bug fixes

This commit is contained in:
Dennis Eichhorn 2024-05-12 00:06:28 +00:00
parent 3ab72fd319
commit 78a0bcf52e
20 changed files with 1766 additions and 1788 deletions

View File

@ -5,7 +5,7 @@
"type": 2,
"subtype": 1,
"name": "Analysis",
"uri": "{/base}/sales/analysis",
"uri": "{/base}/sales/analysis/ytd",
"target": "self",
"icon": null,
"order": 15,
@ -14,34 +14,156 @@
"parent": 1001601001,
"children": [
{
"id": 1001602001,
"id": 1005402001,
"pid": "/sales/analysis",
"type": 3,
"subtype": 1,
"name": "Dashboard",
"uri": "{/base}/sales/analysis",
"uri": "{/base}/sales/analysis/ytd",
"target": "self",
"icon": null,
"order": 1,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005401001,
"children": []
"children": [
{
"id": 1005402002,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "YTD",
"uri": "{/base}/sales/analysis/ytd",
"target": "self",
"icon": null,
"order": 1,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005402001,
"children": []
},
{
"id": 1005402003,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "MTD",
"uri": "{/base}/sales/analysis/mtd",
"target": "self",
"icon": null,
"order": 5,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005402001,
"children": []
},
{
"id": 1005402004,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Monthly",
"uri": "{/base}/sales/analysis/monthly",
"target": "self",
"icon": null,
"order": 10,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005402001,
"children": []
},
{
"id": 1005402005,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Annually",
"uri": "{/base}/sales/analysis/annually",
"target": "self",
"icon": null,
"order": 15,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005402001,
"children": []
}
]
},
{
"id": 1001603001,
"id": 1005403001,
"pid": "/sales/analysis",
"type": 3,
"subtype": 1,
"name": "Item",
"uri": "{/base}/sales/analysis/item",
"uri": "{/base}/sales/analysis/item/ytd",
"target": "self",
"icon": null,
"order": 5,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005401001,
"children": []
"children": [
{
"id": 1005403002,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "YTD",
"uri": "{/base}/sales/analysis/item/ytd",
"target": "self",
"icon": null,
"order": 1,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005403001,
"children": []
},
{
"id": 1005403003,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "MTD",
"uri": "{/base}/sales/analysis/item/mtd",
"target": "self",
"icon": null,
"order": 5,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005403001,
"children": []
},
{
"id": 1005403004,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Monthly",
"uri": "{/base}/sales/analysis/item/monthly",
"target": "self",
"icon": null,
"order": 10,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005403001,
"children": []
},
{
"id": 1005403005,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Annually",
"uri": "{/base}/sales/analysis/item/annually",
"target": "self",
"icon": null,
"order": 15,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005403001,
"children": []
}
]
},
{
"id": 1005404001,
@ -49,14 +171,75 @@
"type": 3,
"subtype": 1,
"name": "Client",
"uri": "{/base}/sales/analysis/client",
"uri": "{/base}/sales/analysis/client/ytd",
"target": "self",
"icon": null,
"order": 10,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005401001,
"children": []
"children": [
{
"id": 1005404002,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "YTD",
"uri": "{/base}/sales/analysis/client/ytd",
"target": "self",
"icon": null,
"order": 1,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005404001,
"children": []
},
{
"id": 1005404003,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "MTD",
"uri": "{/base}/sales/analysis/client/mtd",
"target": "self",
"icon": null,
"order": 5,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005404001,
"children": []
},
{
"id": 1005404004,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Monthly",
"uri": "{/base}/sales/analysis/client/monthly",
"target": "self",
"icon": null,
"order": 10,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005404001,
"children": []
},
{
"id": 1005404005,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Annually",
"uri": "{/base}/sales/analysis/client/annually",
"target": "self",
"icon": null,
"order": 15,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005404001,
"children": []
}
]
},
{
"id": 1005405001,
@ -64,14 +247,15 @@
"type": 3,
"subtype": 1,
"name": "Bill",
"uri": "{/base}/sales/analysis/bill",
"uri": "{/base}/sales/analysis/bill/ytd",
"target": "self",
"icon": null,
"order": 15,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005401001,
"children": []
"children": [],
"status": 3
},
{
"id": 1005406001,
@ -79,14 +263,75 @@
"type": 3,
"subtype": 1,
"name": "Region",
"uri": "{/base}/sales/analysis/region",
"uri": "{/base}/sales/analysis/region/ytd",
"target": "self",
"icon": null,
"order": 20,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005401001,
"children": []
"children": [
{
"id": 1005406002,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "YTD",
"uri": "{/base}/sales/analysis/region/ytd",
"target": "self",
"icon": null,
"order": 1,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005406001,
"children": []
},
{
"id": 1005406003,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "MTD",
"uri": "{/base}/sales/analysis/region/mtd",
"target": "self",
"icon": null,
"order": 5,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005406001,
"children": []
},
{
"id": 1005406004,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Monthly",
"uri": "{/base}/sales/analysis/region/monthly",
"target": "self",
"icon": null,
"order": 10,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005406001,
"children": []
},
{
"id": 1005406005,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Annually",
"uri": "{/base}/sales/analysis/region/annually",
"target": "self",
"icon": null,
"order": 15,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005406001,
"children": []
}
]
},
{
"id": 1005407001,
@ -94,14 +339,75 @@
"type": 3,
"subtype": 1,
"name": "SalesRep",
"uri": "{/base}/sales/analysis/rep",
"uri": "{/base}/sales/analysis/rep/ytd",
"target": "self",
"icon": null,
"order": 25,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005401001,
"children": []
"children": [
{
"id": 1005407002,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "YTD",
"uri": "{/base}/sales/analysis/rep/ytd",
"target": "self",
"icon": null,
"order": 1,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005407001,
"children": []
},
{
"id": 1005407003,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "MTD",
"uri": "{/base}/sales/analysis/rep/mtd",
"target": "self",
"icon": null,
"order": 5,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005407001,
"children": []
},
{
"id": 1005407004,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Monthly",
"uri": "{/base}/sales/analysis/rep/monthly",
"target": "self",
"icon": null,
"order": 10,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005407001,
"children": []
},
{
"id": 1005407005,
"pid": "/sales/analysis",
"type": 4,
"subtype": 1,
"name": "Annually",
"uri": "{/base}/sales/analysis/rep/annually",
"target": "self",
"icon": null,
"order": 15,
"from": "SalesAnalysis",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1005407001,
"children": []
}
]
}
]
}

View File

