Merge branch 'ticket-fidelite'
This commit is contained in:
commit
5c8e35adf2
@ -180,9 +180,8 @@ class LoyaltyModule extends ObjectModel
|
||||
public static function getAllByIdCustomer($id_customer, $id_lang, $onlyValidate = false, $pagination = false, $nb = 10, $page = 1)
|
||||
{
|
||||
$query = '
|
||||
SELECT f.id_order AS id, f.date_add AS date, (o.total_paid - o.total_shipping) total_without_shipping, f.discount_value, f.id_loyalty, f.id_loyalty_state, fsl.name state
|
||||
SELECT f.id_order AS id, f.date_add AS date, f.discount_value, f.id_loyalty, f.id_loyalty_state, fsl.name state
|
||||
FROM `'._DB_PREFIX_.'loyalty` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (f.id_order = o.id_order)
|
||||
LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).')
|
||||
WHERE f.id_customer = '.(int)($id_customer);
|
||||
if ($onlyValidate === true)
|
||||
@ -198,7 +197,6 @@ class LoyaltyModule extends ObjectModel
|
||||
$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();
|
||||
@ -206,10 +204,21 @@ class LoyaltyModule extends ObjectModel
|
||||
return Db::getInstance()->getValue($query);
|
||||
}
|
||||
|
||||
public static function getOrdersWithDiscountByIdCustomer($id_customer, $notCancel = true)
|
||||
{
|
||||
$query = '
|
||||
SELECT f.`id_loyalty`,f.`id_loyalty_state`,f.`discount_value`
|
||||
FROM `'._DB_PREFIX_.'loyalty` f
|
||||
WHERE f.`id_customer` = '.(int)($id_customer);
|
||||
if ($notCancel === true)
|
||||
$query .= ' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId();
|
||||
|
||||
return Db::getInstance()->ExecuteS($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);
|
||||
|
||||
/*$percent = (float)(Configuration::get('PS_LOYALTY_PERCENT_VALUE') / 100);
|
||||
$query = '
|
||||
SELECT f.id_order AS id, f.date_add AS date,
|
||||
(o.total_paid - o.total_shipping) total_without_shipping,
|
||||
@ -218,6 +227,12 @@ class LoyaltyModule extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'loyalty` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (f.id_order = o.id_order)
|
||||
LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).')
|
||||
WHERE f.id_customer = '.(int)($id_customer).'*/
|
||||
|
||||
$query = '
|
||||
SELECT f.id_order AS id, f.date_add AS date, f.discount_value, f.id_loyalty, f.id_loyalty_state, fsl.name state
|
||||
FROM `'._DB_PREFIX_.'loyalty` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).')
|
||||
WHERE f.id_customer = '.(int)($id_customer).'
|
||||
'.(($onlyValidate)?'':' AND f.id_loyalty_state != '.(int)LoyaltyStateModule::getCancelId());
|
||||
if ($onlyValidate) {
|
||||
|
@ -44,12 +44,25 @@ Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.dimensions.js',_PS_JS_DIR_.'jquery
|
||||
$displayorders = LoyaltyModule::getAllByIdCustomerCustom((int)($cookie->id_customer), (int)($cookie->id_lang), false, true, ((int)(Tools::getValue('n')) > 0 ? (int)(Tools::getValue('n')) : 10), ((int)(Tools::getValue('p')) > 0 ? (int)(Tools::getValue('p')) : 1));
|
||||
//$orderToConvert = LoyaltyModule::getAllByIdCustomerCustom((int)($cookie->id_customer), (int)($cookie->id_lang), true, false, $nb = 10, $page = 1);
|
||||
//$total_discount = LoyaltyModule::getVoucherValueByPercentOfOrder($orderToConvert, (int)($cookie->id_currency));
|
||||
$total_discount = Db::getInstance()->getValue('
|
||||
/*$total_discount = Db::getInstance()->getValue('
|
||||
SELECT SUM(`discount_value`) FROM `'._DB_PREFIX_.'loyalty`
|
||||
WHERE `id_loyalty_state`=2
|
||||
AND `id_discount`=0
|
||||
AND `id_customer` = ' .(int) $cookie->id_customer
|
||||
);
|
||||
);*/
|
||||
$allOrders = LoyaltyModule::getOrdersWithDiscountByIdCustomer((int) $cookie->id_customer);
|
||||
$total_discount = 0;
|
||||
if (!empty($allOrders)) {
|
||||
$nb_orders = count($allOrders);
|
||||
foreach ($allOrders as $key => $order) {
|
||||
if ((int)$order['id_loyalty_state'] !=2){
|
||||
continue;
|
||||
}
|
||||
$total_discount += (float)$order['discount_value'];
|
||||
}
|
||||
} else {
|
||||
$nb_orders = 0;
|
||||
}
|
||||
|
||||
/* transform point into voucher if needed */
|
||||
if (Tools::getValue('transform-points') == 'true' AND $total_discount > 0)
|
||||
@ -123,7 +136,8 @@ include(dirname(__FILE__).'/../../header.php');
|
||||
|
||||
//$orders = LoyaltyModule::getAllByIdCustomer((int)($cookie->id_customer), (int)($cookie->id_lang));
|
||||
$smarty->assign(array(
|
||||
'nb_orders' => (int)LoyaltyModule::getNbOrdersByIdCustomer((int)($cookie->id_customer)),
|
||||
/*'nb_orders' => (int)LoyaltyModule::getNbOrdersByIdCustomer((int)($cookie->id_customer)),*/
|
||||
'nb_orders' => $nb_orders,
|
||||
'displayorders' => $displayorders,
|
||||
'pagination_link' => __PS_BASE_URI__.'modules/loyalty/loyalty-program.php',
|
||||
'voucher' => $total_discount,
|
||||
|
@ -651,7 +651,6 @@ class Loyalty extends Module
|
||||
<tr style="background-color:#F5E9CF; padding: 0.3em 0.1em;">
|
||||
<th>'.$this->l('Order').'</th>
|
||||
<th>'.$this->l('Date').'</th>
|
||||
<th>'.$this->l('Total (without shipping)').'</th>
|
||||
<th>'.$this->l('Discount').'</th>
|
||||
<th>'.$this->l('Discount Status').'</th>
|
||||
</tr>';
|
||||
@ -661,14 +660,12 @@ class Loyalty extends Module
|
||||
<tr style="background-color: '.($key % 2 != 0 ? '#FFF6CF' : '#FFFFFF').';">
|
||||
<td>'.((int)$loyalty['id'] > 0 ? '<a style="color: #268CCD; font-weight: bold; text-decoration: underline;" href="index.php?tab=AdminOrders&id_order='.$loyalty['id'].'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($params['cookie']->id_employee)).'">'.$this->l('#').sprintf('%06d', $loyalty['id']).'</a>' : '--').'</td>
|
||||
<td>'.Tools::displayDate($loyalty['date'], (int)($params['cookie']->id_lang)).'</td>
|
||||
<td>'.((int)$loyalty['id'] > 0 ? Tools::displayPrice($loyalty['total_without_shipping'],(int)Configuration::get('PS_CURRENCY_DEFAULT')) : '--').'</td>
|
||||
<td>'.Tools::displayPrice((float)$loyalty['discount_value'],(int)Configuration::get('PS_CURRENCY_DEFAULT')).'</td>
|
||||
<td>'.$loyalty['state'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
$html.= '
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>'.$this->l('Voucher value:').'</td>
|
||||
<td>'.Tools::displayPrice($discount_value, new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT'))).'</td>
|
||||
|
@ -11,14 +11,14 @@
|
||||
<tr>
|
||||
<th class="first_item">{l s='Order' mod='loyalty'}</th>
|
||||
<th class="item">{l s='Date' mod='loyalty'}</th>
|
||||
<th class="item">{l s='Total' mod='loyalty'}</th>
|
||||
{*<th class="item">{l s='Total' mod='loyalty'}</th>*}
|
||||
<th class="item">{l s='Discount' mod='loyalty'}</th>
|
||||
<th class="last_item">{l s='Points Status' mod='loyalty'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr class="alternate_item">
|
||||
<td class="history_method"> </td>
|
||||
{*<td class="history_method"> </td>*}
|
||||
<td colspan="2" class="history_method bold" style="text-align:right;">{l s='Total discount available:' mod='loyalty'}</td>
|
||||
<td class="history_method" style="text-align:left;"><span class='total-discount-loyalty'>{Tools::displayPrice($voucher)}</span></td>
|
||||
<td class="history_method"> </td>
|
||||
@ -32,7 +32,7 @@
|
||||
<tr class="alternate_item {if $smarty.foreach.orders.index % 2 == 0}odd{else}even{/if}">
|
||||
<td class="history_link bold">{l s='#' mod='loyalty'}{$order.id|string_format:"%06d"}</td>
|
||||
<td class="history_date">{dateFormat date=$order.date full=1}</td>
|
||||
<td class="history_method">{Tools::displayPrice($order.total_without_shipping)}</td>
|
||||
{*<td class="history_method">{Tools::displayPrice($order.total_without_shipping)}</td>*}
|
||||
<td class="history_method">{Tools::displayPrice($order.discount_value)}</td>
|
||||
<td class="history_method">{$order.state|escape:'htmlall':'UTF-8'}</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user