Forráskód Böngészése

pagato non pagato

FabioFratini 8 hónapja
szülő
commit
ac67f3f4e6

+ 26 - 34
app/Http/Livewire/RecordOUT.php

@@ -45,7 +45,10 @@ class RecordOUT extends Component
         $this->sortField = $field;
     }
 
-    public $records, $dataId, $member_id, $supplier_id,
+    public $records,
+        $dataId,
+        $member_id,
+        $supplier_id,
         $causal_id,
         $payment_method_id,
         $date,
@@ -55,7 +58,10 @@ class RecordOUT extends Component
         $type,
         $amount,
         $note,
-        $commercial, $update = false, $add = false;
+        $commercial,
+        $update = false,
+        $add = false,
+        $is_paid = false;
     public $attachment;
 
     public $filterSupplier = 0, $filterPaymentMethod = 0, $filterCausals = [], $filterFrom = '', $filterTo = '', $filterCommercial = 0;
@@ -86,8 +92,6 @@ class RecordOUT extends Component
         'payment_method_id' => 'required',
         'rows.*.causal_id' => 'required',
         'rows.*.amount' => 'required'
-        //'causal_id' => 'required',
-        //'amount' => 'required'
     ];
 
     protected $messages = [
@@ -119,16 +123,11 @@ class RecordOUT extends Component
     {
         $this->member_id = null;
         $this->supplier_id = null;
-        //$this->causal_id = null;
         $this->payment_method_id = null;
         $this->date = date("Y-m-d");
         $this->data_pagamento = date("Y-m-d");
         //$this->attachment = null;
-        //$this->month = date("n");
-        //$this->year = date("Y");
         $this->type = 'OUT';
-        //$this->note = '';
-        //$this->amount = null;
         $this->commercial = 1;
         $this->rows = array();
         $this->rows[] = array(
@@ -278,21 +277,13 @@ class RecordOUT extends Component
         if (false) {
             if ($this->hasFilter) {
 
-                $datas = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method');
-                /*if ($this->filterCommercial > 0)
-                {
-                    $datas = $datas->where('commercial', $this->filterCommercial == 1 ? true : false);
-                }*/
+                $datas = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method','is_paid');
                 if ($this->filterSupplier > 0) {
                     $datas = $datas->where('supplier_id', $this->filterSupplier);
                 }
                 if ($this->filterPaymentMethod > 0) {
                     $datas = $datas->where('payment_method_id', $this->filterPaymentMethod);
                 }
-                /*if (sizeof($this->filterCausals) > 0)
-                {
-                    $datas = $datas->whereIn('causal_id', $this->filterCausals);
-                }*/
                 if ($this->filterFrom != '') {
                     $datas = $datas->where('date', '>=', $this->filterFrom);
                 }
@@ -310,6 +301,8 @@ class RecordOUT extends Component
                     }
                 }
             } else {
+                $fromDate = date("Y-m-d");
+                $toDate = date("Y-m-d");
                 if ($this->selectedFilter == '') {
                     $this->records = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method')->limit(20)->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
                 } else {
@@ -337,6 +330,7 @@ class RecordOUT extends Component
                 $r->total = $r->getTotal();
                 $r->supplier = $r->supplier ? $r->supplier->name : '';
                 $r->payment = $r->payment_method ? $r->payment_method->name : '';
+                $r->is_paid = $r->is_paid ? 'Pagato' : 'Non Pagato';
             }
         }
         return view('livewire.records_out');
@@ -353,7 +347,6 @@ class RecordOUT extends Component
     {
 
         $this->emit('load-select');
-        //if ($this->hasFilter)
         $this->emit('hide-search');
         $this->resetFields();
         $this->add = true;
@@ -373,14 +366,16 @@ class RecordOUT extends Component
 
         $invoiceNumber = null;
 
-        // Option 1: Use current date and time as the invoice number
         $invoiceNumber = 'USC-' . date('YmdHis');
 
+
         if (empty($this->data_pagamento) || $this->data_pagamento == '1970-01-01') {
             $this->data_pagamento = null;
             Log::info("Setting data_pagamento to NULL in store");
+            $is_paid = false;
         } else {
             Log::info("Using data_pagamento: " . $this->data_pagamento);
+            $is_paid = true;
         }
 
         $this->validate();
@@ -388,18 +383,15 @@ class RecordOUT extends Component
             $record = \App\Models\Record::create([
                 'member_id' => $this->member_id,
                 'supplier_id' => $this->supplier_id,
-                //'causal_id' => $this->causal_id,
                 'payment_method_id' => $this->payment_method_id,
                 'date' => $this->date,
                 'data_pagamento' =>$this->data_pagamento,
-                //'month' => $this->month,
-                //'year' => $this->year,
-                //'note' => $this->note,
                 //'attachment' => $this->attachment,
                 'type' => $this->type,
                 'amount' => $this->currencyToDouble($this->amount),
                 'commercial' => $this->commercial,
                 'numero_fattura' => $invoiceNumber,
+                'is_paid' => $is_paid,
             ]);
             Log::info("Record data being inserted: " . json_encode($record));
 
@@ -439,7 +431,6 @@ class RecordOUT extends Component
 
     public function setDataPagamentoAttribute($value)
     {
-        // Convert empty values to NULL
         if (empty($value) || $value == '1970-01-01' || $value == '0000-00-00') {
             $this->attributes['data_pagamento'] = null;
         } else {
@@ -447,10 +438,8 @@ class RecordOUT extends Component
         }
     }
 
-    // Optional: Also add an accessor to prevent returning 1970-01-01
     public function getDataPagamentoAttribute($value)
     {
-        // Return null instead of Unix epoch date
         if ($value == '1970-01-01' || $value == '0000-00-00') {
             return null;
         }
@@ -463,7 +452,6 @@ class RecordOUT extends Component
             $this->fromPage = 'out';
         $this->emit('setEdit', true);
         $this->emit('load-select');
-        //if ($this->hasFilter)
         $this->emit('hide-search');
         try {
             $record = \App\Models\Record::findOrFail($id);
@@ -472,16 +460,11 @@ class RecordOUT extends Component
             } else {
                 $this->member_id = $record->member_id;
                 $this->supplier_id = $record->supplier_id;
-                //$this->causal_id = $record->causal_id;
                 $this->payment_method_id = $record->payment_method_id;
                 $this->date = date("Y-m-d", strtotime($record->date));
                 $this->data_pagamento =  $record->data_pagamento;
-                //$this->month = $record->month;
-                //$this->year = $record->year;
-                //$this->note = $record->note;
                 $this->type = $record->type;
                 //$attachment = $record->attachment;
-                //$this->amount = formatPrice($record->amount);
                 $this->commercial = $record->commercial;
                 $this->dataId = $record->id;
                 $this->update = true;
@@ -522,12 +505,13 @@ class RecordOUT extends Component
     {
         $this->emit('refresh');
         $this->validate();
-
         if (empty($this->data_pagamento) || $this->data_pagamento == '') {
             $this->data_pagamento = null;
             Log::info("Data pagamento vuota, imposto a NULL in update");
+            $is_paid = false;
         } else {
             Log::info("Data pagamento in update: " . $this->data_pagamento);
+            $is_paid = true;
         }
 
         try {
@@ -539,6 +523,7 @@ class RecordOUT extends Component
                 'data_pagamento' => $this->data_pagamento,
                 'type' => $this->type,
                 'commercial' => $this->commercial,
+                'is_paid' => $is_paid,
                 //'attachment' => $this->attachment,
             ]);
 
@@ -1081,6 +1066,13 @@ class RecordOUT extends Component
         $record->tipo_documento = $this->mapTipoDocumento($fatturaData['tipoDocumento']);
 
         $record->is_ricevuta = true;
+
+        if ($record->data_pagamento != null) {
+            $record->is_paid = true;
+        }else {
+            $record->is_paid = false;
+        }
+
         if (isset($fatturaData['condizioniPagamento']) && !empty($fatturaData['condizioniPagamento'])) {
             $record->condizioni_pagamento = $this->mapCondizioniPagamento($fatturaData['condizioniPagamento']);
         }

+ 1 - 0
app/Models/Record.php

@@ -28,6 +28,7 @@ class Record extends Model
         'amount',
         'numero_fattura',
         //'attachment'
+        'is_paid',
     ];
 
     public function member()

+ 34 - 0
database/migrations/2025_05_15_000000_add_field_paid_to_records_table.php

@@ -0,0 +1,34 @@
+<?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('records', function (Blueprint $table) {
+            $table->boolean('is_paid')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('records', function (Blueprint $table) {
+
+            $table->dropColumn([
+                'is_paid',
+            ]);
+        });
+    }
+};

+ 61 - 148
resources/views/livewire/records_out.blade.php

@@ -175,54 +175,19 @@
             <table class="table tablesaw tableHead tablesaw-stack table--lista_entrate tableHead" id="tablesaw-350" width="100%">
                 <thead>
                     <tr>
-                        <!--<th scope="col"></th>-->
                         <th scope="col">Data</th>
                         <th scope="col">Importo</th>
                         <th scope="col">Fornitore</th>
                         <th scope="col">Causale</th>
                         <th scope="col">Pagamento</th>
+                        <th scope="col">Stato</th>
                         <th scope="col">...</th>
                     </tr>
                 </thead>
 
                 <tbody id="checkall-target">
                 </tbody>
-                <!--
-                <tfoot>
-                    <tr id="tfooter">
-                        <td colspan="6"><span class="total"></span></td>
-                    </tr>
-                </tfoot>
-                -->
             </table>
-
-
-            <!--
-            <div class="paginator d-flex justify-content-center">
-                <nav aria-label="Page navigation example">
-                    <ul class="pagination">
-                        <li class="page-item">
-                        <a class="page-link" href="#" aria-label="Previous">
-                            <span aria-hidden="true"></span>
-                        </a>
-                        </li>
-                        <li class="page-item"><a class="page-link" href="#">1</a></li>
-                        <li class="page-item"><a class="page-link" href="#">2</a></li>
-                        <li class="page-item"><a class="page-link" href="#">3</a></li>
-                        <li class="page-item"><a class="page-link" href="#">3</a></li>
-
-                        <li class="page-item"><span class="more-page">...</span></li>
-
-                        <li class="page-item">
-                        <a class="page-link" href="#" aria-label="Next">
-                            <span aria-hidden="true"></span>
-                        </a>
-                        </li>
-                    </ul>
-                    </nav>
-            </div>
-            -->
-
             <br><b class="totalDiv"></b>
 
         </section>
@@ -275,15 +240,6 @@
                                     <input id="datePagamento" type="date" class="form-control"  wire:model="data_pagamento">
                                 </div>
                             </div>
-
-
-{{--                             <div class="col-md-6">
-                                <span class="title-form d-block w-100">Allegato</span>
-                                <div class="input-group mb-3">
-                                    <input type="file" class="form-control form-control-lg" wire:model="attachment">
-                                </div>
-                            </div> --}}
-
                             <div class="col-12">
                                 <span class="title-form d-block w-100">Fornitore</span>
 
@@ -569,9 +525,6 @@
                             <div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
                                 <span class="amount_p"><strong>Importo</strong></span><span class="amount_data"><strong>{{$amount}}</strong></span>
                             </div>
-                            <!--<div class="total--wrapper_tax d-flex align-items-center justify-content-between w-100 mb-2 pb-3">
-                                <span class="taxt_p">IVA (22%):</span><span class="tax_data">€ 22,00</span>
-                            </div>-->
                             <div class="total--wrapper_netprice d-flex align-items-center justify-content-between w-100">
                                 <span class="netprice_p"><strong>Totale Netto</strong></span><span class="netprice_data"><strong>{{$amount}}</strong></span>
                             </div>
@@ -672,9 +625,7 @@
                     }
                 });
             $('.supplierClass').select2({
-                    /*matcher: function(params, data) {
-                        return matchStart(params, data);
-                    }*/
+
                 });
             $('.paymentClass').select2({
                     matcher: function(params, data) {
@@ -699,16 +650,6 @@
         });
 
         Livewire.on('load-select', () => {
-            /*$('.causalClass').select2({
-                    matcher: function(params, data) {
-                        return matchStart(params, data);
-                    }
-                });
-            $('.causalClass').on('change', function (e) {
-                var data = $('.causalClass').select2("val");
-                @this.set('causal_id', data);
-            });
-            */
             $('.causalClass').each(function(i, obj) {
                 $(obj).select2({"language": {"noResults": function(){return "Nessun risultato";}}});
                 $(obj).on('change', function (e) {
@@ -718,9 +659,7 @@
                 });
             });
             $('.supplierClass').select2({
-                    /*matcher: function(params, data) {
-                        return matchStart(params, data);
-                    }*/
+
                 });
             $('.supplierClass').on('change', function (e) {
                 var data = $('.supplierClass').select2("val");
@@ -738,40 +677,31 @@
 
             $('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
             $('.filterSupplier').on('change', function (e) {
-                //var data = $('.filterSupplier').select2("val");
-                //@this.set('filterSupplier', data);
+
             });
             $('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
             $('.filterPaymentMethod').on('change', function (e) {
-                //var data = $('.filterPaymentMethod').select2("val");
-                //@this.set('filterPaymentMethod', data);
+
             });
             $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
             $('.filterCausals').on('change', function (e) {
-                //var data = $('.filterCausals').select2("val");
-                //@this.set('filterCausals', data);
+
             });
 
         });
 
         Livewire.on('hide-search', () => {
-            //pcsh2();
         });
 
         $('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
         $('.filterSupplier').on('change', function (e) {
-            //var data = $('.filterSupplier').select2("val");
-            //@this.set('filterSupplier', data);
         });
         $('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
         $('.filterPaymentMethod').on('change', function (e) {
-            //var data = $('.filterPaymentMethod').select2("val");
-            //@this.set('filterPaymentMethod', data);
+
         });
         $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
         $('.filterCausals').on('change', function (e) {
-            //var data = $('.filterCausals').select2("val");
-            //@this.set('filterCausals', data);
         });
 
         function onlyNumberAmount(input) {
@@ -846,7 +776,6 @@
             });
 
             $(document).on("select2:open",".filterCausals",function() {
-            //$('.filterCausals').on('select2:open', function (e) {
                 setTimeout(() => {
                     $(".select2-results__option").each(function(){
                         var txt = $(this).html();
@@ -956,14 +885,22 @@
                     { data: 'supplier' },
                     { data: 'causals' },
                     { data: 'payment' },
+                    {
+                        data: 'is_paid',
+                        render: function (data) {
+                            if (data === true || data === 'true' || data === 1 || data === '1' || data === 'Pagato') {
+                                return '<span class="badge bg-success">Pagato</span>';
+                            } else {
+                                return '<span class="badge bg-danger">Non Pagato</span>';
+                            }
+                        }
+                    },
                     {
                         data: "action",
                         render: function (data){
                             if (data == "")
                                 return "";
                             const j = data.split("|");
-                            //$(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + j[1] + '</b>');
-                            //$(".total").html('Totale&nbsp;:&nbsp;<b>' + j[1] + '</b>');
                             var ret = '<button type="button" class="btn" onclick="editData(' + j[0] + ')" data-bs-toggle="popover"  data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button>&nbsp;';
                             ret += '<button type="button" class="btn" onclick="deleteData(' + j[0] + ')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>';
                             return ret;
@@ -1089,7 +1026,6 @@
                         modalInstance.show();
                     }
 
-                    // Re-initialize table if needed after Livewire updates
                     setTimeout(() => {
                         if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
                             loadDataTable();
@@ -1133,7 +1069,6 @@
         setTimeout(function() {
             initImportCausalSelect();
 
-            // Ensure the table is reloaded when modal is shown
             if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
                 loadDataTable();
                 if (tableState) {
@@ -1213,12 +1148,11 @@
         closeButton.setAttribute('aria-label', 'Close');
         alert.appendChild(closeButton);
 
-        const accountingExit = document.getElementById('accountingExit'); // Or any other suitable container
+        const accountingExit = document.getElementById('accountingExit');
         if (accountingExit) {
             accountingExit.prepend(alert);
         } else {
-            // If accountingExit is not found, prepend to the main container
-            const mainContainer = document.querySelector('.col.card--ui'); // Adjust selector as needed
+            const mainContainer = document.querySelector('.col.card--ui');
             if (mainContainer) {
                 mainContainer.prepend(alert);
             } else {
@@ -1228,7 +1162,7 @@
 
         setTimeout(() => {
             alert.remove();
-        }, 5000); // Remove after 5 seconds
+        }, 5000);
     });
 
     function closeImportModal() {
@@ -1236,19 +1170,15 @@
         if (importModal) {
             importModal.hide();
         }
-        // We no longer need to reload the page here, as this will happen after the result modal is closed
     }
 
-    // Update the existing emit handler for import-started
     Livewire.on('import-started', () => {
-        // Disable the close button and submit button during import
         const closeButton = document.querySelector('#importModal .btn-close');
         const submitButton = document.querySelector('#importModal button[type="submit"]');
         if (closeButton) closeButton.disabled = true;
         if (submitButton) submitButton.disabled = true;
     });
 
-    // Add listener for close-import-modal event
     Livewire.on('close-import-modal', () => {
         const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
         if (importModal) {
@@ -1258,9 +1188,7 @@
 
     let transitioningToResultModal = false;
 
-    // Listener per evento di chiusura della modale di import
     document.getElementById('importModal').addEventListener('hidden.bs.modal', function () {
-        // Ricarica la pagina solo se non stiamo passando alla modale di risultato
         if (!transitioningToResultModal) {
             console.log("Modal import chiusa dall'utente: ricarica la pagina");
             setTimeout(function() {
@@ -1268,7 +1196,6 @@
             }, 500);
         } else {
             console.log("Transizione da importModal a resultModal: non ricaricare");
-            // Reset della variabile dopo la transizione
             transitioningToResultModal = false;
         }
     });
@@ -1277,16 +1204,13 @@
     Livewire.on('show-import-result', data => {
         transitioningToResultModal = true;
 
-        // Prepara il contenuto della modale di risultato
         const resultDiv = document.getElementById('importResultMessage');
         resultDiv.innerHTML = data.message;
-        // Chiudi la modale di importazione
         const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
         if (importModal) {
             importModal.hide();
         }
 
-        // Mostra la modale dei risultati dopo un breve ritardo
         setTimeout(() => {
             const resultModal = new bootstrap.Modal(document.getElementById('importResultModal'));
             resultModal.show();
@@ -1299,68 +1223,57 @@
     });
 
     document.addEventListener('DOMContentLoaded', function() {
-    // Function to calculate and update the amount field
-    function calculateAmount(rowIndex) {
-        const imponibileField = document.getElementById(`rows.${rowIndex}.imponibile`);
-        const aliquotaField = document.getElementById(`rows.${rowIndex}.aliquota_iva`);
-        const amountField = document.getElementById(`rows.${rowIndex}.amount`);
-
-        if (imponibileField && aliquotaField && amountField) {
-            // Get imponibile value (remove formatting)
-            let imponibile = imponibileField.value.replace('€', '').replace(/\./g, '').replace(',', '.').trim();
-            imponibile = parseFloat(imponibile) || 0;
-
-            // Get aliquota value (remove % sign)
-            let aliquota = aliquotaField.value.replace('%', '').trim();
-            aliquota = parseFloat(aliquota) || 0;
-
-            // Calculate amount: imponibile + (imponibile * aliquota / 100)
-            const imposta = imponibile * (aliquota / 100);
-            const totalAmount = imponibile + imposta;
-
-            // Format and set the amount value
-            let formattedAmount = "€ " + totalAmount.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
-            amountField.value = formattedAmount;
-
-            // Trigger the Livewire update to sync with backend
-            // This uses the Livewire.find method to access component methods
-            const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
-            if (component) {
-                component.set(`rows.${rowIndex}.amount`, formattedAmount);
+
+        function calculateAmount(rowIndex) {
+            const imponibileField = document.getElementById(`rows.${rowIndex}.imponibile`);
+            const aliquotaField = document.getElementById(`rows.${rowIndex}.aliquota_iva`);
+            const amountField = document.getElementById(`rows.${rowIndex}.amount`);
+
+            if (imponibileField && aliquotaField && amountField) {
+                let imponibile = imponibileField.value.replace('€', '').replace(/\./g, '').replace(',', '.').trim();
+                imponibile = parseFloat(imponibile) || 0;
+
+                let aliquota = aliquotaField.value.replace('%', '').trim();
+                aliquota = parseFloat(aliquota) || 0;
+
+                const imposta = imponibile * (aliquota / 100);
+                const totalAmount = imponibile + imposta;
+
+                let formattedAmount = "€ " + totalAmount.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
+                amountField.value = formattedAmount;
+
+                const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
+                if (component) {
+                    component.set(`rows.${rowIndex}.amount`, formattedAmount);
+                }
             }
         }
-    }
 
-    // Attach event listeners to imponibile and aliquota fields
-    function setupCalculationListeners() {
-        const rows = document.querySelectorAll('input[id^="rows."][id$=".imponibile"], input[id^="rows."][id$=".aliquota_iva"]');
+        function setupCalculationListeners() {
+            const rows = document.querySelectorAll('input[id^="rows."][id$=".imponibile"], input[id^="rows."][id$=".aliquota_iva"]');
 
-        rows.forEach(field => {
-            field.addEventListener('blur', function() {
-                // Extract row index from the field ID
-                const rowIndex = this.id.match(/rows\.(\d+)\./)[1];
-                calculateAmount(rowIndex);
+            rows.forEach(field => {
+                field.addEventListener('blur', function() {
+                    const rowIndex = this.id.match(/rows\.(\d+)\./)[1];
+                    calculateAmount(rowIndex);
+                });
             });
-        });
-    }
-
-    // Initial setup
-    setupCalculationListeners();
+        }
 
-    // Re-attach listeners after Livewire updates
-    document.addEventListener('livewire:load', function() {
         setupCalculationListeners();
-    });
 
-    document.addEventListener('livewire:update', function() {
-        setupCalculationListeners();
-    });
+        document.addEventListener('livewire:load', function() {
+            setupCalculationListeners();
+        });
+
+        document.addEventListener('livewire:update', function() {
+            setupCalculationListeners();
+        });
 
-    // Also attach to rows added dynamically
-    Livewire.on('load-select', function() {
-        setTimeout(setupCalculationListeners, 300); // Give time for DOM to update
+        Livewire.on('load-select', function() {
+            setTimeout(setupCalculationListeners, 300);
+        });
     });
-});
     </script>
 
 @endpush

+ 4 - 25
routes/web.php

@@ -65,9 +65,9 @@ function setDatabase()
     config()->set('database.connections.' . $connectionName, $config);
     DB::purge($connectionName);
     //DB::setDefaultConnection('mysql');
-    
+
 }
-    
+
 Route::group(['middleware' => 'auth'], function () {
 
     // setDatabase();
@@ -710,15 +710,6 @@ Route::get('/get_record_out', function () {
         $x = $x->where('supplier_id', $_GET["filterSupplier"]);
         $hasFilter = true;
     }
-    /*if ($_GET["filterPaymentMethod"] > 0)
-        {
-            $x = $x->where('payment_method_id', $_GET["filterPaymentMethod"]);
-        }
-        if ($_GET["filterCausals"] > 0)
-        {
-            $causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
-            $x = $x->whereIn('records.id', $causals);
-        }*/
     if ($_GET["filterPaymentMethod"] != "null") {
         $payments = explode(",", $_GET["filterPaymentMethod"]);
         $x = $x->whereIn('payment_method_id', $payments);
@@ -739,7 +730,6 @@ Route::get('/get_record_out', function () {
             }
         }
 
-        //$causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
         $causals = \App\Models\RecordRow::whereIn('causal_id', $causals)->pluck('record_id');
         $x = $x->whereIn('records.id', $causals);
         $hasFilter = true;
@@ -780,26 +770,15 @@ Route::get('/get_record_out', function () {
 
 
         $datas[] = array(
-            //'id' => $r->id,
             'date' => $r->date,
             'total' => formatPrice($r->getTotal()),
             'supplier' => $r->supplier->name,
             'causals' => $causals,
             'payment' => $r->payment_method->name,
+            'is_paid' => $r->is_paid ? 'Pagato' : 'Non Pagato',
             'action' => $r->id . "|"
         );
     }
-    /*
-        $datas[] = array(
-            //'id' => $r->id,
-            'date' => '',
-            'total' => formatPrice($total),
-            'supplier' => '',
-            'causals' => '',
-            'payment' => '',
-            'action' => ''
-        );
-        */
     if ($hasFilter)
         return json_encode(array("data" => $datas, "totals" => formatPrice($total)));
     else
@@ -1671,4 +1650,4 @@ Route::get('/test_mail', function(){
         ]));
     }
 
-});
+});