<?php | <?php | ||||
use common\helpers\Price; | use common\helpers\Price; | ||||
use common\logic\Order\ProductOrder\Module\ProductOrderModule; | |||||
use common\logic\Producer\Producer\Module\ProducerModule; | |||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$documentModule = $this->getDocumentModule(); | $documentModule = $this->getDocumentModule(); | ||||
$productModule = $this->getProductModule(); | $productModule = $this->getProductModule(); | ||||
$productOrderModule = ProductOrderModule::getInstance(); | |||||
$producerModule = ProducerModule::getInstance(); | |||||
?> | ?> | ||||
<?php if($displayPrices): ?> | <?php if($displayPrices): ?> | ||||
<td class="align-center column-unit-price"> | <td class="align-center column-unit-price"> | ||||
<?= Price::format($price, $documentPriceDecimals) ?> | |||||
<?php $displayPriceUnitReference = $producerModule->getSolver()->getConfig('option_document_display_price_unit_reference'); ?> | |||||
<?php $priceUnitReference = $productOrderModule->getSolver()->getPriceUnitReference($productOrder); ?> | |||||
<?php $priceUnitReferenceString = Price::format($priceUnitReference, $documentPriceDecimals).' / kg' ?> | |||||
<?php if($productOrder->unit == 'piece'): ?> | |||||
<?= Price::format($price, $documentPriceDecimals) ?> | |||||
<?php if($priceUnitReference): ?> | |||||
(<?= $priceUnitReferenceString ?>) | |||||
<?php endif; ?> | |||||
<?php else: ?> | |||||
<?= $priceUnitReferenceString ?> | |||||
<?php endif; ?> | |||||
</td> | </td> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<td class="align-center column-quantity"> | <td class="align-center column-quantity"> | ||||
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | <?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | ||||
<?= $productModule->getSolver()->strUnit($productOrder->product, 'wording') ?> | |||||
</td> | </td> | ||||
<td class="align-center column-unit"><?= $productModule->getSolver()->strUnit($productOrder->product, 'wording') ?></td> | |||||
<?php if($displayPrices): ?> | <?php if($displayPrices): ?> | ||||
<?php if($producer->taxRate->value != 0): ?> | <?php if($producer->taxRate->value != 0): ?> | ||||
<td class="align-center column-tax-rate"><?= $productOrder->taxRate->value * 100 ?> %</td> | <td class="align-center column-tax-rate"><?= $productOrder->taxRate->value * 100 ?> %</td> |
<?php endif; ?> | <?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<th>Quantité</th> | <th>Quantité</th> | ||||
<th>Unité</th> | |||||
<?php if ($displayPrices): ?> | <?php if ($displayPrices): ?> | ||||
<?php if ($producer->taxRate->value == 0): ?> | <?php if ($producer->taxRate->value == 0): ?> | ||||
<th>Prix</th> | <th>Prix</th> | ||||
<td class="align-center"></td> | <td class="align-center"></td> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<td></td> | <td></td> | ||||
<td></td> | |||||
<?php if ($displayPrices): ?> | <?php if ($displayPrices): ?> | ||||
<?php if ($producer->taxRate->value != 0): ?> | <?php if ($producer->taxRate->value != 0): ?> | ||||
<td class="align-center"></td> | <td class="align-center"></td> | ||||
<?php if ($producer->taxRate->value != 0): ?> | <?php if ($producer->taxRate->value != 0): ?> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"><strong>Total HT</strong></td> | |||||
<td class="align-right" colspan="4"><strong>Total HT</strong></td> | |||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= Price::format($documentModule->getAmount($document, $typeAmount)); ?> | <?= Price::format($documentModule->getAmount($document, $typeAmount)); ?> | ||||
</td> | </td> | ||||
$taxRateArray = $this-> getTaxRateModule()->findTaxRatesAsArray(); | $taxRateArray = $this-> getTaxRateModule()->findTaxRatesAsArray(); | ||||
foreach ($documentModule->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?> | foreach ($documentModule->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"> | |||||
<td class="align-right" colspan="4"> | |||||
<strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | <strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= Price::format($totalVat); ?> | <?= Price::format($totalVat); ?> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<!--<tr> | |||||
<td class="align-right" colspan="5"><strong>TVA</strong></td> | |||||
<td class="align-center"> | |||||
<?= Price::format($documentModule->getAmountWithTax($document, $typeAmount) - $documentModule->getAmount($document, $typeAmount)) ?> | |||||
</td> | |||||
</tr>--> | |||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"><strong>Total TTC</strong></td> | |||||
<td class="align-center"><?= Price::format($documentModule->getAmountWithTax($document, $typeAmount)) ?></td> | |||||
<td class="align-right" colspan="4"> | |||||
<strong>Total TTC</strong> | |||||
</td> | |||||
<td class="align-center"> | |||||
<?= Price::format($documentModule->getAmountWithTax($document, $typeAmount)) ?> | |||||
</td> | |||||
</tr> | </tr> | ||||
<?php else: ?> | <?php else: ?> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="4"> | |||||
<td class="align-right" colspan="3"> | |||||
<strong>Total</strong><br/> | <strong>Total</strong><br/> | ||||
TVA non applicable | TVA non applicable | ||||
</td> | </td> | ||||
<td class="align-center"><?= Price::format($documentModule->getAmount($document, $typeAmount)) ?></td> | |||||
<td class="align-center"> | |||||
<?= Price::format($documentModule->getAmount($document, $typeAmount)) ?> | |||||
</td> | |||||
</tr> | </tr> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> |
2 => '2', | 2 => '2', | ||||
3 => '3' | 3 => '3' | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'option_document_display_price_unit_reference') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'document_infos_top') | <?= $form->field($model, 'document_infos_top') | ||||
->textarea(['rows' => 8]) | ->textarea(['rows' => 8]) | ||||
->hint("Affichées juste en dessous de l'adresse"); ?> | ->hint("Affichées juste en dessous de l'adresse"); ?> |
.document-download #block-products table td { | .document-download #block-products table td { | ||||
font-size: 11px; | font-size: 11px; | ||||
} | } | ||||
/* line 105, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.column-unit-price, .document-download #block-products table td.column-quantity, .document-download #block-products table td.column-unit, .document-download #block-products table td.column-tax-rate, .document-download #block-products table td.column-price { | |||||
/* line 103, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.column-unit-price { | |||||
width: 120px; | |||||
} | |||||
/* line 107, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.column-tax-rate, .document-download #block-products table td.column-price { | |||||
width: 70px; | width: 70px; | ||||
} | } | ||||
/* line 116, ../../sass/document/download.scss */ | |||||
/* line 112, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.column-quantity { | |||||
width: 80px; | |||||
} | |||||
/* line 119, ../../sass/document/download.scss */ | |||||
.document-download .block-infos { | .document-download .block-infos { | ||||
margin-bottom: 15px; | margin-bottom: 15px; | ||||
border: solid 1px #c0c0c0; | border: solid 1px #c0c0c0; | ||||
background-color: transparent; | background-color: transparent; | ||||
font-size: 11px; | font-size: 11px; | ||||
} | } | ||||
/* line 123, ../../sass/document/download.scss */ | |||||
/* line 126, ../../sass/document/download.scss */ | |||||
.document-download .block-infos strong { | .document-download .block-infos strong { | ||||
font-size: 12px; | font-size: 12px; | ||||
} | } | ||||
/* line 129, ../../sass/document/download.scss */ | |||||
/* line 132, ../../sass/document/download.scss */ | |||||
#footer { | #footer { | ||||
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; | font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; | ||||
text-align: center; | text-align: center; | ||||
padding-top: 10px; | padding-top: 10px; | ||||
border-top: solid 1px gray; | border-top: solid 1px gray; | ||||
} | } | ||||
/* line 135, ../../sass/document/download.scss */ | |||||
/* line 138, ../../sass/document/download.scss */ | |||||
#footer .infos-bottom { | #footer .infos-bottom { | ||||
font-size: 12px; | font-size: 12px; | ||||
line-height: 18px; | line-height: 18px; |
td { | td { | ||||
font-size: 11px; | font-size: 11px; | ||||
&.column-product { | |||||
&.column-product {} | |||||
&.column-unit-price { | |||||
width: 120px; | |||||
} | } | ||||
&.column-unit-price, | |||||
&.column-quantity, | |||||
&.column-unit, | |||||
&.column-tax-rate, | &.column-tax-rate, | ||||
&.column-price { | &.column-price { | ||||
width: 70px; | width: 70px; | ||||
} | } | ||||
&.column-quantity { | |||||
width: 80px; | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
return $productOrder->price; | return $productOrder->price; | ||||
} | } | ||||
public function getPriceUnitReference(ProductOrder $productOrder): ?float | |||||
{ | |||||
if($productOrder->unit == 'piece') { | |||||
if($productOrder->product->weight) { | |||||
$price = (1000 * $productOrder->price) / $productOrder->product->weight; | |||||
} | |||||
else { | |||||
return null; | |||||
} | |||||
} | |||||
else { | |||||
$price = $productOrder->price; | |||||
} | |||||
return $price; | |||||
} | |||||
} | } |
'option_display_message_new_opendistrib_version', | 'option_display_message_new_opendistrib_version', | ||||
'option_billing_permanent_transfer', | 'option_billing_permanent_transfer', | ||||
'option_export_display_column_delivery_note', | 'option_export_display_column_delivery_note', | ||||
'option_invoice_only_based_on_delivery_notes' | |||||
'option_invoice_only_based_on_delivery_notes', | |||||
'option_document_display_price_unit_reference' | |||||
], | ], | ||||
'boolean' | 'boolean' | ||||
], | ], | ||||
'option_invoice_only_based_on_delivery_notes' => 'Facturer uniquement sur la base des bons de livraison', | 'option_invoice_only_based_on_delivery_notes' => 'Facturer uniquement sur la base des bons de livraison', | ||||
'option_document_width_logo' => 'Largeur du logo dans les documents', | 'option_document_width_logo' => 'Largeur du logo dans les documents', | ||||
'export_shopping_cart_labels_number_per_column' => "Étiquettes (PDF) : nombre d'étiquettes par colonne", | 'export_shopping_cart_labels_number_per_column' => "Étiquettes (PDF) : nombre d'étiquettes par colonne", | ||||
'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m231108_131232_add_column_producer_option_document_display_price_unit_reference | |||||
*/ | |||||
class m231108_131232_add_column_producer_option_document_display_price_unit_reference extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'option_document_display_price_unit_reference', Schema::TYPE_BOOLEAN); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'option_document_display_price_unit_reference'); | |||||
} | |||||
} |