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.

198 lines
9.2KB

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