소스 검색

pulizia Log

FabioFratini 7 달 전
부모
커밋
9d9a7dbcb9
1개의 변경된 파일3개의 추가작업 그리고 39개의 파일을 삭제
  1. 3 39
      app/Http/Livewire/RecordOUT.php

+ 3 - 39
app/Http/Livewire/RecordOUT.php

@@ -392,20 +392,18 @@ class RecordOUT extends Component
         $this->validate();
 
         try {
-            // DEBUG: Check if we have an attachment
-            Log::info("STORE DEBUG - Has attachment?: " . ($this->attachment ? 'YES' : 'NO'));
+
             if ($this->attachment) {
                 Log::info("STORE DEBUG - Attachment original name: " . $this->attachment->getClientOriginalName());
             }
 
-            // Create the record first WITHOUT attachment
             $record = \App\Models\Record::create([
                 'member_id' => $this->member_id,
                 'supplier_id' => $this->supplier_id,
                 'payment_method_id' => $this->payment_method_id,
                 'date' => $this->date,
                 'data_pagamento' => $this->data_pagamento,
-                'attachment' => '', // Empty initially
+                'attachment' => '',
                 'type' => $this->type,
                 'amount' => $this->currencyToDouble($this->amount),
                 'commercial' => $this->commercial,
@@ -413,46 +411,30 @@ class RecordOUT extends Component
                 'is_paid' => $is_paid,
             ]);
 
-            Log::info("STORE DEBUG - Record created with ID: " . $record->id);
             $this->dataId = $record->id;
 
-            // Create record folders after record is created
             $this->recordFileService->createRecordFolders($record->id, 'OUT');
-            Log::info("STORE DEBUG - Folders created for record ID: " . $record->id);
 
-            // Now handle attachment upload if exists
             if ($this->attachment) {
                 try {
-                    Log::info("STORE DEBUG - Starting attachment upload...");
                     $attachmentPath = $this->recordFileService->uploadAttachment($this->attachment, $record->id, 'OUT');
-                    Log::info("STORE DEBUG - Attachment uploaded to path: " . $attachmentPath);
 
-                    // Use DB query builder instead of model update to ensure it works
                     $updateResult = \DB::table('records')
                         ->where('id', $record->id)
                         ->update(['attachment' => $attachmentPath]);
 
-                    Log::info("STORE DEBUG - DB update result: " . ($updateResult ? 'SUCCESS' : 'FAILED'));
 
-                    // Verify the update worked by fetching fresh from database
                     $updatedRecord = \App\Models\Record::where('id', $record->id)->first();
-                    Log::info("STORE DEBUG - Verified attachment in DB: '" . $updatedRecord->attachment . "'");
 
-                    // Also refresh the model instance
                     $record->refresh();
-                    Log::info("STORE DEBUG - Model after refresh: '" . $record->attachment . "'");
 
-                    Log::info("Attachment uploaded and record updated: " . $attachmentPath);
                 } catch (\Exception $ex) {
-                    Log::error("STORE ERROR - Error uploading attachment: " . $ex->getMessage());
-                    Log::error("STORE ERROR - Exception trace: " . $ex->getTraceAsString());
                     session()->flash('warning', 'Record created but attachment upload failed: ' . $ex->getMessage());
                 }
             } else {
                 Log::info("STORE DEBUG - No attachment to upload");
             }
 
-            // Create record rows
             $tot = 0;
             foreach ($this->rows as $row) {
                 foreach ($row["when"] as $x => $y) {
@@ -474,7 +456,6 @@ class RecordOUT extends Component
                 $tot += $this->currencyToDouble($row["amount"]);
             }
 
-            // Update final amount
             $record->amount = $tot;
             $record->save();
 
@@ -519,12 +500,6 @@ class RecordOUT extends Component
             if (!$record) {
                 $this->emit('flash-error', 'Movimento non trovato');
             } else {
-                // DEBUG: Let's see what's in the database
-                Log::info("EDIT DEBUG - Record ID: {$record->id}");
-                Log::info("EDIT DEBUG - Database attachment value: '" . $record->attachment . "'");
-                Log::info("EDIT DEBUG - Database attachment type: " . gettype($record->attachment));
-                Log::info("EDIT DEBUG - Is attachment empty?: " . (empty($record->attachment) ? 'YES' : 'NO'));
-                Log::info("EDIT DEBUG - Is attachment null?: " . (is_null($record->attachment) ? 'YES' : 'NO'));
 
                 $this->member_id = $record->member_id;
                 $this->supplier_id = $record->supplier_id;
@@ -534,16 +509,13 @@ class RecordOUT extends Component
                 $this->type = $record->type;
                 $this->numero_fattura = $record->numero_fattura;
 
-                // Set attachment_old - handle different cases
                 if (!empty($record->attachment) && $record->attachment !== null && $record->attachment !== '') {
                     $this->attachment_old = $record->attachment;
-                    Log::info("EDIT DEBUG - Setting attachment_old to: '" . $this->attachment_old . "'");
                 } else {
                     $this->attachment_old = '';
-                    Log::info("EDIT DEBUG - Setting attachment_old to empty string");
                 }
 
-                $this->attachment = null; // Clear any temporary attachment
+                $this->attachment = null;
 
                 $this->commercial = $record->commercial;
                 $this->dataId = $record->id;
@@ -600,10 +572,8 @@ class RecordOUT extends Component
                     $this->rows[] = $rowData;
                 }
 
-                // Final debug log
                 Log::info("EDIT DEBUG - Final attachment_old value: '" . $this->attachment_old . "'");
 
-                // Force Livewire to re-render
                 $this->emit('refresh');
             }
         } catch (\Exception $ex) {
@@ -941,16 +911,10 @@ class RecordOUT extends Component
                         Log::info("Fattura importata con successo: {$fatturaData['numeroFattura']}, Fornitore: {$supplier->name}");
                     }
 
-                    // ← NOW $record exists! Create folder structure for the record
                     $this->recordFileService->createRecordFolders($record->id, 'OUT');
 
-                    // ← Store the XML file as an attachment to the record
                     try {
                         $xmlAttachmentPath = $this->recordFileService->uploadXmlReceipt($receiptFile, $record->id, 'OUT');
-
-                        // ← Update the record with the XML attachment path (if you have a field for it)
-                        // If you want to store XML separately from regular attachments, you could add a xml_attachment field
-                        // Or if you want to overwrite the attachment field:
                         $record->update(['attachment' => $xmlAttachmentPath]);
 
                         Log::info("XML receipt stored as attachment: " . $xmlAttachmentPath);