Refactor bookings handling and update wash certificate logic
Reverted table name from 'bookings_new' to 'bookings' and removed unused sync data structure. Updated routes to use 'wash_certificate_store' instead of 'pdf_store' for wash certificate management. Added 'taulov' as a new department legacy name entry.
This commit is contained in:
@@ -33,7 +33,7 @@ class bookings_o extends db
|
||||
|
||||
public function structure(): void
|
||||
{
|
||||
$this->setTable('bookings_new');
|
||||
$this->setTable('bookings');
|
||||
}
|
||||
|
||||
public function objectChanged(): void
|
||||
@@ -121,11 +121,6 @@ class bookings_o extends db
|
||||
|
||||
public function syncBookings(): array
|
||||
{
|
||||
return [
|
||||
"bookings" => 0,
|
||||
"cancelled" => 0,
|
||||
"parsed" => 0,
|
||||
];
|
||||
global /** @var response $response */
|
||||
$db, $response;
|
||||
$wordpress_bookings_remote = new wordpress_bookings_remote();
|
||||
@@ -244,6 +239,7 @@ class bookings_o extends db
|
||||
'roskilde' => 6,
|
||||
'hvidovre' => 1,
|
||||
'glostrup' => 3,
|
||||
'taulov' => 7,
|
||||
];
|
||||
return $departmentLegacyNames[strtolower($departmentName)] ?? 0;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace routes;
|
||||
|
||||
use classes\authentication;
|
||||
use classes\pdf_store;
|
||||
use classes\response;
|
||||
use objects\bookings_new_o;
|
||||
use classes\wash_certificate_store;
|
||||
use objects\bookings_o;
|
||||
use objects\departments_o;
|
||||
use objects\logs_o;
|
||||
@@ -240,10 +239,10 @@ class bookingsRoute
|
||||
$response->error('You are not allowed to download this wash certificate', 400);
|
||||
}
|
||||
// Check if the booking is completed
|
||||
if (!(new bookings_new_o())->select($id)->exists()) {
|
||||
if (!(new bookings_o())->select($id)->exists()) {
|
||||
$response->error('Booking not found', 404);
|
||||
}
|
||||
$bookings_new = (new bookings_new_o())->select($id);
|
||||
$bookings_new = (new bookings_o())->select($id);
|
||||
$wash_certificate_status = $bookings_new->washCertificateStatus->value();
|
||||
switch ($wash_certificate_status) {
|
||||
case 'pending':
|
||||
@@ -257,16 +256,16 @@ class bookingsRoute
|
||||
$response->error('Wash certificate status is unknown', 500);
|
||||
}
|
||||
// Get the wash certificate object
|
||||
$wash_certificate_object = $bookings_new->washCertificateUrl->value();
|
||||
//$wash_certificate_object = $bookings_new->washCertificateUrl->value();
|
||||
// Create the connection
|
||||
$pdf_storage = new pdf_store();
|
||||
$pdf_storage = new wash_certificate_store();
|
||||
// Check if the wash certificate exists.
|
||||
if (!$pdf_storage->doesObjectExist($wash_certificate_object)) {
|
||||
if (!$pdf_storage->washCertificateExists($bookings_new->id)) {
|
||||
$response->error('Wash certificate not found, but it should exist', 500);
|
||||
}
|
||||
// Generate the download link
|
||||
$response->success(
|
||||
["link" => $pdf_storage->getPresignedUrl($wash_certificate_object)]
|
||||
["link" => $pdf_storage->getWashCertificateDownload($bookings_new->id)]
|
||||
);
|
||||
},
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user