]; | ]; | ||||
} | } | ||||
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) ; | ||||
} | } | ||||
<?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> |
}, | }, | ||||
}, | }, | ||||
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() ; |