|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <?php
-
- use common\helpers\Price;
- use domain\Order\Order\Order;
- use yii\helpers\Html;
-
- $producerModule = $this->getProducerModule();
- $userModule = $this->getUserModule();
- $documentModule = $this->getDocumentModule();
- $orderModule = $this->getOrderModule();
- $deliveryNoteModule = $this->getDeliveryNoteModule();
-
- $isDocumentDeliveryNote = $documentModule->getSolver()->isDocumentDeliveryNote($document);
- $displayPrices = !$isDocumentDeliveryNote || ($isDocumentDeliveryNote && $producerModule->getConfig('document_display_prices_delivery_note'));
- $displayProductDescription = $producerModule->getConfig('document_display_product_description');
- $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price_decimals');
-
- ?>
-
- <div class="document-download">
-
- <div id="block-addresses">
- <div class="producer">
- <?php if (strlen($producer->logo)) : ?>
- <?php $optionDocumentWidthLogo = $producerModule->getSolver()->getConfig('option_document_width_logo'); ?>
- <div class="logo" style="width: <?= $optionDocumentWidthLogo ?: 100; ?>px;">
- <img src="<?= $producerModule->getUrlLogo($producer) ?>"/>
- </div>
- <?php endif; ?>
- <div class="address">
- <?= $producerModule->getFullAddressAsHtml($producer); ?>
- </div>
- <?php if (strlen($producer->document_infos_top)): ?>
- <div class="infos-top">
- <?= nl2br(Html::encode($producer->document_infos_top)) ?>
- </div>
- <?php endif; ?>
- </div>
- <div class="user">
- <?php if ($document->address && strlen($document->address) > 0): ?>
- <?= nl2br($document->address) ?>
- <?php else: ?>
- <?= $userModule->getFullAddress($document->user, true); ?>
- <?php endif; ?>
- </div>
- </div>
-
- <?php if($documentModule->getSolver()->isStatusDraft($document)): ?>
- <div class="block-is-draft">
- <?= $documentModule->getType($document); ?> non
- validé<?= ($documentModule->getType($document) == 'Facture') ? 'e' : '' ?></div>
- <?php endif; ?>
-
- <div id="block-infos-document">
- <div class="type">
- <strong><?= $documentModule->getType($document); ?></strong>
- </div>
- <div class="date">
- <strong>Date : </strong>
- <?= strftime('%d %B %Y', strtotime($document->date)) ?>
- </div>
- <?php if (strlen($document->reference)) : ?>
- <div class="reference">
- <strong>Référence : </strong>
- <?= $document->reference; ?>
- </div>
- <?php endif; ?>
- <div class="name">
- <strong>Libellé : </strong>
- <?= $document->name; ?>
- </div>
- <?php if ($documentModule->getSolver()->isDocumentInvoice($document)): ?>
- <?php $deliveryNotesUpdateArray = $deliveryNoteModule->getRepository()->findDeliveryNotesByInvoice($document); ?>
- <?php if($deliveryNotesUpdateArray && count($deliveryNotesUpdateArray)): ?>
- <strong>Bons de livraison : </strong>
- <?php foreach($deliveryNotesUpdateArray as $key => $deliveryNote): ?>
- <?= $deliveryNote->reference ?><?php if ($key !== array_key_last($deliveryNotesUpdateArray)): ?>, <?php endif; ?>
- <?php endforeach; ?>
- <?php endif; ?>
- <?php endif; ?>
- <?php if (strlen($document->comment)): ?>
- <div class="comment">
- <br>
- <strong>Commentaire</strong><br>
- <?= Html::encode($document->comment) ?>
- </div>
- <?php endif; ?>
- </div>
-
- <div id="block-products">
- <?php if (count($document->orders) > 0) : ?>
- <table class="table table-bordered">
- <thead>
- <tr>
- <th class="align-left">Produit</th>
- <?php if ($displayPrices): ?>
- <?php if ($producer->taxRate->value == 0): ?>
- <th>Prix unitaire</th>
- <?php else: ?>
- <th>Prix unitaire HT</th>
- <?php endif; ?>
- <?php endif; ?>
- <th>Quantité</th>
- <?php if ($displayPrices): ?>
- <?php if ($producer->taxRate->value == 0): ?>
- <th>Prix</th>
- <?php else: ?>
- <th>TVA</th>
- <th>Prix HT</th>
- <?php endif; ?>
- <?php endif; ?>
-
- </tr>
- </thead>
- <tbody>
-
- <?php if ($producerModule->isDocumentDisplayOrders($document)): ?>
- <?php foreach ($document->orders as $order): ?>
- <tr>
- <td>
- <strong><?= $orderModule->getOrderUsername($order); ?></strong>
- <?php if ($order->distribution): ?>
- le <?= date('d/m/Y', strtotime($order->distribution->date)) ?>
- <?php endif; ?>
- </td>
- <?php if ($displayPrices): ?>
- <td class="align-center"></td>
- <?php endif; ?>
- <td></td>
- <?php if ($displayPrices): ?>
- <?php if ($producer->taxRate->value != 0): ?>
- <td class="align-center"></td>
- <?php endif; ?>
- <td class="align-center"></td>
- <?php endif; ?>
- </tr>
- <?php foreach ($order->productOrder as $productOrder): ?>
- <?= $this->render('_download_product_line', [
- 'producer' => $producer,
- 'document' => $document,
- 'productOrder' => $productOrder,
- 'displayOrders' => true,
- 'displayPrices' => $displayPrices,
- 'displayProductDescription' => $displayProductDescription,
- 'documentPriceDecimals' => $documentPriceDecimals
- ]) ?>
- <?php endforeach; ?>
- <?php endforeach; ?>
- <?php else: ?>
- <?php foreach ($documentModule->getProductsOrders($document, true) as $product): ?>
- <?php foreach ($product as $productOrder): ?>
- <?= $this->render('_download_product_line', [
- 'producer' => $producer,
- 'document' => $document,
- 'productOrder' => $productOrder,
- 'displayPrices' => $displayPrices,
- 'displayProductDescription' => $displayProductDescription,
- 'documentPriceDecimals' => $documentPriceDecimals
- ]) ?>
- <?php endforeach; ?>
- <?php endforeach; ?>
- <?php endif; ?>
- <?php if ($displayPrices): ?>
- <?php $typeAmount = $documentModule->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?>
-
- <?php if ($producer->taxRate->value != 0): ?>
-
- <tr>
- <td class="align-right" colspan="4"><strong>Total HT</strong></td>
- <td class="align-center">
- <?= Price::format($documentModule->getAmount($document, $typeAmount)); ?>
- </td>
- </tr>
-
- <?php
- $taxRateArray = $this-> getTaxRateModule()->findTaxRatesAsArray();
- foreach ($documentModule->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?>
- <tr>
- <td class="align-right" colspan="4">
- <strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td>
- <td class="align-center">
- <?= Price::format($totalVat); ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <tr>
- <td class="align-right" colspan="4">
- <strong>Total TTC</strong>
- </td>
- <td class="align-center">
- <?= Price::format($documentModule->getAmountWithTax($document, $typeAmount)) ?>
- </td>
- </tr>
- <?php else: ?>
- <tr>
- <td class="align-right" colspan="3">
- <strong>Total</strong><br/>
- TVA non applicable
- </td>
- <td class="align-center">
- <?= Price::format($documentModule->getAmount($document, $typeAmount)) ?>
- </td>
- </tr>
- <?php endif; ?>
- <?php endif; ?>
- </tbody>
- </table>
- <?php else : ?>
- <div id="block-no-product">
- <strong>Aucun produit</strong>
- </div>
- <?php endif; ?>
- </div>
-
- <?php
- $fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($documentModule->getClass($document))); ?>
- <?php if (strlen($producer->$fieldProducerDocumentInfo)): ?>
- <div class="block-infos">
- <strong>Informations générales</strong><br/>
- <?= nl2br(Html::encode($producer->$fieldProducerDocumentInfo)) ?>
- </div>
- <?php endif; ?>
- </div>
|