From 480d52c6f3d15ed7f00eb7e71b67a7a64e10afcd Mon Sep 17 00:00:00 2001 From: Diksha Date: Mon, 23 Dec 2019 15:43:20 +0530 Subject: [PATCH] feat(attendance): add work from home option in status --- erpnext/hr/doctype/attendance/attendance.json | 34 ++++++++++--------- erpnext/hr/doctype/attendance/attendance.py | 2 +- .../hr/doctype/attendance/attendance_list.js | 13 ++++--- .../employee_attendance_tool.js | 31 +++++++++++++++-- 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/erpnext/hr/doctype/attendance/attendance.json b/erpnext/hr/doctype/attendance/attendance.json index bc89b368d3..ab2dc4a90f 100644 --- a/erpnext/hr/doctype/attendance/attendance.json +++ b/erpnext/hr/doctype/attendance/attendance.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_import": 1, "autoname": "naming_series:", "creation": "2013-01-10 16:34:13", @@ -63,6 +64,14 @@ "oldfieldname": "employee_name", "oldfieldtype": "Data" }, + { + "depends_on": "working_hours", + "fieldname": "working_hours", + "fieldtype": "Float", + "label": "Working Hours", + "precision": "1", + "read_only": 1 + }, { "default": "Present", "fieldname": "status", @@ -72,7 +81,7 @@ "no_copy": 1, "oldfieldname": "status", "oldfieldtype": "Select", - "options": "\nPresent\nAbsent\nOn Leave\nHalf Day", + "options": "\nPresent\nAbsent\nOn Leave\nHalf Day\nWork From Home", "reqd": 1, "search_index": 1 }, @@ -126,6 +135,12 @@ "options": "Department", "read_only": 1 }, + { + "fieldname": "shift", + "fieldtype": "Link", + "label": "Shift", + "options": "Shift Type" + }, { "fieldname": "attendance_request", "fieldtype": "Link", @@ -143,20 +158,6 @@ "print_hide": 1, "read_only": 1 }, - { - "depends_on": "working_hours", - "fieldname": "working_hours", - "fieldtype": "Float", - "label": "Working Hours", - "precision": "1", - "read_only": 1 - }, - { - "fieldname": "shift", - "fieldtype": "Link", - "label": "Shift", - "options": "Shift Type" - }, { "default": "0", "fieldname": "late_entry", @@ -173,7 +174,8 @@ "icon": "fa fa-ok", "idx": 1, "is_submittable": 1, - "modified": "2019-07-29 20:35:40.845422", + "links": [], + "modified": "2020-01-27 20:25:29.572281", "modified_by": "Administrator", "module": "HR", "name": "Attendance", diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py index c3fbed599b..9e965dbc39 100644 --- a/erpnext/hr/doctype/attendance/attendance.py +++ b/erpnext/hr/doctype/attendance/attendance.py @@ -52,7 +52,7 @@ class Attendance(Document): def validate(self): from erpnext.controllers.status_updater import validate_status - validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day"]) + validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day", "Work From Home"]) self.validate_attendance_date() self.validate_duplicate_record() self.check_leave_record() diff --git a/erpnext/hr/doctype/attendance/attendance_list.js b/erpnext/hr/doctype/attendance/attendance_list.js index 1161703003..6df3dbd784 100644 --- a/erpnext/hr/doctype/attendance/attendance_list.js +++ b/erpnext/hr/doctype/attendance/attendance_list.js @@ -1,7 +1,13 @@ frappe.listview_settings['Attendance'] = { add_fields: ["status", "attendance_date"], - get_indicator: function(doc) { - return [__(doc.status), doc.status=="Present" ? "green" : "darkgrey", "status,=," + doc.status]; + get_indicator: function (doc) { + if (["Present", "Work From Home"].includes(doc.status)) { + return [__(doc.status), "green", "status,=," + doc.status]; + } else if (["Absent", "On Leave"].includes(doc.status)) { + return [__(doc.status), "red", "status,=," + doc.status]; + } else if (doc.status == "Half Day") { + return [__(doc.status), "orange", "status,=," + doc.status]; + } }, onload: function(list_view) { let me = this; @@ -44,7 +50,7 @@ frappe.listview_settings['Attendance'] = { label: __("Status"), fieldtype: "Select", fieldname: "status", - options: ["Present", "Absent", "Half Day"], + options: ["Present", "Absent", "Half Day", "Work From Home"], hidden:1, reqd: 1, @@ -102,5 +108,4 @@ frappe.listview_settings['Attendance'] = { }); }); } - }; diff --git a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js index 22ba5ad473..3205a92b1b 100644 --- a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js +++ b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js @@ -124,8 +124,10 @@ erpnext.EmployeeSelector = Class.extend({ var mark_employee_toolbar = $('
\ \ - \ -
') + \ + \ + \ + '); employee_toolbar.find(".btn-add") .html(__('Check all')) @@ -224,6 +226,31 @@ erpnext.EmployeeSelector = Class.extend({ }); + mark_employee_toolbar.find(".btn-mark-work-from-home") + .html(__('Mark Work From Home')) + .on("click", function() { + var employee_work_from_home = []; + $(me.wrapper).find('input[type="checkbox"]').each(function(i, check) { + if($(check).is(":checked")) { + employee_work_from_home.push(employee[i]); + } + }); + frappe.call({ + method: "erpnext.hr.doctype.employee_attendance_tool.employee_attendance_tool.mark_employee_attendance", + args:{ + "employee_list":employee_work_from_home, + "status":"Work From Home", + "date":frm.doc.date, + "company":frm.doc.company + }, + + callback: function(r) { + erpnext.employee_attendance_tool.load_employees(frm); + + } + }); + }); + var row; $.each(employee, function(i, m) { if (i===0 || (i % 4) === 0) {