|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
-
-
-
- use common\logic\Document\DeliveryNote\Model\DeliveryNote;
- use yii\grid\GridView;
- use common\logic\PointSale\PointSale\Model\PointSale;
- use common\logic\Order\Order\Model\Order;
- use yii\helpers\Html;
- use yii\helpers\ArrayHelper;
- use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager;
-
- $deliveryNoteManager = $this->getDeliveryNoteManager();
-
- $this->setTitle('Bons de livraison');
- $this->addBreadcrumb($this->getTitle());
- $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon glyphicon-plus"></span>', 'url' => ['distribution/index', 'message_generate_bl' => 1], 'class' => 'btn btn-primary']);
-
- ?>
-
- <div class="delivery-note-index">
- <?php if (DeliveryNote::searchCount()): ?>
- <?= GridView::widget([
- 'filterModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- 'columns' => [
- [
- 'attribute' => 'status',
- 'label' => 'Statut',
- 'filter' => [
- 'draft' => 'Brouillon',
- 'valid' => 'Valide',
- ],
- 'format' => 'raw',
- 'value' => function ($model) use ($deliveryNoteManager) {
- return $deliveryNoteManager->getHtmlLabel($model);
- }
- ],
- [
- 'attribute' => 'reference',
- 'value' => function ($model) {
- return (strlen($model->reference) > 0) ? $model->reference : '';
- }
- ],
- 'name',
- [
- 'attribute' => 'date_distribution',
- 'header' => 'Jour de distribution',
- 'filter' => \yii\jui\DatePicker::widget([
- 'language' => 'fr',
- 'dateFormat' => 'dd/MM/yyyy',
- 'model' => $searchModel,
- 'attribute' => 'date_distribution',
- 'options' => ['class' => 'form-control']
- ]),
- 'value' => function ($model) use ($deliveryNoteManager) {
- $distribution = $deliveryNoteManager->getDistribution($model);
- return $distribution ? date('d/m/Y', strtotime($distribution->date)) : '';
- }
- ],
- [
- 'attribute' => 'id_point_sale',
- 'header' => 'Point de vente',
- 'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'),
- 'format' => 'html',
- 'value' => function ($model) use ($deliveryNoteManager) {
- $pointSale = $deliveryNoteManager->getPointSale($model);
- return $pointSale ? Html::encode($pointSale->name) : '';
- }
- ],
- [
- 'attribute' => 'amount',
- 'header' => 'Montant',
- 'value' => function ($deliveryNote) use ($deliveryNoteManager) {
- return $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true);
- }
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{validate} {update} {delete} {send} {download}',
- 'headerOptions' => ['class' => 'column-actions'],
- 'contentOptions' => ['class' => 'column-actions'],
- 'buttons' => [
- 'send' => function ($url, $deliveryNote) use ($deliveryNoteManager) {
- return ((isset($deliveryNote->user) && strlen($deliveryNote->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [
- 'title' => 'Envoyer', 'class' => 'btn btn-default'
- ]) : '');
- },
- 'download' => function ($url, $deliveryNote) {
- return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [
- 'title' => 'Télécharger', 'class' => 'btn btn-default'
- ]);
- },
- 'validate' => function ($url, $deliveryNote) use ($deliveryNoteManager) {
- return ($deliveryNoteManager->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [
- 'title' => 'Valider', 'class' => 'btn btn-default'
- ]) : '');
- },
- 'update' => function ($url, $deliveryNote) {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
- 'title' => 'Modifier', 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $deliveryNote) use ($deliveryNoteManager) {
- return ($deliveryNoteManager->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
- 'title' => 'Supprimer', 'class' => 'btn btn-default'
- ]) : '');
- }
- ],
- ],
- ],
- ]); ?>
- <?php else: ?>
- <div class="alert alert-info">Aucun bon de livraison enregistré</div>
- <?php endif; ?>
- </div>
|