Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F727062
D397.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jan 6, 5:56 AM
Size
12 KB
Mime Type
text/x-diff
Expires
Tue, Jan 7, 5:56 AM (2 d, 22 h ago)
Engine
blob
Format
Raw Data
Handle
537128
Attached To
D397: MINC-197 - Improve user experience for "E-commerce > Sales Report" section
D397.id.diff
View Options
Index: branches/5.2.x/admin_templates/reports/results.tpl
===================================================================
--- branches/5.2.x/admin_templates/reports/results.tpl
+++ branches/5.2.x/admin_templates/reports/results.tpl
@@ -1,5 +1,9 @@
<inp2:m_include t="incs/header"/>
-<inp2:m_RenderElement name="combined_header" prefix="rep" section="in-commerce:reports" pagination="1" title_preset="report_results"/>
+
+<inp2:rep.metric_SyncIDFieldDeclaration/>
+<inp2:rep.metric_ReportOptionValue name="grid" result_to_var="grid"/>
+
+<inp2:m_RenderElement name="combined_header" prefix="rep" section="in-commerce:reports" grid="$grid" pagination="1" title_preset="report_results"/>
<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%">
@@ -34,6 +38,9 @@
a_toolbar.AddButton( new ToolBarButton('export', '<inp2:m_phrase label="la_ToolTip_Export" escape="1"/>', function() {
submit_event('rep','OnExportReport');
+
+ set_hidden_field('events[rep]', null);
+ submitted = false;
}
) );
@@ -55,14 +62,16 @@
</script>
</td>
- <inp2:m_RenderElement name="search_main_toolbar" prefix="rep" grid="Default"/>
+ <inp2:m_RenderElement name="search_main_toolbar" prefix="rep" grid="$grid"/>
</tr>
</tbody>
</table>
-<inp2:m_RenderElement name="grid" PrefixSpecial="rep" IdField="CategoryId" grid="Default" totals_render_as="grid_total_row"/>
+<inp2:rep.metric_ReportOptionValue name="id_field" result_to_var="id_field"/>
+
+<inp2:m_RenderElement name="grid" PrefixSpecial="rep" IdField="$id_field" grid="$grid" totals_render_as="grid_total_row"/>
<script type="text/javascript">
Grids['rep'].SetDependantToolbarButtons( new Array() );
</script>
-<inp2:m_include t="incs/footer"/>
\ No newline at end of file
+<inp2:m_include t="incs/footer"/>
Index: branches/5.2.x/units/reports/reports_config.php
===================================================================
--- branches/5.2.x/units/reports/reports_config.php
+++ branches/5.2.x/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: branches/5.2.x/units/reports/reports_event_handler.php
===================================================================
--- branches/5.2.x/units/reports/reports_event_handler.php
+++ branches/5.2.x/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,
@@ -318,10 +327,7 @@
}
}
- $vars = array('rep_Page', 'rep_Sort1', 'rep_Sort1_Dir', 'rep_Sort2', 'rep_Sort2_Dir');
- foreach ($vars as $var_name) {
- $this->Application->RemoveVar($var_name);
- }
+ $event->CallSubEvent('OnResetSorting');
//temporary
$event->redirect = $this->Application->GetVar('reports_finish_t');
@@ -340,6 +346,7 @@
}
$field_values = unserialize($report);
+ $grid = $field_values['grid'];
$rep_options = $this->Application->getUnitOptions('rep');
$new_options = Array ();
@@ -375,12 +382,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 +409,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 +423,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 +448,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 +487,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 +515,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 +530,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 +548,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 +558,7 @@
'default' => 1
);
- $new_options['Grids']['Default'] = Array(
+ $new_options['Grids'][$grid] = Array(
'Icons' => Array(
'default' => 'icon16_item.png',
'module' => 'core',
@@ -569,7 +581,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 +642,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 +773,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 +843,6 @@
$ret = str_replace('<tab>',',', $ret);
$ret = str_replace('<cr>',"\r", $ret);
- $report_options = unserialize($this->Application->RecallVar('report_options'));
-
switch ($report_options['ReportType'])
{
case 1:
Index: branches/5.2.x/units/reports/reports_tag_processor.php
===================================================================
--- branches/5.2.x/units/reports/reports_tag_processor.php
+++ branches/5.2.x/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
+}
Event Timeline
Log In to Comment