diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 58449352d..bba787f92 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1206,14 +1206,14 @@ abstract class PaymentModuleCore extends Module // changing mail format $cart_booking_data = $this->cartBookingDataForMail($order); - $cart_booking_data_text = $this->getEmailTemplateContent('hotel-booking-cart-data-text.tpl', Mail::TYPE_TEXT, $cart_booking_data['cart_htl_data']); - $cart_booking_data_html = $this->getEmailTemplateContent('hotel-booking-cart-data.tpl', Mail::TYPE_HTML, $cart_booking_data['cart_htl_data']); + $cart_booking_data_text = $this->getEmailTemplateContent('hotel_booking_cart_data_text.tpl', Mail::TYPE_TEXT, $cart_booking_data['cart_htl_data']); + $cart_booking_data_html = $this->getEmailTemplateContent('hotel_booking_cart_data.tpl', Mail::TYPE_HTML, $cart_booking_data['cart_htl_data']); $extra_demands_details_html = $this->getEmailTemplateContent('booking_extra_demands.tpl', Mail::TYPE_HTML, $cart_booking_data['cart_htl_data']); $extra_demands_details_text = $this->getEmailTemplateContent('booking_extra_demands_text.tpl', Mail::TYPE_TEXT, $cart_booking_data['cart_htl_data']); - $normal_products_data_html = $this->getEmailTemplateContent('service-product-data.tpl', Mail::TYPE_HTML, $orderServiceProducts); - $normal_products_data_txt = $this->getEmailTemplateContent('service-product-data-text.tpl', Mail::TYPE_TEXT, $orderServiceProducts); + $normal_products_data_html = $this->getEmailTemplateContent('service_product_data.tpl', Mail::TYPE_HTML, $orderServiceProducts); + $normal_products_data_txt = $this->getEmailTemplateContent('service_product_data_text.tpl', Mail::TYPE_TEXT, $orderServiceProducts); // get order total information html/txt files // total room price @@ -1272,8 +1272,8 @@ abstract class PaymentModuleCore extends Module 'has_room_bookings' => $cart_booking_data['cart_htl_data'] ); - $order_total_info_html = $this->getEmailTemplateContent('order-conf-total-info.tpl', Mail::TYPE_HTML, $orderTotalData); - $order_total_info_txt = $this->getEmailTemplateContent('order-conf-total-info-text.tpl', Mail::TYPE_TEXT, $orderTotalData); + $order_total_info_html = $this->getEmailTemplateContent('order_conf_total_info.tpl', Mail::TYPE_HTML, $orderTotalData); + $order_total_info_txt = $this->getEmailTemplateContent('order_conf_total_info_text.tpl', Mail::TYPE_TEXT, $orderTotalData); $hotelName = ''; if ($idOrderHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) { diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index f479306e7..0026d8af5 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -597,7 +597,7 @@ class OrderReturnCore extends ObjectModel $serviceProductsData ); $data['{refundServiceProductsTxt}'] = $objMail->getEmailTemplateContent( - 'service_products_refund_request_detail', + 'service_products_refund_request_detail_text', Mail::TYPE_TEXT, $serviceProductsData ); @@ -614,7 +614,7 @@ class OrderReturnCore extends ObjectModel )) { $idHotel = reset($refundReqBookings)['id_hotel']; $data['{refundBookingHtml}'] = $objMail->getEmailTemplateContent('bookings_refund_request_detail_customer', Mail::TYPE_HTML, $refundReqBookings); - $data['{refundBookingTxt}'] = $objMail->getEmailTemplateContent('bookings_refund_request_detail_customer', Mail::TYPE_TEXT, $refundReqBookings); + $data['{refundBookingTxt}'] = $objMail->getEmailTemplateContent('bookings_refund_request_detail_customer_text', Mail::TYPE_TEXT, $refundReqBookings); $data['{refund_for_txt}'] = Mail::l('bookings', (int)$idLang); } @@ -648,7 +648,7 @@ class OrderReturnCore extends ObjectModel )) { $idHotel = $refundReqBookings[0]['id_hotel']; $data['{refundBookingHtml}'] = $objMail->getEmailTemplateContent('bookings_refund_request_detail_admin', Mail::TYPE_HTML, $refundReqBookings); - $data['{refundBookingTxt}'] = $objMail->getEmailTemplateContent('bookings_refund_request_detail_admin', Mail::TYPE_TEXT, $refundReqBookings); + $data['{refundBookingTxt}'] = $objMail->getEmailTemplateContent('bookings_refund_request_detail_admin_text', Mail::TYPE_TEXT, $refundReqBookings); $data['{refund_for_txt}'] = Mail::l('bookings', (int)$idLang); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index e3ea50bbd..346a64194 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -2738,7 +2738,21 @@ class AdminOrdersControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Total Due Amount', null, null, false); $minValue = ('0.' . str_repeat('0', (Configuration::get('PS_PRICE_DISPLAY_PRECISION') - 1)) . '1'); - $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_amount_due%5B0%5D='.$minValue; + + // get all valid order states for due amount calculations + $validOrderStatesFilter = ''; + if ($allOrderStates = OrderState::getOrderStates($this->context->language->id)) { + $allOrderStates = array_column($allOrderStates, 'id_order_state'); + $objHotelBooking = new HotelBookingDetail(); + $invalidOrderStates = $objHotelBooking->getOrderStatusToFreeBookedRoom(); + + if ($validOrderStates = array_diff($allOrderStates, $invalidOrderStates)) { + foreach ($validOrderStates as $idOrderState) { + $validOrderStatesFilter .= '&orderFilter_os!id_order_state[]='.$idOrderState; + } + } + } + $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_amount_due%5B0%5D='.$minValue.$validOrderStatesFilter; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_due_amount'; $helper->tooltip = $this->l('Total due amount of all the orders created.', null, null, false); $this->kpis[] = $helper; diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 0c1786d85..7d301dc2b 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -972,10 +972,21 @@ class AdminStatsControllerCore extends AdminStatsTabController FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_state` os ON os.`id_order_state` = o.`current_state` WHERE o.`invoice_date` BETWEEN "'.pSQL(date('Y-m-d', strtotime('-'.($daysForAvgOrderVal + 1).' day'))).' 00:00:00" - AND "'.pSQL(date('Y-m-d')).' 23:59:59" AND os.`logable` = 1 AND EXISTS ( - SELECT 1 - FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotels).' + AND "'.pSQL(date('Y-m-d')).' 23:59:59" AND os.`logable` = 1 + AND ( + EXISTS ( + SELECT 1 + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotels).' + ) OR EXISTS ( + SELECT 1 + FROM `'._DB_PREFIX_.'service_product_order_detail` spod + WHERE spod.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotels, 'spod').' + )'.(!$idHotels ? ' OR EXISTS ( + SELECT 1 + FROM `'._DB_PREFIX_.'service_product_order_detail` spod + WHERE spod.`id_order` = o.`id_order` AND spod.`id_hotel` = 0 AND spod.`id_htl_booking_detail` = 0 + )' : '').' )'); $value = Tools::displayPrice($row['orders'] ? $row['total_paid_tax_excl'] / $row['orders'] : 0, $currency).' ('.$this->l('tax excl.').')'; @@ -2555,11 +2566,21 @@ class AdminStatsControllerCore extends AdminStatsTabController LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state WHERE 1 ' . ($invalidOrderStates ? ' AND o.`current_state` NOT IN ('.implode(',', $invalidOrderStates).')' : '') . - (($dateFrom && $dateTo) ? ' AND o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"' : ''). - ' AND EXISTS ( - SELECT 1 - FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).' + (($dateFrom && $dateTo) ? ' AND o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"' : '').' + AND ( + EXISTS ( + SELECT 1 + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).' + ) OR EXISTS ( + SELECT 1 + FROM `'._DB_PREFIX_.'service_product_order_detail` spod + WHERE spod.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel, 'spod').' + )'.(!$idHotel ? ' OR EXISTS ( + SELECT 1 + FROM `'._DB_PREFIX_.'service_product_order_detail` spod + WHERE spod.`id_order` = o.`id_order` AND spod.`id_hotel` = 0 AND spod.`id_htl_booking_detail` = 0 + )' : '').' )'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } diff --git a/mails/en/booking_extra_demands_text.tpl b/mails/en/booking_extra_demands_text.tpl index 5f74a1b03..38d5b7320 100644 --- a/mails/en/booking_extra_demands_text.tpl +++ b/mails/en/booking_extra_demands_text.tpl @@ -1,20 +1,30 @@ -{if isset($list)} -{l s='Extra Demands Details'} +{if isset($list) && $list} + +{l s='Room Extra Demands Detail'} + {l s='Room Type'} -{l s='Extra demand name'} +{l s='Name'} {l s='Total'} {l s='(Tax excl.)'} {foreach from=$list key=data_k item=data_v} {foreach from=$data_v['date_diff'] key=rm_k item=rm_v} + {if isset($rm_v['extra_demands']) && $rm_v['extra_demands']} {assign var=roomCount value=1} + {foreach $rm_v['extra_demands'] as $roomDemand} {foreach name=demandRow from=$roomDemand['extra_demands'] item=demand} +{if !isset($room_demand_exists)} +{assign var=room_demand_exists value=1} +{/if} + {if $smarty.foreach.demandRow.first} + {$data_v['name']} {$rm_v['data_form']|date_format:"%d-%m-%Y"} {l s='to'} {$rm_v['data_to']|date_format:"%d-%m-%Y"} {l s='Room'} - {$roomCount} + {/if} {$demand['name']} @@ -27,4 +37,56 @@ {/if} {/foreach} {/foreach} + +{if !isset($room_demand_exists)} +{l s='No room extra demands added.'} +{/if} + + +{l s='Rooms Services Detail'} + +{l s='Room Type'} +{l s='Name'} +{l s='Qty'} +{l s='Total'} + +{foreach from=$list key=data_k item=data_v} +{foreach from=$data_v['date_diff'] key=rm_k item=rm_v} + +{if isset($rm_v['additional_services']) && $rm_v['additional_services']} +{assign var=roomCount value=1} + +{foreach $rm_v['additional_services'] as $roomService} +{foreach name=serviceRow from=$roomService['additional_services'] item=service} + +{if !isset($room_additinal_services_exists)} +{assign var=room_additinal_services_exists value=1} +{/if} + +{if $smarty.foreach.serviceRow.first} +{$data_v['name']} +{$rm_v['data_form']|date_format:"%d-%m-%Y"} {l s='to'} {$rm_v['data_to']|date_format:"%d-%m-%Y"} +{l s='Room'} - {$roomCount} +{/if} + +{$service['name']} + +{if $service['allow_multiple_quantity']} +{$service['quantity']} +{else} +{l s='--'} +{/if} + +{convertPrice price=$service['total_price_tax_excl']} + +{/foreach} +{assign var=roomCount value=$roomCount+1} +{/foreach} +{/if} +{/foreach} +{/foreach} + +{if !isset($room_additinal_services_exists)} +{l s='No room services added.'} +{/if} {/if} diff --git a/mails/en/bookings_refund_request_detail_admin_text.tpl b/mails/en/bookings_refund_request_detail_admin_text.tpl new file mode 100644 index 000000000..236cfacad --- /dev/null +++ b/mails/en/bookings_refund_request_detail_admin_text.tpl @@ -0,0 +1,22 @@ +{if isset($list) && $list} + +{l s="Room Num"} + +{l s="Room Type"} + +{l s="Hotel"} + +{l s="Duration"} + +{foreach from=$list key=data_k item=data_v} + +{$data_v['room_num']} + +{$data_v['room_type_name']} + +{$data_v['hotel_name']} + +{$data_v['date_from']|date_format:"%d-%b-%G"} To {$data_v['date_to']|date_format:"%d-%b-%G"} + +{/foreach} +{/if} \ No newline at end of file diff --git a/mails/en/bookings_refund_request_detail_customer_text.tpl b/mails/en/bookings_refund_request_detail_customer_text.tpl new file mode 100644 index 000000000..51d0d3ea7 --- /dev/null +++ b/mails/en/bookings_refund_request_detail_customer_text.tpl @@ -0,0 +1,25 @@ +{if isset($list) && $list} + +{l s='Rooms Bookings Detail'} + + +{l s="Room Type"} + +{l s="Hotel"} + +{l s="Rooms Qty"} + +{l s="Duration"} + +{foreach from=$list key=data_k item=data_v} + +{$data_v['room_type_name']} + +{$data_v['hotel_name']} + +{$data_v['num_rooms']} + +{$data_v['date_from']|date_format:"%d-%b-%G"} To {$data_v['date_to']|date_format:"%d-%b-%G"} + +{/foreach} +{/if} \ No newline at end of file diff --git a/mails/en/hotel-booking-cart-data.tpl b/mails/en/hotel_booking_cart_data.tpl similarity index 100% rename from mails/en/hotel-booking-cart-data.tpl rename to mails/en/hotel_booking_cart_data.tpl diff --git a/mails/en/hotel-booking-cart-data-text.tpl b/mails/en/hotel_booking_cart_data_text.tpl similarity index 100% rename from mails/en/hotel-booking-cart-data-text.tpl rename to mails/en/hotel_booking_cart_data_text.tpl diff --git a/mails/en/order-conf-total-info-text.tpl b/mails/en/order-conf-total-info-text.tpl deleted file mode 100644 index 91848af9a..000000000 --- a/mails/en/order-conf-total-info-text.tpl +++ /dev/null @@ -1,22 +0,0 @@ -Total Rooms Cost -{$list['room_price_tax_excl']} - -{if isset($list['has_standalone_products']) && $list['has_standalone_products']} -Total Products Cost -{$list['service_products_price_tax_excl']} -{/if} - -Total Extra Services Cost -{$list['additional_service_price_tax_excl']} - -Total Convenience Fees -{$list['total_convenience_fee_te']} - -Total Tax -{$list['total_order_tax']} - -Discounts -{$list['total_discounts']} - -Final Booking Amount -{$list['total_paid']} \ No newline at end of file diff --git a/mails/en/order_conf_cart_rules_text.tpl b/mails/en/order_conf_cart_rules_text.tpl new file mode 100644 index 000000000..c84217ff0 --- /dev/null +++ b/mails/en/order_conf_cart_rules_text.tpl @@ -0,0 +1,7 @@ +{foreach $list as $cart_rule} + +{$cart_rule['voucher_name']} + +{$cart_rule['voucher_reduction']} + +{/foreach} diff --git a/mails/en/order_conf_product_list_text.tpl b/mails/en/order_conf_product_list_text.tpl new file mode 100644 index 000000000..05cd145b4 --- /dev/null +++ b/mails/en/order_conf_product_list_text.tpl @@ -0,0 +1,26 @@ +{foreach $list as $product} + +{$product['reference']} + +{$product['name']} + +{$product['unit_price']} + +{$product['quantity']} + +{$product['price']} + + +{foreach $product['customization'] as $customization} +{$product['name']} + +{$customization['customization_text']} + +{$product['unit_price']} + +{$customization['customization_quantity']} + +{$customization['quantity']} + +{/foreach} +{/foreach} \ No newline at end of file diff --git a/mails/en/order-conf-total-info.tpl b/mails/en/order_conf_total_info.tpl similarity index 100% rename from mails/en/order-conf-total-info.tpl rename to mails/en/order_conf_total_info.tpl diff --git a/mails/en/order_conf_total_info_text.tpl b/mails/en/order_conf_total_info_text.tpl new file mode 100644 index 000000000..ca048b8d0 --- /dev/null +++ b/mails/en/order_conf_total_info_text.tpl @@ -0,0 +1,21 @@ +{if isset($list['has_room_bookings']) && $list['has_room_bookings']} +{l s="Total Rooms Cost"} {$list['room_price_tax_excl']} +{/if} + +{if isset($list['has_standalone_products']) && $list['has_standalone_products']} +{l s="Total Products Cost"} {$list['service_products_price_tax_excl']} +{/if} + +{if isset($list['has_room_bookings']) && $list['has_room_bookings']} +{l s="Total Extra Services Cost"} {$list['additional_service_price_tax_excl']} +{/if} + +{if isset($list['has_room_bookings']) && $list['has_room_bookings']} +{l s="Total Convenience Fees"} {$list['total_convenience_fee_te']} +{/if} + +{l s="Total Tax"} {$list['total_order_tax']} + +{l s="Discounts"} {$list['total_discounts']} + +{l s="Final Booking Amount"} {$list['total_paid']} \ No newline at end of file diff --git a/mails/en/order_header_line_text.tpl b/mails/en/order_header_line_text.tpl new file mode 100644 index 000000000..c72f40a42 --- /dev/null +++ b/mails/en/order_header_line_text.tpl @@ -0,0 +1,21 @@ +{if isset($list['for_admin']) && $list['for_admin']} +{if isset($list['hotel_name']) && $list['hotel_name']} +{if isset($list['has_room_bookings']) && $list['has_room_bookings']} +{l s='New bookings are created on'} {$list['hotel_name']}! +{else} +{l s='New order is created on'} {$list['hotel_name']}! +{/if} +{else} +{l s='New order is created'}! +{/if} +{else} +{if isset($list['hotel_name']) && $list['hotel_name']} +{if isset($list['has_room_bookings']) && $list['has_room_bookings']} +{l s='Thank you for booking with'} {$list['hotel_name']}! +{else} +{l s='Thank you for order with'} {$list['hotel_name']}! +{/if} +{else} +{l s='Thank you for your order'}! +{/if} +{/if} \ No newline at end of file diff --git a/mails/en/order_hotel_detail_text.tpl b/mails/en/order_hotel_detail_text.tpl new file mode 100644 index 000000000..e80d3bb4b --- /dev/null +++ b/mails/en/order_hotel_detail_text.tpl @@ -0,0 +1,9 @@ +{if isset($list['hotel_name']) && $list['hotel_name']} +{l s='Hotel details'}: + +{l s='Hotel Name'}: {$list['hotel_name']} +{l s='Hotel Phone'}: {$list['hotel_phone']} +{l s='Hotel Email'}: {$list['hotel_email']} +{l s='Total Rooms'}: {$list['num_rooms']} + +{/if} \ No newline at end of file diff --git a/mails/en/service-product-data-text.tpl b/mails/en/service-product-data-text.tpl deleted file mode 100644 index e69de29bb..000000000 diff --git a/mails/en/service-product-data.tpl b/mails/en/service_product_data.tpl similarity index 100% rename from mails/en/service-product-data.tpl rename to mails/en/service_product_data.tpl diff --git a/mails/en/service_product_data_text.tpl b/mails/en/service_product_data_text.tpl new file mode 100644 index 000000000..00cbd95fb --- /dev/null +++ b/mails/en/service_product_data_text.tpl @@ -0,0 +1,26 @@ +{if isset($list) && $list} + +{l s='Image'} + +{l s='Name'} + +{l s='Unit Price'} + +{l s='Qty'} + +{l s='Total'} + +{foreach from=$list key=key item=product} + + + +{$product['name']}{if isset($product['option_name']) && $product['option_name']} : {$product['option_name']}{/if} + +{convertPrice price=$product['unit_price_tax_excl']} + +{$product['quantity']} + +{convertPrice price=$product['total_price_tax_excl']} + +{/foreach} +{/if} diff --git a/mails/en/service_products_refund_request_detail_text.tpl b/mails/en/service_products_refund_request_detail_text.tpl new file mode 100644 index 000000000..bef7e65a0 --- /dev/null +++ b/mails/en/service_products_refund_request_detail_text.tpl @@ -0,0 +1,24 @@ +{if isset($list['service_products']) && $list['service_products']} + +{l s='Service Products Detail'} + + +{l s="Product name"} + +{if isset($list['is_hotel_products']) && $list['is_hotel_products']} +{l s="Hotel"} +{/if} + +{l s="Quantity"} + +{foreach $list['service_products'] as $product} +{$product['name']}{if isset($product['option_name']) && $product['option_name']} : {$product['option_name']}{/if} + +{if isset($list['is_hotel_products']) && $list['is_hotel_products']} +{$product['hotel_name']} +{/if} + +{$product['quantity']} + +{/foreach} +{/if} \ No newline at end of file