$order = Order::searchOne([ | $order = Order::searchOne([ | ||||
'id' => $order->id | 'id' => $order->id | ||||
]) ; | ]) ; | ||||
if ($credit && ($pointSale->credit || $order->getAmount(Order::AMOUNT_PAID))) { | |||||
if($credit && $pointSale->credit && ($posts['use_credit'] || $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY)) { | |||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | $amountPaid = $order->getAmount(Order::AMOUNT_PAID); | ||||
// à payer | // à payer | ||||
]) ; | ]) ; | ||||
$json['producer'] = [ | $json['producer'] = [ | ||||
'order_infos' => $producer->order_infos, | 'order_infos' => $producer->order_infos, | ||||
'credit' => $producer->credit | |||||
'credit' => $producer->credit, | |||||
'credit_functioning' => $producer->credit_functioning, | |||||
] ; | ] ; | ||||
// Distributions | // Distributions | ||||
]) | ]) | ||||
->all(); | ->all(); | ||||
$creditFunctioningProducer = Producer::getConfig('credit_functioning') ; | |||||
foreach($pointsSaleArray as &$pointSale) { | foreach($pointsSaleArray as &$pointSale) { | ||||
$pointSale = array_merge($pointSale->getAttributes(),[ | $pointSale = array_merge($pointSale->getAttributes(),[ | ||||
'pointSaleDistribution' => [ | 'pointSaleDistribution' => [ | ||||
if($pointSale['code'] && strlen($pointSale['code'])) { | if($pointSale['code'] && strlen($pointSale['code'])) { | ||||
$pointSale['code'] = '***' ; | $pointSale['code'] = '***' ; | ||||
} | } | ||||
if(!strlen($pointSale['credit_functioning'])) { | |||||
$pointSale['credit_functioning'] = $creditFunctioningProducer ; | |||||
} | |||||
} | } | ||||
$json['points_sale'] = $pointsSaleArray; | $json['points_sale'] = $pointsSaleArray; |
</div> | </div> | ||||
<div class="credit"> | <div class="credit"> | ||||
<div v-if="producer.credit == 1 && pointSaleActive.credit == 1"> | <div v-if="producer.credit == 1 && pointSaleActive.credit == 1"> | ||||
<span class="glyphicon glyphicon-chevron-right"></span> La commande va être réglée via votre Crédit ({{ formatPrice(credit) }}). | |||||
<div class="info"> | |||||
<input type="checkbox" id="use-credit" v-model="useCredit" disabled="disabled" v-if="pointSaleActive.credit_functioning == 'mandatory'" /> | |||||
<input type="checkbox" id="use-credit" v-model="useCredit" v-else /> <label for="use-credit">Utiliser mon Crédit ({{ formatPrice(credit) }})</label> | |||||
<div class="info" v-if="useCredit"> | |||||
<span v-if="order == null || order.amount_paid == 0">{{ priceTotal(true) }} seront débités</span> | <span v-if="order == null || order.amount_paid == 0">{{ priceTotal(true) }} seront débités</span> | ||||
<span v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span> | <span v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span> | ||||
<span v-else-if="order != null && order.amount_paid > priceTotal()">{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span> | <span v-else-if="order != null && order.amount_paid > priceTotal()">{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span> |
comment: '', | comment: '', | ||||
creditCheckbox: false, | creditCheckbox: false, | ||||
credit: 0, | credit: 0, | ||||
useCredit: false, | |||||
errors: [], | errors: [], | ||||
disableConfirmButton: false, | disableConfirmButton: false, | ||||
calendar: { | calendar: { | ||||
validatePointSale: function(idPointSale) { | validatePointSale: function(idPointSale) { | ||||
this.pointSaleActive = this.getPointSale(idPointSale) ; | this.pointSaleActive = this.getPointSale(idPointSale) ; | ||||
this.useCredit = true ; | |||||
this.changeStep('products') ; | this.changeStep('products') ; | ||||
}, | }, | ||||
productQuantityClick: function(product, quantity) { | productQuantityClick: function(product, quantity) { | ||||
comment: this.comment | comment: this.comment | ||||
}, | }, | ||||
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | ||||
products: productsArray | |||||
products: productsArray, | |||||
use_credit: Number(this.useCredit) | |||||
}).then(function(response) { | }).then(function(response) { | ||||
if(response.data.status == 'success') { | if(response.data.status == 'success') { | ||||
window.location.href = chat_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ; | window.location.href = chat_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ; |