diff --git a/classes/order/Order.php b/classes/order/Order.php index dd26b7321..a39e441cd 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -3057,6 +3057,14 @@ class OrderCore extends ObjectModel public function getOrderCompleteRefundStatus() { + $objHotelBooking = new HotelBookingdetail(); + foreach ($objHotelBooking->getOrderCurrentDataByOrderId($this->id) as $booking) { + if ($booking['id_status'] != HotelBookingDetail::STATUS_CANCELLED + && $booking['id_status'] != HotelBookingDetail::STATUS_NO_SHOW + ) { + return 0; + } + } // any completed refund anywhere in the order takes priority over // No-show/Cancelled and is sticky (a refund never un-completes) if ((new OrderReturn())->hasAnyCompletedRefund($this->id)) { diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 9d99916d5..80305d922 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -356,7 +356,7 @@ class OrderReturnCore extends ObjectModel } if ($onlyBookingIds) { - return array_column($returnDetails, 'id_htl_booking'); + return array_values(array_unique(array_column($returnDetails, 'id_htl_booking'))); } if ($customerView) { diff --git a/classes/order/OrderReturnDetail.php b/classes/order/OrderReturnDetail.php index 2d7b8571e..fa227c20a 100644 --- a/classes/order/OrderReturnDetail.php +++ b/classes/order/OrderReturnDetail.php @@ -77,8 +77,11 @@ class OrderReturnDetailCore extends ObjectModel public static function deleteReturnDetailByIdBookingDetail($idOrder, $idHtlBooking) { - if (Validate::isLoadedObject($objOrderReturnDetail = OrderReturnDetail::getReturnDetailByIdBookingDetail($idHtlBooking))) { - if ($objOrderReturnDetail->delete()) { + $orderReturnDetails = OrderReturn::getOrdersReturnDetail($idOrder, 0, $idHtlBooking); + + foreach ($orderReturnDetails as $row) { + $objOrderReturnDetail = new OrderReturnDetail((int) $row['id_order_return_detail']); + if (Validate::isLoadedObject($objOrderReturnDetail) && $objOrderReturnDetail->delete()) { $objOrderReturn = new OrderReturn(); if (empty($objOrderReturn->getOrderRefundRequestedBookings($idOrder, $objOrderReturnDetail->id_order_return, true))) { $objOrderReturn = new OrderReturn($objOrderReturnDetail->id_order_return); diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 6659043d4..9238869c6 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1720,10 +1720,7 @@ class HotelBookingDetail extends ObjectModel $objHistory->id_status_to = $newStatus; $objHistory->id_employee = isset($params['id_employee']) ? (int) $params['id_employee'] : null; $objHistory->id_customer = isset($params['id_customer']) ? (int) $params['id_customer'] : null; - $remark = isset($params['remark']) ? $params['remark'] : ''; - foreach (Language::getLanguages(true) as $lang) { - $objHistory->remark[$lang['id_lang']] = $remark; - } + $objHistory->remark = isset($params['remark']) ? $params['remark'] : ''; $objHistory->save(); Hook::exec('actionBookingStatusAfter', array( diff --git a/modules/hotelreservationsystem/classes/HotelBookingStatusHistory.php b/modules/hotelreservationsystem/classes/HotelBookingStatusHistory.php index e1c3e9b6c..91d9631a7 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingStatusHistory.php +++ b/modules/hotelreservationsystem/classes/HotelBookingStatusHistory.php @@ -37,34 +37,26 @@ class HotelBookingStatusHistory extends ObjectModel public static $definition = array( 'table' => 'htl_booking_status_history', 'primary' => 'id_booking_status_history', - 'multilang' => true, 'fields' => array( 'id_htl_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_status_from' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true), 'id_status_to' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true), + 'remark' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - // lang fields - 'remark' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'), ), ); /** * @param int $idHtlBooking - * @param int $idLang * @return array history rows for one booking, oldest first */ - public function getHistoryByBooking($idHtlBooking, $idLang = 0) + public function getHistoryByBooking($idHtlBooking) { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - - $sql = 'SELECT hbsh.*, hbshl.`remark` FROM `'._DB_PREFIX_.$this->table.'` hbsh - LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` hbshl ON hbsh.`id_booking_status_history` = hbshl.`id_booking_status_history` AND hbshl.`id_lang` = '.(int) $idLang.' - WHERE hbsh.`id_htl_booking` = '.(int) $idHtlBooking.' - ORDER BY hbsh.`id_booking_status_history` ASC'; + $sql = 'SELECT * FROM `'._DB_PREFIX_.$this->table.'` + WHERE `id_htl_booking` = '.(int) $idHtlBooking.' + ORDER BY `id_booking_status_history` ASC'; return Db::getInstance()->executeS($sql); } diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index b32b659eb..d0608b92a 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -223,17 +223,11 @@ class HotelReservationSystemDb `id_status_to` int(11) NOT NULL, `id_employee` int(11) DEFAULT NULL, `id_customer` int(11) DEFAULT NULL, + `remark` text, `date_add` datetime NOT NULL, PRIMARY KEY (`id_booking_status_history`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_status_history_lang` ( - `id_booking_status_history` int(11) NOT NULL, - `id_lang` int(11) NOT NULL, - `remark` text, - PRIMARY KEY (`id_booking_status_history`, `id_lang`) - ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_document` ( `id_htl_booking_document` int(11) NOT NULL AUTO_INCREMENT, `id_htl_booking` int(11) NOT NULL, @@ -627,7 +621,6 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_booking_status`, `'._DB_PREFIX_.'htl_booking_status_lang`, `'._DB_PREFIX_.'htl_booking_status_history`, - `'._DB_PREFIX_.'htl_booking_status_history_lang`, `'._DB_PREFIX_.'htl_booking_document`, `'._DB_PREFIX_.'htl_booking_demands`, `'._DB_PREFIX_.'htl_booking_demands_tax`, diff --git a/modules/hotelreservationsystem/controllers/admin/AdminRoomStatusesController.php b/modules/hotelreservationsystem/controllers/admin/AdminRoomStatusesController.php index 55ba23ca3..540efa9c0 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminRoomStatusesController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminRoomStatusesController.php @@ -33,6 +33,7 @@ class AdminRoomStatusesController extends ModuleAdminController $this->lang = true; parent::__construct(); + $this->_new_list_header_design = true; // edit only — the 5 statuses are fixed (their IDs are the // HotelBookingDetail::STATUS_* constants used everywhere), no add/delete @@ -122,7 +123,7 @@ class AdminRoomStatusesController extends ModuleAdminController 'type' => 'switch', 'label' => $this->l('Terminal (final) status'), 'name' => 'is_terminal_display', - 'hint' => $this->l('A terminal status is final — once a room reaches it, it can\'t move to any other status. Fixed per status, cannot be changed here.'), + 'hint' => $this->l('If set to Yes, a room with this status cannot be edited, only deleted. If No, the room can still be edited. This setting is fixed for each status, so it is disabled here.'), 'disabled' => true, 'values' => array( array(