Parcourir la source

Aggiunto flag nella causale per blocco visualizzazione in report

ferrari il y a 4 mois
Parent
commit
8413baa57d

+ 5 - 1
app/Http/Livewire/Causal.php

@@ -6,7 +6,7 @@ use Livewire\Component;
 
 class Causal extends Component
 {
-    public $recordsIn, $recordsOut, $parent_id,  $name, $enabled, $corrispettivo_fiscale, $no_receipt, $money, $user_status, $no_first, $no_records, $type, $dataId, $update = false, $add = false;
+    public $recordsIn, $recordsOut, $parent_id,  $name, $enabled, $corrispettivo_fiscale, $no_receipt, $money, $user_status, $no_first, $no_records, $no_reports, $type, $dataId, $update = false, $add = false;
 
     public $corrispettivo_causal_id = 0;
 
@@ -43,6 +43,7 @@ class Causal extends Component
         $this->user_status = false;
         $this->no_first = false;
         $this->no_records = false;
+        $this->no_reports = false;
         $this->enabled = true;
     }
 
@@ -85,6 +86,7 @@ class Causal extends Component
                 'user_status' => $this->user_status,
                 'no_first' => $this->no_first,
                 'no_records' => $this->no_records,
+                'no_reports' => $this->no_reports,
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Causale creata');
@@ -107,6 +109,7 @@ class Causal extends Component
                 $this->user_status = $causal->user_status;
                 $this->no_first = $causal->no_first;
                 $this->no_records = $causal->no_records;
+                $this->no_reports = $causal->no_reports;
                 $this->enabled = $causal->enabled;
                 $this->type = $causal->type;
                 $this->parent_id = $causal->parent_id;
@@ -130,6 +133,7 @@ class Causal extends Component
                 'user_status' => $this->user_status,
                 'no_first' => $this->no_first,
                 'no_records' => $this->no_records,
+                'no_reports' => $this->no_reports,
                 'money' => $this->money,
                 'no_receipt' => $this->no_receipt,
                 'corrispettivo_fiscale' => $this->corrispettivo_fiscale,

+ 4 - 0
app/Http/Livewire/Reports.php

@@ -326,6 +326,10 @@ class Reports extends Component
             'causals.parent_id',
             DB::raw('SUM(records_rows.amount) as total_amount')
         )
+            ->where(function ($query) {
+                $query->where('causals.no_reports', '=', '0')
+                    ->orWhereNull('causals.no_reports');
+            })
             ->groupBy('causals.id', 'causals.name', 'causals.parent_id')
             ->orderBy('total_amount', 'desc')
             ->limit($limit)

+ 2 - 1
app/Models/Causal.php

@@ -19,7 +19,8 @@ class Causal extends Model
         'user_status',
         'no_first',
         'no_records',
-        'enabled'
+        'enabled',
+        'no_reports',
     ];
 
 

+ 32 - 0
database/migrations/2025_09_24_101133_add_no_reports_to_causals_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('causals', function (Blueprint $table) {
+            $table->boolean('no_reports')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('causals', function (Blueprint $table) {
+            $table->dropColumn('no_reports');
+        });
+    }
+};

+ 7 - 0
resources/views/livewire/causal.blade.php

@@ -197,6 +197,13 @@
                             </div>
                         </div>
 
+                        <div class="form--item mb-3">
+                            <div class="form-check form-check-inline" style="padding-left:28px !important;">
+                                <input class="form-check-input form-control" style="width:22px; height:22px;" type="checkbox" id="no_reports" wire:model="no_reports">
+                                <label class="form-check-label" for="no_reports">Escludi da reports</label>
+                            </div>
+                        </div>
+
                         <!-- // inline input field -->
 
                         <div class="form--item">