diff --git a/app/Enums/Claims/ClaimExportFormat.php b/app/Enums/Claims/ClaimExportFormat.php index fae0a4b..c58db75 100644 --- a/app/Enums/Claims/ClaimExportFormat.php +++ b/app/Enums/Claims/ClaimExportFormat.php @@ -8,32 +8,78 @@ enum ClaimExportFormat: int { use BaseEnum; - case csv = 1; - case pdf = 2; + case csv = 1; + case csvWithoutAttachment = 2; + case pdf = 3; /** * Optionnal labels definition */ private const LABELS = [ - self::csv->name => 'CSV', - self::pdf->name => 'PDF', + self::csv->name => 'csv', + self::csvWithoutAttachment->name => 'csv sans pièces jointes', + self::pdf->name => 'pdf', ]; - public function class() + /** + * Bootstrap color class to use for the export buttons. + * + * @return string + */ + public function class(): string { return match ($this) { - self::csv => 'success', - self::pdf => 'danger', - default => 'primary', + self::csv, + self::csvWithoutAttachment => 'success', + self::pdf => 'danger', + default => 'primary', }; } - public function picto() + /** + * Font Awesome picto to use for the export buttons. + * + * @return string + */ + public function picto(): string { return match ($this) { - self::csv => 'fa-solid fa-file-csv', - self::pdf => 'fa-solid fa-file-pdf', - default => 'fa-solid fa-file', + self::csv, + self::csvWithoutAttachment => 'fa-solid fa-file-csv', + self::pdf => 'fa-solid fa-file-pdf', + default => 'fa-solid fa-file', + }; + } + + + /** + * File headers to use when the exported file is return with StreamedResponse. + * + * @return array + */ + public function fileHeaders(): array + { + return match ($this) { + self::csv, + self::csvWithoutAttachment => [ + 'Content-Type' => 'text/csv', + 'Content-Disposition' => 'attachment; filename="export.csv"', + ], + default => [], + }; + } + + /** + * Export file name. + * + * @return string + */ + public function fileName(): string + { + return match ($this) { + self::csv, + self::csvWithoutAttachment => 'export.csv', + self::pdf => 'export.pdf', }; } } diff --git a/app/Http/Controllers/Api/V4/ClaimController.php b/app/Http/Controllers/Api/V4/ClaimController.php index 784127c..f2e5fd2 100644 --- a/app/Http/Controllers/Api/V4/ClaimController.php +++ b/app/Http/Controllers/Api/V4/ClaimController.php @@ -24,7 +24,7 @@ class ClaimController extends Controller { $claimModel = (new Claim())->fill(Arr::except($request->validated(), 'file')); if ($request->filled('file')) { - $claimModel->file = FileHelper::storeBase64File('claim', $request->file); + $claimModel->file = FileHelper::storeBase64File('claim', $request->file, private: true); } if (!$claimModel->saveOrFail()) { diff --git a/app/Http/Controllers/Bo/ClaimController.php b/app/Http/Controllers/Bo/ClaimController.php index e6847b8..b426958 100644 --- a/app/Http/Controllers/Bo/ClaimController.php +++ b/app/Http/Controllers/Bo/ClaimController.php @@ -23,10 +23,13 @@ use App\Traits\Controllers\UpdateModelPublished; use Barryvdh\DomPDF\Facade\Pdf; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Symfony\Component\HttpFoundation\StreamedResponse; use Uwil\LaravelCommon\Helpers\CollectionHelper; +use ZipArchive; class ClaimController extends Controller { @@ -231,55 +234,219 @@ class ClaimController extends Controller // * EXPORT /** - * CSV File headers + * Export claim datas to a given format * - * @var array + * @param ExportClaimRequest $request + * @return \Illuminate\Http\Response|Symfony\Component\HttpFoundation\StreamedResponse|\Illuminate\Http\RedirectResponse */ - private $header = [ - "Prénom NOM", - "Email", - "Adresse", - "Date de création", - "Sujet", - "Statut", - "Message", - "Pièce jointe", - ]; - public function export(ExportClaimRequest $request) { + /** @var \Illuminate\Database\Eloquent\Collection $claims*/ $claims = Claim::query()->whereIn('id', $request->validated('claimList'))->get(); $format = ClaimExportFormat::from($request->validated('format')); - if ($format->equals(ClaimExportFormat::csv)) { - $csvlines[] = $this->header; - foreach ($claims as $claim) { - $csvlines[] = $this->fillLine($claim); + // * CSV + if ($format->equals(ClaimExportFormat::csvWithoutAttachment, ClaimExportFormat::csv)) { + $csv = $this->generateCsv($claims); + if (!$this->needsZip($format, $claims)) { + return new StreamedResponse(function () use ($format, $csv) { + echo $csv; + }, 200, $this->getFileHeaders($format)); } - - return new StreamedResponse(function() use ($csvlines) { - $this->array2csv($csvlines, ';'); - }, 200, [ - 'Content-Type' => 'text/csv', - 'Content-Disposition' => 'attachment; filename="export.csv"', - ]); + return $this->returnStreamedZip($format, $claims, $csv); + // * PDF } elseif ($format->equals(ClaimExportFormat::pdf)) { - $pdf = Pdf::loadView('bo.pages.claims.pdf', [ - 'claimModels' => $claims - ]); - return $pdf->download('export.pdf'); - }; + $pdf = $this->generatePdf($claims); - return back()->with('error', __('Une erreur est survenue lors de l\'export. Veuillez réessayer en rafraîchissant la page.')); + if (!$this->needsZip(ClaimExportFormat::pdf, $claims)) { + return $pdf->download('export.pdf'); + } + return $this->returnStreamedZip($format, $claims, $pdf->output()); + } else { + return back()->with( + 'error', + __('Une erreur est survenue lors de l\'export. Veuillez réessayer en rafraîchissant la page.') + ); + }; //end if } + /** + * Check if the export needs to be in a .zip file. + * + * @param ClaimExportFormat $format + * @param \Illuminate\Database\Eloquent\Collection $claims + * @return boolean + */ + private function needsZip(ClaimExportFormat $format, \Illuminate\Database\Eloquent\Collection $claims): bool + { + /** + * .zip is needed for : + * - csv with any files + * - pdf with files other than pictures + */ + if ($format->equals(ClaimExportFormat::csv)) { + return $claims->whereNotNull('file')->pluck('file')->isNotEmpty(); + } elseif ($format->equals(ClaimExportFormat::pdf)) { + return $claims + ->whereNotNull('file') + ->whereNotIn('file_extension', ['jpg', 'jpeg', 'png']) + ->isNotEmpty(); + } + + return false; + } + + /** + * Create the zip folder for the export with the main file inside. + * + * @param ZipArchive $zip + * @param string $file + * @param ClaimExportFormat $format + * @return string|false + * + * @throws \Exception If the zip opening failed. + */ + private function createExportZip(ZipArchive &$zip, string $file, ClaimExportFormat $format): string|false + { + $zipName = tempnam(Storage::disk('private')->path('export'), 'zip'); + if (!$zip->open($zipName, ZipArchive::OVERWRITE)) { + throw new \Exception(__('Couldn\'t open zip file.')); + }; + $zip->addFromString($format->fileName(), $file); + + return $zipName; + } + + /** + * Add attachments to zip + * + * @param ZipArchive $zip + * @param \Illuminate\Database\Eloquent\Collection $claims + * @param ClaimExportFormat $format + * @return void + */ + private function addAttachmentsToZip( + ZipArchive &$zip, + \Illuminate\Database\Eloquent\Collection $claims, + ClaimExportFormat $format + ) { + $claimsWithFilesToZip = $claims->whereNotNull('file') + ->when($format->equals(ClaimExportFormat::pdf), function ($collection) { + return $collection->whereNotIn('file_extension', ['jpg', 'jpeg', 'png']); + }); + foreach ($claimsWithFilesToZip as $claim) { + $filePath = $this->getPrivateFilePath($claim->file); + if (Storage::disk('private')->exists($filePath)) { + $zip->addFile( + Storage::disk('private')->path($filePath), + $claim->export_file_name + ); + } + } + } + + /** + * Return a StreamedResponse with a zip file. + * + * @param ClaimExportFormat $format + * @param \Illuminate\Database\Eloquent\Collection $claims + * @param string $file + * @return \Symfony\Component\HttpFoundation\StreamedResponse + */ + private function returnStreamedZip( + ClaimExportFormat $format, + \Illuminate\Database\Eloquent\Collection $claims, + string $file + ): \Symfony\Component\HttpFoundation\StreamedResponse { + return new StreamedResponse(function () use ($file, $claims, $format) { + // Create zip. + $zip = new ZipArchive(); + $zipName = $this->createExportZip($zip, $file, $format); + + // Add attachments. + $this->addAttachmentsToZip($zip, $claims, $format); + + $zip->close(); + readfile($zipName); + unlink($zipName); + }, 200, $this->getFileHeaders($format, true)); + } + + /** + * Generate PDF with claims. + * + * @param \Illuminate\Database\Eloquent\Collection $claims + * @return \Barryvdh\DomPDF\PDF + */ + private function generatePdf(\Illuminate\Database\Eloquent\Collection $claims): \Barryvdh\DomPDF\PDF + { + // Convert pictures to base64. + foreach ($claims->whereIn('file_extension', ['jpg', 'jpeg', 'png']) as $claim) { + $filePath = $this->getPrivateFilePath($claim->file); + $claim->fileBase64 = sprintf( + 'data:%s;base64,%s', + File::mimeType(Storage::disk('private')->path($filePath)), + base64_encode(Storage::disk('private')->get($filePath)) + ); + } + + // Create temp folder if it doesn't exists. Needed to allow base64 pictures to be displayed in pdf. + if (!Storage::disk('private')->exists('temp')) { + Storage::disk('private')->makeDirectory('temp'); + } + + return Pdf::setOptions(['tempDir' => Storage::disk('private')->path('temp')]) + ->loadView('bo.pages.claims.pdf', [ + 'claimModels' => $claims + ]); + } + + /** + * Generate claims CSV + * + * @param \Illuminate\Database\Eloquent\Collection $claims + * @return string|false + */ + private function generateCsv(\Illuminate\Database\Eloquent\Collection $claims) + { + // CSV Header. + $csvlines[] = [ + 'Référence', + 'Date de création', + 'Prénom NOM', + 'Email', + 'Adresse', + 'Statut', + 'Sujet', + 'Type', + 'Marque', + 'Message', + 'Pièce jointe', + ]; + + foreach ($claims as $claim) { + $csvlines[] = $this->fillLine($claim); + } + + return $this->array2csv($csvlines, ';'); + } + + /** + * Transform Array into CSV. + * + * @param array $lines + * @param string $delimiter + * @param string $enclosure + * @param string $escape_char + * @return string|false + */ private function array2csv( array $lines, string $delimiter = ',', string $enclosure = '"', string $escape_char = "\\" - ){ - $f = fopen('php://output', 'w'); + ) { + $f = fopen('php://temp', 'r+'); // UTF-8 BOM. $BOM = "\xEF\xBB\xBF"; @@ -289,27 +456,63 @@ class ClaimController extends Controller fputcsv($f, $item, $delimiter, $enclosure, $escape_char); } + rewind($f); + $csvContent = stream_get_contents($f); fclose($f); + + return $csvContent; } /** - * fill one line for csv - * @param \App\Models\Claim $claim + * Fill one line for csv. * + * @param \App\Models\Claim $claim * @return array */ private function fillLine(Claim $claim) { $oneline = [ + $claim->reference, + $claim->created_at->toDateTimeString(), sprintf('%s %s', $claim->first_name, Str::upper($claim->last_name)), $claim->email, sprintf('%s, %s, %s', $claim->address, $claim->postcode, $claim->city), - $claim->created_at->toDateTimeString(), - $claim->claimSubject->label, $claim->status->label(), + $claim->claimSubject->label, + $claim->type->label(), + $claim->brand->name, $claim->message, - asset($claim->file), + $claim->export_file_name, ]; return $oneline; } + + /** + * Get file path in private storage from stored path. + * + * @param string $basePath + * @return string + */ + private function getPrivateFilePath(string $basePath): string + { + return str($basePath)->replaceFirst('storage/app/private', ''); + } + + /** + * Get file headers to use with StreamedResponse. + * + * @param ClaimExportFormat $format + * @param boolean $isZip + * @return array + */ + private function getFileHeaders(ClaimExportFormat $format, bool $isZip = false): array + { + if ($isZip) { + return [ + 'Content-Type' => 'application/zip', + 'Content-Disposition' => 'attachment; filename="export.zip"', + ]; + }; + return $format->fileHeaders(); + } } diff --git a/app/Http/Requests/Bo/Claims/ExportClaimRequest.php b/app/Http/Requests/Bo/Claims/ExportClaimRequest.php index 37861a1..156674c 100644 --- a/app/Http/Requests/Bo/Claims/ExportClaimRequest.php +++ b/app/Http/Requests/Bo/Claims/ExportClaimRequest.php @@ -18,6 +18,11 @@ class ExportClaimRequest extends FormRequest return auth('backend')->check(); } + /** + * Prepare the data for validation. + * + * @return void + */ public function prepareForValidation() { $this->merge([ diff --git a/app/Models/Claim.php b/app/Models/Claim.php index 1a23fda..332aa2b 100644 --- a/app/Models/Claim.php +++ b/app/Models/Claim.php @@ -8,6 +8,7 @@ use App\Enums\Claims\ClaimType; use App\Events\ClaimModelChanged; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\File; use Illuminate\Support\Str; /** @@ -29,6 +30,9 @@ use Illuminate\Support\Str; * @property string|null $hashcode Claim associated Customer hashcode. * @property-read \Illuminate\Support\Carbon $created_at Claim created date. * @property-read \Illuminate\Support\Carbon $updated_at Claim updated date. + * + * @property-read string $file_extension Extension of the file. + * @property-read string $export_file_name Name of the exported file. */ class Claim extends Model { @@ -199,4 +203,32 @@ class Claim extends Model trim(implode(' ', array_filter([$this->postcode, $this->city]))) ])); } + + // * VIRTUAL ATTRIBUTES + + /** + * 'file_extension' virtual property. + * + * @return string + */ + public function getFileExtensionAttribute(): string + { + return File::extension($this->file); + } + + /** + * 'export_file_name' virtual property. + * + * @return string + */ + public function getExportFileNameAttribute(): string + { + return $this->file ? + sprintf( + '%s.%s', + $this->reference, + $this->file_extension, + ) : + __('Aucune pièce jointe'); + } } diff --git a/config/dompdf.php b/config/dompdf.php new file mode 100644 index 0000000..dcdf60c --- /dev/null +++ b/config/dompdf.php @@ -0,0 +1,304 @@ + true, + + // Override the public path if needed. + 'public_path' => null, + + // Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £. + 'convert_entities' => true, + + 'options' => [ + /** + * The location of the DOMPDF font directory + * + * The location of the directory where DOMPDF will store fonts and font metrics + * Note: This directory must exist and be writable by the webserver process. + * *Please note the trailing slash.* + * + * Notes regarding fonts: + * Additional .afm font metrics can be added by executing load_font.php from command line. + * + * Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must + * be embedded in the pdf file or the PDF may not display correctly. This can significantly + * increase file size unless font subsetting is enabled. Before embedding a font please + * review your rights under the font license. + * + * Any font specification in the source HTML is translated to the closest font available + * in the font directory. + * + * The pdf standard "Base 14 fonts" are: + * Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique, + * Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique, + * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic, + * Symbol, ZapfDingbats. + */ + + // Advised by dompdf (https://github.com/dompdf/dompdf/pull/782). + 'font_dir' => storage_path('fonts'), + + /** + * The location of the DOMPDF font cache directory + * + * This directory contains the cached font metrics for the fonts used by DOMPDF. + * This directory can be the same as DOMPDF_FONT_DIR + * + * Note: This directory must exist and be writable by the webserver process. + */ + 'font_cache' => storage_path('fonts'), + + /** + * The location of a temporary directory. + * + * The directory specified must be writeable by the webserver process. + * The temporary directory is required to download remote images and when + * using the PDFLib back end. + */ + 'temp_dir' => sys_get_temp_dir(), + + /** + * ==== IMPORTANT ==== + * + * dompdf's "chroot": Prevents dompdf from accessing system files or other + * files on the webserver. All local files opened by dompdf must be in a + * subdirectory of this directory. DO NOT set it to '/' since this could + * allow an attacker to use dompdf to read any files on the server. This + * should be an absolute path. + * This is only checked on command line call by dompdf.php, but not by + * direct class use like: + * $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output(); + */ + 'chroot' => realpath(base_path()), + + /** + * Protocol whitelist + * + * Protocols and PHP wrappers allowed in URIs, and the validation rules + * that determine if a resouce may be loaded. Full support is not guaranteed + * for the protocols/wrappers specified + * by this array. + * + * @var array + */ + 'allowed_protocols' => [ + 'data://' => ['rules' => []], + 'file://' => ['rules' => []], + 'http://' => ['rules' => []], + 'https://' => ['rules' => []], + ], + + /** + * Operational artifact (log files, temporary files) path validation + */ + 'artifactPathValidation' => null, + + /** + * @var string + */ + 'log_output_file' => null, + + /** + * Whether to enable font subsetting or not. + */ + 'enable_font_subsetting' => false, + + /** + * The PDF rendering backend to use + * + * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and + * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will + * fall back on CPDF. 'GD' renders PDFs to graphic files. + * {@link * Canvas_Factory} ultimately determines which rendering class to + * instantiate based on this setting. + * + * Both PDFLib & CPDF rendering backends provide sufficient rendering + * capabilities for dompdf, however additional features (e.g. object, + * image and font support, etc.) differ between backends. Please see + * {@link PDFLib_Adapter} for more information on the PDFLib backend + * and {@link CPDF_Adapter} and lib/class.pdf.php for more information + * on CPDF. Also see the documentation for each backend at the links + * below. + * + * The GD rendering backend is a little different than PDFLib and + * CPDF. Several features of CPDF and PDFLib are not supported or do + * not make any sense when creating image files. For example, + * multiple pages are not supported, nor are PDF 'objects'. Have a + * look at {@link GD_Adapter} for more information. GD support is + * experimental, so use it at your own risk. + * + * @link http://www.pdflib.com + * @link http://www.ros.co.nz/pdf + * @link http://www.php.net/image + */ + 'pdf_backend' => 'CPDF', + + /** + * html target media view which should be rendered into pdf. + * List of types and parsing rules for future extensions: + * http://www.w3.org/TR/REC-html40/types.html + * screen, tty, tv, projection, handheld, print, braille, aural, all + * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3. + * Note, even though the generated pdf file is intended for print output, + * the desired content might be different (e.g. screen or projection view of html file). + * Therefore allow specification of content here. + */ + 'default_media_type' => 'screen', + + /** + * The default paper size. + * + * North America standard is "letter"; other countries generally "a4" + * + * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.) + */ + 'default_paper_size' => 'a4', + + /** + * The default paper orientation. + * + * The orientation of the page (portrait or landscape). + * + * @var string + */ + 'default_paper_orientation' => 'portrait', + + /** + * The default font family + * + * Used if no suitable fonts can be found. This must exist in the font folder. + * + * @var string + */ + 'default_font' => 'serif', + + /** + * Image DPI setting + * + * This setting determines the default DPI setting for images and fonts. The + * DPI may be overridden for inline images by explictly setting the + * image's width & height style attributes (i.e. if the image's native + * width is 600 pixels and you specify the image's width as 72 points, + * the image will have a DPI of 600 in the rendered PDF. The DPI of + * background images can not be overridden and is controlled entirely + * via this parameter. + * + * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI). + * If a size in html is given as px (or without unit as image size), + * this tells the corresponding size in pt. + * This adjusts the relative sizes to be similar to the rendering of the + * html page in a reference browser. + * + * In pdf, always 1 pt = 1/72 inch + * + * Rendering resolution of various browsers in px per inch: + * Windows Firefox and Internet Explorer: + * SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:? + * Linux Firefox: + * about:config *resolution: Default:96 + * (xorg screen dimension in mm and Desktop font dpi settings are ignored) + * + * Take care about extra font/image zoom factor of browser. + * + * In images, size in pixel attribute, img css style, are overriding + * the real image dimension in px for rendering. + * + * @var int + */ + 'dpi' => 96, + + /** + * Enable embedded PHP + * + * If this setting is set to true then DOMPDF will automatically evaluate embedded PHP contained + * within tags. + * + * ==== IMPORTANT ==== Enabling this for documents you do not trust (e.g. arbitrary remote html pages) + * is a security risk. + * Embedded scripts are run with the same level of system access available to dompdf. + * Set this option to false (recommended) if you wish to process untrusted documents. + * This setting may increase the risk of system exploit. + * Do not change this settings without understanding the consequences. + * Additional documentation is available on the dompdf wiki at: + * https://github.com/dompdf/dompdf/wiki + * + * @var bool + */ + 'enable_php' => false, + + /** + * Rnable inline JavaScript + * + * If this setting is set to true then DOMPDF will automatically insert JavaScript code contained + * within tags as written into the PDF. + * NOTE: This is PDF-based JavaScript to be executed by the PDF viewer, + * not browser-based JavaScript executed by Dompdf. + * + * @var bool + */ + 'enable_javascript' => true, + + /** + * Enable remote file access + * + * If this setting is set to true, DOMPDF will access remote sites for + * images and CSS files as required. + * + * ==== IMPORTANT ==== + * This can be a security risk, in particular in combination with isPhpEnabled and + * allowing remote html code to be passed to $dompdf = new DOMPDF(); $dompdf->load_html(...); + * This allows anonymous users to download legally doubtful internet content which on + * tracing back appears to being downloaded by your server, or allows malicious php code + * in remote html pages to be executed by your server with your account privileges. + * + * This setting may increase the risk of system exploit. Do not change + * this settings without understanding the consequences. Additional + * documentation is available on the dompdf wiki at: + * https://github.com/dompdf/dompdf/wiki + * + * @var bool + */ + 'enable_remote' => false, + + /** + * List of allowed remote hosts + * + * Each value of the array must be a valid hostname. + * + * This will be used to filter which resources can be loaded in combination with + * isRemoteEnabled. If enable_remote is FALSE, then this will have no effect. + * + * Leave to NULL to allow any remote host. + * + * @var array|null + */ + 'allowed_remote_hosts' => null, + + /** + * A ratio applied to the fonts height to be more like browsers' line height + */ + 'font_height_ratio' => 1.1, + + /** + * Use the HTML5 Lib parser + * + * @deprecated This feature is now always on in dompdf 2.x + * + * @var bool + */ + 'enable_html5_parser' => true, + ], + +]; diff --git a/resources/views/bo/modules/claim-tools.blade.php b/resources/views/bo/modules/claim-tools.blade.php index 91b5947..96d3777 100644 --- a/resources/views/bo/modules/claim-tools.blade.php +++ b/resources/views/bo/modules/claim-tools.blade.php @@ -41,7 +41,7 @@ @endforeach diff --git a/resources/views/bo/pages/claims/pdf.blade.php b/resources/views/bo/pages/claims/pdf.blade.php index a3fe59a..78efe28 100644 --- a/resources/views/bo/pages/claims/pdf.blade.php +++ b/resources/views/bo/pages/claims/pdf.blade.php @@ -1,24 +1,44 @@ - + + -@foreach($claimModels as $claimModel) -

{{ __('Référence') }} : {{ $claimModel->reference }}

-

{{ __('Date de la demande') }} : {{ $claimModel->created_at->toDateString() }}

-

{{ __('Prénom NOM') }} : {{ $claimModel->first_name }} {{ str($claimModel->last_name)->upper() }}

-

{{ __('Email') }} : {{ $claimModel->email }}

-

{{ __('Adresse') }} : {{ sprintf('%s, %s, %s', $claimModel->address, $claimModel->postcode, $claimModel->city) }}

-

{{ __('Statut de la réclamation') }} : {{ $claimModel->status->label() }}

-

{{ __('Sujet de la réclamation') }} : {{ $claimModel->claimSubject->label }}

-

{{ __('Type de demande') }} : {{ $claimModel->type->label() }}

-

{{ __('Marque concernée') }} : {{ $claimModel->brand->name }}

-

{{ __('Message') }} : {{ $claimModel->message }}

-

{{ __('Voir la pièce jointe') }} : {{ __('Cliquez ici') }}

+ + + + + -@if (!$loop->last) -
-@endif + + @foreach($claimModels as $claimModel) +

{{ __('Référence') }} : {{ $claimModel->reference }}

+

{{ __('Date de la demande') }} : {{ $claimModel->created_at->toDateString() }}

+

{{ __('Prénom NOM') }} : {{ $claimModel->first_name }} {{ str($claimModel->last_name)->upper() }}

+

{{ __('Email') }} : {{ $claimModel->email }}

+

{{ __('Adresse') }} : {{ sprintf('%s, %s, %s', $claimModel->address, $claimModel->postcode, $claimModel->city) }}

+

{{ __('Statut de la réclamation') }} : {{ $claimModel->status->label() }}

+

{{ __('Sujet de la réclamation') }} : {{ $claimModel->claimSubject->label }}

+

{{ __('Type de demande') }} : {{ $claimModel->type->label() }}

+

{{ __('Marque concernée') }} : {{ $claimModel->brand->name }}

+

{{ __('Message') }} : {{ $claimModel->message }}

+ {{-- ATTACHMENT --}} + @if ($claimModel->file_extension) + @if (in_array($claimModel->file_extension, ['jpg', 'jpeg', 'png'])) +

{{ __('Image') }} :

+ + @else +

{{ __('Nom de la pièce jointe') }} : {{ $claimModel->export_file_name }}

+ @endif + @else +

{{ __('Aucune pièce jointe.') }}

+ @endif -@endforeach + {{-- Page break between every claim. --}} + @if (!$loop->last) +
+ @endif + @endforeach + +