Skip to content

Commit 0b3c912

Browse files
krishna-254mergify[bot]
authored andcommitted
feat(employee): Add birthdays and work anniversaries indicator in form ,list view enhancements and new empty state.
(cherry picked from commit 4f43f65)
1 parent b014551 commit 0b3c912

3 files changed

Lines changed: 84 additions & 2 deletions

File tree

erpnext/setup/doctype/employee/employee.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ frappe.ui.form.on("Employee", {
4646
refresh: function (frm) {
4747
frm.fields_dict.date_of_birth.datepicker.update({ maxDate: new Date() });
4848

49+
frm.trigger("add_anniversary_indicator");
50+
4951
if (!frm.is_new() && !frm.doc.user_id) {
5052
frm.add_custom_button(__("Create User"), () => {
5153
const dialog = new frappe.ui.Dialog({
@@ -95,6 +97,61 @@ frappe.ui.form.on("Employee", {
9597
}
9698
},
9799

100+
date_of_birth: function (frm) {
101+
frm.trigger("add_anniversary_indicator");
102+
},
103+
104+
date_of_joining: function (frm) {
105+
frm.trigger("add_anniversary_indicator");
106+
},
107+
108+
add_anniversary_indicator: function (frm) {
109+
if (!frm.sidebar || !frm.sidebar.sidebar) return;
110+
111+
let $sidebar = frm.sidebar.sidebar;
112+
let $indicator_section = $sidebar.find(".anniversary-indicator-section");
113+
114+
if (!$indicator_section.length) {
115+
$indicator_section = $(`
116+
<div class="sidebar-section anniversary-indicator-section border-bottom">
117+
<div class="anniversary-content"></div>
118+
</div>
119+
`).insertAfter($sidebar.find(".sidebar-meta-details"));
120+
}
121+
122+
let content = "";
123+
let today = moment().startOf("day");
124+
125+
if (frm.doc.date_of_birth) {
126+
let dob = moment(frm.doc.date_of_birth);
127+
if (dob.date() === today.date() && dob.month() === today.month()) {
128+
content += `<div class="mb-1"><span class="indicator green"></span> ${__(
129+
"Today is their Birthday!"
130+
)}</div>`;
131+
}
132+
}
133+
134+
if (frm.doc.date_of_joining) {
135+
let doj = moment(frm.doc.date_of_joining);
136+
if (doj.date() === today.date() && doj.month() === today.month()) {
137+
let years = today.year() - doj.year();
138+
if (years > 0) {
139+
content += `<div class="mb-1"><span class="indicator green"></span> ${__(
140+
"Today is their {0} Year Work Anniversary!",
141+
[years]
142+
)}</div>`;
143+
}
144+
}
145+
}
146+
147+
if (content) {
148+
$indicator_section.find(".anniversary-content").html(content);
149+
$indicator_section.show();
150+
} else {
151+
$indicator_section.hide();
152+
}
153+
},
154+
98155
prefered_contact_email: function (frm) {
99156
frm.events.update_contact(frm);
100157
},

erpnext/setup/doctype/employee/employee.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@
351351
{
352352
"fieldname": "department",
353353
"fieldtype": "Link",
354+
"in_list_view": 1,
354355
"in_standard_filter": 1,
355356
"label": "Department",
356357
"oldfieldname": "department",
@@ -380,6 +381,7 @@
380381
{
381382
"fieldname": "branch",
382383
"fieldtype": "Link",
384+
"in_list_view": 1,
383385
"label": "Branch",
384386
"oldfieldname": "branch",
385387
"oldfieldtype": "Link",
@@ -831,7 +833,7 @@
831833
"image_field": "image",
832834
"is_tree": 1,
833835
"links": [],
834-
"modified": "2026-02-19 17:07:42.691107",
836+
"modified": "2026-02-25 11:23:10.689232",
835837
"modified_by": "Administrator",
836838
"module": "Setup",
837839
"name": "Employee",
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
frappe.listview_settings["Employee"] = {
22
add_fields: ["status", "branch", "department", "designation", "image"],
33
filters: [["status", "=", "Active"]],
4-
get_indicator: function (doc) {
4+
get_indicator(doc) {
55
return [
66
__(doc.status, null, "Employee"),
77
{ Active: "green", Inactive: "red", Left: "gray", Suspended: "orange" }[doc.status],
88
"status,=," + doc.status,
99
];
1010
},
11+
12+
onload(listview) {
13+
listview.get_no_result_message = () => {
14+
return `
15+
<div class="msg-box no-border">
16+
<div class="mb-4">
17+
<svg class="icon icon-xl" style="stroke: var(--text-light);">
18+
<use href="#icon-small-file"></use>
19+
</svg>
20+
</div>
21+
<p>${__("No Active Employees Found. Prefer importing if you have many records.")}</p>
22+
<p>
23+
<button class="btn btn-primary btn-sm btn-new-doc">
24+
${__("Create New")}
25+
</button>
26+
<button class="btn btn-default btn-sm" onclick="frappe.set_route('List', 'Data Import', {reference_doctype: 'Employee'})">
27+
${__("Import Employees")}
28+
</button>
29+
</p>
30+
</div>
31+
`;
32+
};
33+
},
1134
};

0 commit comments

Comments
 (0)