From ac1353c5a103dbf1fa0b88dd1d76fe06686a2ffb Mon Sep 17 00:00:00 2001 From: Kawlll Maxso Date: Tue, 19 Mar 2019 18:45:39 +0800 Subject: [PATCH] Dashboard report --- .../Dashboard/CbmReportLogic.php | 41 ++++++ .../Dashboard/CustomerReportLogic.php | 39 ++++++ .../Dashboard/OrdersReportLogic.php | 43 +++++++ .../Dashboard/OrdersStatusReportLogic.php | 39 ++++++ .../Dashboard/CbmReportController.php | 13 ++ .../Dashboard/CustomerReportController.php | 18 +++ .../Dashboard/OrdersReportController.php | 13 ++ .../OrdersStatusReportController.php | 12 ++ resources/assets/vue/app.js | 5 + .../elements/CbmVsOrdersChartComponent.vue | 117 ++++++++++++++++++ .../elements/CustomerChartComponent.vue | 80 ++++++++++++ .../elements/OrderStatusChartComponent.vue | 82 ++++++++++++ resources/views/pages/dashboard.blade.php | 69 ++++++----- routes/api.php | 7 +- 14 files changed, 546 insertions(+), 32 deletions(-) create mode 100644 app/Classes/Modules/ControllersLogic/Dashboard/CbmReportLogic.php create mode 100644 app/Classes/Modules/ControllersLogic/Dashboard/CustomerReportLogic.php create mode 100644 app/Classes/Modules/ControllersLogic/Dashboard/OrdersReportLogic.php create mode 100644 app/Classes/Modules/ControllersLogic/Dashboard/OrdersStatusReportLogic.php create mode 100644 app/Http/Controllers/Dashboard/CbmReportController.php create mode 100644 app/Http/Controllers/Dashboard/CustomerReportController.php create mode 100644 app/Http/Controllers/Dashboard/OrdersReportController.php create mode 100644 app/Http/Controllers/Dashboard/OrdersStatusReportController.php create mode 100644 resources/assets/vue/components/dashboard/elements/CbmVsOrdersChartComponent.vue create mode 100644 resources/assets/vue/components/dashboard/elements/CustomerChartComponent.vue create mode 100644 resources/assets/vue/components/dashboard/elements/OrderStatusChartComponent.vue diff --git a/app/Classes/Modules/ControllersLogic/Dashboard/CbmReportLogic.php b/app/Classes/Modules/ControllersLogic/Dashboard/CbmReportLogic.php new file mode 100644 index 0000000..2b890a5 --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/Dashboard/CbmReportLogic.php @@ -0,0 +1,41 @@ +repository = $repository; + } + + public function execute() { + + $cbm = $this->repository->selectRaw('created_at, ((((width/100) * (length/100) * (height/100))) * quantity) as cbm')->whereYear('created_at', '=', Carbon::now()->year)->whereMonth('created_at', '=', Carbon::now()->month)->orderBy('created_at')->get(); + + $cbmGroup = $cbm->groupBy(function ($item) { + return Carbon::parse($item->created_at)->format('j'); + }); + + $cbmMap = $cbmGroup->map(function ($item){ + return collect($item)->sum("cbm"); + })->toArray(); + + $report = []; + for($x = 1; $x <= Carbon::now()->daysInMonth; $x++){ + $report[] = isset($cbmMap[$x]) ? $cbmMap[$x] : 0; + } + + return $report; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/ControllersLogic/Dashboard/CustomerReportLogic.php b/app/Classes/Modules/ControllersLogic/Dashboard/CustomerReportLogic.php new file mode 100644 index 0000000..ea9d3ca --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/Dashboard/CustomerReportLogic.php @@ -0,0 +1,39 @@ +orderRepository = $orderRepository; + $this->companiesRepository = $companiesRepository; + } + + + public function execute() { + $active = $this->orderRepository->whereYear('created_at', '=', Carbon::now()->year)->whereMonth('created_at', '=', Carbon::now()->month)->orderBy('company_id')->get()->groupBy('company_id'); + $company = $this->companiesRepository->count(); + + if ($company > $active->count()) $company -= $active->count(); + else $company = $active->count() - $company; + + return [$active->count(), $company]; + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/ControllersLogic/Dashboard/OrdersReportLogic.php b/app/Classes/Modules/ControllersLogic/Dashboard/OrdersReportLogic.php new file mode 100644 index 0000000..8f1c128 --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/Dashboard/OrdersReportLogic.php @@ -0,0 +1,43 @@ +repository = $repository; + } + + public function execute() { + + $Orders= $this->repository->whereYear('created_at', '=', Carbon::now()->year) + ->whereMonth('created_at', '=', Carbon::now()->month)->orderBy('created_at')->get(); + + $group = $Orders->groupBy(function($item) { + return Carbon::parse($item->created_at)->format('j'); + }); + + $groupCount = $group->map(function ($item) { + return collect($item)->count(); + })->toArray(); + + $report = []; + for($x = 1; $x <= Carbon::now()->daysInMonth; $x++) { + $report[] = isset($groupCount[$x]) ? $groupCount[$x] : 0; + + } + return $report; + } +} + diff --git a/app/Classes/Modules/ControllersLogic/Dashboard/OrdersStatusReportLogic.php b/app/Classes/Modules/ControllersLogic/Dashboard/OrdersStatusReportLogic.php new file mode 100644 index 0000000..8a28a93 --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/Dashboard/OrdersStatusReportLogic.php @@ -0,0 +1,39 @@ +repository = $repository; + } + + public function execute() { + $status = $this->repository->whereNotNull('current_step')->get()->groupBy('current_step'); + $completed = $this->repository->whereNull('current_step')->where('complete', '=' , 1)->get(); + + $statusMap = $status->map(function ($item) { + return collect($item)->count(); + })->toArray(); + + $completedArray = ["COMPLETED" => $completed->count()]; + $combine = $statusMap + $completedArray; + + return [ + $combine['PS_PROCESSING'], + $combine['MS_WAREHOUSE_RECEIVING'], + $combine['PS_SHIPPING'], + $completedArray['COMPLETED'] + ]; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Dashboard/CbmReportController.php b/app/Http/Controllers/Dashboard/CbmReportController.php new file mode 100644 index 0000000..804a22a --- /dev/null +++ b/app/Http/Controllers/Dashboard/CbmReportController.php @@ -0,0 +1,13 @@ +execute(); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Dashboard/CustomerReportController.php b/app/Http/Controllers/Dashboard/CustomerReportController.php new file mode 100644 index 0000000..62844a9 --- /dev/null +++ b/app/Http/Controllers/Dashboard/CustomerReportController.php @@ -0,0 +1,18 @@ +execute(); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Dashboard/OrdersReportController.php b/app/Http/Controllers/Dashboard/OrdersReportController.php new file mode 100644 index 0000000..0c06a30 --- /dev/null +++ b/app/Http/Controllers/Dashboard/OrdersReportController.php @@ -0,0 +1,13 @@ +execute(); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Dashboard/OrdersStatusReportController.php b/app/Http/Controllers/Dashboard/OrdersStatusReportController.php new file mode 100644 index 0000000..6b98efb --- /dev/null +++ b/app/Http/Controllers/Dashboard/OrdersStatusReportController.php @@ -0,0 +1,12 @@ +execute(); + } +} \ No newline at end of file diff --git a/resources/assets/vue/app.js b/resources/assets/vue/app.js index ad30f62..0a37f2f 100644 --- a/resources/assets/vue/app.js +++ b/resources/assets/vue/app.js @@ -88,6 +88,11 @@ Vue.component('notification-component', require('./components/common/Notificatio Vue.component('company-error-notification-component', require('./components/company/notifications/CompanyErrorComponent.vue')); +Vue.component('cbm-order-chart-component', require('./components/dashboard/elements/CbmVsOrdersChartComponent.vue')); +Vue.component('customer-chart-component', require('./components/dashboard/elements/CustomerChartComponent.vue')); +Vue.component('order-status-chart-component', require('./components/dashboard/elements/OrderStatusChartComponent.vue')); + + window.Event = new Vue(); const header = new Vue({ diff --git a/resources/assets/vue/components/dashboard/elements/CbmVsOrdersChartComponent.vue b/resources/assets/vue/components/dashboard/elements/CbmVsOrdersChartComponent.vue new file mode 100644 index 0000000..7d327a9 --- /dev/null +++ b/resources/assets/vue/components/dashboard/elements/CbmVsOrdersChartComponent.vue @@ -0,0 +1,117 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/dashboard/elements/CustomerChartComponent.vue b/resources/assets/vue/components/dashboard/elements/CustomerChartComponent.vue new file mode 100644 index 0000000..4963886 --- /dev/null +++ b/resources/assets/vue/components/dashboard/elements/CustomerChartComponent.vue @@ -0,0 +1,80 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/dashboard/elements/OrderStatusChartComponent.vue b/resources/assets/vue/components/dashboard/elements/OrderStatusChartComponent.vue new file mode 100644 index 0000000..fc5c56f --- /dev/null +++ b/resources/assets/vue/components/dashboard/elements/OrderStatusChartComponent.vue @@ -0,0 +1,82 @@ + + \ No newline at end of file diff --git a/resources/views/pages/dashboard.blade.php b/resources/views/pages/dashboard.blade.php index c4f7f33..69c8f3f 100644 --- a/resources/views/pages/dashboard.blade.php +++ b/resources/views/pages/dashboard.blade.php @@ -1,40 +1,47 @@ @extends('layouts.base_portal') @section('inner_content') -
-
-
-
-

Welcome {{auth()->user()->first_name}}

-
-
-
-
-
-
-
-
- Getting Started -
-
-
-
-
-
-
-
- Manage Importers -
-
-
-
-
-
-
+
+
+
+
+

Welcome {{auth()->user()->first_name}}

+
+ +
+ + +
+
+ {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--Getting Started--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--Manage Importers--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}} + {{--
--}}
-
@endsection diff --git a/routes/api.php b/routes/api.php index d14e8e3..a438486 100644 --- a/routes/api.php +++ b/routes/api.php @@ -133,7 +133,12 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function }); - + Route::group(['prefix' => 'report', 'as' => 'report.', 'namespace' => 'Dashboard'], function () { + Route::get('/order', 'OrdersReportController@index')->name('order'); + Route::get('/cbm', 'CbmReportController@index')->name('cbm'); + Route::get('/customer', 'ActiveCustomerReportController@index')->name('customer'); + Route::get('/order/status', 'OrdersStatusReportController@index')->name('order.status'); + });