Add customer synchronization support in xlvask with caching, filtering, and external ID handling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user