Skip to content

Commit

Permalink
Release 1.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrowanwallee committed Nov 29, 2021
1 parent cc86abb commit b8643e0
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ This repository contains the PrestaShop PostFinance Checkout payment module that

## Documentation

* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/prestashop-1.7/1.2.11/docs/en/documentation.html)
* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/prestashop-1.7/1.2.12/docs/en/documentation.html)

## Support

Support queries can be issued on the [PostFinance Checkout support site](https://www.postfinance.ch/en/business/support/written-contact/contact-form.html).

## License

Please see the [license file](https://github.com/pfpayments/prestashop-1.7/blob/1.2.11/LICENSE) for more information.
Please see the [license file](https://github.com/pfpayments/prestashop-1.7/blob/1.2.12/LICENSE) for more information.

## Other PrestaShop Versions

Expand Down
13 changes: 13 additions & 0 deletions config/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* HeaderLicense
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit();
14 changes: 14 additions & 0 deletions config/routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
download_packing_slip:
path: postFinanceCheckout/{orderId}/packingslip
methods: [GET]
defaults:
_controller: PrestaShop\Module\PostFinanceCheckout\Controller\Admin\processPostFinanceCheckoutPackingSlip::processPostFinanceCheckoutPackingSlip
requirements:
orderId: \d+
download_invoice:
path: postFinanceCheckout/{orderId}/invoice
methods: [GET]
defaults:
_controller: PrestaShop\Module\PostFinanceCheckout\Controller\Admin\processPostFinanceCheckoutInvoice::processPostFinanceCheckoutInvoice
requirements:
orderId: \d+
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/pfpayments/prestashop-1.7/releases/tag/1.2.11/">
<a href="https://github.com/pfpayments/prestashop-1.7/releases/tag/1.2.12/">
Source
</a>
</li>
Expand Down Expand Up @@ -51,7 +51,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/pfpayments/prestashop-1.7/releases/tag/1.2.11/">Download</a> the module.</p>
<p><a href="https://github.com/pfpayments/prestashop-1.7/releases/tag/1.2.12/">Download</a> the module.</p>
</li>
<li>
<p>Login to the backend of your PrestsShop store.</p>
Expand Down
74 changes: 73 additions & 1 deletion inc/Basemodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/

use PrestaShop\PrestaShop\Core\Domain\Order\CancellationActionType;
use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction;
use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction;
use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinition;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;

/**
* Base implementation for common features for PS1.6 and 1.7
Expand Down Expand Up @@ -123,7 +128,8 @@ public function checkRequirements(PostFinanceCheckout $module)

public static function installHooks(PostFinanceCheckout $module)
{
return $module->registerHook('actionAdminControllerSetMedia') &&
return $module->registerHook('actionAdminControllerSetMedia') && $module->registerHook('actionOrderGridDefinitionModifier') &&
$module->registerHook('actionOrderGridQueryBuilderModifier') &&
$module->registerHook('actionAdminOrdersControllerBefore') && $module->registerHook('actionMailSend') &&
$module->registerHook('actionOrderEdited') && $module->registerHook('displayAdminAfterHeader') &&
$module->registerHook('displayAdminOrder') && $module->registerHook('displayAdminOrderContentOrder') &&
Expand Down Expand Up @@ -1524,9 +1530,75 @@ public static function hookDisplayOrderDetail(PostFinanceCheckout $module, $para
return $module->display(dirname(dirname(__FILE__)), 'hook/order_detail.tpl');
}

public function hookActionOrderGridQueryBuilderModifier(PostFinanceCheckout $module, $params) {
$searchQueryBuilder = $params['search_query_builder'];

$searchQueryBuilder->addSelect(
'IF(wtransinfo.`order_id` IS NULL,0,1) AS `is_w_payment`'
);

$searchQueryBuilder->leftJoin(
'o',
'`' . pSQL(_DB_PREFIX_) . 'wle_transaction_info`',
'wtransinfo',
'wtransinfo.`order_id` = o.`id_order`'
);
}

public function hookActionOrderGridDefinitionModifier(PostFinanceCheckout $module, $params) {

$orderGridDefinition = $params['definition'];

$columns = $orderGridDefinition->getColumns();
// add columns
$newColumn = (new DataColumn('is_w_payment'))
->setName('Is W Payment')
->setOptions([
'field' => 'is_w_payment',
]);
$columns->addAfter('payment', $newColumn);

/** @var RowActionCollectionInterface $actionsCollection */
$actionsCollection = Self::getActionsColumn($orderGridDefinition)->getOption('actions');
$actionsCollection->add(
(new LinkRowAction('download_packing_slip'))
->setName("Download Packing Slip")
->setIcon('picture_as_pdf')
->setOptions([
'route' => 'download_packing_slip',
'route_param_name' => 'orderId',
'route_param_field' => 'id_order',
'use_inline_display' => true,
])
);
$actionsCollection->add(
(new LinkRowAction('download_invoice'))
->setName("Download PostFinanceCheckout Invoice")
->setIcon('description')
->setOptions([
'route' => 'download_invoice',
'route_param_name' => 'orderId',
'route_param_field' => 'id_order',
'use_inline_display' => true,
])
);
}

private function getActionsColumn(GridDefinition $gridDefinition)
{
try {
return $gridDefinition->getColumnById('actions');
} catch (ColumnNotFoundException $e) {
// It is possible that not every grid will have actions column.
// In this case you can create a new column or throw exception depending on your needs
throw $e;
}
}

public static function hookActionAdminControllerSetMedia(PostFinanceCheckout $module, $arr)
{
if (Tools::strtolower(Tools::getValue('controller')) == 'adminorders') {
Media::addJsDefL('postfinancecheckout_admin_token', $module->getContext()->link->getAdminLink('AdminPostFinanceCheckoutDocuments'));
$module->getContext()->controller->addJS(
__PS_BASE_URI__ . 'modules/' . $module->name . '/views/js/admin/jAlert.min.js'
);
Expand Down
12 changes: 11 additions & 1 deletion postfinancecheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct()
$this->author = 'Customweb GmbH';
$this->bootstrap = true;
$this->need_instance = 0;
$this->version = '1.2.11';
$this->version = '1.2.12';
$this->displayName = 'PostFinance Checkout';
$this->description = $this->l('This PrestaShop module enables to process payments with %s.');
$this->description = sprintf($this->description, 'PostFinance Checkout');
Expand Down Expand Up @@ -477,6 +477,16 @@ public function hookActionOrderEdited($params)
PostFinanceCheckoutBasemodule::hookActionOrderEdited($this, $params);
}

public function hookActionOrderGridDefinitionModifier($params)
{
PostFinanceCheckoutBasemodule::hookActionOrderGridDefinitionModifier($this, $params);
}

public function hookActionOrderGridQueryBuilderModifier($params)
{
PostFinanceCheckoutBasemodule::hookActionOrderGridQueryBuilderModifier($this, $params);
}

public function hookActionProductCancel($params)
{
// check version too here to only run on > 1.7.7 for now
Expand Down
49 changes: 49 additions & 0 deletions views/js/admin/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,53 @@
*/
jQuery(function ($) {

function getOrderIdFromUrl(string) {
let urlSegment = string.split('postfinancecheckout')[1];
return urlSegment.split('/')[1]
}

function initialiseDocumentButtons() {
if ($('.grid-download-postfinancecheckout-invoice-row-link').length) {
$('.grid-download-packing-slip-row-link').click(function(e) {
e.preventDefault();
let id_order = getOrderIdFromUrl($(this).attr('href'));
window.open(postfinancecheckout_admin_token + "&action=postFinanceCheckoutPackingSlip&id_order=" + id_order, "_blank");
});

$('.grid-download-postfinancecheckout-invoice-row-link').click(function(e) {
e.preventDefault();
let id_order = getOrderIdFromUrl($(this).attr('href'));
window.open(postfinancecheckout_admin_token + "&action=postFinanceCheckoutInvoice&id_order=" + id_order, "_blank");
});

$('.grid-download-postfinancecheckout-invoice-row-link').each(function() {
let $this = $(this);
let $row = $this.closest('tr');
let isWPayment = "0";
let $paymentStatusCol = $row.find('.column-osname');
let isWPaymentCol = $row.find('.column-is_w_payment').html();
if (isWPaymentCol) {
isWPayment = isWPaymentCol.trim();
}
let paymentStatusText = $paymentStatusCol.find('.btn').text();
if (!paymentStatusText.includes("Payment accepted") || isWPayment.includes("0")) {
$row.find('.grid-download-postfinancecheckout-invoice-row-link').hide();
$row.find('.grid-download-packing-slip-row-link').hide();
}
});
}
}

function hideIsWPaymentColumn() {
$('th').each(function() {
let $this = $(this);
if ($this.html().includes("is_w_payment")) {
$('table tr').find('td:eq(' + $this.index() + '),th:eq(' + $this.index() + ')').remove();
return false;
}
});
}

function isVersionGTE177()
{
if (_PS_VERSION_ === undefined) {
Expand Down Expand Up @@ -378,6 +425,8 @@ jQuery(function ($) {
{
handlePostFinanceCheckoutLayoutChanges();
registerPostFinanceCheckoutActions();
initialiseDocumentButtons();
hideIsWPaymentColumn();
}

init();
Expand Down
2 changes: 1 addition & 1 deletion views/templates/admin/admin_help_buttons.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<div class="alert alert-info">
<img src="../modules/postfinancecheckout/logo.png" style="float:left; margin-right:15px;" height="50">
<p><strong>{l s='This module requires an %s account.' sprintf='PostFinance Checkout' mod='postfinancecheckout'}</strong></p>
<p><a class="btn btn-default" href="https://checkout.postfinance.ch/user/signup" target="_blank">{l s='Sign Up' mod='postfinancecheckout'}</a> <a class="btn btn-default" href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/prestashop-1.7/1.2.11/docs/en/documentation.html" target="_blank">{l s='Documentation' mod='postfinancecheckout'}</a></p>
<p><a class="btn btn-default" href="https://checkout.postfinance.ch/user/signup" target="_blank">{l s='Sign Up' mod='postfinancecheckout'}</a> <a class="btn btn-default" href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/prestashop-1.7/1.2.12/docs/en/documentation.html" target="_blank">{l s='Documentation' mod='postfinancecheckout'}</a></p>
</div>

0 comments on commit b8643e0

Please sign in to comment.