From 21514d413483f36e6027b0814d637d95fab23e31 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Jun 2022 14:27:52 +0530 Subject: [PATCH 01/42] resolve same order status issue when booking room from multiple hotels --- .../controllers/orders/helpers/view/view.tpl | 30 +++---- classes/PaymentModule.php | 12 ++- classes/order/Order.php | 84 +++++++++++++------ classes/order/OrderHistory.php | 15 ++-- classes/order/OrderInvoice.php | 5 ++ classes/order/OrderPaymentDetail.php | 79 +++++++++++++++++ controllers/admin/AdminOrdersController.php | 17 +++- install/data/db_structure.sql | 10 +++ pdf/invoice.payment-tab.tpl | 6 +- 9 files changed, 200 insertions(+), 58 deletions(-) create mode 100644 classes/order/OrderPaymentDetail.php diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 6922cff6d..f5a30ca46 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -505,15 +505,15 @@ - {foreach from=$order->getOrderPaymentCollection() item=payment} + {foreach from=$order_payment_detail item=payment} - {dateFormat date=$payment->date_add full=true} - {$payment->payment_method|escape:'html':'UTF-8'} - {$payment->transaction_id|escape:'html':'UTF-8'} - {displayPrice price=$payment->amount currency=$payment->id_currency} + {dateFormat date=$payment['date_add'] full=true} + {$payment['payment_method']|escape:'html':'UTF-8'} + {$payment['transaction_id']|escape:'html':'UTF-8'} + {displayPrice price=$payment['real_paid_amount'] currency=$payment['id_currency']} - {if $invoice = $payment->getOrderInvoice($order->id)} - {$invoice->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)} + {if $payment['invoice_number']} + {$payment['invoice_number']} {else} {/if} @@ -528,32 +528,32 @@

{l s='Card Number'}  - {if $payment->card_number} - {$payment->card_number} + {if $payment['card_number']} + {$payment['card_number']} {else} {l s='Not defined'} {/if}

{l s='Card Brand'}  - {if $payment->card_brand} - {$payment->card_brand} + {if $payment['card_brand']} + {$payment['card_brand']} {else} {l s='Not defined'} {/if}

{l s='Card Expiration'}  - {if $payment->card_expiration} - {$payment->card_expiration} + {if $payment['card_expiration']} + {$payment['card_expiration']} {else} {l s='Not defined'} {/if}

