Merge branch 'develop' into gli-1798

This commit is contained in:
Shreesh Arora
2024-06-21 17:54:12 +05:30
87 changed files with 2793 additions and 1547 deletions

View File

@@ -42,11 +42,11 @@ class AdminCartsControllerCore extends AdminController
$this->allow_export = true;
$this->_orderWay = 'DESC';
$this->context = Context::getContext();
$this->_select = 'CONCAT(c.`firstname`, \' \', c.`lastname`) `customer`, a.id_cart total,
TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) AS `time_diff`,
IFNULL(GROUP_CONCAT(DISTINCT o.`id_order`), 0) AS `ids_order`,
IF (IFNULL(o.id_order, \''.$this->l('Non ordered cart').'\') = \''.$this->l('Non ordered cart').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > 86400, \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered cart').'\'), GROUP_CONCAT(DISTINCT o.`id_order`)) AS filter_ids_order,
IF (IFNULL(o.id_order, \''.$this->l('Non ordered cart').'\') = \''.$this->l('Non ordered cart').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > '._TIME_1_DAY_.', \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered cart').'\'), GROUP_CONCAT(DISTINCT o.`id_order`)) AS filter_ids_order,
IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest';
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = a.id_customer)
LEFT JOIN '._DB_PREFIX_.'currency cu ON (cu.id_currency = a.id_currency)
@@ -54,10 +54,6 @@ class AdminCartsControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', co.`date_add`)) < 1800)';
$this->_group = ' GROUP BY a.`id_cart`';
if (Tools::getValue('action') == 'filterOnlyAbandonedCarts') {
$this->_filterHaving = ' AND `ids_order` = 0 AND `time_diff` > 86400';
}
$this->fields_list = array(
'id_cart' => array(
'title' => $this->l('ID'),
@@ -96,7 +92,7 @@ class AdminCartsControllerCore extends AdminController
'type' => 'bool',
'havingFilter' => true,
'class' => 'fixed-width-xs',
'icon' => array(0 => 'icon-', 1 => 'icon-user')
'callback' => 'getOnlineStatus',
)
);
$this->shopLinkType = 'shop';
@@ -117,10 +113,32 @@ class AdminCartsControllerCore extends AdminController
}
parent::__construct();
$this->list_no_link = true;
}
public function postProcess()
{
if (Tools::getValue('action') == 'filterOnlyAbandonedCarts') {
$this->processResetFilters();
$this->context->cookie->{'submitFilter'.$this->table} = true;
$prefix = $this->getCookieFilterPrefix();
$this->context->cookie->{$prefix.$this->table.'Filter_filter_ids_order'} = $this->l('Abandoned cart');
if (($dateFrom = Tools::getValue('date_from'))
&& ($dateTo = Tools::getValue('date_to'))
&& strtotime($dateTo) >= strtotime($dateFrom)
) {
//Updating the date format of the filter dates to the required format.
$dateFrom = date('Y-m-d', strtotime($dateFrom));
$dateTo = date('Y-m-d', strtotime($dateTo));
$this->context->cookie->{$prefix.$this->table.'Filter_'.$this->fields_list['date_add']['filter_key']} = json_encode(array($dateFrom, $dateTo));
}
$this->redirect_after = $this->context->link->getAdminLink('AdminCarts');
}
parent::postProcess();
}
public function getOrderColumn($idsOrder, $tr)
{
$smartyVars = array();
@@ -129,7 +147,7 @@ class AdminCartsControllerCore extends AdminController
$smartyVars['type'] = 'orders';
$smartyVars['ids_order'] = $idsOrder;
} else {
if ($tr['time_diff'] > 86400) {
if ($tr['time_diff'] > _TIME_1_DAY_) {
$smartyVars['type'] = 'abandoned';
} else {
$smartyVars['type'] = 'non_orderd';
@@ -143,6 +161,11 @@ class AdminCartsControllerCore extends AdminController
return $tpl->fetch();
}
public function getOnlineStatus($status)
{
return $status ? $this->l('Yes') : $this->l('No');
}
public function initPageHeaderToolbar()
{
if (empty($this->display)) {
@@ -184,7 +207,7 @@ class AdminCartsControllerCore extends AdminController
$date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day'));
$date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day'));
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to);
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts';
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$date_from.'&date_to='.$date_to;
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
$kpis[] = $helper;