Merge branch 'ticket-fidelite' into develop

This commit is contained in:
Marion Muszynski 2016-05-30 17:04:57 +02:00
commit c7dac58b08
3 changed files with 20 additions and 8 deletions

View File

@ -193,6 +193,19 @@ class LoyaltyModule extends ObjectModel
return Db::getInstance()->ExecuteS($query);
}
public static function getNbOrdersByIdCustomer($id_customer, $notCancel = true)
{
$query = '
SELECT COUNT(f.`id_loyalty`)
FROM `'._DB_PREFIX_.'loyalty` f
-- LEFT JOIN `'._DB_PREFIX_.'orders` o ON (f.id_order = o.id_order)
WHERE f.`id_customer` = '.(int)($id_customer);
if ($notCancel === true)
$query .= ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId();
return Db::getInstance()->getValue($query);
}
public static function getAllByIdCustomerCustom($id_customer, $id_lang, $onlyValidate = false, $pagination = false, $nb = 10, $page = 1, $onlyDefault = false)
{
$percent = (float)(Configuration::get('PS_LOYALTY_PERCENT_VALUE') / 100);

View File

@ -122,9 +122,8 @@ if (Tools::getValue('transform-points') == 'true' AND $total_discount > 0)
include(dirname(__FILE__).'/../../header.php');
//$orders = LoyaltyModule::getAllByIdCustomer((int)($cookie->id_customer), (int)($cookie->id_lang));
$smarty->assign(array(
//'orders' => $orders,
'nb_orders' => (int)LoyaltyModule::getNbOrdersByIdCustomer((int)($cookie->id_customer)),
'displayorders' => $displayorders,
'pagination_link' => __PS_BASE_URI__.'modules/loyalty/loyalty-program.php',
'voucher' => $total_discount,

View File

@ -29,9 +29,9 @@
<h1>{l s='My loyalty points' mod='loyalty'}</h1>
{if $orders}
{if $nb_orders}
<div class="block-center" id="block-history">
{if $orders && count($orders)}
{if $nb_orders && $nb_orders>0}
<table id="order-list" class="std">
<thead>
<tr>
@ -65,7 +65,7 @@
{/if}
</div>
<div id="pagination" class="pagination">
{if $nbpagination < $orders|@count}
{if $nbpagination < $nb_orders}
<ul class="pagination">
{if $page != 1}
{assign var='p_previous' value=$page-1}
@ -93,7 +93,7 @@
{/if}
<li><a href="{$pagination_link}?p={$max_page}&n={$nbpagination}">{$max_page}</a></li>
{/if}
{if $orders|@count > $page * $nbpagination}
{if $nb_orders > $page * $nbpagination}
{assign var='p_next' value=$page+1}
<li id="pagination_next"><a href="{$pagination_link}?p={$p_next}&n={$nbpagination}">{l s='Next' mod='loyalty'}&nbsp;&raquo;</a></li>
{else}
@ -101,14 +101,14 @@
{/if}
</ul>
{/if}
{if $orders|@count > 10}
{if $nb_orders > 10}
<form action="{$pagination_link}" method="get" class="pagination">
<p>
<input type="submit" class="button_mini" value="{l s='OK'}" />
<label for="nb_item">{l s='items:' mod='loyalty'}</label>
<select name="n" id="nb_item">
{foreach from=$nArray item=nValue}
{if $nValue <= $orders|@count}
{if $nValue <= $nb_orders}
<option value="{$nValue|escape:'htmlall':'UTF-8'}" {if $nbpagination == $nValue}selected="selected"{/if}>{$nValue|escape:'htmlall':'UTF-8'}</option>
{/if}
{/foreach}