{l s='Card Holder'}  - {if $payment->card_holder} - {$payment->card_holder} + {if $payment['card_holder']} + {$payment['card_holder']} {else} {l s='Not defined'} {/if} diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 010dcf4a8..88dfe8a9d 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -431,10 +431,14 @@ abstract class PaymentModuleCore extends Module $transaction_id = null; } - if (!isset($order) || !Validate::isLoadedObject($order) || !$order->addOrderPayment($amount_paid, null, $transaction_id)) { + if (!isset($order) || !Validate::isLoadedObject($order) || !$order->addOrderPayment($amount_paid, null, $transaction_id, null, null, null, false)) { PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int)$id_cart, true); throw new PrestaShopException('Can\'t save Order Payment'); } + + foreach($order_list as $order) { + $order->addOrderPaymentDetail($order->advance_paid_amount); + } } // Next ! @@ -713,7 +717,11 @@ abstract class PaymentModuleCore extends Module // Set the order status $new_history = new OrderHistory(); $new_history->id_order = (int)$order->id; - $new_history->changeIdOrderState((int)$id_order_state, $order, true); + if ($order->is_advance_payment && $order->advance_paid_amount < $order->total_paid_tax_incl) { + $new_history->changeIdOrderState((int)Configuration::get('PS_OS_PARTIAL_PAYMENT'), $order, true); + } else { + $new_history->changeIdOrderState((int)$id_order_state, $order, true); + } $new_history->addWithemail(true, $extra_vars); // Switch to back order if needed diff --git a/classes/order/Order.php b/classes/order/Order.php index fbc292b4a..9d0f54cda 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -1267,8 +1267,6 @@ class OrderCore extends ObjectModel $this->setLastInvoiceNumber($order_invoice->id, $this->id_shop); } - - // Update order_carrier $id_order_carrier = Db::getInstance()->getValue(' SELECT `id_order_carrier` @@ -1292,11 +1290,13 @@ class OrderCore extends ObjectModel // Update order payment if ($use_existing_payment) { $id_order_payments = Db::getInstance()->executeS(' - SELECT DISTINCT op.id_order_payment + SELECT DISTINCT op.id_order_payment, opd.id_order_payment_detail FROM `'._DB_PREFIX_.'order_payment` op INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.reference = op.order_reference) + LEFT JOIN `'._DB_PREFIX_.'order_payment_detail` opd ON (op.id_order_payment = opd.id_order_payment) LEFT JOIN `'._DB_PREFIX_.'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment) - WHERE (oip.id_order != '.(int)$order_invoice->id_order.' OR oip.id_order IS NULL) AND o.id_order = '.(int)$order_invoice->id_order); + WHERE (oip.id_order != '.(int)$order_invoice->id_order.' OR oip.id_order IS NULL) AND o.id_order = '.(int)$order_invoice->id_order.' + AND opd.`id_order` = '.$order_invoice->id_order); if (count($id_order_payments)) { foreach ($id_order_payments as $order_payment) { @@ -1304,6 +1304,7 @@ class OrderCore extends ObjectModel INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` SET `id_order_invoice` = '.(int)$order_invoice->id.', + `id_order_payment_detail` = '.(int)$order_payment['id_order_payment_detail'].', `id_order_payment` = '.(int)$order_payment['id_order_payment'].', `id_order` = '.(int)$order_invoice->id_order); } @@ -1311,7 +1312,6 @@ class OrderCore extends ObjectModel Cache::clean('order_invoice_paid_*'); } } - // Update order cart rule Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'order_cart_rule` @@ -1705,6 +1705,16 @@ class OrderCore extends ObjectModel return $order_payments; } + public function getOrderPaymentDetailCollection() + { + $order_payments = new DbQuery(); + $order_payments->select('opd.`amount` as `real_paid_amount`, opd.*, op.*'); + $order_payments->from('order_payment_detail', 'opd'); + $order_payments->innerJoin('order_payment', 'op', 'opd.`id_order_payment` = op.`id_order_payment`'); + $order_payments->where('id_order = '.$this->id); + return Db::getInstance()->executeS($order_payments); + } + /** * * This method allows to add a payment to the current order @@ -1717,7 +1727,7 @@ class OrderCore extends ObjectModel * @param OrderInvoice $order_invoice * @return bool */ - public function addOrderPayment($amount_paid, $payment_method = null, $payment_transaction_id = null, $currency = null, $date = null, $order_invoice = null) + public function addOrderPayment($amount_paid, $payment_method = null, $payment_transaction_id = null, $currency = null, $date = null, $order_invoice = null, $update_payment_detail = true) { $order_payment = new OrderPayment(); $order_payment->order_reference = $this->reference; @@ -1735,32 +1745,50 @@ class OrderCore extends ObjectModel $order_payment->date_add .= ' '.date('H:i:s'); } - // Update total_paid_real value for backward compatibility reasons - if ($order_payment->id_currency == $this->id_currency) { - $this->total_paid_real += $order_payment->amount; - } else { - $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2); - } - // We put autodate parameter of add method to true if date_add field is null - $res = $order_payment->add(is_null($order_payment->date_add)) && $this->update(); + $res = $order_payment->add(is_null($order_payment->date_add)); if (!$res) { return false; } - if (!is_null($order_invoice)) { - $res = Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`) - VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')'); - - // Clear cache - Cache::clean('order_invoice_paid_*'); + if ($update_payment_detail) { + $this->addOrderPaymentDetail($amount_paid, $order_invoice); } return $res; } + public function addOrderPaymentDetail($amount, $order_invoice = null) + { + if ($orderPayments = OrderPayment::getByOrderReference($this->reference)) { + $lastOrderPayment = array_pop($orderPayments); + $order_payment_detail = new OrderPaymentDetail(); + $order_payment_detail->id_order = $this->id; + $order_payment_detail->id_order_payment = (int)$lastOrderPayment->id; + $order_payment_detail->amount = $amount; + + if ($lastOrderPayment->id_currency == $this->id_currency) { + $this->total_paid_real += $order_payment_detail->amount; + } else { + $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment_detail->amount, $lastOrderPayment->id_currency, false), 2); + } + if ($order_payment_detail->add() && $this->update()) { + if (!is_null($order_invoice)) { + $res = Db::getInstance()->execute(' + INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order_payment_detail`, `id_order`) + VALUES('.(int)$order_invoice->id.', '.(int)(int)$lastOrderPayment->id.', '.(int)$order_payment_detail->id.', '.(int)$this->id.')'); + + // Clear cache + Cache::clean('order_invoice_paid_*'); + } + + return $order_payment_detail->id; + } + } + return false; + } + /** * Returns the correct product taxes breakdown. * @@ -1893,14 +1921,15 @@ class OrderCore extends ObjectModel } $total = 0; + // Retrieve all payments - $payments = $this->getOrderPaymentCollection(); + $payments = $this->getOrderPaymentDetailCollection(); foreach ($payments as $payment) { /** @var OrderPayment $payment */ - if ($payment->id_currency == $currency->id) { - $total += $payment->amount; + if ($payment['id_currency'] == $currency->id) { + $total += $payment['real_paid_amount']; } else { - $amount = Tools::convertPrice($payment->amount, $payment->id_currency, false); + $amount = Tools::convertPrice($payment['real_paid_amount'], $payment['id_currency'], false); if ($currency->id == Configuration::get('PS_CURRENCY_DEFAULT', null, null, $this->id_shop)) { $total += $amount; } else { @@ -2166,6 +2195,11 @@ class OrderCore extends ObjectModel return OrderPayment::getByOrderReference($this->reference); } + public function getOrderPaymentsDetail() + { + return OrderPaymentDetail::getByOrderId($this->id); + } + /** * Return a unique reference like : GWJTHMZUN#2 * diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 2da4bf501..851365312 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -333,19 +333,14 @@ class OrderHistoryCore extends ObjectModel $payment->payment_method = null; } - // Update total_paid_real value for backward compatibility reasons - if ($payment->id_currency == $order->id_currency) { - $order->total_paid_real += $payment->amount; - } else { - $order->total_paid_real += Tools::ps_round(Tools::convertPrice($payment->amount, $payment->id_currency, false), 2); - } - $order->save(); - $payment->conversion_rate = ($order ? $order->conversion_rate : 1); $payment->save(); + + $id_order_payment_detail = $order->addOrderPaymentDetail($rest_paid); + Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`) - VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$order->id.')'); + INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order_payment_detail`, `id_order`) + VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$id_order_payment_detail.', '.(int)$order->id.')'); } } } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 2e4e6ceab..91f07ea83 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -880,6 +880,11 @@ class OrderInvoiceCore extends ObjectModel return OrderPayment::getByInvoiceId($this->id); } + public function getOrderPaymentDetailCollection() + { + return OrderPaymentDetail::getByInvoiceId($this->id); + } + /** * Get the formatted number of invoice * @since 1.5.0.2 diff --git a/classes/order/OrderPaymentDetail.php b/classes/order/OrderPaymentDetail.php new file mode 100644 index 000000000..b231efb4d --- /dev/null +++ b/classes/order/OrderPaymentDetail.php @@ -0,0 +1,79 @@ + 'order_payment_detail', + 'primary' => 'id_order_payment_detail', + 'fields' => array( + 'id_order_payment' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isNegativePrice', 'required' => true), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + 'associations' => array( + 'order_payment' => array('type' => self::HAS_ONE, 'table' => 'order_payment') + ) + ); + + public static function getByOrderId($id_order) + { + return Db::getInstance()->executeS(' + SELECT opd.*, op.`id_currency`, op.`payment_method`, op.`conversion_rate`, op.`transaction_id`, op.`card_number`, op.`card_brand`, op.`card_expiration`, op.`card_holder` + FROM `'._DB_PREFIX_.'order_payment_detail` opd + INNER JOIN `'._DB_PREFIX_.'order_payment`op ON (op.`id_order_payment` = opd.`id_order_payment`) + WHERE `id_order` = '.(int)$id_order); + } + + /** + * Get Order Payments By Invoice ID + * + * @param int $id_invoice Invoice ID + * @return PrestaShopCollection Collection of OrderPayment + */ + public static function getByInvoiceId($id_invoice) + { + $payments = Db::getInstance()->executeS('SELECT id_order_payment_detail FROM `'._DB_PREFIX_.'order_invoice_payment` WHERE id_order_invoice = '.(int)$id_invoice); + if (!$payments) { + return array(); + } + + $payment_list = array(); + foreach ($payments as $payment) { + $payment_list[] = $payment['id_order_payment_detail']; + } + $order_payments = new DbQuery(); + $order_payments->select('opd.*, op.*, opd.`amount` as `amount`'); + $order_payments->from('order_payment_detail', 'opd'); + $order_payments->innerJoin('order_payment', 'op', 'opd.`id_order_payment` = op.`id_order_payment`'); + $order_payments->where('id_order_payment_detail IN ('.pSQL(implode(', ', $payment_list)).')'); + return Db::getInstance()->executeS($order_payments); + // $payments = new PrestaShopCollection('OrderPaymentDetail'); + // $payments->join('order_payment', 'id_order_payment'); + // $payments->where('id_order_payment_detail', 'IN', $payment_list); + // ddd($payments->getAll()); + } +} diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b67bb86d9..43ab91edc 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -159,7 +159,7 @@ class AdminOrdersControllerCore extends AdminController 'remove_onclick' => true ) )); - + $this->shopLinkType = 'shop'; $this->shopShareDatas = Shop::SHARE_ORDER; @@ -321,7 +321,7 @@ class AdminOrdersControllerCore extends AdminController $this->addJqueryUI('ui.datepicker'); $this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js'); - + if ($this->tabAccess['edit'] == 1 && $this->display == 'view') { $this->addJS(_PS_JS_DIR_.'admin/orders.js'); $this->addJS(_PS_JS_DIR_.'tools.js'); @@ -1432,6 +1432,16 @@ class AdminOrdersControllerCore extends AdminController foreach ($history as &$order_state) { $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } + + $order_payment_detail = $order->getOrderPaymentDetailCollection(); + foreach ($order_payment_detail as &$payment_detail) { + $payment = new OrderPayment($payment_detail['id_order_payment']); + if ($invoice = $payment->getOrderInvoice($order->id)) { + $payment_detail['invoice_number'] = $invoice->getInvoiceNumberFormatted($this->context->language->id, $order->id_shop); + } + } + + //by webkul to get data to show hotel rooms order data on order detail page $cart_id = Cart::getCartIdByOrderId(Tools::getValue('id_order')); @@ -1544,13 +1554,14 @@ class AdminOrdersControllerCore extends AdminController 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), - 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), // Get the sum of total_paid_tax_incl of the order with similar reference + 'orders_total_paid_tax_incl' => $order->total_paid_tax_incl, // Get the sum of total_paid_tax_incl of the order with similar reference 'total_paid' => $order->getTotalPaid(), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, + 'order_payment_detail' => $order_payment_detail, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 60fc52813..0c969ff1b 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1455,6 +1455,15 @@ CREATE TABLE `PREFIX_order_payment` ( KEY `order_reference`(`order_reference`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; +CREATE TABLE `PREFIX_order_payment_detail` ( + `id_order_payment_detail` INT(10) unsigned NOT NULL auto_increment, + `id_order_payment` INT(10) unsigned NOT NULL, + `id_order` INT(10) unsigned NOT NULL, + `amount` DECIMAL(10,2) NOT NULL, + `date_add` DATETIME NOT NULL, + PRIMARY KEY (`id_order_payment_detail`), +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; + CREATE TABLE `PREFIX_product` ( `id_product` int(10) unsigned NOT NULL auto_increment, `id_supplier` int(10) unsigned DEFAULT NULL, @@ -2605,6 +2614,7 @@ CREATE TABLE `PREFIX_tab_module_preference` ( CREATE TABLE `PREFIX_order_invoice_payment` ( `id_order_invoice` int(11) unsigned NOT NULL, `id_order_payment` int(11) unsigned NOT NULL, + `id_order_payment_detail` int(11) unsigned NOT NULL, `id_order` int(11) unsigned NOT NULL, PRIMARY KEY (`id_order_invoice`,`id_order_payment`), KEY `order_payment` (`id_order_payment`), diff --git a/pdf/invoice.payment-tab.tpl b/pdf/invoice.payment-tab.tpl index 5c303aaf5..a80c0e91e 100644 --- a/pdf/invoice.payment-tab.tpl +++ b/pdf/invoice.payment-tab.tpl @@ -27,10 +27,10 @@ {l s='Payment Method' pdf='true'} - {foreach from=$order_invoice->getOrderPaymentCollection() item=payment} + {foreach from=$order_invoice->getOrderPaymentDetailCollection() item=payment} - - + + {/foreach}
{$payment->payment_method}{displayPrice currency=$payment->id_currency price=$payment->amount}{$payment['payment_method']}{displayPrice currency=$payment['id_currency'] price=$payment['amount']}
From a8c844d2dd3b9913f73d199dd2fecd8a3e541c29 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 9 Jun 2022 18:39:08 +0530 Subject: [PATCH 02/42] resolved Db issue --- install/data/db_structure.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 0c969ff1b..eaeac96c8 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1461,7 +1461,7 @@ CREATE TABLE `PREFIX_order_payment_detail` ( `id_order` INT(10) unsigned NOT NULL, `amount` DECIMAL(10,2) NOT NULL, `date_add` DATETIME NOT NULL, - PRIMARY KEY (`id_order_payment_detail`), + PRIMARY KEY (`id_order_payment_detail`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_product` ( @@ -2604,7 +2604,7 @@ CREATE TABLE `PREFIX_tab_module_preference` ( UNIQUE KEY `employee_module` (`id_employee`, `id_tab`, `module`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; - CREATE TABLE `PREFIX_carrier_tax_rules_group_shop` ( +CREATE TABLE `PREFIX_carrier_tax_rules_group_shop` ( `id_carrier` int( 11 ) unsigned NOT NULL, `id_tax_rules_group` int(11) unsigned NOT NULL, `id_shop` int(11) unsigned NOT NULL, From 867701c49851cdf87d6b3c255073bda2fe60e3b7 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sat, 11 Jun 2022 13:20:00 +0530 Subject: [PATCH 03/42] update invoce total price --- classes/order/OrderInvoice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 91f07ea83..9f79fd793 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -738,10 +738,10 @@ class OrderInvoiceCore extends ObjectModel $cache_id = 'order_invoice_paid_'.(int)$this->id; if (!Cache::isStored($cache_id)) { $amount = 0; - $payments = OrderPayment::getByInvoiceId($this->id); + $payments = OrderPaymentDetail::getByInvoiceId($this->id); foreach ($payments as $payment) { /** @var OrderPayment $payment */ - $amount += $payment->amount; + $amount += $payment['amount']; } Cache::store($cache_id, $amount); return $amount; From 5eed6a0b1abedf9d4c566ea79085e4f9f5c4ea6d Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 14 Jun 2022 13:19:46 +0530 Subject: [PATCH 04/42] resolve issue when paying from nonreal payment gateway --- classes/PaymentModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 88dfe8a9d..86f9e02ce 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -717,7 +717,7 @@ abstract class PaymentModuleCore extends Module // Set the order status $new_history = new OrderHistory(); $new_history->id_order = (int)$order->id; - if ($order->is_advance_payment && $order->advance_paid_amount < $order->total_paid_tax_incl) { + if ($order_status->logable && $order->is_advance_payment && $order->advance_paid_amount < $order->total_paid_tax_incl) { $new_history->changeIdOrderState((int)Configuration::get('PS_OS_PARTIAL_PAYMENT'), $order, true); } else { $new_history->changeIdOrderState((int)$id_order_state, $order, true); From 4927208b1b874f33699104d3a47d03f9f3b109ce Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 21 Nov 2022 18:09:17 +0530 Subject: [PATCH 05/42] Remove module config links from Hotel Reservation System > Settings page --- .../hook/aboutHotelBlockModuleSetting.tpl | 28 ------------------- .../wkabouthotelblock/wkabouthotelblock.php | 11 ++++---- .../hook/hotelFeatureSettingLink.tpl | 28 ------------------- .../wkhotelfeaturesblock.php | 13 ++++----- .../templates/hook/hotelRoomSettingLink.tpl | 28 ------------------- modules/wkhotelroom/wkhotelroom.php | 14 ++++------ .../hook/hotelTestimonialSettingLink.tpl | 28 ------------------- .../wktestimonialblock/wktestimonialblock.php | 13 ++++----- 8 files changed, 20 insertions(+), 143 deletions(-) delete mode 100644 modules/wkabouthotelblock/views/templates/hook/aboutHotelBlockModuleSetting.tpl delete mode 100644 modules/wkhotelfeaturesblock/views/templates/hook/hotelFeatureSettingLink.tpl delete mode 100644 modules/wkhotelroom/views/templates/hook/hotelRoomSettingLink.tpl delete mode 100644 modules/wktestimonialblock/views/templates/hook/hotelTestimonialSettingLink.tpl diff --git a/modules/wkabouthotelblock/views/templates/hook/aboutHotelBlockModuleSetting.tpl b/modules/wkabouthotelblock/views/templates/hook/aboutHotelBlockModuleSetting.tpl deleted file mode 100644 index 43d2bcd9c..000000000 --- a/modules/wkabouthotelblock/views/templates/hook/aboutHotelBlockModuleSetting.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*} - -

\ No newline at end of file diff --git a/modules/wkabouthotelblock/wkabouthotelblock.php b/modules/wkabouthotelblock/wkabouthotelblock.php index 5b3b5a0c1..89e9dc0a8 100644 --- a/modules/wkabouthotelblock/wkabouthotelblock.php +++ b/modules/wkabouthotelblock/wkabouthotelblock.php @@ -67,11 +67,6 @@ class WkAboutHotelBlock extends Module return $this->display(__FILE__, 'hotelInteriorBlock.tpl'); } - public function hookDisplayAddModuleSettingLink() - { - return $this->display(__FILE__, 'aboutHotelBlockModuleSetting.tpl'); - } - /** * If admin add any language then an entry will add in defined $lang_tables array's lang table same as prestashop * @param array $params @@ -102,13 +97,17 @@ class WkAboutHotelBlock extends Module return true; } + public function getContent() + { + Tools::redirectAdmin($this->context->link->getAdminLink('AdminAboutHotelBlockSetting')); + } + public function registerModuleHooks() { return $this->registerHook( array( 'displayHome', 'displayFooterExploreSectionHook', - 'displayAddModuleSettingLink', 'actionObjectLanguageAddAfter' ) ); diff --git a/modules/wkhotelfeaturesblock/views/templates/hook/hotelFeatureSettingLink.tpl b/modules/wkhotelfeaturesblock/views/templates/hook/hotelFeatureSettingLink.tpl deleted file mode 100644 index 3eaee7b60..000000000 --- a/modules/wkhotelfeaturesblock/views/templates/hook/hotelFeatureSettingLink.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*} - - \ No newline at end of file diff --git a/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php b/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php index b7550193a..a882e7404 100644 --- a/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php +++ b/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php @@ -63,13 +63,6 @@ class WkHotelFeaturesBlock extends Module return $this->display(__FILE__, 'hotelfeaturescontent.tpl'); } - public function hookDisplayAddModuleSettingLink() - { - $hrefFeaturesConf = $this->context->link->getAdminLink('AdminFeaturesModuleSetting'); - $this->context->smarty->assign('features_setting_link', $hrefFeaturesConf); - return $this->display(__FILE__, 'hotelFeatureSettingLink.tpl'); - } - /** * If admin add any language then an entry will add in defined $lang_tables array's lang table same as prestashop * @param array $params @@ -140,12 +133,16 @@ class WkHotelFeaturesBlock extends Module array ( 'displayHome', 'displayFooterExploreSectionHook', - 'displayAddModuleSettingLink', 'actionObjectLanguageAddAfter' ) ); } + public function getContent() + { + Tools::redirectAdmin($this->context->link->getAdminLink('AdminFeaturesModuleSetting')); + } + public function uninstall() { $objHotelFeaturesBlockDb = new WkHotelFeaturesBlockDb(); diff --git a/modules/wkhotelroom/views/templates/hook/hotelRoomSettingLink.tpl b/modules/wkhotelroom/views/templates/hook/hotelRoomSettingLink.tpl deleted file mode 100644 index c32c07def..000000000 --- a/modules/wkhotelroom/views/templates/hook/hotelRoomSettingLink.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*} - - \ No newline at end of file diff --git a/modules/wkhotelroom/wkhotelroom.php b/modules/wkhotelroom/wkhotelroom.php index 9f8723c1a..aa8f00b4b 100644 --- a/modules/wkhotelroom/wkhotelroom.php +++ b/modules/wkhotelroom/wkhotelroom.php @@ -126,14 +126,6 @@ class WkHotelRoom extends Module } } - public function hookDisplayAddModuleSettingLink() - { - $htlRoomBlockConfigLink = $this->context->link->getAdminLink('AdminHotelRoomModuleSetting'); - $this->context->smarty->assign('htlRoomBlockConfigLink', $htlRoomBlockConfigLink); - - return $this->display(__FILE__, 'hotelRoomSettingLink.tpl'); - } - /** * If admin add any language then an entry will add in defined $lang_tables array's lang table same as prestashop * @param array $params @@ -204,7 +196,6 @@ class WkHotelRoom extends Module array ( 'displayHome', 'actionProductDelete', - 'displayAddModuleSettingLink', 'displayFooterExploreSectionHook', 'actionProductSave', 'actionObjectLanguageAddAfter' @@ -212,6 +203,11 @@ class WkHotelRoom extends Module ); } + public function getContent() + { + Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomModuleSetting')); + } + public function uninstall() { $objHotelRoomDb = new WkHotelRoomDb(); diff --git a/modules/wktestimonialblock/views/templates/hook/hotelTestimonialSettingLink.tpl b/modules/wktestimonialblock/views/templates/hook/hotelTestimonialSettingLink.tpl deleted file mode 100644 index aa25d33cd..000000000 --- a/modules/wktestimonialblock/views/templates/hook/hotelTestimonialSettingLink.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*} - - \ No newline at end of file diff --git a/modules/wktestimonialblock/wktestimonialblock.php b/modules/wktestimonialblock/wktestimonialblock.php index de379ea38..e8be980d1 100644 --- a/modules/wktestimonialblock/wktestimonialblock.php +++ b/modules/wktestimonialblock/wktestimonialblock.php @@ -44,13 +44,6 @@ class WkTestimonialBlock extends Module $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } - public function hookDisplayAddModuleSettingLink() - { - $hrefTestimonialsConf = $this->context->link->getAdminLink('AdminTestimonialsModuleSetting'); - $this->context->smarty->assign('testimonials_setting_link', $hrefTestimonialsConf); - return $this->display(__FILE__, 'hotelTestimonialSettingLink.tpl'); - } - public function hookDisplayHome() { $this->context->controller->addCSS(_PS_JS_DIR_.'/owl-carousel/assets/owl.carousel.min.css'); @@ -132,12 +125,16 @@ class WkTestimonialBlock extends Module array ( 'displayHome', 'displayFooterExploreSectionHook', - 'displayAddModuleSettingLink', 'actionObjectLanguageAddAfter' ) ); } + public function getContent() + { + Tools::redirectAdmin($this->context->link->getAdminLink('AdminTestimonialsModuleSetting')); + } + public function callInstallTab() { //Controllers which are to be used in this modules but we have not to create tab for those controllers... From 2b35fb3b029c71641de9ff460535f71317085874 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 22 Nov 2022 19:31:07 +0530 Subject: [PATCH 06/42] Move tab Additional Facilities to AdminProductsController --- config/xml/themes/default.xml | 3 - controllers/admin/AdminProductsController.php | 122 +++++++++++++++++ .../hotelreservationsystem.php | 128 ------------------ .../views/css/roomTypeDemand.css | 42 ------ .../views/js/roomTypeDemand.js | 49 ------- .../views/templates/hook/roomTypeDemands.tpl | 127 ----------------- 6 files changed, 122 insertions(+), 349 deletions(-) delete mode 100644 modules/hotelreservationsystem/views/css/roomTypeDemand.css delete mode 100644 modules/hotelreservationsystem/views/js/roomTypeDemand.js delete mode 100644 modules/hotelreservationsystem/views/templates/hook/roomTypeDemands.tpl diff --git a/config/xml/themes/default.xml b/config/xml/themes/default.xml index f7c0da20f..495981b4d 100644 --- a/config/xml/themes/default.xml +++ b/config/xml/themes/default.xml @@ -65,7 +65,6 @@ - @@ -77,8 +76,6 @@ - - diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 1b9457489..487d132ec 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -113,6 +113,7 @@ class AdminProductsControllerCore extends AdminController 'Configuration' => $this->l('Configuration'), 'Occupancy' => $this->l('Occupancy'), 'Booking' => $this->l('Booking Information'), + 'AdditionalFacilities' => $this->l('Additional Facilities'), ); $this->available_tabs = array('Warehouses' => 14); @@ -134,6 +135,7 @@ class AdminProductsControllerCore extends AdminController 'Configuration' => 14, 'Occupancy' => 15, 'Booking' => 16, + 'AdditionalFacilities' => 17, )); } @@ -2231,6 +2233,9 @@ class AdminProductsControllerCore extends AdminController if ($this->isTabSubmitted('Booking')) { $this->processBooking(); } + if ($this->isTabSubmitted('AdditionalFacilities')) { + $this->processAdditionalFacilities(); + } $this->updatePackItems($object); // Disallow avanced stock management if the product become a pack @@ -3727,6 +3732,123 @@ class AdminProductsControllerCore extends AdminController } } + public function initFormAdditionalFacilities($obj) + { + $data = $this->createTemplate($this->tpl_form); + + if ($obj->id) { + $objGlobalDemand = new HotelRoomTypeGlobalDemand(); + $allDemands = $objGlobalDemand->getAllDemands(); + $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); + + // get room type additional facilities + $objRoomDemand = new HotelRoomTypeDemand(); + $roomDemandPrices = $objRoomDemand->getRoomTypeDemands($obj->id, 0, 0); + + $data->assign(array( + 'product' => $obj, + 'idProduct' => $obj->id, + 'roomDemandPrices' => $roomDemandPrices, + 'allDemands' => $allDemands, + 'defaultcurrencySign' => $objCurrency->sign, + )); + } else { + $this->displayWarning($this->l('You must save this room type before managing additional facilities.')); + } + + $this->tpl_form_vars['custom_form'] = $data->fetch(); + } + + public function processAdditionalFacilities() + { + if ($idProduct = Tools::getValue('id_product')) { + $objRoomTypeDemand = new HotelRoomTypeDemand(); + $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); + // first delete all the previously saved prices and demands of this room type + $objRoomTypeDemand->deleteRoomTypeDemands($idProduct); + $objRoomTypeDemandPrice->deleteRoomTypeDemandPrices($idProduct); + if ($selectedDemands = Tools::getValue('selected_demand')) { + $objAdvOption = new HotelRoomTypeGlobalDemandAdvanceOption(); + foreach ($selectedDemands as $idGlobalDemand) { + if (Validate::isLoadedObject($objGlobalDemand = new HotelRoomTypeGlobalDemand($idGlobalDemand))) { + // save selected demands for this room type + $objRoomTypeDemand = new HotelRoomTypeDemand(); + $objRoomTypeDemand->id_product = $idProduct; + $objRoomTypeDemand->id_global_demand = $idGlobalDemand; + $objRoomTypeDemand->save(); + + // save selected demands prices for this room type + $demandPrice = Tools::getValue('demand_price_'.$idGlobalDemand); + if (Validate::isPrice($demandPrice)) { + if ($objGlobalDemand->price != $demandPrice) { + $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); + $objRoomTypeDemandPrice->id_product = $idProduct; + $objRoomTypeDemandPrice->id_global_demand = $idGlobalDemand; + $objRoomTypeDemandPrice->id_option = 0; + $objRoomTypeDemandPrice->price = $demandPrice; + $objRoomTypeDemandPrice->save(); + } + } else { + $this->errors[] = Tools::displayError('Invalid demand price of facility.'). + ' : '.$objGlobalDemand->name[$this->context->language->id]; + } + if ($advOptions = $objAdvOption->getGlobalDemandAdvanceOptions($idGlobalDemand)) { + foreach ($advOptions as $option) { + if (Validate::isLoadedObject($objAdvOption = new HotelRoomTypeGlobalDemandAdvanceOption($option['id']))) { + $optionPrice = Tools::getValue('option_price_'.$option['id']); + if (Validate::isPrice($optionPrice)) { + if ($optionPrice != $objAdvOption->price) { + $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); + $objRoomTypeDemandPrice->id_product = $idProduct; + $objRoomTypeDemandPrice->id_global_demand = $idGlobalDemand; + $objRoomTypeDemandPrice->id_option = $option['id']; + $objRoomTypeDemandPrice->price = $optionPrice; + $objRoomTypeDemandPrice->save(); + } + } else { + $this->errors[] = Tools::displayError('Invalid price of advanced option: ').$objAdvOption->name[$this->context->language->id]; + } + } + } + } + } + } + if (count($this->errors)) { + $this->warnings[] = Tools::displayError('Invalid price values are not saved. Please correct them and save again.'); + } + + $objCartBookingData = new HotelCartBookingData(); + if ($cartExtraDemands = $objCartBookingData->getCartExtraDemands(0, $idProduct)) { + // delete the demands from cart if not available in cart + $objRoomDemand = new HotelRoomTypeDemand(); + $roomTypeDemandIds = array(); + if ($roomTypeDemands = $objRoomDemand->getRoomTypeDemands($idProduct)) { + $roomTypeDemandIds = array_keys($roomTypeDemands); + } + foreach ($cartExtraDemands as &$demandInfo) { + if (isset($demandInfo['extra_demands']) && $demandInfo['extra_demands']) { + $cartChanged = 0; + foreach ($demandInfo['extra_demands'] as $key => $demand) { + if (!in_array($demand['id_global_demand'], $roomTypeDemandIds)) { + $cartChanged = 1; + unset($demandInfo['extra_demands'][$key]); + } + } + if ($cartChanged) { + if (Validate::isLoadedObject( + $objCartBooking = new HotelCartBookingData($demandInfo['id']) + )) { + $objCartBooking->extra_demands = json_encode($demandInfo['extra_demands']); + $objCartBooking->save(); + } + } + } + } + } + } + } + } + public function ajaxProcessProductRoomsBookingDetailsOnMonthChange() { $month = Tools::getValue('month'); diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index 8c0d55f4f..10bf1894a 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -194,123 +194,6 @@ class HotelReservationSystem extends Module } } - public function hookDisplayAdminProductsExtra($params) - { - if ($idProduct = Tools::getValue('id_product')) { - $objGlobalDemand = new HotelRoomTypeGlobalDemand(); - $allDemands = $objGlobalDemand->getAllDemands(); - $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - // get room type additional services - $objRoomDemand = new HotelRoomTypeDemand(); - $roomDemandPrices = $objRoomDemand->getRoomTypeDemands($idProduct, 0, 0); - $this->context->smarty->assign( - array( - 'idProduct' => $idProduct, - 'roomDemandPrices' => $roomDemandPrices, - 'allDemands' => $allDemands, - 'defaultcurrencySign' => $objCurrency->sign, - ) - ); - } - return $this->display(__FILE__, 'roomTypeDemands.tpl'); - } - - public function moduleProductsExtraTabName() - { - return $this->l('Additional Facilities'); - } - - public function hookActionProductUpdate($params) - { - if ($idProduct = $params['id_product']) { - $objRoomTypeDemand = new HotelRoomTypeDemand(); - $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); - // first delete all the previously saved prices and demands of this room type - $objRoomTypeDemand->deleteRoomTypeDemands($idProduct); - $objRoomTypeDemandPrice->deleteRoomTypeDemandPrices($idProduct); - if ($selectedDemands = Tools::getValue('selected_demand')) { - $objAdvOption = new HotelRoomTypeGlobalDemandAdvanceOption(); - foreach ($selectedDemands as $idGlobalDemand) { - if (Validate::isLoadedObject($objGlobalDemand = new HotelRoomTypeGlobalDemand($idGlobalDemand))) { - // save selected demands for this room type - $objRoomTypeDemand = new HotelRoomTypeDemand(); - $objRoomTypeDemand->id_product = $idProduct; - $objRoomTypeDemand->id_global_demand = $idGlobalDemand; - $objRoomTypeDemand->save(); - - // save selected demands prices for this room type - $demandPrice = Tools::getValue('demand_price_'.$idGlobalDemand); - if (Validate::isPrice($demandPrice)) { - if ($objGlobalDemand->price != $demandPrice) { - $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); - $objRoomTypeDemandPrice->id_product = $idProduct; - $objRoomTypeDemandPrice->id_global_demand = $idGlobalDemand; - $objRoomTypeDemandPrice->id_option = 0; - $objRoomTypeDemandPrice->price = $demandPrice; - $objRoomTypeDemandPrice->save(); - } - } else { - $this->context->controller->errors[] = $this->l('Invalid demand price of facility'). - ' : '.$objGlobalDemand->name[$this->context->language->id]; - } - if ($advOptions = $objAdvOption->getGlobalDemandAdvanceOptions($idGlobalDemand)) { - foreach ($advOptions as $option) { - if (Validate::isLoadedObject($objAdvOption = new HotelRoomTypeGlobalDemandAdvanceOption($option['id']))) { - $optionPrice = Tools::getValue('option_price_'.$option['id']); - if (Validate::isPrice($optionPrice)) { - if ($optionPrice != $objAdvOption->price) { - $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); - $objRoomTypeDemandPrice->id_product = $idProduct; - $objRoomTypeDemandPrice->id_global_demand = $idGlobalDemand; - $objRoomTypeDemandPrice->id_option = $option['id']; - $objRoomTypeDemandPrice->price = $optionPrice; - $objRoomTypeDemandPrice->save(); - } - } else { - $this->context->controller->errors[] = $this->l('Invalid price of advance option'). - ' : '.$objAdvOption->name[$this->context->language->id]; - } - } - } - } - } - } - if (count($this->context->controller->errors)) { - $this->context->controller->warnings[] = $this->l('Invalid price values are not saved. Please correct them and save again'); - } - - $objCartBookingData = new HotelCartBookingData(); - if ($cartExtraDemands = $objCartBookingData->getCartExtraDemands(0, $idProduct)) { - // delete the demands from cart if not available in cart - $objRoomDemand = new HotelRoomTypeDemand(); - $roomTypeDemandIds = array(); - if ($roomTypeDemands = $objRoomDemand->getRoomTypeDemands($idProduct)) { - $roomTypeDemandIds = array_keys($roomTypeDemands); - } - foreach ($cartExtraDemands as &$demandInfo) { - if (isset($demandInfo['extra_demands']) && $demandInfo['extra_demands']) { - $cartChanged = 0; - foreach ($demandInfo['extra_demands'] as $key => $demand) { - if (!in_array($demand['id_global_demand'], $roomTypeDemandIds)) { - $cartChanged = 1; - unset($demandInfo['extra_demands'][$key]); - } - } - if ($cartChanged) { - if (Validate::isLoadedObject( - $objCartBooking = new HotelCartBookingData($demandInfo['id']) - )) { - $objCartBooking->extra_demands = json_encode($demandInfo['extra_demands']); - $objCartBooking->save(); - } - } - } - } - } - } - } - } - public function hookActionProductSave($params) { $isToggling = Tools::getValue('statusproduct'); @@ -360,14 +243,6 @@ class HotelReservationSystem extends Module } } - public function hookActionAdminControllerSetMedia() - { - if ('AdminProducts' == Tools::getValue('controller')) { - $this->context->controller->addJs($this->_path.'views/js/roomTypeDemand.js'); - $this->context->controller->addCSS($this->_path.'views/css/roomTypeDemand.css'); - } - } - public function hookDisplayBackOfficeHeader() { $this->context->controller->addCSS($this->_path.'views/css/admin/css/hotel_admin_tab_logo.css'); @@ -509,9 +384,6 @@ class HotelReservationSystem extends Module 'actionProductSave', 'addWebserviceResources', 'actionObjectLanguageAddAfter', - 'actionAdminControllerSetMedia', - 'displayAdminProductsExtra', - 'actionProductUpdate', 'actionObjectProfileAddAfter', 'actionObjectProfileDeleteBefore', 'actionObjectGroupDeleteBefore', diff --git a/modules/hotelreservationsystem/views/css/roomTypeDemand.css b/modules/hotelreservationsystem/views/css/roomTypeDemand.css deleted file mode 100644 index e0eb196eb..000000000 --- a/modules/hotelreservationsystem/views/css/roomTypeDemand.css +++ /dev/null @@ -1,42 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -/*----- Accordion -----*/ -.accordion, .accordion * { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; -} -.accordion { - overflow:hidden; - border-bottom: 1px solid #CCCCCC; -} -.accordion-section-title { - width:100%; - padding:15px; - display:inline-block; - transition:all linear 0.15s; - color:#252525 !important; - text-decoration:none !important; -} -.accordion-section-content { - display:none; - border-top: 1px solid #eee; - padding-top: 15px; -} \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/js/roomTypeDemand.js b/modules/hotelreservationsystem/views/js/roomTypeDemand.js deleted file mode 100644 index 8b84ee213..000000000 --- a/modules/hotelreservationsystem/views/js/roomTypeDemand.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -$(document).ready(function() { - function close_accordion_section() { - $('.accordion .accordion-section-title').removeClass('active'); - $('.accordion .accordion-section-content').slideUp(300).removeClass('open'); - } - - $(document).on('click', '.accordion-section-title', function(e) { - // Grab current anchor value - var currentAttrValue = $(this).attr('href'); - - if ($(e.target).is('.active')) { - close_accordion_section(); - $(this).find('i').removeClass('icon-angle-down'); - $(this).find('i').addClass('icon-angle-left'); - } else { - close_accordion_section(); - // Add active class to section title - $(this).addClass('active'); - $(this).find('i').removeClass('icon-angle-left'); - $(this).find('i').addClass('icon-angle-down'); - // Open up the hidden content panel - $('.accordion ' + currentAttrValue).slideDown(300).addClass('open'); - } - e.preventDefault(); - }); - - $(document).on('click', '.selected_demand', function(e) { - e.stopPropagation(); - }); -}); \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/hook/roomTypeDemands.tpl b/modules/hotelreservationsystem/views/templates/hook/roomTypeDemands.tpl deleted file mode 100644 index 90c2c7b0b..000000000 --- a/modules/hotelreservationsystem/views/templates/hook/roomTypeDemands.tpl +++ /dev/null @@ -1,127 +0,0 @@ -{* -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*} - -{if isset($idProduct) && $idProduct} -
-
-
- {l s='Room Type Additional Facilities' mod='hotelreservationsystem'} -
-
- {l s='To create new please visit' mod='hotelreservationsystem'} {l s='Additional facilities' mod='hotelreservationsystem'} {l s='page' mod='hotelreservationsystem'}. -
- {if isset($allDemands) && $allDemands} -
- {foreach $allDemands as $key => $demand} -
-
- -   {$demand['name']|escape:'html':'UTF-8'} - -
- {if isset($demand['adv_option']) && count($demand['adv_option'])} - - {else} -
- -
-
- {$defaultcurrencySign|escape:'html':'UTF-8'} - -
-
-
- {/if} - {if isset($demand['adv_option']) && $demand['adv_option']} -
- -
-
- - - - - - - - {foreach from=$demand['adv_option'] key=key item=info} - - - - - {/foreach} -
- {l s='Option Name' mod='hotelreservationsystem'} - - {l s='Price' mod='hotelreservationsystem'} -
- {$info['name']|escape:'html':'UTF-8'} - -
- {$defaultcurrencySign|escape:'html':'UTF-8'} - -
-
-
-
-
- {/if} -
-
-
- {/foreach} -
- - {else} -
- {l s='No additional facilities created yet. To create please visit' mod='hotelreservationsystem'} {l s='Additional facilities' mod='hotelreservationsystem'} {l s='page' mod='hotelreservationsystem'}. -
- {/if} -
-
-{else} -
-
- - {l s='There is 1 warning.' mod='hotelreservationsystem'} -
    -
  • {l s='You must save this product before selecting room type addttional facilities.' mod='hotelreservationsystem'}
  • -
-
-
-{/if} \ No newline at end of file From ed13e9c076b72233fd0b6999db507ba6138f2e57 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Wed, 23 Nov 2022 13:03:38 +0530 Subject: [PATCH 07/42] Resolved : count(): Parameter must be an array or an object that implements Countable In classes/webservice/WebserviceOutputJSON.php --- classes/webservice/WebserviceOutputJSON.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/webservice/WebserviceOutputJSON.php b/classes/webservice/WebserviceOutputJSON.php index f1e8cf7c5..0e2da03c4 100644 --- a/classes/webservice/WebserviceOutputJSON.php +++ b/classes/webservice/WebserviceOutputJSON.php @@ -40,7 +40,7 @@ class WebserviceOutputJSON implements WebserviceOutputInterface /** * Current association */ - protected $currentAssociatedEntity; + protected $currentAssociatedEntity = array(); /** * Json content From 117d98280c3799c04a7c1cf9accdf4ca8b8dc108 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sat, 26 Nov 2022 16:31:50 +0530 Subject: [PATCH 08/42] added booking for someone else feature --- .../controllers/orders/helpers/view/view.tpl | 27 +++++- classes/BookingStayingGuest.php | 71 +++++++++++++++ classes/Cart.php | 3 + classes/PaymentModule.php | 29 ++++++ .../CheckoutCustomerDetailsStep.php | 10 ++- classes/order/Order.php | 4 + controllers/admin/AdminOrdersController.php | 7 ++ controllers/front/OrderOpcController.php | 42 +++++++++ install/data/db_structure.sql | 15 ++++ js/validate.js | 10 ++- .../hotel-reservation-theme/js/order-opc.js | 38 ++++++++ themes/hotel-reservation-theme/order-opc.tpl | 89 ++++++++++++++----- 12 files changed, 316 insertions(+), 29 deletions(-) create mode 100644 classes/BookingStayingGuest.php diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 15a2ef097..66dd53a9c 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -669,15 +669,27 @@

{l s='This feature will generate a random password and send an email to the customer.'}

+
+
{l s='Email'}
+
{$customer->email}
+ {if $addresses.invoice->phone_mobile || $addresses.invoice->phone} +
{l s='Phone'}
+
{if $addresses.invoice->phone_mobile}{$addresses.invoice->phone_mobile}{else}{$addresses.invoice->phone}{/if}

+ {/if} +
{else}
{l s='A registered customer account has already claimed this email address'}
{/if} {else} -
+
{l s='Email'}
{$customer->email}

+ {if $addresses.invoice->phone_mobile || $addresses.invoice->phone} +
{l s='Phone'}
+
{if $addresses.invoice->phone_mobile}{$addresses.invoice->phone_mobile}{else}{$addresses.invoice->phone}{/if}

+ {/if}
{l s='Account registered'}
{dateFormat date=$customer->date_add full=true}
+ {if $order->id_booking_staying_guest} +
+
+ {l s='Staying guest'} +
+
{l s='Name'}
+
{$bookingStayingGuest->firstname} {$bookingStayingGuest->lastname}

+
{l s='Email'}
+
{$bookingStayingGuest->email}

+
{l s='Phone'}
+
{$bookingStayingGuest->phone}
+
+ {/if} {/if} diff --git a/classes/BookingStayingGuest.php b/classes/BookingStayingGuest.php new file mode 100644 index 000000000..4d297b70e --- /dev/null +++ b/classes/BookingStayingGuest.php @@ -0,0 +1,71 @@ + +* @copyright 2010-2022 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +class BookingStayingGuestCore extends ObjectModel +{ + public $id_booking_staying_guest; + public $id_gender; + public $firstname; + public $lastname; + public $email; + public $phone; + public $date_add; + public $date_upd; + + public static $definition = array( + 'table' => 'booking_staying_guest', + 'primary' => 'id_booking_staying_guest', + 'fields' => array( + 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), + 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128), + 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + ); + + public static function getBookingStayingGuestInfo($id_booking_staying_guest) + { + return Db::getInstance()->getRow(' + SELECT * FROM `'._DB_PREFIX_.'booking_staying_guest` + WHERE `id_booking_staying_guest` = '.(int)$id_booking_staying_guest + ); + } + + public function validateGuestInfo() + { + $isValid = true; + if (!trim($this->firstname) || !Validate::isName($this->firstname)) { + $isValid = false; + } + if (!trim($this->lastname) || !Validate::isName($this->lastname)) { + $isValid = false; + } + if (!trim($this->email) || !Validate::isEmail($this->email)) { + $isValid = false; + } + if (!trim($this->phone) || !Validate::isPhoneNumber($this->phone)) { + $isValid = false; + } + return $isValid; + } +} \ No newline at end of file diff --git a/classes/Cart.php b/classes/Cart.php index 18b2c15cf..9e5669df0 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -88,6 +88,8 @@ class CartCore extends ObjectModel */ public $is_advance_payment; + public $id_booking_staying_guest; + protected static $_nbProducts = array(); protected static $_isVirtualCart = array(); @@ -116,6 +118,7 @@ class CartCore extends ObjectModel 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_booking_staying_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 39b850a28..07ae42212 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -362,6 +362,11 @@ abstract class PaymentModuleCore extends Module $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); } + // save staying guest information + if ($this->context->cart->id_booking_staying_guest) { + $order->id_booking_staying_guest = (int)$this->context->cart->id_booking_staying_guest; + } + // Creating order $result = $order->add(); @@ -1017,6 +1022,30 @@ abstract class PaymentModuleCore extends Module null, _PS_MAIL_DIR_, false, (int)$order->id_shop ); } + // send mail to staying guest if customer booked for someone other. + if ($order->id_booking_staying_guest) { + if ($stayingGuestInfo = BookingStayingGuest::getBookingStayingGuestInfo( + $order->id_booking_staying_guest + )) { + if (Validate::isEmail($stayingGuestInfo['email'])) { + $data['{firstname}'] = $stayingGuestInfo['firstname']; + $data['{lastname}'] = $stayingGuestInfo['lastname']; + $data['{email}'] = $stayingGuestInfo['email']; + Mail::Send( + (int)$order->id_lang, + 'order_conf', + Mail::l('Order confirmation', (int)$order->id_lang), + $data, + $stayingGuestInfo['email'], + $stayingGuestInfo['firstname'].' '.$stayingGuestInfo['lastname'], + null, + null, + $file_attachement, + null, _PS_MAIL_DIR_, false, (int)$order->id_shop + ); + } + } + } } if (Configuration::get('PS_ORDER_CONF_MAIL_TO_SUPERADMIN')){ // send superadmin information diff --git a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php index 6b6263651..543f2e286 100644 --- a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php +++ b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php @@ -42,9 +42,17 @@ class CheckoutCustomerDetailsStep extends AbstractCheckoutStep } } } elseif (Tools::getValue('proceed_to_payment')) { + $guestInfoComplete = true; + if ($this->context->cart->id_booking_staying_guest) { + $guestInfoComplete = false; + $objBookingStayingGuest = new BookingStayingGuest($this->context->cart->id_booking_staying_guest); + if ($objBookingStayingGuest->validateGuestInfo()) { + $guestInfoComplete = true; + } + } $this->step_is_reachable = 1; $this->step_is_current = 1; - if ($idAddressDelivery) { + if ($idAddressDelivery && $guestInfoComplete) { if (Validate::isLoadedObject($objAddress)) { $this->step_is_current = 0; $this->step_is_complete = 1; diff --git a/classes/order/Order.php b/classes/order/Order.php index 548e58610..5f108da9e 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -59,6 +59,9 @@ class OrderCore extends ObjectModel /** @var int Customer id */ public $id_customer; + /** @var int Staying guest id */ + public $id_booking_staying_guest; + /** @var int Carrier id */ public $id_carrier; @@ -206,6 +209,7 @@ class OrderCore extends ObjectModel 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_booking_staying_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'current_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index a7e150ecc..3b43d4eb9 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1334,6 +1334,12 @@ class AdminOrdersControllerCore extends AdminController $this->toolbar_title .= ' - '.sprintf($this->l('Shop: %s'), $shop->name); } + // get details if booking is done for some other guest + $bookingStayingGuest = false; + if ($order->id_booking_staying_guest) { + $bookingStayingGuest = new BookingStayingGuest($order->id_booking_staying_guest); + } + // gets warehouses to ship products, if and only if advanced stock management is activated $warehouse_list = null; @@ -1516,6 +1522,7 @@ class AdminOrdersControllerCore extends AdminController 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, + 'bookingStayingGuest' => $bookingStayingGuest, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array( 'delivery' => $addressDelivery, diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index a4660529c..5cac05ba3 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -317,6 +317,10 @@ class OrderOpcControllerCore extends ParentOrderController $this->ajaxDie($this->changeRoomDemands()); exit; break; + case 'submitBookingStayingGuest': + $this->ajaxDie($this->submitBookingStayingGuest()); + exit; + break; default: throw new PrestaShopException('Unknown method "'.Tools::getValue('method').'"'); } @@ -477,6 +481,13 @@ class OrderOpcControllerCore extends ParentOrderController $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); + // GUEST BOOKING + if ($this->isLogged) { + if ($this->context->cart->id_booking_staying_guest) { + $this->context->smarty->assign('booking_staying_guest', BookingStayingGuest::getBookingStayingGuestInfo($this->context->cart->id_booking_staying_guest)); + } + $this->context->smarty->assign('id_booking_staying_guest', $this->context->cart->id_booking_staying_guest); + } Tools::safePostVars(); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active); @@ -964,4 +975,35 @@ class OrderOpcControllerCore extends ParentOrderController } die('0'); } + + public function submitBookingStayingGuest() + { + $booking_staying_guest = Tools::getValue('booking_staying_guest'); + $this->context->cookie->__set('customer_details_proceeded', 0); + $this->context->cookie->checkedTOS = false; + if ($booking_staying_guest) { + if ($this->context->cart->id_booking_staying_guest) { + $objBookingStayingGuest = new BookingStayingGuest($this->context->cart->id_booking_staying_guest); + } else { + $objBookingStayingGuest = new BookingStayingGuest(); + } + $booking_staying_guest_gender = Tools::getValue('booking_staying_guest_gender'); + $booking_staying_guest_firstname = Tools::getValue('booking_staying_guest_firstname'); + $booking_staying_guest_lastname = Tools::getValue('booking_staying_guest_lastname'); + $booking_staying_guest_email = Tools::getValue('booking_staying_guest_email'); + $booking_staying_guest_phone = Tools::getValue('booking_staying_guest_phone'); + $objBookingStayingGuest->id_gender = $booking_staying_guest_gender; + $objBookingStayingGuest->firstname = $booking_staying_guest_firstname; + $objBookingStayingGuest->lastname = $booking_staying_guest_lastname; + $objBookingStayingGuest->email = $booking_staying_guest_email; + $objBookingStayingGuest->phone = $booking_staying_guest_phone; + $objBookingStayingGuest->save(); + $this->context->cart->id_booking_staying_guest = $objBookingStayingGuest->id; + } else { + $objBookingStayingGuest = new BookingStayingGuest($this->context->cart->id_booking_staying_guest); + $objBookingStayingGuest->delete(); + $this->context->cart->id_booking_staying_guest = false; + } + $this->context->cart->save(); + } } diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index a3aa8160d..b32447bdb 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -182,6 +182,7 @@ CREATE TABLE `PREFIX_cart` ( `id_currency` int(10) unsigned NOT NULL, `id_customer` int(10) unsigned NOT NULL, `id_guest` int(10) unsigned NOT NULL, + `id_booking_staying_guest` int(10) unsigned NOT NULL, `secure_key` varchar(32) NOT NULL DEFAULT '-1', `recyclable` tinyint(1) unsigned NOT NULL DEFAULT '1', `gift` tinyint(1) unsigned NOT NULL DEFAULT '0', @@ -673,6 +674,19 @@ CREATE TABLE `PREFIX_customer_thread` ( KEY `id_product` (`id_product`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; +CREATE TABLE `PREFIX_booking_staying_guest` ( + `id_booking_staying_guest` int(10) unsigned NOT NULL auto_increment, + `id_cart` int(10) unsigned NOT NULL, + `id_order` int(10) unsigned NOT NULL, + `id_gender` int(10) unsigned NOT NULL, + `firstname` varchar(32) NOT NULL, + `lastname` varchar(32) NOT NULL, + `email` varchar(128) NOT NULL, + `phone` varchar(32) DEFAULT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_booking_staying_guest`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_customization` ( `id_customization` int(10) unsigned NOT NULL auto_increment, @@ -1098,6 +1112,7 @@ CREATE TABLE `PREFIX_orders` ( `id_carrier` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `id_customer` int(10) unsigned NOT NULL, + `id_booking_staying_guest` int(10) unsigned NOT NULL, `id_cart` int(10) unsigned NOT NULL, `id_currency` int(10) unsigned NOT NULL, `id_address_delivery` int(10) unsigned NOT NULL, diff --git a/js/validate.js b/js/validate.js index 85b041fbb..a724f516b 100644 --- a/js/validate.js +++ b/js/validate.js @@ -192,12 +192,16 @@ function validate_field(that) } else if($(that).attr('data-validate')) var result = window['validate_' + $(that).attr('data-validate')]($(that).val()); - - if (result) + if (result) { $(that).parent().removeClass('form-error').addClass('form-ok'); - else + return true; + } else { $(that).parent().addClass('form-error').removeClass('form-ok'); + return false; + } + } + return true; } $(document).on('focusout', 'input.validate, textarea.validate', function() { diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 728a14494..2c11ef492 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -50,6 +50,44 @@ $(document).ready(function() $("#partial_data").slideDown(); }); + // staying guest booking + function initGuestbookingcontainer() { + if ($("#booking_staying_guest:checked").val() == 1) { + $('#customer_info_container').hide('slow'); + $('#booking_staying_guest_container').show('slow'); + } else { + $('#booking_staying_guest_container').hide('slow'); + $('#customer_info_container').show('slow'); + } + } + function validateBookingStayingGuestForm() { + $('#booking_staying_guest_form input.validate').each(function (index, element) { + if (!validate_field(element)) { + if ($('#cgv').prop('checked') == 1) { + $('#cgv').trigger('click'); + } + } + }); + } + initGuestbookingcontainer(); + $("#booking_staying_guest").on('change',function() { + initGuestbookingcontainer(); + }); + if ($("#booking_staying_guest:checked").val() == 1) { + validateBookingStayingGuestForm(); + } + + $('#booking_staying_guest_form').on('change', function(e) { + $.ajax({ + type: 'POST', + url: orderOpcUrl, + async: false, + cache: false, + dataType : "json", + data: $(this).serialize()+'&method=submitBookingStayingGuest&ajax=true&token=' + static_token + }); + }); + // GUEST CHECKOUT / NEW ACCOUNT MANAGEMENT if ((typeof isLogged == 'undefined' || !isLogged) || (typeof isGuest !== 'undefined' && isGuest)) { diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index 76312fcaa..2e0696581 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -78,33 +78,74 @@
{if $is_logged || $isGuest} -
-
{l s='Name'}
-
{$guestInformations['firstname']} {$guestInformations['lastname']}
-
-
-
{l s='Email'}
-
{$guestInformations['email']}
-
- {if (isset($delivery->phone_mobile) && $delivery->phone_mobile) || (isset($delivery->phone) && $delivery->phone)} -
-
- {if isset($delivery->phone_mobile) && $delivery->phone_mobile} - {l s='Mobile Number'} - {else} - {l s='Phone Number'} - {/if} +
+ {if $is_logged} +

+ + +

+ {/if} +
+
+
+ + +
+
+ + +
+
+ + +
-
- {if isset($delivery->phone_mobile) && $delivery->phone_mobile} - {$delivery->phone_mobile|escape:'html':'UTF-8'} - {else} - {$delivery->phone|escape:'html':'UTF-8'} - {/if} +
+
+ + +
+
+
+
+ + +
- {/if} - +
+
+
{l s='Name'}
+
{$guestInformations['firstname']} {$guestInformations['lastname']}
+
+
+
{l s='Email'}
+
{$guestInformations['email']}
+
+ {if (isset($delivery->phone_mobile) && $delivery->phone_mobile) || (isset($delivery->phone) && $delivery->phone)} +
+
+ {if isset($delivery->phone_mobile) && $delivery->phone_mobile} + {l s='Mobile Number'} + {else} + {l s='Phone Number'} + {/if} +
+
+ {if isset($delivery->phone_mobile) && $delivery->phone_mobile} + {$delivery->phone_mobile|escape:'html':'UTF-8'} + {else} + {$delivery->phone|escape:'html':'UTF-8'} + {/if} +
+
+ {/if} +
+ {* proceed only if no order restrict errors are there *} {if !$orderRestrictErr}
From 41b6b4caa27e4531a2bc5757e91a1a1aeb21e28f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 28 Nov 2022 19:35:15 +0530 Subject: [PATCH 09/42] Move search filters to Room Types configurations page --- .../admin/AdminPPreferencesController.php | 23 +++ install/data/theme.sql | 2 + install/data/xml/configuration.xml | 6 + .../wkhotelfilterblock/wkhotelfilterblock.php | 163 ------------------ 4 files changed, 31 insertions(+), 163 deletions(-) diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 11c4203d3..3c02164d8 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -305,6 +305,29 @@ class AdminPPreferencesControllerCore extends AdminController // 'bottom' => '', // 'submit' => array('title' => $this->l('Save')) // ), + 'fo_search_filters' => array( + 'title' => $this->l('Search Filters'), + 'icon' => 'icon-search', + 'fields' => array( + 'SHOW_AMENITIES_FILTER' => array( + 'title' => $this->l('Show Amenities filter'), + 'hint' => $this->l('Enable to display Amenities filter for search.'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'required' => false, + 'type' => 'bool', + ), + 'SHOW_PRICE_FILTER' => array( + 'title' => $this->l('Show Price filter'), + 'hint' => $this->l('Enable to display Price filter for search.'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'required' => false, + 'type' => 'bool', + ), + ), + 'submit' => array('title' => $this->l('Save')) + ), ); } diff --git a/install/data/theme.sql b/install/data/theme.sql index 499aa07d3..f302b2c22 100644 --- a/install/data/theme.sql +++ b/install/data/theme.sql @@ -3,6 +3,8 @@ SET NAMES 'utf8'; UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS'; UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE'; UPDATE `PREFIX_configuration` SET value = '9' WHERE name = 'PS_HOTEL_IMAGES_PER_PAGE'; +UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_AMENITIES_FILTER'; +UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_PRICE_FILTER'; UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY'; UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY'; UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES'; diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 436515bc6..4a07b5e6c 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -59,6 +59,12 @@ 9 + + 1 + + + 1 + 0 diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 79a6423c8..8aada65ce 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -42,129 +42,6 @@ class wkhotelfilterblock extends Module $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } - public function getContent() - { - $this->html = ''; - if (Tools::isSubmit('btnConfigSubmit')) { - $this->postProcess(); - } else { - $this->html .= '
'; - } - - $this->html .= $this->renderForm(); - - return $this->html; - } - - public function renderForm() - { - $fields_form = array(); - $fields_form['form'] = array( - 'legend' => array( - 'icon' => 'icon-cog', - 'title' => $this->l('Search Results Filter Configuration'), - ), - 'input' => array( - array( - 'type' => 'switch', - 'label' => $this->l('Show Guest Rating Filter'), - 'name' => 'SHOW_RATTING_FILTER', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - ), - array( - 'id' => 'active_off', - 'value' => 0, - ), - ), - 'hint' => $this->l('If yes, it will display Guest Rating Filter.'), - ), - array( - 'type' => 'switch', - 'label' => $this->l('Show Amenities Filter'), - 'name' => 'SHOW_AMENITIES_FILTER', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - ), - array( - 'id' => 'active_off', - 'value' => 0, - ), - ), - 'hint' => $this->l('If yes, it will display Amenities Filter.'), - ), - array( - 'type' => 'switch', - 'label' => $this->l('Show Price Filter'), - 'name' => 'SHOW_PRICE_FILTER', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - ), - array( - 'id' => 'active_off', - 'value' => 0, - ), - ), - 'hint' => $this->l('If yes, it will display price Filter.'), - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'name' => 'submit_conf_filter', - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $this->fields_form = array(); - $helper->identifier = $this->identifier; - $helper->submit_action = 'btnConfigSubmit'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false). - '&configure='.$this->name.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id, - ); - - return $helper->generateForm(array($fields_form)); - } - - public function postProcess() - { - if (Tools::isSubmit('btnConfigSubmit')) { - Configuration::updateValue( - 'SHOW_RATTING_FILTER', - Tools::getValue('SHOW_RATTING_FILTER') - ); - Configuration::updateValue( - 'SHOW_AMENITIES_FILTER', - Tools::getValue('SHOW_AMENITIES_FILTER') - ); - Configuration::updateValue('SHOW_PRICE_FILTER', Tools::getValue('SHOW_PRICE_FILTER')); - - // redirect after saving the configuration - Tools::redirectAdmin( - $this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab. - '&module_name='.$this->name.'&conf=4' - ); - } - } - public function install() { if (!parent::install() @@ -174,11 +51,6 @@ class wkhotelfilterblock extends Module return false; } - //set default config variable` - Configuration::updateValue('SHOW_RATTING_FILTER', 1); - Configuration::updateValue('SHOW_AMENITIES_FILTER', 1); - Configuration::updateValue('SHOW_PRICE_FILTER', 1); - return true; } @@ -187,15 +59,6 @@ class wkhotelfilterblock extends Module $this->context->controller->addJQueryUI('ui.slider'); } - public function uninstall($keep = true) - { - if (!parent::uninstall() || !$this->deleteConfigKeys()) { - return false; - } - - return true; - } - public function hookDisplayLeftColumn() { if ($this->context->controller->php_self == 'category') { @@ -266,30 +129,4 @@ class wkhotelfilterblock extends Module return $this->display(__FILE__, 'htlfilterblock.tpl'); } } - - public function getConfigFieldsValues() - { - $config_vars = array( - 'SHOW_RATTING_FILTER' => Tools::getValue('SHOW_RATTING_FILTER', Configuration::get('SHOW_RATTING_FILTER')), - 'SHOW_AMENITIES_FILTER' => Tools::getValue('SHOW_AMENITIES_FILTER', Configuration::get('SHOW_AMENITIES_FILTER')), - 'SHOW_PRICE_FILTER' => Tools::getValue('SHOW_PRICE_FILTER', Configuration::get('SHOW_PRICE_FILTER')), - ); - - return $config_vars; - } - - public function deleteConfigKeys() - { - $var = array('SHOW_RATTING_FILTER', - 'SHOW_AMENITIES_FILTER', - 'SHOW_PRICE_FILTER', ); - - foreach ($var as $key) { - if (!Configuration::deleteByName($key)) { - return false; - } - } - - return true; - } } From 53f1758f5f4c71650f58f8df39e6e3dc2107cfe7 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 30 Nov 2022 16:42:53 +0530 Subject: [PATCH 10/42] Add missing file --- .../products/additionalfacilities.tpl | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 admin/themes/default/template/controllers/products/additionalfacilities.tpl diff --git a/admin/themes/default/template/controllers/products/additionalfacilities.tpl b/admin/themes/default/template/controllers/products/additionalfacilities.tpl new file mode 100644 index 000000000..184db5f77 --- /dev/null +++ b/admin/themes/default/template/controllers/products/additionalfacilities.tpl @@ -0,0 +1,115 @@ +{** + * 2010-2022 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2022 Webkul IN + * @license LICENSE.txt + *} + + {if isset($product->id) && $product->id} + +
+
+ {l s='Room Type Additional Facilities'} +
+
+ {l s='To create new Additiona facilities '} {l s='click here.'} +
+ {if isset($allDemands) && $allDemands} +
+ {foreach $allDemands as $key => $demand} +
+ + + {$demand['name']|escape:'html':'UTF-8'} + +
+ {if isset($demand['adv_option']) && count($demand['adv_option'])} + + {else} +
+ +
+
+ {$defaultcurrencySign|escape:'html':'UTF-8'} + +
+
+
+ {/if} + {if isset($demand['adv_option']) && $demand['adv_option']} +
+ +
+
+ + + + + + + + {foreach from=$demand['adv_option'] key=key item=info} + + + + + {/foreach} +
+ {l s='Option Name'} + + {l s='Price'} +
+ {$info['name']|escape:'html':'UTF-8'} + +
+ {$defaultcurrencySign|escape:'html':'UTF-8'} + +
+
+
+
+
+ {/if} +
+
+ {/foreach} +
+ + {else} +
+ {l s='No additional facilities created yet. To create please visit'} {l s='Additional facilities'} {l s='page'}. +
+ {/if} +
+{/if} From 579fadee674da9ec3d342c105aa2b727953f8f0e Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Fri, 2 Dec 2022 13:15:05 +0530 Subject: [PATCH 11/42] Allow admin user to configure the SameSite cookie attribute --- classes/Cookie.php | 54 +++++++++++++++++-- config/config.inc.php | 4 +- .../admin/AdminAdminPreferencesController.php | 16 ++++++ install/data/xml/configuration.xml | 3 ++ 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/classes/Cookie.php b/classes/Cookie.php index 920415da6..f8d66aa3a 100644 --- a/classes/Cookie.php +++ b/classes/Cookie.php @@ -26,6 +26,25 @@ class CookieCore { + const SAMESITE_NONE = 'None'; + const SAMESITE_LAX = 'Lax'; + const SAMESITE_STRICT = 'Strict'; + + const SAMESITE_AVAILABLE_VALUES = [ + [ + "type" => self::SAMESITE_NONE, + "name" => self::SAMESITE_NONE + ], + [ + "type" => self::SAMESITE_LAX, + "name" => self::SAMESITE_LAX + ], + [ + "type" => self::SAMESITE_STRICT, + "name" => self::SAMESITE_STRICT + ], + ]; + /** @var array Contain cookie content in a key => value format */ protected $_content; @@ -73,6 +92,7 @@ class CookieCore $this->_path = str_replace('%2F', '/', $this->_path); $this->_path = str_replace('%7E', '~', $this->_path); $this->_domain = $this->getDomain($shared_urls); + $this->_sameSite = Configuration::get('PS_COOKIE_SAMESITE'); $this->_name = 'PrestaShop-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain); $this->_allow_writing = true; $this->_salt = $this->_standalone ? str_pad('', 8, md5('ps'.__FILE__)) : _COOKIE_IV_; @@ -82,7 +102,7 @@ class CookieCore } else { $this->_cipherTool = new PhpEncryption(_NEW_COOKIE_KEY_); } - + $this->_secure = (bool)$secure; $this->update(); @@ -342,11 +362,35 @@ class CookieCore $content = 0; $time = 1; } - if (PHP_VERSION_ID <= 50200) { /* PHP version > 5.2.0 */ - return setcookie($this->_name, $content, $time, $this->_path, $this->_domain, $this->_secure); - } else { - return setcookie($this->_name, $content, $time, $this->_path, $this->_domain, $this->_secure, true); + + /* + * The alternative signature supporting an options array is only available since + * PHP 7.3.0, before there is no support for SameSite attribute. + */ + if (PHP_VERSION_ID < 70300) { + return setcookie( + $this->_name, + $content, + $time, + $this->_path, + $this->_domain . '; SameSite=' . $this->_sameSite, + $this->_secure, + true + ); } + + return setcookie( + $this->_name, + $content, + [ + 'expires' => $time, + 'path' => $this->_path, + 'domain' => $this->_domain, + 'secure' => $this->_secure, + 'httponly' => true, + 'samesite' => $this->_sameSite, + ] + ); } public function __destruct() diff --git a/config/config.inc.php b/config/config.inc.php index c9b3f60ca..6ce828748 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -159,10 +159,10 @@ if ($cookie_lifetime > 0) { $cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600); } +$force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'); if (defined('_PS_ADMIN_DIR_')) { - $cookie = new Cookie('psAdmin', '', $cookie_lifetime); + $cookie = new Cookie('psAdmin', '', $cookie_lifetime, null, false, $force_ssl); } else { - $force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'); if ($context->shop->getGroup()->share_order) { $cookie = new Cookie('ps-sg'.$context->shop->getGroup()->id, '', $cookie_lifetime, $context->shop->getUrlsSharedCart(), false, $force_ssl); } else { diff --git a/controllers/admin/AdminAdminPreferencesController.php b/controllers/admin/AdminAdminPreferencesController.php index 9e3124ecb..8179c1f26 100644 --- a/controllers/admin/AdminAdminPreferencesController.php +++ b/controllers/admin/AdminAdminPreferencesController.php @@ -85,6 +85,16 @@ class AdminAdminPreferencesControllerCore extends AdminController 'default' => '480', 'visibility' => Shop::CONTEXT_ALL ), + 'PS_COOKIE_SAMESITE' => array( + 'title' => $this->l('Same site cookie'), + 'hint' => $this->l('Allows you to declare if your cookie should be restricted to a first-party or same-site context.'), + 'validation' => 'isGenericName', + 'type' => 'select', + 'cast' => 'strval', + 'identifier' => 'type', + 'list' => CookieCore::SAMESITE_AVAILABLE_VALUES, + 'visibility' => Shop::CONTEXT_ALL + ), ), 'submit' => array('title' => $this->l('Save')) ), @@ -159,6 +169,12 @@ class AdminAdminPreferencesControllerCore extends AdminController $upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize')); $post_max_size = (int)str_replace('M', '', ini_get('post_max_size')); $max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size; + $forceSsl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'); + + if (!$forceSsl && Tools::getValue('PS_COOKIE_SAMESITE') === Cookie::SAMESITE_NONE) { + $this->errors[] = Tools::displayError('The SameSite=None is only available in secure mode.'); + return; + } if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size || Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size) { $this->errors[] = Tools::displayError('The limit chosen is larger than the server\'s maximum upload limit. Please increase the limits of your server.'); diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 436515bc6..98c79dd41 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -437,6 +437,9 @@ 480 + + Lax + 0 From 3bd98addb6321c7b96ed4a98a13ebff5fe3fa9f1 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 2 Dec 2022 15:12:32 +0530 Subject: [PATCH 12/42] Fix Book Now page isssue at back office --- classes/PaymentModule.php | 4 ++-- controllers/admin/AdminOrdersController.php | 6 ------ .../admin/AdminHotelRoomsBookingController.php | 10 +++++----- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 39b850a28..d40602bde 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -850,8 +850,8 @@ abstract class PaymentModuleCore extends Module HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart); if (isset($_COOKIE['wk_id_cart'])) { - setcookie('wk_id_cart', ' ', time() - 86400, '/'); - setcookie('wk_id_guest', ' ', time() - 86400, '/'); + setcookie('wk_id_cart', ' ', time() - 86400, $this->context->shop->physical_uri); + setcookie('wk_id_guest', ' ', time() - 86400, $this->context->shop->physical_uri); unset($_COOKIE['wk_id_cart']); unset($_COOKIE['wk_id_guest']); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index a7e150ecc..1fc055c12 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -864,13 +864,7 @@ class AdminOrdersControllerCore extends AdminController false, $cart->secure_key ); - /* - setcookie('wk_id_cart', ' ', time() - 86400, '/'); - setcookie('wk_id_guest', ' ', time() - 86400, '/'); - unset($_COOKIE['wk_id_cart']); - unset($_COOKIE['wk_id_guest']); - */ if ($payment_module->currentOrder) { Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 2c8e81273..61800e722 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -42,10 +42,10 @@ class AdminHotelRoomsBookingController extends ModuleAdminController Guest::setNewGuest($this->context->cookie); } - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, "/"); + setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, $this->context->shop->physical_uri); } else { $this->context->cookie->id_guest = $_COOKIE['wk_id_guest']; - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, "/"); + setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, $this->context->shop->physical_uri); } $guest = new Guest($this->context->cookie->id_guest); @@ -67,13 +67,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $this->context->cart = $cart; $this->context->cookie->id_cart = $cart->id; - setcookie('wk_id_cart', $cart->id, time() + 86400, "/"); + setcookie('wk_id_cart', $cart->id, time() + 86400, $this->context->shop->physical_uri); } else { $cart = new Cart((int)$_COOKIE['wk_id_cart']); $this->context->cart = $cart; $this->context->cookie->id_cart = $cart->id; - setcookie('wk_id_cart', $cart->id, time() + 86400, "/"); + setcookie('wk_id_cart', $cart->id, time() + 86400, $this->context->shop->physical_uri); } $customer = new Customer(); @@ -409,7 +409,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'rms_in_cart' => $rms_in_cart, 'total_amount' => Tools::displayPrice($total_amount), 'booking_stats' => $booking_stats, - 'id_cart_book_data' => $obj_cart_book_data->id); + 'id_cart_book_data' => $obj_cart_book_data->id ); if ($obj_cart_book_data->id) { From 74929749421a849fbaea7ac0b247799b42691edb Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 2 Dec 2022 16:46:43 +0530 Subject: [PATCH 13/42] Remove extra variable assignment --- controllers/admin/AdminProductsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 487d132ec..cbce182d6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3747,7 +3747,6 @@ class AdminProductsControllerCore extends AdminController $data->assign(array( 'product' => $obj, - 'idProduct' => $obj->id, 'roomDemandPrices' => $roomDemandPrices, 'allDemands' => $allDemands, 'defaultcurrencySign' => $objCurrency->sign, From 4e86d85132d83d17edd554a012ad3f46fa952f1b Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 2 Dec 2022 17:11:59 +0530 Subject: [PATCH 14/42] Fix search results page issue and text changes --- controllers/admin/AdminPPreferencesController.php | 6 +++--- modules/wkhotelfilterblock/wkhotelfilterblock.php | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 3c02164d8..8d76770bb 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -306,12 +306,12 @@ class AdminPPreferencesControllerCore extends AdminController // 'submit' => array('title' => $this->l('Save')) // ), 'fo_search_filters' => array( - 'title' => $this->l('Search Filters'), + 'title' => $this->l('Search Results Page Filters'), 'icon' => 'icon-search', 'fields' => array( 'SHOW_AMENITIES_FILTER' => array( 'title' => $this->l('Show Amenities filter'), - 'hint' => $this->l('Enable to display Amenities filter for search.'), + 'hint' => $this->l('Enable to display Amenities filter.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, @@ -319,7 +319,7 @@ class AdminPPreferencesControllerCore extends AdminController ), 'SHOW_PRICE_FILTER' => array( 'title' => $this->l('Show Price filter'), - 'hint' => $this->l('Enable to display Price filter for search.'), + 'hint' => $this->l('Enable to display Price filter.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 8aada65ce..d385ed80c 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -129,4 +129,13 @@ class wkhotelfilterblock extends Module return $this->display(__FILE__, 'htlfilterblock.tpl'); } } + + public function getConfigFieldsValues() + { + return array( + 'SHOW_RATTING_FILTER' => Configuration::get('SHOW_RATTING_FILTER'), + 'SHOW_AMENITIES_FILTER' => Configuration::get('SHOW_AMENITIES_FILTER'), + 'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'), + ); + } } From 4da84bfbd42a46aa70df0eb7692aa3e742930436 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 6 Dec 2022 12:20:46 +0530 Subject: [PATCH 15/42] Remove usage of $_COOKIE when creating a booking at back office --- classes/PaymentModule.php | 8 -------- controllers/admin/AdminOrdersController.php | 7 +++++++ .../classes/HotelBookingDetail.php | 5 +++-- .../admin/AdminHotelRoomsBookingController.php | 18 +++++++----------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index d40602bde..56d60a748 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -849,14 +849,6 @@ abstract class PaymentModuleCore extends Module // delete cart feature prices after booking creation success HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart); - if (isset($_COOKIE['wk_id_cart'])) { - setcookie('wk_id_cart', ' ', time() - 86400, $this->context->shop->physical_uri); - setcookie('wk_id_guest', ' ', time() - 86400, $this->context->shop->physical_uri); - - unset($_COOKIE['wk_id_cart']); - unset($_COOKIE['wk_id_guest']); - } - if (self::DEBUG_MODE) { PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int)$id_cart, true); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 1fc055c12..bf5d787c0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -865,6 +865,13 @@ class AdminOrdersControllerCore extends AdminController $cart->secure_key ); + if (isset($this->context->cookie->wk_id_cart)) { + unset($this->context->cookie->wk_id_cart); + } + if (isset($this->context->cookie->wk_id_guest)) { + unset($this->context->cookie->wk_id_guest); + } + if ($payment_module->currentOrder) { Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); } diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 3f020f1ff..6e8f3c505 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -979,8 +979,9 @@ class HotelBookingDetail extends ObjectModel */ public function getAvailableRoomsForReallocation($date_from, $date_to, $room_type, $hotel_id) { - if (isset($_COOKIE['wk_id_cart'])) { - $current_admin_cart_id = $_COOKIE['wk_id_cart']; + $context = Context::getContext(); + if (isset($context->cookie->wk_id_cart)) { + $current_admin_cart_id = $context->cookie->wk_id_cart; } $exclude_ids = 'SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `date_from` < \''.pSQL($date_to).'\' AND `date_to` > \''.pSQL($date_from).'\' diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 61800e722..9a3a79eca 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -30,26 +30,22 @@ class AdminHotelRoomsBookingController extends ModuleAdminController parent::__construct(); - //unset($_COOKIE['wk_id_guest']); - //unset($_COOKIE['wk_id_cart']); $this->setPhpCookieData(); } public function setPhpCookieData() { - if (!isset($_COOKIE['wk_id_guest']) || !$_COOKIE['wk_id_guest']) { + if (!isset($this->context->cookie->wk_id_guest) || !$this->context->cookie->wk_id_guest) { if (!isset($this->context->cookie->id_guest)) { Guest::setNewGuest($this->context->cookie); } - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, $this->context->shop->physical_uri); + $this->context->cookie->wk_id_guest = $this->context->cookie->id_guest; } else { - $this->context->cookie->id_guest = $_COOKIE['wk_id_guest']; - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, $this->context->shop->physical_uri); + $this->context->cookie->id_guest = $this->context->cookie->wk_id_guest; } - $guest = new Guest($this->context->cookie->id_guest); - if (!isset($_COOKIE['wk_id_cart']) && !isset($this->context->cart->id)) { + if (!isset($this->context->cookie->wk_id_cart) && !isset($this->context->cart->id)) { $cart = new Cart(); $cart->recyclable = 0; @@ -67,13 +63,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $this->context->cart = $cart; $this->context->cookie->id_cart = $cart->id; - setcookie('wk_id_cart', $cart->id, time() + 86400, $this->context->shop->physical_uri); + $this->context->cookie->wk_id_cart = $cart->id; } else { - $cart = new Cart((int)$_COOKIE['wk_id_cart']); + $cart = new Cart((int) $this->context->cookie->wk_id_cart); $this->context->cart = $cart; $this->context->cookie->id_cart = $cart->id; - setcookie('wk_id_cart', $cart->id, time() + 86400, $this->context->shop->physical_uri); + $this->context->cookie->wk_id_cart = $cart->id; } $customer = new Customer(); From b5c81b008d1c4840c931973ad812d96853890b7c Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 7 Dec 2022 11:10:21 +0530 Subject: [PATCH 16/42] update correct amount in payment detail table --- classes/PaymentModule.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 86f9e02ce..48b772562 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -357,8 +357,10 @@ abstract class PaymentModuleCore extends Module $order->is_advance_payment = $this->context->cart->is_advance_payment; if ($order->is_advance_payment) { $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); + $order->real_paid_amount = ($order->advance_paid_amount * $amount_paid) / (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)); } else { $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); + $order->real_paid_amount = ($order->advance_paid_amount * $amount_paid) / (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)); } // Creating order @@ -373,7 +375,7 @@ abstract class PaymentModuleCore extends Module // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php // if ($order->total_paid != $order->total_paid_real) // We use number_format in order to compare two string - if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) { + if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_) && $this->name != 'cheque') { // if customer is paying full payment amount $id_order_state = Configuration::get('PS_OS_ERROR'); } @@ -437,7 +439,7 @@ abstract class PaymentModuleCore extends Module } foreach($order_list as $order) { - $order->addOrderPaymentDetail($order->advance_paid_amount); + $order->addOrderPaymentDetail($order->real_paid_amount); } } From 75e11b018cef48b261c6816479fcc09f9c529dc2 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 7 Dec 2022 15:45:37 +0530 Subject: [PATCH 17/42] update amount paid calculation --- classes/PaymentModule.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 48b772562..407f0ded3 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -356,11 +356,23 @@ abstract class PaymentModuleCore extends Module // advance payment information $order->is_advance_payment = $this->context->cart->is_advance_payment; if ($order->is_advance_payment) { - $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); - $order->real_paid_amount = ($order->advance_paid_amount * $amount_paid) / (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)); + $order->advance_paid_amount = (float)Tools::ps_round( + (float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), + _PS_PRICE_COMPUTE_PRECISION_ + ); + $order->amount_paid = (float)Tools::ps_round( + (($order->advance_paid_amount * $amount_paid) / $this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)), + _PS_PRICE_COMPUTE_PRECISION_ + ); } else { - $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); - $order->real_paid_amount = ($order->advance_paid_amount * $amount_paid) / (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)); + $order->advance_paid_amount = (float)Tools::ps_round( + (float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), + _PS_PRICE_COMPUTE_PRECISION_ + ); + $order->amount_paid = (float)Tools::ps_round( + (($order->advance_paid_amount * $amount_paid) / $this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)), + _PS_PRICE_COMPUTE_PRECISION_ + ); } // Creating order @@ -439,7 +451,7 @@ abstract class PaymentModuleCore extends Module } foreach($order_list as $order) { - $order->addOrderPaymentDetail($order->real_paid_amount); + $order->addOrderPaymentDetail($order->amount_paid); } } From d998279ef4e1f2fccc8c046f3f1a203f3d3fd116 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 13 Dec 2022 16:48:20 +0530 Subject: [PATCH 18/42] Allow admin to create new links on Hotel Reservation System > Settings page --- .../classes/HotelHelper.php | 75 ++++ .../classes/HotelReservationSystemDb.php | 25 +- .../classes/HotelSettingsLink.php | 148 ++++++++ ...minHotelConfigurationSettingController.php | 326 +++++++++++++++++- modules/hotelreservationsystem/define.php | 2 + .../helpers/form/form.tpl | 172 +++++++++ .../helpers/form/index.php | 29 ++ .../helpers/list/index.php | 29 ++ .../helpers/list/link-icon.tpl | 20 ++ .../helpers/list/link-page.tpl | 20 ++ .../helpers/view/view.tpl | 68 ++-- 11 files changed, 863 insertions(+), 51 deletions(-) create mode 100644 modules/hotelreservationsystem/classes/HotelSettingsLink.php create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/index.php create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/list/index.php create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/list/link-icon.tpl create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/list/link-page.tpl diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 44b43a517..55a118145 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -527,6 +527,80 @@ class HotelHelper } } + public function saveDefaultHotelSettingsLinks() + { + $settingsLinks = array( + array( + 'name' => 'General Settings', + 'hint' => 'Configure Your Hotel general Settings using this option.', + 'icon' => 'icon-cogs', + 'link' => 'index.php?controller=AdminHotelGeneralSettings', + 'unremovable' => 1, + ), + array( + 'name' => 'Order Restrict', + 'hint' => 'Configure if you want to restrict orders till a specific date for your hotels.', + 'icon' => 'icon-list-alt', + 'link' => 'index.php?controller=AdminOrderRestrictSettings', + 'unremovable' => 1, + ), + array( + 'name' => 'Advanced Price Rules', + 'hint' => 'Here set advanced price rules for specific dates.', + 'icon' => 'icon-cog', + 'link' => 'index.php?controller=AdminHotelFeaturePricesSettings', + 'unremovable' => 1, + ), + array( + 'name' => 'Additional Facilities', + 'hint' => 'Here create additional facilities and their prices for room types.', + 'icon' => 'icon-cog', + 'link' => 'index.php?controller=AdminRoomTypeGlobalDemand', + 'unremovable' => 1, + ), + array( + 'name' => 'Hotel Interior Block', + 'hint' => 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.', + 'icon' => 'icon-file-text', + 'link' => 'index.php?controller=AdminAboutHotelBlockSetting', + 'unremovable' => 0, + ), + array( + 'name' => 'Hotel Amenities Block', + 'hint' => 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.', + 'icon' => 'icon-th-list', + 'link' => 'index.php?controller=AdminFeaturesModuleSetting', + 'unremovable' => 0, + ), + ); + + $languages = Language::getLanguages(); + foreach ($settingsLinks as $key => $settingsLink) { + $name = array(); + $hint = array(); + foreach ($languages as $language) { + $name[$language['id_lang']] = $settingsLink['name']; + $hint[$language['id_lang']] = $settingsLink['hint']; + } + + $objHotelSettingsLink = new HotelSettingsLink(); + $objHotelSettingsLink->name = $name; + $objHotelSettingsLink->hint = $hint; + $objHotelSettingsLink->icon = $settingsLink['icon']; + $objHotelSettingsLink->link = $settingsLink['link']; + $objHotelSettingsLink->new_window = 0; + $objHotelSettingsLink->position = (int) $key; + $objHotelSettingsLink->unremovable = $settingsLink['unremovable']; + $objHotelSettingsLink->active = 1; + + if (!$objHotelSettingsLink->save()) { + return false; + } + } + + return true; + } + public function saveAdvancedPaymentInfo($id_product) { $obj_adv_pmt = new HotelAdvancedPayment(); @@ -573,6 +647,7 @@ class HotelHelper $this->saveDummyHotelImages($htl_id); $this->saveDummyHotelFeatures($htl_id); $this->saveDummyProductsAndRelatedInfo($htl_id); + $this->saveDefaultHotelSettingsLinks(); return true; } diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 26d3c5a4b..b1d6436a0 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -358,6 +358,27 @@ class HotelReservationSystemDb `access` int(11) NOT NULL, PRIMARY KEY (`id_profile`, `id_hotel`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", + + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_settings_link` ( + `id_settings_link` int(11) NOT NULL AUTO_INCREMENT, + `icon` varchar(32) character set utf8 NOT NULL, + `link` text NOT NULL, + `new_window` tinyint(1) NOT NULL DEFAULT '0', + `position` int(11) unsigned NOT NULL DEFAULT '0', + `unremovable` tinyint(1) NOT NULL DEFAULT '0', + `active` tinyint(1) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_settings_link`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_settings_link_lang` ( + `id_settings_link` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `name` varchar(255) character set utf8 NOT NULL, + `hint` varchar(255) character set utf8 NOT NULL, + PRIMARY KEY (`id_settings_link`, `id_lang`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", ); } @@ -408,7 +429,9 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_room_type_demand_price`, `'._DB_PREFIX_.'htl_room_type_demand`, `'._DB_PREFIX_.'htl_room_disable_dates`, - `'._DB_PREFIX_.'htl_access`' + `'._DB_PREFIX_.'htl_access`, + `'._DB_PREFIX_.'htl_settings_link`, + `'._DB_PREFIX_.'htl_settings_link_lang`' ); } } diff --git a/modules/hotelreservationsystem/classes/HotelSettingsLink.php b/modules/hotelreservationsystem/classes/HotelSettingsLink.php new file mode 100644 index 000000000..06229d2c5 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelSettingsLink.php @@ -0,0 +1,148 @@ + 'htl_settings_link', + 'primary' => 'id_settings_link', + 'multilang' => true, + 'fields' => array( + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'lang' => true, 'required' => true), + 'hint' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'lang' => true, 'required' => true), + 'icon' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true), + 'link' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl', 'required' => true), + 'new_window' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'unremovable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + ), + ); + + public function getAll($active = true) + { + return Db::getInstance()->executeS( + 'SELECT * FROM `'._DB_PREFIX_.'htl_settings_link` hsl + LEFT JOIN `'._DB_PREFIX_.'htl_settings_link_lang` hsll + ON hsll.`id_settings_link` = hsl.`id_settings_link` AND hsll.`id_lang` = '.(int) Context::getContext()->language->id. + ($active ? ' WHERE hsl.`active` = 1' : '').' + ORDER BY hsl.`position`' + ); + } + + public function generateLink($link = null, $id_employee = null) + { + if ($link) { + $this->link = $link; + } + + $context = Context::getContext(); + if ($this->link == '../') { + return $context->shop->getBaseURL(); + } else { + preg_match('/controller=(.+)(&.+)?$/', $this->link, $adminTab); + if (isset($adminTab[1])) { + if (strpos($adminTab[1], '&')) { + $adminTab[1] = substr($adminTab[1], 0, strpos($adminTab[1], '&')); + } + + $token = Tools::getAdminToken($adminTab[1].(int) Tab::getIdFromClassName($adminTab[1]).(int) ($id_employee ? $id_employee : $context->employee->id)); + return $link.'&token='.$token; + } + } + + return $link; + } + + public function getUnremovableLinks() + { + return Db::getInstance()->executeS( + 'SELECT * + FROM `'._DB_PREFIX_.'htl_settings_link` hsl + WHERE hsl.`unremovable` = 1' + ); + } + + public function getHigherPosition() + { + $position = Db::getInstance()->getValue( + 'SELECT MAX(`position`) FROM `'._DB_PREFIX_.'htl_settings_link`' + ); + + $result = (is_numeric($position)) ? $position : -1; + + return $result + 1; + } + + public function updatePosition($way, $position) + { + if (!$result = Db::getInstance()->executeS( + 'SELECT hsl.`id_settings_link`, hsl.`position` + FROM `'._DB_PREFIX_.'htl_settings_link` hsl + WHERE hsl.`id_settings_link` = '.(int) $this->id.' ORDER BY `position` ASC') + ) { + return false; + } + + $movedBlock = false; + foreach ($result as $block) { + if ((int)$block['id_settings_link'] == (int) $this->id) { + $movedBlock = $block; + } + } + + if ($movedBlock === false) { + return false; + } + + return (Db::getInstance()->execute( + 'UPDATE `'._DB_PREFIX_.'htl_settings_link` SET `position`= `position` '.($way ? '- 1' : '+ 1'). + ' WHERE `position`'.($way ? '> '. + (int) $movedBlock['position'].' AND `position` <= '.(int) $position : '< ' + .(int) $movedBlock['position'].' AND `position` >= '.(int) $position) + ) && Db::getInstance()->execute( + 'UPDATE `'._DB_PREFIX_.'htl_settings_link` + SET `position` = '.(int) $position.' + WHERE `id_settings_link`='.(int) $movedBlock['id_settings_link'] + )); + } + + public function cleanPositions() + { + Db::getInstance()->execute('SET @i = -1', false); + $sql = 'UPDATE `'._DB_PREFIX_.'htl_settings_link` SET `position` = @i:=@i+1 ORDER BY `position` ASC'; + + return Db::getInstance()->execute($sql); + } +} \ No newline at end of file diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php index aa756be79..77b1ebae6 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php @@ -2,37 +2,339 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController { + protected $position_identifier = 'id_settings_link'; + public function __construct() { - $this->table = 'configuration'; - $this->className = 'Configuration'; + $this->table = 'htl_settings_link'; + $this->identifier = 'id_settings_link'; + $this->className = 'HotelSettingsLink'; + $this->_defaultOrderBy = 'position'; + $this->lang = true; $this->bootstrap = true; - if (!($obj = $this->loadObject(true))) { - return; - } - $this->toolbar_title = $this->l('Manage Hotel Settings'); + $this->list_no_link = true; + parent::__construct(); + + $this->addRowAction('edit'); + $this->addRowAction('delete'); + + $this->fields_list = array( + 'id_settings_link' => array( + 'title' => $this->l('ID'), + 'hint' => $this->l('ID of the settings link.'), + 'align' => 'center', + 'class' => 'fixed-width-xs', + ), + 'name' => array( + 'title' => $this->l('Name'), + 'hint' => $this->l('Name of the settings link.'), + 'align' => 'left', + 'class' => 'fixed-width-xxl', + ), + 'link' => array( + 'title' => $this->l('Link'), + 'hint' => $this->l('Link of the page where admin is redirected.'), + 'align' => 'left', + 'callback' => 'displayColumnLink', + ), + 'icon' => array( + 'title' => $this->l('Icon'), + 'hint' => $this->l('Icon of the settings link.'), + 'align' => 'center', + 'callback' => 'displayColumnIcon', + ), + 'new_window' => array( + 'title' => $this->l('New Window'), + 'hint' => $this->l('Active if link is opened in a new window.'), + 'align' => 'center', + 'active' => 'new_window', + 'ajax' => true, + 'orderby' => false, + 'type' => 'bool', + 'class' => 'fixed-width-sm', + ), + 'position' => array( + 'title' => $this->l('Position'), + 'filter_key' => 'a!position', + 'position' => 'position', + 'align' => 'center', + 'class' => 'fixed-width-md', + ), + 'active' => array( + 'title' => $this->l('Status'), + 'hint' => $this->l('Current status of the settings link.'), + 'type' => 'bool', + 'active' => 'status', + 'align' => 'center', + 'class' => 'fixed-width-lg', + 'filter_key' => 'a!active', + ), + ); + + $this->bulk_actions = array( + 'enableSelection' => array( + 'text' => $this->l('Enable selection'), + 'icon' => 'icon-power-off text-success' + ), + 'disableSelection' => array( + 'text' => $this->l('Disable selection'), + 'icon' => 'icon-power-off text-danger' + ), + 'divider' => array( + 'text' => 'divider' + ), + 'delete' => array( + 'text' => $this->l('Delete selected'), + 'confirm' => $this->l('Delete selected items?'), + 'icon' => 'icon-trash' + ) + ); + } + + public function displayColumnIcon($icon) + { + $tpl = $this->context->smarty->createTemplate( + $this->module->getLocalPath().'views/templates/admin/'.$this->tpl_folder.'helpers/list/link-icon.tpl' + ); + + $tpl->assign('icon', $icon); + + return $tpl->fetch(); + } + + public function displayColumnLink($link) + { + $this->loadObject(true); + $tpl = $this->context->smarty->createTemplate( + $this->module->getLocalPath().'views/templates/admin/'.$this->tpl_folder.'helpers/list/link-page.tpl' + ); + + $tpl->assign(array( + 'saved_link' => $link, + 'generated_link' => $this->object->generateLink($link), + )); + + return $tpl->fetch(); + } + + public function initToolbar() + { + parent::initToolbar(); + if ($this->display == 'view') { + $this->toolbar_title = $this->l('Hotel Settings'); + $this->page_header_toolbar_btn['manage_links'] = array( + 'icon' => 'process-icon-cogs', + 'href' => self::$currentIndex.'&display=list&token='.$this->token, + 'desc' => $this->l('Manage links'), + ); + } elseif ($this->display == 'list') { + $this->page_header_toolbar_title = $this->l('Settings Links'); + $this->page_header_toolbar_btn['new'] = array( + 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, + 'desc' => $this->l('Add new link'), + ); + } } public function initContent() { - $this->show_toolbar = false; - $this->display = 'view'; + if (!$this->ajax) { + if (Tools::getValue('display') == 'list') { + $this->display = 'list'; + } elseif (empty($this->display) + && !Tools::isSubmit('submitFilter'.$this->table) + ) { + $this->display = 'view'; + } + } + parent::initContent(); } + public function renderList() + { + $this->context->smarty->assign('icon', 'icon-list'); + $this->toolbar_title = $this->l('Settings Links'); + + $this->loadObject(true); + $unremovableLinks = $this->object->getUnremovableLinks(); + if (is_array($unremovableLinks) && count($unremovableLinks)) { + $ids = array(); + foreach ($unremovableLinks as $unremovableLink) { + $ids[] = $unremovableLink['id_settings_link']; + } + $this->addRowActionSkipList('delete', $ids); + } + + return parent::renderList(); + } + + public function renderForm() + { + $smartyVars = array(); + $idSettingsLink = (int) Tools::getValue($this->identifier); + $objHotelSettingsLink = $this->loadObject(true); + + $smartyVars['id_hotel_settings_link'] = $idSettingsLink; + $smartyVars['currentTab'] = $this; + $smartyVars['currentObject'] = $objHotelSettingsLink; + + $this->fields_form = $this->getFieldsForm(); + $this->context->smarty->assign($smartyVars); + + return parent::renderForm(); + } + + public function getFieldsForm() + { + $fields_form = array(); + + $fields_form[] = array( + 'form' => array( + 'submit' => array( + 'title' => $this->l('Save'), + 'name' => 'submitHotelSettingsLink', + 'class' => 'btn btn-default pull-right', + ), + ), + ); + + return $fields_form; + } + public function renderView() { + $settingsLinks = $this->object->getAll(); + foreach ($settingsLinks as $index => &$settingsLink) { + $settingsLink['generated_link'] = $this->object->generateLink($settingsLink['link']); + } + $this->tpl_view_vars = array( - 'feature_price_setting_link' => $this->context->link->getAdminLink('AdminHotelFeaturePricesSettings'), - 'general_setting_link' => $this->context->link->getAdminLink('AdminHotelGeneralSettings'), - 'order_restrict_setting_link' => $this->context->link->getAdminLink('AdminOrderRestrictSettings'), - 'additional_demand_setting_link' => $this->context->link->getAdminLink('AdminRoomTypeGlobalDemand'), + 'settings_links' => $settingsLinks, ); return parent::renderView(); } + public function postProcess() + { + if (Tools::isSubmit('submitHotelSettingsLink') || Tools::isSubmit('submitHotelSettingsLinkAndStay')) { + $idHotelSettingsLink = Tools::getValue($this->identifier); + $this->validateRules(); + + if (is_array($this->errors) && !count($this->errors)) { + $objHotelSettingsLink = new HotelSettingsLink($idHotelSettingsLink); + $this->copyFromPost($objHotelSettingsLink, $this->table); + if (!$idHotelSettingsLink) { + $objHotelSettingsLink->position = $objHotelSettingsLink->getHigherPosition(); + } + if ($objHotelSettingsLink->save()) { + $newId = $objHotelSettingsLink->id; + + if (is_array($this->errors) && !count($this->errors)) { + if (Tools::isSubmit('submitHotelSettingsLinkAndStay')) { + if ($idHotelSettingsLink) { + Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token. + '&update'.$this->table.'&'.$this->identifier.'='.$newId); + } else { + Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token. + '&update'.$this->table.'&'.$this->identifier.'='.$newId); + } + } else { + self::$currentIndex .= '&display=list'; + if ($idHotelSettingsLink) { + Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token); + } else { + Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token); + } + } + } + } + } + } + + parent::postProcess(); + } + + public function processStatus() + { + self::$currentIndex .= '&display=list'; + return parent::processStatus(); + } + + public function processDelete() + { + self::$currentIndex .= '&display=list'; + return parent::processDelete(); + } + + public function processBulkDelete() + { + self::$currentIndex .= '&display=list'; + return parent::processBulkDelete(); + } + + public function ajaxProcessNewWindowHtlSettingsLink() + { + $response = array( + 'success' => 0, + 'text' => $this->l('An error occurred while updating object.') + ); + + $idSettingsLink = Tools::getValue('id_settings_link'); + $objHotelSettingsLink = new HotelSettingsLink($idSettingsLink); + + if (Validate::isLoadedObject($objHotelSettingsLink)) { + $objHotelSettingsLink->new_window = (int) !$objHotelSettingsLink->new_window; + + if ($objHotelSettingsLink->save()) { + $response['success'] = 1; + $response['text'] = $this->l('The object has been updated successfully.'); + } + } + + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessUpdatePositions() + { + $way = (int) Tools::getValue('way'); + $idSettingsLink = (int) Tools::getValue('id'); + $positions = Tools::getValue('settings_link'); + + foreach ($positions as $position => $value) { + $pos = explode('_', $value); + + if (isset($pos[2]) && (int) $pos[2] === $idSettingsLink) { + if ($objHotelSettingsLink = new HotelSettingsLink((int) $pos[2])) { + if (isset($position) && $objHotelSettingsLink->updatePosition($way, $position, $idSettingsLink)) { + $this->ajaxDie(json_encode(true)); + } else { + $this->ajaxDie(json_encode(array( + 'hasError' => true, + 'errors' => sprintf( + $this->l('Can not update position for object ID: %d to position %d'), + (int) $idSettingsLink, + $position + ), + ))); + } + } else { + $this->ajaxDie(json_encode(array( + 'hasError' => true, + 'errors' => sprintf( + $this->l('The object with ID: %d can not be loaded.'), + (int) $idSettingsLink + ), + ))); + } + + break; + } + } + } + public function setMedia() { parent::setMedia(); diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index 6218e15af..607004e33 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -45,6 +45,8 @@ require_once 'classes/QloRoomType.php'; require_once 'classes/HotelRoomDisableDates.php'; require_once 'classes/HotelBranchRefundRules.php'; +require_once 'classes/HotelSettingsLink.php'; + // Web services classes require_once 'classes/WebserviceSpecificManagementQlo.php'; require_once 'classes/WebserviceSpecificManagementHotelImages.php'; \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl new file mode 100644 index 000000000..e94b57449 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl @@ -0,0 +1,172 @@ +{** + * 2010-2022 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2022 Webkul IN + * @license LICENSE.txt + *} + +{extends file='helpers/form/form.tpl'} + +{block name='fieldset'} +
+
+ + {l s='Link Information' mod='hotelreservationsystem'} +
+ +
+
+ +
+ + getFieldValue($currentObject, 'active')|intval}checked="checked"{/if}> + + getFieldValue($currentObject, 'active')|intval}checked="checked"{/if}> + + + +
+
+ +
+ +
+ {if $languages|count > 0} + {foreach $languages as $language} + {assign var='value_text' value=$currentTab->getFieldValue($currentObject, 'name', $language.id_lang)} +
+
+ +
+ {if $languages|count > 1} +
+ + +
+ {/if} +
+ {/foreach} + {/if} +
+
+ +
+ +
+ {if $languages|count > 0} + {foreach $languages as $language} + {assign var='value_text' value=$currentTab->getFieldValue($currentObject, 'hint', $language.id_lang)} +
+
+ +
+ {if $languages|count > 1} +
+ + +
+ {/if} +
+ {/foreach} + {/if} +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + getFieldValue($currentObject, 'new_window')|intval}checked="checked"{/if}> + + getFieldValue($currentObject, 'new_window')|intval}checked="checked"{/if}> + + + +
+
+
+ + +
+{/block} diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/index.php new file mode 100644 index 000000000..b2366adc9 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/index.php @@ -0,0 +1,29 @@ + diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/list/link-page.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/list/link-page.tpl new file mode 100644 index 000000000..bb307b859 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/list/link-page.tpl @@ -0,0 +1,20 @@ +{** + * 2010-2022 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2022 Webkul IN + * @license LICENSE.txt + *} + +{$saved_link} diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/view/view.tpl index e354b8d0a..976a956f9 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/view/view.tpl @@ -1,44 +1,36 @@ +{** + * 2010-2022 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2022 Webkul IN + * @license LICENSE.txt + *} +

   {l s='Hotel Configuration' mod='hotelreservationsystem'}

