@@ -310,7 +310,7 @@ class OrderController extends ProducerBaseController | |||
$order = Order::searchOne([ | |||
'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); | |||
// à payer | |||
@@ -436,7 +436,8 @@ class OrderController extends ProducerBaseController | |||
]) ; | |||
$json['producer'] = [ | |||
'order_infos' => $producer->order_infos, | |||
'credit' => $producer->credit | |||
'credit' => $producer->credit, | |||
'credit_functioning' => $producer->credit_functioning, | |||
] ; | |||
// Distributions | |||
@@ -512,6 +513,8 @@ class OrderController extends ProducerBaseController | |||
]) | |||
->all(); | |||
$creditFunctioningProducer = Producer::getConfig('credit_functioning') ; | |||
foreach($pointsSaleArray as &$pointSale) { | |||
$pointSale = array_merge($pointSale->getAttributes(),[ | |||
'pointSaleDistribution' => [ | |||
@@ -524,6 +527,9 @@ class OrderController extends ProducerBaseController | |||
if($pointSale['code'] && strlen($pointSale['code'])) { | |||
$pointSale['code'] = '***' ; | |||
} | |||
if(!strlen($pointSale['credit_functioning'])) { | |||
$pointSale['credit_functioning'] = $creditFunctioningProducer ; | |||
} | |||
} | |||
$json['points_sale'] = $pointsSaleArray; |
@@ -230,8 +230,10 @@ $this->setTitle('Commander') ; | |||
</div> | |||
<div class="credit"> | |||
<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-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> |
@@ -17,6 +17,7 @@ var app = new Vue({ | |||
comment: '', | |||
creditCheckbox: false, | |||
credit: 0, | |||
useCredit: false, | |||
errors: [], | |||
disableConfirmButton: false, | |||
calendar: { | |||
@@ -242,6 +243,8 @@ var app = new Vue({ | |||
validatePointSale: function(idPointSale) { | |||
this.pointSaleActive = this.getPointSale(idPointSale) ; | |||
this.useCredit = true ; | |||
this.changeStep('products') ; | |||
}, | |||
productQuantityClick: function(product, quantity) { | |||
@@ -301,7 +304,8 @@ var app = new Vue({ | |||
comment: this.comment | |||
}, | |||
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | |||
products: productsArray | |||
products: productsArray, | |||
use_credit: Number(this.useCredit) | |||
}).then(function(response) { | |||
if(response.data.status == 'success') { | |||
window.location.href = chat_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ; |