Browse Source

[producer] Possibilité de passer la date en paramètre du formulaire de commande

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

+ 12
- 1
producer/controllers/OrderController.php View File

]; ];
} }
public function actionOrder($id = 0)
public function actionOrder($id = 0, $date = '')
{ {
$params = [] ; $params = [] ;
if($id) { if($id) {
$order = Order::searchOne([ $order = Order::searchOne([
'id' => $id 'id' => $id
} }
} }
if(strlen($date)) {
$distribution = Distribution::searchOne([
'date' => $date,
'id_producer' => Producer::getId()
]) ;
if($distribution) {
$params['date'] = $date ;
}
}
return $this->render('order', $params) ; return $this->render('order', $params) ;
} }

+ 3
- 0
producer/views/order/order.php View File

<?php if(isset($order)): ?> <?php if(isset($order)): ?>
<span id="order-distribution-date"><?= $order->distribution->date; ?></span> <span id="order-distribution-date"><?= $order->distribution->date; ?></span>
<?php endif; ?> <?php endif; ?>
<?php if(isset($date)): ?>
<span id="distribution-date"><?= $date; ?></span>
<?php endif; ?>
<div v-if="loadingInit && distributions.length == 0" class="alert alert-warning"> <div v-if="loadingInit && distributions.length == 0" class="alert alert-warning">
Aucune distribution n'est prévue chez ce producteur. Aucune distribution n'est prévue chez ce producteur.
</div> </div>

+ 8
- 2
producer/web/js/vuejs/order-order.js View File

}, },
}, },
mounted: function() { mounted: function() {
if($('#order-distribution-date').size()) {
this.date = new Date($('#order-distribution-date').html()) ;
if($('#order-distribution-date').size() || $('#distribution-date').size()) {
if($('#order-distribution-date').size()) {
this.date = new Date($('#order-distribution-date').html()) ;
}
else {
this.date = new Date($('#distribution-date').html()) ;
}
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/' + ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ; + this.date.getFullYear() ;

Loading…
Cancel
Save