From 5a7aa606ec808f7da839768d8654115953ea7cea Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 14 Dec 2022 20:49:19 +0530 Subject: [PATCH 19/42] Add icons link for icons --- .../hotel_configuration_setting/helpers/form/form.tpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl index e94b57449..aba822fce 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl @@ -121,6 +121,15 @@
+
+
+ {l s='Refer to the following link for available icons.' mod='hotelreservationsystem'} + + https://fontawesome.com/v4/cheatsheet + + {l s=' Note: Replace fa- with icon- in icon name.' mod='hotelreservationsystem'} +
+
From c96890cff2d9d7a68d7c3b9cd1d43264a96e3dfc Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 15 Dec 2022 20:31:38 +0530 Subject: [PATCH 20/42] Use object methods for HotelCartBookingData and HotelBookingDetail --- controllers/admin/AdminOrdersController.php | 4 +- .../classes/HotelBookingDetail.php | 525 +++++++++++------- .../classes/HotelCartBookingData.php | 236 +++++--- 3 files changed, 506 insertions(+), 259 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index e45271256..30cad6edc 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -459,7 +459,7 @@ class AdminOrdersControllerCore extends AdminController if (!$room_swapped) { $this->errors[] = Tools::displayError('Some error occured. Please try again.'); } else { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token); + Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token.'&conf=4'); } } } else { @@ -494,7 +494,7 @@ class AdminOrdersControllerCore extends AdminController if (!$room_swapped) { $this->errors[] = Tools::displayError('Some error occured. Please try again.'); } else { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token); + Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token.'&conf=4'); } } } else { diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 3f020f1ff..7671d5380 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -787,45 +787,39 @@ class HotelBookingDetail extends ObjectModel * @return [Boolean] [Returns true if successfully updated else returns false] */ public function updateBookingOrderStatusByOrderId( - $order_id, - $new_status, - $id_room, - $date_from, - $date_to, - $status_date = '' + $idOrder, + $newStatus, + $idRoom, + $dateFrom, + $dateTo, + $statusDate = '' ) { - if ($status_date) { - $status_date = date('Y-m-d H:i:s', strtotime($status_date)); - } else { - $status_date = date('Y-m-d H:i:s'); + $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); + + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; } - $table = 'htl_booking_detail'; - - // create date to update in the table - if ($new_status == self::STATUS_CHECKED_IN) { - $data = array( - 'id_status' => $new_status, - 'check_in' => ($status_date > $date_to ? $date_to : $status_date) - ); - } elseif ($new_status == self::STATUS_CHECKED_OUT) { - $data = array( - 'id_status' => $new_status, - 'check_out' => ($status_date > $date_to ? $date_to : $status_date) - ); + if ($statusDate) { + $statusDate = date('Y-m-d H:i:s', strtotime($statusDate)); } else { - $data = array( - 'id_status' => $new_status, - 'check_in' => '', - 'check_out' => '' - ); + $statusDate = date('Y-m-d H:i:s'); } - // where conditions - $where = 'id_order = '.(int)$order_id.' AND id_room = '.(int)$id_room. - ' AND `date_from` = \''.pSQL($date_from).'\' AND `date_to` = \''.pSQL($date_to).'\''; + if ($newStatus == self::STATUS_CHECKED_IN) { + $objHotelBookingDetail->id_status = $newStatus; + $objHotelBookingDetail->check_in = ($statusDate > $dateTo ? $dateTo : $statusDate); + } elseif ($newStatus == self::STATUS_CHECKED_OUT) { + $objHotelBookingDetail->id_status = $newStatus; + $objHotelBookingDetail->check_out = ($statusDate > $dateTo ? $dateTo : $statusDate); + } else { + $objHotelBookingDetail->id_status = $newStatus; + $objHotelBookingDetail->check_in = ''; + $objHotelBookingDetail->check_out = ''; + } - return Db::getInstance()->update($table, $data, $where); + return $objHotelBookingDetail->save(); } /** @@ -1049,36 +1043,52 @@ class HotelBookingDetail extends ObjectModel * * @return [boolean] [true if rooms successfully reallocated else returns false] */ - public function reallocateRoomWithAvailableSameRoomType($current_room_id, $date_from, $date_to, $swapped_room_id) + public function reallocateRoomWithAvailableSameRoomType($currentRoomId, $dateFrom, $dateTo, $swappedRoomId) { - $date_from = date('Y-m-d H:i:s', strtotime($date_from)); - $date_to = date('Y-m-d H:i:s', strtotime($date_to)); - $table = 'htl_cart_booking_data'; - $table2 = 'htl_booking_detail'; - $data = array('id_room' => $swapped_room_id); - $where = 'date_from=\''.pSQL($date_from).'\' AND date_to=\''.pSQL($date_to).'\' AND id_room='. - (int)$current_room_id; + $dateFrom = date('Y-m-d H:i:s', strtotime($dateFrom)); + $dateTo = date('Y-m-d H:i:s', strtotime($dateTo)); - if ($result = Db::getInstance()->update($table, $data, $where)) { - if($room_num = Db::getInstance()->getValue( - 'SELECT `room_num` FROM `'._DB_PREFIX_.'htl_room_information` WHERE `id` = '.$swapped_room_id - )) { - $data['room_num'] = $room_num; + $idHotelCartBookingData = Db::getInstance()->getValue( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE date_from = "'.pSQL($dateFrom).'" AND date_to = "'.pSQL($dateTo).'" + AND id_room = '.(int) $currentRoomId + ); + + if ($idHotelCartBookingData) { + $objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; } - if ($result2 = Db::getInstance()->update($table2, $data, $where)) { - Hook::exec( - 'actionRoomReAllocateAfter', - array( - 'room_id' => $current_room_id, - 'realloc_room_id' => $swapped_room_id, - 'date_from' => $date_from, - 'date_to' => $date_to, - ) - ); - return true; + + $objHotelCartBookingData->id_room = $swappedRoomId; + if ($objHotelCartBookingData->save()) { + $objHotelRoomInformation = new HotelRoomInformation($swappedRoomId); + + $roomBookingData = $this->getRoomBookingData($currentRoomId, $objHotelCartBookingData->id_order, $dateFrom, $dateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + $objHotelBookingDetail->id_room = $swappedRoomId; + $objHotelBookingDetail->room_num = $objHotelRoomInformation->room_num; + if ($objHotelBookingDetail->save()) { + Hook::exec( + 'actionRoomReAllocateAfter', + array( + 'room_id' => $currentRoomId, + 'realloc_room_id' => $swappedRoomId, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, + ) + ); + + return true; + } } - return false; } + return false; } @@ -1091,58 +1101,69 @@ class HotelBookingDetail extends ObjectModel * * @return [boolean] [true if rooms successfully swapped else returns false] */ - public function swapRoomWithAvailableSameRoomType($current_room_id, $date_from, $date_to, $swapped_room_id) + public function swapRoomWithAvailableSameRoomType($currentRoomId, $dateFrom, $dateTo, $swappedRoomId) { - $date_from = date('Y-m-d H:i:s', strtotime($date_from)); - $date_to = date('Y-m-d H:i:s', strtotime($date_to)); + $dateFrom = date('Y-m-d H:i:s', strtotime($dateFrom)); + $dateTo = date('Y-m-d H:i:s', strtotime($dateTo)); - $idcrt1 = Db::getInstance()->getValue( + $idHotelCartBookingData1 = Db::getInstance()->getValue( 'SELECT `id` FROM `'._DB_PREFIX_.'htl_cart_booking_data` WHERE `is_refunded` = 0 - AND `date_from`=\''.pSQL($date_from).'\' AND `date_to`=\''.pSQL($date_to).'\' - AND `id_room`='.(int)$swapped_room_id + AND `date_from`=\''.pSQL($dateFrom).'\' AND `date_to`=\''.pSQL($dateTo).'\' + AND `id_room`='.(int)$swappedRoomId ); - $idcrt2 = Db::getInstance()->getValue( + $idHotelCartBookingData2 = Db::getInstance()->getValue( 'SELECT `id` FROM `'._DB_PREFIX_.'htl_cart_booking_data` WHERE `is_refunded` = 0 - AND `date_from`=\''.pSQL($date_from).'\' AND `date_to`=\''.pSQL($date_to).'\' - AND `id_room`='.(int)$current_room_id + AND `date_from`=\''.pSQL($dateFrom).'\' AND `date_to`=\''.pSQL($dateTo).'\' + AND `id_room`='.(int)$currentRoomId ); - $swap_room = Db::getInstance()->getRow( - 'SELECT `id`, `room_num` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `is_refunded` = 0 - AND `date_from`=\''.pSQL($date_from).'\' AND `date_to`=\''.pSQL($date_to).'\' - AND `id_room`='.(int)$swapped_room_id + $idHotelBookingDetail1 = Db::getInstance()->getValue( + 'SELECT `id` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `is_refunded` = 0 + AND `date_from`=\''.pSQL($dateFrom).'\' AND `date_to`=\''.pSQL($dateTo).'\' + AND `id_room`='.(int)$swappedRoomId ); - $curr_room = Db::getInstance()->getRow( - 'SELECT `id`, `room_num` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `is_refunded` = 0 - AND `date_from`=\''.pSQL($date_from).'\' AND `date_to`=\''.pSQL($date_to).'\' - AND `id_room`='.(int)$current_room_id + $idHotelBookingDetail2 = Db::getInstance()->getValue( + 'SELECT `id` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `is_refunded` = 0 + AND `date_from`=\''.pSQL($dateFrom).'\' AND `date_to`=\''.pSQL($dateTo).'\' + AND `id_room`='.(int)$currentRoomId ); - $sql = 'UPDATE `'._DB_PREFIX_.'htl_cart_booking_data` SET `id_room`=IF(`id`='.(int)$idcrt1.','. - (int)$current_room_id.','.(int)$swapped_room_id.') WHERE `id` IN('.(int)$idcrt1.','.(int)$idcrt2.')'; - $sql1 = 'UPDATE `'._DB_PREFIX_.'htl_booking_detail` - SET `id_room`=IF(`id`='.(int)$swap_room['id'].','.(int)$current_room_id.','.(int)$swapped_room_id.'), - `room_num`=IF( - `id`='.(int)$swap_room['id'].',\''.pSQL($curr_room['room_num']).'\',\''.pSQL($swap_room['room_num']).'\' - ) - WHERE `id` IN('.(int)$swap_room['id'].','.(int)$curr_room['id'].')'; + $objHotelCartBookingData1 = new HotelCartBookingData($idHotelCartBookingData1); + $objHotelCartBookingData2 = new HotelCartBookingData($idHotelCartBookingData2); - if ($result = Db::getInstance()->execute($sql)) { - $result2 = Db::getInstance()->execute($sql1); - if ($result2) { - Hook::exec( - 'actionRoomSwapAfter', - array( - 'room_id' => $current_room_id, - 'swapped_room_id' => $swapped_room_id, - 'date_from' => $date_from, - 'date_to' => $date_to, - ) - ); - return true; - } - return false; + $temp = $objHotelCartBookingData1->id_room; + $objHotelCartBookingData1->id_room = $objHotelCartBookingData2->id_room; + $objHotelCartBookingData2->id_room = $temp; + + $objHotelBookingDetail1 = new HotelBookingDetail($idHotelBookingDetail1); + $objHotelBookingDetail2 = new HotelBookingDetail($idHotelBookingDetail2); + + $temp = $objHotelBookingDetail1->id_room; + $objHotelBookingDetail1->id_room = $objHotelBookingDetail2->id_room; + $objHotelBookingDetail2->id_room = $temp; + + $temp = $objHotelBookingDetail1->room_num; + $objHotelBookingDetail1->room_num = $objHotelBookingDetail2->room_num; + $objHotelBookingDetail2->room_num = $temp; + + if ($objHotelCartBookingData1->save() + && $objHotelCartBookingData2->save() + && $objHotelBookingDetail1->save() + && $objHotelBookingDetail2->save() + ) { + Hook::exec( + 'actionRoomSwapAfter', + array( + 'room_id' => $currentRoomId, + 'swapped_room_id' => $swappedRoomId, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, + ) + ); + + return true; } + return false; } @@ -1155,20 +1176,39 @@ class HotelBookingDetail extends ObjectModel * * @return [boolean] [true if updated otherwise false] */ - public function updateOrderRefundStatus($id_order, $date_from = false, $date_to = false, $id_rooms = array()) + public function updateOrderRefundStatus($idOrder, $dateFrom = false, $dateTo = false, $idsRoom = array()) { - $table = 'htl_booking_detail'; - $data = array('is_refunded' => 1); - if ($id_rooms) { - foreach ($id_rooms as $key_rm => $val_rm) { - $where = 'id_order='.(int)$id_order.' AND id_room = '.(int)$val_rm['id_room'].' AND `date_from`= \''. - pSQL($date_from).'\' AND `date_to` = \''.pSQL($date_to).'\''; - $result = Db::getInstance()->update($table, $data, $where); + if ($idsRoom) { + foreach ($idsRoom as $idRoom) { + $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + $objHotelBookingDetail->is_refunded = 1; + if (!$objHotelBookingDetail->save()) { + return false; + } } } else { - return Db::getInstance()->update($table, $data, 'id_order='.(int)$id_order); + $bookingsData = $this->getBookingDataByOrderId($idOrder); + if (is_array($bookingsData) && count($bookingsData)) { + foreach ($bookingsData as $bookingData) { + $objHotelBookingDetail = new self($bookingData['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + $objHotelBookingDetail->is_refunded = 1; + if (!$objHotelBookingDetail->save()) { + return false; + } + } + } } - return $result; + + return true; } /** @@ -1211,15 +1251,16 @@ class HotelBookingDetail extends ObjectModel * * @return [Boolean] [True if deleted else false] */ - public function deleteOrderedRoomFromOrder($id_order, $id_hotel, $id_room, $date_from, $date_to) + public function deleteOrderedRoomFromOrder($idOrder, $idHotel, $idRoom, $dateFrom, $dateTo) { - return Db::getInstance()->delete( - 'htl_booking_detail', - '`id_order`='.(int) $id_order.' AND `id_hotel`='.(int) $id_hotel.' AND `id_room`='.(int) $id_room. - ' AND `date_from`=\''.pSQL($date_from).'\' AND `date_to`=\''.pSQL($date_to).'\'' - ); + $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); - return $delete; + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + return $objHotelBookingDetail->delete(); } public function getRoomBookinInformationForDateRangeByOrder( @@ -1238,79 +1279,89 @@ class HotelBookingDetail extends ObjectModel } public function UpdateHotelCartHotelOrderOnOrderEdit( - $id_order, - $id_room, - $old_date_from, - $old_date_to, - $new_date_from, - $new_date_to, - $new_total_price = null + $idOrder, + $idRoom, + $oldDateFrom, + $oldDateTo, + $newDateFrom, + $newDateTo, + $newTotalPrice = null ) { - $rowByIdOrderIdRoom = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_room`='.(int)$id_room.' AND `id_order`='.(int)$id_order); + // retrieve HotelBookingDetail row + $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $oldDateFrom, $oldDateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + // retrieve HotelCartBookingData row + $idHotelCartBookingData = Db::getInstance()->getValue( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE date_from = "'.pSQL($oldDateFrom).'" AND date_to = "'.pSQL($oldDateTo).'" + AND id_room = '.(int) $idRoom + ); + + $objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + // calculate new prices $newTotalPriceTE = ''; $newTotalPriceTI = ''; - $newNumDays = $this->getNumberOfDays($new_date_from, $new_date_to); - if ($new_total_price) { - $newTotalPriceTE = $new_total_price['tax_excl']; - $newTotalPriceTI = $new_total_price['tax_incl']; + $newNumDays = $this->getNumberOfDays($newDateFrom, $newDateTo); + if ($newTotalPrice) { + $newTotalPriceTE = $newTotalPrice['tax_excl']; + $newTotalPriceTI = $newTotalPrice['tax_incl']; } else { - $oldNumDays = $this->getNumberOfDays($old_date_from, $old_date_to); - $unitRoomPriceTE = $rowByIdOrderIdRoom['total_price_tax_excl'] / $oldNumDays; - $unitRoomPriceTI = $rowByIdOrderIdRoom['total_price_tax_incl'] / $oldNumDays; + $oldNumDays = $this->getNumberOfDays($oldDateFrom, $oldDateTo); + $unitRoomPriceTE = $objHotelBookingDetail->total_price_tax_excl / $oldNumDays; + $unitRoomPriceTI = $objHotelBookingDetail->total_price_tax_incl / $oldNumDays; $newTotalPriceTE = $unitRoomPriceTE * $newNumDays; $newTotalPriceTI = $unitRoomPriceTI * $newNumDays; } - // update `total_paid_amount` on database + // calculate `total_paid_amount` $totalPaidAmount = 0; $isAdvancePayment = Db::getInstance()->getValue( 'SELECT o.`is_advance_payment` FROM `'._DB_PREFIX_.'orders` o - WHERE o.`id_order` = '.(int) $id_order + WHERE o.`id_order` = '.(int) $idOrder ); if ($isAdvancePayment) { $objHotelAdvancedPayment = new HotelAdvancedPayment(); - $productAdvancePayment = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($rowByIdOrderIdRoom['id_product']); + $productAdvancePayment = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($objHotelBookingDetail->id_product); if (!$productAdvancePayment || (isset($productAdvancePayment['payment_type']) && $productAdvancePayment['payment_type'])) { $totalPaidAmount = $objHotelAdvancedPayment->getRoomMinAdvPaymentAmount( - $rowByIdOrderIdRoom['id_product'], - $new_date_from, - $new_date_to + $objHotelBookingDetail->id_product, + $newDateFrom, + $newDateTo ); } } else { $totalPaidAmount = $newTotalPriceTI; } - $cart_booking = array( - 'table' => 'htl_cart_booking_data', - 'data' => array( - 'date_from' => $new_date_from, - 'date_to' => $new_date_to, - 'quantity' => $newNumDays, - ), - ); + // update $objHotelCartBookingData + $objHotelCartBookingData->date_from = $newDateFrom; + $objHotelCartBookingData->date_to = $newDateTo; + $objHotelCartBookingData->quantity = $newNumDays; - $booking_detail = array( - 'table' => 'htl_booking_detail', - 'data' => array( - 'date_from' => $new_date_from, - 'date_to' => $new_date_to, - 'total_price_tax_excl' => $newTotalPriceTE, - 'total_price_tax_incl' => $newTotalPriceTI, - 'total_paid_amount' => $totalPaidAmount, - ), - ); + // update $objHotelBookingDetail + $objHotelBookingDetail->date_from = $newDateFrom; + $objHotelBookingDetail->date_to = $newDateTo; + $objHotelBookingDetail->total_price_tax_excl = Tools::ps_round($newTotalPriceTE, 6); + $objHotelBookingDetail->total_price_tax_incl = Tools::ps_round($newTotalPriceTI, 6); + $objHotelBookingDetail->total_paid_amount = Tools::ps_round($totalPaidAmount, 6); - $where = 'id_order = '.(int)$id_order.' AND id_room = '.(int)$id_room.' AND date_from= \''.pSQL($old_date_from). - '\' AND date_to = \''.pSQL($old_date_to).'\' AND `is_refunded`=0 AND `is_back_order`=0'; + if ($objHotelCartBookingData->save() && $objHotelBookingDetail->save()) { + return true; + } - $result = Db::getInstance()->update($cart_booking['table'], $cart_booking['data'], $where); - $result &= Db::getInstance()->update($booking_detail['table'], $booking_detail['data'], $where); - - return $result; + return false; } /** @@ -1717,37 +1768,126 @@ class HotelBookingDetail extends ObjectModel } } - public function deleteHotelOrderInfo($id_order) + public function deleteHotelOrderInfo($idOrder) { - $cartTable = 'htl_cart_booking_data'; - $orderTable = 'htl_booking_detail'; - $condition = 'id_order = '.(int)$id_order; - if (Db::getInstance()->delete($orderTable, $condition)) { - return Db::getInstance()->delete($cartTable, $condition); + $objHotelCartBookingData = new HotelCartBookingData(); + $bookingsCartData = $objHotelCartBookingData->getCartCurrentDataByOrderId($idOrder); + if (is_array($bookingsCartData) && count($bookingsCartData)) { + foreach ($bookingsData as $bookingCartData) { + $objHotelCartBookingData = new HotelCartBookingData($bookingCartData['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } } - return false; + + $bookingsData = $this->getBookingDataByOrderId($idOrder); + if (is_array($bookingsData) && count($bookingsData)) { + foreach ($bookingsData as $bookingData) { + $objHotelBookingDetail = new self($bookingData['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + if (!$objHotelBookingDetail->delete()) { + return false; + } + } + } + + return true; } - public function deleteHotelOrderRoomInfo($id_order, $id_product, $id_room) + public function deleteHotelOrderRoomInfo($idOrder, $idProduct, $idRoom) { - $cartTable = 'htl_cart_booking_data'; - $orderTable = 'htl_booking_detail'; - $condition = 'id_order = '.(int)$id_order.' AND id_product = '.(int)$id_product.' AND id_room = '.(int)$id_room; - if (Db::getInstance()->delete($orderTable, $condition)) { - return Db::getInstance()->delete($cartTable, $condition); + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE `id_order` = '.(int) $idOrder.' AND `id_product` = '.(int) $idProduct.' + AND `id_room` = '.(int) $idRoom + ); + + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } } - return false; + + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_booking_detail` + WHERE `id_order` = '.(int) $idOrder.' AND `id_product` = '.(int) $idProduct.' + AND `id_room` = '.(int) $idRoom + ); + + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelBookingDetail = new self($row['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + if (!$objHotelBookingDetail->delete()) { + return false; + } + } + } + + return true; } - public function deleteHotelOrderRoomTypeInfo($id_order, $id_product) + public function deleteHotelOrderRoomTypeInfo($idOrder, $idProduct) { - $cartTable = 'htl_cart_booking_data'; - $orderTable = 'htl_booking_detail'; - $condition = 'id_order = '.(int)$id_order.' AND id_product = '.(int)$id_product; - if (Db::getInstance()->delete($orderTable, $condition)) { - return Db::getInstance()->delete($cartTable, $condition); + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE `id_order` = '.(int) $idOrder.' AND `id_product` = '.(int) $idProduct + ); + + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } } - return false; + + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_booking_detail` + WHERE `id_order` = '.(int) $idOrder.' AND `id_product` = '.(int) $idProduct + ); + + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelBookingDetail = new self($row['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + if (!$objHotelBookingDetail->delete()) { + return false; + } + } + } + + return true; } public function enterHotelOrderBookingFormCartBookingData($id_cart) @@ -1799,6 +1939,8 @@ class HotelBookingDetail extends ObjectModel public function updateHotelOrderRoomDurationInfo($id_order, $id_product, $id_room, $update_params) { + Tools::displayAsDeprecated(); + $cartTable = 'htl_cart_booking_data'; $orderTable = 'htl_booking_detail'; $condition = '`id_order` = '.(int)$id_order.' AND `id_product` = '.(int)$id_product. @@ -1843,11 +1985,22 @@ class HotelBookingDetail extends ObjectModel // Add new entry to the table if ($orderDetail->save()) { - return Db::getInstance()->update( - 'htl_booking_detail', - array('id_order_detail' => $orderDetail->id_order_detail), - '`id_order` = '.(int)$id_order.' AND `id_product` = '.(int)$id_product - ); + $bookingsData = self::getOrderInfoIdOrderIdProduct($id_order, $id_product); + if (is_array($bookingsData) && count($bookingsData)) { + foreach ($bookingsData as $bookingData) { + $objHotelBookingDetail = new self($bookingData['id']); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + return false; + } + + $objHotelBookingDetail->id_order_detail = $orderDetail->id_order_detail; + if (!$objHotelBookingDetail->save()) { + return false; + } + } + + return true; + } } } return false; @@ -1872,7 +2025,7 @@ class HotelBookingDetail extends ObjectModel public function getRoomBookingData($idRoom, $idOrder, $date_from, $date_to) { - $sql = 'SELECT `id_product`, `id_order_detail`, `id_hotel`, `id_customer`, `booking_type`, `id_status`, `check_in`, `check_out` + $sql = 'SELECT `id`, `id_product`, `id_order_detail`, `id_hotel`, `id_customer`, `booking_type`, `id_status`, `check_in`, `check_out` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_order`='.(int)$idOrder.' AND `id_room`='.(int)$idRoom.' AND `date_from`=\''.pSQL($date_from).'\' AND `date_to`= \''.pSQL($date_to).'\''; diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index dd0fb2cf8..50a7a2d4f 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -224,9 +224,12 @@ class HotelCartBookingData extends ObjectModel */ public function deleteRowById($id) { - $delete = Db::getInstance()->delete('htl_cart_booking_data', '`id`='.(int) $id); + $objHotelCartBookingData = new self($id); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } - return $delete; + return $objHotelCartBookingData->delete(); } /** @@ -289,28 +292,34 @@ class HotelCartBookingData extends ObjectModel * * @return [boolean] [If cart updated with quantity successfully returns true else returns false] */ - public function changeProductDataByRoomId($roomid, $id_product, $days_diff, $cart_id) + public function changeProductDataByRoomId($idRoom, $idProduct, $daysDiff, $idCart) { - $deleted = Db::getInstance()->delete('htl_cart_booking_data', '`id_room` = '.(int) $roomid.' AND `id_cart` = '.(int) $cart_id); + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE `id_room` = '.(int) $idRoom.' AND `id_cart` = '.(int) $idCart + ); - $cart_product_quantity = Db::getInstance()->getValue('SELECT `quantity` FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart`='.$cart_id.' AND `id_product`='.$id_product); + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } - $new_quantity = $cart_product_quantity - $days_diff; - - if ($new_quantity > 0) { - $update_quantity = Db::getInstance()->update('cart_product', array('quantity' => $new_quantity), '`id_cart`='.$cart_id.' AND `id_product`='.$id_product); - if ($update_quantity) { - return true; + if (!$objHotelCartBookingData->delete()) { + return false; + } } + } - return false; + $cartProductQuantity = Db::getInstance()->getValue('SELECT `quantity` FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart`='.$idCart.' AND `id_product`='.$idProduct); + $newQuantity = $cartProductQuantity - $daysDiff; + + if ($newQuantity > 0) { + return Db::getInstance()->update('cart_product', array('quantity' => $newQuantity), '`id_cart`='.$idCart.' AND `id_product`='.$idProduct); } else { - $delete_product = Db::getInstance()->delete('cart_product', '`id_cart`='.$cart_id.' AND `id_product`='.$id_product); - if ($delete_product) { - return true; - } - - return false; + return Db::getInstance()->delete('cart_product', '`id_cart`='.$idCart.' AND `id_product`='.$idProduct); } } @@ -402,13 +411,22 @@ class HotelCartBookingData extends ObjectModel } } } + // delete rows from table - if (!Db::getInstance()->delete('htl_cart_booking_data', $where)) { - return false; + foreach ($cartBookingInfo as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } } } + // return number of rooms deleted - return true; + return $numRooms; } /** @@ -443,14 +461,23 @@ class HotelCartBookingData extends ObjectModel * * @return [boolean] [Returns true if deleted successfully else returns false] */ - public function deleteCartDataByIdProductIdCart($id_cart, $id_product, $date_from, $date_to) + public function deleteCartDataByIdProductIdCart($idCart, $idProduct, $dateFrom, $dateTo) { - $result = Db::getInstance()->delete('htl_cart_booking_data', '`id_cart`='.$id_cart.' AND `id_product`='.$id_product." AND `date_from` = '$date_from' AND `date_to` = '$date_to'"); - if ($result) { - return true; + $result = $this->getHotelCartRoomsInfoByRoomType($idCart, $idProduct, $dateFrom, $dateTo); + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } } - return false; + return true; } /** @@ -478,15 +505,23 @@ class HotelCartBookingData extends ObjectModel $this->context = Context::getContext(); $update_quantity = $this->context->cart->updateQty($qty, $id_product, null, false, 'down'); - $delete_rooms = Db::getInstance()->delete('htl_cart_booking_data', '`id_cart`='.$id_cart.' AND `id_guest`='.$id_guest.' AND `id_product`='.$id_product." AND `date_from`= '$date_from' AND `date_to`= '$date_to'"); - if ($delete_rooms) { - return true; + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } } - return false; - } else { - return false; + return true; } + + return false; } /** @@ -498,37 +533,26 @@ class HotelCartBookingData extends ObjectModel */ public function deleteBookingCartDataNotOrderedByProductId($id_product) { - return Db::getInstance()->delete( - 'htl_cart_booking_data', - '`id_product`='.(int) $id_product.' AND `id_order`= 0' + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE `id_product`='.(int) $id_product.' AND `id_order`= 0' ); - } - /** - * [updateOrderRefundStatus :: To update the refund status of a room booked in the Cart(htl_cart_booking_data) if amount refunded by the admin]. - * - * @param [int] $id_cart [Id of the Cart] - * @param [date] $date_from [start date of the bookin of the room] - * @param [date] $date_to [end date of the bookin of the room] - * @param [int] $id_room [id of the room for which refund is done] - * - * @return [boolean] [true if updated otherwise false] - */ - public function updateOrderRefundStatus($id_cart, $date_from, $date_to, $id_rooms) - { - $table = 'htl_cart_booking_data'; - $data = array('is_refunded' => 1); + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } - foreach ($id_rooms as $key_rm => $val_rm) { - $where = '`id_cart` = '.$id_cart.' AND `id_room` = '.$val_rm['id_room']." AND `date_from` = '$date_from' AND `date_to` = '$date_to'"; - $result = Db::getInstance()->update($table, $data, $where); + if (!$objHotelCartBookingData->delete()) { + return false; + } + } } - if ($result) { - return $result; - } - - return false; + return true; } /** @@ -564,7 +588,7 @@ class HotelCartBookingData extends ObjectModel return false; } - $dltdata = false; + $dltdata = ''; $stringArr = array('date_from', 'date_to'); @@ -579,9 +603,27 @@ class HotelCartBookingData extends ObjectModel $dltdata .= $c_key.' = '.$c_val; } } - $delete = Db::getInstance()->delete('htl_cart_booking_data', $dltdata); - return $delete; + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE '.$dltdata + ); + + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } + } + + return true; } /** @@ -598,7 +640,7 @@ class HotelCartBookingData extends ObjectModel return false; } - $where = false; + $where = ''; $stringArr = array('date_from', 'date_to'); foreach ($updBy as $u_key => $u_val) { if ($where) { @@ -611,9 +653,31 @@ class HotelCartBookingData extends ObjectModel $where .= $u_key.' = '.$u_val; } } - $update = Db::getInstance()->update('htl_cart_booking_data', $updData, $where); + // $update = Db::getInstance()->update('htl_cart_booking_data', $updData, $where); + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE '.$where + ); - return $update; + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + foreach ($updData as $key => $value) { + $objHotelCartBookingData->$key = $value; + } + + if (!$objHotelCartBookingData->save()) { + return false; + } + } + } + + return true; } /** @@ -725,12 +789,25 @@ class HotelCartBookingData extends ObjectModel */ public function updateIdCurrencyByIdCart($id_cart, $id_currency) { - $update_currency = Db::getInstance()->update('htl_cart_booking_data', array('id_currency' => $id_currency), '`id_cart`='.$id_cart); - if ($update_currency) { - return true; - } + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE `id_cart` = '.(int) $idCart + ); - return false; + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + $objHotelCartBookingData->id_currency = $id_currency; + if (!$objHotelCartBookingData->save()) { + return false; + } + } + } } /** @@ -745,9 +822,26 @@ class HotelCartBookingData extends ObjectModel */ public function deleteOrderedRoomFromCart($id_order, $id_hotel, $id_room, $date_from, $date_to) { - $delete = Db::getInstance()->delete('htl_cart_booking_data', '`id_order`='.(int) $id_order.' AND `id_hotel`='.(int) $id_hotel.' AND `id_room`='.(int) $id_room." AND `date_from`='$date_from' AND `date_to`='$date_to'"); + $result = Db::getInstance()->executeS( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE '.'`id_order`='.(int) $id_order.' AND `id_hotel`='.(int) $id_hotel.' AND `id_room`='.(int) $id_room." AND `date_from`='$date_from' AND `date_to`='$date_to'" + ); - return $delete; + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (!Validate::isLoadedObject($objHotelCartBookingData)) { + return false; + } + + if (!$objHotelCartBookingData->delete()) { + return false; + } + } + } + + return true; } /** From b107eb7fb992ffc25b23ba8b70c3e65e325c4b73 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 16 Dec 2022 18:47:46 +0530 Subject: [PATCH 21/42] Add id_order to query --- modules/hotelreservationsystem/classes/HotelBookingDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 7671d5380..6dd821a61 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1299,7 +1299,7 @@ class HotelBookingDetail extends ObjectModel 'SELECT `id` FROM `'._DB_PREFIX_.'htl_cart_booking_data` WHERE date_from = "'.pSQL($oldDateFrom).'" AND date_to = "'.pSQL($oldDateTo).'" - AND id_room = '.(int) $idRoom + AND id_room = '.(int) $idRoom.' AND `id_order` = '.(int) $idOrder ); $objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData); From a404f5bd0f24ad0e089cb083f86a40ad490e057b Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sat, 17 Dec 2022 07:05:13 +0000 Subject: [PATCH 22/42] update addPaymentDetail call parameters --- .../controllers/orders/helpers/view/view.tpl | 8 +++--- classes/PaymentModule.php | 9 +++++-- classes/order/Order.php | 25 +++++++++---------- classes/order/OrderHistory.php | 2 +- controllers/admin/AdminOrdersController.php | 1 - 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index f5a30ca46..7262462dd 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -472,12 +472,12 @@ {l s="Payment"} {$order->getOrderPayments()|@count}
{if count($order->getOrderPayments()) > 0} -

id == 6)} style="display: none;"{/if}> +

