public function add($autodate = true, $null_values = false) { if (!($result = parent::add($autodate, $null_values))) { return false; } Referrer::refreshCache(array(array('id_referrer' => $this->id))); Referrer::refreshIndex(array(array('id_referrer' => $this->id))); return $result; }
public function displayAccount() { global $smarty, $cookie; if (!isset($cookie->stats_date_from)) { $cookie->stats_date_from = date('Y-m-d'); } if (!isset($cookie->stats_date_to)) { $cookie->stats_date_to = date('Y-m-t'); } $fakeEmployee = new Employee(); $fakeEmployee->stats_date_from = $cookie->stats_date_from; $fakeEmployee->stats_date_to = $cookie->stats_date_to; Referrer::refreshCache(array(array('id_referrer' => intval($cookie->tracking_id))), $fakeEmployee); $referrer = new Referrer(intval($cookie->tracking_id)); $smarty->assign('referrer', $referrer); $smarty->assign('datepickerFrom', $fakeEmployee->stats_date_from); $smarty->assign('datepickerTo', $fakeEmployee->stats_date_to); $displayTab = array('uniqs' => $this->l('Unique visitors'), 'visitors' => $this->l('Visitors'), 'visits' => $this->l('Visits'), 'pages' => $this->l('Pages viewed'), 'registrations' => $this->l('Registrations'), 'orders' => $this->l('Orders'), 'base_fee' => $this->l('Base fee'), 'percent_fee' => $this->l('Percent fee'), 'click_fee' => $this->l('Click fee'), 'sales' => $this->l('Sales'), 'cart' => $this->l('Average cart'), 'reg_rate' => $this->l('Registration rate'), 'order_rate' => $this->l('Order rate')); $smarty->assign('displayTab', $displayTab); $products = Product::getSimpleProducts(intval($cookie->id_lang)); $productsArray = array(); foreach ($products as $product) { $productsArray[] = $product['id_product']; } $echo = ' <script type="text/javascript" src="../../js/jquery/datepicker/ui/i18n/ui.datepicker-' . Db::getInstance()->getValue('SELECT iso_code FROM ' . _DB_PREFIX_ . 'lang WHERE `id_lang` = ' . intval($cookie->id_lang)) . '.js"></script> <script type="text/javascript"> $("#datepickerFrom").datepicker({ prevText:"", nextText:"", dateFormat:"yy-mm-dd"}); $("#datepickerTo").datepicker({ prevText:"", nextText:"", dateFormat:"yy-mm-dd"}); function updateValues() { $.getJSON("stats.php",{ajaxProductFilter:1,id_referrer:' . $referrer->id . ',token:"' . $cookie->tracking_passwd . '",id_product:0}, function(j) {'; foreach ($displayTab as $key => $value) { $echo .= '$("#' . $key . '").html(j[0].' . $key . ');'; } $echo .= ' } ) } var productIds = new Array(\'' . implode('\',\'', $productsArray) . '\'); var referrerStatus = new Array(); function newProductLine(id_referrer, result, color) { return \'\'+ \'<tr id="trprid_\'+id_referrer+\'_\'+result.id_product+\'" style="background-color: rgb(\'+color+\', \'+color+\', \'+color+\');">\'+ \' <td align="center">\'+result.id_product+\'</td>\'+ \' <td>\'+result.product_name+\'</td>\'+ \' <td align="center">\'+result.uniqs+\'</td>\'+ \' <td align="center">\'+result.visits+\'</td>\'+ \' <td align="center">\'+result.pages+\'</td>\'+ \' <td align="center">\'+result.registrations+\'</td>\'+ \' <td align="center">\'+result.orders+\'</td>\'+ \' <td align="right">\'+result.sales+\'</td>\'+ \' <td align="right">\'+result.cart+\'</td>\'+ \' <td align="center">\'+result.reg_rate+\'</td>\'+ \' <td align="center">\'+result.order_rate+\'</td>\'+ \' <td align="center">\'+result.click_fee+\'</td>\'+ \' <td align="center">\'+result.base_fee+\'</td>\'+ \' <td align="center">\'+result.percent_fee+\'</td>\'+ \'</tr>\'; } function showProductLines() { var irow = 0; for (var i = 0; i < productIds.length; ++i) $.getJSON("stats.php",{ajaxProductFilter:1,token:"' . $cookie->tracking_passwd . '",id_referrer:' . $referrer->id . ',id_product:productIds[i]}, function(result) { var newLine = newProductLine(' . $referrer->id . ', result[0], (irow++%2 ? 204 : 238)); $(newLine).hide().insertBefore($(\'#trid_dummy\')).fadeIn(); } ); } </script>'; $echo2 = ' <script type="text/javascript"> updateValues(); //showProductLines(); </script>'; return $this->display(__FILE__, 'header.tpl') . $echo . $this->display(__FILE__, 'account.tpl') . $echo2; }
public function displayAccount() { if (!isset($this->context->cookie->stats_date_from)) { $this->context->cookie->stats_date_from = date('Y-m-01'); } if (!isset($this->context->cookie->stats_date_to)) { $this->context->cookie->stats_date_to = date('Y-m-t'); } Referrer::refreshCache(array(array('id_referrer' => (int) $this->context->cookie->tracking_id))); $referrer = new Referrer((int) $this->context->cookie->tracking_id); $this->smarty->assign('referrer', $referrer); $this->smarty->assign('datepickerFrom', $this->context->cookie->stats_date_from); $this->smarty->assign('datepickerTo', $this->context->cookie->stats_date_to); $display_tab = array('uniqs' => $this->l('Unique visitors'), 'visitors' => $this->l('Visitors'), 'visits' => $this->l('Visits'), 'pages' => $this->l('Pages viewed'), 'registrations' => $this->l('Registrations'), 'orders' => $this->l('Orders'), 'base_fee' => $this->l('Base fee'), 'percent_fee' => $this->l('Percent fee'), 'click_fee' => $this->l('Click fee'), 'sales' => $this->l('Sales'), 'cart' => $this->l('Average cart'), 'reg_rate' => $this->l('Registration rate'), 'order_rate' => $this->l('Order rate')); $this->smarty->assign('displayTab', $display_tab); $products = Product::getSimpleProducts($this->context->language->id); $products_array = array(); foreach ($products as $product) { $products_array[] = $product['id_product']; } $js_files = array(); $jquery_files = Media::getJqueryPath(); if (is_array($jquery_files)) { $js_files = array_merge($js_files, $jquery_files); } else { $js_files[] = $jquery_files; } $jquery_ui_files = Media::getJqueryUIPath('ui.datepicker', 'base', true); $js_files = array_merge($js_files, $jquery_ui_files['js']); $css_files = $jquery_ui_files['css']; $js_files[] = $this->_path . 'js/trackingfront.js'; $js_tpl_var = array('product_ids' => implode(', ', $products_array), 'referrer_id' => $referrer->id, 'token' => $this->context->cookie->tracking_passwd, 'display_tab' => implode('", "', array_keys($display_tab))); $this->smarty->assign(array('js' => $js_files, 'css' => $css_files, 'js_tpl_var' => $js_tpl_var)); return $this->display(__FILE__, 'views/templates/front/account.tpl'); }
public function postProcess() { global $currentIndex; if ($this->enableCalendar()) { $calendarTab = new AdminStats(); $calendarTab->postProcess(); } if (Tools::isSubmit('submitSettings')) { if ($this->tabAccess['edit'] === '1') { if (Configuration::updateValue('TRACKING_DIRECT_TRAFFIC', (int) Tools::getValue('tracking_dt'))) { Tools::redirectAdmin($currentIndex . '&conf=4&token=' . Tools::getValue('token')); } } } if (ModuleGraph::getDateBetween() != Configuration::get('PS_REFERRERS_CACHE_LIKE') or Tools::isSubmit('submitRefreshCache')) { Referrer::refreshCache(); } if (Tools::isSubmit('submitRefreshIndex')) { Referrer::refreshIndex(); } return parent::postProcess(); }
public function postProcess() { if ($this->enableCalendar()) { // Warning, instantiating a controller here changes the controller in the Context... $calendar_tab = new AdminStatsController(); $calendar_tab->postProcess(); // ...so we set it back to the correct one here $this->context->controller = $this; } if (Tools::isSubmit('submitSettings')) { if ($this->tabAccess['edit'] === '1') { if (Configuration::updateValue('TRACKING_DIRECT_TRAFFIC', (int) Tools::getValue('tracking_dt'))) { Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . Tools::getValue('token')); } } } if (ModuleGraph::getDateBetween() != Configuration::get('PS_REFERRERS_CACHE_LIKE') || Tools::isSubmit('submitRefreshCache')) { Referrer::refreshCache(); } if (Tools::isSubmit('submitRefreshIndex')) { Referrer::refreshIndex(); } return parent::postProcess(); }