diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index 46a0376f..49c825f8 100644 --- a/src/controllers/departmentController.js +++ b/src/controllers/departmentController.js @@ -434,7 +434,19 @@ exports.addDepartment = async (request, reply) => { let finalReportingManagerEmail = reportingManager_email; if (reportingManager?.toLowerCase() === "self") { - finalReportingManager = `${firstName || ""} ${lastName || ""} - (${phone}) - ${city}`; + // Default format + let managerString = `${firstName || ""} ${lastName || ""} - (${phone}) - ${city}`; + + // If departmentName is "Head Office" or "Branch Office" → add departmentName + if ( + ["head office", "branch office"].includes( + (departmentName || "").toLowerCase().trim() + ) + ) { + managerString += ` - ${departmentName}`; + } + + finalReportingManager = managerString; finalReportingManagerMobile = phone; finalReportingManagerEmail = email; } @@ -481,6 +493,7 @@ exports.addDepartment = async (request, reply) => { } }; + exports.getDetails = async (request, reply) => { try {