diff --git a/LEAF_Nexus/sources/Employee.php b/LEAF_Nexus/sources/Employee.php index a06185083..958b34a66 100644 --- a/LEAF_Nexus/sources/Employee.php +++ b/LEAF_Nexus/sources/Employee.php @@ -258,8 +258,12 @@ private function updateEmployeeDataBatch(array $local_employees): array $this->prepareArrays($national_employee_uids, $local_array, $national_employees_list, $local_employee_array); + $users = $this->updateDisabledEmployees(); + $local_deleted_employees = array_diff(array_column($local_employees_uid, 'userName'), array_column($national_employees_list, 'userName')); + $local_deleted_employees = array_merge($local_deleted_employees, $users); + if (!empty($local_deleted_employees)) { $results[] = $this->disableEmployees($local_deleted_employees); @@ -284,6 +288,25 @@ private function updateEmployeeDataBatch(array $local_employees): array return $results; } + private function updateDisabledEmployees(): array + { + $vars = array(); + $sql = 'SELECT `userName` + FROM `employee` + WHERE `deleted` > 0 + AND LEFT(`userName`, 9) <> "disabled_"'; + + $res = $this->db->prepared_query($sql, $vars); + + $userNames = array(); + + foreach ($res as $user) { + $userNames[] = $user['userName']; + } + + return $userNames; + } + private function disablePortalTables(): void { $portals = $this->getPortals();