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