fitness-web/backend/views/product/index.php

76 lines
2.2 KiB
PHP

<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ProductSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/product', 'Products');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="product-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/product', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'name',
],
[
'attribute' => 'id_product_category',
'value' => 'productCategoryName',
],
[
'attribute' => 'id_account',
'value' => 'accountName',
],
'product_number',
'barcode',
'sale_price',
'tax',
[
'attribute' => 'status',
'value' => 'statusHuman',
],
'stock',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {procurement}',
'buttons' =>[
'view' => function ($url, $model, $key) {
return Html::a( Yii::t('common/product', 'Details' ), $url,[ 'class' => 'btn btn-xs btn-primary' ]) ;
},
'update' => function ($url, $model, $key) {
return Html::a( Yii::t('common/product', 'Update' ), $url,[ 'class' => 'btn btn-xs btn-primary' ]) ;
},
'procurement' => function ($url, $model, $key) {
return Html::a( Yii::t('common/product', 'Procurement' ), $url,[ 'class' => 'btn btn-xs btn-primary' ]) ;
},
],
'urlCreator' => function ( $action, $model, $key, $index ){
$result = '';
if ( $action == 'procurement' ){
$result = Url::toRoute(['procurement/create-product' , 'id' => $model->id_product]);
}else{
$result = Url::toRoute(['product/'.$action , 'id' => $model->id_product]);
}
return $result;
}
],
],
]); ?>
</div>