total_paid_tax_incl, 2) == round($total_paid, 2) || (isset($currentState) && $currentState->id == 6)} style="display: none;"{/if}> {l s='Warning'} {displayPrice price=$total_paid currency=$currency->id} {l s='paid instead of'} - {displayPrice price=$orders_total_paid_tax_incl currency=$currency->id} - {foreach $order->getBrother() as $brother_order} + {displayPrice price=$order->total_paid_tax_incl currency=$currency->id} + {* {foreach $order->getBrother() as $brother_order} {if $brother_order@first} {if count($order->getBrother()) == 1}
{l s='This warning also concerns order '} @@ -488,7 +488,7 @@ #{'%06d'|sprintf:$brother_order->id} - {/foreach} + {/foreach} *}

{/if}
diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 407f0ded3..f5efa57b4 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -450,8 +450,13 @@ abstract class PaymentModuleCore extends Module throw new PrestaShopException('Can\'t save Order Payment'); } - foreach($order_list as $order) { - $order->addOrderPaymentDetail($order->amount_paid); + // now add payment detail for order + if ($payment = OrderPayment::getByOrderReference($order->reference)) { + if ($payment = array_shift($payment)) { + foreach($order_list as $order) { + $order->addOrderPaymentDetail($payment, $order->amount_paid); + } + } } } diff --git a/classes/order/Order.php b/classes/order/Order.php index 9d0f54cda..eb468965f 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -1725,6 +1725,7 @@ class OrderCore extends ObjectModel * @param Currency $currency * @param string $date * @param OrderInvoice $order_invoice + * @param bool $update_payment_detail :: if false, be sure to add payment detail in payment detail table * @return bool */ public function addOrderPayment($amount_paid, $payment_method = null, $payment_transaction_id = null, $currency = null, $date = null, $order_invoice = null, $update_payment_detail = true) @@ -1746,26 +1747,24 @@ class OrderCore extends ObjectModel } // We put autodate parameter of add method to true if date_add field is null - $res = $order_payment->add(is_null($order_payment->date_add)); - - if (!$res) { - return false; - } - - if ($update_payment_detail) { - $this->addOrderPaymentDetail($amount_paid, $order_invoice); + if ($res = $order_payment->add(is_null($order_payment->date_add))) { + if ($update_payment_detail) { + $res &= $this->addOrderPaymentDetail($order_payment, $amount_paid, $order_invoice); + } } return $res; } - public function addOrderPaymentDetail($amount, $order_invoice = null) + public function addOrderPaymentDetail(OrderPayment $payment, $amount = false, $order_invoice = null) { - if ($orderPayments = OrderPayment::getByOrderReference($this->reference)) { - $lastOrderPayment = array_pop($orderPayments); + if (Validate::isLoadedObject($payment)) { + if (!$amount) { + $amount = $payment->amount; + } $order_payment_detail = new OrderPaymentDetail(); $order_payment_detail->id_order = $this->id; - $order_payment_detail->id_order_payment = (int)$lastOrderPayment->id; + $order_payment_detail->id_order_payment = (int)$payment->id; $order_payment_detail->amount = $amount; if ($lastOrderPayment->id_currency == $this->id_currency) { @@ -1777,7 +1776,7 @@ class OrderCore extends ObjectModel if (!is_null($order_invoice)) { $res = Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order_payment_detail`, `id_order`) - VALUES('.(int)$order_invoice->id.', '.(int)(int)$lastOrderPayment->id.', '.(int)$order_payment_detail->id.', '.(int)$this->id.')'); + VALUES('.(int)$order_invoice->id.', '.(int)(int)$payment->id.', '.(int)$order_payment_detail->id.', '.(int)$this->id.')'); // Clear cache Cache::clean('order_invoice_paid_*'); diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 851365312..b2be62c84 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -336,7 +336,7 @@ class OrderHistoryCore extends ObjectModel $payment->conversion_rate = ($order ? $order->conversion_rate : 1); $payment->save(); - $id_order_payment_detail = $order->addOrderPaymentDetail($rest_paid); + $id_order_payment_detail = $order->addOrderPaymentDetail($payment); Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order_payment_detail`, `id_order`) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 43ab91edc..b03f6e375 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1554,7 +1554,6 @@ class AdminOrdersControllerCore extends AdminController 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), - 'orders_total_paid_tax_incl' => $order->total_paid_tax_incl, // Get the sum of total_paid_tax_incl of the order with similar reference 'total_paid' => $order->getTotalPaid(), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), From b29ecea9453f675ccc916f055903fbcc5251a49a Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sat, 17 Dec 2022 07:07:05 +0000 Subject: [PATCH 23/42] added order_payment_detail in pscleaner --- modules/pscleaner/pscleaner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/pscleaner/pscleaner.php b/modules/pscleaner/pscleaner.php index f49e61333..5fc55d0b3 100644 --- a/modules/pscleaner/pscleaner.php +++ b/modules/pscleaner/pscleaner.php @@ -839,6 +839,7 @@ class PSCleaner extends Module 'order_message', 'order_message_lang', 'order_payment', + 'order_payment_detail', 'order_return', 'order_return_detail', 'order_slip', From 8c4591de84da3563f39d2dc075246c22ac06f116 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 23 Dec 2022 16:47:31 +0530 Subject: [PATCH 24/42] Create default links using queries --- .../classes/HotelHelper.php | 75 ------------------- .../classes/HotelReservationSystemDb.php | 38 ++++++++++ .../classes/HotelSettingsLink.php | 6 +- ...minHotelConfigurationSettingController.php | 40 +++++----- 4 files changed, 61 insertions(+), 98 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 55a118145..44b43a517 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -527,80 +527,6 @@ class HotelHelper } } - public function saveDefaultHotelSettingsLinks() - { - $settingsLinks = array( - array( - 'name' => 'General Settings', - 'hint' => 'Configure Your Hotel general Settings using this option.', - 'icon' => 'icon-cogs', - 'link' => 'index.php?controller=AdminHotelGeneralSettings', - 'unremovable' => 1, - ), - array( - 'name' => 'Order Restrict', - 'hint' => 'Configure if you want to restrict orders till a specific date for your hotels.', - 'icon' => 'icon-list-alt', - 'link' => 'index.php?controller=AdminOrderRestrictSettings', - 'unremovable' => 1, - ), - array( - 'name' => 'Advanced Price Rules', - 'hint' => 'Here set advanced price rules for specific dates.', - 'icon' => 'icon-cog', - 'link' => 'index.php?controller=AdminHotelFeaturePricesSettings', - 'unremovable' => 1, - ), - array( - 'name' => 'Additional Facilities', - 'hint' => 'Here create additional facilities and their prices for room types.', - 'icon' => 'icon-cog', - 'link' => 'index.php?controller=AdminRoomTypeGlobalDemand', - 'unremovable' => 1, - ), - array( - 'name' => 'Hotel Interior Block', - 'hint' => 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.', - 'icon' => 'icon-file-text', - 'link' => 'index.php?controller=AdminAboutHotelBlockSetting', - 'unremovable' => 0, - ), - array( - 'name' => 'Hotel Amenities Block', - 'hint' => 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.', - 'icon' => 'icon-th-list', - 'link' => 'index.php?controller=AdminFeaturesModuleSetting', - 'unremovable' => 0, - ), - ); - - $languages = Language::getLanguages(); - foreach ($settingsLinks as $key => $settingsLink) { - $name = array(); - $hint = array(); - foreach ($languages as $language) { - $name[$language['id_lang']] = $settingsLink['name']; - $hint[$language['id_lang']] = $settingsLink['hint']; - } - - $objHotelSettingsLink = new HotelSettingsLink(); - $objHotelSettingsLink->name = $name; - $objHotelSettingsLink->hint = $hint; - $objHotelSettingsLink->icon = $settingsLink['icon']; - $objHotelSettingsLink->link = $settingsLink['link']; - $objHotelSettingsLink->new_window = 0; - $objHotelSettingsLink->position = (int) $key; - $objHotelSettingsLink->unremovable = $settingsLink['unremovable']; - $objHotelSettingsLink->active = 1; - - if (!$objHotelSettingsLink->save()) { - return false; - } - } - - return true; - } - public function saveAdvancedPaymentInfo($id_product) { $obj_adv_pmt = new HotelAdvancedPayment(); @@ -647,7 +573,6 @@ class HotelHelper $this->saveDummyHotelImages($htl_id); $this->saveDummyHotelFeatures($htl_id); $this->saveDummyProductsAndRelatedInfo($htl_id); - $this->saveDefaultHotelSettingsLinks(); return true; } diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index b4d3edb84..756053675 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -386,6 +386,14 @@ class HotelReservationSystemDb PRIMARY KEY (`id_settings_link`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + "INSERT INTO `"._DB_PREFIX_."htl_settings_link` (`id_settings_link`, `icon`, `link`, `new_window`, `position`, `unremovable`, `active`, `date_add`, `date_upd`) VALUES + (1, 'icon-cogs', 'index.php?controller=AdminHotelGeneralSettings', 0, 0, 1, 1, NOW(), NOW()), + (2, 'icon-list-alt', 'index.php?controller=AdminOrderRestrictSettings', 0, 1, 1, 1, NOW(), NOW()), + (3, 'icon-dollar', 'index.php?controller=AdminHotelFeaturePricesSettings', 0, 2, 1, 1, NOW(), NOW()), + (4, 'icon-plus-square', 'index.php?controller=AdminRoomTypeGlobalDemand', 0, 3, 1, 1, NOW(), NOW()), + (5, 'icon-file-text', 'index.php?controller=AdminAboutHotelBlockSetting', 0, 4, 0, 1, NOW(), NOW()), + (6, 'icon-th-list', 'index.php?controller=AdminFeaturesModuleSetting', 0, 5, 0, 1, NOW(), NOW());", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_settings_link_lang` ( `id_settings_link` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, @@ -393,6 +401,36 @@ class HotelReservationSystemDb `hint` varchar(255) character set utf8 NOT NULL, PRIMARY KEY (`id_settings_link`, `id_lang`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", + + "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 1, `id_lang`, 'General Settings', 'Configure Your hotel general gettings using this option.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", + + "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 2, `id_lang`, 'Order Restrict', 'Configure if you want to restrict orders till a specific date for your hotels.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", + + "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 3, `id_lang`, 'Advanced Price Rules', 'Here set Advanced price rules for specific dates.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", + + "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 4, `id_lang`, 'Additional Facilities', 'Here create Additional facilities and their prices for room types.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", + + "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 5, `id_lang`, 'Hotel Interior Block', 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", + + "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 6, `id_lang`, 'Hotel Amenities Block', 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", ); } diff --git a/modules/hotelreservationsystem/classes/HotelSettingsLink.php b/modules/hotelreservationsystem/classes/HotelSettingsLink.php index 06229d2c5..c59ed9ebe 100644 --- a/modules/hotelreservationsystem/classes/HotelSettingsLink.php +++ b/modules/hotelreservationsystem/classes/HotelSettingsLink.php @@ -50,13 +50,13 @@ class HotelSettingsLink extends ObjectModel ), ); - public function getAll($active = true) + public function getAllSettingsLinks($active = true) { return Db::getInstance()->executeS( 'SELECT * FROM `'._DB_PREFIX_.'htl_settings_link` hsl LEFT JOIN `'._DB_PREFIX_.'htl_settings_link_lang` hsll - ON hsll.`id_settings_link` = hsl.`id_settings_link` AND hsll.`id_lang` = '.(int) Context::getContext()->language->id. - ($active ? ' WHERE hsl.`active` = 1' : '').' + ON (hsll.`id_settings_link` = hsl.`id_settings_link` AND hsll.`id_lang` = '.(int) Context::getContext()->language->id.') + WHERE hsl.`active` = '.(int) $active.' ORDER BY hsl.`position`' ); } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php index 77b1ebae6..84368f047 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php @@ -19,6 +19,25 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController $this->addRowAction('edit'); $this->addRowAction('delete'); + $this->bulk_actions = array( + 'enableSelection' => array( + 'text' => $this->l('Enable selection'), + 'icon' => 'icon-power-off text-success' + ), + 'disableSelection' => array( + 'text' => $this->l('Disable selection'), + 'icon' => 'icon-power-off text-danger' + ), + 'divider' => array( + 'text' => 'divider' + ), + 'delete' => array( + 'text' => $this->l('Delete selected'), + 'confirm' => $this->l('Delete selected items?'), + 'icon' => 'icon-trash' + ) + ); + $this->fields_list = array( 'id_settings_link' => array( 'title' => $this->l('ID'), @@ -71,25 +90,6 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController 'filter_key' => 'a!active', ), ); - - $this->bulk_actions = array( - 'enableSelection' => array( - 'text' => $this->l('Enable selection'), - 'icon' => 'icon-power-off text-success' - ), - 'disableSelection' => array( - 'text' => $this->l('Disable selection'), - 'icon' => 'icon-power-off text-danger' - ), - 'divider' => array( - 'text' => 'divider' - ), - 'delete' => array( - 'text' => $this->l('Delete selected'), - 'confirm' => $this->l('Delete selected items?'), - 'icon' => 'icon-trash' - ) - ); } public function displayColumnIcon($icon) @@ -205,7 +205,7 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController public function renderView() { - $settingsLinks = $this->object->getAll(); + $settingsLinks = $this->object->getAllSettingsLinks(); foreach ($settingsLinks as $index => &$settingsLink) { $settingsLink['generated_link'] = $this->object->generateLink($settingsLink['link']); } From 53b4f466a5b96fbb37da9689bd67b716129a3805 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 23 Dec 2022 17:08:52 +0530 Subject: [PATCH 25/42] Fix PHP error on passing wrong dates in URL --- controllers/front/CategoryController.php | 12 ++++++++++++ controllers/front/ProductController.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index ffc087ecd..de7b24565 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -95,6 +95,18 @@ class CategoryControllerCore extends FrontController $this->errors[] = Tools::displayError('Missing category ID'); } + // validate dates if available + $dateFrom = Tools::getValue('date_from'); + $dateTo = Tools::getValue('date_to'); + + if ($dateFrom != '' && !Validate::isDate($dateFrom)) { + Tools::redirect($this->context->link->getPageLink('pagenotfound')); + } + + if ($dateTo != '' && !Validate::isDate($dateTo)) { + Tools::redirect($this->context->link->getPageLink('pagenotfound')); + } + // Instantiate category $this->category = new Category($id_category, $this->context->language->id); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index f0b0d732d..b9e725682 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -88,6 +88,18 @@ class ProductControllerCore extends FrontController */ public function init() { + // validate dates if available + $dateFrom = Tools::getValue('date_from'); + $dateTo = Tools::getValue('date_to'); + + if ($dateFrom != '' && !Validate::isDate($dateFrom)) { + Tools::redirect($this->context->link->getPageLink('pagenotfound')); + } + + if ($dateTo != '' && !Validate::isDate($dateTo)) { + Tools::redirect($this->context->link->getPageLink('pagenotfound')); + } + parent::init(); if ($id_product = (int) Tools::getValue('id_product')) { From 9bf2cdf42f332c8d4886a2cb74b0fd5e17ac7ce7 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 25 Dec 2022 11:55:59 +0530 Subject: [PATCH 26/42] udpated changes --- .../controllers/orders/helpers/view/view.tpl | 10 ++-- classes/Cart.php | 4 +- ...ayingGuest.php => CustomerGuestDetail.php} | 25 ++++++--- classes/PaymentModule.php | 26 +++++----- .../CheckoutCustomerDetailsStep.php | 6 +-- classes/order/Order.php | 6 +-- controllers/admin/AdminOrdersController.php | 8 +-- controllers/front/OrderOpcController.php | 52 +++++++++---------- install/data/db_structure.sql | 20 +++++-- .../hotel-reservation-theme/js/order-opc.js | 22 ++++---- themes/hotel-reservation-theme/order-opc.tpl | 22 ++++---- 11 files changed, 111 insertions(+), 90 deletions(-) rename classes/{BookingStayingGuest.php => CustomerGuestDetail.php} (70%) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 66dd53a9c..3d9c89ec6 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -703,17 +703,17 @@
{$customer->ape}
{/if} -->
- {if $order->id_booking_staying_guest} + {if $order->id_customer_guest_detail}
- {l s='Staying guest'} + {l s='Guest'}
{l s='Name'}
-
{$bookingStayingGuest->firstname} {$bookingStayingGuest->lastname}

+
{$customerGuestDetail->firstname} {$customerGuestDetail->lastname}

{l s='Email'}
-
{$bookingStayingGuest->email}

+
{$customerGuestDetail->email}

{l s='Phone'}
-
{$bookingStayingGuest->phone}
+
{$customerGuestDetail->phone}
{/if} {/if} diff --git a/classes/Cart.php b/classes/Cart.php index 9e5669df0..361942ff4 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -88,7 +88,7 @@ class CartCore extends ObjectModel */ public $is_advance_payment; - public $id_booking_staying_guest; + public $id_customer_guest_detail; protected static $_nbProducts = array(); protected static $_isVirtualCart = array(); @@ -118,7 +118,7 @@ class CartCore extends ObjectModel 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_booking_staying_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_customer_guest_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), diff --git a/classes/BookingStayingGuest.php b/classes/CustomerGuestDetail.php similarity index 70% rename from classes/BookingStayingGuest.php rename to classes/CustomerGuestDetail.php index 4d297b70e..f78f8b231 100644 --- a/classes/BookingStayingGuest.php +++ b/classes/CustomerGuestDetail.php @@ -18,9 +18,9 @@ * @license https://store.webkul.com/license.html */ -class BookingStayingGuestCore extends ObjectModel +class CustomerGuestDetailCore extends ObjectModel { - public $id_booking_staying_guest; + public $id_customer_guest_detail; public $id_gender; public $firstname; public $lastname; @@ -30,9 +30,10 @@ class BookingStayingGuestCore extends ObjectModel public $date_upd; public static $definition = array( - 'table' => 'booking_staying_guest', - 'primary' => 'id_booking_staying_guest', + 'table' => 'customer_guest_detail', + 'primary' => 'id_customer_guest_detail', 'fields' => array( + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), @@ -43,11 +44,21 @@ class BookingStayingGuestCore extends ObjectModel ), ); - public static function getBookingStayingGuestInfo($id_booking_staying_guest) + public static function getCustomerGuests($id_customer) { return Db::getInstance()->getRow(' - SELECT * FROM `'._DB_PREFIX_.'booking_staying_guest` - WHERE `id_booking_staying_guest` = '.(int)$id_booking_staying_guest + SELECT `id_customer_guest_detail`, `id_gender`, `firstname`, `lastname`, `email`, `phone` + FROM `'._DB_PREFIX_.'customer_guest_detail` + WHERE `id_customer` = '.(int)$id_customer + ); + } + + public static function getCustomerGuestDetail($id_customer_guest_detail) + { + return Db::getInstance()->getRow(' + SELECT `id_gender`, `firstname`, `lastname`, `email`, `phone` + FROM `'._DB_PREFIX_.'customer_guest_detail` + WHERE `id_customer_guest_detail` = '.(int)$id_customer_guest_detail ); } diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 07ae42212..df6969c94 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -362,9 +362,9 @@ abstract class PaymentModuleCore extends Module $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); } - // save staying guest information - if ($this->context->cart->id_booking_staying_guest) { - $order->id_booking_staying_guest = (int)$this->context->cart->id_booking_staying_guest; + // save customer guest information + if ($this->context->cart->id_customer_guest_detail) { + $order->id_customer_guest_detail = (int)$this->context->cart->id_customer_guest_detail; } // Creating order @@ -1022,22 +1022,22 @@ abstract class PaymentModuleCore extends Module null, _PS_MAIL_DIR_, false, (int)$order->id_shop ); } - // send mail to staying guest if customer booked for someone other. - if ($order->id_booking_staying_guest) { - if ($stayingGuestInfo = BookingStayingGuest::getBookingStayingGuestInfo( - $order->id_booking_staying_guest + // send mail to customer guest if customer booked for someone other. + if ($order->id_customer_guest_detail) { + if ($customerGuestDetail = CustomerGuestDetail::getCustomerGuestDetail( + $order->id_customer_guest_detail )) { - if (Validate::isEmail($stayingGuestInfo['email'])) { - $data['{firstname}'] = $stayingGuestInfo['firstname']; - $data['{lastname}'] = $stayingGuestInfo['lastname']; - $data['{email}'] = $stayingGuestInfo['email']; + if (Validate::isEmail($customerGuestDetail['email'])) { + $data['{firstname}'] = $customerGuestDetail['firstname']; + $data['{lastname}'] = $customerGuestDetail['lastname']; + $data['{email}'] = $customerGuestDetail['email']; Mail::Send( (int)$order->id_lang, 'order_conf', Mail::l('Order confirmation', (int)$order->id_lang), $data, - $stayingGuestInfo['email'], - $stayingGuestInfo['firstname'].' '.$stayingGuestInfo['lastname'], + $customerGuestDetail['email'], + $customerGuestDetail['firstname'].' '.$customerGuestDetail['lastname'], null, null, $file_attachement, diff --git a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php index 543f2e286..00d908283 100644 --- a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php +++ b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php @@ -43,10 +43,10 @@ class CheckoutCustomerDetailsStep extends AbstractCheckoutStep } } elseif (Tools::getValue('proceed_to_payment')) { $guestInfoComplete = true; - if ($this->context->cart->id_booking_staying_guest) { + if ($this->context->cart->id_customer_guest_detail) { $guestInfoComplete = false; - $objBookingStayingGuest = new BookingStayingGuest($this->context->cart->id_booking_staying_guest); - if ($objBookingStayingGuest->validateGuestInfo()) { + $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); + if ($objCustomerGuestDetail->validateGuestInfo()) { $guestInfoComplete = true; } } diff --git a/classes/order/Order.php b/classes/order/Order.php index 5f108da9e..7bbbe06f2 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -59,8 +59,8 @@ class OrderCore extends ObjectModel /** @var int Customer id */ public $id_customer; - /** @var int Staying guest id */ - public $id_booking_staying_guest; + /** @var int Customer guest id */ + public $id_customer_guest_detail; /** @var int Carrier id */ public $id_carrier; @@ -209,7 +209,7 @@ class OrderCore extends ObjectModel 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'id_booking_staying_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_customer_guest_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'current_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 3b43d4eb9..d500a73ee 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1335,9 +1335,9 @@ class AdminOrdersControllerCore extends AdminController } // get details if booking is done for some other guest - $bookingStayingGuest = false; - if ($order->id_booking_staying_guest) { - $bookingStayingGuest = new BookingStayingGuest($order->id_booking_staying_guest); + $customerGuestDetail = false; + if ($order->id_customer_guest_detail) { + $customerGuestDetail = new CustomerGuestDetail($order->id_customer_guest_detail); } // gets warehouses to ship products, if and only if advanced stock management is activated @@ -1522,7 +1522,7 @@ class AdminOrdersControllerCore extends AdminController 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, - 'bookingStayingGuest' => $bookingStayingGuest, + 'customerGuestDetail' => $customerGuestDetail, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array( 'delivery' => $addressDelivery, diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 5cac05ba3..03d94e09d 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -317,8 +317,8 @@ class OrderOpcControllerCore extends ParentOrderController $this->ajaxDie($this->changeRoomDemands()); exit; break; - case 'submitBookingStayingGuest': - $this->ajaxDie($this->submitBookingStayingGuest()); + case 'submitCustomerGuestDetail': + $this->ajaxDie($this->submitCustomerGuestDetail()); exit; break; default: @@ -483,10 +483,10 @@ class OrderOpcControllerCore extends ParentOrderController $this->_assignPayment(); // GUEST BOOKING if ($this->isLogged) { - if ($this->context->cart->id_booking_staying_guest) { - $this->context->smarty->assign('booking_staying_guest', BookingStayingGuest::getBookingStayingGuestInfo($this->context->cart->id_booking_staying_guest)); + if ($this->context->cart->id_customer_guest_detail) { + $this->context->smarty->assign('customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetail($this->context->cart->id_customer_guest_detail)); } - $this->context->smarty->assign('id_booking_staying_guest', $this->context->cart->id_booking_staying_guest); + $this->context->smarty->assign('id_customer_guest_detail', $this->context->cart->id_customer_guest_detail); } Tools::safePostVars(); @@ -976,33 +976,33 @@ class OrderOpcControllerCore extends ParentOrderController die('0'); } - public function submitBookingStayingGuest() + public function submitCustomerGuestDetail() { - $booking_staying_guest = Tools::getValue('booking_staying_guest'); + $customer_guest_detail = Tools::getValue('customer_guest_detail'); $this->context->cookie->__set('customer_details_proceeded', 0); $this->context->cookie->checkedTOS = false; - if ($booking_staying_guest) { - if ($this->context->cart->id_booking_staying_guest) { - $objBookingStayingGuest = new BookingStayingGuest($this->context->cart->id_booking_staying_guest); + if ($customer_guest_detail) { + if ($this->context->cart->id_customer_guest_detail) { + $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); } else { - $objBookingStayingGuest = new BookingStayingGuest(); + $objCustomerGuestDetail = new CustomerGuestDetail(); } - $booking_staying_guest_gender = Tools::getValue('booking_staying_guest_gender'); - $booking_staying_guest_firstname = Tools::getValue('booking_staying_guest_firstname'); - $booking_staying_guest_lastname = Tools::getValue('booking_staying_guest_lastname'); - $booking_staying_guest_email = Tools::getValue('booking_staying_guest_email'); - $booking_staying_guest_phone = Tools::getValue('booking_staying_guest_phone'); - $objBookingStayingGuest->id_gender = $booking_staying_guest_gender; - $objBookingStayingGuest->firstname = $booking_staying_guest_firstname; - $objBookingStayingGuest->lastname = $booking_staying_guest_lastname; - $objBookingStayingGuest->email = $booking_staying_guest_email; - $objBookingStayingGuest->phone = $booking_staying_guest_phone; - $objBookingStayingGuest->save(); - $this->context->cart->id_booking_staying_guest = $objBookingStayingGuest->id; + $customer_guest_detail_gender = Tools::getValue('customer_guest_detail_gender'); + $customer_guest_detail_firstname = Tools::getValue('customer_guest_detail_firstname'); + $customer_guest_detail_lastname = Tools::getValue('customer_guest_detail_lastname'); + $customer_guest_detail_email = Tools::getValue('customer_guest_detail_email'); + $customer_guest_detail_phone = Tools::getValue('customer_guest_detail_phone'); + $objCustomerGuestDetail->id_gender = $customer_guest_detail_gender; + $objCustomerGuestDetail->firstname = $customer_guest_detail_firstname; + $objCustomerGuestDetail->lastname = $customer_guest_detail_lastname; + $objCustomerGuestDetail->email = $customer_guest_detail_email; + $objCustomerGuestDetail->phone = $customer_guest_detail_phone; + $objCustomerGuestDetail->save(); + $this->context->cart->id_customer_guest_detail = $objCustomerGuestDetail->id; } else { - $objBookingStayingGuest = new BookingStayingGuest($this->context->cart->id_booking_staying_guest); - $objBookingStayingGuest->delete(); - $this->context->cart->id_booking_staying_guest = false; + $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); + $objCustomerGuestDetail->delete(); + $this->context->cart->id_customer_guest_detail = false; } $this->context->cart->save(); } diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index b32447bdb..331237fe1 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -182,7 +182,6 @@ CREATE TABLE `PREFIX_cart` ( `id_currency` int(10) unsigned NOT NULL, `id_customer` int(10) unsigned NOT NULL, `id_guest` int(10) unsigned NOT NULL, - `id_booking_staying_guest` int(10) unsigned NOT NULL, `secure_key` varchar(32) NOT NULL DEFAULT '-1', `recyclable` tinyint(1) unsigned NOT NULL DEFAULT '1', `gift` tinyint(1) unsigned NOT NULL DEFAULT '0', @@ -674,9 +673,21 @@ CREATE TABLE `PREFIX_customer_thread` ( KEY `id_product` (`id_product`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; -CREATE TABLE `PREFIX_booking_staying_guest` ( - `id_booking_staying_guest` int(10) unsigned NOT NULL auto_increment, +CREATE TABLE `PREFIX_order_customer_guest_detail` ( + `id_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, `id_cart` int(10) unsigned NOT NULL, + `id_gender` int(10) unsigned NOT NULL, + `firstname` varchar(32) NOT NULL, + `lastname` varchar(32) NOT NULL, + `email` varchar(128) NOT NULL, + `phone` varchar(32) DEFAULT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_customer_guest_detail`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; + +CREATE TABLE `PREFIX_cart_customer_guest_detail` ( + `id_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, `id_order` int(10) unsigned NOT NULL, `id_gender` int(10) unsigned NOT NULL, `firstname` varchar(32) NOT NULL, @@ -685,7 +696,7 @@ CREATE TABLE `PREFIX_booking_staying_guest` ( `phone` varchar(32) DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_booking_staying_guest`) + PRIMARY KEY (`id_customer_guest_detail`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_customization` ( @@ -1112,7 +1123,6 @@ CREATE TABLE `PREFIX_orders` ( `id_carrier` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `id_customer` int(10) unsigned NOT NULL, - `id_booking_staying_guest` int(10) unsigned NOT NULL, `id_cart` int(10) unsigned NOT NULL, `id_currency` int(10) unsigned NOT NULL, `id_address_delivery` int(10) unsigned NOT NULL, diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 2c11ef492..0bf99bd8f 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -50,18 +50,18 @@ $(document).ready(function() $("#partial_data").slideDown(); }); - // staying guest booking + // customer guest booking function initGuestbookingcontainer() { - if ($("#booking_staying_guest:checked").val() == 1) { + if ($("#customer_guest_detail:checked").val() == 1) { $('#customer_info_container').hide('slow'); - $('#booking_staying_guest_container').show('slow'); + $('#customer_guest_detail_container').show('slow'); } else { - $('#booking_staying_guest_container').hide('slow'); + $('#customer_guest_detail_container').hide('slow'); $('#customer_info_container').show('slow'); } } - function validateBookingStayingGuestForm() { - $('#booking_staying_guest_form input.validate').each(function (index, element) { + function validateCustomerGuestDetailForm() { + $('#customer_guest_detail_form input.validate').each(function (index, element) { if (!validate_field(element)) { if ($('#cgv').prop('checked') == 1) { $('#cgv').trigger('click'); @@ -70,21 +70,21 @@ $(document).ready(function() }); } initGuestbookingcontainer(); - $("#booking_staying_guest").on('change',function() { + $("#customer_guest_detail").on('change',function() { initGuestbookingcontainer(); }); - if ($("#booking_staying_guest:checked").val() == 1) { - validateBookingStayingGuestForm(); + if ($("#customer_guest_detail:checked").val() == 1) { + validateCustomerGuestDetailForm(); } - $('#booking_staying_guest_form').on('change', function(e) { + $('#customer_guest_detail_form').on('change', function(e) { $.ajax({ type: 'POST', url: orderOpcUrl, async: false, cache: false, dataType : "json", - data: $(this).serialize()+'&method=submitBookingStayingGuest&ajax=true&token=' + static_token + data: $(this).serialize()+'&method=submitCustomerGuestDetail&ajax=true&token=' + static_token }); }); diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index 2e0696581..eb1959b54 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -78,46 +78,46 @@
{if $is_logged || $isGuest} - + {if $is_logged}

