Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/units/reports/reports_event_handler.php
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
/** @var kDBItem $object */ | /** @var kDBItem $object */ | ||||
$object = $event->getObject( Array('skip_autoload' => true) ); | $object = $event->getObject( Array('skip_autoload' => true) ); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$object->UpdateFormattersMasterFields(); | $object->UpdateFormattersMasterFields(); | ||||
$field_values['offset'] = 0; | $field_values['offset'] = 0; | ||||
$field_values['export_ignore'] = ''; | |||||
$table_name = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_SaleReport'; | $table_name = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_SaleReport'; | ||||
$field_values['table_name'] = $table_name; | $field_values['table_name'] = $table_name; | ||||
$this->Conn->Query('DROP TABLE IF EXISTS '.$table_name); | $this->Conn->Query('DROP TABLE IF EXISTS '.$table_name); | ||||
$filter_value = ''; | $filter_value = ''; | ||||
$from = $object->GetDBField('FromDateTime'); | $from = $object->GetDBField('FromDateTime'); | ||||
$to = $object->GetDBField('ToDateTime'); | $to = $object->GetDBField('ToDateTime'); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
SUM(IF(ISNULL(eod.OptionsSalt), (od.Price - od.Cost) * od.Quantity, 0)) as StoreProfit, | SUM(IF(ISNULL(eod.OptionsSalt), (od.Price - od.Cost) * od.Quantity, 0)) as StoreProfit, | ||||
SUM(IF(ISNULL(eod.OptionsSalt), 0, (od.Price - od.Cost) * od.Quantity)) as eBayProfit | SUM(IF(ISNULL(eod.OptionsSalt), 0, (od.Price - od.Cost) * od.Quantity)) as eBayProfit | ||||
'; | '; | ||||
} | } | ||||
} | } | ||||
if ($field_values['ReportType'] == 1) { // by Category | 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.' ( | $q = 'CREATE TABLE '.$table_name.' ( | ||||
CategoryId int(11) NOT NULL DEFAULT 0, | CategoryId int(11) NOT NULL DEFAULT 0, | ||||
Qty int(11) NOT NULL DEFAULT 0, | Qty int(11) NOT NULL DEFAULT 0, | ||||
Cost double(10,4) NOT NULL DEFAULT 0, | Cost double(10,4) NOT NULL DEFAULT 0, | ||||
Amount double(10,4) NOT NULL DEFAULT 0, | Amount double(10,4) NOT NULL DEFAULT 0, | ||||
Tax double(10,4) NOT NULL DEFAULT 0, | Tax double(10,4) NOT NULL DEFAULT 0, | ||||
Shipping double(10,4) NOT NULL DEFAULT 0, | Shipping double(10,4) NOT NULL DEFAULT 0, | ||||
Processing double(10,4) NOT NULL DEFAULT 0, | Processing double(10,4) NOT NULL DEFAULT 0, | ||||
Show All 30 Lines | |||||
ci.PrimaryCat = 1 | ci.PrimaryCat = 1 | ||||
'.$filter_value.' | '.$filter_value.' | ||||
GROUP BY c.CategoryId | GROUP BY c.CategoryId | ||||
HAVING NOT ISNULL(CategoryId) | HAVING NOT ISNULL(CategoryId) | ||||
'; | '; | ||||
$this->Conn->Query($q); | $this->Conn->Query($q); | ||||
} | } | ||||
elseif ($field_values['ReportType'] == 2) { // by User | 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.' ( | $q = 'CREATE TABLE '.$table_name.' ( | ||||
PortalUserId int(11) NOT NULL DEFAULT 0, | PortalUserId int(11) NOT NULL DEFAULT 0, | ||||
Qty int(11) NOT NULL DEFAULT 0, | Qty int(11) NOT NULL DEFAULT 0, | ||||
Cost double(10,4) NOT NULL DEFAULT 0, | Cost double(10,4) NOT NULL DEFAULT 0, | ||||
Amount double(10,4) NOT NULL DEFAULT 0, | Amount double(10,4) NOT NULL DEFAULT 0, | ||||
Tax double(10,4) NOT NULL DEFAULT 0, | Tax double(10,4) NOT NULL DEFAULT 0, | ||||
Shipping double(10,4) NOT NULL DEFAULT 0, | Shipping double(10,4) NOT NULL DEFAULT 0, | ||||
Processing double(10,4) NOT NULL DEFAULT 0, | Processing double(10,4) NOT NULL DEFAULT 0, | ||||
Show All 21 Lines | |||||
o.Status IN (4,6) | o.Status IN (4,6) | ||||
'.$filter_value.' | '.$filter_value.' | ||||
GROUP BY u.PortalUserId | GROUP BY u.PortalUserId | ||||
HAVING NOT ISNULL(PortalUserId) | HAVING NOT ISNULL(PortalUserId) | ||||
'; | '; | ||||
$this->Conn->Query($q); | $this->Conn->Query($q); | ||||
} | } | ||||
elseif ($field_values['ReportType'] == 5) { // by Product | 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.' ( | $q = 'CREATE TABLE '.$table_name.' ( | ||||
ProductId int(11) NOT NULL DEFAULT 0, | ProductId int(11) NOT NULL DEFAULT 0, | ||||
Qty int(11) NOT NULL DEFAULT 0, | Qty int(11) NOT NULL DEFAULT 0, | ||||
Cost double(10,4) NOT NULL DEFAULT 0, | Cost double(10,4) NOT NULL DEFAULT 0, | ||||
Amount double(10,4) NOT NULL DEFAULT 0, | Amount double(10,4) NOT NULL DEFAULT 0, | ||||
Tax double(10,4) NOT NULL DEFAULT 0, | Tax double(10,4) NOT NULL DEFAULT 0, | ||||
Shipping double(10,4) NOT NULL DEFAULT 0, | Shipping double(10,4) NOT NULL DEFAULT 0, | ||||
Processing double(10,4) NOT NULL DEFAULT 0, | Processing double(10,4) NOT NULL DEFAULT 0, | ||||
Show All 24 Lines | |||||
o.Status IN (4,6) | o.Status IN (4,6) | ||||
'.$filter_value.' | '.$filter_value.' | ||||
GROUP BY p.ProductId | GROUP BY p.ProductId | ||||
HAVING NOT ISNULL(ProductId) | HAVING NOT ISNULL(ProductId) | ||||
'; | '; | ||||
$this->Conn->Query($q); | $this->Conn->Query($q); | ||||
} | } | ||||
elseif ($field_values['ReportType'] == 12) { // Overall | elseif ($field_values['ReportType'] == 12) { // Overall | ||||
$field_values['id_field'] = 'Marketplace'; | |||||
$field_values['grid'] = 'Overall'; | |||||
$q = 'CREATE TABLE '.$table_name.' ( | $q = 'CREATE TABLE '.$table_name.' ( | ||||
Marketplace tinyint(1) NOT NULL DEFAULT 0, | Marketplace tinyint(1) NOT NULL DEFAULT 0, | ||||
Qty int(11) NOT NULL DEFAULT 0, | Qty int(11) NOT NULL DEFAULT 0, | ||||
Cost double(10,4) NOT NULL DEFAULT 0, | Cost double(10,4) NOT NULL DEFAULT 0, | ||||
Amount double(10,4) NOT NULL DEFAULT 0, | Amount double(10,4) NOT NULL DEFAULT 0, | ||||
Tax double(10,4) NOT NULL DEFAULT 0, | Tax double(10,4) NOT NULL DEFAULT 0, | ||||
Shipping double(10,4) NOT NULL DEFAULT 0, | Shipping double(10,4) NOT NULL DEFAULT 0, | ||||
Processing double(10,4) NOT NULL DEFAULT 0, | Processing double(10,4) NOT NULL DEFAULT 0, | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
WHERE | WHERE | ||||
o.Status IN (4,6) | o.Status IN (4,6) | ||||
'.$filter_value; | '.$filter_value; | ||||
$this->Conn->Query($q); | $this->Conn->Query($q); | ||||
} | } | ||||
} | } | ||||
$vars = array('rep_Page', 'rep_Sort1', 'rep_Sort1_Dir', 'rep_Sort2', 'rep_Sort2_Dir'); | $event->CallSubEvent('OnResetSorting'); | ||||
foreach ($vars as $var_name) { | |||||
$this->Application->RemoveVar($var_name); | |||||
} | |||||
//temporary | //temporary | ||||
$event->redirect = $this->Application->GetVar('reports_finish_t'); | $event->redirect = $this->Application->GetVar('reports_finish_t'); | ||||
$field_values['from'] = $from; | $field_values['from'] = $from; | ||||
$field_values['to'] = $to; | $field_values['to'] = $to; | ||||
$this->Application->StoreVar('report_options', serialize($field_values)); | $this->Application->StoreVar('report_options', serialize($field_values)); | ||||
} | } | ||||
function OnUpdateConfig($event) | function OnUpdateConfig($event) | ||||
{ | { | ||||
$report = $this->Application->RecallVar('report_options'); | $report = $this->Application->RecallVar('report_options'); | ||||
if (!$report) { | if (!$report) { | ||||
return ; | return ; | ||||
} | } | ||||
$field_values = unserialize($report); | $field_values = unserialize($report); | ||||
$grid = $field_values['grid']; | |||||
$rep_options = $this->Application->getUnitOptions('rep'); | $rep_options = $this->Application->getUnitOptions('rep'); | ||||
$new_options = Array (); | $new_options = Array (); | ||||
$new_options['TableName'] = $field_values['table_name']; | $new_options['TableName'] = $field_values['table_name']; | ||||
$new_options['Fields'] = Array ( | $new_options['Fields'] = Array ( | ||||
'Qty' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%d', 'default' => 0, 'totals' => 'sum'), | 'Qty' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%d', 'default' => 0, 'totals' => 'sum'), | ||||
Show All 19 Lines | |||||
} | } | ||||
if ($field_values['ReportType'] == 1) { // by Category | if ($field_values['ReportType'] == 1) { // by Category | ||||
$new_options['ListSQLs'][''] = | $new_options['ListSQLs'][''] = | ||||
'SELECT %1$s.* %2$s FROM %1$s | 'SELECT %1$s.* %2$s FROM %1$s | ||||
LEFT JOIN '.TABLE_PREFIX.'Categories AS c | LEFT JOIN '.TABLE_PREFIX.'Categories AS c | ||||
ON c.CategoryId = %1$s.CategoryId'; | 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 ( | 'Icons' => Array ( | ||||
'default' => 'icon16_item.png', | 'default' => 'icon16_item.png', | ||||
'module' => 'core', | 'module' => 'core', | ||||
), | ), | ||||
'Fields' => Array ( | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | 'eBayProfit' => Array ('title' => 'la_col_eBayProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
), | ), | ||||
); | ); | ||||
if (!$this->Application->isModuleEnabled('in-auction')) { | 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['StoreQty']); | ||||
unset($a_fields['eBayQty']); | unset($a_fields['eBayQty']); | ||||
unset($a_fields['StoreAmount']); | unset($a_fields['StoreAmount']); | ||||
unset($a_fields['eBayAmount']); | unset($a_fields['eBayAmount']); | ||||
unset($a_fields['StoreProfit']); | unset($a_fields['StoreProfit']); | ||||
unset($a_fields['eBayProfit']); | unset($a_fields['eBayProfit']); | ||||
} | } | ||||
$new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( | $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( | ||||
'CategoryName' => Array ('type' => 'string', 'default' => ''), | 'CategoryName' => Array ('type' => 'string', 'default' => ''), | ||||
'Metric' => Array ( | 'Metric' => Array ( | ||||
'type' => 'int', | 'type' => 'int', | ||||
'formatter' => 'kOptionsFormatter', | 'formatter' => 'kOptionsFormatter', | ||||
'options' => $this->GetMetricOptions($new_options, 'CategoryName'), | 'options' => $this->GetMetricOptions($new_options, array('CategoryId', 'CategoryName'), $grid), | ||||
'use_phrases' => 1, | 'use_phrases' => 1, | ||||
'default' => 0, | 'default' => 0, | ||||
), | ), | ||||
)); | )); | ||||
$lang = $this->Application->GetVar('m_lang'); | $lang = $this->Application->GetVar('m_lang'); | ||||
// products root category | // products root category | ||||
$products_category_id = $this->Application->findModule('Name', 'In-Commerce', 'RootCat'); | $products_category_id = $this->Application->findModule('Name', 'In-Commerce', 'RootCat'); | ||||
// get root category name | // get root category name | ||||
$sql = 'SELECT LENGTH(l' . $lang . '_CachedNavbar) | $sql = 'SELECT LENGTH(l' . $lang . '_CachedNavbar) | ||||
FROM ' . TABLE_PREFIX . 'Categories | FROM ' . TABLE_PREFIX . 'Categories | ||||
WHERE CategoryId = '.$products_category_id; | WHERE CategoryId = '.$products_category_id; | ||||
$root_length = $this->Conn->GetOne($sql) + 4; | $root_length = $this->Conn->GetOne($sql) + 4; | ||||
$new_options['CalculatedFields'][''] = array( | $new_options['CalculatedFields'][''] = array( | ||||
'CategoryName' => 'REPLACE(SUBSTR(c.l'.$lang.'_CachedNavbar, '.$root_length.'), "&|&", " > ")', | 'CategoryName' => 'REPLACE(SUBSTR(c.l'.$lang.'_CachedNavbar, '.$root_length.'), "&|&", " > ")', | ||||
); | ); | ||||
} | } | ||||
elseif ($field_values['ReportType'] == 2) { // by User | elseif ($field_values['ReportType'] == 2) { // by User | ||||
$new_options['ListSQLs'][''] = | $new_options['ListSQLs'][''] = | ||||
'SELECT %1$s.* %2$s FROM %1$s | 'SELECT %1$s.* %2$s FROM %1$s | ||||
LEFT JOIN '.TABLE_PREFIX.'Users AS u | LEFT JOIN '.TABLE_PREFIX.'Users AS u | ||||
ON u.PortalUserId = %1$s.PortalUserId'; | ON u.PortalUserId = %1$s.PortalUserId'; | ||||
$new_options['Fields']['PortalUserId'] = Array ('type' => 'int', 'default' => null); | |||||
$new_options['Grids']['Default'] = Array ( | $new_options['Grids'][$grid] = Array ( | ||||
'Icons' => Array ( | 'Icons' => Array ( | ||||
'default' => 'icon16_item.png', | 'default' => 'icon16_item.png', | ||||
'module' => 'core', | 'module' => 'core', | ||||
), | ), | ||||
'Fields' => Array ( | 'Fields' => Array ( | ||||
'PortalUserId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter', 'hidden' => 1), | |||||
'Login' => Array ('filter_block' => 'grid_like_filter'), | 'Login' => Array ('filter_block' => 'grid_like_filter'), | ||||
'FirstName' => Array ('filter_block' => 'grid_like_filter'), | 'FirstName' => Array ('filter_block' => 'grid_like_filter'), | ||||
'LastName' => Array ('filter_block' => 'grid_like_filter'), | 'LastName' => Array ('filter_block' => 'grid_like_filter'), | ||||
'Qty' => Array ('td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | 'Qty' => Array ('td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', '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', 'filter_block' => 'grid_range_filter'), | 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
Show All 15 Lines | |||||
); | ); | ||||
} | } | ||||
elseif ($field_values['ReportType'] == 5) { // by Product | elseif ($field_values['ReportType'] == 5) { // by Product | ||||
$new_options['ListSQLs'][''] = | $new_options['ListSQLs'][''] = | ||||
'SELECT %1$s.* %2$s FROM %1$s | 'SELECT %1$s.* %2$s FROM %1$s | ||||
LEFT JOIN '.TABLE_PREFIX.'Products AS p | LEFT JOIN '.TABLE_PREFIX.'Products AS p | ||||
ON p.ProductId = %1$s.ProductId'; | ON p.ProductId = %1$s.ProductId'; | ||||
$new_options['Fields']['ProductId'] = Array ('type' => 'int', 'default' => null); | |||||
$new_options['Grids']['Default'] = Array ( | $new_options['Grids'][$grid] = Array ( | ||||
'Icons' => Array ( | 'Icons' => Array ( | ||||
'default' => 'icon16_item.png', | 'default' => 'icon16_item.png', | ||||
'module' => 'core', | 'module' => 'core', | ||||
), | ), | ||||
'Fields' => Array ( | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | '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'), | 'eBayProfit' => Array ('title' => 'la_col_eBayProfit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
), | ), | ||||
); | ); | ||||
if (!$this->Application->isModuleEnabled('in-auction')) | 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['StoreQty']); | ||||
unset($a_fields['eBayQty']); | unset($a_fields['eBayQty']); | ||||
unset($a_fields['StoreAmount']); | unset($a_fields['StoreAmount']); | ||||
unset($a_fields['eBayAmount']); | unset($a_fields['eBayAmount']); | ||||
unset($a_fields['StoreProfit']); | unset($a_fields['StoreProfit']); | ||||
unset($a_fields['eBayProfit']); | unset($a_fields['eBayProfit']); | ||||
} | } | ||||
$new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( | $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], Array ( | ||||
'ProductName' => Array ('type' => 'string', 'default' => ''), | 'ProductName' => Array ('type' => 'string', 'default' => ''), | ||||
'Metric' => Array ( | 'Metric' => Array ( | ||||
'type' => 'int', | 'type' => 'int', | ||||
'formatter' => 'kOptionsFormatter', | 'formatter' => 'kOptionsFormatter', | ||||
'options' => $this->GetMetricOptions($new_options, 'ProductName'), | 'options' => $this->GetMetricOptions($new_options, array('ProductId', 'ProductName'), $grid), | ||||
'use_phrases' => 1, | 'use_phrases' => 1, | ||||
'default' => 0 | 'default' => 0 | ||||
), | ), | ||||
)); | )); | ||||
$lang = $this->Application->GetVar('m_lang'); | $lang = $this->Application->GetVar('m_lang'); | ||||
$new_options['CalculatedFields'][''] = Array ( | $new_options['CalculatedFields'][''] = Array ( | ||||
'ProductName' => 'p.l'.$lang.'_Name', | 'ProductName' => 'p.l'.$lang.'_Name', | ||||
); | ); | ||||
} | } | ||||
elseif ($field_values['ReportType'] == 12) { // Overall | elseif ($field_values['ReportType'] == 12) { // Overall | ||||
$new_options['ListSQLs'][''] = | $new_options['ListSQLs'][''] = | ||||
'SELECT %1$s.* %2$s FROM %1$s'; | 'SELECT %1$s.* %2$s FROM %1$s'; | ||||
$new_options['Fields']['Marketplace'] = Array ( | $new_options['Fields']['Marketplace'] = Array ( | ||||
'type' => 'int', | |||||
'formatter' => 'kOptionsFormatter', | 'formatter' => 'kOptionsFormatter', | ||||
'options' => Array ( | 'options' => Array ( | ||||
1 => 'la_OnlineStore', | 1 => 'la_OnlineStore', | ||||
2 => 'la_eBayMarketplace', | 2 => 'la_eBayMarketplace', | ||||
), | ), | ||||
'use_phrases' => 1, | 'use_phrases' => 1, | ||||
'default' => 1 | 'default' => 1 | ||||
); | ); | ||||
$new_options['Grids']['Default'] = Array( | $new_options['Grids'][$grid] = Array( | ||||
'Icons' => Array( | 'Icons' => Array( | ||||
'default' => 'icon16_item.png', | 'default' => 'icon16_item.png', | ||||
'module' => 'core', | 'module' => 'core', | ||||
), | ), | ||||
'Fields' => Array( | 'Fields' => Array( | ||||
'Marketplace' => Array ('title' => 'la_col_Marketplace', 'filter_block' => 'grid_options_filter'), | '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'), | 'Qty' => Array ('td_style' => 'text-align: center', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | 'Cost' => Array ('td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Amount' => Array ('title' => 'la_col_GMV', 'td_style' => 'text-align: right', 'total' => 'sum', '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', 'filter_block' => 'grid_range_filter'), | 'Tax' => Array ('title' => 'la_col_Tax', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | 'Shipping' => Array ('title' => 'la_col_Shipping', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
'Processing' => Array ('title' => 'la_col_Processing', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | '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'), | 'Profit' => Array ('title' => 'la_col_Profit', 'td_style' => 'text-align: right', 'total' => 'sum', 'filter_block' => 'grid_range_filter'), | ||||
), | ), | ||||
); | ); | ||||
$new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], array( | $new_options['VirtualFields'] = array_merge($rep_options['VirtualFields'], array( | ||||
'Metric' => Array ( | 'Metric' => Array ( | ||||
'type' => 'int', | 'type' => 'int', | ||||
'formatter' => 'kOptionsFormatter', | 'formatter' => 'kOptionsFormatter', | ||||
'options' => $this->GetMetricOptions($new_options, 'Marketplace'), | 'options' => $this->GetMetricOptions($new_options, array('Marketplace'), $grid), | ||||
'use_phrases' => 1, | 'use_phrases' => 1, | ||||
'default' => 0 | 'default' => 0 | ||||
), | ), | ||||
)); | )); | ||||
$lang = $this->Application->GetVar('m_lang'); | $lang = $this->Application->GetVar('m_lang'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
return false; | return false; | ||||
} | } | ||||
return $value_ts; | return $value_ts; | ||||
} | } | ||||
/** | /** | ||||
* Generate Metric Field Options | * Generate Metric Field Options | ||||
* | * | ||||
* @param array $a_config_options | * @param array $a_config_options Config options. | ||||
* @param string $exclude_field | * @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; | continue; | ||||
} | } | ||||
$a_ret[$field] = $a_options['title']; | |||||
$a_ret[$field] = isset($a_options['title']) ? $a_options['title'] : 'column:la_fld_' . $field; | |||||
} | } | ||||
return $a_ret; | return $a_ret; | ||||
} | } | ||||
function OnChangeStatistics($event) | function OnChangeStatistics($event) | ||||
{ | { | ||||
$this->Application->StoreVar('ChartMetric', $this->Application->GetVar('metric')); | $this->Application->StoreVar('ChartMetric', $this->Application->GetVar('metric')); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
function OnExportReport($event) | function OnExportReport($event) | ||||
{ | { | ||||
/** @var kDBList $report */ | /** @var kDBList $report */ | ||||
$report = $this->Application->recallObject($event->getPrefixSpecial(),'rep_List',Array('skip_counting'=>true,'per_page'=>-1) ); | $report = $this->Application->recallObject($event->getPrefixSpecial(),'rep_List',Array('skip_counting'=>true,'per_page'=>-1) ); | ||||
/** @var kDBItem $ReportItem */ | /** @var kDBItem $ReportItem */ | ||||
$ReportItem = $this->Application->recallObject('rep.item', 'rep', Array('skip_autoload' => true)); | $ReportItem = $this->Application->recallObject('rep.item', 'rep', Array('skip_autoload' => true)); | ||||
$report_options = unserialize($this->Application->RecallVar('report_options')); | |||||
$a_grids = $this->Application->getUnitOption('rep', 'Grids'); | $a_grids = $this->Application->getUnitOption('rep', 'Grids'); | ||||
$a_fields = $a_grids['Default']['Fields']; | $a_fields = $a_grids[$report_options['grid']]['Fields']; | ||||
if ( $report_options['export_ignore'] ) { | |||||
unset($a_fields[$report_options['export_ignore']]); | |||||
} | |||||
$ret = ''; | $ret = ''; | ||||
foreach ($a_fields AS $field => $a_props) | foreach ($a_fields AS $field => $a_props) | ||||
{ | { | ||||
$ret .= '<commas>'.$field.'<commas><tab>'; | $ret .= '<commas>'.$field.'<commas><tab>'; | ||||
} | } | ||||
$ret = substr($ret, 0, strlen($ret) - 5).'<cr>'; | $ret = substr($ret, 0, strlen($ret) - 5).'<cr>'; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
$ret = str_replace("\r",'', $ret); | $ret = str_replace("\r",'', $ret); | ||||
$ret = str_replace("\n",'', $ret); | $ret = str_replace("\n",'', $ret); | ||||
$ret = str_replace('"','\'\'', $ret); | $ret = str_replace('"','\'\'', $ret); | ||||
$ret = str_replace('<commas>','"', $ret); | $ret = str_replace('<commas>','"', $ret); | ||||
$ret = str_replace('<tab>',',', $ret); | $ret = str_replace('<tab>',',', $ret); | ||||
$ret = str_replace('<cr>',"\r", $ret); | $ret = str_replace('<cr>',"\r", $ret); | ||||
$report_options = unserialize($this->Application->RecallVar('report_options')); | |||||
switch ($report_options['ReportType']) | switch ($report_options['ReportType']) | ||||
{ | { | ||||
case 1: | case 1: | ||||
$file_name = '-ByCategory'; | $file_name = '-ByCategory'; | ||||
break; | break; | ||||
case 2: | case 2: | ||||
$file_name = '-ByUser'; | $file_name = '-ByUser'; | ||||
break; | break; | ||||
Show All 16 Lines |