Add customer synchronization support in xlvask with caching, filtering, and external ID handling

This commit is contained in:
Jepp9350
2025-06-03 13:52:23 +02:00
parent 5e9f0ade22
commit 0e82d9a7bf
3 changed files with 131 additions and 7 deletions
+27
View File
@@ -1176,4 +1176,31 @@ class users_o extends db
}, $customer_numbers);
}
/**
* @throws Exception
*/
public function getUsersByCustomerNumbers(array $customer_numbers, bool $customerNumberAndUserArray = false): array
{
global $db;
// Get the users by customer numbers
$customer_numbers = array_map('intval', $customer_numbers);
$customer_numbers = implode(',', $customer_numbers);
$sql = "SELECT id, customer_number FROM $this->table WHERE customer_number IN ($customer_numbers)";
$result = $db->query($sql);
// Create an array of user objects
$users = [];
while ($row = $result->fetch_assoc()) {
$user = new users_o();
$user->select((int)$row['id']);
if ($customerNumberAndUserArray) {
// If the customerNumberAndUserArray is true, return an array with the customer number and user object
$users[(int)$row['customer_number']] = $user;
continue;
}
// Otherwise, return the user object
$users[] = $user;
}
return $users;
}
}