Add handling for fixed pricing and tank cleaning transactions with action checks and enhanced customer retrieval

This commit is contained in:
Jepp9350
2025-06-02 22:04:57 +02:00
parent 27ca81ba8f
commit 9774b589cc
3 changed files with 217 additions and 1 deletions
+41
View File
@@ -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);
}
}