- - + +

{/if} -
+
- {foreach from=$genders key=k item=gender} - + {/foreach}
- +
- +
- +
- +
-
+
{l s='Name'}
{$guestInformations['firstname']} {$guestInformations['lastname']}
From 8935b0a6703ab8b171e1ccaa911e03910a6fae8e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 26 Dec 2022 14:41:07 +0530 Subject: [PATCH 27/42] created indivisual table of guest detail for cart and order --- .../controllers/orders/helpers/view/view.tpl | 113 ++++++++++++++++-- classes/Cart.php | 3 - ...Detail.php => CartCustomerGuestDetail.php} | 19 +-- classes/PaymentModule.php | 39 +++--- .../CheckoutCustomerDetailsStep.php | 4 +- classes/order/Order.php | 4 - classes/order/OrderCustomerGuestDetail.php | 74 ++++++++++++ controllers/admin/AdminOrdersController.php | 49 +++++++- controllers/front/OrderDetailController.php | 7 ++ controllers/front/OrderOpcController.php | 59 +++++---- install/data/db_structure.sql | 8 +- .../hotel-reservation-theme/order-detail.tpl | 37 ++++-- 12 files changed, 335 insertions(+), 81 deletions(-) rename classes/{CustomerGuestDetail.php => CartCustomerGuestDetail.php} (81%) create mode 100644 classes/order/OrderCustomerGuestDetail.php diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 3d9c89ec6..80fcb197a 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -703,18 +703,66 @@
{$customer->ape}
{/if} --> - {if $order->id_customer_guest_detail} -
+ {if $customerGuestDetail} +
{l s='Guest'}
-
{l s='Name'}
-
{$customerGuestDetail->firstname} {$customerGuestDetail->lastname}

