Przeglądaj źródła

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

refactoring
Guillaume Bourgeois 5 lat temu
rodzic
commit
f666c1f33b
3 zmienionych plików z 23 dodań i 3 usunięć
  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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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() ;

Ładowanie…
Anuluj
Zapisz