diff --git a/classes/module/ModuleGraph.php b/classes/module/ModuleGraph.php index a68560201..9596c9e9b 100644 --- a/classes/module/ModuleGraph.php +++ b/classes/module/ModuleGraph.php @@ -102,7 +102,7 @@ abstract class ModuleGraphCore extends Module $this->_values[$j][$i] = 0; } } - $this->_legend[$i] = ($i % 2) ? '' : sprintf('%02d', $i); + $this->_legend[$i] = sprintf('%02d', $i); } } if (is_callable(array($this, 'setMonthValues'))) { @@ -195,15 +195,15 @@ abstract class ModuleGraphCore extends Module if (count($this->_legend)) { $total = 0; if ($datas['type'] == 'pie') { - foreach ($this->_legend as $key => $legend) { + // foreach ($this->_legend as $key => $legend) { for ($i = 0, $total_main = (is_array($this->_titles['main']) ? count($this->_values) : 1); $i < $total_main; ++$i) { - $total += (is_array($this->_values[$i]) ? $this->_values[$i][$key] : $this->_values[$key]); + $total += (is_array($this->_values[$i]) ? $this->_values[$i][$key] : $this->_values[$i]); } - } + // } } foreach ($this->_legend as $key => $legend) { $this->_csv .= $legend.';'; - for ($i = 0, $total_main = (is_array($this->_titles['main']) ? count($this->_values) : 1); $i < $total_main; ++$i) { + for ($i = 0, $total_main = (is_array($this->_titles['main']) ? (count($this->_titles['main']) - 1) : 1); $i < $total_main; ++$i) { if (!isset($this->_values[$i]) || !is_array($this->_values[$i])) { if (isset($this->_values[$key])) { // We don't want strings to be divided. Example: product name diff --git a/modules/statsequipment/statsequipment.php b/modules/statsequipment/statsequipment.php index 69a596cea..5827f13ff 100644 --- a/modules/statsequipment/statsequipment.php +++ b/modules/statsequipment/statsequipment.php @@ -179,7 +179,10 @@ class StatsEquipment extends ModuleGraph { switch ($option) { case 'wb': - $this->_titles['main'] = $this->l('Web browser used'); + $this->_titles['main'][] = $this->l('Web browser used'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = ''; + } $this->query = 'SELECT wb.`name`, COUNT(g.`id_web_browser`) AS total FROM `'._DB_PREFIX_.'web_browser` wb LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_web_browser` = wb.`id_web_browser` @@ -191,7 +194,10 @@ class StatsEquipment extends ModuleGraph break; case 'os': - $this->_titles['main'] = $this->l('Operating system used'); + $this->_titles['main'][] = $this->l('Operating system used'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = ''; + } $this->query = 'SELECT os.`name`, COUNT(g.`id_operating_system`) AS total FROM `'._DB_PREFIX_.'operating_system` os LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_operating_system` = os.`id_operating_system` diff --git a/modules/statsnewsletter/statsnewsletter.php b/modules/statsnewsletter/statsnewsletter.php index ea837ec28..19938822f 100644 --- a/modules/statsnewsletter/statsnewsletter.php +++ b/modules/statsnewsletter/statsnewsletter.php @@ -125,10 +125,12 @@ class StatsNewsletter extends ModuleGraph protected function getData($layers) { - $this->_titles['main'][0] = $this->l('Customers'); - $this->_titles['main'][1] = $this->l('Visitors'); - $this->_titles['main'][2] = $this->l('Newsletter statistics'); - $this->_titles['main'][3] = $this->l('Both'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Date'); + } + $this->_titles['main'][] = $this->l('Customers'); + $this->_titles['main'][] = $this->l('Visitors'); + $this->_titles['main'][] = $this->l('Both'); $this->_query = 'SELECT newsletter_date_add FROM `'._DB_PREFIX_.'customer` diff --git a/modules/statsorigin/statsorigin.php b/modules/statsorigin/statsorigin.php index 32bfe8f82..020ca10e3 100644 --- a/modules/statsorigin/statsorigin.php +++ b/modules/statsorigin/statsorigin.php @@ -142,7 +142,10 @@ class StatsOrigin extends ModuleGraph protected function getData($layers) { - $this->_titles['main'] = $this->l('Top ten referral websites'); + $this->_titles['main'][] = $this->l('Top ten referral websites'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Referal percentage'); + } $websites = $this->getOrigins($this->getDate()); $total = 0; $total2 = 0; diff --git a/modules/statspersonalinfos/statspersonalinfos.php b/modules/statspersonalinfos/statspersonalinfos.php index a08bee698..7b4e21af9 100644 --- a/modules/statspersonalinfos/statspersonalinfos.php +++ b/modules/statspersonalinfos/statspersonalinfos.php @@ -212,7 +212,12 @@ class StatsPersonalInfos extends ModuleGraph { switch ($this->option) { case 'gender': - $this->_titles['main'] = $this->l('Gender distribution'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Gender'); + $this->_titles['main'][] = ''; + } else { + $this->_titles['main'] = $this->l('Gender distribution'); + } $genders = array( 0 => $this->l('Male'), 1 => $this->l('Female'), @@ -243,7 +248,12 @@ class StatsPersonalInfos extends ModuleGraph break; case 'age': - $this->_titles['main'] = $this->l('Age range'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Age'); + $this->_titles['main'][] = ''; + } else { + $this->_titles['main'] = $this->l('Age range'); + } // 0 - 18 years $sql = 'SELECT COUNT(`id_customer`) as total @@ -334,7 +344,12 @@ class StatsPersonalInfos extends ModuleGraph break; case 'country': - $this->_titles['main'] = $this->l('Country distribution'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Country'); + $this->_titles['main'][] = ''; + } else { + $this->_titles['main'] = $this->l('Country distribution'); + } $sql = 'SELECT cl.`name`, COUNT(c.`id_country`) AS total FROM `'._DB_PREFIX_.'address` a LEFT JOIN `'._DB_PREFIX_.'customer` cu ON cu.id_customer = a.id_customer @@ -351,7 +366,12 @@ class StatsPersonalInfos extends ModuleGraph break; case 'currency': - $this->_titles['main'] = $this->l('Currency distribution'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Currency'); + $this->_titles['main'][] = ''; + } else { + $this->_titles['main'] = $this->l('Currency distribution'); + } $sql = 'SELECT c.`name`, COUNT(c.`id_currency`) AS total FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'currency` c ON o.`id_currency` = c.`id_currency` @@ -366,7 +386,12 @@ class StatsPersonalInfos extends ModuleGraph break; case 'language': - $this->_titles['main'] = $this->l('Language distribution'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Language'); + $this->_titles['main'][] = ''; + } else { + $this->_titles['main'] = $this->l('Language distribution'); + } $sql = 'SELECT c.`name`, COUNT(c.`id_lang`) AS total FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'lang` c ON o.`id_lang` = c.`id_lang` diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index fcd91f0e6..feba386e3 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -339,8 +339,11 @@ class StatsProduct extends ModuleGraph $date_between = $this->getDate(); switch ($this->option) { case 1: - $this->_titles['main'][0] = $this->l('Room nights'); - $this->_titles['main'][1] = $this->l('Views (x100)'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Date'); + } + $this->_titles['main'][] = $this->l('Room nights'); + $this->_titles['main'][] = $this->l('Views (x100)'); $this->_titles['x'] = $this->l('Date'); $this->_titles['y'] = $this->l('Room nights, Views (x100)'); diff --git a/modules/statsregistrations/statsregistrations.php b/modules/statsregistrations/statsregistrations.php index 6931a4cc6..030958cc0 100644 --- a/modules/statsregistrations/statsregistrations.php +++ b/modules/statsregistrations/statsregistrations.php @@ -170,7 +170,10 @@ class StatsRegistrations extends ModuleGraph WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' AND `date_add` BETWEEN'; - $this->_titles['main'] = $this->l('Number of customer registrations'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Date'); + } + $this->_titles['main'][] = $this->l('Number of customer registrations'); $this->setDateGraph($layers, true); } diff --git a/modules/statssales/statssales.php b/modules/statssales/statssales.php index c56931ab6..6ae972257 100644 --- a/modules/statssales/statssales.php +++ b/modules/statssales/statssales.php @@ -216,14 +216,23 @@ class StatsSales extends ModuleGraph list($this->option, $this->id_country, $this->id_hotel) = explode('-', $options); switch ($this->option) { case 1: - $this->_titles['main'] = $this->l('Orders placed'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Date'); + } + $this->_titles['main'][] = $this->l('Orders placed'); break; case 2: + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Date'); + } $currency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT')); - $this->_titles['main'] = sprintf($this->l('Revenue currency: %s'), $currency->iso_code); + $this->_titles['main'][] = sprintf($this->l('Revenue currency: %s'), $currency->iso_code); break; case 3: - $this->_titles['main'] = $this->l('Percentage of orders per status.'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Payment method'); + } + $this->_titles['main'][] = $this->l('Percentage of orders per status.'); break; } } diff --git a/modules/statsvisits/statsvisits.php b/modules/statsvisits/statsvisits.php index f96716af5..aab29d1d8 100644 --- a/modules/statsvisits/statsvisits.php +++ b/modules/statsvisits/statsvisits.php @@ -137,9 +137,12 @@ class StatsVisits extends ModuleGraph { switch ($option) { case 3: - $this->_titles['main'][0] = $this->l('Visits'); - $this->_titles['main'][1] = $this->l('Number of visits and unique visitors'); - $this->_titles['main'][2] = $this->l('Visitors'); + if (Tools::getValue('export')) { + $this->_titles['main'][] = $this->l('Date'); + } + + $this->_titles['main'][] = $this->l('Visits'); + $this->_titles['main'][] = $this->l('Number of visits and unique visitors'); $this->query[0] = 'SELECT date_add, COUNT(`date_add`) as total FROM `'._DB_PREFIX_.'connections` WHERE 1