Просмотр исходного кода

prima nota - aggiunti filtri + fix grafici

ferrari 1 месяц назад
Родитель
Сommit
e19b8ad750

+ 58 - 0
app/Http/Livewire/Record.php

@@ -21,6 +21,8 @@ class Record extends Component
     public $in;
     public $out;
     public $payments = [];
+    public $origins = [];
+    public $destinations = [];
     public $fromDate;
     public $toDate;
     public $appliedFromDate;
@@ -31,6 +33,8 @@ class Record extends Component
     public $selectedPeriod = 'OGGI';
     public $filterCausals = null;
     public $filterPaymentMethods = null;
+    public $filterOrigins = null;
+    public $filterDestinations = null;
     public $filterMember = null;
     public $isFiltering = false;
     public array $recordDatas = [];
@@ -91,6 +95,8 @@ class Record extends Component
             })->orderBy('last_name')->orderBy('first_name')->get();
 
         $this->payments = \App\Models\PaymentMethod::select('id', 'name', 'type')->where('enabled', true)->where('money', false)->get();
+        $this->origins = \App\Models\Bank::select('id', 'name')->where('enabled', true)->where('visibility', 'OUT')->get();
+        $this->destinations = \App\Models\Bank::select('id', 'name')->where('enabled', true)->where('visibility', 'IN')->get();
 
         $this->selectedMonth = date('Y-m');
         $this->selectedDay = date('Y-m-d');
@@ -168,6 +174,16 @@ class Record extends Component
             Log::info('generateExportDataAndTotals: Payment method filters applied', ['payment_method_count' => count($this->filterPaymentMethods)]);
         }
 
