Normalize handling of pickup_bool in booking data.

Refactored `pickup_bool` parsing to ensure consistent boolean handling across the application. Replaced mixed type checks with explicit boolean conversion and updated relevant logic to improve data reliability. This change avoids potential errors caused by inconsistent input formats.
This commit is contained in:
Jepp9350
2025-01-28 08:44:34 +01:00
parent 37673f4aa6
commit f0747d1966
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -88,6 +88,15 @@ class wordpress_bookings_remote implements wordpress_bookings_remote_i
return null;
}
// Parse the booking pickup bool
// 1 = true, 0 = false
// "true" = true, "false" = false
if ($booking["pickup_bool"] === 1 || $booking["pickup_bool"] === "true") {
$booking["pickup_bool"] = true;
} else {
$booking["pickup_bool"] = false;
}
$this->booking_cache[$booking["id"]] = [
"id" => (int)$booking["id"],
"customer_number" => (int)$booking["customer_number"],
@@ -99,7 +108,7 @@ class wordpress_bookings_remote implements wordpress_bookings_remote_i
"washCertificateEmail" => (string)$booking["washCertificateEmail"],
"date" => (string)$booking["date"],
"department" => (string)$booking["department"],
"pickup_bool" => (boolean)$booking["pickup_bool"] ? 'true' : 'false',
"pickup_bool" => $booking["pickup_bool"],
"notes" => (string)$booking["notes"],
"washCertificateStatus" => (string)$booking["washCertificateStatus"],
"washCertificateUrl" => (string)$booking["washCertificateUrl"],
+1 -1
View File
@@ -143,7 +143,7 @@ class bookings_o extends db
$booking['washCertificateEmail'],
$booking['date'],
$booking['department'],
$booking['pickup_bool'] === 'true' ? 1 : 0,
$booking['pickup_bool'] ? 1 : 0,
$booking['notes'],
$booking['washCertificateStatus'],
$booking['washCertificateUrl'],