@php $establishment = $document->establishment; $customer = $document->customer; $left = ($document->series) ? $document->series : $document->prefix; $tittle = $left.'-'.str_pad($document->number, 8, '0', STR_PAD_LEFT); // N° Expediente (Historia clínica), no N° documento $number_history = null; try { $patient_id = $document->customer_id ?? ($customer && isset($customer->id) ? $customer->id : null); $specialty_id = $document->specialty_id ?? null; $est_id = $document->establishment_id ?? ($establishment && isset($establishment->id) ? $establishment->id : null); if ($patient_id) { $q = \App\Models\History::where('patient_id', $patient_id)->whereNotNull('number_history'); if ($specialty_id) $q->where('specialty_id', $specialty_id); if ($est_id) $q->where('establishment_id', $est_id); $history = $q->latest('id')->first(); if ($history && $history->number_history) $number_history = $history->number_history; } } catch (\Throwable $e) { $number_history = null; } $establishment_id = $document->establishment_id ?? ($establishment->id ?? null); if ($establishment_id) { $establishment_db = \App\Models\Establishment::find($establishment_id); if ($establishment_db) { $establishment = $establishment_db; } } $establishment_name = ''; if ($establishment && !empty($establishment->description) && $establishment->description !== '-') { $establishment_name = (string) $establishment->description; } else { $establishment_name = 'SIN ESTABLECIMIENTO'; } $logo_a4_base64 = null; $logo_a4_mime = 'image/jpeg'; $logo_a4_path = null; if (isset($logo) && is_array($logo) && !empty($logo['full_path']) && file_exists($logo['full_path']) && is_readable($logo['full_path']) && @filesize($logo['full_path']) > 0) { $logo_a4_path = $logo['full_path']; $raw = @file_get_contents($logo_a4_path); if ($raw !== false && $raw !== '') { $logo_a4_base64 = base64_encode($raw); $ext = strtolower(pathinfo($logo_a4_path, PATHINFO_EXTENSION)); $logo_a4_mime = in_array($ext, ['png', 'webp']) ? "image/{$ext}" : 'image/jpeg'; } } if (!$logo_a4_base64) { $eid = isset($document->establishment_id) ? $document->establishment_id : (isset($establishment->id) ? $establishment->id : null); $candidates = []; if ($eid) { $bases = [base_path('media/logos'), public_path('logos_de_sistema')]; $names = [ "logosuc_{$eid}.jpg", "logosuc_{$eid}.jpeg", "logosuc_{$eid}.png", "logosuc_{$eid}.webp", "avatar_logosuc_{$eid}.jpg", "avatar_logosuc_{$eid}.jpeg", "avatar_logosuc_{$eid}.png", "avatar_logosuc_{$eid}.webp", ]; foreach ($bases as $baseDir) { foreach ($names as $fileName) { $candidates[] = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fileName; } } } if ($company && !empty($company->logo)) { $company_logo = ltrim((string) $company->logo, '/\\'); $candidates[] = base_path($company_logo); $candidates[] = public_path($company_logo); } foreach ([base_path('media/logos'), public_path('logos_de_sistema')] as $baseDir) { foreach (['logo_sistema.jpg', 'logo_sistema.jpeg', 'logo_sistema.png', 'logo_sistema.webp'] as $fileName) { $candidates[] = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fileName; } } foreach ($candidates as $path) { if (is_string($path) && $path !== '' && file_exists($path) && is_readable($path) && @filesize($path) > 0) { $logo_a4_path = $path; $raw = @file_get_contents($logo_a4_path); if ($raw !== false && $raw !== '') { $logo_a4_base64 = base64_encode($raw); $ext = strtolower(pathinfo($logo_a4_path, PATHINFO_EXTENSION)); $logo_a4_mime = in_array($ext, ['png', 'webp']) ? "image/{$ext}" : 'image/jpeg'; break; } } } } @endphp
{{--|
|
@else
@endif |
{{ $establishment_name }}{{ ($establishment->trade_address !== '-')? ' DIRECCION: '.$establishment->trade_address : '' }} {{ ($establishment->district_id !== '-')? ', '.$establishment->district->description : '' }} {{ ($establishment->province_id !== '-')? ', '.$establishment->province->description : '' }} {{ ($establishment->department_id !== '-')? '- '.$establishment->department->description : '' }}{{ ($establishment->email !== '-')? 'Email: ' .$establishment->email : '' }}{{ ($establishment->telephone !== '-')? 'TELEFONO.: '.$establishment->telephone : '' }} |
FACTURA{{ $tittle }} |
| Paciente: | {{ $customer->name }} | N° Expediente: | {{ $number_history ? str_pad($number_history, 7, "0", STR_PAD_LEFT) : '' }} |
| Telefono: | {{ $customer->telephone }} | Fecha Emisión | {{ $document->date_of_issue->format('d-m-Y') }} |
| DIRECCION: | {{ $customer->address }} {{ ($customer->district_id !== '-')? ', '.$customer->district->description : '' }} {{ ($customer->province_id !== '-')? ', '.$customer->province->description : '' }} {{ ($customer->department_id !== '-')? '- '.$customer->department->description : '' }} | ||
| Estado: | CANCELADO | ||
| Estado: | PENDIENTE DE PAGO | ||
| OBSERVACION: | {{trim($document->observation)}} | ||
| {{ $guide->document_type_description }} | @else{{ $guide->document_type_id }} | @endif: | {{ $guide->number }} |
| CANTIDAD | DESCRIPCIÓN | P. UND | DTO. | TOTAL | |
|---|---|---|---|---|---|
| @if(((int)$row->quantity != $row->quantity)) {{ $row->quantity }} @else {{ number_format($row->quantity, 0) }} @endif |
@if(isset($row->item) && isset($row->item->description))
{!! $row->item->description !!}
@endif
@if (!empty($row->item->presentation) && isset($row->item->presentation->description))
{!! $row->item->presentation->description !!}
@endif
@if($row->attributes)
@foreach($row->attributes as $attr)
@if(isset($attr->description))
{!! $attr->description !!} : {{ $attr->value ?? '' }} @endif @endforeach @endif @if($row->discounts) @foreach($row->discounts as $dtos) @if(isset($dtos->description)) {{ $dtos->factor * 100 }}% {{ $dtos->description }} @endif @endforeach @endif @if($row->item->is_set == 1) @inject('itemSet', 'App\Services\ItemSetService') {{ join("-", $itemSet->getItemsSet($row->item_id)) }} @endif |
{{ number_format($row->unit_price, 2) }} | {{ number_format($row->total, 2) }} | ||
| OP. EXPORTACIÓN: {{ $document->currency_type->symbol }} | {{ number_format($document->total_exportation, 2) }} | ||||
| OP. GRATUITAS: {{ $document->currency_type->symbol }} | {{ number_format($document->total_free, 2) }} | ||||
| OP. INAFECTAS: {{ $document->currency_type->symbol }} | {{ number_format($document->total_unaffected, 2) }} | ||||
| OP. EXONERADAS: {{ $document->currency_type->symbol }} | {{ number_format($document->total_exonerated, 2) }} | ||||
| {{(($document->total_prepayment > 0) ? 'ANTICIPO':'DESCUENTO TOTAL')}}: {{ $document->currency_type->symbol }} | {{ number_format($document->total_discount, 2) }} | ||||
| TOTAL A PAGAR: {{ $document->currency_type->symbol }} | {{ number_format($document->total, 2) }} | ||||