Index: modules/in-commerce/admin_templates/reports/results.tpl
===================================================================
--- modules/in-commerce/admin_templates/reports/results.tpl
+++ modules/in-commerce/admin_templates/reports/results.tpl
@@ -1,5 +1,9 @@
-
+
+
+
+
+
-
+
+
+
-
\ No newline at end of file
+
Index: modules/in-commerce/units/reports/reports_config.php
===================================================================
--- modules/in-commerce/units/reports/reports_config.php
+++ modules/in-commerce/units/reports/reports_config.php
@@ -42,7 +42,7 @@
),
),
- 'IDField' => 'CategoryId',
+ 'IDField' => '__DYNAMIC__',
'TitlePresets' => Array (
'default' => Array (
@@ -83,10 +83,11 @@
'CalculatedFields' => Array (
'' => Array (
- 'CategoryId' => '0',
),
),
+ 'Fields' => array(),
+
'VirtualFields' => Array (
'ReportType' => array('formatter' => 'kOptionsFormatter', 'options' =>array(
12 => 'la_Overall',
@@ -110,7 +111,6 @@
'options' => Array (0 => 'la_No', 1 => 'la_Yes'),
'use_phrases' => 1, 'not_null' => 1, 'default' => 1,
),
- 'CategoryId' => Array ('type' => 'int', 'default' => 0),
),
'Grids' => Array (
Index: modules/in-commerce/units/reports/reports_event_handler.php
===================================================================
--- modules/in-commerce/units/reports/reports_event_handler.php
+++ modules/in-commerce/units/reports/reports_event_handler.php
@@ -55,6 +55,7 @@
$object->UpdateFormattersMasterFields();
$field_values['offset'] = 0;
+ $field_values['export_ignore'] = '';
$table_name = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_SaleReport';
$field_values['table_name'] = $table_name;
$this->Conn->Query('DROP TABLE IF EXISTS '.$table_name);
@@ -116,6 +117,8 @@
}
if ($field_values['ReportType'] == 1) { // by Category
+ $field_values['id_field'] = $field_values['export_ignore'] = 'CategoryId';
+ $field_values['grid'] = 'ByCategory';
$q = 'CREATE TABLE '.$table_name.' (
CategoryId int(11) NOT NULL DEFAULT 0,
Qty int(11) NOT NULL DEFAULT 0,
@@ -162,6 +165,8 @@
$this->Conn->Query($q);
}
elseif ($field_values['ReportType'] == 2) { // by User
+ $field_values['id_field'] = $field_values['export_ignore'] = 'PortalUserId';
+ $field_values['grid'] = 'ByUser';
$q = 'CREATE TABLE '.$table_name.' (
PortalUserId int(11) NOT NULL DEFAULT 0,
Qty int(11) NOT NULL DEFAULT 0,
@@ -199,6 +204,8 @@
$this->Conn->Query($q);
}
elseif ($field_values['ReportType'] == 5) { // by Product
+ $field_values['id_field'] = $field_values['export_ignore'] = 'ProductId';
+ $field_values['grid'] = 'ByProduct';
$q = 'CREATE TABLE '.$table_name.' (
ProductId int(11) NOT NULL DEFAULT 0,
Qty int(11) NOT NULL DEFAULT 0,
@@ -239,6 +246,8 @@
$this->Conn->Query($q);
}
elseif ($field_values['ReportType'] == 12) { // Overall
+ $field_values['id_field'] = 'Marketplace';
+ $field_values['grid'] = 'Overall';
$q = 'CREATE TABLE '.$table_name.' (
Marketplace tinyint(1) NOT NULL DEFAULT 0,
Qty int(11) NOT NULL DEFAULT 0,
@@ -340,6 +349,7 @@
}
$field_values = unserialize($report);
+ $grid = $field_values['grid'];
$rep_options = $this->Application->getUnitOptions('rep');
$new_options = Array ();
@@ -375,12 +385,14 @@
'SELECT %1$s.* %2$s FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Categories AS c
ON c.CategoryId = %1$s.CategoryId';
- $new_options['Grids']['Default'] = Array (
+ $new_options['Fields']['CategoryId'] = Array ('type' => 'int', 'default' => null);
+ $new_options['Grids'][$grid] = Array (
'Icons' => Array (
'default' => 'icon16_item.png',
'module' => 'core',
),
'Fields' => Array (
+ 'CategoryId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter', 'hidden' => 1),
'CategoryName' => Array ('title' => 'la_col_CategoryName', 'filter_block' => 'grid_like_filter'),
'Qty' => Array ('td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'),
'StoreQty' => Array ('title' => 'la_col_StoreQty', 'td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'),
@@ -400,7 +412,7 @@
);
if (!$this->Application->isModuleEnabled('in-auction')) {
- $a_fields =& $new_options['Grids']['Default']['Fields'];
+ $a_fields =& $new_options['Grids'][$grid]['Fields'];
unset($a_fields['StoreQty']);
unset($a_fields['eBayQty']);
unset($a_fields['StoreAmount']);
@@ -414,7 +426,7 @@
'Metric' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
- 'options' => $this->GetMetricOptions($new_options, 'CategoryName'),
+ 'options' => $this->GetMetricOptions($new_options, array('CategoryId', 'CategoryName'), $grid),
'use_phrases' => 1,
'default' => 0,
),
@@ -439,13 +451,14 @@
'SELECT %1$s.* %2$s FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Users AS u
ON u.PortalUserId = %1$s.PortalUserId';
-
- $new_options['Grids']['Default'] = Array (
+ $new_options['Fields']['PortalUserId'] = Array ('type' => 'int', 'default' => null);
+ $new_options['Grids'][$grid] = Array (
'Icons' => Array (
'default' => 'icon16_item.png',
'module' => 'core',
),
'Fields' => Array (
+ 'PortalUserId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter', 'hidden' => 1),
'Login' => Array ('filter_block' => 'grid_like_filter'),
'FirstName' => Array ('filter_block' => 'grid_like_filter'),
'LastName' => Array ('filter_block' => 'grid_like_filter'),
@@ -477,13 +490,14 @@
'SELECT %1$s.* %2$s FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Products AS p
ON p.ProductId = %1$s.ProductId';
-
- $new_options['Grids']['Default'] = Array (
+ $new_options['Fields']['ProductId'] = Array ('type' => 'int', 'default' => null);
+ $new_options['Grids'][$grid] = Array (
'Icons' => Array (
'default' => 'icon16_item.png',
'module' => 'core',
),
'Fields' => Array (
+ 'ProductId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter', 'hidden' => 1),
'ProductName' => Array ('title' => 'la_col_ProductName', 'filter_block' => 'grid_like_filter'),
'Qty' => Array ('td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'),
'StoreQty' => Array ('title' => 'la_col_StoreQty', 'td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'),
@@ -504,7 +518,7 @@
if (!$this->Application->isModuleEnabled('in-auction'))
{
- $a_fields =& $new_options['Grids']['Default']['Fields'];
+ $a_fields =& $new_options['Grids'][$grid]['Fields'];
unset($a_fields['StoreQty']);
unset($a_fields['eBayQty']);
unset($a_fields['StoreAmount']);
@@ -519,7 +533,7 @@
'Metric' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
- 'options' => $this->GetMetricOptions($new_options, 'ProductName'),
+ 'options' => $this->GetMetricOptions($new_options, array('ProductId', 'ProductName'), $grid),
'use_phrases' => 1,
'default' => 0
),
@@ -537,6 +551,7 @@
'SELECT %1$s.* %2$s FROM %1$s';
$new_options['Fields']['Marketplace'] = Array (
+ 'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (
1 => 'la_OnlineStore',
@@ -546,7 +561,7 @@
'default' => 1
);
- $new_options['Grids']['Default'] = Array(
+ $new_options['Grids'][$grid] = Array(
'Icons' => Array(
'default' => 'icon16_item.png',
'module' => 'core',
@@ -569,7 +584,7 @@
'Metric' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
- 'options' => $this->GetMetricOptions($new_options, 'Marketplace'),
+ 'options' => $this->GetMetricOptions($new_options, array('Marketplace'), $grid),
'use_phrases' => 1,
'default' => 0
),
@@ -630,20 +645,24 @@
/**
* Generate Metric Field Options
*
- * @param array $a_config_options
- * @param string $exclude_field
+ * @param array $a_config_options Config options.
+ * @param array $exclude_fields Exclude fields.
+ * @param string $grid Grid.
+ *
+ * @return array
*/
- function GetMetricOptions(&$a_config_options, $exclude_field)
+ function GetMetricOptions(&$a_config_options, array $exclude_fields, $grid)
{
- $a_ret = Array();
- foreach ($a_config_options['Grids']['Default']['Fields'] AS $field => $a_options)
- {
- if ($field == $exclude_field)
- {
+ $a_ret = array();
+
+ foreach ( $a_config_options['Grids'][$grid]['Fields'] as $field => $a_options ) {
+ if ( in_array($field, $exclude_fields) ) {
continue;
}
- $a_ret[$field] = $a_options['title'];
+
+ $a_ret[$field] = isset($a_options['title']) ? $a_options['title'] : 'column:la_fld_' . $field;
}
+
return $a_ret;
}
@@ -757,8 +776,15 @@
/** @var kDBItem $ReportItem */
$ReportItem = $this->Application->recallObject('rep.item', 'rep', Array('skip_autoload' => true));
- $a_grids = $this->Application->getUnitOption('rep', 'Grids');
- $a_fields = $a_grids['Default']['Fields'];
+ $report_options = unserialize($this->Application->RecallVar('report_options'));
+
+ $a_grids = $this->Application->getUnitOption('rep', 'Grids');
+ $a_fields = $a_grids[$report_options['grid']]['Fields'];
+
+ if ( $report_options['export_ignore'] ) {
+ unset($a_fields[$report_options['export_ignore']]);
+ }
+
$ret = '';
foreach ($a_fields AS $field => $a_props)
@@ -820,8 +846,6 @@
$ret = str_replace('',',', $ret);
$ret = str_replace('',"\r", $ret);
- $report_options = unserialize($this->Application->RecallVar('report_options'));
-
switch ($report_options['ReportType'])
{
case 1:
Index: modules/in-commerce/units/reports/reports_tag_processor.php
===================================================================
--- modules/in-commerce/units/reports/reports_tag_processor.php
+++ modules/in-commerce/units/reports/reports_tag_processor.php
@@ -85,6 +85,35 @@
return ($field_values['ReportType'] == $params['value']);
}
+ /**
+ * Returns report option value.
+ *
+ * @param array $params Tag params.
+ *
+ * @return string
+ */
+ protected function ReportOptionValue(array $params)
+ {
+ $field_values = unserialize($this->Application->RecallVar('report_options'));
+
+ return $field_values[$params['name']];
+ }
+
+ /**
+ * Replaces "IDField" unit config option to be inline with current report
+ *
+ * @param array $params Tag params.
+ *
+ * @return string
+ */
+ protected function SyncIDFieldDeclaration(array $params)
+ {
+ $field_values = unserialize($this->Application->RecallVar('report_options'));
+ $this->Application->setUnitOption($this->Prefix, 'IDField', $field_values['id_field']);
+
+ return '';
+ }
+
function CalculateChart($params)
{
@@ -435,4 +464,4 @@
$curver = explode(".", phpversion());
return ($curver[0] >= $params['version']);
}
-}
\ No newline at end of file
+}