|
- <?php
-
-
-
- use common\helpers\GlobalParam;
- use common\helpers\Image;
- use common\helpers\Price;
- use lo\widgets\Toggle;
- use yii\grid\GridView;
- use yii\helpers\Html;
-
- $productModule = $this->getProductModule();
-
- $this->setTitle('Produits');
- $this->addBreadcrumb($this->getTitle());
- $this->addButton(['label' => 'Nouveau produit <span class="glyphicon glyphicon-plus"></span>', 'url' => 'product/create', 'class' => 'btn btn-primary']);
-
- ?>
-
- <span style="display: none;" id="page-size"><?= $dataProvider->pagination->pageSize; ?></span>
- <div class="product-index">
- <?= GridView::widget([
- 'filterModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- 'columns' => [
- [
- 'attribute' => 'order',
- 'headerOptions' => ['class' => 'order column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- 'format' => 'raw',
- 'filter' => '',
- 'value' => function ($model) {
- return '<a class="btn-order btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>';
- }
- ],
- [
- 'attribute' => 'photo',
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'td-photo column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- 'filter' => '',
- 'value' => function ($model) {
- if (strlen($model->photo)) {
- return '<img class="photo-product" src="' . Image::getThumbnailSmall($model->photo, true) . '" />';
- }
- return '';
- }
- ],
- 'name',
- [
- 'attribute' => 'description',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- ],
- [
- 'attribute' => 'id_product_category',
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'td-product-category column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- 'filter' => '',
- 'value' => function ($model) {
- if ($model->productCategory) {
- return $model->productCategory->name;
- }
- return '';
- }
- ],
- [
- 'attribute' => 'id_tax_rate',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- 'value' => function ($model) {
- if ($model->id_tax_rate == 0 || $model->id_tax_rate == null) {
-
-
- $taxRateDefault = GlobalParam::getCurrentProducer()->taxRate;
-
- $return = $taxRateDefault->name;
- } else {
-
- $return = $model->taxRate->name;
- }
- return $return;
- }
- ],
- [
- 'attribute' => 'price',
- 'value' => function ($model) use ($productModule) {
- $return = '';
- if ($model->price) {
- $return = Price::format($productModule->getPriceWithTax($model)) . ' (' . $productModule->getSolver()->strUnit($model, 'wording_unit', true) . ')';
- }
- return $return;
- }
- ],
- [
- 'attribute' => 'status',
- 'label' => 'Actif',
- 'headerOptions' => ['class' => 'active column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'center column-hide-on-mobile'],
- 'format' => 'raw',
- 'filter' => [0 => 'Non', 1 => 'Oui'],
- 'value' => function ($model) {
- return Toggle::widget(
- [
- 'name' => 'active',
- 'checked' => $model->status,
- 'options' => [
- 'data-id' => $model->id,
- 'data-on' => 'Oui',
- 'data-off' => 'Non',
- ],
- ]
- );
- }
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {delete}',
- 'headerOptions' => ['class' => 'column-actions'],
- 'contentOptions' => ['class' => 'column-actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
- 'title' => 'Modifier', 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
- 'title' => 'Supprimer', 'class' => 'btn btn-default'
- ]);
- }
- ],
- ],
- ],
- ]); ?>
- </div>
|