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 1bc448b89..d734dbf57 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 *} - + @@ -476,12 +476,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 '} @@ -492,7 +492,7 @@ #{'%06d'|sprintf:$brother_order->id} - {/foreach} + {/foreach} *}

{/if}
@@ -509,15 +509,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} @@ -532,32 +532,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} @@ -673,15 +673,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 $customerGuestDetail} +
+
+ {l s='Traveller detail'} +
+
+
{l s='Name'}
+
{$customerGuestDetail->gender->name} {$customerGuestDetail->firstname} {$customerGuestDetail->lastname}
+
+
{l s='Email'}
+
{$customerGuestDetail->email}

+
{l s='Phone'}
+
{$customerGuestDetail->phone}
+
+ +
+
+ +
+ {/if} {/if} @@ -1690,6 +1763,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/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} diff --git a/admin/themes/default/template/helpers/kpi/row.tpl b/admin/themes/default/template/helpers/kpi/row.tpl index 2f634809a..fc481cbd3 100644 --- a/admin/themes/default/template/helpers/kpi/row.tpl +++ b/admin/themes/default/template/helpers/kpi/row.tpl @@ -26,6 +26,7 @@ {if $refresh}
{/if} + {if ($kpis|count) > 0}
{assign var='col' value=(int)(12 / $kpis|count)} {foreach from=$kpis item=i name=kpi} @@ -36,4 +37,5 @@
{$i}
{/foreach}
+ {/if} diff --git a/classes/CartCustomerGuestDetail.php b/classes/CartCustomerGuestDetail.php new file mode 100644 index 000000000..d21c56c68 --- /dev/null +++ b/classes/CartCustomerGuestDetail.php @@ -0,0 +1,83 @@ + +* @copyright 2010-2022 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +class CartCustomerGuestDetailCore extends ObjectModel +{ + public $id_customer_guest_detail; + public $id_cart; + public $id_gender; + public $firstname; + public $lastname; + public $email; + public $phone; + public $date_add; + public $date_upd; + + public static $definition = array( + 'table' => 'cart_customer_guest_detail', + 'primary' => 'id_customer_guest_detail', + 'fields' => array( + '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), + '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 getCartCustomerGuest($id_cart) + { + return Db::getInstance()->getValue(' + SELECT `id_customer_guest_detail` + FROM `'._DB_PREFIX_.'cart_customer_guest_detail` + WHERE `id_cart` = '.(int)$id_cart + ); + } + + public static function getCustomerGuestDetail($id_customer_guest_detail) + { + return Db::getInstance()->getRow(' + SELECT `id_gender`, `firstname`, `lastname`, `email`, `phone` + FROM `'._DB_PREFIX_.'cart_customer_guest_detail` + WHERE `id_customer_guest_detail` = '.(int)$id_customer_guest_detail + ); + } + + 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/Cookie.php b/classes/Cookie.php index 579c0c8db..29b89b697 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 = 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; @@ -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_; @@ -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/classes/PaymentModule.php b/classes/PaymentModule.php index adb48175a..a6f8255f3 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -371,9 +371,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->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->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 @@ -384,11 +398,27 @@ 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) // 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 != 'wsorder') { // if customer is paying full payment amount $id_order_state = Configuration::get('PS_OS_ERROR'); } @@ -446,10 +476,19 @@ 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'); } + + // 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); + } + } + } } // Next ! @@ -862,14 +901,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, '/'); - setcookie('wk_id_guest', ' ', time() - 86400, '/'); - - 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); } @@ -896,7 +927,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_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); + } $new_history->addWithemail(true, $extra_vars); // Switch to back order if needed @@ -1030,6 +1065,30 @@ abstract class PaymentModuleCore extends Module null, _PS_MAIL_DIR_, false, (int)$order->id_shop ); } + // send mail to customer guest if customer booked for someone other. + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + if ($objOrderCustomerGuestDetail = new OrderCustomerGuestDetail( + $id_customer_guest_detail + )) { + 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, + $objOrderCustomerGuestDetail->email, + $objOrderCustomerGuestDetail->firstname.' '.$objOrderCustomerGuestDetail->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..7ec1fef59 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 ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + $guestInfoComplete = false; + $objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail); + if ($objCustomerGuestDetail->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 399d4ec04..812a5373a 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -1278,8 +1278,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` @@ -1303,11 +1301,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) { @@ -1315,6 +1315,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); } @@ -1322,7 +1323,6 @@ class OrderCore extends ObjectModel Cache::clean('order_invoice_paid_*'); } } - // Update order cart rule Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'order_cart_rule` @@ -1697,11 +1697,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 + ); } /** @@ -1716,6 +1717,21 @@ class OrderCore extends ObjectModel return $order_payments; } + /** + * 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() + { + 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 + ); + } + /** * * This method allows to add a payment to the current order @@ -1726,9 +1742,10 @@ 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) + 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; @@ -1746,36 +1763,53 @@ 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); - } - - if (!validate::isPrice($this->total_paid_real)) { - return false; - } - // 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(); - - 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 ($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(OrderPayment $payment, $amount = null, $order_invoice = null) + { + if (Validate::isLoadedObject($payment)) { + if (!is_null($amount)) { + $amount = $payment->amount; + } + $order_payment_detail = new OrderPaymentDetail(); + $order_payment_detail->id_order = $this->id; + $order_payment_detail->id_order_payment = (int)$payment->id; + $order_payment_detail->amount = $amount; + + 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, $payment->id_currency, false), 2); + } + + if (!validate::isPrice($this->total_paid_real)) { + return false; + } + + 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)$payment->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. * @@ -1908,14 +1942,15 @@ class OrderCore extends ObjectModel } $total = 0; + // Retrieve all payments - $payments = $this->getOrderPaymentCollection(); + $payments = $this->getOrderPaymentDetail(); 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 { @@ -2181,6 +2216,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/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/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 2da4bf501..de1abdf54 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -322,30 +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; } - - // 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(); - 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.')'); + $order->addOrderPayment( + $rest_paid, + $payment_method, + null, + null, + null, + $invoice + ); } } } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 2e4e6ceab..0efdca2bb 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; @@ -880,6 +880,11 @@ class OrderInvoiceCore extends ObjectModel return OrderPayment::getByInvoiceId($this->id); } + public function getOrderPaymentDetail() + { + 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..ddfb1b58a --- /dev/null +++ b/classes/order/OrderPaymentDetail.php @@ -0,0 +1,71 @@ + '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'), + ) + ); + + /** + * 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 + ); + } + + /** + * Get Order Payments By Invoice ID + * + * @param int $id_invoice Invoice ID + * @return array OrderPayment detail + */ + public static function getByInvoiceId($id_invoice) + { + 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/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 diff --git a/config/config.inc.php b/config/config.inc.php index 880d0fc41..819e3be4f 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -161,10 +161,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/config/xml/themes/default.xml b/config/xml/themes/default.xml index 98ef61c2d..e664345a4 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/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/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 896842322..31e471fc8 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 4734cc732..1a5b1b554 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -881,13 +881,14 @@ 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 (isset($this->context->cookie->id_cart)) { + unset($this->context->cookie->id_cart); + } + if (isset($this->context->cookie->id_guest)) { + unset($this->context->cookie->id_guest); + } + if ($payment_module->currentOrder) { Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); } @@ -1351,6 +1352,13 @@ class AdminOrdersControllerCore extends AdminController $this->toolbar_title .= ' - '.sprintf($this->l('Shop: %s'), $shop->name); } + // get details if booking is done for some other guest + $customerGuestDetail = false; + 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 $warehouse_list = null; @@ -1431,6 +1439,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->getOrderPaymentDetail(); + 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')); @@ -1537,6 +1555,8 @@ class AdminOrdersControllerCore extends AdminController 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, + 'customerGuestDetail' => $customerGuestDetail, + 'genders' => Gender::getGenders(), 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array( 'delivery' => $addressDelivery, @@ -1547,13 +1567,13 @@ 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 '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), @@ -1606,6 +1626,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/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 4b5070e8a..81ddc9b17 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -382,6 +382,29 @@ class AdminPPreferencesControllerCore extends AdminController // 'bottom' => '', // 'submit' => array('title' => $this->l('Save')) // ), + 'fo_search_filters' => array( + '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.'), + '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.'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'required' => false, + 'type' => 'bool', + ), + ), + 'submit' => array('title' => $this->l('Save')) + ), ); } diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index a92df02ac..1d4b293c3 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'), 'LengthOfStay' => $this->l('Length of Stay'), + 'AdditionalFacilities' => $this->l('Additional Facilities'), ); $this->available_tabs = array('Warehouses' => 14); @@ -134,6 +135,7 @@ class AdminProductsControllerCore extends AdminController 'Configuration' => 14, 'Occupancy' => 15, 'LengthOfStay' => 16, + 'AdditionalFacilities' => 17, )); } @@ -2228,6 +2230,9 @@ class AdminProductsControllerCore extends AdminController if ($this->isTabSubmitted('Configuration')) { $this->processConfiguration(); } + if ($this->isTabSubmitted('AdditionalFacilities')) { + $this->processAdditionalFacilities(); + } $this->updatePackItems($object); // Disallow avanced stock management if the product become a pack @@ -3784,6 +3789,122 @@ class AdminProductsControllerCore extends AdminController die('0'); } + 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, + '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(); + } + } + } + } + } + } + } + } + /** * @param Product $obj * 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/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 25c59d1eb..393e7d577 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -98,6 +98,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/OrderDetailController.php b/controllers/front/OrderDetailController.php index a7e0c27b3..a570c68cb 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')) { @@ -459,6 +465,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 ee6601751..c45aa2d48 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -345,6 +345,10 @@ class OrderOpcControllerCore extends ParentOrderController $this->ajaxDie($this->changeRoomDemands()); exit; break; + case 'submitCustomerGuestDetail': + $this->ajaxDie($this->submitCustomerGuestDetail()); + exit; + break; default: throw new PrestaShopException('Unknown method "'.Tools::getValue('method').'"'); } @@ -505,6 +509,15 @@ class OrderOpcControllerCore extends ParentOrderController $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); + // GUEST BOOKING + if ($this->isLogged) { + 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', $id_customer_guest_detail); + } Tools::safePostVars(); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active); @@ -993,6 +1006,50 @@ class OrderOpcControllerCore extends ParentOrderController die('0'); } + public function submitCustomerGuestDetail() + { + $customerGuestDetail = Tools::getValue('customer_guest_detail'); + $this->context->cookie->__set('customer_details_proceeded', 0); + $this->context->cookie->checkedTOS = false; + if ($customerGuestDetail) { + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + $objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail); + } else { + $objCustomerGuestDetail = new CartCustomerGuestDetail(); + } + + $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(); + } else { + 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(); + } + public function updateContext(Customer $customer) { $this->context->cookie->id_customer = (int)$customer->id; diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a35ded882..9b4504dd6 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -91,6 +91,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')) { diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 946467010..cb8054296 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -673,6 +673,32 @@ CREATE TABLE `PREFIX_customer_thread` ( KEY `id_product` (`id_product`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; +CREATE TABLE `PREFIX_order_customer_guest_detail` ( + `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, + `email` varchar(128) NOT NULL, + `phone` varchar(32) DEFAULT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + 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_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_customization` ( `id_customization` int(10) unsigned NOT NULL auto_increment, `id_product_attribute` int(10) unsigned NOT NULL DEFAULT '0', @@ -1458,6 +1484,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, @@ -2598,7 +2633,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, @@ -2608,6 +2643,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/install/data/theme.sql b/install/data/theme.sql index 9ce4b813b..ec71efd71 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 3582d9981..8381ac7dd 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -62,6 +62,12 @@ 9 + + 1 + + + 1 + 0 @@ -440,6 +446,9 @@ 480 + + Lax + 0 diff --git a/js/validate.js b/js/validate.js index b8c011e0e..79d7af124 100644 --- a/js/validate.js +++ b/js/validate.js @@ -190,12 +190,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/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index c011e9992..1571ec2f3 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -129,7 +129,7 @@ class Blockcart extends Module $wrappingCost = (float) ($params['cart']->getOrderTotal($useTax, Cart::ONLY_WRAPPING)); $totalToPay = $params['cart']->getOrderTotal($useTax); $tax_cost = 0; - if ($showTax) { + if ($useTax && $showTax) { $totalToPayWithoutTaxes = $params['cart']->getOrderTotal(false); $tax_cost = Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency); } @@ -252,6 +252,7 @@ class Blockcart extends Module 'shipping_cost_float' => $shipping_cost_float, 'show_wrapping' => $wrappingCost > 0 ? true : false, 'show_tax' => $showTax, + 'use_tax' => $useTax, 'tax_cost' => $tax_cost, 'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_PRODUCTS), $currency), diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index 571283c56..ab402c9ab 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -206,7 +206,7 @@ {/if} --> - {if $show_tax && isset($tax_cost)} + {if $show_tax && $use_tax}
{$tax_cost} {l s='Tax' mod='blockcart'} diff --git a/modules/dashoccupancy/dashoccupancy.php b/modules/dashoccupancy/dashoccupancy.php index 0e22e01cc..444e07eb5 100644 --- a/modules/dashoccupancy/dashoccupancy.php +++ b/modules/dashoccupancy/dashoccupancy.php @@ -59,13 +59,6 @@ class DashOccupancy extends Module public function hookDashboardZoneOne() { - $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'); } diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index b82da92da..76aebbeeb 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1408,45 +1408,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)) { + 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(); } - $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) - ); - } else { - $data = array( - 'id_status' => $new_status, - 'check_in' => '', - 'check_out' => '' - ); - } - - // 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).'\''; - - return Db::getInstance()->update($table, $data, $where); + return false; } /** @@ -1602,8 +1596,9 @@ class HotelBookingDetail extends ObjectModel */ public function getAvailableRoomsForReallocation($date_from, $date_to, $id_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->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).'\' @@ -1672,36 +1667,48 @@ 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)) { + $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, + ) + ); + + return true; + } + } + } } - 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; - } - return false; } + return false; } @@ -1714,58 +1721,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; } @@ -1834,15 +1852,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 $objHotelBookingDetail->delete(); + } + + return false; } public function getRoomBookinInformationForDateRangeByOrder( @@ -1861,86 +1880,92 @@ class HotelBookingDetail extends ObjectModel } public function UpdateHotelCartHotelOrderOnOrderEdit( - $id_order, - $id_room, - $old_date_from, - $old_date_to, - $new_date_from, - $new_date_to, + $idOrder, + $idRoom, + $oldDateFrom, + $oldDateTo, + $newDateFrom, + $newDateTo, $occupancy, - $new_total_price = null + $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); - $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']; - } else { - $oldNumDays = $this->getNumberOfDays($old_date_from, $old_date_to); - $unitRoomPriceTE = $rowByIdOrderIdRoom['total_price_tax_excl'] / $oldNumDays; - $unitRoomPriceTI = $rowByIdOrderIdRoom['total_price_tax_incl'] / $oldNumDays; - $newTotalPriceTE = $unitRoomPriceTE * $newNumDays; - $newTotalPriceTI = $unitRoomPriceTI * $newNumDays; - } + // retrieve HotelBookingDetail row + $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $oldDateFrom, $oldDateTo); + $objHotelBookingDetail = new self($roomBookingData['id']); + 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 + ); - // update `total_paid_amount` on database - $totalPaidAmount = 0; - $isAdvancePayment = Db::getInstance()->getValue( - 'SELECT o.`is_advance_payment` - FROM `'._DB_PREFIX_.'orders` o - WHERE o.`id_order` = '.(int) $id_order - ); + $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; + } - if ($isAdvancePayment) { - $objHotelAdvancedPayment = new HotelAdvancedPayment(); - $productAdvancePayment = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($rowByIdOrderIdRoom['id_product']); - - if (!$productAdvancePayment || (isset($productAdvancePayment['payment_type']) && $productAdvancePayment['payment_type'])) { - $totalPaidAmount = $objHotelAdvancedPayment->getRoomMinAdvPaymentAmount( - $rowByIdOrderIdRoom['id_product'], - $new_date_from, - $new_date_to + // 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; + $objHotelCartBookingData->adults = $occupancy['adults']; + $objHotelCartBookingData->children = $occupancy['children']; + $objHotelCartBookingData->child_ages = json_encode($occupancy['child_ages']); + + // 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); + $objHotelBookingDetail->adults = $occupancy['adults']; + $objHotelBookingDetail->children = $occupancy['children']; + $objHotelBookingDetail->child_ages = json_encode($occupancy['child_ages']); + + if ($objHotelCartBookingData->save() && $objHotelBookingDetail->save()) { + return true; + } } - } 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, - 'adults' => $occupancy['adults'], - 'children' => $occupancy['children'], - 'child_ages' => json_encode($occupancy['child_ages']), - ), - ); - - $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, - 'adults' => $occupancy['adults'], - 'children' => $occupancy['children'], - 'child_ages' => json_encode($occupancy['child_ages']), - ), - ); - - $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'; - - $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; } /** @@ -2358,37 +2383,105 @@ 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); + $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)) { + $result &= $objHotelCartBookingData->delete(); + } + } } - 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)) { + $result &= $objHotelBookingDetail->delete(); + } + } + } + + return $result; } - 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 + ); + + $return = true; + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } } - 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 &= $objHotelBookingDetail->delete(); + } + } + } + + return $return; } - 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 + ); + + $return = true; + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } } - 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 &= $objHotelBookingDetail->delete(); + } + } + } + + return $return; } public function enterHotelOrderBookingFormCartBookingData($id_cart) @@ -2440,6 +2533,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. @@ -2484,11 +2579,19 @@ 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)) { + $result = true; + foreach ($bookingsData as $bookingData) { + $objHotelBookingDetail = new self($bookingData['id']); + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $objHotelBookingDetail->id_order_detail = $orderDetail->id_order_detail; + $result &= $objHotelBookingDetail->save(); + } + } + + return $result; + } } } return false; @@ -2513,7 +2616,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 04546f4ac..d7adfa6eb 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -230,9 +230,13 @@ 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)) { + $objHotelCartBookingData->delete(); + return true; + } - return $delete; + return false; } /** @@ -314,28 +318,15 @@ 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); + $cartProductQuantity = Db::getInstance()->getValue('SELECT `quantity` FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart`='.$idCart.' AND `id_product`='.$idProduct); + $newQuantity = $cartProductQuantity - $daysDiff; - $cart_product_quantity = Db::getInstance()->getValue('SELECT `quantity` FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart`='.$cart_id.' AND `id_product`='.$id_product); - - $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; - } - - return false; + 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); } } @@ -427,13 +418,18 @@ 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)) { + $objHotelCartBookingData->delete(); + } } } + // return number of rooms deleted - return true; + return $numRooms; } public function addCartBookingData( @@ -612,11 +608,19 @@ 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)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } + + return $return; } return false; @@ -647,15 +651,20 @@ 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)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } } - return false; - } else { - return false; + return $return; } + + return false; } /** @@ -667,34 +676,22 @@ 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)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } - 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 ($result) { - return $result; + return $return; } return false; @@ -733,7 +730,7 @@ class HotelCartBookingData extends ObjectModel return false; } - $dltdata = false; + $dltdata = ''; $stringArr = array('date_from', 'date_to'); @@ -748,9 +745,26 @@ 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)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } + + return $return; + } + + return false; } /** @@ -767,7 +781,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) { @@ -780,9 +794,30 @@ 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)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new self($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + foreach ($updData as $key => $value) { + $objHotelCartBookingData->$key = $value; + } + + $return &= $objHotelCartBookingData->save(); + } + } + + return $return; + } + + return true; } /** @@ -896,12 +931,26 @@ 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 + ); + + if (is_array($result) && count($result)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $objHotelCartBookingData->id_currency = $id_currency; + $return &= $objHotelCartBookingData->save(); + } + } + + return $return; } - return false; + return true; } /** @@ -916,9 +965,25 @@ 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)) { + $return = true; + foreach ($result as $row) { + $objHotelCartBookingData = new HotelCartBookingData($row['id']); + if (Validate::isLoadedObject($objHotelCartBookingData)) { + $return &= $objHotelCartBookingData->delete(); + } + } + + return $return; + } + + return true; } /** diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index d7e78db71..52f6c66f7 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -381,6 +381,65 @@ 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;", + + "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, + `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;", + + "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`;", ); } @@ -431,6 +490,8 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_room_type_demand_price`, `'._DB_PREFIX_.'htl_room_type_demand`, `'._DB_PREFIX_.'htl_room_disable_dates`, + `'._DB_PREFIX_.'htl_settings_link`, + `'._DB_PREFIX_.'htl_settings_link_lang`, `'._DB_PREFIX_.'htl_room_type_restriction_date_range`, `'._DB_PREFIX_.'htl_access`' ); diff --git a/modules/hotelreservationsystem/classes/HotelSettingsLink.php b/modules/hotelreservationsystem/classes/HotelSettingsLink.php new file mode 100644 index 000000000..c59ed9ebe --- /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 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.') + WHERE hsl.`active` = '.(int) $active.' + 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 9680cf5e4..84368f047 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php @@ -2,36 +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->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'), + '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', + ), + ); + } + + 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->getAllSettingsLinks(); + 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'), - '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/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 1347b7c80..ea66e3327 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -30,65 +30,51 @@ class AdminHotelRoomsBookingController extends ModuleAdminController parent::__construct(); - $this->setPhpCookieData(); + $this->initCart(); } - public function setPhpCookieData() + public function initCart() { - if (!isset($_COOKIE['wk_id_guest']) || !$_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, "/"); - } else { - $this->context->cookie->id_guest = $_COOKIE['wk_id_guest']; - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, "/"); - } - $guest = new Guest($this->context->cookie->id_guest); - - if (!isset($_COOKIE['wk_id_cart']) && !isset($this->context->cart->id)) { - $cart = new Cart(); - - $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 = $cart; - $this->context->cookie->id_cart = $cart->id; - - setcookie('wk_id_cart', $cart->id, time() + 86400, "/"); - } 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, "/"); + if (!isset($this->context->cookie->id_guest)) { + Guest::setNewGuest($this->context->cookie); } - $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; + 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(); - $this->context->customer = $customer; + $this->context->cart = $objCart; + $this->context->cart->save(); - return true; + $this->context->cookie->id_cart = (int) $objCart->id; + } else { + // use previous cart + $this->context->cart = new Cart($this->context->cookie->id_cart); + } + + $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 = $objCustomer; } public function postProcess() diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index ac3b75301..8914bf202 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -46,5 +46,7 @@ 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'; \ No newline at end of file diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index fc59c5d38..669d8ccc3 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -253,123 +253,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'); @@ -419,14 +302,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'); @@ -567,9 +442,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/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..aba822fce --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_configuration_setting/helpers/form/form.tpl @@ -0,0 +1,181 @@ +{** + * 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} +
+
+ +
+ +
+ +
+
+
+ {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'} +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ + 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 82e7ca383..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,35 +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'}

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 8dd75cd7b..85274c7c9 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 @@ -111,90 +111,84 @@ - + - + {if $occupancy_required_for_booking} {/if} - + {foreach from=$book_v['data']['partially_available'] key=part_k item=part_v} - - - - + + {* *} + + + + {/if} + + + {/foreach} {/foreach}
{l s='Duration' mod='hotelreservationsystem'}{l s='Duration' mod='hotelreservationsystem'} {l s='Room No.' mod='hotelreservationsystem'}{l s='Allotment Type' mod='hotelreservationsystem'}{l s='Allotment Type' mod='hotelreservationsystem'}{l s='Guests' mod='hotelreservationsystem'}{l s='Action' mod='hotelreservationsystem'}{l s='Action' mod='hotelreservationsystem'}
-

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

-
- - {foreach from=$part_v['rooms'] key=sub_part_k item=sub_part_v} - - - - {if $occupancy_required_for_booking} - + {if $sub_part_v@first} + + {/if} + + + {if $occupancy_required_for_booking} + - {/if} - - - {/foreach} -
-

{$sub_part_v['room_num']}

-
- {foreach $allotment_types as $allotment_type} - - {/foreach} - - -
+

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

+
{$sub_part_v['room_num']|escape:'htmlall':'UTF-8'} + {foreach $allotment_types as $allotment_type} + + {/foreach} + + + - -
-
+ +
@@ -206,39 +200,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 a8d9c6f96..dc97e7d80 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 @@ -187,6 +187,97 @@ + +