diff --git a/config.example.php b/config.example.php index 840cb42c..73304a39 100644 --- a/config.example.php +++ b/config.example.php @@ -21,4 +21,5 @@ if ($DEBUG && !$USE_PROD_ECONOMIC_IN_DEBUG) { 'app_secret_token' => '' // Development Economic API secret token ]; } -$WORDPRESS_STATIC_TOKEN = ''; // Static token used to authenticate the WordPress plugin \ No newline at end of file +$WORDPRESS_STATIC_TOKEN = ''; // Static token used to authenticate the WordPress plugin +$EMAIL_WASH_CERTIFICATE_TOKEN = ''; // Token used to authenticate the wash certificate generator \ No newline at end of file diff --git a/routes/bookingsRoute.php b/routes/bookingsRoute.php index 319be7f4..76c1130b 100644 --- a/routes/bookingsRoute.php +++ b/routes/bookingsRoute.php @@ -18,7 +18,9 @@ class bookingsRoute /** All bookings */ $this->get('/bookings', function () { // Require the user to be logged in - global /** @var response $response */ + global + /** @var response $response */ + $EMAIL_WASH_CERTIFICATE_TOKEN, $response; $this->requirePermission('list_bookings'); // Get the user object @@ -27,6 +29,10 @@ class bookingsRoute if ($user) { // Log the incident (new logs_o())->add('bookings', 'global', 1, $user->id, 'LIST_BOOKINGS', 'Successfully listed bookings'); + // If the user has the permission to issue wash certificates, add the wash certificate key to the response + if ($user->hasPermission('issue_wash_certificates')) { + $response->add_meta('wash_certificate_token', $EMAIL_WASH_CERTIFICATE_TOKEN); + } // Return the list of bookings $response->success( (new bookings_o())->listObjectsWithPaginationIfSet() @@ -103,7 +109,7 @@ class bookingsRoute (string)$booking['washCertificateEmail'], (string)$booking['date'], (string)$booking['department'], - (bool)$booking['pickup_bool'], + (string)$booking['pickup_bool'], (string)$booking['notes'], (string)$booking['washCertificateStatus'], (string)$booking['washCertificateUrl'], diff --git a/traits/db_object_t.php b/traits/db_object_t.php index e2f8211f..bbb26d3c 100644 --- a/traits/db_object_t.php +++ b/traits/db_object_t.php @@ -123,7 +123,12 @@ trait db_object_t $searchQuery = 'WHERE '; } foreach ( $filters as $field => $value ) { - $searchQuery .= "$field = $value AND "; + // If the value is a number, do not add quotes + if (is_numeric($value)) { + $searchQuery .= "$field = $value AND "; + } else { + $searchQuery .= "$field = '$value' AND "; + } } // If the deleted_at column exists, filter out the deleted objects if (in_array('deleted_at', $searchfields)) {