Index: branches/5.3.x/units/reports/reports_event_handler.php =================================================================== diff -u -N -r15492 -r15695 --- branches/5.3.x/units/reports/reports_event_handler.php (.../reports_event_handler.php) (revision 15492) +++ branches/5.3.x/units/reports/reports_event_handler.php (.../reports_event_handler.php) (revision 15695) @@ -1,6 +1,6 @@ Application->StoreVar('report_options', serialize($field_values)); } - function OnUpdateConfig($event) + function OnUpdateConfig(kEvent $event) { $report = $this->Application->RecallVar('report_options'); - if (!$report) { - return ; + + if ( !$report ) { + return; } $field_values = unserialize($report); - $rep_options = $this->Application->getUnitOptions('rep'); - $new_options = Array (); + $config = $event->getUnitConfig('rep'); + $config->setTableName($field_values['table_name']); - $new_options['TableName'] = $field_values['table_name']; - - $new_options['Fields'] = Array ( + $config->addFields(Array ( 'Qty' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%d', 'default' => 0, 'totals' => 'sum'), 'Cost' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'Amount' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'Tax' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'Shipping' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'Processing' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'Profit' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), - ); + )); if ( $this->Application->isModuleEnabled('in-auction') ) { - if ( in_Array ($field_values['ReportType'], Array (1, 5)) ) { - $new_options['Fields'] += Array ( + if ( in_array($field_values['ReportType'], Array (1, 5)) ) { + $config->addFields(Array ( 'StoreQty' => Array ('type' => 'int', 'formatter' => 'kFormatter', 'format' => '%d', 'default' => 0, 'totals' => 'sum'), 'StoreAmount' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'StoreProfit' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'eBayQty' => Array ('type' => 'int', 'formatter' => 'kFormatter', 'format' => '%d', 'default' => 0, 'totals' => 'sum'), 'eBayAmount' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), 'eBayProfit' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.2f', 'default' => 0, 'totals' => 'sum'), - ); + )); } } - if ($field_values['ReportType'] == 1) { // by Category + if ( $field_values['ReportType'] == 1 ) { // by Category + $config->setListSQLsBySpecial('', ' SELECT %1$s.* %2$s + FROM %1$s + LEFT JOIN ' . TABLE_PREFIX . 'Categories AS c ON c.CategoryId = %1$s.CategoryId'); - $new_options['ListSQLs'][''] = - '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 ( - 'Icons' => Array ( - 'default' => 'icon16_item.png', - 'module' => 'core', - ), - 'Fields' => Array ( - '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'), - 'eBayQty' => Array ('title' => 'la_col_eBayQty', 'td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'StoreAmount' => Array ('title' => 'la_col_StoreGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'eBayAmount' => Array ('title' => 'la_col_eBayGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'StoreProfit' => Array ('title' => 'la_col_StoreProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'eBayProfit' => Array ('title' => 'la_col_eBayProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - ), - - ); - - if (!$this->Application->isModuleEnabled('in-auction')) { - $a_fields =& $new_options['Grids']['Default']['Fields']; - unset($a_fields['StoreQty']); - unset($a_fields['eBayQty']); - unset($a_fields['StoreAmount']); - unset($a_fields['eBayAmount']); - unset($a_fields['StoreProfit']); - unset($a_fields['eBayProfit']); + if ( $this->Application->isModuleEnabled('in-auction') ) { + $config->addGrids(Array ( + 'Icons' => Array ('default' => 'icon16_item.png', 'module' => 'core'), + 'Fields' => Array ( + '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'), + 'eBayQty' => Array ('title' => 'la_col_eBayQty', 'td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'StoreAmount' => Array ('title' => 'la_col_StoreGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'eBayAmount' => Array ('title' => 'la_col_eBayGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'StoreProfit' => Array ('title' => 'la_col_StoreProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'eBayProfit' => Array ('title' => 'la_col_eBayProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + ), + ), 'Default'); } + else { + $config->addGrids(Array ( + 'Icons' => Array ('default' => 'icon16_item.png', 'module' => 'core'), + 'Fields' => Array ( + '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'), + 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + ), + ), 'Default'); + } - $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( + $config->addVirtualFields(Array ( 'CategoryName' => Array ('type' => 'string', 'default' => ''), - 'Metric' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', - 'options' => $this->GetMetricOptions($new_options, 'CategoryName'), - 'use_phrases' => 1, - 'default' => 0, - ), + 'Metric' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', + 'options' => $this->GetMetricOptions($config, 'CategoryName'), + 'use_phrases' => 1, + 'default' => 0, + ), )); $lang = $this->Application->GetVar('m_lang'); // products root category $products_category_id = $this->Application->findModule('Name', 'In-Commerce', 'RootCat'); + // get root category name $sql = 'SELECT LENGTH(l' . $lang . '_CachedNavbar) FROM ' . TABLE_PREFIX . 'Categories WHERE CategoryId = '.$products_category_id; $root_length = $this->Conn->GetOne($sql) + 4; - $new_options['CalculatedFields'][''] = array( - 'CategoryName' => 'REPLACE(SUBSTR(c.l'.$lang.'_CachedNavbar, '.$root_length.'), "&|&", " > ")', - ); + $config->addCalculatedFieldsBySpecial('', 'REPLACE(SUBSTR(c.l'.$lang.'_CachedNavbar, '.$root_length.'), "&|&", " > ")', 'CategoryName'); } elseif ($field_values['ReportType'] == 2) { // by User - $new_options['ListSQLs'][''] = - 'SELECT %1$s.* %2$s FROM %1$s - LEFT JOIN '.TABLE_PREFIX.'Users AS u - ON u.PortalUserId = %1$s.PortalUserId'; + $config->setListSQLsBySpecial('', ' 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 ( - 'Icons' => Array ( - 'default' => 'icon16_item.png', - 'module' => 'core', - ), + $config->addGrids(Array ( + 'Icons' => Array ('default' => 'icon16_item.png', 'module' => 'core'), 'Fields' => Array ( 'Login' => Array ('filter_block' => 'grid_like_filter'), 'FirstName' => Array ('filter_block' => 'grid_like_filter'), @@ -455,100 +451,89 @@ 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), ), - ); + ), 'Default'); - $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( + $config->addVirtualFields(Array ( 'Login' => Array ('type' => 'string', 'default' => ''), 'FirstName' => Array ('type' => 'string', 'default' => ''), 'LastName' => Array ('type' => 'string', 'default' => ''), )); - $new_options['CalculatedFields'][''] = Array ( + $config->addCalculatedFieldsBySpecial('', Array ( 'Login' => 'u.Username', 'FirstName' => 'u.FirstName', 'LastName' => 'u.LastName', - ); + )); } elseif ($field_values['ReportType'] == 5) { // by Product + $config->setListSQLsBySpecial('', ' SELECT %1$s.* %2$s + FROM %1$s + LEFT JOIN '.TABLE_PREFIX.'Products AS p ON p.ProductId = %1$s.ProductId'); - $new_options['ListSQLs'][''] = - '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 ( - 'Icons' => Array ( - 'default' => 'icon16_item.png', - 'module' => 'core', + if ( $this->Application->isModuleEnabled('in-auction') ) { + $config->addGrids(Array ( + 'Icons' => Array ('default' => 'icon16_item.png', 'module' => 'core'), + 'Fields' => Array ( + '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'), + 'eBayQty' => Array ('title' => 'la_col_eBayQty', 'td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'StoreAmount' => Array ('title' => 'la_col_StoreGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'eBayAmount' => Array ('title' => 'la_col_eBayGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'StoreProfit' => Array ('title' => 'la_col_StoreProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'eBayProfit' => Array ('title' => 'la_col_eBayProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), ), - 'Fields' => Array ( - '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'), - 'eBayQty' => Array ('title' => 'la_col_eBayQty', 'td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'StoreAmount' => Array ('title' => 'la_col_StoreGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'eBayAmount' => Array ('title' => 'la_col_eBayGMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), - 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'StoreProfit' => Array ('title' => 'la_col_StoreProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - 'eBayProfit' => Array ('title' => 'la_col_eBayProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), - ), - - ); - - if (!$this->Application->isModuleEnabled('in-auction')) - { - $a_fields =& $new_options['Grids']['Default']['Fields']; - unset($a_fields['StoreQty']); - unset($a_fields['eBayQty']); - unset($a_fields['StoreAmount']); - unset($a_fields['eBayAmount']); - unset($a_fields['StoreProfit']); - unset($a_fields['eBayProfit']); + ), 'Default'); } + else { + $config->addGrids(Array ( + 'Icons' => Array ('default' => 'icon16_item.png', 'module' => 'core'), + 'Fields' => Array ( + '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'), + 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'hidden' => 1, 'filter_block' => 'grid_range_filter'), + 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), + ), + ), 'Default'); + } - - $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( + $config->addVirtualFields(Array ( 'ProductName' => Array ('type' => 'string', 'default' => ''), - 'Metric' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', - 'options' => $this->GetMetricOptions($new_options, 'ProductName'), - 'use_phrases' => 1, - 'default' => 0 - ), + 'Metric' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', + 'options' => $this->GetMetricOptions($config, 'ProductName'), + 'use_phrases' => 1, + 'default' => 0 + ) )); $lang = $this->Application->GetVar('m_lang'); - - $new_options['CalculatedFields'][''] = Array ( - 'ProductName' => 'p.l'.$lang.'_Name', - ); + $config->addCalculatedFieldsBySpecial('', 'p.l' . $lang . '_Name', 'ProductName'); } elseif ($field_values['ReportType'] == 12) { // Overall + $config->setListSQLsBySpecial('', 'SELECT %1$s.* %2$s FROM %1$s'); - $new_options['ListSQLs'][''] = - 'SELECT %1$s.* %2$s FROM %1$s'; + $config->addFields(Array ( + 'Marketplace' => Array ( + 'formatter' => 'kOptionsFormatter', + 'options' => Array (1 => 'la_OnlineStore', 2 => 'la_eBayMarketplace'), 'use_phrases' => 1, + 'default' => 1 + ) + )); - $new_options['Fields']['Marketplace'] = Array ( - 'formatter' => 'kOptionsFormatter', - 'options' => Array ( - 1 => 'la_OnlineStore', - 2 => 'la_eBayMarketplace', - ), - 'use_phrases' => 1, - 'default' => 1 - ); - - $new_options['Grids']['Default'] = Array( - 'Icons' => Array( - 'default' => 'icon16_item.png', - 'module' => 'core', - ), + $config->addGrids(Array( + 'Icons' => Array('default' => 'icon16_item.png', 'module' => 'core'), 'Fields' => Array( 'Marketplace' => Array ('title' => 'la_col_Marketplace', 'filter_block' => 'grid_options_filter'), 'Qty' => Array ('td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), @@ -559,33 +544,20 @@ 'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), ), + ), 'Default'); - ); - - - $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], array( - 'Metric' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', - 'options' => $this->GetMetricOptions($new_options, 'Marketplace'), - 'use_phrases' => 1, - 'default' => 0 - ), - )); - - $lang = $this->Application->GetVar('m_lang'); - + $config->addVirtualFields(Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', + 'options' => $this->GetMetricOptions($config, 'Marketplace'), + 'use_phrases' => 1, + 'default' => 0 + ), 'Metric'); } - $new_options['ListSortings'] = Array( - '' => Array( - 'Sorting' => Array('Amount' => 'desc'), - ) - ); - - foreach ($new_options as $key => $val) { - $this->Application->setUnitOption('rep', $key, $val); - } + $config->setListSortingsBySpecial('', Array( + 'Sorting' => Array('Amount' => 'desc'), + )); } /** @@ -628,21 +600,24 @@ /** * Generate Metric Field Options * - * @param array $a_config_options + * @param kUnitConfig $config * @param string $exclude_field + * @return Array */ - function GetMetricOptions(&$a_config_options, $exclude_field) + function GetMetricOptions(kUnitConfig $config, $exclude_field) { - $a_ret = Array(); - foreach ($a_config_options['Grids']['Default']['Fields'] AS $field => $a_options) - { - if ($field == $exclude_field) - { + $grid = $config->getGridByName('Default'); + + $ret = Array (); + foreach ($grid['Fields'] as $field => $field_options) { + if ( $field == $exclude_field ) { continue; } - $a_ret[$field] = $a_options['title']; + + $ret[$field] = $field_options['title']; } - return $a_ret; + + return $ret; } function OnChangeStatistics($event) @@ -755,8 +730,8 @@ $ReportItem = $this->Application->recallObject('rep.item', 'rep', Array('skip_autoload' => true)); /* @var $ReportItem kDBItem*/ - $a_grids = $this->Application->getUnitOption('rep', 'Grids'); - $a_fields = $a_grids['Default']['Fields']; + $grid = $this->Application->getUnitConfig('rep')->getGridByName('Default'); + $a_fields = $grid['Fields']; $ret = ''; foreach ($a_fields AS $field => $a_props)