-
{l s='Email'}
-
{$customerGuestDetail->email}

-
{l s='Phone'}
-
{$customerGuestDetail->phone}
-
+
+
{l s='Name'}
+
{$customerGuestDetail->gender->name} {$customerGuestDetail->firstname} {$customerGuestDetail->lastname}
+
+
{l s='Email'}
+
{$customerGuestDetail->email}

+
{l s='Phone'}
+
{$customerGuestDetail->phone}
+
+ +
+
+ +
+
{l s='Social title'}
+
+ +

+
{l s='First name'}
+
+ +

+
{l s='Last name'}
+
+ +

+
{l s='Email'}
+
+ +

+
{l s='Phone'}
+
+ +
+
+
+ + + +
+ +
{/if} {/if}
@@ -1695,6 +1743,53 @@ /*END*/ + // for updating customer guest details + $('#edit_guest_details').on('click', function(e) { + e.preventDefault(); + $('#customer-guest-details-form').show(); + $('#customer-guest-details').hide(); + }); + + $('#cancle_edit_guest_details').on('click', function(e) { + e.preventDefault(); + $('#customer-guest-details-form').hide(); + $('#customer-guest-details').show(); + }); + + $('#submit_guest_details').on('click', function(e) { + e.preventDefault(); + $.ajax({ + type: 'POST', + headers: { + "cache-control": "no-cache" + }, + url: "{$link->getAdminLink('AdminOrders')|addslashes}", + dataType: 'JSON', + cache: false, + data: $('#customer-guest-details-form').serialize()+'&ajax=true&id_order='+id_order+'&action=updateGuestDetails', + success: function(result) { + if (result.success) { + if (result.msg) { + showSuccessMessage(result.msg); + } + if (result.data.guest_name) { + $('#customer-guest-details .guest_name').text(result.data.guest_name); + } + if (result.data.guest_email) { + $('#customer-guest-details .guest_email a').attr('href', 'mailto:'+result.data.guest_email).text(result.data.guest_email); + } + if (result.data.guest_phone) { + $('#customer-guest-details .guest_phone a').attr('href', 'tel'+result.data.guest_phone).text(result.data.guest_phone); + } + $('#customer-guest-details-form').hide(); + $('#customer-guest-details').show(); + } else if (result.errors) { + showErrorMessage(result.errors); + } + } + }); + }); + $(".textarea-autosize").autosize(); var date = new Date(); diff --git a/classes/Cart.php b/classes/Cart.php index 361942ff4..18b2c15cf 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -88,8 +88,6 @@ class CartCore extends ObjectModel */ public $is_advance_payment; - public $id_customer_guest_detail; - protected static $_nbProducts = array(); protected static $_isVirtualCart = array(); @@ -118,7 +116,6 @@ class CartCore extends ObjectModel 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_customer_guest_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), diff --git a/classes/CustomerGuestDetail.php b/classes/CartCustomerGuestDetail.php similarity index 81% rename from classes/CustomerGuestDetail.php rename to classes/CartCustomerGuestDetail.php index f78f8b231..d21c56c68 100644 --- a/classes/CustomerGuestDetail.php +++ b/classes/CartCustomerGuestDetail.php @@ -18,9 +18,10 @@ * @license https://store.webkul.com/license.html */ -class CustomerGuestDetailCore extends ObjectModel +class CartCustomerGuestDetailCore extends ObjectModel { public $id_customer_guest_detail; + public $id_cart; public $id_gender; public $firstname; public $lastname; @@ -30,10 +31,10 @@ class CustomerGuestDetailCore extends ObjectModel public $date_upd; public static $definition = array( - 'table' => 'customer_guest_detail', + 'table' => 'cart_customer_guest_detail', 'primary' => 'id_customer_guest_detail', 'fields' => array( - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), @@ -44,12 +45,12 @@ class CustomerGuestDetailCore extends ObjectModel ), ); - public static function getCustomerGuests($id_customer) + public static function getCartCustomerGuest($id_cart) { - return Db::getInstance()->getRow(' - SELECT `id_customer_guest_detail`, `id_gender`, `firstname`, `lastname`, `email`, `phone` - FROM `'._DB_PREFIX_.'customer_guest_detail` - WHERE `id_customer` = '.(int)$id_customer + return Db::getInstance()->getValue(' + SELECT `id_customer_guest_detail` + FROM `'._DB_PREFIX_.'cart_customer_guest_detail` + WHERE `id_cart` = '.(int)$id_cart ); } @@ -57,7 +58,7 @@ class CustomerGuestDetailCore extends ObjectModel { return Db::getInstance()->getRow(' SELECT `id_gender`, `firstname`, `lastname`, `email`, `phone` - FROM `'._DB_PREFIX_.'customer_guest_detail` + FROM `'._DB_PREFIX_.'cart_customer_guest_detail` WHERE `id_customer_guest_detail` = '.(int)$id_customer_guest_detail ); } diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index df6969c94..2a696c1ee 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -362,11 +362,6 @@ abstract class PaymentModuleCore extends Module $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); } - // save customer guest information - if ($this->context->cart->id_customer_guest_detail) { - $order->id_customer_guest_detail = (int)$this->context->cart->id_customer_guest_detail; - } - // Creating order $result = $order->add(); @@ -375,6 +370,22 @@ abstract class PaymentModuleCore extends Module throw new PrestaShopException('Can\'t save Order'); } + // save customer guest information + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + if (Validate::isLoadedObject($objCartCustomerGuestDetail = new CartCustomerGuestDetail( + $id_customer_guest_detail + ))) { + $objOrderCustomerGuestDetail = new OrderCustomerGuestDetail(); + $objOrderCustomerGuestDetail->id_gender = $objCartCustomerGuestDetail->id_gender; + $objOrderCustomerGuestDetail->firstname = $objCartCustomerGuestDetail->firstname; + $objOrderCustomerGuestDetail->lastname = $objCartCustomerGuestDetail->lastname; + $objOrderCustomerGuestDetail->email = $objCartCustomerGuestDetail->email; + $objOrderCustomerGuestDetail->phone = $objCartCustomerGuestDetail->phone; + $objOrderCustomerGuestDetail->id_order = (int)$order->id; + $objOrderCustomerGuestDetail->save(); + } + } + // Amount paid by customer is not the right one -> Status = payment error // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php // if ($order->total_paid != $order->total_paid_real) @@ -1023,21 +1034,21 @@ abstract class PaymentModuleCore extends Module ); } // send mail to customer guest if customer booked for someone other. - if ($order->id_customer_guest_detail) { - if ($customerGuestDetail = CustomerGuestDetail::getCustomerGuestDetail( - $order->id_customer_guest_detail + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + if ($objOrderCustomerGuestDetail = new OrderCustomerGuestDetail( + $id_customer_guest_detail )) { - if (Validate::isEmail($customerGuestDetail['email'])) { - $data['{firstname}'] = $customerGuestDetail['firstname']; - $data['{lastname}'] = $customerGuestDetail['lastname']; - $data['{email}'] = $customerGuestDetail['email']; + if (Validate::isEmail($objOrderCustomerGuestDetail->email)) { + $data['{firstname}'] = $objOrderCustomerGuestDetail->firstname; + $data['{lastname}'] = $objOrderCustomerGuestDetail->lastname; + $data['{email}'] = $objOrderCustomerGuestDetail->email; Mail::Send( (int)$order->id_lang, 'order_conf', Mail::l('Order confirmation', (int)$order->id_lang), $data, - $customerGuestDetail['email'], - $customerGuestDetail['firstname'].' '.$customerGuestDetail['lastname'], + $objOrderCustomerGuestDetail->email, + $objOrderCustomerGuestDetail->firstname.' '.$objOrderCustomerGuestDetail->lastname, null, null, $file_attachement, diff --git a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php index 00d908283..7ec1fef59 100644 --- a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php +++ b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php @@ -43,9 +43,9 @@ class CheckoutCustomerDetailsStep extends AbstractCheckoutStep } } elseif (Tools::getValue('proceed_to_payment')) { $guestInfoComplete = true; - if ($this->context->cart->id_customer_guest_detail) { + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { $guestInfoComplete = false; - $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); + $objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail); if ($objCustomerGuestDetail->validateGuestInfo()) { $guestInfoComplete = true; } diff --git a/classes/order/Order.php b/classes/order/Order.php index 7bbbe06f2..548e58610 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -59,9 +59,6 @@ class OrderCore extends ObjectModel /** @var int Customer id */ public $id_customer; - /** @var int Customer guest id */ - public $id_customer_guest_detail; - /** @var int Carrier id */ public $id_carrier; @@ -209,7 +206,6 @@ class OrderCore extends ObjectModel 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'id_customer_guest_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'current_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'), diff --git a/classes/order/OrderCustomerGuestDetail.php b/classes/order/OrderCustomerGuestDetail.php new file mode 100644 index 000000000..9f7013bdd --- /dev/null +++ b/classes/order/OrderCustomerGuestDetail.php @@ -0,0 +1,74 @@ + +* @copyright 2010-2022 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +class OrderCustomerGuestDetailCore extends ObjectModel +{ + public $id_order_customer_guest_detail; + public $id_order; + public $id_gender; + public $firstname; + public $lastname; + public $email; + public $phone; + public $date_add; + public $date_upd; + + public static $definition = array( + 'table' => 'order_customer_guest_detail', + 'primary' => 'id_order_customer_guest_detail', + 'fields' => array( + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), + 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128), + 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + ); + + public static function isCustomerGuestBooking($id_order) + { + return Db::getInstance()->getValue(' + SELECT `id_order_customer_guest_detail` + FROM `'._DB_PREFIX_.'order_customer_guest_detail` + WHERE `id_order` = '.(int)$id_order + ); + } + + public function validateGuestInfo() + { + $isValid = true; + if (!trim($this->firstname) || !Validate::isName($this->firstname)) { + $isValid = false; + } + if (!trim($this->lastname) || !Validate::isName($this->lastname)) { + $isValid = false; + } + if (!trim($this->email) || !Validate::isEmail($this->email)) { + $isValid = false; + } + if (!trim($this->phone) || !Validate::isPhoneNumber($this->phone)) { + $isValid = false; + } + return $isValid; + } +} \ No newline at end of file diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d500a73ee..08be801d0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1336,8 +1336,9 @@ class AdminOrdersControllerCore extends AdminController // get details if booking is done for some other guest $customerGuestDetail = false; - if ($order->id_customer_guest_detail) { - $customerGuestDetail = new CustomerGuestDetail($order->id_customer_guest_detail); + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + $customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail); + $customerGuestDetail->gender = new Gender($customerGuestDetail->id_gender, $this->context->language->id); } // gets warehouses to ship products, if and only if advanced stock management is activated @@ -1523,6 +1524,7 @@ class AdminOrdersControllerCore extends AdminController 'customer' => $customer, 'gender' => $gender, 'customerGuestDetail' => $customerGuestDetail, + 'genders' => Gender::getGenders(), 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array( 'delivery' => $addressDelivery, @@ -1592,6 +1594,49 @@ class AdminOrdersControllerCore extends AdminController return parent::renderView(); } + public function ajaxProcessUpdateGuestDetails() + { + $response = array( + 'success' => false + ); + if (Validate::isLoadedObject($order = new Order(Tools::getValue('id_order')))) { + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + if (Validate::isLoadedObject($objCustomerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail))) { + $id_gender = Tools::getValue('id_gender'); + $firstname = Tools::getValue('firstname'); + $lastname = Tools::getValue('lastname'); + $email = Tools::getValue('email'); + $phone = Tools::getValue('phone'); + $objCustomerGuestDetail->id_gender = $id_gender; + $objCustomerGuestDetail->firstname = $firstname; + $objCustomerGuestDetail->lastname = $lastname; + $objCustomerGuestDetail->email = $email; + $objCustomerGuestDetail->phone = $phone; + if ($objCustomerGuestDetail->validateGuestInfo()) { + if ($objCustomerGuestDetail->save()) { + $response['success'] = true; + $gender = new Gender($objCustomerGuestDetail->id_gender, $this->context->language->id); + $response['data']['guest_name'] = $gender->name.' '.$objCustomerGuestDetail->firstname.' '.$objCustomerGuestDetail->lastname ; + $response['data']['guest_email'] = $objCustomerGuestDetail->email; + $response['data']['guest_phone'] = $objCustomerGuestDetail->phone; + $response['msg'] = $this->l('Guest details are updated.'); + } else { + $response['errors'][] = $this->l('Unable to save guest details.'); + } + } else { + $response['errors'][] = $this->l('Invalid guest details, please check and try again.'); + } + } else { + $response['errors'][] = $this->l('Guest details not found.'); + } + } else { + $response['errors'][] = $this->l('Guest details not found.'); + } + } + + $this->ajaxDie(json_encode($response)); + } + public function ajaxProcessSearchProducts() { Context::getContext()->customer = new Customer((int)Tools::getValue('id_customer')); diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 120a32022..07d84ff97 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -275,6 +275,12 @@ class OrderDetailControllerCore extends FrontController $customer = new Customer($order->id_customer); + $customerGuestDetail = false; + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + $customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail); + } + + //by webkul to show order details properly on order history page if (Module::isInstalled('hotelreservationsystem')) { @@ -457,6 +463,7 @@ class OrderDetailControllerCore extends FrontController 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'guestInformations' => (array)new Customer($order->id_customer), + 'customerGuestDetail' => $customerGuestDetail, 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 03d94e09d..2112ae0ba 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -483,10 +483,12 @@ class OrderOpcControllerCore extends ParentOrderController $this->_assignPayment(); // GUEST BOOKING if ($this->isLogged) { - if ($this->context->cart->id_customer_guest_detail) { - $this->context->smarty->assign('customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetail($this->context->cart->id_customer_guest_detail)); + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + $this->context->smarty->assign( + 'customer_guest_detail', CartCustomerGuestDetail::getCustomerGuestDetail($id_customer_guest_detail) + ); } - $this->context->smarty->assign('id_customer_guest_detail', $this->context->cart->id_customer_guest_detail); + $this->context->smarty->assign('id_customer_guest_detail', $id_customer_guest_detail); } Tools::safePostVars(); @@ -978,31 +980,44 @@ class OrderOpcControllerCore extends ParentOrderController public function submitCustomerGuestDetail() { - $customer_guest_detail = Tools::getValue('customer_guest_detail'); + $customerGuestDetail = Tools::getValue('customer_guest_detail'); $this->context->cookie->__set('customer_details_proceeded', 0); $this->context->cookie->checkedTOS = false; - if ($customer_guest_detail) { - if ($this->context->cart->id_customer_guest_detail) { - $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); + if ($customerGuestDetail) { + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + $objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail); } else { - $objCustomerGuestDetail = new CustomerGuestDetail(); + $objCustomerGuestDetail = new CartCustomerGuestDetail(); } - $customer_guest_detail_gender = Tools::getValue('customer_guest_detail_gender'); - $customer_guest_detail_firstname = Tools::getValue('customer_guest_detail_firstname'); - $customer_guest_detail_lastname = Tools::getValue('customer_guest_detail_lastname'); - $customer_guest_detail_email = Tools::getValue('customer_guest_detail_email'); - $customer_guest_detail_phone = Tools::getValue('customer_guest_detail_phone'); - $objCustomerGuestDetail->id_gender = $customer_guest_detail_gender; - $objCustomerGuestDetail->firstname = $customer_guest_detail_firstname; - $objCustomerGuestDetail->lastname = $customer_guest_detail_lastname; - $objCustomerGuestDetail->email = $customer_guest_detail_email; - $objCustomerGuestDetail->phone = $customer_guest_detail_phone; + + $customerGuestDetailGender = Tools::getValue('customer_guest_detail_gender'); + $customerGuestDetailFirstname = Tools::getValue('customer_guest_detail_firstname'); + $customerGuestDetailLastname = Tools::getValue('customer_guest_detail_lastname'); + $customerGuestDetailEmail = Tools::getValue('customer_guest_detail_email'); + $customerGuestDetailPhone = Tools::getValue('customer_guest_detail_phone'); + if (trim($customerGuestDetailGender) && Validate::isUnsignedInt($customerGuestDetailGender)) { + $objCustomerGuestDetail->id_gender = $customerGuestDetailGender; + } + if (trim($customerGuestDetailFirstname) && Validate::isName($customerGuestDetailFirstname)) { + $objCustomerGuestDetail->firstname = $customerGuestDetailFirstname; + } + if (trim($customerGuestDetailLastname) && Validate::isName($customerGuestDetailLastname)) { + $objCustomerGuestDetail->lastname = $customerGuestDetailLastname; + } + if (trim($customerGuestDetailEmail) && Validate::isEmail($customerGuestDetailEmail)) { + $objCustomerGuestDetail->email = $customerGuestDetailEmail; + } + if (trim($customerGuestDetailPhone) && Validate::isPhoneNumber($customerGuestDetailPhone)) { + $objCustomerGuestDetail->phone = $customerGuestDetailPhone; + } + $objCustomerGuestDetail->id_cart = $this->context->cart->id; $objCustomerGuestDetail->save(); - $this->context->cart->id_customer_guest_detail = $objCustomerGuestDetail->id; } else { - $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); - $objCustomerGuestDetail->delete(); - $this->context->cart->id_customer_guest_detail = false; + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + if (Validate::isLoadedObject($objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail))) { + $objCustomerGuestDetail->delete(); + } + } } $this->context->cart->save(); } diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 331237fe1..e6942a0bd 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -674,8 +674,8 @@ CREATE TABLE `PREFIX_customer_thread` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_order_customer_guest_detail` ( - `id_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, - `id_cart` int(10) unsigned NOT NULL, + `id_order_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, + `id_order` int(10) unsigned NOT NULL, `id_gender` int(10) unsigned NOT NULL, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, @@ -683,12 +683,12 @@ CREATE TABLE `PREFIX_order_customer_guest_detail` ( `phone` varchar(32) DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_customer_guest_detail`) + PRIMARY KEY (`id_order_customer_guest_detail`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_cart_customer_guest_detail` ( `id_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, - `id_order` int(10) unsigned NOT NULL, + `id_cart` int(10) unsigned NOT NULL, `id_gender` int(10) unsigned NOT NULL, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index bcfc6d8cd..3571a1205 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -93,23 +93,36 @@
    -
  • {l s='Customer Details'}

  • - {if isset($address_invoice->firstname) && $address_invoice->firstname} -
  • {l s='Name'}
    {$address_invoice->firstname|escape:'html':'UTF-8'} {$address_invoice->lastname|escape:'html':'UTF-8'}
  • - {/if} - {if isset($guestInformations['email']) && $guestInformations['email']} -
  • {l s='Email'}
    {$guestInformations['email']|escape:'html':'UTF-8'}
  • - {/if} - {if isset($address_invoice->phone_mobile) && $address_invoice->phone_mobile} -
  • {l s='Mobile Number'}
    {$address_invoice->phone_mobile|escape:'html':'UTF-8'}
  • - {/if} - {if isset($address_invoice->phone) && $address_invoice->phone} -
  • {l s='Phone Number'}
    {$address_invoice->phone|escape:'html':'UTF-8'}
  • +
  • {l s='Guest Details'}

  • + {if $customerGuestDetail} + {if isset($customerGuestDetail->firstname) && $customerGuestDetail->firstname} +
  • {l s='Name'}
    {$customerGuestDetail->firstname|escape:'html':'UTF-8'} {$customerGuestDetail->lastname|escape:'html':'UTF-8'}
  • + {/if} + {if isset($customerGuestDetail->email) && $customerGuestDetail->email} +
  • {l s='Email'}
    {$customerGuestDetail->email|escape:'html':'UTF-8'}
  • + {/if} + {if isset($customerGuestDetail->phone) && $customerGuestDetail->phone} +
  • {l s='Mobile Number'}
    {$customerGuestDetail->phone|escape:'html':'UTF-8'}
  • + {/if} + {else} + {if isset($address_invoice->firstname) && $address_invoice->firstname} +
  • {l s='Name'}
    {$address_invoice->firstname|escape:'html':'UTF-8'} {$address_invoice->lastname|escape:'html':'UTF-8'}
  • + {/if} + {if isset($guestInformations['email']) && $guestInformations['email']} +
  • {l s='Email'}
    {$guestInformations['email']|escape:'html':'UTF-8'}
  • + {/if} + {if isset($address_invoice->phone_mobile) && $address_invoice->phone_mobile} +
  • {l s='Mobile Number'}
    {$address_invoice->phone_mobile|escape:'html':'UTF-8'}
  • + {/if} + {if isset($address_invoice->phone) && $address_invoice->phone} +
  • {l s='Phone Number'}
    {$address_invoice->phone|escape:'html':'UTF-8'}
  • + {/if} {/if}
