You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
10KB

  1. <?php
  2. use common\helpers\Price;
  3. use domain\Order\Order\Order;
  4. use yii\helpers\Html;
  5. $producerModule = $this->getProducerModule();
  6. $userModule = $this->getUserModule();
  7. $documentModule = $this->getDocumentModule();
  8. $orderModule = $this->getOrderModule();
  9. $deliveryNoteModule = $this->getDeliveryNoteModule();
  10. $isDocumentDeliveryNote = $documentModule->getSolver()->isDocumentDeliveryNote($document);
  11. $displayPrices = !$isDocumentDeliveryNote || ($isDocumentDeliveryNote && $producerModule->getConfig('document_display_prices_delivery_note'));
  12. $displayProductDescription = $producerModule->getConfig('document_display_product_description');
  13. $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price_decimals');
  14. ?>
  15. <div class="document-download">
  16. <div id="block-addresses">
  17. <div class="producer">
  18. <?php if (strlen($producer->logo)) : ?>
  19. <?php $optionDocumentWidthLogo = $producerModule->getSolver()->getConfig('option_document_width_logo'); ?>
  20. <div class="logo" style="width: <?= $optionDocumentWidthLogo ?: 100; ?>px;">
  21. <img src="<?= $producerModule->getUrlLogo($producer) ?>"/>
  22. </div>
  23. <?php endif; ?>
  24. <div class="address">
  25. <?= $producerModule->getFullAddressAsHtml($producer); ?>
  26. </div>
  27. <?php if (strlen($producer->document_infos_top)): ?>
  28. <div class="infos-top">
  29. <?= nl2br(Html::encode($producer->document_infos_top)) ?>
  30. </div>
  31. <?php endif; ?>
  32. </div>
  33. <div class="user">
  34. <?php if ($document->address && strlen($document->address) > 0): ?>
  35. <?= nl2br($document->address) ?>
  36. <?php else: ?>
  37. <?= $userModule->getFullAddress($document->user, true); ?>
  38. <?php endif; ?>
  39. </div>
  40. </div>
  41. <?php if($documentModule->getSolver()->isStatusDraft($document)): ?>
  42. <div class="block-is-draft">
  43. <?= $documentModule->getType($document); ?> non
  44. validé<?= ($documentModule->getType($document) == 'Facture') ? 'e' : '' ?></div>
  45. <?php endif; ?>
  46. <div id="block-infos-document">
  47. <div class="type">
  48. <strong><?= $documentModule->getType($document); ?></strong>
  49. </div>
  50. <div class="date">
  51. <strong>Date : </strong>
  52. <?= strftime('%d %B %Y', strtotime($document->date)) ?>
  53. </div>
  54. <?php if (strlen($document->reference)) : ?>
  55. <div class="reference">
  56. <strong>Référence : </strong>
  57. <?= $document->reference; ?>
  58. </div>
  59. <?php endif; ?>
  60. <div class="name">
  61. <strong>Libellé : </strong>
  62. <?= $document->name; ?>
  63. </div>
  64. <?php if ($documentModule->getSolver()->isDocumentInvoice($document)): ?>
  65. <?php $deliveryNotesUpdateArray = $deliveryNoteModule->getRepository()->findDeliveryNotesByInvoice($document); ?>
  66. <?php if($deliveryNotesUpdateArray && count($deliveryNotesUpdateArray)): ?>
  67. <strong>Bons de livraison : </strong>
  68. <?php foreach($deliveryNotesUpdateArray as $key => $deliveryNote): ?>
  69. <?= $deliveryNote->reference ?><?php if ($key !== array_key_last($deliveryNotesUpdateArray)): ?>, <?php endif; ?>
  70. <?php endforeach; ?>
  71. <?php endif; ?>
  72. <?php endif; ?>
  73. <?php if (strlen($document->comment)): ?>
  74. <div class="comment">
  75. <br>
  76. <strong>Commentaire</strong><br>
  77. <?= Html::encode($document->comment) ?>
  78. </div>
  79. <?php endif; ?>
  80. </div>
  81. <div id="block-products">
  82. <?php if (count($document->orders) > 0) : ?>
  83. <table class="table table-bordered">
  84. <thead>
  85. <tr>
  86. <th class="align-left">Produit</th>
  87. <?php if ($displayPrices): ?>
  88. <?php if ($producer->taxRate->value == 0): ?>
  89. <th>Prix unitaire</th>
  90. <?php else: ?>
  91. <th>Prix unitaire HT</th>
  92. <?php endif; ?>
  93. <?php endif; ?>
  94. <th>Quantité</th>
  95. <?php if ($displayPrices): ?>
  96. <?php if ($producer->taxRate->value == 0): ?>
  97. <th>Prix</th>
  98. <?php else: ?>
  99. <th>TVA</th>
  100. <th>Prix HT</th>
  101. <?php endif; ?>
  102. <?php endif; ?>
  103. </tr>
  104. </thead>
  105. <tbody>
  106. <?php if ($producerModule->isDocumentDisplayOrders($document)): ?>
  107. <?php foreach ($document->orders as $order): ?>
  108. <tr>
  109. <td>
  110. <strong><?= $orderModule->getOrderUsername($order); ?></strong>
  111. <?php if ($order->distribution): ?>
  112. le <?= date('d/m/Y', strtotime($order->distribution->date)) ?>
  113. <?php endif; ?>
  114. </td>
  115. <?php if ($displayPrices): ?>
  116. <td class="align-center"></td>
  117. <?php endif; ?>
  118. <td></td>
  119. <?php if ($displayPrices): ?>
  120. <?php if ($producer->taxRate->value != 0): ?>
  121. <td class="align-center"></td>
  122. <?php endif; ?>
  123. <td class="align-center"></td>
  124. <?php endif; ?>
  125. </tr>
  126. <?php foreach ($order->productOrder as $productOrder): ?>
  127. <?= $this->render('_download_product_line', [
  128. 'producer' => $producer,
  129. 'document' => $document,
  130. 'productOrder' => $productOrder,
  131. 'displayOrders' => true,
  132. 'displayPrices' => $displayPrices,
  133. 'displayProductDescription' => $displayProductDescription,
  134. 'documentPriceDecimals' => $documentPriceDecimals
  135. ]) ?>
  136. <?php endforeach; ?>
  137. <?php endforeach; ?>
  138. <?php else: ?>
  139. <?php foreach ($documentModule->getProductsOrders($document, true) as $product): ?>
  140. <?php foreach ($product as $productOrder): ?>
  141. <?= $this->render('_download_product_line', [
  142. 'producer' => $producer,
  143. 'document' => $document,
  144. 'productOrder' => $productOrder,
  145. 'displayPrices' => $displayPrices,
  146. 'displayProductDescription' => $displayProductDescription,
  147. 'documentPriceDecimals' => $documentPriceDecimals
  148. ]) ?>
  149. <?php endforeach; ?>
  150. <?php endforeach; ?>
  151. <?php endif; ?>
  152. <?php if ($displayPrices): ?>
  153. <?php $typeAmount = $documentModule->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?>
  154. <?php if ($producer->taxRate->value != 0): ?>
  155. <tr>
  156. <td class="align-right" colspan="4"><strong>Total HT</strong></td>
  157. <td class="align-center">
  158. <?= Price::format($documentModule->getAmount($document, $typeAmount)); ?>
  159. </td>
  160. </tr>
  161. <?php
  162. $taxRateArray = $this-> getTaxRateModule()->getRepository()->findTaxRatesAsArray();
  163. foreach ($documentModule->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?>
  164. <tr>
  165. <td class="align-right" colspan="4">
  166. <strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td>
  167. <td class="align-center">
  168. <?= Price::format($totalVat); ?>
  169. </td>
  170. </tr>
  171. <?php endforeach; ?>
  172. <tr>
  173. <td class="align-right" colspan="4">
  174. <strong>Total TTC</strong>
  175. </td>
  176. <td class="align-center">
  177. <?= Price::format($documentModule->getAmountWithTax($document, $typeAmount)) ?>
  178. </td>
  179. </tr>
  180. <?php else: ?>
  181. <tr>
  182. <td class="align-right" colspan="3">
  183. <strong>Total</strong><br/>
  184. TVA non applicable
  185. </td>
  186. <td class="align-center">
  187. <?= Price::format($documentModule->getAmount($document, $typeAmount)) ?>
  188. </td>
  189. </tr>
  190. <?php endif; ?>
  191. <?php endif; ?>
  192. </tbody>
  193. </table>
  194. <?php else : ?>
  195. <div id="block-no-product">
  196. <strong>Aucun produit</strong>
  197. </div>
  198. <?php endif; ?>
  199. </div>
  200. <?php
  201. $fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($documentModule->getClass($document))); ?>
  202. <?php if (strlen($producer->$fieldProducerDocumentInfo)): ?>
  203. <div class="block-infos">
  204. <strong>Informations générales</strong><br/>
  205. <?= nl2br(Html::encode($producer->$fieldProducerDocumentInfo)) ?>
  206. </div>
  207. <?php endif; ?>
  208. </div>