Browse Source

[backend] Distributions : Lors ajout / modification d'une commande, sélection automatique du point de vente favoris pour un utilisateur donné.

dev
Guillaume Bourgeois 5 years ago
parent
commit
fdced130d9
4 changed files with 20 additions and 8 deletions
  1. +8
    -0
      backend/controllers/DistributionController.php
  2. +7
    -7
      backend/views/distribution/index.php
  3. +4
    -0
      backend/web/js/vuejs/distribution-index.js
  4. +1
    -1
      common/models/User.php

+ 8
- 0
backend/controllers/DistributionController.php View File

// utilisateurs // utilisateurs
$usersArray = User::findBy()->all() ; $usersArray = User::findBy()->all() ;
foreach($usersArray as &$user) {
$userObject = User::findOne(['id' => $user['user_id']]) ;
$favoritePointSale = $userObject->getFavoritePointSale() ;
if($favoritePointSale) {
$user['id_point_sale_favorite'] = $favoritePointSale->id ;
}
}
$json['users'] = $usersArray ; $json['users'] = $usersArray ;
// une production de la semaine activée ou non // une production de la semaine activée ou non

+ 7
- 7
backend/views/distribution/index.php View File

</ul> </ul>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="form-group">
<label class="control-label" for="select-id-point-sale">Point de vente</label>
<select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale">
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id">{{ pointSale.name }}</option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<a v-if="producer.credit && order.id_user > 0" class="btn btn-xs btn-primary btn-credit" :href="baseUrl+'/user/credit?id='+user.id_user" v-for="user in users" v-if="user.id_user == order.id_user">{{ parseFloat(user.credit).toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}</a> <a v-if="producer.credit && order.id_user > 0" class="btn btn-xs btn-primary btn-credit" :href="baseUrl+'/user/credit?id='+user.id_user" v-for="user in users" v-if="user.id_user == order.id_user">{{ parseFloat(user.credit).toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}</a>
<label class="control-label" for="select-id-user"> <label class="control-label" for="select-id-user">
</label> </label>
<select class="form-control" v-model="order.id_user"> <select class="form-control" v-model="order.id_user">
<option value="0">--</option> <option value="0">--</option>
<option v-for="user in users" :value="user.id_user">{{ user.lastname +' '+ user.name }}</option>
<option v-for="user in users" :value="user.id_user" @click="userChange" :data-id-point-sale-favorite="user.id_point_sale_favorite">{{ user.lastname +' '+ user.name }}</option>
</select> </select>
<input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" /> <input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" />
</div> </div>
<div class="form-group">
<label class="control-label" for="select-id-point-sale">Point de vente</label>
<select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale">
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id">{{ pointSale.name }}</option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="textarea-comment">Commentaire</label> <label class="control-label" for="textarea-comment">Commentaire</label>
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea> <textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>

+ 4
- 0
backend/web/js/vuejs/distribution-index.js View File

var theQuantity = parseFloat(this.order.productOrder[id_product].quantity) + parseFloat(quantity) ; var theQuantity = parseFloat(this.order.productOrder[id_product].quantity) + parseFloat(quantity) ;
Vue.set(this.order.productOrder, id_product, {quantity: theQuantity, unit: this.order.productOrder[id_product].unit}); Vue.set(this.order.productOrder, id_product, {quantity: theQuantity, unit: this.order.productOrder[id_product].unit});
} }
},
userChange: function(event) {
var idPointSaleFavorite = event.currentTarget.getAttribute('data-id-point-sale-favorite') ;
this.order.id_point_sale = idPointSaleFavorite ;
} }
} }
}) ; }) ;

+ 1
- 1
common/models/User.php View File

} }
} }
if($pointSale) {
if(isset($pointSale)) {
return $pointSale ; return $pointSale ;
} }

Loading…
Cancel
Save