+ {$HOOK_ORDERDETAILDISPLAYED} {if !$is_guest}
{/if} From fba475f51c4ccfe2d56e7b4a9c2eabb4b8a2b662 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 26 Dec 2022 17:17:33 +0530 Subject: [PATCH 28/42] updated function definition and optimized code --- classes/PaymentModule.php | 2 +- classes/order/Order.php | 40 +++++++++------- classes/order/OrderHistory.php | 26 ++++------- classes/order/OrderInvoice.php | 2 +- classes/order/OrderPaymentDetail.php | 52 +++++++++------------ controllers/admin/AdminOrdersController.php | 2 +- pdf/invoice.payment-tab.tpl | 2 +- 7 files changed, 59 insertions(+), 67 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 32ef50981..9177ec927 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -388,7 +388,7 @@ abstract class PaymentModuleCore extends Module // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php // if ($order->total_paid != $order->total_paid_real) // We use number_format in order to compare two string - if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_) && $this->name != 'cheque') { + if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_) && $this->name != 'wsorder') { // if customer is paying full payment amount $id_order_state = Configuration::get('PS_OS_ERROR'); } diff --git a/classes/order/Order.php b/classes/order/Order.php index 2eccb6f19..5aac4cf00 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -1691,11 +1691,12 @@ class OrderCore extends ObjectModel { // if one of the order details use the tax computation method the display will be different return Db::getInstance()->getValue(' - SELECT od.`tax_computation_method` - FROM `'._DB_PREFIX_.'order_detail_tax` odt - LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = odt.`id_order_detail`) - WHERE od.`id_order` = '.(int)$this->id.' - AND od.`tax_computation_method` = '.(int)TaxCalculator::ONE_AFTER_ANOTHER_METHOD); + SELECT od.`tax_computation_method` + FROM `'._DB_PREFIX_.'order_detail_tax` odt + LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = odt.`id_order_detail`) + WHERE od.`id_order` = '.(int)$this->id.' + AND od.`tax_computation_method` = '.(int)TaxCalculator::ONE_AFTER_ANOTHER_METHOD + ); } /** @@ -1710,14 +1711,19 @@ class OrderCore extends ObjectModel return $order_payments; } - public function getOrderPaymentDetailCollection() + /** + * This method allows to get all Order Payment detail for the current order + * @since 1.5.0.1 + * @return array of OrderPaymentDetails + */ + public function getOrderPaymentDetail() { - $order_payments = new DbQuery(); - $order_payments->select('opd.`amount` as `real_paid_amount`, opd.*, op.*'); - $order_payments->from('order_payment_detail', 'opd'); - $order_payments->innerJoin('order_payment', 'op', 'opd.`id_order_payment` = op.`id_order_payment`'); - $order_payments->where('id_order = '.$this->id); - return Db::getInstance()->executeS($order_payments); + return Db::getInstance()->executeS(' + SELECT opd.`amount` as `real_paid_amount`, opd.*, op.* + FROM `'._DB_PREFIX_.'order_payment_detail` opd + INNER JOIN `'._DB_PREFIX_.'order_payment` op ON (opd.`id_order_payment` = op.`id_order_payment`) + WHERE `id_order` = '.$this->id + ); } /** @@ -1761,10 +1767,10 @@ class OrderCore extends ObjectModel return $res; } - public function addOrderPaymentDetail(OrderPayment $payment, $amount = false, $order_invoice = null) + public function addOrderPaymentDetail(OrderPayment $payment, $amount = null, $order_invoice = null) { if (Validate::isLoadedObject($payment)) { - if (!$amount) { + if (!is_null($amount)) { $amount = $payment->amount; } $order_payment_detail = new OrderPaymentDetail(); @@ -1772,10 +1778,10 @@ class OrderCore extends ObjectModel $order_payment_detail->id_order_payment = (int)$payment->id; $order_payment_detail->amount = $amount; - if ($lastOrderPayment->id_currency == $this->id_currency) { + if ($payment->id_currency == $this->id_currency) { $this->total_paid_real += $order_payment_detail->amount; } else { - $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment_detail->amount, $lastOrderPayment->id_currency, false), 2); + $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment_detail->amount, $payment->id_currency, false), 2); } if (!validate::isPrice($this->total_paid_real)) { @@ -1932,7 +1938,7 @@ class OrderCore extends ObjectModel $total = 0; // Retrieve all payments - $payments = $this->getOrderPaymentDetailCollection(); + $payments = $this->getOrderPaymentDetail(); foreach ($payments as $payment) { /** @var OrderPayment $payment */ if ($payment['id_currency'] == $currency->id) { diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index b2be62c84..de1abdf54 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -322,25 +322,19 @@ class OrderHistoryCore extends ObjectModel /** @var OrderInvoice $invoice */ $rest_paid = $invoice->getRestPaid(); if ($rest_paid > 0) { - $payment = new OrderPayment(); - $payment->order_reference = Tools::substr($order->reference, 0, 9); - $payment->id_currency = $order->id_currency; - $payment->amount = $rest_paid; - if ($order->total_paid != 0) { - $payment->payment_method = $payment_method->displayName; + $payment_method = $payment_method->displayName; } else { - $payment->payment_method = null; + $payment_method = null; } - - $payment->conversion_rate = ($order ? $order->conversion_rate : 1); - $payment->save(); - - $id_order_payment_detail = $order->addOrderPaymentDetail($payment); - - Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order_payment_detail`, `id_order`) - VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$id_order_payment_detail.', '.(int)$order->id.')'); + $order->addOrderPayment( + $rest_paid, + $payment_method, + null, + null, + null, + $invoice + ); } } } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 9f79fd793..0efdca2bb 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -880,7 +880,7 @@ class OrderInvoiceCore extends ObjectModel return OrderPayment::getByInvoiceId($this->id); } - public function getOrderPaymentDetailCollection() + public function getOrderPaymentDetail() { return OrderPaymentDetail::getByInvoiceId($this->id); } diff --git a/classes/order/OrderPaymentDetail.php b/classes/order/OrderPaymentDetail.php index b231efb4d..ddfb1b58a 100644 --- a/classes/order/OrderPaymentDetail.php +++ b/classes/order/OrderPaymentDetail.php @@ -1,6 +1,6 @@ 'id_order_payment_detail', 'fields' => array( 'id_order_payment' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isNegativePrice', 'required' => true), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isNegativePrice', 'required' => true), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - ), - 'associations' => array( - 'order_payment' => array('type' => self::HAS_ONE, 'table' => 'order_payment') ) ); + /** + * Get Order Payments By Order ID + * + * @param int $id_invoice Order ID + * @return array OrderPayment detail + */ public static function getByOrderId($id_order) { return Db::getInstance()->executeS(' - SELECT opd.*, op.`id_currency`, op.`payment_method`, op.`conversion_rate`, op.`transaction_id`, op.`card_number`, op.`card_brand`, op.`card_expiration`, op.`card_holder` - FROM `'._DB_PREFIX_.'order_payment_detail` opd - INNER JOIN `'._DB_PREFIX_.'order_payment`op ON (op.`id_order_payment` = opd.`id_order_payment`) - WHERE `id_order` = '.(int)$id_order); + SELECT opd.*, op.`id_currency`, op.`payment_method`, op.`conversion_rate`, op.`transaction_id`, op.`card_number`, op.`card_brand`, op.`card_expiration`, op.`card_holder` + FROM `'._DB_PREFIX_.'order_payment_detail` opd + INNER JOIN `'._DB_PREFIX_.'order_payment`op ON (op.`id_order_payment` = opd.`id_order_payment`) + WHERE `id_order` = '.(int)$id_order + ); } /** * Get Order Payments By Invoice ID * * @param int $id_invoice Invoice ID - * @return PrestaShopCollection Collection of OrderPayment + * @return array OrderPayment detail */ public static function getByInvoiceId($id_invoice) { - $payments = Db::getInstance()->executeS('SELECT id_order_payment_detail FROM `'._DB_PREFIX_.'order_invoice_payment` WHERE id_order_invoice = '.(int)$id_invoice); - if (!$payments) { - return array(); - } - - $payment_list = array(); - foreach ($payments as $payment) { - $payment_list[] = $payment['id_order_payment_detail']; - } - $order_payments = new DbQuery(); - $order_payments->select('opd.*, op.*, opd.`amount` as `amount`'); - $order_payments->from('order_payment_detail', 'opd'); - $order_payments->innerJoin('order_payment', 'op', 'opd.`id_order_payment` = op.`id_order_payment`'); - $order_payments->where('id_order_payment_detail IN ('.pSQL(implode(', ', $payment_list)).')'); - return Db::getInstance()->executeS($order_payments); - // $payments = new PrestaShopCollection('OrderPaymentDetail'); - // $payments->join('order_payment', 'id_order_payment'); - // $payments->where('id_order_payment_detail', 'IN', $payment_list); - // ddd($payments->getAll()); + return Db::getInstance()->executeS(' + SELECT opd.`id_order_payment_detail`, opd.`id_order_payment`, opd.`id_order`, opd.`date_add`, op.*, opd.`amount` as `amount` + FROM `'._DB_PREFIX_.'order_payment_detail` opd + INNER JOIN `'._DB_PREFIX_.'order_payment` op ON (opd.`id_order_payment` = op.`id_order_payment`) + INNER JOIN `'._DB_PREFIX_.'order_invoice_payment` oip ON (oip.`id_order_payment_detail` = opd.`id_order_payment_detail`) + WHERE oip.`id_order_invoice` = '.(int)$id_invoice + ); } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b4a736162..b36d5eb58 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1419,7 +1419,7 @@ class AdminOrdersControllerCore extends AdminController $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } - $order_payment_detail = $order->getOrderPaymentDetailCollection(); + $order_payment_detail = $order->getOrderPaymentDetail(); foreach ($order_payment_detail as &$payment_detail) { $payment = new OrderPayment($payment_detail['id_order_payment']); if ($invoice = $payment->getOrderInvoice($order->id)) { diff --git a/pdf/invoice.payment-tab.tpl b/pdf/invoice.payment-tab.tpl index a80c0e91e..f7c9e2af2 100644 --- a/pdf/invoice.payment-tab.tpl +++ b/pdf/invoice.payment-tab.tpl @@ -27,7 +27,7 @@ {l s='Payment Method' pdf='true'} - {foreach from=$order_invoice->getOrderPaymentDetailCollection() item=payment} + {foreach from=$order_invoice->getOrderPaymentDetail() item=payment} From 8b5cb104e732015d47915b4b5e7846c5085880fb Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 26 Dec 2022 18:49:30 +0530 Subject: [PATCH 29/42] Change variables from wk_id_guest, wk_id_cart to id_guest and id_cart --- controllers/admin/AdminOrdersController.php | 8 +- .../AdminHotelRoomsBookingController.php | 76 ++++++++----------- 2 files changed, 36 insertions(+), 48 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bf5d787c0..4b823a0b3 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -865,11 +865,11 @@ class AdminOrdersControllerCore extends AdminController $cart->secure_key ); - if (isset($this->context->cookie->wk_id_cart)) { - unset($this->context->cookie->wk_id_cart); + if (isset($this->context->cookie->id_cart)) { + unset($this->context->cookie->id_cart); } - if (isset($this->context->cookie->wk_id_guest)) { - unset($this->context->cookie->wk_id_guest); + if (isset($this->context->cookie->id_guest)) { + unset($this->context->cookie->id_guest); } if ($payment_module->currentOrder) { diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 9a3a79eca..3bf8aa64d 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -35,58 +35,46 @@ class AdminHotelRoomsBookingController extends ModuleAdminController public function setPhpCookieData() { - if (!isset($this->context->cookie->wk_id_guest) || !$this->context->cookie->wk_id_guest) { - if (!isset($this->context->cookie->id_guest)) { - Guest::setNewGuest($this->context->cookie); - } - - $this->context->cookie->wk_id_guest = $this->context->cookie->id_guest; - } else { - $this->context->cookie->id_guest = $this->context->cookie->wk_id_guest; + if (!isset($this->context->cookie->id_guest)) { + Guest::setNewGuest($this->context->cookie); } - if (!isset($this->context->cookie->wk_id_cart) && !isset($this->context->cart->id)) { - $cart = new Cart(); + if (!isset($this->context->cookie->id_cart)) { + // create a new cart + $objCart = new Cart(); + $objCart->recyclable = 0; + $objCart->gift = 0; + $objCart->id_shop = (int) $this->context->shop->id; + $objCart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT')); + $objCart->id_currency = (($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT')); + $objCart->id_address_delivery = 0; + $objCart->id_address_invoice = 0; + $objCart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT'); + $objCart->id_guest = (int) $this->context->cookie->id_guest; + $objCart->setNoMultishipping(); - $cart->recyclable = 0; - $cart->gift = 0; - $cart->id_shop = (int)$this->context->shop->id; - $cart->id_lang = (($id_lang = (int)Tools::getValue('id_lang')) ? $id_lang : Configuration::get('PS_LANG_DEFAULT')); - $cart->id_currency = (($id_currency = (int)Tools::getValue('id_currency')) ? $id_currency : Configuration::get('PS_CURRENCY_DEFAULT')); - $cart->id_address_delivery = 0; - $cart->id_address_invoice = 0; - $cart->id_currency = Configuration::get('PS_CURRENCY_DEFAULT'); - $cart->id_guest = (int)$this->context->cookie->id_guest; - $cart->setNoMultishipping(); - $cart->save(); + $this->context->cart = $objCart; + $this->context->cart->save(); - $this->context->cart = $cart; - $this->context->cookie->id_cart = $cart->id; - - $this->context->cookie->wk_id_cart = $cart->id; + $this->context->cookie->id_cart = (int) $objCart->id; } else { - $cart = new Cart((int) $this->context->cookie->wk_id_cart); - - $this->context->cart = $cart; - $this->context->cookie->id_cart = $cart->id; - $this->context->cookie->wk_id_cart = $cart->id; + // use previous cart + $this->context->cart = new Cart($this->context->cookie->id_cart); } - $customer = new Customer(); - $customer->id_gender = 0; - $customer->id_default_group = 1; - $customer->outstanding_allow_amount = 0; - $customer->show_public_prices = 0; - $customer->max_payment_days = 0; - $customer->active = 1; - $customer->is_guest = 0; - $customer->deleted = 0; - $customer->logged = 0; - $customer->id_guest = $this->context->cookie->id_guest; + $objCustomer = new Customer(); + $objCustomer->id_gender = 0; + $objCustomer->id_default_group = 1; + $objCustomer->outstanding_allow_amount = 0; + $objCustomer->show_public_prices = 0; + $objCustomer->max_payment_days = 0; + $objCustomer->active = 1; + $objCustomer->is_guest = 0; + $objCustomer->deleted = 0; + $objCustomer->logged = 0; + $objCustomer->id_guest = (int) $this->context->cookie->id_guest; - $this->context->customer = $customer; - - return true; + $this->context->customer = $objCustomer; } public function initContent() From 8d3a5b7be479a08e30320d6c26863178bd7b7bbc Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 26 Dec 2022 18:56:32 +0530 Subject: [PATCH 30/42] Required changes in HotelBookingDetail.php --- modules/hotelreservationsystem/classes/HotelBookingDetail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 6e8f3c505..8cf22b76b 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -980,8 +980,8 @@ class HotelBookingDetail extends ObjectModel public function getAvailableRoomsForReallocation($date_from, $date_to, $room_type, $hotel_id) { $context = Context::getContext(); - if (isset($context->cookie->wk_id_cart)) { - $current_admin_cart_id = $context->cookie->wk_id_cart; + if (isset($context->cookie->id_cart)) { + $current_admin_cart_id = $context->cookie->id_cart; } $exclude_ids = 'SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `date_from` < \''.pSQL($date_to).'\' AND `date_to` > \''.pSQL($date_from).'\' From d611cf4852669236005aaf44f05ede6574776c2c Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 27 Dec 2022 12:27:47 +0530 Subject: [PATCH 31/42] Fix undefined variable issue on dashboard --- modules/dashoccupancy/dashoccupancy.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/dashoccupancy/dashoccupancy.php b/modules/dashoccupancy/dashoccupancy.php index b99b30385..97bb2ce6a 100644 --- a/modules/dashoccupancy/dashoccupancy.php +++ b/modules/dashoccupancy/dashoccupancy.php @@ -59,19 +59,6 @@ class DashOccupancy extends Module public function hookDashboardZoneOne($params) { - $occupancyData = AdminStatsController::getOccupancyData( - $params['date_from'], - $params['date_to'], - $params['id_hotel'] - ); - - $this->context->smarty->assign(array( - 'count_total' => sprintf('%02d', $occupancyData['count_total']), - 'count_occupied' => sprintf('%02d', $occupancyData['count_occupied']), - 'count_available' => sprintf('%02d', $occupancyData['count_available']), - 'count_unavailable' => sprintf('%02d', $occupancyData['count_unavailable']), - )); - return $this->display(__FILE__, 'dashboard_zone_one.tpl'); } From 7fa69f84adb76d3e5856dfa7e1aa2454e47a1bb8 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 27 Dec 2022 12:57:15 +0530 Subject: [PATCH 32/42] Update checkout date on order view page --- .../default/template/controllers/orders/helpers/view/view.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index ea80d46a9..0dc8d3b2f 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -312,7 +312,7 @@ {/if} {* field for the current date *} - + From 07159b68e86d2c545163c35d91ed143e1204d159 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 27 Dec 2022 15:02:55 +0530 Subject: [PATCH 33/42] fixed logo height issue --- controllers/admin/AdminThemesController.php | 4 ++-- themes/hotel-reservation-theme/css/global.css | 3 +-- themes/hotel-reservation-theme/header.tpl | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index 2d5923acb..98619dedd 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -144,7 +144,7 @@ class AdminThemesControllerCore extends AdminController 'fields' => array( 'PS_LOGO' => array( 'title' => $this->l('Header logo'), - 'hint' => $this->l('Will appear on main page. Recommended height: 52px. Maximum height on default theme: 65px.'), + 'hint' => $this->l('Will appear on header of website. Maximum height on default theme: 60px.'), 'type' => 'file', 'name' => 'PS_LOGO', 'tab' => 'logo', @@ -153,7 +153,7 @@ class AdminThemesControllerCore extends AdminController 'PS_LOGO_MOBILE' => array( 'title' => $this->l('Header logo for mobile'), 'desc' => ((Configuration::get('PS_LOGO_MOBILE') === false) ? ''.$this->l('Warning: No mobile logo has been defined. The header logo will be used instead.').'
' : ''), - 'hint' => $this->l('Will appear on the main page of your mobile template. If left undefined, the header logo will be used.'), + 'hint' => $this->l('Will appear on the header of your mobile template. If left undefined, the header logo will be used.'), 'type' => 'file', 'name' => 'PS_LOGO_MOBILE', 'tab' => 'mobile', diff --git a/themes/hotel-reservation-theme/css/global.css b/themes/hotel-reservation-theme/css/global.css index a905169a8..845560a7e 100644 --- a/themes/hotel-reservation-theme/css/global.css +++ b/themes/hotel-reservation-theme/css/global.css @@ -5818,8 +5818,7 @@ header { header .row #header_logo { padding: 10px 0; } header .row #header_logo img { - max-width: 120px; - max-height: 120px; } + max-height: 60px; } header .header-top > div > div > div .header-top-menu { display: flex; flex-direction: row-reverse; diff --git a/themes/hotel-reservation-theme/header.tpl b/themes/hotel-reservation-theme/header.tpl index b19aa1f10..04608afdc 100644 --- a/themes/hotel-reservation-theme/header.tpl +++ b/themes/hotel-reservation-theme/header.tpl @@ -105,7 +105,7 @@
From d3d54059c38766083e39d6414c4591e75b2ad399 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 27 Dec 2022 17:16:43 +0530 Subject: [PATCH 34/42] Show updated helpful count when marking a review helpful --- modules/qlohotelreview/classes/QhrHotelReview.php | 9 +++++++++ modules/qlohotelreview/controllers/front/default.php | 2 ++ modules/qlohotelreview/views/js/front/review-list.js | 3 ++- .../helpers/view/_partials/review.tpl | 6 +++++- .../views/templates/hook/_partials/review.tpl | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/qlohotelreview/classes/QhrHotelReview.php b/modules/qlohotelreview/classes/QhrHotelReview.php index 92602bdac..39bc9a262 100644 --- a/modules/qlohotelreview/classes/QhrHotelReview.php +++ b/modules/qlohotelreview/classes/QhrHotelReview.php @@ -244,6 +244,15 @@ class QhrHotelReview extends ObjectModel ); } + public function getTotalUseful() + { + return (int) Db::getInstance()->getValue( + 'SELECT COUNT(*) + FROM `'._DB_PREFIX_.'qhr_review_usefulness` ru + WHERE ru.`id_hotel_review` = '.(int) $this->id_hotel_review + ); + } + public function getTotalReports() { $sql = new DbQuery(); diff --git a/modules/qlohotelreview/controllers/front/default.php b/modules/qlohotelreview/controllers/front/default.php index e1cfecb53..fe6e6f2eb 100644 --- a/modules/qlohotelreview/controllers/front/default.php +++ b/modules/qlohotelreview/controllers/front/default.php @@ -139,6 +139,8 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController if (QhrHotelReview::markHelpful($idHotelReview, $this->context->cookie->id_customer)) { $response['status'] = true; + $objHotelReview = new QhrHotelReview($idHotelReview); + $response['count_useful'] = $objHotelReview->getTotalUseful(); $this->ajaxDie(json_encode($response)); } } diff --git a/modules/qlohotelreview/views/js/front/review-list.js b/modules/qlohotelreview/views/js/front/review-list.js index 5b26ab468..8e67eea04 100644 --- a/modules/qlohotelreview/views/js/front/review-list.js +++ b/modules/qlohotelreview/views/js/front/review-list.js @@ -36,9 +36,10 @@ var QhrReview = { headers: { 'cache-control': 'no-cache' }, success: function(response) { if (response.status == true) { + $(btnHelpful).closest('.review').find('.helpful-count span').html(response.count_useful); $(btnHelpful).fadeOut('slow', function() { $(btnHelpful).remove(); - }) + }); } } }); diff --git a/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl b/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl index 57e88a071..114f895d3 100644 --- a/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl +++ b/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl @@ -124,7 +124,11 @@

