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.

205 line
9.5KB

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