Browse Source

Gestion du crédit

refactoring
Guillaume Bourgeois 5 years ago
parent
commit
bf7cf030bb
3 changed files with 29 additions and 16 deletions
  1. +7
    -3
      producer/controllers/OrderController.php
  2. +12
    -8
      producer/views/order/order.php
  3. +10
    -5
      producer/web/js/vuejs/order-order.js

+ 7
- 3
producer/controllers/OrderController.php View File

} }


// credit // credit
$credit = isset($posts['use_credit']) && $posts['use_credit'];
$credit = Producer::getConfig('credit');
$order = Order::searchOne([ $order = Order::searchOne([
'id' => $order->id 'id' => $order->id
]) ; ]) ;
'id' => $this->getProducer()->id 'id' => $this->getProducer()->id
]) ; ]) ;
$json['producer'] = [ $json['producer'] = [
'order_infos' => $producer->order_infos
'order_infos' => $producer->order_infos,
'credit' => $producer->credit
] ; ] ;
// Distributions // Distributions
]); ]);
if($orderUser) { if($orderUser) {
$json['order'] = $orderUser->getAttributes() ;
$json['order'] = array_merge($orderUser->getAttributes(), [
'amount_total' => $orderUser->getAmount(Order::AMOUNT_TOTAL),
'amount_paid' => $orderUser->getAmount(Order::AMOUNT_PAID),
]) ;
} }
// distribution // distribution

+ 12
- 8
producer/views/order/order.php View File

<li><span class="glyphicon glyphicon-time"></span> {{ dateFormat }}</li> <li><span class="glyphicon glyphicon-time"></span> {{ dateFormat }}</li>
<li><span class="glyphicon glyphicon-map-marker"></span> {{ pointSaleActive.name }} <span class="locality" v-if="pointSaleActive.locality.length > 0">à {{ pointSaleActive.locality }}</span></li> <li><span class="glyphicon glyphicon-map-marker"></span> {{ pointSaleActive.name }} <span class="locality" v-if="pointSaleActive.locality.length > 0">à {{ pointSaleActive.locality }}</span></li>
<li><span class="glyphicon glyphicon-th-list"></span> {{ countProductOrdered() }} produits</li> <li><span class="glyphicon glyphicon-th-list"></span> {{ countProductOrdered() }} produits</li>
<li><span class="glyphicon glyphicon-chevron-right"></span> {{ priceTotal() }}</li>
<li><span class="glyphicon glyphicon-chevron-right"></span> {{ priceTotal(true) }}</li>
</ul> </ul>
</div> </div>
<div class="clr"></div> <div class="clr"></div>
</tr> </tr>
<tr class="total"> <tr class="total">
<td colspan="3"></td> <td colspan="3"></td>
<td class="price-total">{{ priceTotal() }}</td>
<td class="price-total">{{ priceTotal(true) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<textarea id="order-comment" v-model="comment" class="form-control"></textarea> <textarea id="order-comment" v-model="comment" class="form-control"></textarea>
</div> </div>
<div class="credit"> <div class="credit">
<input type="checkbox" id="checkbox-credit" v-model="creditCheckbox" />
<label for="checkbox-credit">Utiliser mon Crédit : {{ formatPrice(credit) }}</label>
<div class="info">
<span v-if="creditCheckbox == true">
{{ priceTotal() }} seront débités
</span>
<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">
<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>
</div>
</div>
<div v-else>
<span class="glyphicon glyphicon-chevron-right"></span> La commande sera à régler sur place.
</div> </div>
</div> </div>
<div class="block-actions"> <div class="block-actions">

+ 10
- 5
producer/web/js/vuejs/order-order.js View File

this.products = response.data.products ; this.products = response.data.products ;
} }
this.order = null ;
if(response.data.order) { if(response.data.order) {
this.order = response.data.order ;
this.pointSaleActive = this.getPointSale(response.data.order.id_point_sale) ; this.pointSaleActive = this.getPointSale(response.data.order.id_point_sale) ;
} }
else { else {
} }
return count ; return count ;
}, },
priceTotal: function() {
priceTotal: function(format) {
var price = 0 ; var price = 0 ;
for(var key in this.products) { for(var key in this.products) {
if(this.products[key].quantity_form > 0) { if(this.products[key].quantity_form > 0) {
price += this.products[key].quantity_form * this.products[key].price ; price += this.products[key].quantity_form * this.products[key].price ;
} }
} }
return this.formatPrice(price) ;
if(format) {
return this.formatPrice(price) ;
}
else {
return price ;
}
}, },
confirmClick: function() { confirmClick: function() {
var productsArray = {} ; var productsArray = {} ;
comment: this.comment comment: this.comment
}, },
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id],
products: productsArray,
use_credit: this.creditCheckbox
products: productsArray
}).then(response => { }).then(response => {
if(response.data.status == 'success') { if(response.data.status == 'success') {
this.orderSuccess = true ; this.orderSuccess = true ;

Loading…
Cancel
Save