- {$total_reports|escape:'html':'UTF-8'} + {if $total_reports|intval > 0} + {$total_reports|escape:'html':'UTF-8'} + {else} + -- + {/if}

{if $total_reports|intval > 0}

diff --git a/modules/qlohotelreview/views/templates/hook/_partials/review.tpl b/modules/qlohotelreview/views/templates/hook/_partials/review.tpl index 5362b70b5..5444ec30f 100644 --- a/modules/qlohotelreview/views/templates/hook/_partials/review.tpl +++ b/modules/qlohotelreview/views/templates/hook/_partials/review.tpl @@ -51,7 +51,7 @@ {/if} -

{l s='%1$d people found it helpful.' sprintf=[$review.total_useful] mod='qlohotelreview'}

+

{$review.total_useful|escape:'html':'UTF-8'}{l s=' people found it helpful.' mod='qlohotelreview'}

{if $logged && !$review.response_report}
From 3d523bf18f4aa7da549ca5de22aa7d9444020b1a Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 27 Dec 2022 22:06:46 +0530 Subject: [PATCH 35/42] Code optimization --- controllers/admin/AdminCartsController.php | 2 +- controllers/admin/AdminOrdersController.php | 4 +- .../classes/HotelBookingDetail.php | 61 ++++-------- .../classes/HotelCartBookingData.php | 98 ++++++------------- 4 files changed, 50 insertions(+), 115 deletions(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 5f5b3b82c..85039d866 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -592,7 +592,7 @@ class AdminCartsControllerCore extends AdminController $id_cart = Tools::getValue('id_cart');//get cart id from url $cart_detail_data = array(); $cart_detail_data_obj = new HotelCartBookingData(); - $update_htl_cart_currency = $cart_detail_data_obj->updateIdCurrencyByIdCart($id_cart, $currency->id); + $cart_detail_data_obj->updateIdCurrencyByIdCart($id_cart, $currency->id); $cart_detail_data = $cart_detail_data_obj->getCartFormatedBookinInfoByIdCart((int) $id_cart); $this->context->smarty->assign(array( 'cart_detail_data' => $cart_detail_data, diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index a67a16cdc..c28fe337e 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -460,7 +460,7 @@ class AdminOrdersControllerCore extends AdminController if (!$room_swapped) { $this->errors[] = Tools::displayError('Some error occured. Please try again.'); } else { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token.'&conf=4'); + Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token); } } } else { @@ -495,7 +495,7 @@ class AdminOrdersControllerCore extends AdminController if (!$room_swapped) { $this->errors[] = Tools::displayError('Some error occured. Please try again.'); } else { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token.'&conf=4'); + Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $order_id.'&vieworder&token='.$this->token); } } } else { diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 0fbf5b226..650ccb3e9 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1758,12 +1758,8 @@ class HotelBookingDetail extends ObjectModel if (is_array($bookingsCartData) && count($bookingsCartData)) { foreach ($bookingsData as $bookingCartData) { $objHotelCartBookingData = new HotelCartBookingData($bookingCartData['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -1772,12 +1768,8 @@ class HotelBookingDetail extends ObjectModel if (is_array($bookingsData) && count($bookingsData)) { foreach ($bookingsData as $bookingData) { $objHotelBookingDetail = new self($bookingData['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; - } - - if (!$objHotelBookingDetail->delete()) { - return false; + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $objHotelBookingDetail->delete(); } } } @@ -1797,12 +1789,8 @@ class HotelBookingDetail extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -1817,12 +1805,8 @@ class HotelBookingDetail extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelBookingDetail = new self($row['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; - } - - if (!$objHotelBookingDetail->delete()) { - return false; + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $objHotelBookingDetail->delete(); } } } @@ -1841,12 +1825,8 @@ class HotelBookingDetail extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -1860,12 +1840,8 @@ class HotelBookingDetail extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelBookingDetail = new self($row['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; - } - - if (!$objHotelBookingDetail->delete()) { - return false; + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $objHotelBookingDetail->delete(); } } } @@ -1970,19 +1946,16 @@ class HotelBookingDetail extends ObjectModel if ($orderDetail->save()) { $bookingsData = self::getOrderInfoIdOrderIdProduct($id_order, $id_product); if (is_array($bookingsData) && count($bookingsData)) { + $result = true; foreach ($bookingsData as $bookingData) { $objHotelBookingDetail = new self($bookingData['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; - } - - $objHotelBookingDetail->id_order_detail = $orderDetail->id_order_detail; - if (!$objHotelBookingDetail->save()) { - return false; + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $objHotelBookingDetail->id_order_detail = $orderDetail->id_order_detail; + $result &= $objHotelBookingDetail->save(); } } - return true; + return $result; } } } diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 50a7a2d4f..e28b9937b 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -225,11 +225,12 @@ class HotelCartBookingData extends ObjectModel public function deleteRowById($id) { $objHotelCartBookingData = new self($id); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); + return true; } - return $objHotelCartBookingData->delete(); + return false; } /** @@ -294,25 +295,6 @@ class HotelCartBookingData extends ObjectModel */ public function changeProductDataByRoomId($idRoom, $idProduct, $daysDiff, $idCart) { - $result = Db::getInstance()->executeS( - 'SELECT `id` - FROM `'._DB_PREFIX_.'htl_cart_booking_data` - WHERE `id_room` = '.(int) $idRoom.' AND `id_cart` = '.(int) $idCart - ); - - if (is_array($result) && count($result)) { - foreach ($result as $row) { - $objHotelCartBookingData = new self($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; - } - } - } - $cartProductQuantity = Db::getInstance()->getValue('SELECT `quantity` FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart`='.$idCart.' AND `id_product`='.$idProduct); $newQuantity = $cartProductQuantity - $daysDiff; @@ -415,12 +397,8 @@ class HotelCartBookingData extends ObjectModel // delete rows from table foreach ($cartBookingInfo as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -467,12 +445,8 @@ class HotelCartBookingData extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -508,12 +482,8 @@ class HotelCartBookingData extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -613,12 +583,8 @@ class HotelCartBookingData extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } @@ -661,20 +627,19 @@ class HotelCartBookingData extends ObjectModel ); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } + if (Validate::isLoadedObject($objHotelCartBookingData)) { + foreach ($updData as $key => $value) { + $objHotelCartBookingData->$key = $value; + } - foreach ($updData as $key => $value) { - $objHotelCartBookingData->$key = $value; - } - - if (!$objHotelCartBookingData->save()) { - return false; + $return &= $objHotelCartBookingData->save(); } } + + return $return; } return true; @@ -796,18 +761,19 @@ class HotelCartBookingData extends ObjectModel ); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - $objHotelCartBookingData->id_currency = $id_currency; - if (!$objHotelCartBookingData->save()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->id_currency = $id_currency; + $return &= $objHotelCartBookingData->save(); } } + + return $return; } + + return true; } /** @@ -831,12 +797,8 @@ class HotelCartBookingData extends ObjectModel if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->delete(); } } } From db67ea8b740684c8ec1bda0c85019c03a5b53506 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 28 Dec 2022 16:53:41 +0530 Subject: [PATCH 36/42] updated traveller details block --- .../default/template/controllers/orders/helpers/view/view.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 3291b4477..c51a0fea6 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -710,7 +710,7 @@ {if $customerGuestDetail}
- {l s='Guest'} + {l s='Traveller detail'}
{l s='Name'}
From 1d55a32db5f936c16e6be35d213ba57dcca96c8d Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 3 Jan 2023 17:01:51 +0530 Subject: [PATCH 37/42] Code optimizations --- .../classes/HotelBookingDetail.php | 243 +++++++++--------- .../classes/HotelCartBookingData.php | 37 ++- 2 files changed, 142 insertions(+), 138 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 650ccb3e9..c5c34ae8d 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -797,29 +797,29 @@ class HotelBookingDetail extends ObjectModel $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo); $objHotelBookingDetail = new self($roomBookingData['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; + if (Validate::isLoadedObject($objHotelBookingDetail)) { + if ($statusDate) { + $statusDate = date('Y-m-d H:i:s', strtotime($statusDate)); + } else { + $statusDate = date('Y-m-d H:i:s'); + } + + if ($newStatus == self::STATUS_CHECKED_IN) { + $objHotelBookingDetail->id_status = $newStatus; + $objHotelBookingDetail->check_in = ($statusDate > $dateTo ? $dateTo : $statusDate); + } elseif ($newStatus == self::STATUS_CHECKED_OUT) { + $objHotelBookingDetail->id_status = $newStatus; + $objHotelBookingDetail->check_out = ($statusDate > $dateTo ? $dateTo : $statusDate); + } else { + $objHotelBookingDetail->id_status = $newStatus; + $objHotelBookingDetail->check_in = ''; + $objHotelBookingDetail->check_out = ''; + } + + return $objHotelBookingDetail->save(); } - if ($statusDate) { - $statusDate = date('Y-m-d H:i:s', strtotime($statusDate)); - } else { - $statusDate = date('Y-m-d H:i:s'); - } - - if ($newStatus == self::STATUS_CHECKED_IN) { - $objHotelBookingDetail->id_status = $newStatus; - $objHotelBookingDetail->check_in = ($statusDate > $dateTo ? $dateTo : $statusDate); - } elseif ($newStatus == self::STATUS_CHECKED_OUT) { - $objHotelBookingDetail->id_status = $newStatus; - $objHotelBookingDetail->check_out = ($statusDate > $dateTo ? $dateTo : $statusDate); - } else { - $objHotelBookingDetail->id_status = $newStatus; - $objHotelBookingDetail->check_in = ''; - $objHotelBookingDetail->check_out = ''; - } - - return $objHotelBookingDetail->save(); + return false; } /** @@ -1059,34 +1059,30 @@ class HotelBookingDetail extends ObjectModel if ($idHotelCartBookingData) { $objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->id_room = $swappedRoomId; + if ($objHotelCartBookingData->save()) { + $objHotelRoomInformation = new HotelRoomInformation($swappedRoomId); - $objHotelCartBookingData->id_room = $swappedRoomId; - if ($objHotelCartBookingData->save()) { - $objHotelRoomInformation = new HotelRoomInformation($swappedRoomId); + $roomBookingData = $this->getRoomBookingData($currentRoomId, $objHotelCartBookingData->id_order, $dateFrom, $dateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $objHotelBookingDetail->id_room = $swappedRoomId; + $objHotelBookingDetail->room_num = $objHotelRoomInformation->room_num; + if ($objHotelBookingDetail->save()) { + Hook::exec( + 'actionRoomReAllocateAfter', + array( + 'room_id' => $currentRoomId, + 'realloc_room_id' => $swappedRoomId, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, + ) + ); - $roomBookingData = $this->getRoomBookingData($currentRoomId, $objHotelCartBookingData->id_order, $dateFrom, $dateTo); - $objHotelBookingDetail = new self($roomBookingData['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; - } - - $objHotelBookingDetail->id_room = $swappedRoomId; - $objHotelBookingDetail->room_num = $objHotelRoomInformation->room_num; - if ($objHotelBookingDetail->save()) { - Hook::exec( - 'actionRoomReAllocateAfter', - array( - 'room_id' => $currentRoomId, - 'realloc_room_id' => $swappedRoomId, - 'date_from' => $dateFrom, - 'date_to' => $dateTo, - ) - ); - - return true; + return true; + } + } } } } @@ -1239,11 +1235,11 @@ class HotelBookingDetail extends ObjectModel $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo); $objHotelBookingDetail = new self($roomBookingData['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; + if (Validate::isLoadedObject($objHotelBookingDetail)) { + return $objHotelBookingDetail->delete(); } - return $objHotelBookingDetail->delete(); + return false; } public function getRoomBookinInformationForDateRangeByOrder( @@ -1273,75 +1269,71 @@ class HotelBookingDetail extends ObjectModel // retrieve HotelBookingDetail row $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $oldDateFrom, $oldDateTo); $objHotelBookingDetail = new self($roomBookingData['id']); - if (!Validate::isLoadedObject($objHotelBookingDetail)) { - return false; - } + if (Validate::isLoadedObject($objHotelBookingDetail)) { + // retrieve HotelCartBookingData row + $idHotelCartBookingData = Db::getInstance()->getValue( + 'SELECT `id` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` + WHERE date_from = "'.pSQL($oldDateFrom).'" AND date_to = "'.pSQL($oldDateTo).'" + AND id_room = '.(int) $idRoom.' AND `id_order` = '.(int) $idOrder + ); - // retrieve HotelCartBookingData row - $idHotelCartBookingData = Db::getInstance()->getValue( - 'SELECT `id` - FROM `'._DB_PREFIX_.'htl_cart_booking_data` - WHERE date_from = "'.pSQL($oldDateFrom).'" AND date_to = "'.pSQL($oldDateTo).'" - AND id_room = '.(int) $idRoom.' AND `id_order` = '.(int) $idOrder - ); + $objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + // calculate new prices + $newTotalPriceTE = ''; + $newTotalPriceTI = ''; + $newNumDays = $this->getNumberOfDays($newDateFrom, $newDateTo); + if ($newTotalPrice) { + $newTotalPriceTE = $newTotalPrice['tax_excl']; + $newTotalPriceTI = $newTotalPrice['tax_incl']; + } else { + $oldNumDays = $this->getNumberOfDays($oldDateFrom, $oldDateTo); + $unitRoomPriceTE = $objHotelBookingDetail->total_price_tax_excl / $oldNumDays; + $unitRoomPriceTI = $objHotelBookingDetail->total_price_tax_incl / $oldNumDays; + $newTotalPriceTE = $unitRoomPriceTE * $newNumDays; + $newTotalPriceTI = $unitRoomPriceTI * $newNumDays; + } - $objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - // calculate new prices - $newTotalPriceTE = ''; - $newTotalPriceTI = ''; - $newNumDays = $this->getNumberOfDays($newDateFrom, $newDateTo); - if ($newTotalPrice) { - $newTotalPriceTE = $newTotalPrice['tax_excl']; - $newTotalPriceTI = $newTotalPrice['tax_incl']; - } else { - $oldNumDays = $this->getNumberOfDays($oldDateFrom, $oldDateTo); - $unitRoomPriceTE = $objHotelBookingDetail->total_price_tax_excl / $oldNumDays; - $unitRoomPriceTI = $objHotelBookingDetail->total_price_tax_incl / $oldNumDays; - $newTotalPriceTE = $unitRoomPriceTE * $newNumDays; - $newTotalPriceTI = $unitRoomPriceTI * $newNumDays; - } - - // calculate `total_paid_amount` - $totalPaidAmount = 0; - $isAdvancePayment = Db::getInstance()->getValue( - 'SELECT o.`is_advance_payment` - FROM `'._DB_PREFIX_.'orders` o - WHERE o.`id_order` = '.(int) $idOrder - ); - - if ($isAdvancePayment) { - $objHotelAdvancedPayment = new HotelAdvancedPayment(); - $productAdvancePayment = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($objHotelBookingDetail->id_product); - - if (!$productAdvancePayment || (isset($productAdvancePayment['payment_type']) && $productAdvancePayment['payment_type'])) { - $totalPaidAmount = $objHotelAdvancedPayment->getRoomMinAdvPaymentAmount( - $objHotelBookingDetail->id_product, - $newDateFrom, - $newDateTo + // calculate `total_paid_amount` + $totalPaidAmount = 0; + $isAdvancePayment = Db::getInstance()->getValue( + 'SELECT o.`is_advance_payment` + FROM `'._DB_PREFIX_.'orders` o + WHERE o.`id_order` = '.(int) $idOrder ); + + if ($isAdvancePayment) { + $objHotelAdvancedPayment = new HotelAdvancedPayment(); + $productAdvancePayment = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($objHotelBookingDetail->id_product); + + if (!$productAdvancePayment || (isset($productAdvancePayment['payment_type']) && $productAdvancePayment['payment_type'])) { + $totalPaidAmount = $objHotelAdvancedPayment->getRoomMinAdvPaymentAmount( + $objHotelBookingDetail->id_product, + $newDateFrom, + $newDateTo + ); + } + } else { + $totalPaidAmount = $newTotalPriceTI; + } + + // update $objHotelCartBookingData + $objHotelCartBookingData->date_from = $newDateFrom; + $objHotelCartBookingData->date_to = $newDateTo; + $objHotelCartBookingData->quantity = $newNumDays; + + // update $objHotelBookingDetail + $objHotelBookingDetail->date_from = $newDateFrom; + $objHotelBookingDetail->date_to = $newDateTo; + $objHotelBookingDetail->total_price_tax_excl = Tools::ps_round($newTotalPriceTE, 6); + $objHotelBookingDetail->total_price_tax_incl = Tools::ps_round($newTotalPriceTI, 6); + $objHotelBookingDetail->total_paid_amount = Tools::ps_round($totalPaidAmount, 6); + + if ($objHotelCartBookingData->save() && $objHotelBookingDetail->save()) { + return true; + } } - } else { - $totalPaidAmount = $newTotalPriceTI; - } - - // update $objHotelCartBookingData - $objHotelCartBookingData->date_from = $newDateFrom; - $objHotelCartBookingData->date_to = $newDateTo; - $objHotelCartBookingData->quantity = $newNumDays; - - // update $objHotelBookingDetail - $objHotelBookingDetail->date_from = $newDateFrom; - $objHotelBookingDetail->date_to = $newDateTo; - $objHotelBookingDetail->total_price_tax_excl = Tools::ps_round($newTotalPriceTE, 6); - $objHotelBookingDetail->total_price_tax_incl = Tools::ps_round($newTotalPriceTI, 6); - $objHotelBookingDetail->total_paid_amount = Tools::ps_round($totalPaidAmount, 6); - - if ($objHotelCartBookingData->save() && $objHotelBookingDetail->save()) { - return true; } return false; @@ -1753,13 +1745,14 @@ class HotelBookingDetail extends ObjectModel public function deleteHotelOrderInfo($idOrder) { + $result = true; $objHotelCartBookingData = new HotelCartBookingData(); $bookingsCartData = $objHotelCartBookingData->getCartCurrentDataByOrderId($idOrder); if (is_array($bookingsCartData) && count($bookingsCartData)) { foreach ($bookingsData as $bookingCartData) { $objHotelCartBookingData = new HotelCartBookingData($bookingCartData['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $result &= $objHotelCartBookingData->delete(); } } } @@ -1769,12 +1762,12 @@ class HotelBookingDetail extends ObjectModel foreach ($bookingsData as $bookingData) { $objHotelBookingDetail = new self($bookingData['id']); if (Validate::isLoadedObject($objHotelBookingDetail)) { - $objHotelBookingDetail->delete(); + $result &= $objHotelBookingDetail->delete(); } } } - return true; + return $result; } public function deleteHotelOrderRoomInfo($idOrder, $idProduct, $idRoom) @@ -1786,11 +1779,12 @@ class HotelBookingDetail extends ObjectModel AND `id_room` = '.(int) $idRoom ); + $return = true; if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $return &= $objHotelCartBookingData->delete(); } } } @@ -1806,12 +1800,12 @@ class HotelBookingDetail extends ObjectModel foreach ($result as $row) { $objHotelBookingDetail = new self($row['id']); if (Validate::isLoadedObject($objHotelBookingDetail)) { - $objHotelBookingDetail->delete(); + $return &= $objHotelBookingDetail->delete(); } } } - return true; + return $return; } public function deleteHotelOrderRoomTypeInfo($idOrder, $idProduct) @@ -1822,11 +1816,12 @@ class HotelBookingDetail extends ObjectModel WHERE `id_order` = '.(int) $idOrder.' AND `id_product` = '.(int) $idProduct ); + $return = true; if (is_array($result) && count($result)) { foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $return &= $objHotelCartBookingData->delete(); } } } @@ -1841,12 +1836,12 @@ class HotelBookingDetail extends ObjectModel foreach ($result as $row) { $objHotelBookingDetail = new self($row['id']); if (Validate::isLoadedObject($objHotelBookingDetail)) { - $objHotelBookingDetail->delete(); + $return &= $objHotelBookingDetail->delete(); } } } - return true; + return $return; } public function enterHotelOrderBookingFormCartBookingData($id_cart) diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index e28b9937b..83cd903ef 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -443,15 +443,18 @@ class HotelCartBookingData extends ObjectModel { $result = $this->getHotelCartRoomsInfoByRoomType($idCart, $idProduct, $dateFrom, $dateTo); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $return &= $objHotelCartBookingData->delete(); } } + + return $return; } - return true; + return false; } /** @@ -480,15 +483,16 @@ class HotelCartBookingData extends ObjectModel $update_quantity = $this->context->cart->updateQty($qty, $id_product, null, false, 'down'); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $return &= $objHotelCartBookingData->delete(); } } } - return true; + return $return; } return false; @@ -510,19 +514,18 @@ class HotelCartBookingData extends ObjectModel ); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); - if (!Validate::isLoadedObject($objHotelCartBookingData)) { - return false; - } - - if (!$objHotelCartBookingData->delete()) { - return false; + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); } } + + return $return; } - return true; + return false; } /** @@ -581,15 +584,18 @@ class HotelCartBookingData extends ObjectModel ); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new self($row['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $return &= $objHotelCartBookingData->delete(); } } + + return $return; } - return true; + return false; } /** @@ -795,12 +801,15 @@ class HotelCartBookingData extends ObjectModel ); if (is_array($result) && count($result)) { + $return = true; foreach ($result as $row) { $objHotelCartBookingData = new HotelCartBookingData($row['id']); if (Validate::isLoadedObject($objHotelCartBookingData)) { - $objHotelCartBookingData->delete(); + $return &= $objHotelCartBookingData->delete(); } } + + return $return; } return true; From b66151a7c838299445b4b54afa130caae35db8bd Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Tue, 3 Jan 2023 20:30:02 +0530 Subject: [PATCH 38/42] update array declaration --- classes/Cookie.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/Cookie.php b/classes/Cookie.php index f8d66aa3a..29b89b697 100644 --- a/classes/Cookie.php +++ b/classes/Cookie.php @@ -30,20 +30,20 @@ class CookieCore const SAMESITE_LAX = 'Lax'; const SAMESITE_STRICT = 'Strict'; - const SAMESITE_AVAILABLE_VALUES = [ - [ + const SAMESITE_AVAILABLE_VALUES = array( + array( "type" => self::SAMESITE_NONE, "name" => self::SAMESITE_NONE - ], - [ + ), + array( "type" => self::SAMESITE_LAX, "name" => self::SAMESITE_LAX - ], - [ + ), + array( "type" => self::SAMESITE_STRICT, "name" => self::SAMESITE_STRICT - ], - ]; + ), + ); /** @var array Contain cookie content in a key => value format */ protected $_content; From f4b4d55b71147cc3a79030c933f0e8a6a85cb31c Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 5 Jan 2023 15:17:30 +0530 Subject: [PATCH 39/42] updated booking rooms list and added reallocation modal --- .../helpers/view/_partials/booking-rooms.tpl | 104 ++++++++---------- .../hotel_rooms_booking/helpers/view/view.tpl | 91 +++++++++++++++ 2 files changed, 139 insertions(+), 56 deletions(-) diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl index b853484bd..2a481476c 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl @@ -57,39 +57,35 @@
- - - + + + {foreach from=$book_v['data']['partially_available'] key=part_k item=part_v} - - - - + + + + + {/foreach} {/foreach}
{$payment['payment_method']} {displayPrice currency=$payment['id_currency'] price=$payment['amount']}
{l s='Room No.' mod='hotelreservationsystem'}{l s='Duration' mod='hotelreservationsystem'}{l s='Allotment Type' mod='hotelreservationsystem'}{l s='Action' mod='hotelreservationsystem'}{l s='Duration' mod='hotelreservationsystem'}{l s='Allotment Type' mod='hotelreservationsystem'}{l s='Action' mod='hotelreservationsystem'}
{$part_v['room_num']|escape:'htmlall':'UTF-8'} - - {foreach from=$part_v['avai_dates'] key=sub_part_k item=sub_part_v} - - - - - + {foreach from=$part_v['avai_dates'] key=sub_part_k item=sub_part_v} + + {if $sub_part_v@first} + + {/if} + +
-

{dateFormat date=date('Y-m-d', strtotime($sub_part_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($sub_part_v['date_to']))}

-
- {foreach $allotment_types as $allotment_type} - - {/foreach} - - - -
{$part_v['room_num']|escape:'htmlall':'UTF-8'} +

{dateFormat date=date('Y-m-d', strtotime($sub_part_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($sub_part_v['date_to']))}

+
+ {foreach $allotment_types as $allotment_type} + {/foreach} -
-
+ +
@@ -101,39 +97,35 @@ {l s='Room No.' mod='hotelreservationsystem'} - {l s='Duration' mod='hotelreservationsystem'} - {l s='Message' mod='hotelreservationsystem'} - {l s='Allotment Type' mod='hotelreservationsystem'} + {l s='Duration' mod='hotelreservationsystem'} + {l s='Message' mod='hotelreservationsystem'} + {l s='Allotment Type' mod='hotelreservationsystem'} {l s='Reallocate' mod='hotelreservationsystem'} {foreach from=$book_v['data']['booked'] key=booked_k item=booked_v} - - {$booked_v['room_num']|escape:'htmlall':'UTF-8'} - - - {foreach from=$booked_v['detail'] key=rm_dtl_k item=rm_dtl_v} - - - - - - - {/foreach} -
{dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_to']))}{$rm_dtl_v['comment']|escape:'htmlall':'UTF-8'} - {if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO}{l s='Auto Allotment' mod='hotelreservationsystem'}{elseif $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_MANUAL}{l s='Manual Allotment' mod='hotelreservationsystem'}{/if} - - {if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO} - - {else} - -- - {/if} -
- - + {foreach from=$booked_v['detail'] key=rm_dtl_k item=rm_dtl_v} + + {if $rm_dtl_v@first} + {$booked_v['room_num']|escape:'htmlall':'UTF-8'} + {/if} + {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_to']))} + {$rm_dtl_v['comment']|escape:'htmlall':'UTF-8'} + + {if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO}{l s='Auto Allotment' mod='hotelreservationsystem'}{elseif $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_MANUAL}{l s='Manual Allotment' mod='hotelreservationsystem'}{/if} + + + {if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO} + + {else} + -- + {/if} + + + {/foreach} {/foreach} diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl index b45a7f04b..de178dca3 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl @@ -92,6 +92,97 @@ + +