Handle null values consistently and add deleted_at checks in vehiclesRoute queries

- Updated `db_object_t` to treat both `null` and string `'null'` as null values for filtering.
- Added `deleted_at IS NULL` condition in `vehiclesRoute` booking-related queries to exclude soft-deleted entries.
This commit is contained in:
Jeppe Bundgaard
2025-11-24 15:48:15 +01:00
parent 36d902d833
commit 449908c833
2 changed files with 5 additions and 1 deletions
@@ -829,12 +829,14 @@ class vehiclesRoute
$booking = (new order_bookings_o())->getFieldsWhere([
'reg_1' => $reg,
'order_id' => null,
'deleted_at' => null,
], ['id', 'customer_number', 'reference', 'note']);
// If there is no booking with the tractor reg, check the trailer reg
if (!$booking) {
$booking = (new order_bookings_o())->getFieldsWhere([
'reg_2' => $reg,
'order_id' => null,
'deleted_at' => null,
], ['id', 'customer_number', 'reference', 'note']);
}
// Populate other variables
@@ -973,6 +975,7 @@ class vehiclesRoute
[
'reg_1' => $search,
'order_id' => null,
'deleted_at' => null,
...$filters
],
['reg_1'],
@@ -982,6 +985,7 @@ class vehiclesRoute
[
'reg_2' => $search,
'order_id' => null,
'deleted_at' => null,
...$filters
],
['reg_2'],
+1 -1
View File
@@ -192,7 +192,7 @@ trait db_object_t
$where = [];
foreach ( $fieldsAndValues as $field => $value ) {
// Check if the value is null
if ($value === null) {
if ($value === null || $value === 'null') {
$where[] = "$field IS NULL";
continue;
}