<?php if($displayPrices): ?> | <?php if($displayPrices): ?> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= Price::format($price) ?> | |||||
<?= Price::format($price, $documentPriceDecimals) ?> | |||||
</td> | </td> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<td class="align-center"> | <td class="align-center"> |
[ | [ | ||||
'@change' => 'changeUser', | '@change' => 'changeUser', | ||||
'v-model' => 'idUser', | 'v-model' => 'idUser', | ||||
'class' => 'select2' | |||||
'class' => 'select2 select2-document-form' | |||||
] | ] | ||||
); ?> | ); ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text">Commandes</span> | <span class="info-box-text">Commandes</span> | ||||
<?php foreach($model->orders as $order): ?> | <?php foreach($model->orders as $order): ?> | ||||
<a class="btn btn-sm btn-default" href="<?= Yii::$app->urlManager->createUrl(['distribution/index', 'idOrderUpdate' => $order->id]); ?>"> | |||||
<?= date('d/m/Y', strtotime($order->distribution->date)) ?> | |||||
</a> | |||||
<?php if($order->distribution): ?> | |||||
<a class="btn btn-sm btn-default" href="<?= Yii::$app->urlManager->createUrl(['distribution/index', 'idOrderUpdate' => $order->id]); ?>"> | |||||
<?= date('d/m/Y', strtotime($order->distribution->date)) ?> | |||||
</a> | |||||
<?php endif; ?> | |||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<div id="block-list-products"> | <div id="block-list-products"> | ||||
<table class="table table-bordered" v-if="total > 0"> | |||||
<table class="table table-bordered" v-if="Object.keys(ordersArray).length > 0"> | |||||
<thead> | <thead> | ||||
<tr> | <tr> | ||||
<th>Nom</th> | <th>Nom</th> |
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note')); | $displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note')); | ||||
$displayProductDescription = Producer::getConfig('document_display_product_description'); | $displayProductDescription = Producer::getConfig('document_display_product_description'); | ||||
$documentPriceDecimals = (int) Producer::getConfig('option_document_price_decimals'); | |||||
?> | ?> | ||||
'productOrder' => $productOrder, | 'productOrder' => $productOrder, | ||||
'displayOrders' => true, | 'displayOrders' => true, | ||||
'displayPrices' => $displayPrices, | 'displayPrices' => $displayPrices, | ||||
'displayProductDescription' => $displayProductDescription | |||||
'displayProductDescription' => $displayProductDescription, | |||||
'documentPriceDecimals' => $documentPriceDecimals | |||||
]) ?> | ]) ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
'document' => $document, | 'document' => $document, | ||||
'productOrder' => $productOrder, | 'productOrder' => $productOrder, | ||||
'displayPrices' => $displayPrices, | 'displayPrices' => $displayPrices, | ||||
'displayProductDescription' => $displayProductDescription | |||||
'displayProductDescription' => $displayProductDescription, | |||||
'documentPriceDecimals' => $documentPriceDecimals | |||||
]) ?> | ]) ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> |
0 => 'Non', | 0 => 'Non', | ||||
1 => 'Oui' | 1 => 'Oui' | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'option_document_price_decimals')->dropDownList([ | |||||
2 => '2', | |||||
3 => '3' | |||||
]); ?> | |||||
<?= $form->field($model, 'document_infos_bottom') | <?= $form->field($model, 'document_infos_bottom') | ||||
->textarea(['rows' => 15]) ?> | ->textarea(['rows' => 15]) ?> | ||||
<?= $form->field($model, 'document_infos_quotation') | <?= $form->field($model, 'document_infos_quotation') |
methods: { | methods: { | ||||
formatPrice: formatPrice, | formatPrice: formatPrice, | ||||
init: function () { | init: function () { | ||||
var app = this; | |||||
if (this.getDocumentId()) { | if (this.getDocumentId()) { | ||||
var app = this; | |||||
axios.get(UrlManager.getBaseUrlAbsolute() + "document/ajax-init", { | axios.get(UrlManager.getBaseUrlAbsolute() + "document/ajax-init", { | ||||
params: { | params: { | ||||
idDocument: this.getDocumentId(), | idDocument: this.getDocumentId(), | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
else { | |||||
$('.select2-document-form').on('select2:select', function (e) { | |||||
var idUser = e.params.data.id; | |||||
app.idUser = idUser; | |||||
app.changeUser(); | |||||
}); | |||||
} | |||||
}, | }, | ||||
getProductById: function(idProduct) { | getProductById: function(idProduct) { | ||||
var app = this; | var app = this; |
class Price | class Price | ||||
{ | { | ||||
public static function format($number) | |||||
public static function format($number, $decimals = 2) | |||||
{ | { | ||||
return self::numberTwoDecimals($number).' €'; | |||||
return self::numberTwoDecimals($number, $decimals).' €'; | |||||
} | } | ||||
public static function round($number) | public static function round($number) | ||||
return $vat; | return $vat; | ||||
} | } | ||||
public static function numberTwoDecimals($number) | |||||
public static function numberTwoDecimals($number, $decimals = 2) | |||||
{ | { | ||||
return number_format(( ($number * 100)) / 100, 2) ; | |||||
return number_format(( ($number * 100)) / 100, $decimals) ; | |||||
} | } | ||||
} | } |
*/ | */ | ||||
public function save($runValidation = true, $attributeNames = NULL) | public function save($runValidation = true, $attributeNames = NULL) | ||||
{ | { | ||||
if($this->amount > -0.01 && $this->amount < 0.01) { | |||||
return false; | |||||
} | |||||
// initialisation du commentaire avant sauvegarde | // initialisation du commentaire avant sauvegarde | ||||
$this->comment .= $this->getStrComment() ; | $this->comment .= $this->getStrComment() ; | ||||
'id_tax_rate_default', | 'id_tax_rate_default', | ||||
'document_quotation_duration', | 'document_quotation_duration', | ||||
'option_dashboard_number_distributions', | 'option_dashboard_number_distributions', | ||||
'option_online_payment_minimum_amount' | |||||
'option_online_payment_minimum_amount', | |||||
'option_document_price_decimals' | |||||
], | ], | ||||
'integer' | 'integer' | ||||
], | ], | ||||
'latest_version_opendistrib' => 'Dernière version d\'Opendistrib', | 'latest_version_opendistrib' => 'Dernière version d\'Opendistrib', | ||||
'option_csv_separator' => 'Séparateur de colonnes (CSV)', | 'option_csv_separator' => 'Séparateur de colonnes (CSV)', | ||||
'option_display_message_new_opendistrib_version' => 'Afficher les messages de mise à jour du logiciel Opendistrib', | 'option_display_message_new_opendistrib_version' => 'Afficher les messages de mise à jour du logiciel Opendistrib', | ||||
'option_online_payment_minimum_amount' => 'Paiement en ligne : montant minimum' | |||||
'option_online_payment_minimum_amount' => 'Paiement en ligne : montant minimum', | |||||
'option_document_price_decimals' => 'Prix : nombre de décimales affichées' | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m221212_143815_producer_add_option_document_price_decimals | |||||
*/ | |||||
class m221212_143815_producer_add_option_document_price_decimals extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'option_document_price_decimals', Schema::TYPE_INTEGER . ' DEFAULT 2'); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'option_document_price_decimals'); | |||||
} | |||||
} |