mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-22 05:54:08 +00:00
customer report
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
@@ -66,6 +67,41 @@ class MonthlyReportController
|
||||
]]))->handler();
|
||||
}
|
||||
|
||||
public function customerReport(Request $request): JsonResponse {
|
||||
|
||||
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
|
||||
$id = $connection->invitee->id;
|
||||
|
||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::parse('01-01-2018');
|
||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now();
|
||||
|
||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
|
||||
$packages = $containers->flatMap(function ($container) {
|
||||
return $container->packages;
|
||||
});
|
||||
|
||||
$packages = $packages->filter(function($package){
|
||||
return $package->companyModule->id === $id;
|
||||
});
|
||||
|
||||
$orders = $packages->unique(function ($package) {
|
||||
return $package->order;
|
||||
});
|
||||
|
||||
$totalCbm = $packages->sum(function($package){
|
||||
return $package->companyModule->id === 108 ? (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity : 0;
|
||||
});
|
||||
|
||||
return (new ApiResponseObject('fetch monthly report Successful',
|
||||
'',
|
||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
||||
'activated_orders' => count($orders),
|
||||
'total_cbm' => $totalCbm,
|
||||
'packages' => $packages->sum('quantity'),
|
||||
]]))->handler();
|
||||
}
|
||||
|
||||
public function serviceReport(Request $request): JsonResponse {
|
||||
|
||||
return (new ApiResponseObject('fetch service report Successful',
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div class="row" >
|
||||
<div class="col">
|
||||
<loading-component v-if="isLoading"></loading-component>
|
||||
<div class="row" v-if="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-15">
|
||||
<div class="col-8 p-r-0">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Customer Marking</label>
|
||||
<input type="text" class="form-control" v-model="marking" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Start Date</label>
|
||||
<date-picker-component v-model="from"></date-picker-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">End Date</label>
|
||||
<date-picker-component v-model="to"></date-picker-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<div class="btn btn-primary b-rad-none" @click="fetchReport()">
|
||||
<i class="fa fa-refresh lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="report">
|
||||
<div class="col">
|
||||
<div class="card no-border bg-master-lightest widget-loader-bar m-b-10">
|
||||
<div class="container-xs-height full-height">
|
||||
<div class="row-xs-height">
|
||||
<div class="col-xs-height col-top">
|
||||
<div class="card-header top-left top-right">
|
||||
<div class="card-title">
|
||||
<span class="font-montserrat fs-11 all-caps">Total CBM</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-xs-height">
|
||||
<div class="col-xs-height col-top">
|
||||
<div class="p-l-20 p-t-50 p-b-40 p-r-20">
|
||||
<h3 class="no-margin p-b-5">{{(Math.ceil(report.total_cbm * 1000) / 1000).toFixed(3)}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card no-border bg-master-lightest widget-loader-bar m-b-10">
|
||||
<div class="container-xs-height full-height">
|
||||
<div class="row-xs-height">
|
||||
<div class="col-xs-height col-top">
|
||||
<div class="card-header top-left top-right">
|
||||
<div class="card-title">
|
||||
<span class="font-montserrat fs-11 all-caps">Total Orders</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-xs-height">
|
||||
<div class="col-xs-height col-top">
|
||||
<div class="p-l-20 p-t-50 p-b-40 p-r-20">
|
||||
<h3 class="no-margin p-b-5">{{report.activated_orders}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card no-border bg-master-lightest widget-loader-bar m-b-10">
|
||||
<div class="container-xs-height full-height">
|
||||
<div class="row-xs-height">
|
||||
<div class="col-xs-height col-top">
|
||||
<div class="card-header top-left top-right">
|
||||
<div class="card-title">
|
||||
<span class="font-montserrat fs-11 all-caps">Total Package</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-xs-height">
|
||||
<div class="col-xs-height col-top">
|
||||
<div class="p-l-20 p-t-50 p-b-40 p-r-20">
|
||||
<h3 class="no-margin p-b-5">{{report.packages}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import LoadingComponent from "../../general/elements/LoadingComponent";
|
||||
export default {
|
||||
components: {LoadingComponent},
|
||||
data(){
|
||||
return {
|
||||
section: 'customerReportSection',
|
||||
isLoading: false,
|
||||
report: null,
|
||||
marking: null,
|
||||
from: null,
|
||||
to: null,
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
marking: {},
|
||||
from: {},
|
||||
to: {},
|
||||
},
|
||||
methods: {
|
||||
fetchReport(){
|
||||
this.isLoading = true;
|
||||
this.submit(route('api.report.customer', this.marking, this.from, this.to), 'get', this.section, false, false)
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.report = response.payload.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -2,6 +2,7 @@
|
||||
@section('inner_content')
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<customer-report-section-component></customer-report-section-component>
|
||||
<div class="row d-none" :class="[{'d-flex': $store.getters.isAdmin}]" v-if="$store.getters.isAdmin">
|
||||
<div class="col-6">
|
||||
<div class="row p-b-5 b-b b-grey m-b-10 m-l-0 m-r-0">
|
||||
|
||||
@@ -50,6 +50,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
require __DIR__ . '/schedule.php';
|
||||
|
||||
Route::get('/report/customer/{marking}/{from?}/{to?}', 'Reports\MonthlyReportController@customerReport')->name('report.customer');
|
||||
Route::get('/report/sales/{from?}/{to?}', 'Reports\MonthlyReportController@salesReport')->name('report.sales');
|
||||
Route::get('/report/service', 'Reports\MonthlyReportController@serviceReport')->name('report.service');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user