diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 3aab098e2..dd9e603e4 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -62,6 +62,7 @@ class HotelBookingDetail extends ObjectModel public $adults; public $children; public $child_ages; + public $planned_check_out; public $date_add; public $date_upd; @@ -124,6 +125,7 @@ class HotelBookingDetail extends ObjectModel 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 255, 'required' => true), 'check_in_time' => array('type' => self::TYPE_STRING, 'required' => true), 'check_out_time' => array('type' => self::TYPE_STRING, 'required' => true), + 'planned_check_out' => array('type' => self::TYPE_STRING, 'required' => true), 'adults' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'children' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'child_ages' => array('type' => self::TYPE_STRING), @@ -3665,4 +3667,18 @@ class HotelBookingDetail extends ObjectModel return $result; } + + public function add($auto_date = true, $null_values = false) + { + if (!$this->planned_check_out) { + $objHotelBranchInfo = new HotelBranchInformation((int) $this->id_hotel); + $dateTo = new DateTime($this->date_to); + $timeParts = explode(':', $objHotelBranchInfo->check_out); + $dateTo->setTime($timeParts[0], $timeParts[1]); + + $this->planned_check_out = $dateTo->format('Y-m-d H:i:s'); + } + + return parent::add($auto_date, $null_values); + } } diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 484311892..56b672313 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -153,6 +153,7 @@ class HotelReservationSystemDb `comment` text NOT NULL, `check_in` datetime NOT NULL, `check_out` datetime NOT NULL, + `planned_check_out` datetime NOT NULL, `date_from` datetime NOT NULL, `date_to` datetime NOT NULL, `total_price_tax_excl` decimal(20,6) NOT NULL,