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.

186 lines
8.4KB

  1. <?php
  2. $displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note'));
  3. $displayProductDescription = Producer::getConfig('document_display_product_description');
  4. ?>
  5. <div class="document-download">
  6. <div id="block-addresses">
  7. <div class="producer">
  8. <?php if (strlen($producer->logo)) : ?>
  9. <div class="logo">
  10. <img style="max-height: 80px;" src="<?= $producer->getUrlLogo() ?>"/>
  11. </div>
  12. <?php endif; ?>
  13. <div class="address"><?= $producer->getFullAddress(true); ?></div>
  14. </div>
  15. <div class="user">
  16. <?php if ($document->address && strlen($document->address) > 0): ?>
  17. <?= nl2br($document->address) ?>
  18. <?php else: ?>
  19. <?= $document->user->getFullAddress(true); ?>
  20. <?php endif; ?>
  21. </div>
  22. </div>
  23. <div id="block-infos-document">
  24. <div class="date">
  25. Le <?= strftime('%d %B %Y', strtotime($document->date)) ?>
  26. </div>
  27. <div class="reference">
  28. <?php if (strlen($document->reference)) : ?>
  29. <?= $document->getType(); ?> N°<?= $document->reference; ?>
  30. <?php else: ?>
  31. <div class="block-is-draft"><?= $document->getType(); ?> non
  32. validé<?= ($document->getType() == 'Facture') ? 'e' : '' ?></div>
  33. <?php endif; ?>
  34. </div>
  35. <div class="name">
  36. <strong>Libellé : </strong><?= $document->name; ?>
  37. </div>
  38. </div>
  39. <?php if (strlen($document->comment)): ?>
  40. <div class="block-infos">
  41. <strong>Commentaire</strong><br/>
  42. <?= Html::encode($document->comment) ?>
  43. </div>
  44. <?php endif; ?>
  45. <div id="block-products">
  46. <?php if (count($document->orders) > 0) : ?>
  47. <table class="table table-bordered">
  48. <thead>
  49. <tr>
  50. <th class="align-left">Produit</th>
  51. <?php if ($displayPrices): ?>
  52. <?php if ($producer->taxRate->value == 0): ?>
  53. <th>Prix unitaire</th>
  54. <?php else: ?>
  55. <th>Prix unitaire HT</th>
  56. <?php endif; ?>
  57. <?php endif; ?>
  58. <th>Quantité</th>
  59. <th>Unité</th>
  60. <?php if ($displayPrices): ?>
  61. <?php if ($producer->taxRate->value == 0): ?>
  62. <th>Prix</th>
  63. <?php else: ?>
  64. <th>TVA</th>
  65. <th>Prix HT</th>
  66. <?php endif; ?>
  67. <?php endif; ?>
  68. </tr>
  69. </thead>
  70. <tbody>
  71. <?php if ($document->isDisplayOrders()): ?>
  72. <?php foreach ($document->orders as $order): ?>
  73. <tr>
  74. <td>
  75. <strong><?= Html::encode($order->getUsername()); ?></strong>
  76. <?php if ($order->distribution): ?>
  77. le <?= date('d/m/Y', strtotime($order->distribution->date)) ?>
  78. <?php endif; ?>
  79. </td>
  80. <?php if ($displayPrices): ?>
  81. <td class="align-center"></td>
  82. <?php endif; ?>
  83. <td></td>
  84. <td></td>
  85. <?php if ($displayPrices): ?>
  86. <?php if ($producer->taxRate->value != 0): ?>
  87. <td class="align-center"></td>
  88. <?php endif; ?>
  89. <td class="align-center"></td>
  90. <?php endif; ?>
  91. </tr>
  92. <?php foreach ($order->productOrder as $productOrder): ?>
  93. <?= $this->render('_download_product_line', [
  94. 'producer' => $producer,
  95. 'document' => $document,
  96. 'productOrder' => $productOrder,
  97. 'displayOrders' => true,
  98. 'displayPrices' => $displayPrices,
  99. 'displayProductDescription' => $displayProductDescription
  100. ]) ?>
  101. <?php endforeach; ?>
  102. <?php endforeach; ?>
  103. <?php else: ?>
  104. <?php foreach ($document->getProductsOrders() as $product): ?>
  105. <?php foreach ($product as $productOrder): ?>
  106. <?= $this->render('_download_product_line', [
  107. 'producer' => $producer,
  108. 'document' => $document,
  109. 'productOrder' => $productOrder,
  110. 'displayPrices' => $displayPrices,
  111. 'displayProductDescription' => $displayProductDescription
  112. ]) ?>
  113. <?php endforeach; ?>
  114. <?php endforeach; ?>
  115. <?php endif; ?>
  116. <?php if ($displayPrices): ?>
  117. <?php $typeAmount = $document->isInvoicePrice() ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?>
  118. <?php if ($producer->taxRate->value != 0): ?>
  119. <tr>
  120. <td class="align-right" colspan="5"><strong>Total HT</strong></td>
  121. <td class="align-center">
  122. <?= Price::format($document->getAmount($typeAmount)); ?>
  123. </td>
  124. </tr>
  125. <?php
  126. $taxRateArray = TaxRate::getTaxRateArray();
  127. foreach ($document->getTotalVatArray($typeAmount) as $idTaxRate => $totalVat): ?>
  128. <tr>
  129. <td class="align-right" colspan="5">
  130. <strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td>
  131. <td class="align-center">
  132. <?= Price::format($totalVat); ?>
  133. </td>
  134. </tr>
  135. <?php endforeach; ?>
  136. <!--<tr>
  137. <td class="align-right" colspan="5"><strong>TVA</strong></td>
  138. <td class="align-center">
  139. <?= Price::format($document->getAmountWithTax($typeAmount) - $document->getAmount($typeAmount)) ?>
  140. </td>
  141. </tr>-->
  142. <tr>
  143. <td class="align-right" colspan="5"><strong>Total TTC</strong></td>
  144. <td class="align-center"><?= Price::format($document->getAmountWithTax($typeAmount)) ?></td>
  145. </tr>
  146. <?php else: ?>
  147. <tr>
  148. <td class="align-right" colspan="4">
  149. <strong>Total</strong><br/>
  150. TVA non applicable
  151. </td>
  152. <td class="align-center"><?= Price::format($document->getAmount($typeAmount)) ?></td>
  153. </tr>
  154. <?php endif; ?>
  155. <?php endif; ?>
  156. </tbody>
  157. </table>
  158. <?php else : ?>
  159. <div id="block-no-product">
  160. <strong>Aucun produit</strong>
  161. </div>
  162. <?php endif; ?>
  163. </div>
  164. <?php
  165. $fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($document->getClass())); ?>
  166. <?php if (strlen($producer->$fieldProducerDocumentInfo)): ?>
  167. <div class="block-infos">
  168. <strong>Informations</strong><br/>
  169. <?= nl2br(Html::encode($producer->$fieldProducerDocumentInfo)) ?>
  170. </div>
  171. <?php endif; ?>
  172. </div>