diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index c466b0f..605b26d 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -34,7 +34,7 @@ "type": 3, "subtype": 1, "name": "Item", - "uri": "{/base}/sales/analysis/item", + "uri": "{/base}/sales/analysis/item?{?}", "target": "self", "icon": null, "order": 5, @@ -64,7 +64,7 @@ "type": 3, "subtype": 1, "name": "Bill", - "uri": "{/base}/sales/analysis/bill", + "uri": "{/base}/sales/analysis/bill?{?}", "target": "self", "icon": null, "order": 15, diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 56549d2..862ebe7 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -56,9 +56,9 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-overview-dashboard'); @@ -160,10 +160,10 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/plugins/chartjs-chart-geo.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/plugins/chartjs-chart-geo.js?v=' . self::VERSION, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-region'); @@ -349,9 +349,9 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-bill'); @@ -377,9 +377,9 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-rep'); @@ -461,10 +461,10 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/plugins/chartjs-chart-geo.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/plugins/chartjs-chart-geo.js?v=' . self::VERSION, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-client'); @@ -636,9 +636,9 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/SalesAnalysis/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-item'); diff --git a/Models/ClientMapper.php b/Models/ClientMapper.php index c2493bf..d27f6be 100755 --- a/Models/ClientMapper.php +++ b/Models/ClientMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\SalesAnalysis\Models; +use Modules\Billing\Models\BillTransferType; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Stdlib\Base\SmartDateTime; @@ -64,7 +65,8 @@ class ClientMapper extends DataMapperFactory LEFT JOIN clientmgmt_attr_value_l11n ON clientmgmt_attr_value_id = clientmgmt_attr_value_l11n_value AND clientmgmt_attr_value_l11n_lang = \'' . $language . '\' WHERE - billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' AND clientmgmt_attr_type_name IN (\'segment\', \'section\', \'client_group\', \'client_type\') GROUP BY diff --git a/Models/GeneralMapper.php b/Models/GeneralMapper.php index 5689922..4de5dd9 100755 --- a/Models/GeneralMapper.php +++ b/Models/GeneralMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\SalesAnalysis\Models; +use Modules\Billing\Models\BillTransferType; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Stdlib\Base\SmartDateTime; @@ -46,7 +47,8 @@ class GeneralMapper extends DataMapperFactory SUM(billing_bill_netprofit) as netprofit FROM billing_bill WHERE - billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' GROUP BY YEAR(billing_bill_performance_date), @@ -135,7 +137,8 @@ class GeneralMapper extends DataMapperFactory SUM(billing_bill_netprofit) as netprofit FROM billing_bill WHERE - billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' GROUP BY YEAR(billing_bill_performance_date), diff --git a/Models/ItemMapper.php b/Models/ItemMapper.php index b6801f9..b718c5a 100755 --- a/Models/ItemMapper.php +++ b/Models/ItemMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\SalesAnalysis\Models; +use Modules\Billing\Models\BillTransferType; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Stdlib\Base\SmartDateTime; @@ -66,7 +67,8 @@ class ItemMapper extends DataMapperFactory LEFT JOIN itemmgmt_attr_value_l11n ON itemmgmt_attr_value_id = itemmgmt_attr_value_l11n_value AND itemmgmt_attr_value_l11n_lang = \'' . $language . '\' WHERE - billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' AND itemmgmt_attr_type_name IN (\'segment\', \'section\', \'product_group\', \'product_type\') GROUP BY diff --git a/Models/RegionMapper.php b/Models/RegionMapper.php index e4f9a50..65b3132 100755 --- a/Models/RegionMapper.php +++ b/Models/RegionMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\SalesAnalysis\Models; +use Modules\Billing\Models\BillTransferType; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Localization\ISO3166TwoEnum; @@ -53,7 +54,8 @@ class RegionMapper extends DataMapperFactory LEFT JOIN address ON clientmgmt_client_address = address_id WHERE - billing_bill_performance_date >= \'' . $start->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $start->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $end->format('Y-m-d') . '\' GROUP BY address_country, @@ -129,7 +131,8 @@ class RegionMapper extends DataMapperFactory LEFT JOIN address ON clientmgmt_client_address = address_id WHERE - billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' GROUP BY address_country, @@ -206,7 +209,8 @@ class RegionMapper extends DataMapperFactory LEFT JOIN address ON clientmgmt_client_address = address_id WHERE - billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' GROUP BY address_country, @@ -308,8 +312,11 @@ class RegionMapper extends DataMapperFactory LEFT JOIN address ON clientmgmt_client_address = address_id WHERE - billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $currentEnd->format('Y-m-d') . '\' + GROUP BY + address_country, billing_bill_performance_date ORDER BY billing_bill_performance_date ASC, address_country' @@ -370,7 +377,8 @@ class RegionMapper extends DataMapperFactory LEFT JOIN address ON clientmgmt_client_address = address_id WHERE - billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' + billing_bill_type = ' . BillTransferType::SALES . ' + AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\' AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\' GROUP BY address_country, @@ -494,6 +502,10 @@ class RegionMapper extends DataMapperFactory public static function countryIntervalToRegion(array $countries, array $region, array $columns) : array { + if (empty($countries)) { + return []; + } + $count = \count(\reset($countries)); $tempStruct = []; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index c5e5e07..3ee26ec 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -15,31 +15,21 @@ declare(strict_types=1); return ['SalesAnalysis' => [ 'ItemAttribute' => 'Item Attribute', 'ClientAttribute' => 'Client Attribute', - 'SalesRegion' => 'Sales Region', - 'Customers' => 'Customers', 'Months' => 'Months', 'Total' => 'Total', 'Year' => 'Year', 'Month' => 'Month', - 'A' => 'A', - 'PY' => 'PY', - 'B' => 'B', 'All' => 'All', 'New' => 'New', 'Lost' => 'Lost', - 'Product' => 'Product', 'Continent' => 'Continent', 'SalesPY' => 'Sales PY', - 'SalesB' => 'Sales B', 'SalesA' => 'Sales A', 'ProfitPY' => 'Profit PY', - 'ProfitB' => 'Profit B', 'ProfitA' => 'Profit A', 'DiffPY' => 'Δ PY', - 'DiffB' => 'Δ B', 'Data' => 'Data', 'Actual' => 'Actual', - 'Budget' => 'Budget', 'Segment' => 'Segment', 'Section' => 'Section', 'Group' => 'Group', @@ -49,7 +39,6 @@ return ['SalesAnalysis' => [ 'Category' => 'Category', 'General' => 'General', 'MTD' => 'MTD', - 'Other' => 'Other', 'YTD' => 'YTD', 'GrossProfit' => 'Gross Profit', 'SalesProfit' => 'Sales / Profit', @@ -61,55 +50,18 @@ return ['SalesAnalysis' => [ 'Sales' => 'Sales', 'Client' => 'Client', 'Clients' => 'Clients', - 'Item' => 'Item', 'World' => 'World', - 'Africa' => 'Africa', - 'America' => 'America', 'DomesticExport' => 'Domestic & Export', - 'Oceania' => 'Oceania', - 'Analysis' => 'Analysis', - 'Asia' => 'Asia', - 'Change' => 'Change', - 'ChangeAcc' => 'Change Acc.', - 'Charts' => 'Charts', 'Comparison' => 'Comparison', 'Continents' => 'Continents', - 'CurrentMonth' => 'Current Month', - 'CurrentYear' => 'Current Year', - 'CurrentYearAcc' => 'Current Year Acc.', - 'Customers' => 'Customers', 'Data' => 'Data', - 'Database' => 'Database', - 'Day' => 'Day', - 'Developed' => 'Developed', - 'Developed/Undeveloped' => 'Developed/Undeveloped', - 'Development' => 'Development', 'Domestic' => 'Domestic', - 'Domestic/Export' => 'Domestic/Export', - 'Employees' => 'Employees', - 'Europe' => 'Europe', 'Export' => 'Export', - 'Forecast' => 'Forecast', - 'Frequency' => 'Frequency', - 'Interval' => 'Interval', - 'Invoices' => 'Invoices', - 'LastMonth' => 'Last Month', - 'LastYear' => 'Last Year', - 'LastYearAcc' => 'Last Year Acc.', - 'Marketing' => 'Marketing', - 'Misc' => 'Misc', 'Month' => 'Month', 'Current' => 'Current', 'Analyze' => 'Analyze', - 'Overview' => 'Overview', - 'Products' => 'Products', 'Regions' => 'Regions', - 'To' => 'To', - 'Today' => 'Today', - 'Top10' => 'Top 10', 'Total' => 'Total', 'Type' => 'Type', - 'Undeveloped' => 'Undeveloped', 'Year' => 'Year', - 'Yesterday' => 'Yesterday', ]]; diff --git a/Theme/Backend/analysis-overview-dashboard.tpl.php b/Theme/Backend/analysis-overview-dashboard.tpl.php index 4493d5a..005ab66 100755 --- a/Theme/Backend/analysis-overview-dashboard.tpl.php +++ b/Theme/Backend/analysis-overview-dashboard.tpl.php @@ -13,6 +13,7 @@ declare(strict_types=1); use phpOMS\Localization\ISO3166NameEnum; +use phpOMS\Stdlib\Base\FloatInt; use phpOMS\Uri\UriFactory; /** @@ -60,7 +61,7 @@ echo $this->data['nav']->render();
-
+
getHtml('Actual'); ?>
@@ -167,7 +168,7 @@ echo $this->data['nav']->render(); @@ -184,7 +185,7 @@ echo $this->data['nav']->render(); @@ -270,7 +271,7 @@ echo $this->data['nav']->render(); getCurrency($sum1); ?> getCurrency($sum2); ?> % - % + %
@@ -331,7 +332,7 @@ echo $this->data['nav']->render(); @@ -396,8 +397,8 @@ echo $this->data['nav']->render(); foreach ($sales as $values) : ?> - - getCurrency(((int) $values['net_sales']) / 10000); ?> + + getCurrency(((int) $values['net_sales']) / FloatInt::DIVISOR); ?> % diff --git a/Theme/Backend/analysis-region.tpl.php b/Theme/Backend/analysis-region.tpl.php index 615376f..8ba9e13 100755 --- a/Theme/Backend/analysis-region.tpl.php +++ b/Theme/Backend/analysis-region.tpl.php @@ -14,6 +14,7 @@ declare(strict_types=1); use phpOMS\Localization\ISO3166CharEnum; use phpOMS\Localization\ISO3166NameEnum; +use phpOMS\Stdlib\Base\FloatInt; /** * @var \phpOMS\Views\View $this @@ -50,7 +51,7 @@ echo $this->data['nav']->render(); data['ytdAClientCountry'] as $lang => $values) { - $temp[] = '{"id": "' . ISO3166CharEnum::getBy2Code($lang) . '", "value": ' . ($values['net_sales'] / 10000) . '}'; + $temp[] = '{"id": "' . ISO3166CharEnum::getBy2Code($lang) . '", "value": ' . ($values['net_sales'] / FloatInt::DIVISOR) . '}'; } ?> ] @@ -202,7 +203,7 @@ echo $this->data['nav']->render(); data['domestic']][$i]['net_sales'] ?? 0) / 10000; + $temp[] = ($sales[1][$this->data['domestic']][$i]['net_sales'] ?? 0) / FloatInt::DIVISOR; } echo \implode(',', $temp); ?> @@ -219,7 +220,7 @@ echo $this->data['nav']->render(); data['domestic']][$i]['net_sales'] ?? 0) / 10000; + $temp[] = ($sales[2][$this->data['domestic']][$i]['net_sales'] ?? 0) / FloatInt::DIVISOR; } echo \implode(',', $temp); ?> @@ -305,7 +306,7 @@ echo $this->data['nav']->render(); getCurrency($sum1); ?> getCurrency($sum2); ?> % - % + %
@@ -392,7 +393,7 @@ echo $this->data['nav']->render(); @@ -409,7 +410,7 @@ echo $this->data['nav']->render(); @@ -495,7 +496,7 @@ echo $this->data['nav']->render(); getCurrency($sum1); ?> getCurrency($sum2); ?> % - % + % @@ -520,7 +521,7 @@ echo $this->data['nav']->render(); data['ytdADomesticExport'] as $values) { - $temp[] = $values['net_sales'] / 10000; + $temp[] = $values['net_sales'] / FloatInt::DIVISOR; } echo \implode(',', $temp); ?> @@ -591,7 +592,7 @@ echo $this->data['nav']->render(); @@ -661,7 +662,7 @@ echo $this->data['nav']->render(); data['ytdADomesticExport'] as $values) { - $temp[] = $values['net_profit'] / 10000; + $temp[] = $values['net_profit'] / FloatInt::DIVISOR; } echo \implode(',', $temp); ?> @@ -956,7 +957,7 @@ echo $this->data['nav']->render(); data['ytdAContinent'] as $values) { - $temp[] = $values['net_sales'] / 10000; + $temp[] = $values['net_sales'] / FloatInt::DIVISOR; } echo \implode(',', $temp); ?> @@ -1027,7 +1028,7 @@ echo $this->data['nav']->render(); @@ -1097,7 +1098,7 @@ echo $this->data['nav']->render(); data['ytdAContinent'] as $values) { - $temp[] = $values['net_profit'] / 10000; + $temp[] = $values['net_profit'] / FloatInt::DIVISOR; } echo \implode(',', $temp); ?>