From 7e8a830f42de7409b4d20fcf96f9b3166876e3c6 Mon Sep 17 00:00:00 2001 From: Krishna Shirsath Date: Wed, 25 Feb 2026 13:21:06 +0530 Subject: [PATCH] feat(employee): Add birthdays and work anniversaries indicator in form --- erpnext/setup/doctype/employee/employee.js | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js index 21d67d70e78..4669a9d5b74 100755 --- a/erpnext/setup/doctype/employee/employee.js +++ b/erpnext/setup/doctype/employee/employee.js @@ -45,6 +45,63 @@ frappe.ui.form.on("Employee", { refresh: function (frm) { frm.fields_dict.date_of_birth.datepicker.update({ maxDate: new Date() }); + + frm.trigger("add_anniversary_indicator"); + }, + + 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) {