Affichage des commandes à venir par défaut.dev
* | * | ||||
* @return ProducerView | * @return ProducerView | ||||
*/ | */ | ||||
public function actionHistory() | |||||
public function actionHistory($type = 'incoming') | |||||
{ | { | ||||
$dataProviderOrders = new ActiveDataProvider([ | |||||
'query' => Order::find() | |||||
$query = Order::find() | |||||
->with('productOrder', 'pointSale', 'creditHistory') | ->with('productOrder', 'pointSale', 'creditHistory') | ||||
->joinWith('distribution', 'distribution.producer') | ->joinWith('distribution', 'distribution.producer') | ||||
->where([ | ->where([ | ||||
'id_user' => Yii::$app->user->id, | 'id_user' => Yii::$app->user->id, | ||||
'distribution.id_producer' => Producer::getId() | 'distribution.id_producer' => Producer::getId() | ||||
]) | ]) | ||||
->orderBy('distribution.date DESC'), | |||||
->params([':date_today' => date('Y-m-d')]); | |||||
$queryIncoming = clone $query ; | |||||
$queryIncoming->andWhere('distribution.date >= :date_today')->orderBy('distribution.date ASC'); | |||||
$queryPassed = clone $query ; | |||||
$queryPassed->andWhere('distribution.date < :date_today')->orderBy('distribution.date DESC'); | |||||
$dataProviderOrders = new ActiveDataProvider([ | |||||
'query' => ($type == 'incoming') ? $queryIncoming : $queryPassed, | |||||
'pagination' => [ | 'pagination' => [ | ||||
'pageSize' => 10, | 'pageSize' => 10, | ||||
], | ], | ||||
'dataProviderOrders' => $dataProviderOrders, | 'dataProviderOrders' => $dataProviderOrders, | ||||
'orderOk' => Yii::$app->getRequest()->get('orderOk', false), | 'orderOk' => Yii::$app->getRequest()->get('orderOk', false), | ||||
'cancelOk' => Yii::$app->getRequest()->get('cancelOk', false), | 'cancelOk' => Yii::$app->getRequest()->get('cancelOk', false), | ||||
'type' => $type, | |||||
'countIncoming' => $queryIncoming->count(), | |||||
'countPassed' => $queryPassed->count(), | |||||
]); | ]); | ||||
} | } | ||||
<div class="alert alert-success"><div class="icon"></div>Votre commande a bien été annulée.</div> | <div class="alert alert-success"><div class="icon"></div>Votre commande a bien été annulée.</div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<ul id="tabs-orders-history" class="nav nav-tabs" role="tablist"> | |||||
<li class="<?php if($type == 'incoming'): ?>active<?php endif; ?>"> | |||||
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history', 'type' => 'incoming']); ?>"> | |||||
À venir | |||||
<span class="label <?php if($countIncoming): ?>label-success<?php else: ?>label-default<?php endif; ?>"><?= $countIncoming ?></span> | |||||
</a> | |||||
</li> | |||||
<li class="<?php if($type == 'passed'): ?>active<?php endif; ?>"> | |||||
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history', 'type' => 'passed']); ?>"> | |||||
Passées | |||||
<span class="label label-default"><?= $countPassed ?></span> | |||||
</a> | |||||
</li> | |||||
</ul> | |||||
<?= | <?= | ||||
GridView::widget([ | GridView::widget([ |
.order-history #list-producers { | .order-history #list-producers { | ||||
display: none; | display: none; | ||||
} | } | ||||
/* line 44, ../sass/order/_history.scss */ | |||||
.order-history #tabs-orders-history { | |||||
margin-bottom: 20px; | |||||
} | |||||
/* line 48, ../sass/order/_history.scss */ | |||||
.order-history #tabs-orders-history li a { | |||||
color: #BB8757; | |||||
} | |||||
/* line 52, ../sass/order/_history.scss */ | |||||
.order-history #tabs-orders-history li.active a { | |||||
color: #333; | |||||
} | |||||
/* line 3, ../sass/order/_order.scss */ | /* line 3, ../sass/order/_order.scss */ | ||||
.order-order #app-order-order { | .order-order #app-order-order { |
display: none ; | display: none ; | ||||
} | } | ||||
#tabs-orders-history { | |||||
margin-bottom: 20px ; | |||||
li { | |||||
a { | |||||
color: $color1 ; | |||||
} | |||||
&.active a { | |||||
color: #333 ; | |||||
} | |||||
} | |||||
} | |||||
} | } |