Skip to content

Commit

Permalink
Merge pull request #26 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Release 2.1.0
  • Loading branch information
PierreRambaud authored Jul 9, 2020
2 parents 35b35fc + 9d56cf8 commit ad716b9
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 120 deletions.
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-----------------------------------------------------------------------------
Thank you for contributing to the PrestaShop project!
Please take the time to edit the "Answers" rows below with the necessary information.
Check out our contribution guidelines to find out how to complete it:
https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/#pull-requests
------------------------------------------------------------------------------>

| Questions | Answers
| ------------- | -------------------------------------------------------
| Description? | Please be specific when describing the PR. <br> 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.

<!-- Click the form's "Preview" button to make sure the table is functional in GitHub. Thank you! -->
14 changes: 14 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -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
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>dashproducts</name>
<displayName><![CDATA[Dashboard Products]]></displayName>
<version><![CDATA[2.0.4]]></version>
<version><![CDATA[2.1.0]]></version>
<description><![CDATA[Adds a block with a table of your latest orders and a ranking of your products]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[dashboard]]></tab>
Expand Down
49 changes: 45 additions & 4 deletions dashproducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
)
);

Expand Down Expand Up @@ -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' => '<a href="'.$this->context->link->getAdminLink('AdminCustomers', true).'&id_customer='.$order['id_customer'].'&viewcustomer">'.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'</a>',
'value' => '<a href="'.$this->context->link->getAdminLink('AdminCustomers', true, $customerLinkParams) .'">'.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'</a>',
'class' => 'text-left',
);
$tr[] = array(
Expand Down Expand Up @@ -242,7 +243,7 @@ public function getTableBestSellers($date_from, $date_to)
),
array(
'id' => 'product',
'value' => '<a href="'.$this->context->link->getAdminLink('AdminProducts', true).'&id_product='.$product_obj->id.'&updateproduct">'.Tools::htmlentitiesUTF8($product['product_name']).'</a>'.'<br/>'.Tools::displayPrice($productPrice),
'value' => '<a href="'.$this->context->link->getAdminLink('AdminProducts', true, ['id_product' => $product_obj->id, 'updateproduct' => 1]).'">'.Tools::htmlentitiesUTF8($product['product_name']).'</a>'.'<br/>'.Tools::displayPrice($productPrice),
'class' => 'text-center'
),
array(
Expand Down Expand Up @@ -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;
}
}
234 changes: 119 additions & 115 deletions views/templates/hook/dashboard_zone_two.tpl
Original file line number Diff line number Diff line change
@@ -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 <contact@prestashop.com>
* @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 <contact@prestashop.com>
* @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
*}

<section id="dashproducts" class="panel widget {if $allow_push} allow_push{/if}">
<header class="panel-heading">
<i class="icon-bar-chart"></i> {l s='Products and Sales' d='Modules.Dashproducts.Admin'}
<span class="panel-heading-action">
<a class="list-toolbar-btn" href="#" onclick="toggleDashConfig('dashproducts'); return false;" title="{l s='Configure' d='Admin.Actions'}">
<i class="process-icon-configure"></i>
</a>
<a class="list-toolbar-btn" href="#" onclick="refreshDashboard('dashproducts'); return false;" title="{l s='Refresh' d='Admin.Actions'}">
<i class="process-icon-refresh"></i>
</a>
</span>
</header>
<header class="panel-heading">
<i class="icon-bar-chart"></i> {l s='Products and Sales' d='Modules.Dashproducts.Admin'}
<span class="panel-heading-action">
{if !empty($dashproducts_config_form)}
<a class="list-toolbar-btn" href="#" onclick="toggleDashConfig('dashproducts'); return false;" title="{l s='Configure' d='Admin.Actions'}">
<i class="process-icon-configure"></i>
</a>
{/if}
<a class="list-toolbar-btn" href="#" onclick="refreshDashboard('dashproducts'); return false;" title="{l s='Refresh' d='Admin.Actions'}">
<i class="process-icon-refresh"></i>
</a>
</span>
</header>