+        if ($this->filterOrigins != null && sizeof($this->filterOrigins) > 0) {
+            $datas->whereIn('origin_id', $this->filterOrigins);
+            Log::info('generateExportDataAndTotals: Origin filters applied', ['origins_count' => count($this->filterOrigins)]);
+        }
+
+        if ($this->filterDestinations != null && sizeof($this->filterDestinations) > 0) {
+            $datas->whereIn('destination_id', $this->filterDestinations);
+            Log::info('generateExportDataAndTotals: Destination filters applied', ['destinations_count' => count($this->filterDestinations)]);
+        }
+
         if ($this->filterMember != null && $this->filterMember > 0) {
             $datas->where('member_id', $this->filterMember);
             Log::info('generateExportDataAndTotals: Member filter applied', ['member_id' => $this->filterMember]);
@@ -395,6 +411,12 @@ class Record extends Component
         if ($this->filterPaymentMethods != null && sizeof($this->filterPaymentMethods) > 0) {
             $datas->whereIn('payment_method_id', $this->filterPaymentMethods);
         }
+        if ($this->filterOrigins != null && sizeof($this->filterOrigins) > 0) {
+            $datas->whereIn('origin_id', $this->filterOrigins);
+        }
+        if ($this->filterDestinations != null && sizeof($this->filterDestinations) > 0) {
+            $datas->whereIn('destination_id', $this->filterDestinations);
+        }
         if ($this->filterMember != null && $this->filterMember > 0) {
             $datas->where('member_id', $this->filterMember);
         }
@@ -437,6 +459,8 @@ class Record extends Component
         $this->showDayPicker = false;
         $this->filterCausals = [];
         $this->filterPaymentMethods = [];
+        $this->filterOrigins = [];
+        $this->filterDestinations = [];
         $this->filterMember = null;
 
         $today = date("Y-m-d");
@@ -638,6 +662,12 @@ class Record extends Component
         if ($this->filterPaymentMethods != null && sizeof($this->filterPaymentMethods) > 0) {
             $datas->whereIn('payment_method_id', $this->filterPaymentMethods);
         }
+        if ($this->filterOrigins != null && sizeof($this->filterOrigins) > 0) {
+            $datas->whereIn('origin_id', $this->filterOrigins);
+        }
+        if ($this->filterDestinations != null && sizeof($this->filterDestinations) > 0) {
+            $datas->whereIn('destination_id', $this->filterDestinations);
+        }
         if ($this->filterMember != null && $this->filterMember > 0) {
             $datas->where('member_id', $this->filterMember);
         }
@@ -1079,6 +1109,12 @@ class Record extends Component
         if ($this->filterPaymentMethods != null && sizeof($this->filterPaymentMethods) > 0) {
             $query->whereIn('payment_method_id', $this->filterPaymentMethods);
         }
+        if ($this->filterOrigins != null && sizeof($this->filterOrigins) > 0) {
+            $query->whereIn('origin_id', $this->filterOrigins);
+        }
+        if ($this->filterDestinations != null && sizeof($this->filterDestinations) > 0) {
+            $query->whereIn('destination_id', $this->filterDestinations);
+        }
 
         if ($this->filterMember != null && $this->filterMember > 0) {
             $query->where('member_id', $this->filterMember);
@@ -1113,6 +1149,26 @@ class Record extends Component
         return implode(', ', $payment_methods);
     }
 
+    private function getOriginsNames($originIds)
+    {
+        if (!is_array($originIds)) {
+            return null;
+        }
+
+        $origins = \App\Models\Bank::whereIn('id', $originIds)->pluck('name')->toArray();
+        return implode(', ', $origins);
+    }
+
+    private function getDestinationsNames($destinationIds)
+    {
+        if (!is_array($destinationIds)) {
+            return null;
+        }
+
+        $destinations = \App\Models\Bank::whereIn('id', $destinationIds)->pluck('name')->toArray();
+        return implode(', ', $destinations);
+    }
+
     public function updatedExportFromDate()
     {
         $this->updateEmailSubject();
@@ -1164,6 +1220,8 @@ class Record extends Component
                 'member' => $this->filterMember ? $this->getMemberName($this->filterMember) : null,
                 'causals' => $this->filterCausals ? $this->getCausalsNames($this->filterCausals) : null,
                 'payment_methods' => $this->filterPaymentMethods ? $this->getPaymentMethodsNames($this->filterPaymentMethods) : null,
+                'origins' => $this->filterOrigins ? $this->getOriginsNames($this->filterOrigins) : null,
+                'destinations' => $this->filterDestinations ? $this->getDestinationsNames($this->filterDestinations) : null,
             ];
 
             $paymentsArray = $this->payments->map(function ($payment) {

+ 8 - 0
app/Jobs/ExportPrimaNota.php

@@ -879,6 +879,14 @@ class ExportPrimaNota implements ShouldQueue
             $descriptions[] = "Metodi di pagamento: " . (is_array($this->filters['payment_methods']) ? implode(', ', $this->filters['payment_methods']) : $this->filters['payment_methods']);
         }
 
+        if (!empty($this->filters['origins'])) {
+            $descriptions[] = "Origini: " . (is_array($this->filters['origins']) ? implode(', ', $this->filters['origins']) : $this->filters['origins']);
+        }
+
+        if (!empty($this->filters['destinations'])) {
+            $descriptions[] = "Destinazioni: " . (is_array($this->filters['destinations']) ? implode(', ', $this->filters['destinations']) : $this->filters['destinations']);
+        }
+
         return empty($descriptions) ? 'Nessun filtro applicato' : implode(' | ', $descriptions);
     }
 

+ 4 - 0
public/css/style.css

@@ -16851,4 +16851,8 @@ button.download-png {
 #btnArchive:hover,
 #btnRestore:hover {
     background-color: #0e70af !important;
+}
+
+#resume-table.records-table {
+    height: calc(100dvh - (86px + 231px)) !important;
 }

+ 120 - 14
resources/views/livewire/records.blade.php

@@ -27,15 +27,7 @@
                     @endforeach
                 </select>
             </div>
