Merge branch 'develop' into gli-1096
This commit is contained in:
@@ -1833,7 +1833,7 @@ class CartCore extends ObjectModel
|
||||
$this->id,
|
||||
[],
|
||||
0,
|
||||
isset($product['id_hotel_cart_booking']) ? $product['id_hotel_cart_booking'] : null,
|
||||
null,
|
||||
null,
|
||||
(int)$product['id_product'],
|
||||
null,
|
||||
@@ -1862,53 +1862,55 @@ class CartCore extends ObjectModel
|
||||
// by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices....
|
||||
$totalPriceByProduct = 0;
|
||||
$priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
|
||||
foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) {
|
||||
$occupancy = array(
|
||||
array(
|
||||
'adults' => $cartRoomInfo['adults'],
|
||||
'children' => $cartRoomInfo['children'],
|
||||
'child_ages' => json_decode($cartRoomInfo['child_ages'])
|
||||
)
|
||||
|
||||
if ($type == Cart::ADVANCE_PAYMENT || $type == Cart::ADVANCE_PAYMENT_ONLY_PRODUCTS) {
|
||||
// getProductMinAdvPaymentAmountByIdCart already aggregates all rooms for this product internally,
|
||||
// so call it once and add once — not inside the per-room loop.
|
||||
$advProductPrice = $objAdvPayment->getProductMinAdvPaymentAmountByIdCart(
|
||||
$this->id,
|
||||
$product['id_product'],
|
||||
0,
|
||||
0,
|
||||
$with_taxes
|
||||
);
|
||||
// get the real price of the room type
|
||||
$roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$cartRoomInfo['id_product'],
|
||||
$cartRoomInfo['date_from'],
|
||||
$cartRoomInfo['date_to'],
|
||||
$occupancy,
|
||||
Group::getCurrent()->id,
|
||||
$cartRoomInfo['id_cart'],
|
||||
$cartRoomInfo['id_guest'],
|
||||
$cartRoomInfo['id_room'],
|
||||
0
|
||||
);
|
||||
if ($with_taxes) {
|
||||
$totalPriceByProduct = $roomTotalPrice['total_price_tax_incl'];
|
||||
} else {
|
||||
$totalPriceByProduct = $roomTotalPrice['total_price_tax_excl'];
|
||||
}
|
||||
|
||||
// If customer has selected advance payment of the cart
|
||||
if ($type == Cart::ADVANCE_PAYMENT || $type == Cart::ADVANCE_PAYMENT_ONLY_PRODUCTS) {
|
||||
$advProductPrice = $objAdvPayment->getProductMinAdvPaymentAmountByIdCart(
|
||||
$this->id,
|
||||
$cartRoomInfo['id_product'],
|
||||
0,
|
||||
0,
|
||||
$with_taxes
|
||||
);
|
||||
|
||||
// set advance payment price only if it is greater than real price
|
||||
if ($advProductPrice < $totalPriceByProduct) {
|
||||
$totalPriceByProduct = $advProductPrice;
|
||||
}
|
||||
}
|
||||
|
||||
// Rounding as per configurations
|
||||
if ($ps_round_type == Order::ROUND_TOTAL) {
|
||||
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($totalPriceByProduct);
|
||||
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($advProductPrice);
|
||||
} else {
|
||||
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($totalPriceByProduct);
|
||||
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($advProductPrice);
|
||||
}
|
||||
} else {
|
||||
foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) {
|
||||
$occupancy = array(
|
||||
array(
|
||||
'adults' => $cartRoomInfo['adults'],
|
||||
'children' => $cartRoomInfo['children'],
|
||||
'child_ages' => json_decode($cartRoomInfo['child_ages'])
|
||||
)
|
||||
);
|
||||
// get the real price of the room type
|
||||
$roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$cartRoomInfo['id_product'],
|
||||
$cartRoomInfo['date_from'],
|
||||
$cartRoomInfo['date_to'],
|
||||
$occupancy,
|
||||
Group::getCurrent()->id,
|
||||
$cartRoomInfo['id_cart'],
|
||||
$cartRoomInfo['id_guest'],
|
||||
$cartRoomInfo['id_room'],
|
||||
0
|
||||
);
|
||||
if ($with_taxes) {
|
||||
$totalPriceByProduct = $roomTotalPrice['total_price_tax_incl'];
|
||||
} else {
|
||||
$totalPriceByProduct = $roomTotalPrice['total_price_tax_excl'];
|
||||
}
|
||||
|
||||
// Rounding as per configurations
|
||||
if ($ps_round_type == Order::ROUND_TOTAL) {
|
||||
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($totalPriceByProduct);
|
||||
} else {
|
||||
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($totalPriceByProduct);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class ProfileCore extends ObjectModel
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
if (parent::add($autodate, true)) {
|
||||
$result = Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'access (SELECT '.(int)$this->id.', id_tab, 0, 0, 0, 0 FROM '._DB_PREFIX_.'tab)');
|
||||
$result = Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'access (SELECT '.(int)$this->id.', id_tab, 0, 0, 0, 0, 0 FROM '._DB_PREFIX_.'tab)');
|
||||
$result &= Db::getInstance()->execute('
|
||||
INSERT INTO '._DB_PREFIX_.'module_access
|
||||
(`id_profile`, `id_module`, `configure`, `view`, `uninstall`)
|
||||
@@ -138,6 +138,7 @@ class ProfileCore extends ObjectModel
|
||||
'add' => 1,
|
||||
'edit' => 1,
|
||||
'delete' => 1,
|
||||
'kpi' => 1,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -151,6 +152,7 @@ class ProfileCore extends ObjectModel
|
||||
$result[$key]['delete'] = (int) $profileAccess['delete'];
|
||||
$result[$key]['add'] = (int) $profileAccess['add'];
|
||||
$result[$key]['edit'] = (int) $profileAccess['edit'];
|
||||
$result[$key]['kpi'] = (int) $profileAccess['kpi'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -367,12 +367,12 @@ class SpecificPriceCore extends ObjectModel
|
||||
`id_shop` '.self::formatIntInQuery(0, $id_shop).' AND
|
||||
`id_currency` '.self::formatIntInQuery(0, $id_currency).' AND
|
||||
`id_country` '.self::formatIntInQuery(0, $id_country).
|
||||
' AND `id_htl_cart_booking`='.(int)$id_htl_cart_booking.' '.
|
||||
' AND `id_htl_cart_booking` '.self::formatIntInQuery(0, $id_htl_cart_booking).' '.
|
||||
(Group::isFeatureActive() ? ' AND `id_group` '.self::formatIntInQuery(0, $id_group) : '').' '.$query_extra.'
|
||||
AND IF(`from_quantity` > 1, `from_quantity`, 0) <= ';
|
||||
|
||||
$query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity);
|
||||
$query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `score` DESC, `to` DESC, `from` DESC';
|
||||
$query .= ' ORDER BY `id_htl_cart_booking` DESC, `id_product_attribute` DESC, `from_quantity` DESC, `score` DESC, `to` DESC, `from` DESC';
|
||||
|
||||
SpecificPrice::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||
}
|
||||
|
||||
@@ -137,12 +137,12 @@ class TabCore extends ObjectModel
|
||||
}
|
||||
|
||||
/* Query definition */
|
||||
$query = 'REPLACE INTO `'._DB_PREFIX_.'access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ';
|
||||
$query .= '(1, '.(int)$id_tab.', 1, 1, 1, 1),';
|
||||
$query = 'REPLACE INTO `'._DB_PREFIX_.'access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`, `kpi`) VALUES ';
|
||||
$query .= '(1, '.(int)$id_tab.', 1, 1, 1, 1, 1),';
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
$rights = $profile['id_profile'] == $context->employee->id_profile ? 1 : 0;
|
||||
$query .= '('.(int)$profile['id_profile'].', '.(int)$id_tab.', '.(int)$rights.', '.(int)$rights.', '.(int)$rights.', '.(int)$rights.'),';
|
||||
$query .= '('.(int)$profile['id_profile'].', '.(int)$id_tab.', '.(int)$rights.', '.(int)$rights.', '.(int)$rights.', '.(int)$rights.', '.(int)$rights.'),';
|
||||
}
|
||||
$query = trim($query, ', ');
|
||||
return Db::getInstance()->execute($query);
|
||||
@@ -247,7 +247,7 @@ class TabCore extends ObjectModel
|
||||
* @return array tabs
|
||||
*/
|
||||
protected static $_cache_tabs = array();
|
||||
public static function getTabs($id_lang, $id_parent = null)
|
||||
public static function getTabs($id_lang, $id_parent = null, $include_kpi = false)
|
||||
{
|
||||
if (!isset(self::$_cache_tabs[$id_lang])) {
|
||||
self::$_cache_tabs[$id_lang] = array();
|
||||
@@ -274,10 +274,52 @@ class TabCore extends ObjectModel
|
||||
foreach (self::$_cache_tabs[$id_lang] as $array_parent) {
|
||||
$array_all = array_merge($array_all, $array_parent);
|
||||
}
|
||||
return $array_all;
|
||||
$tabs = $array_all;
|
||||
} else {
|
||||
$tabs = isset(self::$_cache_tabs[$id_lang][$id_parent]) ? self::$_cache_tabs[$id_lang][$id_parent] : array();
|
||||
}
|
||||
|
||||
return (isset(self::$_cache_tabs[$id_lang][$id_parent]) ? self::$_cache_tabs[$id_lang][$id_parent] : array());
|
||||
if ($include_kpi) {
|
||||
$hookKpiClasses = array();
|
||||
$hookRows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT SUBSTRING(h.`name`, 7, LENGTH(h.`name`) - 24) AS `class_name`
|
||||
FROM `'._DB_PREFIX_.'hook` h
|
||||
INNER JOIN `'._DB_PREFIX_.'hook_module` hm
|
||||
ON hm.`id_hook` = h.`id_hook`
|
||||
AND hm.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||
INNER JOIN `'._DB_PREFIX_.'module` m
|
||||
ON m.`id_module` = hm.`id_module` AND m.`active` = 1
|
||||
WHERE h.`name` LIKE \'action%KPIListingModifier\''
|
||||
);
|
||||
if (is_array($hookRows)) {
|
||||
foreach ($hookRows as $row) {
|
||||
$hookKpiClasses[$row['class_name']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($tabs as &$tab) {
|
||||
if (!empty($tab['module'])) {
|
||||
$file = _PS_MODULE_DIR_.$tab['module'].'/controllers/admin/'.$tab['class_name'].'Controller.php';
|
||||
$class_name = $tab['class_name'].'Controller';
|
||||
} else {
|
||||
$file = _PS_CONTROLLER_DIR_.'admin/'.$tab['class_name'].'Controller.php';
|
||||
$class_name = $tab['class_name'].'ControllerCore';
|
||||
}
|
||||
if (file_exists($file) && !class_exists($class_name)) {
|
||||
require_once $file;
|
||||
}
|
||||
try {
|
||||
$objreflect = new ReflectionMethod($class_name, 'renderKpis');
|
||||
$tab['has_kpi'] = ($objreflect->getDeclaringClass()->getName() === $class_name)
|
||||
|| isset($hookKpiClasses[$tab['class_name']]);
|
||||
} catch (ReflectionException $e) {
|
||||
$tab['has_kpi'] = isset($hookKpiClasses[$tab['class_name']]);
|
||||
}
|
||||
}
|
||||
unset($tab);
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2307,7 +2307,9 @@ class AdminControllerCore extends Controller
|
||||
$this->content .= $this->renderDetails();
|
||||
} elseif (!$this->ajax) {
|
||||
$this->content .= $this->renderModulesList();
|
||||
$this->content .= $this->renderKpis();
|
||||
if ($this->tabAccess['kpi'] === 1) {
|
||||
$this->content .= $this->renderKpis();
|
||||
}
|
||||
$this->content .= $this->renderList();
|
||||
$this->content .= $this->renderOptions();
|
||||
|
||||
|
||||
@@ -1905,7 +1905,15 @@ class OrderCore extends ObjectModel
|
||||
$order_payment_detail->id_order = $this->id;
|
||||
$order_payment_detail->id_order_payment = (int)$payment->id;
|
||||
$order_payment_detail->amount = $amount;
|
||||
$receipt_number = Configuration::get('PS_PAYMENT_RECEIPTS_START_NUMBER', null, null, $this->id_shop);
|
||||
// If payment start number has been set, you clean the value of this configuration
|
||||
if ($receipt_number) {
|
||||
Configuration::updateValue('PS_PAYMENT_RECEIPTS_START_NUMBER', false, false, null, $this->id_shop);
|
||||
}else{
|
||||
$receipt_number = OrderPaymentDetail::getLastPaymentReceiptNumber() + 1;
|
||||
}
|
||||
|
||||
$order_payment_detail->receipt_number = $receipt_number;
|
||||
if ($payment->id_currency == $this->id_currency) {
|
||||
$this->total_paid_real += $order_payment_detail->amount;
|
||||
} else {
|
||||
@@ -1935,6 +1943,8 @@ class OrderCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the correct product taxes breakdown.
|
||||
*
|
||||
@@ -3148,4 +3158,26 @@ class OrderCore extends ObjectModel
|
||||
|
||||
return $totalOrder;
|
||||
}
|
||||
|
||||
public function getPaymentsTypes()
|
||||
{
|
||||
$module = Module::getInstanceByName('hotelreservationsystem');
|
||||
return array(
|
||||
OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL => array(
|
||||
'key' => 'PAYMENT_TYPE_PAY_AT_HOTEL',
|
||||
'value' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
|
||||
'name' => $module->l('Pay at hotel')
|
||||
),
|
||||
OrderPayment::PAYMENT_TYPE_ONLINE => array(
|
||||
'key' => 'PAYMENT_TYPE_ONLINE',
|
||||
'value' => OrderPayment::PAYMENT_TYPE_ONLINE,
|
||||
'name' => $module->l('Online')
|
||||
),
|
||||
OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT => array(
|
||||
'key' => 'PAYMENT_TYPE_REMOTE_PAYMENT',
|
||||
'value' => OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT,
|
||||
'name' => $module->l('Remote payment')
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,4 +159,5 @@ class OrderPaymentCore extends ObjectModel
|
||||
{
|
||||
return Db::getInstance()->getValue('SELECT (SUM(`amount` * `conversion_rate`) / SUM(`amount`)) FROM `'._DB_PREFIX_.'order_payment` WHERE `order_reference` = \''.pSQL($order_reference).'\' AND `id_currency` = '.(int)$idCurrency);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ class OrderPaymentDetailCore extends ObjectModel
|
||||
public $id_order_payment;
|
||||
public $id_order;
|
||||
public $amount;
|
||||
public $receipt_number;
|
||||
public $date_add;
|
||||
|
||||
public static $definition = array(
|
||||
@@ -35,6 +36,7 @@ class OrderPaymentDetailCore extends ObjectModel
|
||||
'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),
|
||||
'receipt_number' => array('type' => self::TYPE_INT, 'validate' => 'isGenericName', 'size' => 64),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
)
|
||||
);
|
||||
@@ -71,4 +73,49 @@ class OrderPaymentDetailCore extends ObjectModel
|
||||
WHERE oip.`id_order_invoice` = '.(int)$id_invoice
|
||||
);
|
||||
}
|
||||
|
||||
public static function getLastPaymentReceiptNumber()
|
||||
{
|
||||
$sql = 'SELECT MAX(`receipt_number`) FROM `'._DB_PREFIX_.'order_payment_detail`';
|
||||
if (Configuration::get('PS_PAYMENT_RECEIPTS_RESET')) {
|
||||
$sql .= ' WHERE DATE_FORMAT(`date_add`, "%Y") = '.(int)date('Y');
|
||||
}
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
public static function getPaymentDetailsByPaymentId($id_order_payment)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'order_payment_detail`
|
||||
WHERE `id_order_payment` = '.(int)$id_order_payment
|
||||
);
|
||||
}
|
||||
|
||||
public static function getByDateInterval($date_from, $date_to)
|
||||
{
|
||||
$payment_list = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT opd.*
|
||||
FROM `'._DB_PREFIX_.'order_payment_detail` opd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = opd.`id_order`)
|
||||
WHERE DATE_ADD(opd.`date_add`, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
|
||||
AND opd.`date_add` >= \''.pSQL($date_from).'\'
|
||||
AND opd.`receipt_number` > 0
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
||||
ORDER BY opd.`date_add` ASC, opd.`id_order_payment_detail` ASC
|
||||
');
|
||||
|
||||
return ObjectModel::hydrateCollection('OrderPaymentDetail', $payment_list);
|
||||
}
|
||||
|
||||
public function getPaymentReceiptNumberFormated($id_lang, $id_shop = null)
|
||||
{
|
||||
$format = '%1$s%2$06d';
|
||||
|
||||
if (Configuration::get('PS_PAYMENT_RECEIPTS_USE_YEAR')) {
|
||||
$format = '%1$s%2$06d/%3$s';
|
||||
}
|
||||
|
||||
return sprintf($format, Configuration::get('PS_PAYMENT_RECEIPTS_PREFIX', (int)$id_lang, null, (int)$id_shop), $this->receipt_number, date('Y', strtotime($this->date_add)));
|
||||
}
|
||||
}
|
||||
|
||||
396
classes/pdf/HTMLTemplateBookingVoucher.php
Normal file
396
classes/pdf/HTMLTemplateBookingVoucher.php
Normal file
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/license/osl-3.0-php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to support@qloapps.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to a 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 Since 2010 Webkul
|
||||
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds and renders the Booking Voucher PDF for a given Order.
|
||||
* Data assembly follows the same inline pattern as HTMLTemplateInvoice::getContent().
|
||||
*/
|
||||
class HTMLTemplateBookingVoucherCore extends HTMLTemplate
|
||||
{
|
||||
/** @var Order */
|
||||
public $order;
|
||||
public $available_in_your_account = false;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param Smarty $smarty
|
||||
*/
|
||||
public function __construct(Order $order, $smarty)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->smarty = $smarty;
|
||||
$this->date = Tools::displayDate(date('Y-m-d'));
|
||||
$this->title = sprintf(self::l('Booking Voucher - %s'), $this->order->reference);
|
||||
$this->shop = new Shop((int)$this->order->id_shop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string HTML header
|
||||
*/
|
||||
public function getHeader()
|
||||
{
|
||||
$this->assignCommonHeaderData();
|
||||
$this->smarty->assign(array('header' => self::l('Booking Voucher')));
|
||||
|
||||
return $this->smarty->fetch($this->getTemplate('header'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles all voucher data inline and renders the template.
|
||||
*
|
||||
* @return string HTML content
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
// --- Bookings ---
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
$bookings = $objHotelBookingDetail->getBookingDataByOrderId((int)$this->order->id);
|
||||
if (!is_array($bookings)) {
|
||||
$bookings = array();
|
||||
}
|
||||
|
||||
// --- Order state ---
|
||||
$orderState = $this->order->getCurrentStateFull((int)$this->order->id_lang);
|
||||
|
||||
// --- Hotel / property ---
|
||||
$objHotel = null;
|
||||
$idHotel = HotelBookingDetail::getIdHotelByIdOrder((int)$this->order->id);
|
||||
if ($idHotel) {
|
||||
$objHotel = new HotelBranchInformation((int)$idHotel, (int)$this->order->id_lang);
|
||||
if (!Validate::isLoadedObject($objHotel)) {
|
||||
$objHotel = null;
|
||||
}
|
||||
}
|
||||
|
||||
$hotelAddress = '';
|
||||
$paymentPolicy = '';
|
||||
$cancellationPolicy = '';
|
||||
|
||||
if ($objHotel) {
|
||||
$policies = is_array($objHotel->policies) ? '' : (string)$objHotel->policies;
|
||||
if ($policies) {
|
||||
$policyText = html_entity_decode($policies, ENT_QUOTES, 'UTF-8');
|
||||
$policyText = preg_replace('/<br\\s*\\/?>/i', "\n", $policyText);
|
||||
$policyText = strip_tags($policyText);
|
||||
$policyText = preg_replace("/[\r\n]+/", "\n", $policyText);
|
||||
$paymentPolicy = nl2br(trim($policyText));
|
||||
}
|
||||
|
||||
$objBranchRefundRules = new HotelBranchRefundRules();
|
||||
$refundRules = $objBranchRefundRules->getHotelRefundRules(
|
||||
(int)$objHotel->id, 0, 1, (int)$this->order->id_lang, 1
|
||||
);
|
||||
if (is_array($refundRules) && !empty($refundRules)) {
|
||||
$policyBlocks = array();
|
||||
foreach ($refundRules as $rule) {
|
||||
$ruleName = isset($rule['name']) ? trim(strip_tags($rule['name'])) : '';
|
||||
$ruleDescription = isset($rule['description']) ? trim($rule['description']) : '';
|
||||
if ($ruleName === '' && $ruleDescription === '') {
|
||||
continue;
|
||||
}
|
||||
$block = $ruleName !== '' ? '<strong>'.Tools::safeOutput($ruleName).'</strong>' : '';
|
||||
if ($ruleDescription !== '') {
|
||||
$block .= ($block !== '' ? ': ' : '').$ruleDescription;
|
||||
}
|
||||
$policyBlocks[] = $block;
|
||||
}
|
||||
if (!empty($policyBlocks)) {
|
||||
$cancellationPolicy = implode('<br /><br />', $policyBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
if ($idHotelAddress = $objHotel->getHotelIdAddress()) {
|
||||
$objHotelAddress = new Address((int)$idHotelAddress);
|
||||
if (Validate::isLoadedObject($objHotelAddress)) {
|
||||
$objHotelAddress->firstname = $objHotel->hotel_name;
|
||||
$hotelAddress = AddressFormat::generateAddress(
|
||||
$objHotelAddress,
|
||||
array('avoid' => array('lastname')),
|
||||
'<br />',
|
||||
' '
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Rooms, services, occupancy ---
|
||||
$totalRooms = 0;
|
||||
$totalRoomNights = 0;
|
||||
$totalGuests = 0;
|
||||
$serviceGroups = array();
|
||||
$roomTypeRows = array();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
$nights = (int)HotelHelper::getNumberOfDays($booking['date_from'], $booking['date_to']);
|
||||
if ($nights <= 0) {
|
||||
$nights = 1;
|
||||
}
|
||||
|
||||
$totalGuests += (int)$booking['adults'] + (int)$booking['children'];
|
||||
$totalRoomNights += $nights;
|
||||
$totalRooms++;
|
||||
|
||||
$dateFrom = ($booking['date_from'] && $booking['date_from'] !== '0000-00-00 00:00:00')
|
||||
? Tools::displayDate($booking['date_from'], null, false) : '--';
|
||||
$dateTo = ($booking['date_to'] && $booking['date_to'] !== '0000-00-00 00:00:00')
|
||||
? Tools::displayDate($booking['date_to'], null, false) : '--';
|
||||
|
||||
// Services for this booking
|
||||
$bookingServices = array();
|
||||
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
$extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
(int)$this->order->id, 0, 0, 0, 0, 0, 0, 0,
|
||||
(int)$booking['id'], (int)$booking['id_order_detail']
|
||||
);
|
||||
if (is_array($extraDemands)) {
|
||||
foreach ($extraDemands as $demand) {
|
||||
$bookingServices[] = array('name' => $demand['name'], 'quantity' => 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-added services bundled with room price (for cost calculation only)
|
||||
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
|
||||
$autoAddedWithRoomPriceTaxExcl = (float)$objServiceProductOrderDetail->getRoomTypeServiceProducts(
|
||||
(int)$this->order->id, 0, 0,
|
||||
isset($booking['id_product']) ? (int)$booking['id_product'] : 0,
|
||||
isset($booking['date_from']) ? $booking['date_from'] : 0,
|
||||
isset($booking['date_to']) ? $booking['date_to'] : 0,
|
||||
isset($booking['id_room']) ? (int)$booking['id_room'] : 0,
|
||||
1, 0, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
|
||||
// Additional services chosen by guest
|
||||
$additionalServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts(
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, null, 0, (int)$booking['id']
|
||||
);
|
||||
if (isset($additionalServices[(int)$booking['id']]['additional_services'])) {
|
||||
foreach ($additionalServices[(int)$booking['id']]['additional_services'] as $service) {
|
||||
$bookingServices[] = array('name' => $service['name'], 'quantity' => (int)$service['quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($bookingServices)) {
|
||||
$serviceGroups[] = array(
|
||||
'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '',
|
||||
'check_in_date' => $dateFrom,
|
||||
'check_out_date' => $dateTo,
|
||||
'room_count' => $totalRooms,
|
||||
'services' => $bookingServices,
|
||||
);
|
||||
}
|
||||
|
||||
$roomTotalWithAutoServicesTaxExcl = (float)$booking['total_price_tax_excl'] + $autoAddedWithRoomPriceTaxExcl;
|
||||
|
||||
// Aggregate per room type + date range
|
||||
$roomTypeRowKey = implode('|', array(
|
||||
(int)$booking['id_order_detail'],
|
||||
isset($booking['room_type_name']) ? $booking['room_type_name'] : '',
|
||||
isset($booking['date_from']) ? $booking['date_from'] : '',
|
||||
isset($booking['date_to']) ? $booking['date_to'] : '',
|
||||
));
|
||||
|
||||
if (!isset($roomTypeRows[$roomTypeRowKey])) {
|
||||
$idOrderDetail = (int)$booking['id_order_detail'];
|
||||
$detailTaxes = $idOrderDetail ? OrderDetail::getTaxListStatic($idOrderDetail) : null;
|
||||
$orderDetailTaxLabel = self::l('No tax');
|
||||
if ($detailTaxes) {
|
||||
$taxTemp = array();
|
||||
foreach ($detailTaxes as $tax) {
|
||||
$objTax = new Tax($tax['id_tax']);
|
||||
$taxTemp[] = sprintf(self::l('%1$s%2$s%%'), $objTax->rate + 0, ' ');
|
||||
}
|
||||
$orderDetailTaxLabel = implode(', ', $taxTemp);
|
||||
}
|
||||
|
||||
$roomTypeRows[$roomTypeRowKey] = array(
|
||||
'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '',
|
||||
'order_detail_tax_label' => $orderDetailTaxLabel,
|
||||
'rooms' => 0,
|
||||
'adults' => 0,
|
||||
'children' => 0,
|
||||
'nights' => $nights,
|
||||
'check_in_date' => $dateFrom,
|
||||
'check_out_date' => $dateTo,
|
||||
'unit_price_tax_excl' => 0,
|
||||
'total_price_tax_excl' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
$roomTypeRows[$roomTypeRowKey]['rooms'] += 1;
|
||||
$roomTypeRows[$roomTypeRowKey]['adults'] += (int)$booking['adults'];
|
||||
$roomTypeRows[$roomTypeRowKey]['children'] += (int)$booking['children'];
|
||||
$roomTypeRows[$roomTypeRowKey]['total_price_tax_excl'] += $roomTotalWithAutoServicesTaxExcl;
|
||||
}
|
||||
|
||||
foreach ($roomTypeRows as &$roomTypeRow) {
|
||||
$denominator = (int)$roomTypeRow['nights'] * (int)$roomTypeRow['rooms'];
|
||||
if ($denominator > 0) {
|
||||
$roomTypeRow['unit_price_tax_excl'] = Tools::ps_round(
|
||||
$roomTypeRow['total_price_tax_excl'] / $denominator,
|
||||
6,
|
||||
$this->order->round_mode
|
||||
);
|
||||
}
|
||||
}
|
||||
unset($roomTypeRow);
|
||||
|
||||
$guestAddress = '';
|
||||
$guest = new Customer((int)$this->order->id_customer);
|
||||
|
||||
$addressId = (int)$this->order->id_address_invoice ?: (int)$this->order->id_address_delivery;
|
||||
if ($addressId) {
|
||||
$address = new Address($addressId);
|
||||
if (Validate::isLoadedObject($address)) {
|
||||
$guestAddress = AddressFormat::generateAddress($address, array(), '<br />', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
if ($idCustomerGuestDetail = OrderCustomerGuestDetail::isCustomerGuestBooking((int)$this->order->id)) {
|
||||
$objGuest = new OrderCustomerGuestDetail((int)$idCustomerGuestDetail);
|
||||
if (Validate::isLoadedObject($objGuest)) {
|
||||
$guest = $objGuest;
|
||||
}
|
||||
}
|
||||
// --- Totals ---
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
$totalDemandsPriceTE = (float)$objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
(int)$this->order->id, 0, 0, 0, 0, 1, 1, 0
|
||||
);
|
||||
$totalDemandsPriceTI = (float)$objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
(int)$this->order->id, 0, 0, 0, 0, 1, 1, 1
|
||||
);
|
||||
|
||||
$orderDetails = OrderDetail::getList((int)$this->order->id);
|
||||
$idsOrderDetail = is_array($orderDetails)
|
||||
? array_unique(array_map('intval', array_column($orderDetails, 'id_order_detail')))
|
||||
: array();
|
||||
|
||||
$footer = array(
|
||||
'room_price_tax_excl' => 0,
|
||||
'service_products_price_tax_excl' => 0,
|
||||
'additional_service_price_tax_excl' => 0,
|
||||
'total_convenience_fee_te' => 0,
|
||||
);
|
||||
$roomsCostTaxIncl = 0;
|
||||
$serviceProductsCostTaxIncl = 0;
|
||||
$additionalServicesCostTaxIncl = 0;
|
||||
$convenienceFeeTaxIncl = 0;
|
||||
|
||||
if (!empty($idsOrderDetail)) {
|
||||
$footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail);
|
||||
$roomsCostTaxIncl = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail);
|
||||
$footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail);
|
||||
$serviceProductsCostTaxIncl = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail);
|
||||
$footer['additional_service_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTE;
|
||||
$additionalServicesCostTaxIncl = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTI;
|
||||
$footer['total_convenience_fee_te'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail);
|
||||
$convenienceFeeTaxIncl = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail);
|
||||
}
|
||||
|
||||
$productDiscountsTaxIncl = (float)$this->order->total_discounts_tax_incl;
|
||||
foreach ($this->order->getCartRules() as $cartRule) {
|
||||
if (!empty($cartRule['free_shipping'])) {
|
||||
$productDiscountsTaxIncl -= (float)$this->order->total_shipping_tax_incl;
|
||||
}
|
||||
}
|
||||
if ($productDiscountsTaxIncl < 0) {
|
||||
$productDiscountsTaxIncl = 0;
|
||||
}
|
||||
|
||||
$footer['total_without_discount_te'] = $footer['room_price_tax_excl'] + $footer['total_convenience_fee_te'] + $footer['additional_service_price_tax_excl'] + $footer['service_products_price_tax_excl'];
|
||||
$totalWithoutDiscountTaxIncl = $roomsCostTaxIncl + $serviceProductsCostTaxIncl + $additionalServicesCostTaxIncl + $convenienceFeeTaxIncl;
|
||||
$footer['total_tax_without_discount'] = max(0, $totalWithoutDiscountTaxIncl - $footer['total_without_discount_te']);
|
||||
$grandTotal = max(0.0, $totalWithoutDiscountTaxIncl - $productDiscountsTaxIncl);
|
||||
$footer['product_discounts_tax_incl'] = $productDiscountsTaxIncl;
|
||||
$footer['total_paid_tax_incl'] = $grandTotal;
|
||||
$footer['amount_due'] = Tools::ps_round(
|
||||
max(0, $grandTotal - (float)$this->order->getTotalPaid()),
|
||||
_PS_PRICE_COMPUTE_PRECISION_,
|
||||
$this->order->round_mode
|
||||
);
|
||||
|
||||
$paymentMethods = array();
|
||||
$payments = $this->order->getOrderPaymentDetail();
|
||||
if (is_array($payments) && $payments) {
|
||||
foreach ($payments as $paymentDetail) {
|
||||
$method = isset($paymentDetail['payment_method']) ? trim($paymentDetail['payment_method']) : '';
|
||||
if (!$method) {
|
||||
$method = $this->order->payment;
|
||||
}
|
||||
$amount = isset($paymentDetail['real_paid_amount'])
|
||||
? (float)$paymentDetail['real_paid_amount']
|
||||
: (float)$paymentDetail['amount'];
|
||||
$idCurrency = isset($paymentDetail['id_currency'])
|
||||
? (int)$paymentDetail['id_currency']
|
||||
: (int)$this->order->id_currency;
|
||||
$paymentMethods[] = $method.': '.Tools::displayPrice($amount, $idCurrency);
|
||||
}
|
||||
}
|
||||
$paymentMethod = $paymentMethods ? implode('<br /><br /> ', $paymentMethods) : $this->order->payment;
|
||||
|
||||
$data = array(
|
||||
'order' => $this->order,
|
||||
'order_state' => $orderState,
|
||||
'booking_date' => Tools::displayDate($this->order->date_add, null, false),
|
||||
'issue_date' => Tools::displayDate(date('Y-m-d'), null, false),
|
||||
'hotel' => $objHotel,
|
||||
'hotel_address' => $hotelAddress,
|
||||
'guest' => $guest,
|
||||
'guest_address' => $guestAddress,
|
||||
'total_guests' => (int)$totalGuests,
|
||||
'total_rooms' => (int)$totalRooms,
|
||||
'total_room_nights' => (int)$totalRoomNights,
|
||||
'room_type_rows' => array_values($roomTypeRows),
|
||||
'service_groups' => $serviceGroups,
|
||||
'payment_method' => $paymentMethod,
|
||||
'footer' => $footer,
|
||||
'payment_policy' => $paymentPolicy,
|
||||
'cancellation_policy' => $cancellationPolicy,
|
||||
);
|
||||
|
||||
if (Tools::getValue('debug')) {
|
||||
die(json_encode($data));
|
||||
}
|
||||
$this->smarty->assign($data);
|
||||
|
||||
return $this->smarty->fetch($this->getTemplate('booking-voucher'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBulkFilename()
|
||||
{
|
||||
return self::l('BookingVouchers').'.pdf';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
return sprintf(self::l('BOOKING VOUCHER - Refrence No. #%s.pdf'), $this->order->reference);
|
||||
}
|
||||
}
|
||||
@@ -474,8 +474,32 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$fullDate = (isset($context->controller->show_full_date) && $context->controller->show_full_date && (date('Y-m-d', strtotime($data_v['date_from'])) == date('Y-m-d', strtotime($data_v['date_to'])))) ? true : false;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = Tools::displayDate($data_v['date_from'], null, $fullDate);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = Tools::displayDate($data_v['date_to'], null, $fullDate);
|
||||
$display_date_from = $data_v['date_from'];
|
||||
$display_date_to = $data_v['date_to'];
|
||||
if ((int)$data_v['id_status'] === HotelBookingDetail::STATUS_CHECKED_OUT) {
|
||||
if ($data_v['check_in']) {
|
||||
$display_date_from = $data_v['check_in'];
|
||||
}
|
||||
if ($data_v['check_out']) {
|
||||
$display_date_to = $data_v['check_out'];
|
||||
}
|
||||
} elseif ((int)$data_v['id_status'] === HotelBookingDetail::STATUS_CHECKED_IN) {
|
||||
if ($data_v['check_in']) {
|
||||
$display_date_from = $data_v['check_in'];
|
||||
}
|
||||
if ($data_v['check_out_time']) {
|
||||
$display_date_to = date('Y-m-d', strtotime($data_v['date_to'])) . ' ' . date('H:i:s', strtotime($data_v['check_out_time']));
|
||||
}
|
||||
} else {
|
||||
if ($data_v['check_in_time']) {
|
||||
$display_date_from = date('Y-m-d', strtotime($data_v['date_from'])) . ' ' . date('H:i:s', strtotime($data_v['check_in_time']));
|
||||
}
|
||||
if ($data_v['check_out_time']) {
|
||||
$display_date_to = date('Y-m-d', strtotime($data_v['date_to'])) . ' ' . date('H:i:s', strtotime($data_v['check_out_time']));
|
||||
}
|
||||
}
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = Tools::displayDate($display_date_from, null, true);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = Tools::displayDate($display_date_to, null, true);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['children'] = $data_v['children'];
|
||||
|
||||
171
classes/pdf/HTMLTemplatePaymentReceipt.php
Normal file
171
classes/pdf/HTMLTemplatePaymentReceipt.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/license/osl-3-0-php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to support@qloapps.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to a 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 Since 2010 Webkul
|
||||
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.5
|
||||
*/
|
||||
class HTMLTemplatePaymentReceiptCore extends HTMLTemplate
|
||||
{
|
||||
public $paymentReceipt;
|
||||
public $orderPayment;
|
||||
public $order;
|
||||
/**
|
||||
* @param OrderPaymentDetail $paymentReceipt
|
||||
* @param $smarty
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function __construct(OrderPaymentDetail $paymentReceipt, $smarty, $bulk_mode = false)
|
||||
{
|
||||
$this->paymentReceipt = $paymentReceipt;
|
||||
$this->smarty = $smarty;
|
||||
$this->date = Tools::displayDate($this->paymentReceipt->date_add);
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$this->orderPayment = new OrderPayment((int)$this->paymentReceipt->id_order_payment);
|
||||
if (!Validate::isLoadedObject($this->orderPayment)) {
|
||||
throw new PrestaShopException('Cannot load the payment associated with this payment receipt.');
|
||||
}
|
||||
|
||||
$this->order = new Order((int)$this->paymentReceipt->id_order);
|
||||
|
||||
if (!Validate::isLoadedObject($this->order)) {
|
||||
throw new PrestaShopException('Cannot load the order associated with this payment receipt.');
|
||||
}
|
||||
|
||||
$id_shop = (int)$this->order->id_shop;
|
||||
$this->shop = new Shop($id_shop);
|
||||
$this->orderPayment->amount = $this->paymentReceipt->amount;
|
||||
$this->title = $this->paymentReceipt->getPaymentReceiptNumberFormated($id_lang, $id_shop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the template's HTML header
|
||||
*
|
||||
* @return string HTML header
|
||||
*/
|
||||
public function getHeader()
|
||||
{
|
||||
$this->assignCommonHeaderData();
|
||||
$this->smarty->assign(array(
|
||||
'header' => HTMLTemplatePaymentReceipt::l('Receipt'),
|
||||
));
|
||||
|
||||
return $this->smarty->fetch($this->getTemplate('header'));
|
||||
}
|
||||
|
||||
public function getFooter()
|
||||
{
|
||||
$shop_address = $this->getShopAddress();
|
||||
|
||||
$id_shop = (int)$this->shop->id;
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'shop_address' => $shop_address,
|
||||
'shop_fax' => Configuration::get('PS_SHOP_FAX', null, null, $id_shop),
|
||||
'shop_phone' => Configuration::get('PS_SHOP_PHONE', null, null, $id_shop),
|
||||
'shop_email' => Configuration::get('PS_SHOP_EMAIL', null, null, $id_shop),
|
||||
'free_text' => Configuration::get('PS_PAYMENT_RECEIPTS_FREE_TEXT', (int)Context::getContext()->language->id, null, $id_shop)
|
||||
));
|
||||
|
||||
return $this->smarty->fetch($this->getTemplate('footer'));
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$delivery_address = $invoice_address = new Address((int)$this->order->id_address_invoice);
|
||||
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
|
||||
$formatted_delivery_address = '';
|
||||
|
||||
if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
|
||||
$delivery_address = new Address((int)$this->order->id_address_delivery);
|
||||
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
|
||||
}
|
||||
|
||||
$formattedHotelAddress = '';
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($this->order->id)) {
|
||||
$objHotelBranchInfo = new HotelBranchInformation((int) $idHotel, Context::getContext()->language->id);
|
||||
$invoiceAddressPatternRules['avoid'][] = 'lastname';
|
||||
if ($idHotelAddress = $objHotelBranchInfo->getHotelIdAddress()) {
|
||||
$objHotelAddress = new Address((int) $idHotelAddress);
|
||||
$objHotelAddress->firstname = $objHotelBranchInfo->hotel_name;
|
||||
$formattedHotelAddress = AddressFormat::generateAddress($objHotelAddress, $invoiceAddressPatternRules, '<br />', ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
$customer = new Customer((int)$this->order->id_customer);
|
||||
$getPaymentTypes = $this->order->getPaymentsTypes();
|
||||
$this->orderPayment->payment_type = isset($getPaymentTypes[$this->orderPayment->payment_type]) ? $getPaymentTypes[$this->orderPayment->payment_type] : null;
|
||||
|
||||
$legal_free_text = Configuration::get('PS_PAYMENT_RECEIPTS_LEGAL_FREE_TEXT', (int)Context::getContext()->language->id, null, (int)$this->order->id_shop);
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'order' => $this->order,
|
||||
'payment_list' => array($this->orderPayment),
|
||||
'delivery_address' => $formatted_delivery_address,
|
||||
'invoice_address' => $formatted_invoice_address,
|
||||
'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address),
|
||||
'customer' => $customer,
|
||||
'hotel_address' => $formattedHotelAddress,
|
||||
'legal_free_text' => $legal_free_text,
|
||||
));
|
||||
|
||||
$smarty_tpls = array(
|
||||
'style_tab' => $this->smarty->fetch($this->getTemplate('payment-receipt.style-tab')),
|
||||
'addresses_tab' => $this->smarty->fetch($this->getTemplate('payment-receipt.addresses-tab')),
|
||||
'payment_info_tab' => $this->smarty->fetch($this->getTemplate('payment-receipt.payment-info-tab')),
|
||||
);
|
||||
$this->smarty->assign($smarty_tpls);
|
||||
return $this->smarty->fetch($this->getTemplate('payment-receipt'));
|
||||
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return 'payment-receipt-'.sprintf('%06d', $this->paymentReceipt->id).'.pdf';
|
||||
}
|
||||
|
||||
public function getBulkFilename()
|
||||
{
|
||||
return 'payment-receipts.pdf';
|
||||
}
|
||||
|
||||
protected function getPaymentType($paymentType = null)
|
||||
{
|
||||
$paymentTypeName = null;
|
||||
switch ($paymentType) {
|
||||
case OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL:
|
||||
$paymentTypeName = HTMLTemplatePaymentReceipt::l('Pay at hotel');
|
||||
break;
|
||||
case OrderPayment::PAYMENT_TYPE_ONLINE:
|
||||
$paymentTypeName = HTMLTemplatePaymentReceipt::l('Online');
|
||||
break;
|
||||
case OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT:
|
||||
$paymentTypeName = HTMLTemplatePaymentReceipt::l('Remote payment');
|
||||
break;
|
||||
default:
|
||||
$paymentTypeName = null;
|
||||
break;
|
||||
}
|
||||
return $paymentTypeName;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ class PDFCore
|
||||
const TEMPLATE_ORDER_SLIP = 'OrderSlip';
|
||||
const TEMPLATE_DELIVERY_SLIP = 'DeliverySlip';
|
||||
const TEMPLATE_SUPPLY_ORDER_FORM = 'SupplyOrderForm';
|
||||
const TEMPLATE_BOOKING_VOUCHER = 'BookingVoucher';
|
||||
const TEMPLATE_PAYMENT_RECEIPT = 'PaymentReceipt';
|
||||
|
||||
/**
|
||||
* @param $objects
|
||||
|
||||
Reference in New Issue
Block a user