Skip to content

Commit

Permalink
Leaf 4486 - fixing an error
Browse files Browse the repository at this point in the history
  • Loading branch information
jampaul3 committed Dec 18, 2024
1 parent 188ecae commit 80826d5
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions LEAF_Nexus/sources/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ private function updateEmployeeDataBatch(array $local_employees): array

$this->prepareArrays($national_employee_uids, $local_array, $national_employees_list, $local_employee_array);

$local_deleted_employees = array_diff(array_column($local_employees_uid, 'userName'), array_column($national_employees_list, 'userName'));

if (!empty($local_deleted_employees)) {
$results[] = $this->disableEmployees($local_deleted_employees);

$this->disableAllTables();
$this->disablePortalTables();
}

if (!empty($local_array)) {
$results[] = $this->batchEmployeeUpdate($local_array);
}
Expand All @@ -270,15 +279,10 @@ private function updateEmployeeDataBatch(array $local_employees): array
$results[] = $this->batchEmployeeDataUpdate($local_data_array);
}

$users = $this->updateDisabledEmployees();

$local_deleted_employees = array_diff(array_column($local_employees_uid, 'userName'), array_column($national_employees_list, 'userName'));
$users = $this->updateNationalDisabledEmployees();

$local_deleted_employees = array_merge($local_deleted_employees, $users);
error_log(print_r($local_deleted_employees, true), 3, '/var/www/php-logs/testing.log');

if (!empty($local_deleted_employees)) {
$results[] = $this->disableEmployees($local_deleted_employees);
if (!empty($users)) {
$results[] = $this->disableEmployees($users);

$this->disableAllTables();
$this->disablePortalTables();
Expand All @@ -288,7 +292,7 @@ private function updateEmployeeDataBatch(array $local_employees): array
return $results;
}

private function updateDisabledEmployees(): array
private function updateNationalDisabledEmployees(): array
{
$vars = array();
$sql = 'SELECT `userName`
Expand Down Expand Up @@ -401,10 +405,10 @@ private function getPortals(): array
return $return_value;
}

private function disableAllTables(int $deletedAgo = 600): void
private function disableAllTables(): void
{
// get all the newly disabled users
$this->disabledUsers = $this->getNewlyDisabledUsers($deletedAgo);
$this->disabledUsers = $this->getNewlyDisabledUsers();

$sql = '';

Expand Down Expand Up @@ -461,12 +465,13 @@ private function enableAllTables(string $userName): void
$this->db->prepared_query($sql, $vars);
}

private function getNewlyDisabledUsers(int $deletedAgo = 600): array
private function getNewlyDisabledUsers(): array
{
$vars = array(':deleteTime' => time() - $deletedAgo);
$vars = array(':deleteTime' => 0);
$sql = 'SELECT `userName`
FROM `employee`
WHERE `deleted` > :deleteTime';
WHERE `deleted` > :deleteTime
AND LEFT(`userName`, 9) <> "disabled_"';

$return_value = $this->db->prepared_query($sql, $vars);

Expand Down Expand Up @@ -1063,7 +1068,7 @@ public function disableAccount($empUID)

$this->disableEmployees(array($res[0]['userName']));

$this->disableAllTables(60);
$this->disableAllTables();
$this->disablePortalTables();

return true;
Expand Down

0 comments on commit 80826d5

Please sign in to comment.