diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php new file mode 100644 index 00000000..abc55895 --- /dev/null +++ b/app/Http/Controllers/Reports/MonthlyReportController.php @@ -0,0 +1,62 @@ +whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get(); + + $total = 0; + $customers = collect(); + + foreach ($containers as $container){ + foreach($container->packingLists as $packingList){ + $cbm = $packingList->packages->sum(function ($package){ + return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; + }); + + $total += $cbm; + $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; + if(!$customers->has($marking)){ + $customers->put($marking, collect([ + 'cbm' => $cbm, + 'orders' => 1, + 'packages' => $packingList->packages->sum('quantity') + ])); + + continue; + } + + $customers[$marking]['cbm'] += $cbm; + $customers[$marking]['orders'] += 1; + $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); + } + } + + $activeOrders = $customers->sum(function($customer){ + return $customer['orders']; + }); + return (new ApiResponseObject('fetch monthly report Successful', + '', + HttpStatus::OK_WITH_MESSAGE, ['data' => [ + 'containers' => count($containers), + 'activated_orders' => $activeOrders, + 'active_customers' => count($customers), + 'total_cbm' => $customers->sum(function($customer){ + return $customer['cbm']; + }), + 'packages' => $customers->sum(function($customer){ + return $customer['packages']; + }), + 'total_orders' => Order::whereMonth('created_at', 9)->whereHas('packingLists')->count() + ]]))->handler(); + } +} diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue new file mode 100644 index 00000000..d40eea3d --- /dev/null +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -0,0 +1,168 @@ + + \ No newline at end of file diff --git a/resources/views/pages/admin/customers.blade.php b/resources/views/pages/admin/customers.blade.php new file mode 100644 index 00000000..048b81c6 --- /dev/null +++ b/resources/views/pages/admin/customers.blade.php @@ -0,0 +1,25 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+
+
+
+
+
Customers List
+
+
+
+
+ + + +
+
+
+
+
+
+@endsection diff --git a/resources/views/pages/admin/dashboard.blade.php b/resources/views/pages/admin/dashboard.blade.php index 0fe49ba7..f5b7df56 100644 --- a/resources/views/pages/admin/dashboard.blade.php +++ b/resources/views/pages/admin/dashboard.blade.php @@ -1,47 +1,42 @@
-
-
-
-
Customers List
-
-
-
+
+
- - - +
-
-
-
-
-
Identification Verification
+
+
+
+
+
Identification Verification
+
+
+
+
+ + + +
+
-
-
-
- - - -
-
-
-
-
Address Change Verification
-
-
-
-
- - - +
+
+
+
Address Change Verification
+
+
+
+
+ + + +
+
diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 0d7693a5..c32eb3df 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -30,6 +30,17 @@
Dashboard
+
+
+ +
+
+
Customers
+
+
'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/schedule.php'; + Route::get('/report', 'Reports\MonthlyReportController@report')->name('report'); + }); }); diff --git a/routes/web.php b/routes/web.php index c0023a55..5e4cba15 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,6 +7,7 @@ use App\Classes\Jobs\FetchPackingListFromVTPortalJob; use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob; use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal; use App\Models\CompanyConnection; +use App\Models\Order; use Illuminate\Support\Facades\Crypt; use App\Models\Container; use Illuminate\Support\Facades\Route; @@ -53,6 +54,10 @@ Route::get('/dashboard', function () { return view('pages.dashboard'); })->name('dashboard'); +Route::get('/customers', function () { + return view('pages.admin.customers'); +})->name('customers'); + Route::get('/orders', function () { return view('pages.orders.index'); })->name('orders'); @@ -178,3 +183,4 @@ Route::get('/report', function(){ }); +