diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 66dd53a9c..3d9c89ec6 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -703,17 +703,17 @@
{$customer->ape}
{/if} --> - {if $order->id_booking_staying_guest} + {if $order->id_customer_guest_detail}
- {l s='Staying guest'} + {l s='Guest'}
{l s='Name'}
-
{$bookingStayingGuest->firstname} {$bookingStayingGuest->lastname}

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

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

+
{$customerGuestDetail->email}

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

- - + +

{/if} -
+
- {foreach from=$genders key=k item=gender} - + {/foreach}
- +
- +
- +
- +
-
+
{l s='Name'}
{$guestInformations['firstname']} {$guestInformations['lastname']}