Browse Source

Sélection du point de vente par défaut lors de l'ajout d'une commande dans le backend

refactoring
Guillaume Bourgeois 5 years ago
parent
commit
8fe2df42c5
2 changed files with 28 additions and 14 deletions
  1. +20
    -13
      backend/controllers/DistributionController.php
  2. +8
    -1
      backend/web/js/vuejs/distribution-index.js

+ 20
- 13
backend/controllers/DistributionController.php View File

$json['orders'] = $ordersArray ; $json['orders'] = $ordersArray ;
// order create
$productOrderArray = [] ;
foreach($productsArray as $product) {
$productOrderArray[$product['id']] = 0 ;
}
$json['order_create'] = [
'id_point_sale' => 0,
'id_user' => 0,
'username' => '',
'comment' => '',
'productOrder' => $productOrderArray
] ;
// points de vente // points de vente
$pointsSaleArray = PointSale::find() $pointsSaleArray = PointSale::find()
->joinWith(['pointSaleDistribution' => function($q) use ($distribution) { ->joinWith(['pointSaleDistribution' => function($q) use ($distribution) {
->asArray() ->asArray()
->all(); ->all();
$idPointSaleDefault = 0 ;
foreach($pointsSaleArray as $pointSale) {
if($pointSale['default']) {
$idPointSaleDefault = $pointSale['id'] ;
}
}
$json['points_sale'] = $pointsSaleArray ; $json['points_sale'] = $pointsSaleArray ;
// order create
$productOrderArray = [] ;
foreach($productsArray as $product) {
$productOrderArray[$product['id']] = 0 ;
}
$json['order_create'] = [
'id_point_sale' => $idPointSaleDefault,
'id_user' => 0,
'username' => '',
'comment' => '',
'productOrder' => $productOrderArray
] ;
// utilisateurs // utilisateurs
$usersArray = User::findBy()->all() ; $usersArray = User::findBy()->all() ;
$json['users'] = $usersArray ; $json['users'] = $usersArray ;

+ 8
- 1
backend/web/js/vuejs/distribution-index.js View File

countActiveProducts: 0, countActiveProducts: 0,
pointsSale: [], pointsSale: [],
idActivePointSale: 0, idActivePointSale: 0,
idDefaultPointSale: 0,
countActivePointsSale: 0, countActivePointsSale: 0,
countOrdersByPointSale: [], countOrdersByPointSale: [],
orders: [], orders: [],
if(response.data.order_create) { if(response.data.order_create) {
app.orderCreate = response.data.order_create ; app.orderCreate = response.data.order_create ;
app.idDefaultPointSale = app.orderCreate.id_point_sale ;
} }
if(response.data.points_sale) { if(response.data.points_sale) {
}, },
setIdActivePointSale: function(id) { setIdActivePointSale: function(id) {
this.idActivePointSale = id ; this.idActivePointSale = id ;
this.orderCreate.id_point_sale = id ;
if(!id) {
this.orderCreate.id_point_sale = this.idDefaultPointSale ;
}
else {
this.orderCreate.id_point_sale = id ;
}
}, },
orderCreatedUpdated: function() { orderCreatedUpdated: function() {
this.showModalFormOrderCreate = false ; this.showModalFormOrderCreate = false ;

Loading…
Cancel
Save