/
var
/
www
/
vhosts
/
nabawater
/
backend
/
views
/
mall-product
/
/var/www/vhosts/nabawater/backend/views/mall-product
mkdir
upload
Name
Size
Mode
Actions
create.php
563
0644
edit
dl
rm
index.php
5109
0644
edit
dl
rm
update.php
565
0644
edit
dl
rm
_form.php
1890
0644
edit
dl
rm
Edit:
/var/www/vhosts/nabawater/backend/views/mall-product/index.php
(5109B)
<?php use backend\components\CGridView; use backend\models\MallProduct; use yii\helpers\Html; use yii\helpers\Url; use common\helpers\UploadHelper; /* @var $this \yii\web\View */ /* @var $model \backend\models\MallProduct */ /* @var $dataProvider \backend\models\MallProductSearch */ $this->title = yii::t('backend','Mall Product Management'); ?> <div class="card"> <div class="row"> <div class="card-body"> <div class="card-title"> <h3> <?= $this->title ?> <?= Html::a('<i class="fa fa-plus-circle"></i>'.' '. Yii::t('backend', 'Create'), ['create'], ['class' => 'btn btn-info d-none d-lg-block m-l-15 pull-right']) ?> </h3> </div> <?php echo CGridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => \yii\grid\SerialColumn::className()], [ 'attribute' => 'product_image_path', 'format' => 'raw', 'value' => function (MallProduct $model) { $uploadHelper = UploadHelper::getInstance(); $url = ($model->product_image_path != null && !empty($model->product_image_path)) ? $model->product_image_path : ''; return Html::img($url, ['alt'=>'ProductImage','width'=>'80','height'=>'70', 'class' => 'img-responsive img-thumbnail']); } ], [ 'attribute' => 'product_name', 'filterInputOptions' => ['class' => 'form-control col-md-8'], 'value' => function (MallProduct $model) { return $model->product_name; } ], 'price', [ 'attribute' => 'product_status', 'filter' => [MallProduct::ACTIVE => 'active', MallProduct::INACTIVE => 'Inactive'], 'filterInputOptions' => ['class' => 'select2 form-control col-md-6', 'prompt' => 'All'], 'format' => 'raw', 'value' => function (MallProduct $model) { $id = Html::getInputId($model, 'product_status') . "-{$model->getPrimaryKey()}"; $html = Html::activeCheckbox($model, 'product_status', ['data-size'=> 'mini','data-toggle' => 'switch', 'label' => false, 'id' => $id]); $html .= Html::tag('span', Html::label('', $id)); return Html::tag('div', $html, ['class' => 'bootstrap-switch']); } ], [ 'class' => \yii\grid\ActionColumn::className(), 'header' => Yii::t('backend', 'Actions'), 'template' => '{update}{delete}', 'buttons' => [ 'update' => function ($url, $model, $key) { $html = Html::tag('span', '', ['class' => 'fa fa-pencil text-inverse m-r-10']); return Html::a($html, $url); }, 'delete' => function ($url, $model, $key) { $html = Html::tag('span', '', ['class' => 'fa fa-trash-o']); return Html::a($html, $url, [ 'data-pjax' => '0', 'data-confirm' => yii::t('backend', 'Are you sure you want to delete this item?'), 'data-method' => 'post' ]); }, ], ], ] ]); ?> </div> </div> </div> <script type="text/javascript"> runOnLoad(function () { var $this; $("[data-size = mini]").on('switchChange.bootstrapSwitch', function () { $this = $(this); var url_val = '<?= Url::to(['change-status']) ?>'; Core.ajax({ url: url_val, data: {key: $this.closest('tr').attr('data-key'), status: Core.checkboxBoolToInt($this.is(':checked'))}, done: function (json) { if (parseInt(json.status) === 1) { Core.success(json.msg); return; } $this.attr('checked', !$this.is(':checked')); } }); }); $("[data-size = mini]").bootstrapSwitch(); $(".select2").select2(); }) </script>
Save
cmd:
run