Skip to content

Commit

Permalink
Add CSS to fix carrier logo size in Order List page
Browse files Browse the repository at this point in the history
  • Loading branch information
mRaigne committed May 24, 2019
1 parent 5231a7f commit ef862df
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/config_*.xml
/translations/
!/translations/index.php
/vendor/
!/vendor/index.php
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Display order carrier

This is a demo module
This is a demo module but can be used safely on your PrestaShop instance

## About

Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>displayordercarrier</name>
<displayName><![CDATA[Carrier logo on Orders list]]></displayName>
<version><![CDATA[1.0.0]]></version>
<version><![CDATA[1.0.1]]></version>
<description><![CDATA[Adds carrier logo on Order list]]></description>
<author><![CDATA[Matt75]]></author>
<is_configurable>0</is_configurable>
Expand Down
51 changes: 45 additions & 6 deletions displayordercarrier.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
<?php

/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}

class DisplayOrderCarrier extends Module
{
/**
* @var array List of hooks used.
* @var array list of hooks used
*/
public $hooks = [
'actionAdminControllerSetMedia',
'actionAdminOrdersListingFieldsModifier',
'actionAdminOrdersListingResultsModifier',
];
Expand All @@ -21,7 +45,7 @@ public function __construct()
{
$this->name = 'displayordercarrier';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->version = '1.0.1';
$this->author = 'Matt75';
$this->need_instance = 0;
$this->ps_versions_compliancy = [
Expand All @@ -46,6 +70,21 @@ public function install()
&& $this->registerHook($this->hooks);
}

/**
* Add CSS to fix carrier logo size in Order List page
*
* @param array $params
*/
public function hookActionAdminControllerSetMedia(array $params)
{
if ('AdminOrders' === Tools::getValue('controller')
&& false === Tools::getIsset('addorder')
&& false === Tools::getIsset('vieworder')
) {
$this->context->controller->addCSS($this->getPathUri() . 'views/css/displayordercarrier.css', 'all');
}
}

/**
* Append custom fields.
*
Expand All @@ -67,7 +106,7 @@ public function hookActionAdminOrdersListingFieldsModifier(array $params)
'carrier_name' => [
'title' => $this->l('Carrier'),
'align' => 'text-center',
'class' => 'fixed-width-xs',
'class' => 'fixed-width-xs column-img-carrier',
'icon' => true,
'filter_key' => 'car!name',
'order_key' => 'car!name',
Expand All @@ -85,8 +124,8 @@ public function hookActionAdminOrdersListingResultsModifier(array $params)
foreach ($params['list'] as &$fields) {
if (isset($fields['id_carrier'], $fields['carrier_name'])) {
$fields['carrier_name'] = [
'src' => '../s/' . $fields['id_carrier'] . '.jpg',
'alt' => $fields['carrier_name'],
'src' => '../s/' . (int) $fields['id_carrier'] . '.jpg',
'alt' => Tools::safeOutput($fields['carrier_name']),
];
}
}
Expand Down
35 changes: 35 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

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;
31 changes: 31 additions & 0 deletions translations/fr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

global $_MODULE;
$_MODULE = array();
$_MODULE['<{displayordercarrier}prestashop>displayordercarrier_eee8cf7ee13db4ebeb2674923580dd67'] = 'Logo transporteur sur la liste des commandes';
$_MODULE['<{displayordercarrier}prestashop>displayordercarrier_f8a35d3b6c54823e915a05f2f583c7f3'] = 'Ajoute le logo du transporteur sur la liste des commandes';
$_MODULE['<{displayordercarrier}prestashop>displayordercarrier_914419aa32f04011357d3b604a86d7eb'] = 'Transporteur';
35 changes: 35 additions & 0 deletions translations/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

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;
35 changes: 35 additions & 0 deletions upgrade/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

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;
38 changes: 38 additions & 0 deletions upgrade/upgrade-1.0.1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}

/**
* @param DisplayOrderCarrier $module
*
* @return bool
*/
function upgrade_module_1_0_1($module)
{
return $module->registerHook('actionAdminControllerSetMedia');
}
29 changes: 29 additions & 0 deletions views/css/displayordercarrier.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

.column-img-carrier img {
max-height: 30px;
max-width: 30px;
}
35 changes: 35 additions & 0 deletions views/css/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

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;
35 changes: 35 additions & 0 deletions views/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

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;

0 comments on commit ef862df

Please sign in to comment.