diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1deac3a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ + + +| Questions | Answers +| ------------- | ------------------------------------------------------- +| Description? | Please be specific when describing the PR.
Every detail helps: versions, browser/server configuration, specific module/theme, etc. Feel free to add more information below this table. +| Type? | bug fix / improvement / new feature / refacto / critical +| BC breaks? | yes / no +| Deprecations? | yes / no +| Fixed ticket? | Fixes PrestaShop/Prestashop#{issue number here}. +| How to test? | Please indicate how to best verify that this PR is correct. + + diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..e9b1f18 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,14 @@ +branches: + - master +name-template: v$NEXT_PATCH_VERSION +tag-template: v$NEXT_PATCH_VERSION +categories: + - title: 🚀 Improvements + label: enhancement + - title: 🐛 Bug Fixes + label: bug +change-template: '- #$NUMBER: $TITLE by @$AUTHOR' +template: | + # Changes + + $CHANGES diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..0e343b3 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,23 @@ +GitHub contributors: +-------------------------------- + - AntoineMille + - Azouz-Jribi + - Francois Gaillard + - Gregory Roussac + - Jérôme Nadaud + - Maxime Biloé + - Quetzacoalt91 + - aleeks + - antoin-m + - eternoendless + - gRoussac + - gaillafr + - gnujeremie + - hibatallahAouadni + - indesign47 + - kelu95 + - matks + - maximebiloe + - mickaelandrieu + - tchauviere + - xBorderie diff --git a/config.xml b/config.xml index 68d8fcc..95c9836 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ dashproducts - + diff --git a/dashproducts.php b/dashproducts.php index f209110..d412e1b 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -34,7 +34,7 @@ public function __construct() { $this->name = 'dashproducts'; $this->tab = 'dashboard'; - $this->version = '2.0.4'; + $this->version = '2.1.0'; $this->author = 'PrestaShop'; $this->push_filename = _PS_CACHE_DIR_.'push/activity'; @@ -72,7 +72,7 @@ public function hookDashboardZoneTwo($params) 'DASHPRODUCT_NBR_SHOW_TOP_SEARCH' => Configuration::get('DASHPRODUCT_NBR_SHOW_TOP_SEARCH'), 'date_from' => Tools::displayDate($params['date_from']), 'date_to' => Tools::displayDate($params['date_to']), - 'dashproducts_config_form' => $this->renderConfigForm(), + 'dashproducts_config_form' => $this->getPermission('configure') ? $this->renderConfigForm() : null, ) ); @@ -116,9 +116,10 @@ public function getTableRecentOrders() foreach ($orders as $order) { $currency = Currency::getCurrency((int)$order['id_currency']); $tr = array(); + $customerLinkParams = ['route' => 'admin_customers_view', 'customerId' => $order['id_customer']]; $tr[] = array( 'id' => 'firstname_lastname', - 'value' => ''.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'', + 'value' => ''.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'', 'class' => 'text-left', ); $tr[] = array( @@ -242,7 +243,7 @@ public function getTableBestSellers($date_from, $date_to) ), array( 'id' => 'product', - 'value' => ''.Tools::htmlentitiesUTF8($product['product_name']).''.'
'.Tools::displayPrice($productPrice), + 'value' => ''.Tools::htmlentitiesUTF8($product['product_name']).''.'
'.Tools::displayPrice($productPrice), 'class' => 'text-center' ), array( @@ -616,4 +617,44 @@ public function hookActionSearch($params) { Tools::changeFileMTime($this->push_filename); } + + /** + * Validate dashboard configuration + * + * @param array $config + * + * @return array + */ + public function validateDashConfig(array $config) + { + $errors = []; + $possibleValues = [5, 10, 20, 50]; + foreach (array_keys($this->getConfigFieldsValues()) as $fieldName) { + if (!isset($config[$fieldName]) || !in_array($config[$fieldName], $possibleValues)) { + $errors[$fieldName] = $this->trans('The %s field is invalid.', [$fieldName], 'Modules.Dashproducts.Admin'); + } + } + + return $errors; + } + + /** + * Save dashboard configuration + * + * @param array $config + * + * @return bool determines if there are errors or not + */ + public function saveDashConfig(array $config) + { + if (!$this->getPermission('configure')) { + return true; + } + + foreach (array_keys($this->getConfigFieldsValues()) as $fieldName) { + Configuration::updateValue($fieldName, (int) $config[$fieldName]); + } + + return false; + } } diff --git a/views/templates/hook/dashboard_zone_two.tpl b/views/templates/hook/dashboard_zone_two.tpl index 084c6af..1a497ca 100644 --- a/views/templates/hook/dashboard_zone_two.tpl +++ b/views/templates/hook/dashboard_zone_two.tpl @@ -1,123 +1,127 @@ {* -* 2007-2018 PrestaShop -* -* 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: -* http://opensource.org/licenses/afl-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 license@prestashop.com 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 http://www.prestashop.com for more information. -* -* @author PrestaShop SA -* @copyright 2007-2018 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} + * 2007-2018 PrestaShop + * + * 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: + * http://opensource.org/licenses/afl-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 license@prestashop.com 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 http://www.prestashop.com for more information. + * + * @author PrestaShop SA + * @copyright 2007-2018 PrestaShop SA + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * International Registered Trademark & Property of PrestaShop SA + *}
-
- {l s='Products and Sales' d='Modules.Dashproducts.Admin'} - - - - - - - - -
+
+ {l s='Products and Sales' d='Modules.Dashproducts.Admin'} + + {if !empty($dashproducts_config_form)} + + + + {/if} + + + + +
-
-
{l s='Configuration' d='Admin.Global'}
- {$dashproducts_config_form} -
+ {if !empty($dashproducts_config_form)} +
+
{l s='Configuration' d='Admin.Global'}
+ {$dashproducts_config_form} +
+ {/if} -
- +
+ -
-
-

{l s='Last %d orders' sprintf=$DASHPRODUCT_NBR_SHOW_LAST_ORDER|intval d='Modules.Dashproducts.Admin'}

-
- - - -
-
-
-
-

- {l s='Top %d products' sprintf=$DASHPRODUCT_NBR_SHOW_BEST_SELLER|intval d='Modules.Dashproducts.Admin'} - {l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'} -

-
- - - -
-
-
-
-

- {l s="Most Viewed" d='Modules.Dashproducts.Admin'} - {l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'} -

-
- - - -
-
-
- -
+
+
+

{l s='Last %d orders' sprintf=$DASHPRODUCT_NBR_SHOW_LAST_ORDER|intval d='Modules.Dashproducts.Admin'}

+
+ + + +
+
+
+
+

+ {l s='Top %d products' sprintf=$DASHPRODUCT_NBR_SHOW_BEST_SELLER|intval d='Modules.Dashproducts.Admin'} + {l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'} +

+
+ + + +
+
+
+
+

+ {l s="Most Viewed" d='Modules.Dashproducts.Admin'} + {l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'} +

+
+ + + +
+
+
+ +
-
+