/**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ProductSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->sort = ['defaultOrder' => ['title' => SORT_ASC]];
     // data provider used for export
     $exportDataProvider = $dataProvider;
     if (Yii::$app->request->isPost) {
         $exportDataProvider = $searchModel->search(Yii::$app->request->queryParams);
         $exportDataProvider->sort = ['defaultOrder' => ['id' => SORT_DESC]];
         $exportDataProvider->pagination->pageSize = 0;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'exportDataProvider' => $exportDataProvider]);
 }
 /**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ProductSearch();
     $searchModel->provider_id = $this->getProvider()->id;
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Beispiel #3
0
 public function actionGetProjects()
 {
     $this->layout = false;
     $product = new ProductSearch();
     list($pages, $models) = $product->search();
     return $this->render('products', ['resultFillter' => $models, 'pages' => $pages]);
 }
 /**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex()
 {
     $this->checkLogin();
     $this->layout = 'admin';
     $searchModel = new ProductSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Beispiel #5
0
 /**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (!Yii::$app->user->can('product/index')) {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         return $this->redirect('/');
     }
     $searchModel = new ProductSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (isset($_POST['hasEditable'])) {
         $model = Product::find()->where(['id' => Yii::$app->request->post('editableKey')])->one();
         $posted = current($_POST['Product']);
         \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         if (isset($posted['status'])) {
             return $model->saveStatusOrName($posted['status'], 'status');
         } elseif (isset($posted['name'])) {
             return $model->saveStatusOrName($posted['name'], 'name');
         }
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Beispiel #6
0
<?php

/**
 * Group partial
 */
use yii\grid\GridView;
use yii\helpers\Html;
use yii\helpers\Url;
use app\models\ProductSearch;
$app = \Yii::$app;
$productSearch = new ProductSearch();
$productDataProvider = $productSearch->search($app->request->queryParams);
$productDataProvider->pagination = ['pageParam' => 'product-page', 'pageSizeParam' => 'product-per-page', 'pageSize' => 5];
echo GridView::widget(['dataProvider' => $productDataProvider, 'filterModel' => $productSearch, 'summary' => '', 'columns' => [['attribute' => 'id'], ['attribute' => 'name'], ['attribute' => 'description'], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['view' => function ($url, $model, $key) {
    return '';
}, 'update' => function ($url, $model, $key) {
    $url = Url::to(['/product/update', 'id' => $key]);
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['data' => ['ajax-get' => '#product-form']]);
}, 'delete' => function ($url, $model, $key) {
    $url = Url::to(['product/delete', 'id' => $key]);
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['data' => ['pjax' => '0', 'method' => 'post', 'confirm' => Yii::t('app/views', 'Are you sure you want to delete this record?')]]);
}], 'contentOptions' => ['style' => 'width: 50px;']]]]);
if (\Yii::$app->request->isPjax) {
    $this->clear();
}