Przeglądaj źródła

dashboard - aggiunto blocco pagato e differenziato uscite pagate/da pagare

ferrari 4 miesięcy temu
rodzic
commit
28ff86b636

+ 15 - 0
app/Http/Livewire/Dashboard.php

@@ -29,6 +29,7 @@ class Dashboard extends Component
 
 
     public $received = 0;
     public $received = 0;
     public $toPay = 0;
     public $toPay = 0;
+    public $paid = 0;
 
 
     public $courses = [];
     public $courses = [];
     public $fields = [];
     public $fields = [];
@@ -199,6 +200,7 @@ class Dashboard extends Component
 
 
         try {
         try {
             $currentMonth = now()->format('Y-m');
             $currentMonth = now()->format('Y-m');
+            $currentDate = now()->format('Y-m-d');
             Log::info('Calculating financial stats for month', ['month' => $currentMonth]);
             Log::info('Calculating financial stats for month', ['month' => $currentMonth]);
 
 
             $this->received = \App\Models\Record::where('type', 'IN')
             $this->received = \App\Models\Record::where('type', 'IN')
@@ -208,8 +210,20 @@ class Dashboard extends Component
                 })
                 })
                 ->sum('amount') ?? 0;
                 ->sum('amount') ?? 0;
 
 
+            $this->paid = \App\Models\Record::where('type', 'OUT')
+                ->whereRaw('DATE_FORMAT(date, "%Y-%m") = ?', [$currentMonth])
+                ->where('data_pagamento', '<=', $currentDate)
+                ->where(function ($query) {
+                    $query->where('deleted', false)->orWhere('deleted', null);
+                })
+                ->sum('amount') ?? 0;
+
             $this->toPay = \App\Models\Record::where('type', 'OUT')
             $this->toPay = \App\Models\Record::where('type', 'OUT')
                 ->whereRaw('DATE_FORMAT(date, "%Y-%m") = ?', [$currentMonth])
                 ->whereRaw('DATE_FORMAT(date, "%Y-%m") = ?', [$currentMonth])
+                ->where(function ($query) use($currentDate) {
+                    $query->where('data_pagamento', '>', $currentDate)
+                        ->orWhereNull('data_pagamento');
+                })
                 ->where(function ($query) {
                 ->where(function ($query) {
                     $query->where('deleted', false)->orWhere('deleted', null);
                     $query->where('deleted', false)->orWhere('deleted', null);
                 })
                 })
@@ -218,6 +232,7 @@ class Dashboard extends Component
             $endTime = microtime(true);
             $endTime = microtime(true);
             Log::info('Financial stats loaded successfully', [
             Log::info('Financial stats loaded successfully', [
                 'received' => $this->received,
                 'received' => $this->received,
+                'paid' => $this->paid,
                 'to_pay' => $this->toPay,
                 'to_pay' => $this->toPay,
                 'execution_time_ms' => round(($endTime - $startTime) * 1000, 2)
                 'execution_time_ms' => round(($endTime - $startTime) * 1000, 2)
             ]);
             ]);

+ 4 - 4
public/css/new_style.css

@@ -474,9 +474,9 @@ body .dashboard-container .card-income .dashboard-card-value {
     color: var(--color-verde);
     color: var(--color-verde);
 }
 }
 
 
-body .dashboard-container .card-receive .dashboard-card-icon,
-body .dashboard-container .card-receive .dashboard-card-value {
-    color: var(--color-arancione);
+body .dashboard-container .card-topay .dashboard-card-icon,
+body .dashboard-container .card-topay .dashboard-card-value {
+    color: var(--color-viola);
 }
 }
 
 
 body .dashboard-container .card-expense .dashboard-card-icon,
 body .dashboard-container .card-expense .dashboard-card-icon,
@@ -490,7 +490,7 @@ body .dashboard-container .card-delta .dashboard-card-value {
 }
 }
 
 
 body .dashboard-container .card-income .dashboard-card-value,
 body .dashboard-container .card-income .dashboard-card-value,
-body .dashboard-container .card-receive .dashboard-card-value,
+body .dashboard-container .card-topay .dashboard-card-value,
 body .dashboard-container .card-expense .dashboard-card-value,
 body .dashboard-container .card-expense .dashboard-card-value,
 body .dashboard-container .card-delta .dashboard-card-value {
 body .dashboard-container .card-delta .dashboard-card-value {
     font-size: 30px;
     font-size: 30px;

+ 9 - 1
resources/views/livewire/dashboard.blade.php

@@ -233,7 +233,7 @@
                 <div class="dashboard-card-value">{{number_format($toPay, 2, ",", ".")}}</div>
                 <div class="dashboard-card-value">{{number_format($toPay, 2, ",", ".")}}</div>
             </div> --}}
             </div> --}}
 
 
-            <div class="dashboard-card dashboard-stat card-inverted card-expense">
+            <div class="dashboard-card dashboard-stat card-inverted card-topay">
                 <div class="dashboard-card-header">
                 <div class="dashboard-card-header">
                     <div class="dashboard-card-title">Da pagare<br/><small><small><i>{{$current_month}}</i></small></small></div>
                     <div class="dashboard-card-title">Da pagare<br/><small><small><i>{{$current_month}}</i></small></small></div>
                     <i class="dashboard-card-icon fa-solid fa-money-bill-transfer"></i>
                     <i class="dashboard-card-icon fa-solid fa-money-bill-transfer"></i>
@@ -241,6 +241,14 @@
                 <div class="dashboard-card-value">{{number_format($toPay, 2, ",", ".")}}</div>
                 <div class="dashboard-card-value">{{number_format($toPay, 2, ",", ".")}}</div>
             </div>
             </div>
 
 
+            <div class="dashboard-card dashboard-stat card-inverted card-expense">
+                <div class="dashboard-card-header">
+                    <div class="dashboard-card-title">Pagato<br/><small><small><i>{{$current_month}}</i></small></small></div>
+                    <i class="dashboard-card-icon fa-solid fa-money-bill-transfer"></i>
+                </div>
+                <div class="dashboard-card-value">{{number_format($paid, 2, ",", ".")}}</div>
+            </div>
+
             <div class="dashboard-card grid-w-3">
             <div class="dashboard-card grid-w-3">
                 <div class="dashboard-card-title">Ultimi movimenti finanziari</div>
                 <div class="dashboard-card-title">Ultimi movimenti finanziari</div>
                 @if(count($recentTransactions) > 0)
                 @if(count($recentTransactions) > 0)