Skip to content

Commit 0fb61d9

Browse files
committed
1 parent 23b5579 commit 0fb61d9

File tree

6 files changed

+89
-23
lines changed

6 files changed

+89
-23
lines changed

app/Http/Controllers/Workflow/OrdersController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function index()
5353
$remainingDeliveryOrder = $this->orderKPIService->getOrderMonthlyRemainingToDelivery(now()->month, $CurentYear);
5454
$remainingInvoiceOrder = $this->orderKPIService->getOrderMonthlyRemainingToInvoice();
5555
$serviceRate = $this->orderKPIService->getServiceRate();
56+
$topCustomers = $this->orderKPIService->getTopCustomersByOrderVolume(3);
57+
$averageProcessingTime = $this->orderKPIService->getAverageOrderProcessingTime();
5658
$data['ordersDataRate']= $this->orderKPIService->getOrdersDataRate();
5759
$data['orderMonthlyRecap'] = $this->orderKPIService->getOrderMonthlyRecap($CurentYear);
5860
$data['orderMonthlyRecapPreviousYear'] = $this->orderKPIService->getOrderMonthlyRecapPreviousYear($CurentYear);
@@ -65,6 +67,8 @@ public function index()
6567
'remainingDeliveryOrder',
6668
'remainingInvoiceOrder',
6769
'serviceRate',
70+
'topCustomers',
71+
'averageProcessingTime',
6872
'data',
6973
));
7074
}

app/Services/OrderKPIService.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Models\Workflow\Deliverys;
88
use Illuminate\Support\Facades\DB;
99
use App\Models\Workflow\OrderLines;
10+
use App\Models\Workflow\DeliveryLines;
1011