@ -6,9 +6,45 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^/sales/analysis(\?.*$|$)' => [
'^/sales/analysis/ytd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewDashboard',
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewDashboardYtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/mtd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewDashboardMtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/monthly(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewDashboardMonthly',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/annually(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewDashboardAnnually',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
@ -19,9 +55,9 @@ return [
],
],
'^/sales/analysis/bill(\?.*$|$)' => [
'^/sales/analysis/bill/ytd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewBillAnalysis',
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewBillAnalysisYtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
@ -31,9 +67,9 @@ return [
],
],
],
'^/sales/analysis/rep(\?.*$|$)' => [
'^/sales/analysis/bill/mtd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewSalesRepAnalysis',
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewBillAnalysisMtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
@ -43,9 +79,9 @@ return [
],
],
],
'^/sales/analysis/region(\?.*$|$)' => [
'^/sales/analysis/bill/monthly(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewRegionAnalysis',
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewBillAnalysisMonthly',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
@ -55,9 +91,9 @@ return [
],
],
],
'^/sales/analysis/client(\?.*$|$)' => [
'^/sales/analysis/bill/annually(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewClientAnalysis',
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewBillAnalysisAnnually',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
@ -67,9 +103,189 @@ return [
],
],
],
'^/sales/analysis/item(\?.*$|$)' => [
'^/sales/analysis/rep/ytd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewItemSalesAnalysis',
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewSalesRepAnalysisYtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/rep/mtd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewSalesRepAnalysisMtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/rep/monthly(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewSalesRepAnalysisMonthly',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/rep/annually(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewSalesRepAnalysisAnnually',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/region/ytd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewRegionAnalysisYtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/region/mtd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewRegionAnalysisMtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/region/monthly(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewRegionAnalysisMonthly',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/region/annually(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewRegionAnalysisAnnually',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/client/ytd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewClientAnalysisYtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/client/mtd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewClientAnalysisMtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/client/monthly(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewClientAnalysisMonthly',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/client/annually(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewClientAnalysisAnnually',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/item/ytd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewItemSalesAnalysisYtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/item/mtd(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewItemSalesAnalysisMtd',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/item/monthly(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewItemSalesAnalysisMonthly',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::DASHBOARD,
],
],
],
'^/sales/analysis/item/annually(\?.*$|$)' => [
[
'dest' => '\Modules\SalesAnalysis\Controller\BackendController:viewItemSalesAnalysisAnnually',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\SalesAnalysis\Controller;
use Modules\Organization\Models\UnitMapper;
use Modules\Sales\Models\SalesRepMapper as ModelsSalesRepMapper;
use Modules\SalesAnalysis\Models\ClientMapper;
use Modules\SalesAnalysis\Models\GeneralMapper;
use Modules\SalesAnalysis\Models\ItemMapper;
@ -58,7 +59,7 @@ final class BackendController extends Controller
*
* @since 1.0.0
*/
public function viewDashboard(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
public function viewDashboardYtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
@ -162,7 +163,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewRegionAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
public function viewRegionAnalysisYtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
@ -355,7 +356,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewSalesRepAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
public function viewSalesRepAnalysisYtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
@ -365,8 +366,9 @@ final class BackendController extends Controller
$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');
$view->setTemplate('/Modules/SalesAnalysis/Theme/Backend/analysis-rep-ytd');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005401001, $request, $response);
$view->data['nav-sub'] = $this->app->moduleManager->get('Navigation')->createNavigationMidSub(1005407001, $request, $response);
$businessStart = 1;
$startOfYear = SmartDateTime::createFromDateTime(SmartDateTime::startOfYear($businessStart));
@ -383,30 +385,11 @@ final class BackendController extends Controller
$view->data['endComparison'] = $endComparison;
$view->data['historyStart'] = $historyStart;
$domestic = UnitMapper::get()
->with('mainAddress')
->where('id', $this->app->unitId)
->execute();
[
$mtdCurrent,
$ytdCurrent,
$monthlyCurrent
] = SalesRepMapper::monthlySalesProfit(
$startCurrent,
$endCurrent,
$businessStart
);
[
$mtdPY,
$ytdPY,
$monthlyPY
] = SalesRepMapper::monthlySalesProfit(
$startComparison,
$endComparison,
$businessStart
);
$view->data['salesRep'] = ModelsSalesRepMapper::getAll()
->with('main')
->with('main/account')
->where('unit', $this->app->unitId)
->executeGetArray();
[
$view->data['mtdPYClientRep'],
@ -421,8 +404,6 @@ final class BackendController extends Controller
$businessStart
);
$annualRepSales = SalesRepMapper::salesProfitRep($historyStart, $startCurrent, $startCurrent, $endCurrent);
[
$view->data['mtdPYClientRepCount'],
$view->data['mtdAClientRepCount'],
@ -453,7 +434,242 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewBillAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
public function viewSalesRepAnalysisMtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
$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-mtd');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005401001, $request, $response);
$view->data['nav-sub'] = $this->app->moduleManager->get('Navigation')->createNavigationMidSub(1005407001, $request, $response);
$businessStart = 1;
$startOfYear = SmartDateTime::createFromDateTime(SmartDateTime::startOfYear($businessStart));
$startCurrent = $request->getDataDateTime('startcurrent') ?? clone $startOfYear;
$endCurrent = $request->getDataDateTime('endcurrent') ?? SmartDateTime::endOfMonth();
$endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $endCurrent->format('m'), $businessStart);
$startComparison = $request->getDataDateTime('startcomparison') ?? SmartDateTime::createFromDateTime($startCurrent)->createModify(-1);
$endComparison = $request->getDataDateTime('endcomparison') ?? SmartDateTime::createFromDateTime(SmartDateTime::endOfYear($businessStart))->smartModify(-1);
$historyStart = $startOfYear->createModify(-9);
$view->data['startCurrent'] = $startCurrent;
$view->data['endCurrent'] = $endCurrent;
$view->data['startComparison'] = $startComparison;
$view->data['endComparison'] = $endComparison;
$view->data['historyStart'] = $historyStart;
$view->data['salesRep'] = ModelsSalesRepMapper::getAll()
->with('main')
->with('main/account')
->where('unit', $this->app->unitId)
->executeGetArray();
[
$view->data['mtdPYClientRep'],
$view->data['mtdAClientRep'],
$view->data['ytdPYClientRep'],
$view->data['ytdAClientRep'],
] = SalesRepMapper::mtdYtdRep(
$startCurrent,
$endCurrent,
$startComparison,
$endComparison,
$businessStart
);
[
$view->data['mtdPYClientRepCount'],
$view->data['mtdAClientRepCount'],
$view->data['ytdPYClientRepCount'],
$view->data['ytdAClientRepCount'],
] = SalesRepMapper::mtdYtdClientRep(
$startCurrent,
$endCurrent,
$startComparison,
$endComparison,
$businessStart
);
$annualRepCount = SalesRepMapper::annualCustomerRep(clone $historyStart, $endCurrent);
return $view;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewSalesRepAnalysisMonthly(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
$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-monthly');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005401001, $request, $response);
$view->data['nav-sub'] = $this->app->moduleManager->get('Navigation')->createNavigationMidSub(1005407001, $request, $response);
$businessStart = 1;
$startOfYear = SmartDateTime::createFromDateTime(SmartDateTime::startOfYear($businessStart));
$startCurrent = $request->getDataDateTime('startcurrent') ?? clone $startOfYear;
$endCurrent = $request->getDataDateTime('endcurrent') ?? SmartDateTime::endOfMonth();
$endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $endCurrent->format('m'), $businessStart);
$startComparison = $request->getDataDateTime('startcomparison') ?? SmartDateTime::createFromDateTime($startCurrent)->createModify(-1);
$endComparison = $request->getDataDateTime('endcomparison') ?? SmartDateTime::createFromDateTime(SmartDateTime::endOfYear($businessStart))->smartModify(-1);
$historyStart = $startOfYear->createModify(-9);
$view->data['startCurrent'] = $startCurrent;
$view->data['endCurrent'] = $endCurrent;
$view->data['startComparison'] = $startComparison;
$view->data['endComparison'] = $endComparison;
$view->data['endCurrentIndex'] = $endCurrentIndex;
$view->data['historyStart'] = $historyStart;
$view->data['salesRep'] = ModelsSalesRepMapper::getAll()
->with('main')
->with('main/account')
->where('unit', $this->app->unitId)
->executeGetArray();
[
$mtdCurrent,
$ytdCurrent,
$monthlyCurrent
] = SalesRepMapper::monthlySalesProfit(
$startCurrent,
$endCurrent,
$businessStart
);
$view->data['monthlyRepCurrent'] = $monthlyCurrent;
[
$mtdPY,
$ytdPY,
$monthlyPY
] = SalesRepMapper::monthlySalesProfit(
$startComparison,
$endComparison,
$businessStart
);
$view->data['monthlyRepPY'] = $monthlyPY;
return $view;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewSalesRepAnalysisAnnually(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
$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-annually');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005401001, $request, $response);
$view->data['nav-sub'] = $this->app->moduleManager->get('Navigation')->createNavigationMidSub(1005407001, $request, $response);
$businessStart = 1;
$startOfYear = SmartDateTime::createFromDateTime(SmartDateTime::startOfYear($businessStart));
$startCurrent = $request->getDataDateTime('startcurrent') ?? clone $startOfYear;
$endCurrent = $request->getDataDateTime('endcurrent') ?? SmartDateTime::endOfMonth();
$endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $endCurrent->format('m'), $businessStart);
$startComparison = $request->getDataDateTime('startcomparison') ?? SmartDateTime::createFromDateTime($startCurrent)->createModify(-1);
$endComparison = $request->getDataDateTime('endcomparison') ?? SmartDateTime::createFromDateTime(SmartDateTime::endOfYear($businessStart))->smartModify(-1);
$historyStart = $startOfYear->createModify(-9);
$view->data['startCurrent'] = $startCurrent;
$view->data['endCurrent'] = $endCurrent;
$view->data['startComparison'] = $startComparison;
$view->data['endComparison'] = $endComparison;
$view->data['historyStart'] = $historyStart;
$view->data['salesRep'] = ModelsSalesRepMapper::getAll()
->with('main')
->with('main/account')
->where('unit', $this->app->unitId)
->executeGetArray();
[
$view->data['mtdPYClientRep'],
$view->data['mtdAClientRep'],
$view->data['ytdPYClientRep'],
$view->data['ytdAClientRep'],
] = SalesRepMapper::mtdYtdRep(
$startCurrent,
$endCurrent,
$startComparison,
$endComparison,
$businessStart
);
$view->data['annualRep'] = SalesRepMapper::salesProfitRep($historyStart, $startCurrent, $startCurrent, $endCurrent);
[
$view->data['mtdPYClientRepCount'],
$view->data['mtdAClientRepCount'],
$view->data['ytdPYClientRepCount'],
$view->data['ytdAClientRepCount'],
] = SalesRepMapper::mtdYtdClientRep(
$startCurrent,
$endCurrent,
$startComparison,
$endComparison,
$businessStart
);
$annualRepCount = SalesRepMapper::annualCustomerRep(clone $historyStart, $endCurrent);
return $view;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewBillAnalysisYtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
@ -481,7 +697,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewClientAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
public function viewClientAnalysisYtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');
@ -656,7 +872,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewItemSalesAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
public function viewItemSalesAnalysisYtd(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$head = $response->data['Content']->head;
$nonce = $this->app->appSettings->getOption('script-nonce');

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\SalesAnalysis\Models;
use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillTransferType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Query\Builder;
@ -73,6 +74,7 @@ class ClientMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
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\')

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\SalesAnalysis\Models;
use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillTransferType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Query\Builder;
@ -55,6 +56,7 @@ class GeneralMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY
@ -151,6 +153,7 @@ class GeneralMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\SalesAnalysis\Models;
use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillTransferType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Query\Builder;
@ -47,47 +48,54 @@ class ItemMapper extends DataMapperFactory
$query = new Builder(self::$db);
$query->raw(
'SELECT
itemmgmt_attr_type_name,
itemmgmt_attr_type_l11n_title,
itemmgmt_attr_value_id,
itemmgmt_attr_value_l11n_title,
segment, section, sales_group, product_group, product_type,
YEAR(billing_bill_performance_date) as salesyear,
MONTH(billing_bill_performance_date) as salesmonth,
SUM(billing_bill_element_total_netsalesprice * billing_type_sign) as netsales,
SUM(billing_bill_element_total_netprofit * billing_type_sign) as netprofit
FROM billing_bill
LEFT JOIN billing_type
ON billing_bill_type = billing_type_id
LEFT JOIN billing_bill_element
ON billing_bill_id = billing_bill_element_bill
LEFT JOIN itemmgmt_item
ON itemmgmt_item_id = billing_bill_element_item
LEFT JOIN itemmgmt_item_attr
ON itemmgmt_item_id = itemmgmt_item_attr_item
LEFT JOIN itemmgmt_attr_type
ON itemmgmt_item_attr_type = itemmgmt_attr_type_id
LEFT JOIN itemmgmt_attr_type_l11n
ON itemmgmt_attr_type_id = itemmgmt_attr_type_l11n_type AND itemmgmt_attr_type_l11n_lang = \'' . $language . '\'
LEFT JOIN itemmgmt_attr_value
ON itemmgmt_item_attr_value = itemmgmt_attr_value_id
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_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
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\', \'sales_group\', \'product_group\', \'product_type\')
SUM(netsales) AS netsales,
SUM(netprofit) AS netprofit
FROM (
SELECT
MAX(CASE WHEN itemmgmt_attr_type.itemmgmt_attr_type_name = \'segment\' THEN itemmgmt_attr_value_l11n.itemmgmt_attr_value_l11n_title END) AS segment,
MAX(CASE WHEN itemmgmt_attr_type.itemmgmt_attr_type_name = \'section\' THEN itemmgmt_attr_value_l11n.itemmgmt_attr_value_l11n_title END) AS section,
MAX(CASE WHEN itemmgmt_attr_type.itemmgmt_attr_type_name = \'sales_group\' THEN itemmgmt_attr_value_l11n.itemmgmt_attr_value_l11n_title END) AS sales_group,
MAX(CASE WHEN itemmgmt_attr_type.itemmgmt_attr_type_name = \'product_group\' THEN itemmgmt_attr_value_l11n.itemmgmt_attr_value_l11n_title END) AS product_group,
MAX(CASE WHEN itemmgmt_attr_type.itemmgmt_attr_type_name = \'product_type\' THEN itemmgmt_attr_value_l11n.itemmgmt_attr_value_l11n_title END) AS product_type,
billing_bill_performance_date,
SUM(billing_bill_element_total_netsalesprice * billing_type_sign) as netsales,
SUM(billing_bill_element_total_netprofit * billing_type_sign) as netprofit
FROM billing_bill
LEFT JOIN billing_type
ON billing_bill_type = billing_type_id
LEFT JOIN billing_bill_element
ON billing_bill_id = billing_bill_element_bill
LEFT JOIN itemmgmt_item
ON itemmgmt_item_id = billing_bill_element_item
LEFT JOIN itemmgmt_item_attr
ON itemmgmt_item_id = itemmgmt_item_attr_item
LEFT JOIN itemmgmt_attr_type
ON itemmgmt_item_attr_type = itemmgmt_attr_type_id
LEFT JOIN itemmgmt_attr_type_l11n
ON itemmgmt_attr_type_id = itemmgmt_attr_type_l11n_type AND itemmgmt_attr_type_l11n_lang = \'' . $language . '\'
LEFT JOIN itemmgmt_attr_value
ON itemmgmt_item_attr_value = itemmgmt_attr_value_id
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_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
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\', \'sales_group\', \'product_group\', \'product_type\')
GROUP BY billing_bill_performance_date
) AS subquery
GROUP BY
itemmgmt_attr_type_name,
itemmgmt_attr_type_l11n_title,
itemmgmt_attr_value_id,
itemmgmt_attr_value_l11n_title,
segment, section, sales_group, product_group, product_type,
YEAR(billing_bill_performance_date),
MONTH(billing_bill_performance_date)
ORDER BY
YEAR(billing_bill_performance_date) ASC,
MONTH(billing_bill_performance_date) ASC'
MONTH(billing_bill_performance_date) ASC;'
);
$results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
@ -95,11 +103,11 @@ class ItemMapper extends DataMapperFactory
$oldIndex = 1;
$period = 1;
$mtdAItemAttribute = [];
$mtdPYItemAttribute = [];
$mtdAItemAttribute = ['segment' => [], 'section' => [], 'sales_group' => [], 'product_group' => [], 'product_type' => []];
$mtdPYItemAttribute = ['segment' => [], 'section' => [], 'sales_group' => [], 'product_group' => [], 'product_type' => []];
$ytdAItemAttribute = [];
$ytdPYItemAttribute = [];
$ytdAItemAttribute = ['segment' => [], 'section' => [], 'sales_group' => [], 'product_group' => [], 'product_type' => []];
$ytdPYItemAttribute = ['segment' => [], 'section' => [], 'sales_group' => [], 'product_group' => [], 'product_type' => []];
foreach ($results as $result) {
$monthIndex = SmartDateTime::calculateMonthIndex((int) $result['salesmonth'], $businessStart);
@ -127,33 +135,113 @@ class ItemMapper extends DataMapperFactory
if ($monthIndex === $endCurrentIndex) {
if ($period === 1) {
$mtdPYItemAttribute[$result['itemmgmt_attr_type_name']] = $temp;
$mtdPYItemAttribute['segment'][$result['segment']] = $temp;
$mtdPYItemAttribute['section'][$result['section']] = $temp;
$mtdPYItemAttribute['sales_group'][$result['sales_group']] = $temp;
$mtdPYItemAttribute['product_group'][$result['product_group']] = $temp;
$mtdPYItemAttribute['product_type'][$result['product_type']] = $temp;
} else {
$mtdAItemAttribute[$result['itemmgmt_attr_type_name']] = $temp;
$mtdAItemAttribute['segment'][$result['segment']] = $temp;
$mtdAItemAttribute['section'][$result['section']] = $temp;
$mtdAItemAttribute['sales_group'][$result['sales_group']] = $temp;
$mtdAItemAttribute['product_group'][$result['product_group']] = $temp;
$mtdAItemAttribute['product_type'][$result['product_type']] = $temp;
}
}
if ($monthIndex <= $endCurrentIndex) {
if (!isset($ytdPYItemAttribute[$result['itemmgmt_attr_type_name']])) {
$ytdPYItemAttribute[$result['itemmgmt_attr_type_name']] = [
if (!isset($ytdPYItemAttribute['segment'][$result['segment']])) {
$ytdPYItemAttribute['segment'][$result['segment']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['itemmgmt_attr_value_l11n_title'],
'value_l11n' => $result['segment'],
];
$ytdAItemAttribute[$result['itemmgmt_attr_type_name']] = [
$ytdAItemAttribute['segment'][$result['segment']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['itemmgmt_attr_value_l11n_title'],
'value_l11n' => $result['segment'],
];
}
if (!isset($ytdPYItemAttribute['section'][$result['section']])) {
$ytdPYItemAttribute['section'][$result['section']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['section'],
];
$ytdAItemAttribute['section'][$result['section']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['section'],
];
}
if (!isset($ytdPYItemAttribute['sales_group'][$result['sales_group']])) {
$ytdPYItemAttribute['sales_group'][$result['sales_group']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['sales_group'],
];
$ytdAItemAttribute['sales_group'][$result['sales_group']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['sales_group'],
];
}
if (!isset($ytdPYItemAttribute['product_group'][$result['product_group']])) {
$ytdPYItemAttribute['product_group'][$result['product_group']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['product_group'],
];
$ytdAItemAttribute['product_group'][$result['product_group']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['product_group'],
];
}
if (!isset($ytdPYItemAttribute['product_type'][$result['product_type']])) {
$ytdPYItemAttribute['product_type'][$result['product_type']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['product_type'],
];
$ytdAItemAttribute['product_type'][$result['product_type']] = [
'net_sales' => 0,
'net_profit' => 0,
'value_l11n' => $result['product_type'],
];
}
if ($period === 1) {
$ytdPYItemAttribute[$result['itemmgmt_attr_type_name']]['net_sales'] += $temp['net_sales'];
$ytdPYItemAttribute[$result['itemmgmt_attr_type_name']]['net_profit'] += $temp['net_profit'];
$ytdPYItemAttribute['segment'][$result['segment']]['net_sales'] += $temp['net_sales'];
$ytdPYItemAttribute['segment'][$result['segment']]['net_profit'] += $temp['net_profit'];
$ytdPYItemAttribute['section'][$result['section']]['net_sales'] += $temp['net_sales'];
$ytdPYItemAttribute['section'][$result['section']]['net_profit'] += $temp['net_profit'];
$ytdPYItemAttribute['sales_group'][$result['sales_group']]['net_sales'] += $temp['net_sales'];
$ytdPYItemAttribute['sales_group'][$result['sales_group']]['net_profit'] += $temp['net_profit'];
$ytdPYItemAttribute['product_group'][$result['product_group']]['net_sales'] += $temp['net_sales'];
$ytdPYItemAttribute['product_group'][$result['product_group']]['net_profit'] += $temp['net_profit'];
$ytdPYItemAttribute['product_type'][$result['product_type']]['net_sales'] += $temp['net_sales'];
$ytdPYItemAttribute['product_type'][$result['product_type']]['net_profit'] += $temp['net_profit'];
} else {
$ytdAItemAttribute[$result['itemmgmt_attr_type_name']]['net_sales'] += $temp['net_sales'];
$ytdAItemAttribute[$result['itemmgmt_attr_type_name']]['net_profit'] += $temp['net_profit'];
$ytdAItemAttribute['segment'][$result['segment']]['net_sales'] += $temp['net_sales'];
$ytdAItemAttribute['segment'][$result['segment']]['net_profit'] += $temp['net_profit'];
$ytdAItemAttribute['section'][$result['section']]['net_sales'] += $temp['net_sales'];
$ytdAItemAttribute['section'][$result['section']]['net_profit'] += $temp['net_profit'];
$ytdAItemAttribute['sales_group'][$result['sales_group']]['net_sales'] += $temp['net_sales'];
$ytdAItemAttribute['sales_group'][$result['sales_group']]['net_profit'] += $temp['net_profit'];
$ytdAItemAttribute['product_group'][$result['product_group']]['net_sales'] += $temp['net_sales'];
$ytdAItemAttribute['product_group'][$result['product_group']]['net_profit'] += $temp['net_profit'];
$ytdAItemAttribute['product_type'][$result['product_type']]['net_sales'] += $temp['net_sales'];
$ytdAItemAttribute['product_type'][$result['product_type']]['net_profit'] += $temp['net_profit'];
}
}
}

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\SalesAnalysis\Models;
use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillTransferType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Query\Builder;
@ -62,6 +63,7 @@ class RegionMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $start->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $end->format('Y-m-d') . '\'
GROUP BY
@ -145,6 +147,7 @@ class RegionMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY
@ -229,6 +232,7 @@ class RegionMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY
@ -339,6 +343,7 @@ class RegionMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $currentEnd->format('Y-m-d') . '\'
GROUP BY
@ -406,6 +411,7 @@ class RegionMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\SalesAnalysis\Models;
use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillTransferType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Query\Builder;
@ -58,6 +59,7 @@ class SalesRepMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $start->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $end->format('Y-m-d') . '\'
GROUP BY
@ -141,6 +143,7 @@ class SalesRepMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY
@ -225,6 +228,7 @@ class SalesRepMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY
@ -242,11 +246,11 @@ class SalesRepMapper extends DataMapperFactory
$oldIndex = 1;
$period = 1;
$mtdAClientCountry = [];
$mtdPYClientCountry = [];
$mtdAClientRep = [];
$mtdPYClientRep = [];
$ytdAClientCountry = [];
$ytdPYClientCountry = [];
$ytdAClientRep = [];
$ytdPYClientRep = [];
foreach ($results as $result) {
$monthIndex = SmartDateTime::calculateMonthIndex((int) $result['salesmonth'], $businessStart);
@ -273,36 +277,36 @@ class SalesRepMapper extends DataMapperFactory
if ($monthIndex === $endCurrentIndex) {
if ($period === 1) {
$mtdPYClientCountry[$result['billing_bill_rep']] = $temp;
$mtdPYClientRep[$result['billing_bill_rep']] = $temp;
} else {
$mtdAClientCountry[$result['billing_bill_rep']] = $temp;
$mtdAClientRep[$result['billing_bill_rep']] = $temp;
}
}
if ($monthIndex <= $endCurrentIndex) {
if (!isset($ytdPYClientCountry[$result['billing_bill_rep']])) {
$ytdPYClientCountry[$result['billing_bill_rep']] = [
if (!isset($ytdPYClientRep[$result['billing_bill_rep']])) {
$ytdPYClientRep[$result['billing_bill_rep']] = [
'client_count' => 0,
];
$ytdAClientCountry[$result['billing_bill_rep']] = [
$ytdAClientRep[$result['billing_bill_rep']] = [
'client_count' => 0,
];
}
if ($period === 1) {
$ytdPYClientCountry[$result['billing_bill_rep']]['client_count'] += $temp['client_count'];
$ytdPYClientRep[$result['billing_bill_rep']]['client_count'] += $temp['client_count'];
} else {
$ytdAClientCountry[$result['billing_bill_rep']]['client_count'] += $temp['client_count'];
$ytdAClientRep[$result['billing_bill_rep']]['client_count'] += $temp['client_count'];
}
}
}
return [
$mtdPYClientCountry,
$mtdAClientCountry,
$ytdPYClientCountry,
$ytdAClientCountry,
$mtdPYClientRep,
$mtdAClientRep,
$ytdPYClientRep,
$ytdAClientRep,
];
}
@ -328,6 +332,10 @@ class SalesRepMapper extends DataMapperFactory
FROM billing_bill
LEFT JOIN billing_type
ON billing_bill_type = billing_type_id
LEFT JOIN sales_rep
ON billing_bill_rep = sales_rep_id
LEFT JOIN account
ON sales_rep_main = account_id
LEFT JOIN clientmgmt_client
ON clientmgmt_client_id = billing_bill_client
LEFT JOIN address
@ -335,6 +343,7 @@ class SalesRepMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $historyStart->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $currentEnd->format('Y-m-d') . '\'
GROUP BY
@ -402,6 +411,7 @@ class SalesRepMapper extends DataMapperFactory
WHERE
billing_type_transfer_type = ' . BillTransferType::SALES . '
AND billing_type_accounting = 1
AND billing_bill_status = ' . BillStatus::ARCHIVED . '
AND billing_bill_performance_date >= \'' . $startComparison->format('Y-m-d') . '\'
AND billing_bill_performance_date <= \'' . $endCurrent->format('Y-m-d') . '\'
GROUP BY
@ -419,11 +429,11 @@ class SalesRepMapper extends DataMapperFactory
$oldIndex = 1;
$period = 1;
$mtdAClientCountry = [];
$mtdPYClientCountry = [];
$mtdAClientRep = [];
$mtdPYClientRep = [];
$ytdAClientCountry = [];
$ytdPYClientCountry = [];
$ytdAClientRep = [];
$ytdPYClientRep = [];
foreach ($results as $result) {
$monthIndex = SmartDateTime::calculateMonthIndex((int) $result['salesmonth'], $businessStart);
@ -451,40 +461,40 @@ class SalesRepMapper extends DataMapperFactory
if ($monthIndex === $endCurrentIndex) {
if ($period === 1) {
$mtdPYClientCountry[$result['billing_bill_rep']] = $temp;
$mtdPYClientRep[$result['billing_bill_rep']] = $temp;
} else {
$mtdAClientCountry[$result['billing_bill_rep']] = $temp;
$mtdAClientRep[$result['billing_bill_rep']] = $temp;
}
}
if ($monthIndex <= $endCurrentIndex) {
if (!isset($ytdPYClientCountry[$result['billing_bill_rep']])) {
$ytdPYClientCountry[$result['billing_bill_rep']] = [
if (!isset($ytdPYClientRep[$result['billing_bill_rep']])) {
$ytdPYClientRep[$result['billing_bill_rep']] = [
'net_sales' => 0,
'net_profit' => 0,
];
$ytdAClientCountry[$result['billing_bill_rep']] = [
$ytdAClientRep[$result['billing_bill_rep']] = [
'net_sales' => 0,
'net_profit' => 0,
];
}
if ($period === 1) {
$ytdPYClientCountry[$result['billing_bill_rep']]['net_sales'] += $temp['net_sales'];
$ytdPYClientCountry[$result['billing_bill_rep']]['net_profit'] += $temp['net_profit'];
$ytdPYClientRep[$result['billing_bill_rep']]['net_sales'] += $temp['net_sales'];
$ytdPYClientRep[$result['billing_bill_rep']]['net_profit'] += $temp['net_profit'];
} else {
$ytdAClientCountry[$result['billing_bill_rep']]['net_sales'] += $temp['net_sales'];
$ytdAClientCountry[$result['billing_bill_rep']]['net_profit'] += $temp['net_profit'];
$ytdAClientRep[$result['billing_bill_rep']]['net_sales'] += $temp['net_sales'];
$ytdAClientRep[$result['billing_bill_rep']]['net_profit'] += $temp['net_profit'];
}
}
}
return [
$mtdPYClientCountry,
$mtdAClientCountry,
$ytdPYClientCountry,
$ytdAClientCountry,
$mtdPYClientRep,
$mtdAClientRep,
$ytdPYClientRep,
$ytdAClientRep,
];
}
}

View File

@ -13,7 +13,7 @@
declare(strict_types=1);
return ['Navigation' => [
'Analysis' => 'Analyse',
'Analysis' => 'Auswertung',
'Dashboard' => 'Dashboard',
'Database' => 'Database',
'Invoices' => 'Rechnungen',
@ -21,4 +21,5 @@ return ['Navigation' => [
'Overview' => 'Übersicht',
'Products' => 'Produkte',
'Regions' => 'Regionen',
'SalesRep' => 'Verkäufer',
]];

View File

@ -21,4 +21,10 @@ return ['Navigation' => [
'Overview' => 'Overview',
'Products' => 'Products',
'Regions' => 'Regions',
'YTD' => 'YTD',
'MTD' => 'MTD',
'Monthly' => 'Monthly',
'Annually' => 'Annually',
'SalesRep' => 'Sales Reps',
'SalesRep' => 'Sales Rep',
]];

View File

@ -68,6 +68,6 @@ return ['SalesAnalysis' => [
'America' => 'Amerika',
'Oceania' => 'Ozeanien',
'Africa' => 'Afrika',
'SalesRep' => 'Verkäufer',
'SalesReps' => 'Verkäufer',
'SalesRep' => 'Verkäufer',
]];

View File

@ -68,6 +68,9 @@ return ['SalesAnalysis' => [
'America' => 'America',
'Oceania' => 'Oceania',
'Africa' => 'Africa',
'SalesRep' => 'SalesRep',
'SalesReps' => 'SalesReps',
'YTD' => 'YTD',
'Monthly' => 'Monthly',
'Annually' => 'Annually',
'SalesReps' => 'Sales Reps',
'SalesRep' => 'Sales Rep',
]];

View File

@ -49,29 +49,26 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
foreach ($this->data['ytdAItemAttribute'] as $type => $values) :
if ($type !== 'segment') {
continue;
}
foreach ($this->data['ytdAItemAttribute']['segment'] as $values) :
?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYItemAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->printHtml($values['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['ytdAItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['mtdAItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute']['segment'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<?php endforeach; ?>
</table>
</div>
</section>
</section>
</div>
</div>
</div>
@ -94,25 +91,22 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
foreach ($this->data['ytdAItemAttribute'] as $type => $values) :
if ($type !== 'section') {
continue;
}
<?php
foreach ($this->data['ytdAItemAttribute']['section'] as $values) :
?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYItemAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->printHtml($values['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['ytdAItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['mtdAItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute']['section'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<?php endforeach; ?>
</table>
@ -141,24 +135,21 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
foreach ($this->data['ytdAItemAttribute'] as $type => $values) :
if ($type !== 'sales_group') {
continue;
}
foreach ($this->data['ytdAItemAttribute']['sales_group'] as $values) :
?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYItemAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->printHtml($values['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['ytdAItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['mtdAItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute']['sales_group'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<?php endforeach; ?>
</table>
@ -187,24 +178,21 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
foreach ($this->data['ytdAItemAttribute'] as $type => $values) :
if ($type !== 'product_group') {
continue;
}
foreach ($this->data['ytdAItemAttribute']['product_group'] as $values) :
?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYItemAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->printHtml($values['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['ytdAItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['mtdAItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute']['product_group'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<?php endforeach; ?>
</table>
@ -233,24 +221,21 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
foreach ($this->data['ytdAItemAttribute'] as $type => $values) :
if ($type !== 'product_type') {
continue;
}
foreach ($this->data['ytdAItemAttribute']['product_type'] as $values) :
?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYItemAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->printHtml($values['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['ytdAItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0)); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0))
((int) ($this->data['mtdAItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute']['product_type'][$values['value_l11n']]['net_sales'] ?? 0))
); ?>
<?php endforeach; ?>
</table>

View File

@ -21,6 +21,7 @@ use phpOMS\Uri\UriFactory;
*/
echo $this->data['nav']->render();
?>
<!--
<div class="row">
<div class="col-xs-12 col-lg-4">
<section class="portlet">
@ -87,6 +88,7 @@ echo $this->data['nav']->render();
</section>
</div>
</div>
-->
<div class="row">
<div class="col-xs-12 col-lg-6">
@ -233,12 +235,12 @@ echo $this->data['nav']->render();
}
}'></canvas>
<div class="more-container">
<input id="more-customer-sales" type="checkbox" name="more-container">
<label for="more-customer-sales">
<input id="more-customer-sales" class="more" type="checkbox" name="more-container">
<label class="more" for="more-customer-sales">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -380,12 +382,12 @@ echo $this->data['nav']->render();
}
}'></canvas>
<div class="more-container">
<input id="more-customer-sales-annual" type="checkbox" name="more-container">
<label for="more-customer-sales-annual">
<input id="more-customer-sales-annual" class="more" type="checkbox" name="more-container">
<label class="more" for="more-customer-sales-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -397,7 +399,7 @@ echo $this->data['nav']->render();
foreach ($sales as $values) :
?>
<tr>
<td>
<td><?= $this->printHtml($values['year']); ?>
<td><?= $this->getCurrency(((int) $values['net_sales']) / FloatInt::DIVISOR, symbol: ''); ?>
<td><?= \sprintf('%.2f', $values['net_sales'] == 0 ? 0 : $values['net_profit'] * 100 / $values['net_sales']); ?> %
<?php endforeach; ?>
@ -409,90 +411,6 @@ echo $this->data['nav']->render();
</div>
</div>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('ItemAttribute'); ?>
</div>
<div class="slider">
<table class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Category'); ?>
<td><?= $this->getHtml('SalesPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('SalesPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php foreach ($this->data['ytdAItemAttribute'] as $type => $values) : ?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYItemAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYItemAttribute'][$type]['net_sales'] ?? 0)),
symbol: ''
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAItemAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYItemAttribute'][$type]['net_sales'] ?? 0)),
symbol: ''
); ?>
<?php endforeach; ?>
</table>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('ClientAttribute'); ?>
</div>
<div class="slider">
<table class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Category'); ?>
<td><?= $this->getHtml('SalesPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('SalesPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php foreach ($this->data['ytdAClientAttribute'] as $type => $values) : ?>
<tr>
<td><?= $this->printHtml($this->data['ytdPYClientAttribute'][$type]['value_l11n']); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYClientAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAClientAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAClientAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYClientAttribute'][$type]['net_sales'] ?? 0)),
symbol: ''
); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYClientAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAClientAttribute'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAClientAttribute'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYClientAttribute'][$type]['net_sales'] ?? 0)),
symbol: ''
); ?>
<?php endforeach; ?>
</table>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
@ -511,7 +429,10 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php foreach ($this->data['ytdAClientCountry'] as $type => $values) : ?>
<?php
\uasort($this->data['ytdAClientCountry'], function (array $a, array $b) { return (($b['net_sales'] ?? 0) <=> $a['net_sales'] ?? 0); });
foreach ($this->data['ytdAClientCountry'] as $type => $values) :
?>
<tr>
<td><?= $this->printHtml(ISO3166NameEnum::getBy2Code($type)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYClientCountry'][$type]['net_sales'] ?? 0), symbol: ''); ?>

View File

@ -85,7 +85,7 @@ echo $this->data['nav']->render();
<div class="portlet-head">
<?= $this->getHtml('Country'); ?>
</div>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -97,7 +97,10 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php foreach ($this->data['ytdAClientCountry'] as $type => $values) : ?>
<?php
\uasort($this->data['ytdAClientCountry'], function (array $a, array $b) { return (($b['net_sales'] ?? 0) <=> $a['net_sales'] ?? 0); });
foreach ($this->data['ytdAClientCountry'] as $type => $values) :
?>
<tr>
<td><?= $this->printHtml(ISO3166NameEnum::getBy2Code($type)); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYClientCountry'][$type]['net_sales'] ?? 0), symbol: ''); ?>
@ -270,12 +273,12 @@ echo $this->data['nav']->render();
}
}'></canvas>
<div class="more-container">
<input id="more-domestic-monthly-sales" type="checkbox" name="more-container">
<label for="more-domestic-monthly-sales">
<input class="more" id="more-domestic-monthly-sales" type="checkbox" name="more-container">
<label class="more" for="more-domestic-monthly-sales">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -460,12 +463,12 @@ echo $this->data['nav']->render();
}
}'></canvas>
<div class="more-container">
<input id="more-export-monthly-sales" type="checkbox" name="more-container">
<label for="more-export-monthly-sales">
<input class="more" id="more-export-monthly-sales" type="checkbox" name="more-container">
<label class="more" for="more-export-monthly-sales">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -536,12 +539,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-domestic-export-region" type="checkbox" name="more-container">
<label for="more-domestic-export-region">
<input class="more" id="more-domestic-export-region" type="checkbox" name="more-container">
<label class="more" for="more-domestic-export-region">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -611,12 +614,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-sales-domestic-export-annual" type="checkbox" name="more-container">
<label for="more-sales-domestic-export-annual">
<input class="more" id="more-sales-domestic-export-annual" type="checkbox" name="more-container">
<label class="more" for="more-sales-domestic-export-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -677,12 +680,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-domestic-export-profit" type="checkbox" name="more-container">
<label for="more-domestic-export-profit">
<input class="more" id="more-domestic-export-profit" type="checkbox" name="more-container">
<label class="more" for="more-domestic-export-profit">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -762,12 +765,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-profit-domestic-export-annual" type="checkbox" name="more-container">
<label for="more-profit-domestic-export-annual">
<input class="more" id="more-profit-domestic-export-annual" type="checkbox" name="more-container">
<label class="more" for="more-profit-domestic-export-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -828,12 +831,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-client-count-domestic-export-region" type="checkbox" name="more-container">
<label for="more-client-count-domestic-export-region">
<input class="more" id="more-client-count-domestic-export-region" type="checkbox" name="more-container">
<label class="more" for="more-client-count-domestic-export-region">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -903,12 +906,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-client-count-domestic-export-annual" type="checkbox" name="more-container">
<label for="more-client-count-domestic-export-annual">
<input class="more" id="more-client-count-domestic-export-annual" type="checkbox" name="more-container">
<label class="more" for="more-client-count-domestic-export-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -972,12 +975,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-continent-region" type="checkbox" name="more-container">
<label for="more-continent-region">
<input class="more" id="more-continent-region" type="checkbox" name="more-container">
<label class="more" for="more-continent-region">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1047,12 +1050,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-sales-continent-annual" type="checkbox" name="more-container">
<label for="more-sales-continent-annual">
<input class="more" id="more-sales-continent-annual" type="checkbox" name="more-container">
<label class="more" for="more-sales-continent-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1113,12 +1116,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-continent-profit" type="checkbox" name="more-container">
<label for="more-continent-profit">
<input class="more" id="more-continent-profit" type="checkbox" name="more-container">
<label class="more" for="more-continent-profit">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1198,12 +1201,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-profit-continent-annual" type="checkbox" name="more-container">
<label for="more-profit-continent-annual">
<input class="more" id="more-profit-continent-annual" type="checkbox" name="more-container">
<label class="more" for="more-profit-continent-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1264,12 +1267,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-client-count-continent-region" type="checkbox" name="more-container">
<label for="more-client-count-continent-region">
<input class="more" id="more-client-count-continent-region" type="checkbox" name="more-container">
<label class="more" for="more-client-count-continent-region">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1339,12 +1342,12 @@ echo $this->data['nav']->render();
}'></canvas>
<div class="more-container">
<input id="more-client-count-continent-annual" type="checkbox" name="more-container">
<label for="more-client-count-continent-annual">
<input class="more" id="more-client-count-continent-annual" type="checkbox" name="more-container">
<label class="more" for="more-client-count-continent-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1383,7 +1386,7 @@ echo $this->data['nav']->render();
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Sales'); ?></div>
<div class="slider">
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
@ -1395,7 +1398,10 @@ echo $this->data['nav']->render();
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php foreach ($this->data['ytdARegions'] as $type => $values) : ?>
<?php
\uasort($this->data['ytdARegions'], function (array $a, array $b) { return (($b['net_sales'] ?? 0) <=> $a['net_sales'] ?? 0); });
foreach ($this->data['ytdARegions'] as $type => $values) :
?>
<tr>
<td><?= $this->printHtml($type); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYRegions'][$type]['net_sales'] ?? 0), symbol: ''); ?>

View File

@ -0,0 +1,202 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\SalesAnalysis
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Localization\ISO3166CharEnum;
use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Stdlib\Base\FloatInt;
/**
* @var \phpOMS\Views\View $this
*/
echo $this->data['nav']->render();
echo $this->data['nav-sub']->render();
?>
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Sales'); ?> (<?= $this->getHtml('annually'); ?>) - <?= $this->getHtml('SalesReps'); ?></div>
<div class="portlet-body">
<canvas id="sales-annually-rep" data-chart='{
"type": "line",
"data": {
"labels": [
<?php
$temp = [];
for ($i = 0; $i < 10; ++$i) {
$temp[] = ((int) $this->data['historyStart']->format('Y')) + $i;
}
echo \implode(',', $temp);
?>
],
"datasets": [
<?php
$first = true;
foreach ($this->data['annualRep'] as $type => $values) :
echo($first ? '' : ',');
$first = false;
?>{
"label": "<?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>",
"type": "line",
"data": [
<?php
$temp = [];
foreach ($values as $annual) {
$temp[] = ((int) ($annual['net_sales'] ?? 0)) / FloatInt::DIVISOR;
}
echo \implode(',', $temp);
?>
],
"fill": false,
"tension": 0.0,
"hidden": true
}
<?php endforeach; ?>
]
},
"options": {
"responsive": true
}
}'></canvas>
<div class="more-container">
<input class="more" id="more-sales-rep-annual" type="checkbox" name="more-container">
<label class="more" for="more-sales-rep-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Region'); ?>
<?php for ($i = 0; $i < 10; ++$i) : ?>
<td><?= ((int) $this->data['historyStart']->format('Y')) + $i; ?>
<?php endfor; ?>
<tbody>
<?php
$sum = [];
foreach ($this->data['annualRep'] as $type => $values) : ?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>
<?php foreach ($values as $idx => $annual) :
$sum[$idx] = ($sum[$idx] ?? 0) + ($annual['net_sales'] ?? 0);
?>
<td><?= $this->getCurrency($annual['net_sales'] ?? 0, symbol: '', format: 'short', divide: 1000); ?>
<?php endforeach; endforeach; ?>
<tr>
<td><?= $this->getHtml('Total'); ?>
<?php foreach ($sum as $value) : ?>
<td><?= $this->getCurrency($value, symbol: '', format: 'short', divide: 1000); ?>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Profit'); ?> (<?= $this->getHtml('annually'); ?>) - <?= $this->getHtml('SalesReps'); ?></div>
<div class="portlet-body">
<canvas id="profit-annually-rep" data-chart='{
"type": "line",
"data": {
"labels": [
<?php
$temp = [];
for ($i = 0; $i < 10; ++$i) {
$temp[] = ((int) $this->data['historyStart']->format('Y')) + $i;
}
echo \implode(',', $temp);
?>
],
"datasets": [
<?php
$first = true;
foreach ($this->data['annualRep'] as $type => $values) :
echo($first ? '' : ',');
$first = false;
?>{
"label": "<?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>",
"type": "line",
"data": [
<?php
$temp = [];
foreach ($values as $annual) {
$temp[] = ($annual['net_sales'] ?? 0) == 0 ? 0 : ((int) ($annual['net_profit'] ?? 0)) * 100 / $annual['net_sales'];
}
echo \implode(',', $temp);
?>
],
"fill": false,
"tension": 0.0,
"hidden": true
}
<?php endforeach; ?>
]
},
"options": {
"responsive": true,
"scales": {
"y": {
"title": {
"display": true,
"text": "<?= $this->getHtml('Profit'); ?> %"
},
"display": true,
"position": "left"
}
}
}
}'></canvas>
<div class="more-container">
<input class="more" id="more-profit-rep-annual" type="checkbox" name="more-container">
<label class="more" for="more-profit-rep-annual">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Region'); ?>
<?php for ($i = 0; $i < 10; ++$i) : ?>
<td><?= ((int) $this->data['historyStart']->format('Y')) + $i; ?>
<?php endfor; ?>
<tbody>
<?php
$sum = [];
foreach ($this->data['annualRep'] as $type => $values) : ?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>
<?php foreach ($values as $idx => $annual) :
$sum[$idx] = ($sum[$idx] ?? 0) + ($annual['net_profit'] ?? 0);
?>
<td><?= $this->getCurrency($annual['net_profit'] ?? 0, symbol: '', format: 'short', divide: 1000); ?>
<?php endforeach; endforeach; ?>
<tr>
<td><?= $this->getHtml('Total'); ?>
<?php foreach ($sum as $value) : ?>
<td><?= $this->getCurrency($value, symbol: '', format: 'short', divide: 1000); ?>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,219 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\SalesAnalysis
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Localization\ISO3166CharEnum;
use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Stdlib\Base\FloatInt;
/**
* @var \phpOMS\Views\View $this
*/
echo $this->data['nav']->render();
echo $this->data['nav-sub']->render();
?>
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('Sales'); ?> (<?= $this->getHtml('monthly'); ?>) - <?= $this->getHtml('SalesReps'); ?>
</div>
<?php $sales = [1 => $this->data['monthlyRepPY'], 2 => $this->data['monthlyRepCurrent']]; ?>
<div class="portlet-body">
<canvas id="sales-profit-domestic-monthly" data-chart='{
"type": "bar",
"data": {
"labels": [
<?php
$temp = [];
for ($i = 1; $i < 13; ++$i) {
$temp[] = \sprintf('"%02d"', $i);
}
echo \implode(',', $temp);
?>
],
"datasets": [
<?php
$first = true;
foreach ($sales[2] as $type => $values) :
echo($first ? '' : ',');
$first = false;
?>{
"label": "<?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>",
"type": "line",
"data": [
<?php
$temp = [];
for ($i = 1; $i < 13; ++$i) {
if ($i > $this->data['endCurrentIndex']) {
$temp[] = 'null';
continue;
}
if (!isset($sales[2][$type][$i]['net_sales']) || !isset($sales[2][$type][$i]['net_profit'])) {
$temp[] = '0';
continue;
}
$temp[] = $sales[2][$type][$i]['net_sales'] ?? 0;
}
echo \implode(',', $temp);
?>
],
"fill": false,
"tension": 0.0,
"hidden": true
}
<?php endforeach; ?>
]
},
"options": {
"responsive": true
}
}'></canvas>
<div class="more-container">
<input class="more" id="more-domestic-monthly-sales" type="checkbox" name="more-container">
<label class="more" for="more-domestic-monthly-sales">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('SalesRep'); ?>
<?php for ($i = 1; $i < 13; ++$i) : ?>
<td><?= $i; ?>
<?php endfor; ?>
<tbody>
<?php
$sum = [];
foreach ($sales[2] as $type => $values) : ?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>
<?php for ($i = 1; $i < 13; ++$i) :
$sum[$i] = ($sum[$i] ?? 0) + ($values[$i]['net_sales'] ?? 0);
?>
<td><?= $this->getCurrency($values[$i]['net_sales'] ?? 0, symbol: '', format: 'short', divide: 1000); ?>
<?php endfor; endforeach; ?>
<tr>
<td><?= $this->getHtml('Total'); ?>
<?php foreach ($sum as $value) : ?>
<td><?= $this->getCurrency($value, symbol: '', format: 'short', divide: 1000); ?>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('Profit'); ?> (<?= $this->getHtml('monthly'); ?>) - <?= $this->getHtml('SalesReps'); ?>
</div>
<?php $sales = [1 => $this->data['monthlyRepPY'], 2 => $this->data['monthlyRepCurrent']]; ?>
<div class="portlet-body">
<canvas id="sales-profit-domestic-monthly" data-chart='{
"type": "bar",
"data": {
"labels": [
<?php
$temp = [];
for ($i = 1; $i < 13; ++$i) {
$temp[] = \sprintf('"%02d"', $i);
}
echo \implode(',', $temp);
?>
],
"datasets": [
<?php
$first = true;
foreach ($sales[2] as $type => $values) :
echo($first ? '' : ',');
$first = false;
?>{
"label": "<?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>",
"type": "line",
"data": [
<?php
$temp = [];
for ($i = 1; $i < 13; ++$i) {
if ($i > $this->data['endCurrentIndex']) {
$temp[] = 'null';
continue;
}
if (!isset($sales[2][$type][$i]['net_sales']) || !isset($sales[2][$type][$i]['net_profit'])) {
$temp[] = '0';
continue;
}
$temp[] = $sales[2][$type][$i]['net_profit'] ?? 0;
}
echo \implode(',', $temp);
?>
],
"fill": false,
"tension": 0.0,
"hidden": true
}
<?php endforeach; ?>
]
},
"options": {
"responsive": true
}
}'></canvas>
<div class="more-container">
<input class="more" id="more-domestic-monthly-profit" type="checkbox" name="more-container">
<label class="more" for="more-domestic-monthly-profit">
<span><?= $this->getHtml('Data'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('SalesRep'); ?>
<?php for ($i = 1; $i < 13; ++$i) : ?>
<td><?= $i; ?>
<?php endfor; ?>
<tbody>
<?php
$sum = [];
foreach ($sales[2] as $type => $values) : ?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main?->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main?->name2); ?>
<?php for ($i = 1; $i < 13; ++$i) :
$sum[$i] = ($sum[$i] ?? 0) + ($values[$i]['net_profit'] ?? 0);
?>
<td><?= $this->getCurrency($values[$i]['net_profit'] ?? 0, symbol: '', format: 'short', divide: 1000); ?>
<?php endfor; endforeach; ?>
<tr>
<td><?= $this->getHtml('Total'); ?>
<?php foreach ($sum as $value) : ?>
<td><?= $this->getCurrency($value, symbol: '', format: 'short', divide: 1000); ?>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,113 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\SalesAnalysis
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Localization\ISO3166CharEnum;
use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Stdlib\Base\FloatInt;
/**
* @var \phpOMS\Views\View $this
*/
echo $this->data['nav']->render();
echo $this->data['nav-sub']->render();
?>
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
</div>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td class="wf-100"><?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
<td><?= $this->getHtml('SalesPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
\uasort($this->data['mtdAClientRep'], function (array $a, array $b) { return ($b['net_sales'] ?? 0) <=> ($a['net_sales'] ?? 0); });
$total = ['py' => 0, 'a' => 0];
foreach ($this->data['mtdAClientRep'] as $type => $values) :
$total['py'] += $this->data['mtdPYClientRep'][$type]['net_sales'] ?? 0;
$total['a'] += $this->data['mtdAClientRep'][$type]['net_sales'] ?? 0;
?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main->name2); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYClientRep'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAClientRep'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAClientRep'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['mtdPYClientRep'][$type]['net_sales'] ?? 0)),
symbol: ''
); ?>
<?php endforeach; ?>
<tr class="hl-3">
<td><?= $this->getHtml('Total', '0', '0'); ?>
<td><?= $this->getCurrency((int) $total['py'], symbol: ''); ?>
<td><?= $this->getCurrency((int) $total['a'], symbol: ''); ?>
<td><?= $this->getCurrency(
$total['a'] - $total['py'],
symbol: ''
); ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
</div>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td class="wf-100"><?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
<td><?= $this->getHtml('ProfitPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('ProfitA'); ?> (<?= $this->getHtml('MTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('MTD'); ?>)
<tbody>
<?php
\uasort($this->data['mtdAClientRep'], function (array $a, array $b) { return ($b['net_profit'] ?? 0) <=> ($a['net_profit'] ?? 0); });
$total = ['py' => 0, 'a' => 0];
foreach ($this->data['mtdAClientRep'] as $type => $values) :
$total['py'] += $this->data['mtdPYClientRep'][$type]['net_profit'] ?? 0;
$total['a'] += $this->data['mtdAClientRep'][$type]['net_profit'] ?? 0;
?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main->name2); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdPYClientRep'][$type]['net_profit'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['mtdAClientRep'][$type]['net_profit'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['mtdAClientRep'][$type]['net_profit'] ?? 0)) -
((int) ($this->data['mtdPYClientRep'][$type]['net_profit'] ?? 0)),
symbol: ''
); ?>
<?php endforeach; ?>
<tr class="hl-3">
<td><?= $this->getHtml('Total', '0', '0'); ?>
<td><?= $this->getCurrency((int) $total['py'], symbol: ''); ?>
<td><?= $this->getCurrency((int) $total['a'], symbol: ''); ?>
<td><?= $this->getCurrency(
$total['a'] - $total['py'],
symbol: ''
); ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,113 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\SalesAnalysis
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Localization\ISO3166CharEnum;
use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Stdlib\Base\FloatInt;
/**
* @var \phpOMS\Views\View $this
*/
echo $this->data['nav']->render();
echo $this->data['nav-sub']->render();
?>
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
</div>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td class="wf-100"><?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
<td><?= $this->getHtml('SalesPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('SalesA'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<tbody>
<?php
\uasort($this->data['ytdAClientRep'], function (array $a, array $b) { return (($b['net_sales'] ?? 0) <=> $a['net_sales'] ?? 0); });
$total = ['py' => 0, 'a' => 0];
foreach ($this->data['ytdAClientRep'] as $type => $values) :
$total['py'] += $this->data['ytdPYClientRep'][$type]['net_sales'] ?? 0;
$total['a'] += $this->data['ytdAClientRep'][$type]['net_sales'] ?? 0;
?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main->name2); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYClientRep'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAClientRep'][$type]['net_sales'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAClientRep'][$type]['net_sales'] ?? 0)) -
((int) ($this->data['ytdPYClientRep'][$type]['net_sales'] ?? 0)),
symbol: ''
); ?>
<?php endforeach; ?>
<tr class="hl-3">
<td><?= $this->getHtml('Total', '0', '0'); ?>
<td><?= $this->getCurrency((int) $total['py'], symbol: ''); ?>
<td><?= $this->getCurrency((int) $total['a'], symbol: ''); ?>
<td><?= $this->getCurrency(
$total['a'] - $total['py'],
symbol: ''
); ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
</div>
<div class="slider more">
<table class="default sticky">
<thead>
<tr>
<td class="wf-100"><?= $this->getHtml('SalesRep', 'Sales', 'Backend'); ?>
<td><?= $this->getHtml('ProfitPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('ProfitA'); ?> (<?= $this->getHtml('YTD'); ?>)
<td><?= $this->getHtml('DiffPY'); ?> (<?= $this->getHtml('YTD'); ?>)
<tbody>
<?php
\uasort($this->data['ytdAClientRep'], function (array $a, array $b) { return (($b['net_profit'] ?? 0) <=> $a['net_profit'] ?? 0); });
$total = ['py' => 0, 'a' => 0];
foreach ($this->data['ytdAClientRep'] as $type => $values) :
$total['py'] += $this->data['ytdPYClientRep'][$type]['net_profit'] ?? 0;
$total['a'] += $this->data['ytdAClientRep'][$type]['net_profit'] ?? 0;
?>
<tr>
<td><?= $this->printHtml($this->data['salesRep'][$type]->code); ?> - <?= $this->printHtml($this->data['salesRep'][$type]->main->name1); ?> <?= $this->printHtml($this->data['salesRep'][$type]->main->name2); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdPYClientRep'][$type]['net_profit'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency((int) ($this->data['ytdAClientRep'][$type]['net_profit'] ?? 0), symbol: ''); ?>
<td><?= $this->getCurrency(
((int) ($this->data['ytdAClientRep'][$type]['net_profit'] ?? 0)) -
((int) ($this->data['ytdPYClientRep'][$type]['net_profit'] ?? 0)),
symbol: ''
); ?>
<?php endforeach; ?>
<tr class="hl-3">
<td><?= $this->getHtml('Total', '0', '0'); ?>
<td><?= $this->getCurrency((int) $total['py'], symbol: ''); ?>
<td><?= $this->getCurrency((int) $total['a'], symbol: ''); ?>
<td><?= $this->getCurrency(
$total['a'] - $total['py'],
symbol: ''
); ?>
</table>
</div>
</section>
</div>
</div>

File diff suppressed because it is too large Load Diff