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

causali - nascoste in gestionale e prima nota se "hidden = true"

ferrari 3 месяцев назад
Родитель
Сommit
69973c8119
2 измененных файлов с 27 добавлено и 15 удалено
  1. 12 5
      app/Http/Livewire/Record.php
  2. 15 10
      app/Http/Livewire/RecordINOUT.php

+ 12 - 5
app/Http/Livewire/Record.php

@@ -77,7 +77,7 @@ class Record extends Component
         $this->exportEmailSubject = 'Prima Nota - Export del ' . date('d/m/Y');
 
 
-        $this->getCausals(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->get(), 0);
+        $this->getCausals(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('hidden', false)->get(), 0);
 
         $this->members = \App\Models\Member::select(['id', 'first_name', 'last_name', 'fiscal_code'])->orderBy('last_name')->orderBy('first_name')->get();
 
@@ -466,8 +466,10 @@ class Record extends Component
     {
         foreach ($records as $record) {
             $this->causals[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
-            if (count($record->childs))
-                $this->getCausals($record->childs, $indentation + 1);
+            
+            $childs = $record->childs->where('hidden', false);
+            if (count($childs))
+                $this->getCausals($childs, $indentation + 1);
         }
     }
 
@@ -543,16 +545,21 @@ class Record extends Component
                 'records_rows.vat_id',
             )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', 'records_rows.causal_id', '=', 'causals.id')
             ->whereBetween('date', [$this->appliedFromDate, $this->appliedToDate])
             ->where(function ($query) {
-                $query->where('type', 'OUT')
+                $query->where('records.type', 'OUT')
                     ->orWhere(function ($query) {
                         $query->where('records.corrispettivo_fiscale', true)
                             ->orWhere('records.commercial', false);
                     });
             })
+            ->where(function ($query) {
+                $query->where('causals.hidden', false)
+                    ->orWhereNull('causals.hidden');
+            })
             ->where(function ($query) use ($exclude_from_records) {
-                $query->where('type', 'OUT')
+                $query->where('records.type', 'OUT')
                     ->orWhere(function ($subquery) use ($exclude_from_records) {
                         $subquery->whereNotIn('member_id', $exclude_from_records);
                     });

+ 15 - 10
app/Http/Livewire/RecordINOUT.php

@@ -85,12 +85,12 @@ class RecordINOUT extends Component
         $this->year_2 = date("Y");
         $this->show_block_2 = false;
 
-        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get(), 'IN', 0);
-        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get(), 'OUT', 0);
+        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->where('hidden', false)->get(), 'IN', 0);
+        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->where('hidden', false)->get(), 'OUT', 0);
 
-        $this->getCausalsIn(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->get(), 0);
+        $this->getCausalsIn(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->where('hidden', false)->get(), 0);
 
-        $this->getCausalsOut(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->get(), 0);
+        $this->getCausalsOut(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->where('hidden', false)->get(), 0);
 
         //$this->causalsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
         //$this->causalsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get();
@@ -100,8 +100,9 @@ class RecordINOUT extends Component
     {
         foreach ($records as $record) {
             $this->causalsIn[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
-            if (count($record->childs))
-                $this->getCausalsIn($record->childs, $indentation + 1);
+            $childs = $record->childs->where('hidden', false);
+            if (count($childs))
+                $this->getCausalsIn($childs, $indentation + 1);
         }
     }
 
@@ -109,8 +110,10 @@ class RecordINOUT extends Component
     {
         foreach ($records as $record) {
             $this->causalsOut[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
-            if (count($record->childs))
-                $this->getCausalsOut($record->childs, $indentation + 1);
+            $childs = $record->childs->where('hidden', false);
+            if (count($childs)) {
+                $this->getCausalsOut($childs, $indentation + 1);
+            }
         }
     }
 
@@ -125,8 +128,10 @@ class RecordINOUT extends Component
                 $this->rows_in[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id, 'parent_name' => $this->getCausalName($record->parent_id), 'first_parent_id' => $first_parent_id, 'first_parent_name' => $this->getCausalName($first_parent_id), 'all_childs' => $this->getAllChild($record->id));
             if ($type == 'OUT')
                 $this->rows_out[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id, 'parent_name' => $this->getCausalName($record->parent_id), 'first_parent_id' => $first_parent_id, 'first_parent_name' => $this->getCausalName($first_parent_id), 'all_childs' => $this->getAllChild($record->id));
-            if (count($record->childs))
-                $this->getCausale($record->childs, $type, $indentation + 1);
+            
+            $childs = $record->childs->where('hidden', false);
+            if (count($childs))
+                $this->getCausale($childs, $type, $indentation + 1);
         }
     }