From 71dbfe430ef04b1cd4d58636d7fb188bf1dafafe Mon Sep 17 00:00:00 2001 From: gamonoid Date: Sun, 3 Sep 2017 21:35:00 +0200 Subject: [PATCH] Code fixes for date time change --- data/raml/examples/employee.json | 4 ++-- src/Attendance/Admin/Api/AttendanceActionManager.php | 2 +- src/Attendance/User/Api/AttendanceActionManager.php | 2 +- src/Employees/Common/Model/Employee.php | 2 +- src/Reports/Admin/Reports/ActiveEmployeeReport.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/raml/examples/employee.json b/data/raml/examples/employee.json index 7d21ad7c..a242a205 100644 --- a/data/raml/examples/employee.json +++ b/data/raml/examples/employee.json @@ -43,7 +43,7 @@ "custom8": null, "custom9": null, "custom10": null, - "termination_date": "0000-00-00", + "termination_date": null, "notes": null, "status": "Active", "ethnicity": null, @@ -72,4 +72,4 @@ "supervisor_Name_id": [], "supervisor_Name": "IceHrm Employee", "image": "http:\/\/app.app.dev\/images\/user_female.png" -} \ No newline at end of file +} diff --git a/src/Attendance/Admin/Api/AttendanceActionManager.php b/src/Attendance/Admin/Api/AttendanceActionManager.php index 84ab50af..e735a96b 100644 --- a/src/Attendance/Admin/Api/AttendanceActionManager.php +++ b/src/Attendance/Admin/Api/AttendanceActionManager.php @@ -106,7 +106,7 @@ class AttendanceActionManager extends SubActionManager } $attendance->in_time = $inDateTime; if (empty($outDateTime)) { - $attendance->out_time = "0000-00-00 00:00:00"; + $attendance->out_time = null; } else { $attendance->out_time = $outDateTime; } diff --git a/src/Attendance/User/Api/AttendanceActionManager.php b/src/Attendance/User/Api/AttendanceActionManager.php index 66aa530d..0024db56 100644 --- a/src/Attendance/User/Api/AttendanceActionManager.php +++ b/src/Attendance/User/Api/AttendanceActionManager.php @@ -134,7 +134,7 @@ class AttendanceActionManager extends SubActionManager $this->baseService->audit(IceConstants::AUDIT_ACTION, "Punch Out \ time:".$openPunch->out_time); } else { $openPunch->in_time = $dateTime; - $openPunch->out_time = '0000-00-00 00:00:00'; + $openPunch->out_time = null; $openPunch->note = $req->note; $openPunch->image_in = $req->image; $openPunch->employee = $employee->id; diff --git a/src/Employees/Common/Model/Employee.php b/src/Employees/Common/Model/Employee.php index c272adb9..33ca915a 100644 --- a/src/Employees/Common/Model/Employee.php +++ b/src/Employees/Common/Model/Employee.php @@ -98,7 +98,7 @@ class Employee extends BaseModel continue; } - if (empty($obj->$k) && $oldObjOrig->$k = '0000-00-00') { + if (empty($obj->$k) && ($oldObjOrig->$k = '0000-00-00' || empty($oldObjOrig->$k))) { continue; } diff --git a/src/Reports/Admin/Reports/ActiveEmployeeReport.php b/src/Reports/Admin/Reports/ActiveEmployeeReport.php index 14d96f42..c96abec9 100644 --- a/src/Reports/Admin/Reports/ActiveEmployeeReport.php +++ b/src/Reports/Admin/Reports/ActiveEmployeeReport.php @@ -52,10 +52,10 @@ FROM Employees e"; if (empty($request['department']) || $request['department'] == "NULL") { $params = array(); - $query = "where ((termination_date = '0001-01-01 00:00:00' or termination_date = '0000-00-00 00:00:00') and joined_date < NOW()) or (termination_date > NOW() and joined_date < NOW())"; + $query = "where ((termination_date is NULL or termination_date = '0001-01-01 00:00:00' or termination_date = '0000-00-00 00:00:00') and joined_date < NOW()) or (termination_date > NOW() and joined_date < NOW())"; } else { $depts = $this->getChildCompanyStuctures($request['department']); - $query = "where department in (".implode(",", $depts).") and (((termination_date = '0001-01-01 00:00:00' or termination_date = '0000-00-00 00:00:00') and joined_date < NOW()) or (termination_date > NOW() and joined_date < NOW()))"; + $query = "where department in (".implode(",", $depts).") and (((termination_date is NULL or termination_date = '0001-01-01 00:00:00' or termination_date = '0000-00-00 00:00:00') and joined_date < NOW()) or (termination_date > NOW() and joined_date < NOW()))"; }