-            <div class="col-md-2">
-                Metodo di pagamento
-                <select name="search_payment_method[]" class="form-select filterPaymentMethods me-2" multiple="multiple" wire:model="filterPaymentMethods">
-                    @foreach($payments as $payment)
-                        <option value="{{$payment["id"]}}">{!!$payment["name"]!!}
-                    @endforeach
-                </select>
-            </div>
-            <div class="col-md-2">
+            <div class="col-md-3">
                 Periodo
                 <div class="col-12 mb-3">
                     <select wire:model="selectedPeriod" class="form-select" @if($isFiltering) disabled @endif style="height: 43px!important;">
@@ -267,7 +259,33 @@
                 @endif
                 @endif
             </div>
-            <div class="col-md-2">
+        </div>
+        <div class="row g-3">
+            <div class="col-md-3">
+                Metodo di pagamento
+                <select name="search_payment_method[]" class="form-select filterPaymentMethods me-2" multiple="multiple" wire:model="filterPaymentMethods">
+                    @foreach($payments as $payment)
+                        <option value="{{$payment["id"]}}">{!!$payment["name"]!!}
+                    @endforeach
+                </select>
+            </div>
+            <div class="col-md-3">
+                Origine
+                <select name="search_origin[]" class="form-select filterOrigins me-2" multiple="multiple" wire:model="filterOrigins">
+                    @foreach($origins as $origin)
+                        <option value="{{$origin["id"]}}">{!!$origin["name"]!!}
+                    @endforeach
+                </select>
+            </div>
+            <div class="col-md-3">
+                Destinazione
+                <select name="search_destination[]" class="form-select filterDestinations me-2" multiple="multiple" wire:model="filterDestinations">
+                    @foreach($destinations as $destination)
+                        <option value="{{$destination["id"]}}">{!!$destination["name"]!!}
+                    @endforeach
+                </select>
+            </div>
+            <div class="col">
                 <div class="prima--nota_buttons ms-auto" style="float:right; margin-top:25px;">
                     <button class="btn--ui primary" wire:click="applyFilters" style="margin-right:5px;" @if($isFiltering) disabled @endif>
                         @if($isFiltering)
@@ -347,7 +365,7 @@
                     <th scope="col">Stato</th>
                     <th scope="col" class="text-end">Entrata</th>
                     <th scope="col" class="text-end">Uscita</th>
-                    <th scope="col">Origine</th>
+                    <th scope="col" style="padding-left: 20px;">Origine</th>
                     <th scope="col">Destinazione</th>
                     <th scope="col">Metodo di pagamento</th>
                 </tr>
@@ -371,12 +389,12 @@
                         <tr>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($record->date))}}</td>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$record->commercial ? 'Commerciale' : 'Non commerciale'}}</td>
-                            <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}; width: 20%;white-space: pre-line;">{{$record->causal_name}}</td>
-                            <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$record->type == 'IN' ? ($record->member->first_name . " " . $record->member->last_name) : @$record->supplier->name}}</td>
+                            <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}; width: 22%;white-space: pre-line;">{{$record->causal_name}}</td>
+                            <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}; width: 22%">{{$record->type == 'IN' ? ($record->member->first_name . " " . $record->member->last_name) : @$record->supplier->name}}</td>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$record->deleted ? 'Annullata' : ''}}</td>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}; text-align: right; color: green">{{$record->type == 'IN' ? formatPrice($record->amount) : ''}}</td>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}; text-align: right; color: red">{{$record->type == 'OUT' ? formatPrice($record->amount) : ''}}</td>
-                            <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$record->type == 'OUT' ? $record->origin : ''}}</td>
+                            <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}; padding-left: 20px;">{{$record->type == 'OUT' ? $record->origin : ''}}</td>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$record->type == 'IN' ? $record->destination : ''}}</td>
                             <td style="background-color: {{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$record->payment_method->name}}</td>
                         </tr>
@@ -1349,6 +1367,16 @@
                     $(this).select2('close');
                 }
             });
