diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js index 2a525f18f7f..ed210f8e4fa 100755 --- a/erpnext/setup/doctype/employee/employee.js +++ b/erpnext/setup/doctype/employee/employee.js @@ -46,6 +46,8 @@ frappe.ui.form.on("Employee", { refresh: function (frm) { frm.fields_dict.date_of_birth.datepicker.update({ maxDate: new Date() }); + frm.trigger("add_anniversary_indicator"); + if (!frm.is_new() && !frm.doc.user_id) { frm.add_custom_button(__("Create User"), () => { const dialog = new frappe.ui.Dialog({ @@ -95,6 +97,61 @@ frappe.ui.form.on("Employee", { } }, + date_of_birth: function (frm) { + frm.trigger("add_anniversary_indicator"); + }, + + date_of_joining: function (frm) { + frm.trigger("add_anniversary_indicator"); + }, + + add_anniversary_indicator: function (frm) { + if (!frm.sidebar || !frm.sidebar.sidebar) return; + + let $sidebar = frm.sidebar.sidebar; + let $indicator_section = $sidebar.find(".anniversary-indicator-section"); + + if (!$indicator_section.length) { + $indicator_section = $(` + + `).insertAfter($sidebar.find(".sidebar-meta-details")); + } + + let content = ""; + let today = moment().startOf("day"); + + if (frm.doc.date_of_birth) { + let dob = moment(frm.doc.date_of_birth); + if (dob.date() === today.date() && dob.month() === today.month()) { + content += `
${__( + "Today is their Birthday!" + )}
`; + } + } + + if (frm.doc.date_of_joining) { + let doj = moment(frm.doc.date_of_joining); + if (doj.date() === today.date() && doj.month() === today.month()) { + let years = today.year() - doj.year(); + if (years > 0) { + content += `
${__( + "Today is their {0} Year Work Anniversary!", + [years] + )}
`; + } + } + } + + if (content) { + $indicator_section.find(".anniversary-content").html(content); + $indicator_section.show(); + } else { + $indicator_section.hide(); + } + }, + prefered_contact_email: function (frm) { frm.events.update_contact(frm); }, diff --git a/erpnext/setup/doctype/employee/employee.json b/erpnext/setup/doctype/employee/employee.json index 1d717b2b4c6..b2176bd55e9 100644 --- a/erpnext/setup/doctype/employee/employee.json +++ b/erpnext/setup/doctype/employee/employee.json @@ -351,6 +351,7 @@ { "fieldname": "department", "fieldtype": "Link", + "in_list_view": 1, "in_standard_filter": 1, "label": "Department", "oldfieldname": "department", @@ -380,6 +381,7 @@ { "fieldname": "branch", "fieldtype": "Link", + "in_list_view": 1, "label": "Branch", "oldfieldname": "branch", "oldfieldtype": "Link", @@ -831,7 +833,7 @@ "image_field": "image", "is_tree": 1, "links": [], - "modified": "2026-02-19 17:07:42.691107", + "modified": "2026-02-25 11:23:10.689232", "modified_by": "Administrator", "module": "Setup", "name": "Employee", diff --git a/erpnext/setup/doctype/employee/employee_list.js b/erpnext/setup/doctype/employee/employee_list.js index b50eb381c95..33856414537 100644 --- a/erpnext/setup/doctype/employee/employee_list.js +++ b/erpnext/setup/doctype/employee/employee_list.js @@ -1,11 +1,34 @@ frappe.listview_settings["Employee"] = { add_fields: ["status", "branch", "department", "designation", "image"], filters: [["status", "=", "Active"]], - get_indicator: function (doc) { + get_indicator(doc) { return [ __(doc.status, null, "Employee"), { Active: "green", Inactive: "red", Left: "gray", Suspended: "orange" }[doc.status], "status,=," + doc.status, ]; }, + + onload(listview) { + listview.get_no_result_message = () => { + return ` +
+
+ + + +
+

${__("No Active Employees Found. Prefer importing if you have many records.")}

+

+ + +

+
+ `; + }; + }, };