Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 41 additions & 27 deletions audit_management/audit_management/doctype/my_audits/my_audits.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ frappe.ui.form.on("My Audits", {
.map((r) => {
return {
name: r.stage_name,
label: `${r.stage_name} (${r.employee_name || "Unassigned"})`,
employee_name: r.employee_name || "Unassigned",
status: r.status,
is_sent: !!r.status
};
Expand All @@ -1150,40 +1150,55 @@ frappe.ui.form.on("My Audits", {

let html_content = `
<div style="padding: 10px;">
<div style="border-bottom: 1px solid #d1d8dd; padding-bottom: 10px; margin-bottom: 10px;">
<div style="border-bottom: 1px solid #d1d8dd; padding-bottom: 10px; margin-bottom: 15px;">
<label class="checkbox-inline" style="font-weight: bold; cursor: pointer; display: flex; align-items: center;">
<input type="checkbox" id="select-all-stages" style="margin-right: 10px; width: 18px; height: 18px;">
<span style="font-size: 14px;">${__("Send to All Stages")}</span>
<span style="font-size: 14px;">${__("Select All Stages")}</span>
</label>
</div>
<div id="stage-checkboxes-list" style="max-height: 300px; overflow-y: auto;">
${stages
.map(
(s) => `
<div style="margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;">
<label class="checkbox-inline" style="cursor: pointer; display: flex; align-items: center; flex-grow: 1;">
<input type="checkbox" class="stage-checkbox" value="${s.name}"
${s.is_sent ? "checked disabled" : ""}
style="margin-right: 10px; width: 16px; height: 16px;">
<span style="font-size: 13px; color: ${s.is_sent ? "#28a745" : "inherit"};">
${s.label} ${s.is_sent ? `<small class="text-muted" style="margin-left: 5px;">(Already Sent: ${s.status})</small>` : ""}
</span>
</label>
${s.status === "Pending" ? `
<span class="rollback-btn text-danger" data-stage="${s.name}" title="Rollback Stage" style="cursor: pointer; font-weight: bold; font-size: 20px; margin-left: 10px; line-height: 1;">
&times;
</span>
` : ""}
</div>
`,
)
.join("")}
<div style="max-height: 450px; overflow-y: auto;">
<table class="table table-bordered table-hover" style="font-size: 13px;">
<thead style="background-color: #f8f9fa;">
<tr>
<th style="width: 40px; text-align: center;">#</th>
<th style="width: 150px;">${__("Stage Name")}</th>
<th style="width: 200px;">${__("User Name")}</th>
<th style="width: 180px;">${__("Status / Action")}</th>
</tr>
</thead>
<tbody id="stage-table-body">
${stages.map((s) => `
<tr>
<td style="text-align: center; vertical-align: middle;">
<input type="checkbox" class="stage-checkbox" value="${s.name}"
${s.is_sent ? "checked disabled" : ""}
style="width: 16px; height: 16px;">
</td>
<td style="vertical-align: middle; font-weight: 500;">${s.name}</td>
<td style="vertical-align: middle;">${s.employee_name}</td>
<td style="vertical-align: middle;">
<div style="display: flex; align-items: center; justify-content: space-between;">
<span style="color: ${s.is_sent ? "#28a745" : "#6c757d"}; font-weight: ${s.is_sent ? "bold" : "normal"};">
${s.is_sent ? s.status : __("Not Sent")}
</span>
${["Pending", "No Response"].includes(s.status) ? `
<span class="rollback-btn text-danger" data-stage="${s.name}" title="Rollback Stage" style="cursor: pointer; font-weight: bold; font-size: 22px; line-height: 1; margin-left: 10px;">
&times;
</span>
` : ""}
</div>
</td>
</tr>
`).join("")}
</tbody>
</table>
</div>
</div>
`;

let d = new frappe.ui.Dialog({
title: __("Raise Audit Request"),
title: __("Send Audit Query"),
size: "extra-large",
fields: [
{
fieldname: "stagename_html",
Expand All @@ -1194,7 +1209,6 @@ frappe.ui.form.on("My Audits", {
primary_action_label: __("Submit"),
primary_action: function () {
let selected_stages = [];
// Collect only newly checked ones (that are not disabled)
d.$wrapper.find(".stage-checkbox:checked:not(:disabled)").each(function () {
selected_stages.push($(this).val());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ def rollback_stage(docname, stagename):

for row in doc.audit_stages:
if row.stage_name == stagename:
if row.status != "Pending":
frappe.throw(_("Only Pending stages can be rolled back. {0} is currently {1}.").format(stagename, row.status))
if row.status not in ["Pending", "No Response"]:
frappe.throw(_("Only Pending or No Response stages can be rolled back. {0} is currently {1}.").format(stagename, row.status))

# 1. Revoke access first (bypass permission checks for administrative rollback)
if row.user_id:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def get_columns():
{"label": "HR Response", "fieldname": "hr_response_box", "fieldtype": "Data", "width": 180},
{"label": "COO Name", "fieldname": "coo_name", "fieldtype": "Data", "width": 120},
{"label": "COO Response", "fieldname": "coo_response_box", "fieldtype": "Data", "width": 180},
{"label": "CFO Name", "fieldname": "cfo_name", "fieldtype": "Data", "width": 120},
{"label": "CFO Response", "fieldname": "cfo_response_box", "fieldtype": "Data", "width": 180},
{"label": "CHRO Name", "fieldname": "chro_name", "fieldtype": "Data", "width": 120},
{"label": "CHRO Response", "fieldname": "chro_response_box", "fieldtype": "Data", "width": 180},
{"label": "CEO Name", "fieldname": "ceo_name", "fieldtype": "Data", "width": 120},
{"label": "CEO Response", "fieldname": "ceo_response_box", "fieldtype": "Data", "width": 180},
]
Expand Down Expand Up @@ -155,8 +151,6 @@ def get_data(filters):
gm_name, gm_response_box,
hr_name, hr_response_box,
coo_name, coo_response_box,
cfo_name, cfo_response_box,
chro_name, chro_response_box,
ceo_name, ceo_response_box
FROM `tabMy Audits`
{where_clause}
Expand Down
Loading