Parcourir la source

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

dev
Guillaume Bourgeois il y a 5 ans
Parent
révision
f666c1f33b
3 fichiers modifiés avec 23 ajouts et 3 suppressions
  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 Voir le fichier

@@ -63,9 +63,10 @@ class OrderController extends ProducerBaseController
];
}
public function actionOrder($id = 0)
public function actionOrder($id = 0, $date = '')
{
$params = [] ;
if($id) {
$order = Order::searchOne([
'id' => $id
@@ -77,6 +78,16 @@ class OrderController extends ProducerBaseController
}
}
if(strlen($date)) {
$distribution = Distribution::searchOne([
'date' => $date,
'id_producer' => Producer::getId()
]) ;
if($distribution) {
$params['date'] = $date ;
}
}
return $this->render('order', $params) ;
}

+ 3
- 0
producer/views/order/order.php Voir le fichier

@@ -46,6 +46,9 @@ $this->setTitle('Commander') ;
<?php if(isset($order)): ?>
<span id="order-distribution-date"><?= $order->distribution->date; ?></span>
<?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">
Aucune distribution n'est prévue chez ce producteur.
</div>

+ 8
- 2
producer/web/js/vuejs/order-order.js Voir le fichier

@@ -60,8 +60,14 @@ var app = new Vue({
},
},
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)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;

Chargement…
Annuler
Enregistrer