Add handling for fixed pricing and tank cleaning transactions with action checks and enhanced customer retrieval
This commit is contained in:
@@ -1135,4 +1135,45 @@ class users_o extends db
|
||||
return $customer_numbers;
|
||||
}
|
||||
|
||||
public function getCustomersWithFixedPricing(): array
|
||||
{
|
||||
global $db;
|
||||
// Get all customers with fixed pricing
|
||||
$sql = "SELECT DISTINCT customer_number FROM customer_fixed_pricing";
|
||||
$result = $db->query($sql);
|
||||
$customer_numbers = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$customer_numbers[] = (int)$row['customer_number'];
|
||||
}
|
||||
return $customer_numbers;
|
||||
}
|
||||
|
||||
public function getCustomersWithTankCleaning(): array
|
||||
{
|
||||
global $db;
|
||||
// Get all customers with tank cleaning
|
||||
$sql = "SELECT DISTINCT user_id FROM customer_attributes WHERE attribute = 'onlyTankCleaning'";
|
||||
$result = $db->query($sql);
|
||||
$customer_numbers = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$customer_numbers[] = (int)$row['user_id'];
|
||||
}
|
||||
// Get the customer numbers from the user IDs
|
||||
$customer_numbers = array_unique($customer_numbers);
|
||||
// Convert user IDs to customer numbers
|
||||
return self::getCustomerNumbersFromUserIds($customer_numbers);
|
||||
}
|
||||
|
||||
private static function getCustomerNumbersFromUserIds(array $user_ids): array
|
||||
{
|
||||
global $db;
|
||||
$customer_numbers = (new users_o)->getFieldsWhere(
|
||||
['id' => $user_ids],
|
||||
['customer_number']
|
||||
);
|
||||
return array_map(function ($user) {
|
||||
return (int)$user['customer_number'];
|
||||
}, $customer_numbers);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user