+            $('.filterOrigins').each(function() {
+                if ($(this).hasClass('select2-hidden-accessible')) {
+                    $(this).select2('close');
+                }
+            });
+            $('.filterDestinations').each(function() {
+                if ($(this).hasClass('select2-hidden-accessible')) {
+                    $(this).select2('close');
+                }
+            });
             $('.filterMember').each(function() {
                 if ($(this).hasClass('select2-hidden-accessible')) {
                     $(this).select2('close');
@@ -1432,6 +1460,80 @@
                     }, 100);
                 });
 
+                $(document).on("keypress", $('.filterOrigins'), function (e) {
+                    setTimeout(() => {
+                        $(".select2-results__option").each(function(){
+                            var txt = $(this).html();
+                            var count = (txt.match(/-/g) || []).length;
+                            $(this).addClass('paddingLeftSelect' + count);
+                        });
+                    }, 100);
+                });
+
+                if (!$('.filterOrigins').hasClass('select2-hidden-accessible')) {
+                    $('.filterOrigins').select2({
+                        "language": {"noResults": function(){return "Nessun risultato";}},
+                        "dropdownParent": $('body'),
+                        "width": "100%"
+                    });
+                }
+
+                $('.filterOrigins').off('change.customHandler').on('change.customHandler', function (e) {
+                    var data = $('.filterOrigins').select2("val");
+                    @this.set('filterOrigins', data);
+                });
+
+                $('.filterOrigins').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
+                    if ($('#causalsModal').hasClass('show')) {
+                        $('#causalsModal').modal('hide');
+                    }
+
+                    setTimeout(() => {
+                        $(".select2-results__option").each(function(){
+                            var txt = $(this).html();
+                            var count = (txt.match(/-/g) || []).length;
+                            $(this).addClass('paddingLeftSelect' + count);
+                        });
+                    }, 100);
+                });
+
+                $(document).on("keypress", $('.filterDestinations'), function (e) {
+                    setTimeout(() => {
+                        $(".select2-results__option").each(function(){
+                            var txt = $(this).html();
+                            var count = (txt.match(/-/g) || []).length;
+                            $(this).addClass('paddingLeftSelect' + count);
+                        });
+                    }, 100);
+                });
+
+                if (!$('.filterDestinations').hasClass('select2-hidden-accessible')) {
+                    $('.filterDestinations').select2({
+                        "language": {"noResults": function(){return "Nessun risultato";}},
+                        "dropdownParent": $('body'),
+                        "width": "100%"
+                    });
+                }
+
+                $('.filterDestinations').off('change.customHandler').on('change.customHandler', function (e) {
+                    var data = $('.filterDestinations').select2("val");
+                    @this.set('filterDestinations', data);
+                });
+
+                $('.filterDestinations').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
+                    if ($('#causalsModal').hasClass('show')) {
+                        $('#causalsModal').modal('hide');
+                    }
+
+                    setTimeout(() => {
+                        $(".select2-results__option").each(function(){
+                            var txt = $(this).html();
+                            var count = (txt.match(/-/g) || []).length;
+                            $(this).addClass('paddingLeftSelect' + count);
+                        });
+                    }, 100);
+                });
+
                 if (!$('.filterMember').hasClass('select2-hidden-accessible')) {
                     $('.filterMember').select2({
                         "language": {"noResults": function(){return "Nessun risultato";}},
@@ -1570,6 +1672,8 @@
             $('.filterMember').val('').trigger('change');
             $('.filterCausals').val('').trigger('change');
             $('.filterPaymentMethods').val('').trigger('change');
+            $('.filterOrigins').val('').trigger('change');
+            $('.filterDestinations').val('').trigger('change');
             load();
         });
 
@@ -1899,6 +2003,8 @@
             $('.filterMember').val('').trigger('change');
             $('.filterCausals').val('').trigger('change');
             $('.filterPaymentMethods').val('').trigger('change');
+            $('.filterOrigins').val('').trigger('change');
+            $('.filterDestinations').val('').trigger('change');
 
             if (typeof @this !== 'undefined') {
                 @this.call('resetFilters');