Browse Source

Mes commandes : distinction des commandes passées et à venir via deux onglets.

Affichage des commandes à venir par défaut.
dev
Guillaume Bourgeois 5 years ago
parent
commit
08764dbc37
4 changed files with 57 additions and 4 deletions
  1. +16
    -4
      producer/controllers/OrderController.php
  2. +15
    -0
      producer/views/order/history.php
  3. +12
    -0
      producer/web/css/screen.css
  4. +14
    -0
      producer/web/sass/order/_history.scss

+ 16
- 4
producer/controllers/OrderController.php View File

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



+ 15
- 0
producer/views/order/history.php View File

<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([

+ 12
- 0
producer/web/css/screen.css View File

.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 {

+ 14
- 0
producer/web/sass/order/_history.scss View File

display: none ; display: none ;
} }
#tabs-orders-history {
margin-bottom: 20px ;
li {
a {
color: $color1 ;
}

&.active a {
color: #333 ;
}
}
}
} }

Loading…
Cancel
Save