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.

182 lines
11KB

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