Merge pull request #866 from shreesh-webkul/gli-943

Fixed: Arrangement of row and column in csv file is wrong
This commit is contained in:
Rohit Jain
2024-03-17 14:44:35 +05:30
committed by GitHub
9 changed files with 80 additions and 26 deletions

View File

@@ -104,7 +104,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'))) {
@@ -197,15 +197,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

View File

@@ -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`

View File

@@ -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->_formats['y'] = 'd';
$this->_query = 'SELECT newsletter_date_add

View File

@@ -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;

View File

@@ -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`

View File

@@ -351,8 +351,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)');
$this->_formats['y'] = 'd';

View File

@@ -172,7 +172,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->_formats['y'] = 'd';
$this->setDateGraph($layers, true);
}

View File

@@ -214,14 +214,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;
}
}

View File

@@ -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