Refactor booking status handling and enhance file checks.

Updated booking logic to include completed bookings in cancellation handling. Added `isFileInStore` to improve file existence checks in the wash certificate store. Adjusted file server logic to use the new method for enhanced clarity and maintenance.
This commit is contained in:
Jepp9350
2025-02-03 09:34:09 +01:00
parent bcbb4c0164
commit 1e8c60e33a
3 changed files with 11 additions and 5 deletions
@@ -46,4 +46,9 @@ class wash_certificate_store implements minio_wash_certificates_i
]);
return $path;
}
public function isFileInStore(string $file): bool
{
return self::getS3Client()->doesObjectExist(self::getBucket(), $file);
}
}
+3 -2
View File
@@ -7,8 +7,9 @@ $file = str_replace('/modules/washcertificates/output/certificates/', '', $file)
$wash_certificate_store = new \classes\wash_certificate_store();
// Check if the certificate exists
if (!$wash_certificate_store->washCertificateExists($file)) {
header('HTTP/1.1 404 Not Found');
if (!$wash_certificate_store->isFileInStore($file)) {
echo 'Certificate not found in store';
//header('HTTP/1.1 404 Not Found');
exit;
}
+3 -3
View File
@@ -120,7 +120,7 @@ class bookings_o extends db
// Parse the bookings
$parsed_bookings = $wordpress_bookings_remote->parse_bookings($bookings);
// Remove the cancelled bookings from the $parsed_bookings array
$cancelled_bookings = $this->getAllCancelledBookings();
$cancelled_bookings = $this->getAllCancelledOrCompletedBookings();
foreach ( $cancelled_bookings as $cancelled_booking ) {
// Remove the cancelled booking from the parsed bookings
foreach ( $parsed_bookings as $key => $parsed_booking ) {
@@ -157,11 +157,11 @@ class bookings_o extends db
];
}
public function getAllCancelledBookings(): array
public function getAllCancelledOrCompletedBookings(): array
{
global $db;
// Get all the cancelled bookings
$sql = "SELECT * FROM $this->table WHERE status = 'cancelled' OR washCertificateStatus = 'cancelled'";
$sql = "SELECT * FROM $this->table WHERE status = 'cancelled' OR status = 'completed'";
$result = $db->query($sql);
return $db->fetch_all($result);
}