ldc-boutique-cnc/resources/views/documents/order-invoice.blade.php
2023-03-22 17:17:55 +01:00

358 lines
14 KiB
PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{ $title }}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
html,
body {
/** page margins : 5mm */
position: relative;
width: 200mm;
height: 287mm;
margin: 0;
padding: 0;
}
body {
color: #333333;
background-color: #FFFFFF;
}
table {
border-collapse: collapse;
}
#main-table {
margin: auto;
height: 274mm;
width: 100%;
/** Test Mise en page */
/* border-color: red;
border-width: 1px;
border-style: solid; */
}
/* 1pt=0,352778mm, 1pt=1.3333333333333333px font-size=10.5pt=13,9999999965px=3,704169mm*/
/* LOGO + INTRO LINES */
#top-row {
height: 132.28px; /* 35mm */
}
#addresses-row {
height: 170.078px; /* 45mm */
}
#billing-box {
float: right;
width: 321.259px; /* 85mm */
margin-right: 56.69px; /* 15mm */
padding-top: 3rem;
/** Test Mise en page */
/* background-color: rgb(253, 184, 255); */
}
#shipping-box {
height: 6rem; /* 7 lines */
margin-top: 0.5rem;
margin-bottom: 0.5rem;
text-align: center;
/** Test Mise en page */
/* background-color: rgb(215, 255, 135); */
}
#logo-container {
/** Test Mise en page */
/* border: 1px solid blue; */
}
#intro-lines-container {
/** Test Mise en page */
/* border: 1px solid purple; */
}
.logo-container-pages {
/** Test Mise en page */
/* border: 1px solid blue; */
}
.intro-lines-container-pages {
/** Test Mise en page */
/* border: 1px solid purple; */
}
#intro-lines {
font-size: 0.8rem;
}
.font-typed {
font-family: serif;
}
.font-upper {
text-transform: uppercase;
}
.font-spaced {
letter-spacing: 6px;
}
.font-amount {
font-family: serif;
text-transform: uppercase;
text-align: right;
}
.page-footer {
margin: auto;
/** Test Mise en page */
/* border-color: red;
border-width: 1px;
border-style: solid; */
}
.page-footer td {
padding-top: 2mm;
border-top:double medium #CCCCCC;
}
td.bold-cell,
th.bold-cell {
padding: 1mm;
border: 1px solid #333333;
background-color: #dadada;
font-weight: bold;
text-align: center;
}
td.bordered-cell,
th.bordered-cell {
border: 1px solid #333333;
}
table.bordered,
table.bordered thead,
table.bordered body,
table.bordered td,
table.bordered th {
border: 1px solid;
border-color: #333333;
}
table.bordered td,
table.bordered th {
padding-left: 1mm;
padding-right: 1mm;
}
table.bordered td {
border-top: none;
border-bottom: none;
border-color: #333333;
}
@page {
footer: page-footer;
}
</style>
</head>
@php
$customerIsRefunded = !$transactionType->equals(\App\Enums\Order\TransactionType::debit());
$amountPrefix = $customerIsRefunded ? '- ' : '';
@endphp
<body>
<div id="main-table" cellpadding="0" cellspacing="0">
{{-- LOGO and INTROLINES FROM GENERAL CONFIGS --}}
<div id="top-row">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
{{-- LOGO --}}
<td id="logo-container" valign="middle" width="25%" style="text-align: center;height: 30mm;">
<img style="width: 26mm;" src="{{ $logo }}" alt="{{ config('app.name') }}"/>
</td>
{{-- INTROLINES --}}
<td id="intro-lines-container" width="75%" style="text-align: center;">
<h1>{{ config('app.name') }}</h1>
<p id="intro-lines">
@foreach ($introLines as $introLine)
<span>{{ $introLine }}</span>
@if(!$loop->last)<br />@endif
@endforeach
</p>
</td>
</tr>
</table>
</div>
{{-- SHIPPING AND BILLING --}}
<div id="billing-box" class="font-typed font-upper">
<strong>{{ Str::limit(Str::transliterate($billing->lastname) . ' '. Str::transliterate($billing->firstname), 37, '.') }}</strong><br/>
{{ Str::limit(Str::transliterate($billing->line1), 37, '.') }}<br/>
@if(!empty($billing->line2)){{ Str::limit(Str::transliterate($billing->line2), 37, '.') }}<br/>@endif
{!! Str::limit(Str::transliterate(clean($billing->postal_code)) . '&nbsp;&nbsp;'. Str::transliterate(clean($billing->city)), 37, '.') !!}
</div>
<div id="addresses-row">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
{{-- TYPE --}}
<td width="80%" class="bold-cell font-spaced">
<h2>@if(!$customerIsRefunded){{
Str::upper(__('Facture'))
}}@else{{
Str::upper(__('Avoir'))
}}@endif</h2>
</td>
{{-- BILLING --}}
<td rowspan="4" valign="middle">&nbsp;</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr><td class="bold-cell"><h3>{{ Str::upper(__('Adresse de livraison')) }}</h3></td></tr>
{{-- SHIPPING --}}
<tr><td id="shipping-box" class="bordered-cell font-typed font-upper">
<strong>{{ Str::transliterate($shipping->lastname) }} {{ Str::transliterate($shipping->firstname) }}</strong><br/>
{{ Str::transliterate($shipping->line1) }}<br/>
@if(!empty($shipping->line2)){{ Str::transliterate($shipping->line2) }}<br/>@endif
{{ Str::transliterate($shipping->postal_code) }} {{ Str::transliterate($shipping->city) }}
</td></tr>
</table>
</div>
{{-- DATE AND REFERENCES --}}
<table class="bordered" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="bold-cell">{{ __('Date') }}</td>
<td class="font-typed font-upper" style="text-align: center;">{{
Carbon\Carbon::parse($created_at)->isoFormat('DD\/MM\/YYYY')
}}</td>
<td class="bold-cell">{{ __('N° Commande') }}</td>
<td class="font-typed font-upper" style="text-align: center;">{{ $orderReference }}</td>
<td class="bold-cell">{{ __('N° Facture') }}</td>
<td class="font-typed font-upper" style="text-align: center;">{{ $transactionReference }}</td>
</tr>
</tr>
</table>
@php
$basket = collect($basket);
$hasTaxes = !empty($totalTaxes) ? true : false;
$columns = 4 + ($hasTaxes ? 1 : 0);
$page = 1;
$perPage = 15;
$perPageAfterFirstPage = 22;
$lastPage = \App\Lib\Helpers\CollectionHelper::paginateManually(collect($basket), $perPage)->lastPage();
@endphp
@while($lastPage >= $page)
@php $basketPagedList = \App\Lib\Helpers\CollectionHelper::paginateManually(collect($basket), $perPage, $page); @endphp
@if($page !== 1)
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
{{-- LOGO --}}
<td class="logo-container-pages" valign="middle" width="25%" style="text-align: center;height: 15mm;">
<img style="width: 16mm;" src="{{ $logo }}" alt="{{ config('app.name') }}"/>
</td>
{{-- APPNAME --}}
<td class="intro-lines-container-pages" width="75%" style="text-align: center;">
<h2>{{ config('app.name') }}</h2>
</td>
</tr>
</table>
@endif
<table class="bordered" width="100%" cellspacing="0" cellpadding="2" @if($page !== 1) style="margin-top: 5mm;" @endif>
{{-- TABLE HEADER --}}
<thead>
<tr>
<th width="40%" class="bold-cell font-upper"><strong>{{ __('Désignation') }}</strong></th>
<th class="bold-cell font-upper"><strong>{{ __('Qte') }}</strong></th>
<th class="bold-cell font-upper"><strong>{{ __('Prix U. TTC') }}</strong></th>
@if($hasTaxes)
<th class="bold-cell font-upper"><strong>{{ __('Tva') }}</strong></th>
@endif
<th class="bold-cell font-upper"><strong>{{ __('S.Tot TTC') }}</strong></th>
</tr>
</thead>
<tbody>
@foreach($basketPagedList as $basketItem)
<tr>
<td valign="top" class="font-typed">
<strong>{{ Str::limit($basketItem->name, 45, '.') }}</strong><br />
<i>{{ $basketItem->options->reference }}</i>
</td>
<td valign="top" class="font-amount">{{ $amountPrefix }}{{ $basketItem->qty }}</td>
<td valign="top" class="font-amount">{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($basketItem->options->price_ttc, '') }}</td>
@if($hasTaxes)
<td valign="top" class="font-amount">{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($basketItem->tax, '') }}</td>
@endif
<td valign="top" class="font-amount">{{ $amountPrefix }}{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($basketItem->subtotal, '') }}</td>
</tr>
@endforeach
@for ($i = $perPage - $basketPagedList->count(); $i > 0; $i--)
<tr>
@for ($k = $columns; $k > 0; $k--)
<td valign="top">&nbsp;<br>&nbsp;</td>
@endfor
</tr>
@endfor
</tbody>
</table>
@php $page++; $perPage = $perPageAfterFirstPage; $lastPage = \App\Lib\Helpers\CollectionHelper::paginateManually(collect($basket), $perPage)->lastPage(); @endphp
@if($basketPagedList->currentPage() < $basketPagedList->lastPage())
<pagebreak>
@endif
@endwhile
<table width="100%" cellspacing="0" cellpadding="2">
<tr>
<td style="width:50%;"><strong>&nbsp;</strong></td>
<td>
<table width="100%" cellspacing="0" cellpadding="2">
@if($hasTaxes)
<tr>
<td align="right"><u>{{ __('Tva') }}</u></td>
<td align="right" class="font-amount">{{
\App\Lib\Helpers\ToolboxHelper::fmtCurrency($totalTaxes)
}}</td>
</tr>
@endif
<tr>
<td align="right"><strong>{{ __('Total TTC') }}</strong></td>
<td align="right" class="font-amount"><strong>{{ $amountPrefix }}{{
\App\Lib\Helpers\ToolboxHelper::fmtCurrency($totalTtc)
}}</strong></td>
</tr>
</table>
</td>
</tr>
</table>
@if(!$hasTaxes)
<table width="100%" style="height: 10mm;">
<tr>
<td style="text-align:justify;">
{{ __('TVA non applicable, article 293B du code général des impôts') }}</td>
</tr>
</table>
@endif
</div>
<htmlpagefooter name="page-footer">
<table width="100%" cellspacing="0" cellpadding="2" class="page-footer">
<tr>
<td width="16%" style="text-align: right;" valign="top">
{{ __('N° Commande') }}&nbsp;:<br/>
{{ __('N° Facture') }}&nbsp;&nbsp;:
</td>
<td width="22%">
<span>{{ $orderReference }}</span><br/>
<span>{{ $transactionReference }}</span>
</td>
<td width="45%" style="text-align: right;">&nbsp;</td>
<td width="7%" style="text-align: right;">
<span>{{ __('date') }}&nbsp;:</span>
<span>{{ __('page') }}&nbsp;:</span>
</td>
<td valign="bottom" width="10%" style="text-align: left;">
<span>{{ Carbon\Carbon::parse($created_at)->isoFormat('DD\/MM\/YY') }}</span>
<span>{PAGENO}&nbsp;/&nbsp;{nbpg}</span>
</td>
</tr>
</table>
</htmlpagefooter>
</body>
</html>