Explorar o código

cambata view allegati

FabioFratini hai 11 meses
pai
achega
385cea18cb

+ 32 - 34
app/Http/Livewire/Report.php

@@ -1228,8 +1228,7 @@ class Report extends Component
 
             $targa = $this->vei_targa;
 
-            try
-            {
+            try {
                 Log::info("veicolo con targa: " . $targa);
 
                 $wd = "dettaglioAutoveicoloBase";
@@ -1297,14 +1296,10 @@ class Report extends Component
                     $this->vei_carta_circolazione_rilasciata_il = @$obj->DatiAmministrativiVeicolo[0]->DataEmissioneDocumento;
                     $this->vei_cilindrata = @$obj->DatiTecniciVeicolo->CilindrataInCentimetriCubi;
                     $this->vei_peso_complessivo = @$obj->DatiTecniciVeicolo->TaraInKG;
-                }
-                catch(\SoapFault $fault)
-                {
+                } catch (\SoapFault $fault) {
                     $this->loadTarga = $fault->getMessage();
                 }
-            }
-            catch(\Exception $ex)
-            {
+            } catch (\Exception $ex) {
                 Log::error($ex->getMessage());
             }
 
@@ -1389,16 +1384,12 @@ class Report extends Component
                     '</xmp><br/><br/> Error Message : <br/>',
                     $fault->getMessage();
                 }
-            }
-            catch(\SoapFault $ex)
-            {
+            } catch (\SoapFault $ex) {
                 Log::error($ex->getMessage());
             }
 
             $this->emit('hideLoading', 'btPatente');
-
         }
-
     }
 
     protected function handleMCTCError($response)
@@ -1409,7 +1400,8 @@ class Report extends Component
                 session()->flash('error', 'Errore di validazione numero di caratteri errato');
             } else {
                 session()->flash('error', $response->errore->descrizioneErrore);
-            }            return false;
+            }
+            return false;
         }
         return true;
     }
@@ -1521,7 +1513,6 @@ class Report extends Component
         $mainPageCount = $pdf->getDomPDF()->getCanvas()->get_page_count();
         Log::info("Main PDF has {$mainPageCount} pages");
 
-        // Calculate total pages and regenerate PDF with correct count
         $totalPages = $mainPageCount + $totalAttachmentPages;
         Log::info("Total pages (main + attachments): {$totalPages}");
 
@@ -1585,7 +1576,6 @@ class Report extends Component
                     }
                     return $pdf->stream($pdfName);
                 }
-
             } catch (\Exception $e) {
                 Log::error("PDF merging failed: " . $e->getMessage());
                 return $pdf->stream($pdfName);
@@ -1598,24 +1588,19 @@ class Report extends Component
     private function mergeWithGhostScript($pdfFiles, $outputPath)
     {
         try {
-            // Check if GhostScript is installed
             exec('which gs', $output, $returnVar);
             if ($returnVar !== 0) {
                 Log::error("GhostScript (gs) not found on system");
                 return false;
             }
 
-            // Build GhostScript command
             $fileList = implode(' ', array_map('escapeshellarg', $pdfFiles));
             $outputFile = escapeshellarg($outputPath);
 
-            // GhostScript command to merge PDFs
             $command = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputFile $fileList";
 
-            // Execute command
             exec($command, $output, $returnVar);
 
-            // Check if command was successful
             if ($returnVar !== 0) {
                 Log::error("GhostScript command failed: " . implode("\n", $output));
                 return false;
@@ -1660,19 +1645,32 @@ class Report extends Component
             $separatorPath = $tempDir . '/separator_' . uniqid() . '.pdf';
             Log::info("Separator path: $separatorPath");
 
-            // Check if view exists
-            if (!view()->exists('pdf.separator')) {
-                Log::warning("Separator view 'pdf.separator' does not exist");
-                // Create an alternative simple view
-                $html = '<html><body><h1 style="text-align:center;margin-top:50%;">' . $title . '</h1></body></html>';
-                $separatorPdf = Pdf::loadHTML($html);
-            } else {
-                // Create a simple PDF with the title
-                Log::info("Loading separator view");
-                $separatorPdf = Pdf::loadView('pdf.separator', [
-                    'title' => $title
-                ]);
-            }
+            $html = '
+            <!DOCTYPE html>
+            <html>
+            <head>
+                <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+                <style>
+                    body {
+                        font-family: Helvetica, sans-serif;
+                        color: rgb(80, 80, 80);
+                        text-align: center;
+                    }
+                    .separator-title {
+                        margin-top: 300px;
+                        font-size: 24px;
+                        font-weight: bold;
+                        text-transform: uppercase;
+                    }
+                </style>
+            </head>
+            <body>
+                <div class="separator-title">' . $title . '</div>
+            </body>
+            </html>
+        ';
+
+            $separatorPdf = Pdf::loadHTML($html);
 
             Log::info("Generating separator PDF");
             $separatorContent = $separatorPdf->output();

+ 13 - 3
resources/views/components/verbale/allegati/index.blade.php

@@ -1,5 +1,5 @@
 {{-- resources/views/components/allegati/index.blade.php --}}
-@props(['allegati' => []])
+@props(['allegati' => [], 'protocollo'])
 
 @php
     $hasVisibleAllegati = false;
@@ -14,8 +14,18 @@
 @if($hasVisibleAllegati)
     <table width="100%">
         <tr>
-            <td width="100%" valign="top" align="center">
-                <h2>ALLEGATI FOTOGRAFICI</h2>
+            <td valign="top" align="center">
+                <h1>COMUNE DI FRASCATI</h1>
+                <h2>CORPO DI POLIZIA LOCALE</h2>
+                <h3>UFFICIO POLIZIA STRADALE E INFORTUNISTICA</h3>
+                <h3>
+                    VIA ANGELO CELLI 23A1 – 00044 FRASCATI<br>
+                    TEL. 06.9416491 – FAX 06.94010040<br>
+                    PEC: polizialocalefrascati@legalmail.it
+                </h3>
+                <img src="{{ public_path() }}/images/logo_pdf.png" width="250">
+                <h2>DOCUMENTAZIONE FOTOGRAFICA</h2>
+                <h4>Protocollo n. {{ $protocollo->protocollo_num }} / {{ $protocollo->protocollo_anno }}</h4>
             </td>
         </tr>
     </table>

+ 5 - 3
resources/views/pdf/verbale.blade.php

@@ -277,14 +277,16 @@
 
     <x-verbale.pedone.index :data="$data" />
 
-    <div class="page-break"></div>
-
     <x-verbale.testimoni.index :data="$data" />
 
-    <x-verbale.allegati.index :allegati="$data['allegati']" />
 
     <x-verbale.verbalizzanti.index :record="$data['record']" />
 
+    <div class="page-break"></div>
+
+    <x-verbale.allegati.index :allegati="$data['allegati']" :protocollo="$data['record']" />
+
+
     </table>
 
 </body>