1112
class OrderKPIService
1213
{
@@ -229,24 +230,23 @@ public function getOrderCompletionRate()
229230
*/
230231
public function getAverageOrderProcessingTime()
231232
{
232-
$orders = Orders::whereYear('created_at', now()->year)
233-
->whereHas('orderLines', function($query) {
234-
$query->whereColumn('delivered_qty', '>=', 'qty');
235-
})->get();
233+
$orderLines = OrderLines::whereYear('created_at', now()->year)
234+
->where('delivery_status', 3)
235+
->get();
236236

237-
if ($orders->isEmpty()) {
237+
if ($orderLines->isEmpty()) {
238238
return 0;
239239
}
240240

241-
$totalDays = $orders->map(function($order) {
242-
$lastDeliveryDate = Deliverys::where('order_id', $order->id)
241+
$totalDays = $orderLines->map(function($orderLines) {
242+
$lastDeliveryDate = DeliveryLines::where('order_line_id', $orderLines->id)
243243
->latest('created_at')
244244
->value('created_at');
245245

246-
return $lastDeliveryDate ? $lastDeliveryDate->diffInDays($order->created_at) : 0;
246+
return $lastDeliveryDate ? $lastDeliveryDate->diffInDays($orderLines->created_at) : 0;
247247
})->sum();
248248

249-
return $totalDays / $orders->count();
249+
return round($totalDays / $orderLines->count());
250250
}
251251

252252
/**

public/css/custom.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,28 @@
108108

109109
.arrow-steps .step.done:after {
110110
border-left: 17px solid #0e9124;
111+
}
112+
113+
/** PODIUM **/
114+
115+
.podium {
116+
display: flex;
117+
justify-content: center;
118+
margin-top: 50px;
119+
}
120+
.podium-place {
121+
margin: 0 20px;
122+
padding: 20px;
123+
border: 2px solid #ddd;
124+
border-radius: 10px;
125+
width: 150px;
126+
}
127+
.place-1 {
128+
background-color: gold;
129+
}
130+
.place-2 {
131+
background-color: silver;
132+
}
133+
.place-3 {
134+
background-color: bronze;
111135
}

resources/lang/en/general_content.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@
596596
'remaining_month_trans_key' => 'Total remaining to deliver',
597597
'remaining_invoice_month_trans_key' => 'Total remaining to invoice',
598598
'service_rate_trans_key' => 'Service rate',
599+
'average_order_processing_time_trans_key' => 'Average order processing time',
599600
'niko_niko_team_trans_key' => 'Niko Niko - Team Moods Today',
600601
'no_niko_niko_team_trans_key' => 'No team mood today',
601602

resources/lang/fr/general_content.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@
596596
'remaining_month_trans_key' => 'Total restant à livrer',
597597
'remaining_invoice_month_trans_key' => 'Total restant à facturer',
598598
'service_rate_trans_key' => 'Taux de service',
599+
'average_order_processing_time_trans_key' => 'Temps moyen de traitement',
599600
'niko_niko_team_trans_key' => 'Niko Niko - Humeur de l\'équipe aujourd\'hui',
600601
'no_niko_niko_team_trans_key' => 'Aucune humeur aujourd\'hui',
601602

resources/views/workflow/orders-index.blade.php

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@section('title', __('general_content.orders_list_trans_key'))
44

55
@section('content_header')
6+
<link rel="stylesheet" href="{{ asset('css/custom.css') }}">
67
<h1>{{ __('general_content.orders_list_trans_key') }}</h1>
78
@stop
89

@@ -27,27 +28,47 @@
2728
<x-adminlte-small-box title="{{ $invoicedOrdersPercentage }} %" text="{{ __('general_content.order_invoiced_trans_key') }}" icon="fas fa-file-invoice-dollar" theme="info"/>
2829
</div>
2930
<div class="col-lg-4">
30-
<x-adminlte-small-box title="{{ $pendingDeliveries }}" text="{{ __('general_content.order_waiting_trans_key') }}" icon="fas fa-hourglass-half" theme="warning"/>
31+
<x-adminlte-small-box
32+
title="{{ $serviceRate }}%"
33+
text="{{ __('general_content.service_rate_trans_key') }}"
34+
icon="fas fa-chart-line"
35+
theme="primary"
36+
/>
3137
</div>
3238
</div>
3339

3440
<div class="row">
3541
<div class="col-lg-4 col-4">
3642
<x-adminlte-small-box title="{{ number_format($remainingDeliveryOrder->orderSum ?? 0 -$remainingDeliveryOrder->orderSum ?? 0 ,2)}} {{ $Factory->curency }}"
37-
text="{{ __('general_content.remaining_month_trans_key') }}"
38-
icon="icon fas fa-info"
39-
theme="danger" />
40-
<x-adminlte-small-box title="{{ number_format($remainingInvoiceOrder->orderSum ?? 0)}} {{ $Factory->curency }}"
41-
text="{{ __('general_content.remaining_invoice_month_trans_key') }}"
42-
icon="icon fas fa-info"
43-
theme="warning" />
44-
<x-adminlte-small-box title="{{ $lateOrdersCount }}" text="{{ __('general_content.late_orders_trans_key') }}" icon="fas fa-exclamation-triangle" theme="orange"/>
43+
text="{{ __('general_content.remaining_month_trans_key') }}"
44+
icon="icon fas fa-info"
45+
theme="danger" />
46+
4547
<x-adminlte-small-box
46-
title="{{ $serviceRate }}%"
47-
text="{{ __('general_content.service_rate_trans_key') }}"
48-
icon="fas fa-chart-line"
49-
theme="primary"
50-
/>
48+
title="{{ $averageProcessingTime }} {{ __('general_content.day_trans_key') }}"
49+
text="{{ __('general_content.average_order_processing_time_trans_key') }}"
50+
icon="icon fas fa-clock"
51+
theme="info" />
52+
53+
<div class="podium">
54+
@foreach ($topCustomers as $index => $customer)
55+
<div class="podium-place place-{{ $index + 1 }}">
56+
<h3 class="text-center">
57+
@if ($index == 0)
58+
🥇
59+
@elseif ($index == 1)
60+
🥈
61+
@elseif ($index == 2)
62+
🥉
63+
@endif
64+
</h3>
65+
<div class="customer-details text-center">
66+
<strong>{{ $customer->companie->label }}</strong>
67+
<p>{{ __('general_content.orders_trans_key') }}: {{ $customer->order_count }}</p>
68+
</div>
69+
</div>
70+
@endforeach
71+
</div>
5172
</div>
5273
<div class="col-lg-8 col-8">
5374
<!-- CHART: TOTAL OVERVIEW -->
@@ -72,6 +93,21 @@
7293
</div>
7394
</div>
7495

96+
<div class="row">
97+
<div class="col-lg-4">
98+
<x-adminlte-small-box title="{{ number_format($remainingInvoiceOrder->orderSum ?? 0)}} {{ $Factory->curency }}"
99+
text="{{ __('general_content.remaining_invoice_month_trans_key') }}"
100+
icon="icon fas fa-info"
101+
theme="warning" />
102+
</div>
103+
<div class="col-lg-4">
104+
<x-adminlte-small-box title="{{ $lateOrdersCount }}" text="{{ __('general_content.late_orders_trans_key') }}" icon="fas fa-exclamation-triangle" theme="orange"/>
105+
</div>
106+
<div class="col-lg-4">
107+
<x-adminlte-small-box title="{{ $pendingDeliveries }}" text="{{ __('general_content.order_waiting_trans_key') }}" icon="fas fa-hourglass-half" theme="warning"/>
108+
</div>
109+
</div>
110+
75111
</div>
76112
<div class="tab-pane" id="List">
77113
@livewire('orders-index')

0 commit comments

Comments
 (0)