Punching, Dedupe and CutOff Features Done

This commit is contained in:
2026-08-12 07:46:24 +05:30
parent b862a3f686
commit c835a9deb0
76 changed files with 4720 additions and 3695 deletions

View File

@@ -0,0 +1,101 @@
(() => {
"use strict";
const form = document.getElementById("dedupeDetails");
if (!form) return;
const state = { EAR: { rows: [], index: 0 }, NEG: { rows: [], index: 0 } };
const value = (id, next) => {
const element = document.getElementById(id);
if (element && next !== undefined) element.value = next || "";
return element?.value || "";
};
const notify = (type, message, code, referenceId) =>
window.CygnusNotifications?.show({ type, message, code, referenceId });
function address(record) {
return record?.residenceAddress || record?.officeAddress || "";
}
function render(type) {
const group = state[type];
const prefix = type === "EAR" ? "ear" : "neg";
const record = group.rows[group.index];
document.getElementById(type === "EAR" ? "efound" : "nfound").textContent =
group.rows.length ? `(${group.index + 1} / ${group.rows.length} Match Found)` : "(No Match Found)";
document.getElementById(type === "EAR" ? "efoundon" : "nfoundon").textContent =
record ? `Match Found On: ${record.foundOn || ""}` : "No Match Found";
value(`${prefix}name`, record?.customerName);
value(`${prefix}dob`, record?.dob);
value(`${prefix}address`, record ? address(record) : "");
value(`${prefix}rphone`, record?.residencePhone);
value(`${prefix}ophone`, record?.officePhone);
value(`${prefix}mobile`, record?.mobile);
}
async function load() {
const uuid = value("uuid");
try {
const response = await fetch(`${form.dataset.recordsUrl}?uuid=${encodeURIComponent(uuid)}`, {
credentials: "same-origin", headers: { Accept: "application/json" }
});
const payload = await response.json();
if (!response.ok || !payload.success) throw payload.message || {};
state.EAR.rows = payload.data.filter((row) => row.dedupeType === "EAR");
state.NEG.rows = payload.data.filter((row) => row.dedupeType === "NEG");
render("EAR");
render("NEG");
} catch (error) {
notify("danger", error.message || "Matching records could not be loaded.", error.code, error.referenceId);
}
}
window.findRecord = (operation, section) => {
const group = state[section === 1 ? "EAR" : "NEG"];
if (!group.rows.length) return;
if (operation === 1) group.index = 0;
if (operation === 2) group.index = Math.max(0, group.index - 1);
if (operation === 3) group.index = Math.min(group.rows.length - 1, group.index + 1);
if (operation === 4) group.index = group.rows.length - 1;
render(section === 1 ? "EAR" : "NEG");
};
window.addRemarks = (section, elementId) => {
const group = state[section === 1 ? "EAR" : "NEG"];
const record = group.rows[group.index];
if (!record) return notify("warning", "No match found.", "DDP-4001");
const current = value(elementId).trim();
value(elementId, `${current}${current ? "\n\n" : ""}${record.remarks || ""}`);
};
window.editRemarks = (elementId, section) => {
const group = state[section === 1 ? "EAR" : "NEG"];
const remarks = group.rows[group.index]?.remarks;
if (remarks && window.confirm("Remove the selected match remarks?")) {
value(elementId, value(elementId).replace(remarks, "").trim());
}
};
form.addEventListener("submit", async (event) => {
event.preventDefault();
const body = {
uuid: value("uuid"), sessuuid: value("sessuuid"),
earremarks: value("earremarks"), negremarks: value("negremarks")
};
try {
const response = await fetch(form.action, {
method: "POST", credentials: "same-origin",
headers: { "Content-Type": "application/json", Accept: "application/json" },
body: JSON.stringify(body)
});
const payload = await response.json();
if (!response.ok || !payload.success) throw payload.message || {};
notify("success", payload.message.message, payload.message.code);
window.setTimeout(() => window.MatrixDialog?.close(1), 300);
} catch (error) {
notify("danger", error.message || "Dedupe details could not be saved.", error.code, error.referenceId);
}
});
load();
})();