mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-02 06:29:54 +00:00
refactor(employee): remove anniversary indicator logic from employee form
(cherry picked from commit 1f19175fef)
This commit is contained in:
committed by
Mergify
parent
eadf78d694
commit
c33cd5ce15
@@ -46,8 +46,6 @@ 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({
|
||||
@@ -97,61 +95,6 @@ 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 = $(`
|
||||
<div class="sidebar-section anniversary-indicator-section border-bottom">
|
||||
<div class="anniversary-content"></div>
|
||||
</div>
|
||||
`).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 += `<div class="mb-1"><span class="indicator green"></span> ${__(
|
||||
"Today is their Birthday!"
|
||||
)}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
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 += `<div class="mb-1"><span class="indicator green"></span> ${__(
|
||||
"Today is their {0} Year Work Anniversary!",
|
||||
[years]
|
||||
)}</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user