@php $establishment = $document->establishment; $customer = $document->customer; $invoice = $document->invoice; //$path_style = app_path('CoreFacturalo'.DIRECTORY_SEPARATOR.'Templates'.DIRECTORY_SEPARATOR.'pdf'.DIRECTORY_SEPARATOR.'style.css'); $accounts = \App\Models\BankAccount::all(); $tittle = $document->prefix.'-'.str_pad($document->id, 8, '0', STR_PAD_LEFT); // Obtener establishment_id directamente - buscar logo según sucursal $establishment_id = null; // Prioridad 1: Del documento directamente if (method_exists($document, 'getAttribute')) { $establishment_id = $document->getAttribute('establishment_id'); } if (!$establishment_id && isset($document->establishment_id)) { $establishment_id = $document->establishment_id; } // Prioridad 2: Del establecimiento cargado if (!$establishment_id && $establishment) { if (is_object($establishment) && isset($establishment->id)) { $establishment_id = $establishment->id; } elseif (is_array($establishment) && isset($establishment['id'])) { $establishment_id = $establishment['id']; } } // Prioridad 3: Del usuario autenticado if (!$establishment_id && auth()->check()) { $user = auth()->user(); if ($user && isset($user->establishment_id)) { $establishment_id = $user->establishment_id; } } // Buscar logo específico del establecimiento $logo_full_path = null; if ($establishment_id) { // Buscar logosuc_{establishment_id}.jpg $logoSucPath = public_path("logos_de_sistema/logosuc_{$establishment_id}.jpg"); if (file_exists($logoSucPath) && is_readable($logoSucPath)) { $logo_full_path = $logoSucPath; } else { // Buscar avatar_logosuc_{establishment_id}.jpg $avatarLogoSucPathJpg = public_path("logos_de_sistema/avatar_logosuc_{$establishment_id}.jpg"); if (file_exists($avatarLogoSucPathJpg) && is_readable($avatarLogoSucPathJpg)) { $logo_full_path = $avatarLogoSucPathJpg; } else { // Buscar avatar_logosuc_{establishment_id}.png $avatarLogoSucPathPng = public_path("logos_de_sistema/avatar_logosuc_{$establishment_id}.png"); if (file_exists($avatarLogoSucPathPng) && is_readable($avatarLogoSucPathPng)) { $logo_full_path = $avatarLogoSucPathPng; } } } } // Si no se encontró logo específico, usar el logo pasado desde Template.php if (!$logo_full_path && isset($logo) && is_array($logo) && isset($logo['full_path']) && file_exists($logo['full_path'])) { $logo_full_path = $logo['full_path']; } // Fallback final: logo_sistema.jpg if (!$logo_full_path) { $logoSistemaPath = public_path("logos_de_sistema/logo_sistema.jpg"); if (file_exists($logoSistemaPath) && is_readable($logoSistemaPath)) { $logo_full_path = $logoSistemaPath; } } @endphp {{--{{ $tittle }}--}} {{----}} @include('print.partials.ticket_header', [ 'company' => $company ?? null, 'establishment' => $establishment ?? null, 'document' => $document ?? null, 'title' => 'COTIZACION', 'code' => $tittle ?? '', ]) @if($document->date_of_due) @endif @if($document->delivery_date) @endif @if ($customer->address !== '') @endif @if ($document->shipping_address) @endif @if ($customer->telephone) @endif @if ($document->payment_method_type) @endif @if ($document->account_number) @endif @if ($document->sale_opportunity) @endif @if ($document->description) @endif @if ($document->purchase_order) @endif @if ($document->quotation_id) @endif

Fecha:

{{ \Carbon\Carbon::parse($document->date_of_issue)->format('d-m-Y') }} Hora: {{ \Carbon\Carbon::parse($document->created_at)->format('h:m:s') }}

F. Vencimiento:

{{ $document->date_of_due }}

F. Entrega:

{{ $document->delivery_date }}

Cliente:

{{ $customer->name }}

{{ $customer->identity_document_type->description }}:

{{ $customer->number }}

DIRECCION:

{{ $customer->address }} {{ ($customer->district_id !== '-')? ', '.$customer->district->description : '' }} {{ ($customer->province_id !== '-')? ', '.$customer->province->description : '' }} {{ ($customer->department_id !== '-')? '- '.$customer->department->description : '' }}

Dir. Envío:

{{ $document->shipping_address }}

Teléfono:

{{ $customer->telephone }}

Pago:

{{ $document->payment_method_type->description }}

N° Cuenta:

{{ $document->account_number }}

O. Venta:

{{ $document->sale_opportunity->number_full }}

Atendido por:

{{ $document->user->name }}

Tratamiento:

{{ $document->description }}

Orden de Compra:

{{ $document->purchase_order }}

Cotización:

{{ $document->quotation->identifier }}

@foreach($document->items as $row) @endforeach @if($document->total_exportation > 0) @endif @if($document->total_free > 0) @endif @if($document->total_unaffected > 0) @endif @if($document->total_exonerated > 0) @endif @if($document->total_taxed > 0) @endif @if($document->total_discount > 0) @endif
CANTIDAD DESCRIPCIÓN P.UND__ TOTAL
@if(((int)$row->quantity != $row->quantity)) {{ $row->quantity }} @else {{ number_format($row->quantity, 0) }} @endif {!!$row->item->description!!} @if (!empty($row->item->presentation)) {!!$row->item->presentation->description!!} @endif @if($row->attributes) @foreach($row->attributes as $attr)
{!! $attr->description !!} : {{ $attr->value }} @endforeach @endif @if($row->discounts) @foreach($row->discounts as $dtos)
{{ $dtos->factor * 100 }}% {{$dtos->description }} @endforeach @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) }}
SUBTOTAL: {{ $document->currency_type->symbol }} {{ number_format($document->total_taxed, 2) }}
{{(($document->total_prepayment > 0) ? 'ANTICIPO':'DESCUENTO TOTAL')}}: {{ $document->currency_type->symbol }} {{ number_format($document->total_discount, 2) }}
IVA: {{ $document->currency_type->symbol }} {{ number_format($document->total_igv, 2) }}
TOTAL : {{ $document->currency_type->symbol }} {{ number_format($document->total,2) }}
DESCUENTO: {{ $document->currency_type->symbol }} {{ number_format($document->apply_discount, 2) }}
TOTAL A PAGAR: {{ $document->currency_type->symbol }} {{ number_format($document->total-$document->apply_discount, 2) }}
@foreach(array_reverse((array) $document->legends) as $row) @if ($row->code == "1000") @if (count((array) $document->legends)>1) @endif @else @endif @endforeach
Son: {{ $row->value }} {{ $document->currency_type->description }}
Leyendas
{{$row->code}}: {{ $row->value }}

@foreach($accounts as $account) {{$account->bank->description}} {{$account->currency_type->description}}
N°: {{$account->number}} @if($account->cci) - CCI: {{$account->cci}} @endif
@endforeach
Firma y Sello