diff --git a/services/nginx/app/objects/orders_o.php b/services/nginx/app/objects/orders_o.php index f837a61a..511ee9cc 100644 --- a/services/nginx/app/objects/orders_o.php +++ b/services/nginx/app/objects/orders_o.php @@ -4,6 +4,7 @@ namespace objects; use attachments\helpers\attachment_content; use classes\db; +use classes\email; use classes\pdf_generator; use classes\motorapi; use classes\object_property; @@ -1497,4 +1498,20 @@ class orders_o extends db self::requireSelected(); return !(new departments_o())->select((int)$this->department_id->value())->isExcludedFromInvoicing(); } + + /** + * If the order is linked to a booking, get the booking object + * @return order_bookings_o|null The booking object if linked, null otherwise + * @throws Exception + */ + public function getOrderBooking(): order_bookings_o|null + { + self::requireSelected(); + if ((int)$this->booking_id->value() <= 0) { + return null; + } + $booking = new order_bookings_o(); + $booking->select((int)$this->booking_id->value()); + return $booking->exists() ? $booking : null; + } } \ No newline at end of file