No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

212 líneas
9.5KB

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