Merge branch 'develop' into gli-1096
This commit is contained in:
@@ -56,7 +56,7 @@ class AdminAccessControllerCore extends AdminController
|
||||
{
|
||||
$current_profile = (int)$this->getCurrentProfileId();
|
||||
$profiles = Profile::getProfiles($this->context->language->id);
|
||||
$tabs = Tab::getTabs($this->context->language->id);
|
||||
$tabs = Tab::getTabs($this->context->language->id, null, true);
|
||||
$accesses = array();
|
||||
foreach ($profiles as $profile) {
|
||||
$accesses[$profile['id_profile']] = Profile::getProfileAccesses($profile['id_profile']);
|
||||
@@ -214,7 +214,7 @@ class AdminAccessControllerCore extends AdminController
|
||||
|
||||
if (Tools::isSubmit('submitAddAccess')) {
|
||||
$perm = Tools::getValue('perm');
|
||||
if (!in_array($perm, array('view', 'add', 'edit', 'delete', 'all'))) {
|
||||
if (!in_array($perm, array('view', 'add', 'edit', 'delete', 'all', 'kpi'))) {
|
||||
throw new PrestaShopException('permission does not exist');
|
||||
}
|
||||
|
||||
|
||||
@@ -181,69 +181,85 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
public function renderKpis()
|
||||
{
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
$objCart = new Cart(Tools::getValue('id_cart'));
|
||||
if (Validate::isLoadedObject($objCart)) {
|
||||
$currency = new Currency($objCart->id_currency);
|
||||
$summary = $objCart->getSummaryDetails();
|
||||
$tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id);
|
||||
$total_price = ($tax_calculation_method == PS_TAX_EXC)
|
||||
? $summary['total_price_without_tax']
|
||||
: $summary['total_price'];
|
||||
|
||||
$daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-conversion-rate';
|
||||
$helper->icon = 'icon-sort-by-attributes-alt';
|
||||
//$helper->chart = true;
|
||||
$helper->color = 'color1';
|
||||
$helper->title = $this->l('Conversion Rate', null, null, false);
|
||||
if ($daysForConversionRate == 1) {
|
||||
$helper->subtitle = $daysForConversionRate.' '.$this->l('day', null, null, false);
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-kpi-cart';
|
||||
$helper->icon = 'icon-shopping-cart';
|
||||
$helper->color = 'color1';
|
||||
$helper->title = $this->l('Total Cart', null, null, false);
|
||||
$helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $objCart->id);
|
||||
$helper->value = Tools::displayPrice($total_price, $currency);
|
||||
$this->kpis[] = $helper;
|
||||
} else {
|
||||
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
|
||||
}
|
||||
if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) {
|
||||
$helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART');
|
||||
}
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
|
||||
$this->kpis[] = $helper;
|
||||
$daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-carts';
|
||||
$helper->icon = 'icon-shopping-cart';
|
||||
$helper->color = 'color2';
|
||||
$helper->title = $this->l('Abandoned Carts', null, null, false);
|
||||
$date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day'));
|
||||
$date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day'));
|
||||
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to);
|
||||
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.date('Y-m-d', strtotime('-2 day')).'&date_to='.date('Y-m-d', strtotime('-1 day'));
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
|
||||
$this->kpis[] = $helper;
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-conversion-rate';
|
||||
$helper->icon = 'icon-sort-by-attributes-alt';
|
||||
//$helper->chart = true;
|
||||
$helper->color = 'color1';
|
||||
$helper->title = $this->l('Conversion Rate', null, null, false);
|
||||
if ($daysForConversionRate == 1) {
|
||||
$helper->subtitle = $daysForConversionRate.' '.$this->l('day', null, null, false);
|
||||
} else {
|
||||
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
|
||||
}
|
||||
if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) {
|
||||
$helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART');
|
||||
}
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
|
||||
$this->kpis[] = $helper;
|
||||
|
||||
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-average-order';
|
||||
$helper->icon = 'icon-money';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Average Order Value', null, null, false);
|
||||
if ($daysForAvgOrderVal == 1) {
|
||||
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('day', null, null, false);
|
||||
} else {
|
||||
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-carts';
|
||||
$helper->icon = 'icon-shopping-cart';
|
||||
$helper->color = 'color2';
|
||||
$helper->title = $this->l('Abandoned Carts', null, null, false);
|
||||
$date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day'));
|
||||
$date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day'));
|
||||
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to);
|
||||
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.date('Y-m-d', strtotime('-2 day')).'&date_to='.date('Y-m-d', strtotime('-1 day'));
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
|
||||
$this->kpis[] = $helper;
|
||||
|
||||
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-average-order';
|
||||
$helper->icon = 'icon-money';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Average Order Value', null, null, false);
|
||||
if ($daysForAvgOrderVal == 1) {
|
||||
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('day', null, null, false);
|
||||
} else {
|
||||
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
|
||||
}
|
||||
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
|
||||
$this->kpis[] = $helper;
|
||||
|
||||
$daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS');
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-net-profit-visitor';
|
||||
$helper->icon = 'icon-user';
|
||||
$helper->color = 'color4';
|
||||
$helper->title = $this->l('Net Profit per Visitor', null, null, false);
|
||||
if ($daysForProfitPerVisitor == 1) {
|
||||
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('day', null, null, false);
|
||||
} else {
|
||||
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false);
|
||||
}
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit';
|
||||
$this->kpis[] = $helper;
|
||||
}
|
||||
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
|
||||
$this->kpis[] = $helper;
|
||||
|
||||
$daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS');
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-net-profit-visitor';
|
||||
$helper->icon = 'icon-user';
|
||||
$helper->color = 'color4';
|
||||
$helper->title = $this->l('Net Profit per Visitor', null, null, false);
|
||||
if ($daysForProfitPerVisitor == 1) {
|
||||
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('day', null, null, false);
|
||||
} else {
|
||||
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false);
|
||||
}
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit';
|
||||
$this->kpis[] = $helper;
|
||||
|
||||
return parent::renderKpis();
|
||||
}
|
||||
|
||||
@@ -254,6 +270,9 @@ class AdminCartsControllerCore extends AdminController
|
||||
if (!($cart = $this->loadObject(true))) {
|
||||
return;
|
||||
}
|
||||
if ($this->tabAccess['kpi'] === 1) {
|
||||
$this->content .= $this->renderKpis();
|
||||
}
|
||||
$customer = new Customer($cart->id_customer);
|
||||
$currency = new Currency($cart->id_currency);
|
||||
$this->context->cart = $cart;
|
||||
@@ -340,16 +359,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
$cartHtlData = array();
|
||||
}
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-kpi-cart';
|
||||
$helper->icon = 'icon-shopping-cart';
|
||||
$helper->color = 'color1';
|
||||
$helper->title = $this->l('Total Cart', null, null, false);
|
||||
$helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
|
||||
$helper->value = Tools::displayPrice($total_price, $currency);
|
||||
$kpi = $helper->generate();
|
||||
//end
|
||||
|
||||
// get standalone products in cart
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
$hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart(
|
||||
@@ -381,7 +390,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data
|
||||
'standalone_products' => $standaloneProducts,
|
||||
'hotel_products' => $hotelProducts,
|
||||
'kpi' => $kpi,
|
||||
'products' => $products,
|
||||
'discounts' => $cart->getCartRules(),
|
||||
'cart_orders' => $cartOrders,
|
||||
@@ -1121,7 +1129,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
if ($bookingInfo['id'] == $idBookingData) {
|
||||
$amtWithQty = $bookingInfo['amt_with_qty'];
|
||||
$bookingInfo['amt_with_qty'] = Tools::displayPrice($amtWithQty);
|
||||
$bookingInfo['total_price'] = Tools::displayPrice($amtWithQty + $bookingInfo['demand_price']);
|
||||
$bookingInfo['total_price'] = Tools::displayPrice($amtWithQty + $bookingInfo['demand_price'] + $bookingInfo['additional_service_price'] + $bookingInfo['additional_services_auto_add_price']);
|
||||
$response = array(
|
||||
'curr_booking_info' => $bookingInfo,
|
||||
'cart_info' => $this->ajaxReturnVars(),
|
||||
|
||||
@@ -168,6 +168,10 @@ class AdminDashboardControllerCore extends AdminController
|
||||
return parent::renderOptions();
|
||||
}
|
||||
|
||||
if ($this->tabAccess['kpi'] === 1) {
|
||||
$this->content .= $this->renderKpis();
|
||||
}
|
||||
|
||||
// $translations = array(
|
||||
// 'Calendar' => $this->l('Calendar', 'AdminStatsTab'),
|
||||
// 'Day' => $this->l('Day', 'AdminStatsTab'),
|
||||
|
||||
@@ -391,12 +391,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
);
|
||||
}
|
||||
|
||||
$this->page_header_toolbar_btn['print'] = array(
|
||||
'short' => $this->l('Print'),
|
||||
'href' => 'javascript:window.print()',
|
||||
'desc' => $this->l('Print order'),
|
||||
'class' => 'icon-print',
|
||||
);
|
||||
if (HotelBookingDetail::getIdHotelByIdOrder($order->id, false) && !$this->lite_display) {
|
||||
$this->page_header_toolbar_btn['booking_voucher'] = array(
|
||||
'short' => $this->l('Booking Voucher'),
|
||||
'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateBookingVoucherPDF&id_order='.$order->id,
|
||||
'desc' => $this->l('View booking voucher'),
|
||||
'class' => 'icon-file-text',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
if (((int) $order->isReturnable())
|
||||
@@ -467,7 +470,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$paymentTypes = array();
|
||||
foreach ($this->getPaymentsTypes() as $paymentType) {
|
||||
$objOrder = new Order();
|
||||
|
||||
foreach ($objOrder->getPaymentsTypes() as $paymentType) {
|
||||
if ($paymentType['value'] != OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT) {
|
||||
$paymentTypes[] = $paymentType;
|
||||
}
|
||||
@@ -682,7 +687,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'order' => $objOrder,
|
||||
'currencies' => $currencies,
|
||||
'payment_methods' => $payment_methods,
|
||||
'payment_types' => $this->getPaymentsTypes(),
|
||||
'payment_types' => $objOrder->getPaymentsTypes(),
|
||||
'invoices_collection' => $objOrder->getInvoicesCollection(),
|
||||
'current_id_lang' => $this->context->language->id,
|
||||
)
|
||||
@@ -3213,8 +3218,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (!Validate::isLoadedObject($order = new Order(Tools::getValue('id_order')))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->content .= $this->renderKpis();
|
||||
if ($this->tabAccess['kpi'] === 1) {
|
||||
$this->content .= $this->renderKpis();
|
||||
}
|
||||
|
||||
$customer = new Customer($order->id_customer);
|
||||
$carrier = new Carrier($order->id_carrier);
|
||||
@@ -3763,8 +3769,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'invoices_collection' => $order->getInvoicesCollection(),
|
||||
'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(),
|
||||
'payment_methods' => $payment_methods,
|
||||
'payment_types' => $this->getPaymentsTypes(),
|
||||
'payment_types' => $order->getPaymentsTypes(),
|
||||
'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop),
|
||||
'receipt_management_active' => Configuration::get('PS_PAYMENT_RECEIPTS', null, null, $order->id_shop),
|
||||
'display_warehouse' => (int)Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'),
|
||||
'HOOK_CONTENT_ORDER' => Hook::exec(
|
||||
'displayAdminOrderContentOrder',
|
||||
@@ -7273,26 +7280,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
return $products;
|
||||
}
|
||||
|
||||
protected function getPaymentsTypes()
|
||||
{
|
||||
return array(
|
||||
OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL => array(
|
||||
'key' => 'PAYMENT_TYPE_PAY_AT_HOTEL',
|
||||
'value' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
|
||||
'name' => $this->l('Pay at hotel')
|
||||
),
|
||||
OrderPayment::PAYMENT_TYPE_ONLINE => array(
|
||||
'key' => 'PAYMENT_TYPE_ONLINE',
|
||||
'value' => OrderPayment::PAYMENT_TYPE_ONLINE,
|
||||
'name' => $this->l('Online')
|
||||
),
|
||||
OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT => array(
|
||||
'key' => 'PAYMENT_TYPE_REMOTE_PAYMENT',
|
||||
'value' => OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT,
|
||||
'name' => $this->l('Remote payment')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderInvoice $order_invoice
|
||||
|
||||
192
controllers/admin/AdminPaymentReceiptsController.php
Normal file
192
controllers/admin/AdminPaymentReceiptsController.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
class AdminPaymentReceiptsControllerCore extends AdminControllerCore
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
parent::__construct();
|
||||
$this->context = Context::getContext();
|
||||
$this->lang = false;
|
||||
$this->table = 'order_payment';
|
||||
|
||||
$this->fields_options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Payment receipts options'),
|
||||
'fields' => array(
|
||||
'PS_PAYMENT_RECEIPTS' => array(
|
||||
'title' => $this->l('Enable Receipts'),
|
||||
'desc' => $this->l('If enabled, receipts will be generated for order payments.'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_PREFIX' => array(
|
||||
'title' => $this->l('Receipt prefix'),
|
||||
'desc' => $this->l('Prefix used for receipt name (e.g. #IN00001).'),
|
||||
'size' => 6,
|
||||
'type' => 'textLang'
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_USE_YEAR' => array(
|
||||
'title' => $this->l('Add current year to receipt number'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_RESET' => array(
|
||||
'title' => $this->l('Reset Receipt progressive number at beginning of the year'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_START_NUMBER' => array(
|
||||
'title' => $this->l('Receipt number'),
|
||||
'desc' => sprintf($this->l('The next receipt will begin with this number, and then increase with each additional receipt. Set to 0 if you want to keep the current number (which is #%s).'), OrderPaymentDetail::getLastPaymentReceiptNumber() + 1),
|
||||
'size' => 6,
|
||||
'type' => 'text',
|
||||
'cast' => 'intval'
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_LEGAL_FREE_TEXT' => array(
|
||||
'title' => $this->l('Legal free text'),
|
||||
'desc' => $this->l('Use this field to display additional text on your receipt, like specific legal information. It will appear below the payment methods summary.'),
|
||||
'size' => 50,
|
||||
'type' => 'textareaLang',
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_FREE_TEXT' => array(
|
||||
'title' => $this->l('Footer text'),
|
||||
'desc' => $this->l('This text will appear at the bottom of the receipt, below your company details.'),
|
||||
'size' => 50,
|
||||
'type' => 'textLang',
|
||||
)
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->display = 'edit';
|
||||
$this->initTabModuleList();
|
||||
$this->initToolbar();
|
||||
$this->initPageHeaderToolbar();
|
||||
$this->table = 'order_payment';
|
||||
$this->content .= $this->initFormByDate();
|
||||
|
||||
$this->content .= $this->renderOptions();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $this->content,
|
||||
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||
'show_page_header_toolbar' => $this->show_page_header_toolbar,
|
||||
'page_header_toolbar_title' => $this->page_header_toolbar_title,
|
||||
'page_header_toolbar_btn' => $this->page_header_toolbar_btn
|
||||
));
|
||||
}
|
||||
|
||||
public function initFormByDate()
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('By date'),
|
||||
'icon' => 'icon-calendar'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'date',
|
||||
'label' => $this->l('From'),
|
||||
'name' => 'date_from',
|
||||
'maxlength' => 10,
|
||||
'required' => true,
|
||||
'hint' => $this->l('Format: 2011-12-31 (inclusive).')
|
||||
),
|
||||
array(
|
||||
'type' => 'date',
|
||||
'label' => $this->l('To'),
|
||||
'name' => 'date_to',
|
||||
'maxlength' => 10,
|
||||
'required' => true,
|
||||
'hint' => $this->l('Format: 2012-12-31 (inclusive).')
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Generate PDF file by date'),
|
||||
'id' => 'submitPrint',
|
||||
'icon' => 'process-icon-download-alt'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value = array(
|
||||
'date_from' => date('Y-m-d'),
|
||||
'date_to' => date('Y-m-d')
|
||||
);
|
||||
|
||||
$this->table = 'order_payment';
|
||||
$this->show_toolbar = false;
|
||||
$this->show_form_cancel_button = false;
|
||||
$this->toolbar_title = $this->l('Print PDF invoices');
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function initToolbarTitle()
|
||||
{
|
||||
$this->toolbar_title = array_unique($this->breadcrumbs);
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
parent::initPageHeaderToolbar();
|
||||
unset($this->page_header_toolbar_btn['cancel']);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if(Tools::isSubmit('submitAddorder_payment')) {
|
||||
if (!Validate::isDate(Tools::getValue('date_from'))) {
|
||||
$this->errors[] = $this->l('Invalid "From" date');
|
||||
}
|
||||
|
||||
if (!Validate::isDate(Tools::getValue('date_to'))) {
|
||||
$this->errors[] = $this->l('Invalid "To" date');
|
||||
}
|
||||
if(Tools::getValue('date_from') > Tools::getValue('date_to')) {
|
||||
$this->errors[] = $this->l('"From" date must be earlier than "To" date');
|
||||
}
|
||||
if (!count($this->errors)) {
|
||||
if (count(OrderPaymentDetail::getByDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to')))) {
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPdf').'&submitAction=generatePaymentReceiptsPDF&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')));
|
||||
}
|
||||
|
||||
$this->errors[] = $this->l('No payment receipt has been found for this period.');
|
||||
}
|
||||
}else{
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
if ((int)Tools::getValue('PS_PAYMENT_RECEIPTS_START_NUMBER') != 0 && (int)Tools::getValue('PS_PAYMENT_RECEIPTS_START_NUMBER') <= OrderPaymentDetail::getLastPaymentReceiptNumber()) {
|
||||
$this->errors[] = $this->l('Invalid receipt number.').OrderPaymentDetail::getLastPaymentReceiptNumber().')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,15 @@ class AdminPdfControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function processGenerateBookingVoucherPDF()
|
||||
{
|
||||
if (Tools::isSubmit('id_order')) {
|
||||
$this->generateBookingVoucherPDFByIdOrder(Tools::getValue('id_order'));
|
||||
} else {
|
||||
die(Tools::displayError('The order ID is missing.'));
|
||||
}
|
||||
}
|
||||
|
||||
public function processGenerateOrderSlipPDF()
|
||||
{
|
||||
$order_slip = new OrderSlip((int)Tools::getValue('id_order_slip'));
|
||||
@@ -93,7 +102,6 @@ class AdminPdfControllerCore extends AdminController
|
||||
public function processGenerateInvoicesPDF()
|
||||
{
|
||||
$order_invoice_collection = OrderInvoice::getByDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to'));
|
||||
|
||||
if (!count($order_invoice_collection)) {
|
||||
die(Tools::displayError('No invoice was found.'));
|
||||
}
|
||||
@@ -150,14 +158,38 @@ class AdminPdfControllerCore extends AdminController
|
||||
|
||||
$id_supply_order = (int)Tools::getValue('id_supply_order');
|
||||
$supply_order = new SupplyOrder($id_supply_order);
|
||||
|
||||
if (!Validate::isLoadedObject($supply_order)) {
|
||||
die(Tools::displayError('The supply order cannot be found within your database.'));
|
||||
}
|
||||
|
||||
$this->generatePDF($supply_order, PDF::TEMPLATE_SUPPLY_ORDER_FORM);
|
||||
}
|
||||
|
||||
public function processGeneratePaymentReceiptsPDF()
|
||||
{
|
||||
$order_payment_collection = OrderPaymentDetail::getByDateInterval(
|
||||
Tools::getValue('date_from'),
|
||||
Tools::getValue('date_to')
|
||||
);
|
||||
|
||||
if (!count($order_payment_collection)) {
|
||||
die(Tools::displayError('No payment receipt was found.'));
|
||||
}
|
||||
|
||||
$this->generatePDF($order_payment_collection, PDF::TEMPLATE_PAYMENT_RECEIPT);
|
||||
}
|
||||
|
||||
public function processGeneratePaymentReceipt()
|
||||
{
|
||||
$idOrderPaymentDetail = (int) Tools::getValue('id_order_payment_detail');
|
||||
$orderPaymentDetail = new OrderPaymentDetail($idOrderPaymentDetail);
|
||||
if (!Validate::isLoadedObject($orderPaymentDetail)) {
|
||||
die(Tools::displayError('The order payment detail cannot be found.'));
|
||||
}
|
||||
$this->generatePDF($orderPaymentDetail, PDF::TEMPLATE_PAYMENT_RECEIPT);
|
||||
}
|
||||
|
||||
|
||||
public function generateDeliverySlipPDFByIdOrder($id_order)
|
||||
{
|
||||
$order = new Order((int)$id_order);
|
||||
@@ -202,6 +234,23 @@ class AdminPdfControllerCore extends AdminController
|
||||
$this->generatePDF($order_invoice, PDF::TEMPLATE_INVOICE);
|
||||
}
|
||||
|
||||
public function generateBookingVoucherPDFByIdOrder($id_order)
|
||||
{
|
||||
$order = new Order((int)$id_order);
|
||||
if (!Validate::isLoadedObject($order)) {
|
||||
die(Tools::displayError('The order cannot be found within your database.'));
|
||||
}
|
||||
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
$bookingDetails = $objHotelBookingDetail->getBookingDataByOrderId((int)$order->id);
|
||||
if (empty($bookingDetails)) {
|
||||
die(Tools::displayError('No booking voucher is available for this order.'));
|
||||
}
|
||||
|
||||
$pdf = new PDF($order, PDF::TEMPLATE_BOOKING_VOUCHER, Context::getContext()->smarty);
|
||||
$pdf->render('I');
|
||||
}
|
||||
|
||||
public function generatePDF($object, $template)
|
||||
{
|
||||
$pdf = new PDF($object, $template, Context::getContext()->smarty);
|
||||
|
||||
@@ -201,8 +201,8 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
//// By webkul New way to calculate product prices with feature Prices
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$any_back_order = 1;
|
||||
|
||||
70
controllers/front/PdfBookingVoucherController.php
Normal file
70
controllers/front/PdfBookingVoucherController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Serves the Booking Voucher PDF for a customer's own order.
|
||||
*/
|
||||
class PdfBookingVoucherControllerCore extends FrontController
|
||||
{
|
||||
public $php_self = 'pdf-booking-voucher';
|
||||
protected $display_header = false;
|
||||
protected $display_footer = false;
|
||||
public $content_only = true;
|
||||
|
||||
/** @var Order */
|
||||
protected $order;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key')) {
|
||||
Tools::redirect('index.php?controller=authentication&back=pdf-booking-voucher');
|
||||
}
|
||||
|
||||
$idOrder = (int)Tools::getValue('id_order');
|
||||
if (!Validate::isUnsignedId($idOrder)) {
|
||||
die(Tools::displayError('The booking voucher was not found.'));
|
||||
}
|
||||
|
||||
$order = new Order($idOrder);
|
||||
if (!Validate::isLoadedObject($order)) {
|
||||
die(Tools::displayError('The booking voucher was not found.'));
|
||||
}
|
||||
|
||||
$secureKey = Tools::getValue('secure_key');
|
||||
if ($secureKey) {
|
||||
if ($order->secure_key !== $secureKey) {
|
||||
die(Tools::displayError('The booking voucher was not found.'));
|
||||
}
|
||||
} elseif ($order->id_customer != (int)$this->context->customer->id) {
|
||||
die(Tools::displayError('The booking voucher was not found.'));
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$pdf = new PDF($this->order, PDF::TEMPLATE_BOOKING_VOUCHER, $this->context->smarty);
|
||||
$pdf->render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user