<section id="dashproducts_config" class="dash_config hide">
<header><i class="icon-wrench"></i> {l s='Configuration' d='Admin.Global'}</header>
{$dashproducts_config_form}
</section>
{if !empty($dashproducts_config_form)}
<section id="dashproducts_config" class="dash_config hide">
<header><i class="icon-wrench"></i> {l s='Configuration' d='Admin.Global'}</header>
{$dashproducts_config_form}
</section>
{/if}

<section>
<nav>
<ul class="nav nav-pills">
<li class="active">
<a href="#dash_recent_orders" data-toggle="tab">
<i class="icon-fire"></i>
<span class="hidden-inline-xs">{l s='Recent Orders' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
<li>
<a href="#dash_best_sellers" data-toggle="tab">
<i class="icon-trophy"></i>
<span class="hidden-inline-xs">{l s='Best Sellers' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
<li>
<a href="#dash_most_viewed" data-toggle="tab">
<i class="icon-eye-open"></i>
<span class="hidden-inline-xs">{l s='Most Viewed' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
<li>
<a href="#dash_top_search" data-toggle="tab">
<i class="icon-search"></i>
<span class="hidden-inline-xs">{l s='Top Searches' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
</ul>
</nav>
<section>
<nav>
<ul class="nav nav-pills">
<li class="active">
<a href="#dash_recent_orders" data-toggle="tab">
<i class="icon-fire"></i>
<span class="hidden-inline-xs">{l s='Recent Orders' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
<li>
<a href="#dash_best_sellers" data-toggle="tab">
<i class="icon-trophy"></i>
<span class="hidden-inline-xs">{l s='Best Sellers' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
<li>
<a href="#dash_most_viewed" data-toggle="tab">
<i class="icon-eye-open"></i>
<span class="hidden-inline-xs">{l s='Most Viewed' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
<li>
<a href="#dash_top_search" data-toggle="tab">
<i class="icon-search"></i>
<span class="hidden-inline-xs">{l s='Top Searches' d='Modules.Dashproducts.Admin'}</span>
</a>
</li>
</ul>
</nav>

<div class="tab-content panel">
<div class="tab-pane active" id="dash_recent_orders">
<h3>{l s='Last %d orders' sprintf=$DASHPRODUCT_NBR_SHOW_LAST_ORDER|intval d='Modules.Dashproducts.Admin'}</h3>
<div class="table-responsive">
<table class="table data_table" id="table_recent_orders">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane" id="dash_best_sellers">
<h3>
{l s='Top %d products' sprintf=$DASHPRODUCT_NBR_SHOW_BEST_SELLER|intval d='Modules.Dashproducts.Admin'}
<span>{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'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_best_sellers">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane" id="dash_most_viewed">
<h3>
{l s="Most Viewed" d='Modules.Dashproducts.Admin'}
<span>{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'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_most_viewed">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane" id="dash_top_search">
<h3>
{l s='Top %d most search terms' sprintf=$DASHPRODUCT_NBR_SHOW_TOP_SEARCH|intval d='Modules.Dashproducts.Admin'}
<span>{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'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_top_10_most_search">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<div class="tab-content panel">
<div class="tab-pane active" id="dash_recent_orders">
<h3>{l s='Last %d orders' sprintf=$DASHPRODUCT_NBR_SHOW_LAST_ORDER|intval d='Modules.Dashproducts.Admin'}</h3>
<div class="table-responsive">
<table class="table data_table" id="table_recent_orders">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane" id="dash_best_sellers">
<h3>
{l s='Top %d products' sprintf=$DASHPRODUCT_NBR_SHOW_BEST_SELLER|intval d='Modules.Dashproducts.Admin'}
<span>{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'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_best_sellers">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane" id="dash_most_viewed">
<h3>
{l s="Most Viewed" d='Modules.Dashproducts.Admin'}
<span>{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'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_most_viewed">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane" id="dash_top_search">
<h3>
{l s='Top %d most search terms' sprintf=$DASHPRODUCT_NBR_SHOW_TOP_SEARCH|intval d='Modules.Dashproducts.Admin'}
<span>{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'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_top_10_most_search">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
</div>

</section>
</section>
</section>

0 comments on commit ad716b9

Please sign in to comment.