|
- <?php
-
-
-
- use domain\Order\Order\Order;
- use domain\Order\Order\OrderModule;
- use domain\Producer\Producer\ProducerModule;
- use yii\grid\GridView;
-
- $orderModule = OrderModule::getInstance();
- $producerModule = ProducerModule::getInstance();
- $producer = $this->context->getProducerCurrent();
- $this->setTitle('Mes commandes') ;
-
-
- ?>
-
- <div id="index-order">
-
- <?php if($orderOk): ?>
- <div class="alert alert-success">
- <div class="icon"></div>
- Votre commande a bien été prise en compte.
- </div>
- <?php endif; ?>
-
- <?php if($cancelOk): ?>
- <div class="alert alert-success"><div class="icon"></div>Votre commande a bien été annulée.</div>
- <?php endif; ?>
-
- <ul id="tabs-orders-history" class="nav nav-tabs" role="tablist">
- <li class="nav-item">
- <a class="nav-link<?php if($type == 'incoming'): ?> active<?php endif; ?>" href="<?= \Yii::$app->urlManagerProducer->createUrl(['order/history', 'type' => 'incoming']); ?>">
- À venir
- <span class="badge <?php if($countIncoming): ?>text-bg-success<?php else: ?>text-bg-secondary<?php endif; ?>"><?= $countIncoming ?></span>
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link<?php if($type == 'passed'): ?> active<?php endif; ?>" href="<?= \Yii::$app->urlManagerProducer->createUrl(['order/history', 'type' => 'passed']); ?>">
- Passées
- <span class="badge text-bg-secondary"><?= $countPassed ?></span>
- </a>
- </li>
- </ul>
-
- <div class="table-responsive">
- <?php if($dataProviderOrders->getTotalCount()): ?>
- <?= GridView::widget([
- 'dataProvider' => $dataProviderOrders,
- 'summary' => '',
- 'beforeRow' => function($order) use ($orderModule) {
- $orderModule->initOrder($order) ;
- },
- 'columns' => [
- [
- 'attribute' => 'distribution.date',
- 'label' => 'Date de distribution',
- 'format' => 'raw',
- 'value' => function($order) use ($orderModule) {
- return $orderModule->getDateAsHtml($order) ;
- }
- ],
- [
- 'label' => 'Point de vente',
- 'format' => 'raw',
- 'value' => function($order) use ($orderModule) {
- return $orderModule->getPointSaleSummary($order);
- }
- ],
- [
- 'label' => 'Produits',
- 'format' => 'raw',
- 'value' => function($order) use ($orderModule) {
- return $orderModule->getCartSummary($order);
- }
- ],
- [
- 'label' => 'Montant',
- 'format' => 'raw',
- 'value' => function($order) use ($orderModule) {
- return $orderModule->getAmountSummary($order, 'producer');
- }
- ],
- [
- 'label' => 'Statut',
- 'format' => 'raw',
- 'value' => function($order) use ($orderModule) {
- $html = '' ;
-
- if($order->date_delete) {
- $html .= '<span class="badge text-bg-danger">Annulée</span>' ;
- }
- else {
- if($orderModule->getState($order) == Order::STATE_DELIVERED) {
- $html .= '<span class="badge text-bg-success">Livrée</span>' ;
- }
- elseif($orderModule->getState($order) == Order::STATE_PREPARATION) {
- $html .= '<span class="badge text-bg-warning">En préparation</span>' ;
- }
- elseif($orderModule->getState($order) == Order::STATE_OPEN) {
- $html .= '<span class="badge text-bg-secondary">À venir</span>' ;
- }
- }
-
- return $html ;
- }
- ],
- [
- 'label' => 'Actions',
- 'format' => 'raw',
- 'value' => function($order) use ($producer, $producerModule, $orderModule) {
- $html = '' ;
- if($orderModule->getState($order) == Order::STATE_OPEN) {
- $paymentStatus = $orderModule->getPaymentStatus($order);
- if ($producerModule->isOnlinePaymentActive($producer) && $paymentStatus == Order::PAYMENT_UNPAID && $order->online_payment_url) {
- $html .= '<a href="'.$order->online_payment_url.'" class="btn btn-secondary"><i class="bi bi-credit-card"></i> Payer en ligne</a>';
- }
- else {
- $html .= '<a data-bs-toggle="tooltip" data-bs-placement="top" title="Modifier" href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$order->id]).'" class="btn btn-secondary"><i class="bi bi-pencil"></i></a> '.
- '<a data-bs-toggle="tooltip" data-bs-placement="top" title="Annuler" href="'.Yii::$app->urlManager->createUrl(['order/cancel','id'=>$order->id]).'" class="btn btn-secondary"><i class="bi bi-trash"></i></a> '.
- (($order->id_subscription) ? '<a data-bs-toggle="tooltip" data-bs-placement="top" title="Modifier l\'abonnement associé" href="'.Yii::$app->urlManagerProducer->createUrl(['subscription/form','id'=>$order->id_subscription]).'" class="btn btn-secondary"><i class="bi bi-arrow-repeat"></i></a>' : '') ;
- }
- }
-
- return $html ;
- }
- ]
- ]
- ]); ?>
- </div>
-
- <?php else: ?>
- <div class="alert alert-dark">Aucun résultat n'a été trouvé.</div>
- <?php endif; ?>
|