public function actionIndex() { $methods = get_class_methods(__CLASS__); $arProfiles = []; foreach ($methods as $methodName) { if (strpos($methodName, 'profile') === 0) { $arProfiles[$methodName] = $this->{$methodName}('info'); } } $arrPriceType = \yii\helpers\ArrayHelper::map(\app\models\PriceType::find()->all(), 'id', 'name'); $arrPriceType = ['' => ' - Не выбран тип цены - '] + $arrPriceType; return $this->render('index', ['arProfiles' => $arProfiles, 'arrPriceType' => $arrPriceType]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = PriceType::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Lists all offers models. * @return mixed */ public function actionIndex($typePrice = null) { $gt = \app\models\GoodsType::find()->orderBy('name')->all(); $gp = \app\models\Providers::find()->orderBy('id')->all(); $goodsType = \yii\helpers\ArrayHelper::map($gt, 'type', 'name'); $goodsProvider = \yii\helpers\ArrayHelper::map($gp, 'id', 'name'); $goodsProvider = ['' => ' - Все - '] + $goodsProvider; $session = Yii::$app->session; $session->open(); $arrPriceType = \yii\helpers\ArrayHelper::map(\app\models\PriceType::find()->all(), 'id', 'name'); if ($typePrice) { $session['typePrice'] = $typePrice; $session['typePriceName'] = $arrPriceType[$typePrice]; $this->redirect('/' . $this->id); } elseif (intval($session['typePrice']) == 0) { $arW = array_keys($arrPriceType); $session['typePrice'] = array_shift($arW); $session['typePriceName'] = $arrPriceType[$session['typePrice']]; $this->redirect('/' . $this->id); } return $this->render('index', ['goodsType' => $goodsType, 'goodsProvider' => $goodsProvider, 'arrPriceType' => $arrPriceType, 'typePrice' => $session['typePrice']]); }
/** * Lists all Discounts models. * @return mixed */ public function actionIndex($providerId = null, $typePrice = null) { $session = Yii::$app->session; $session->open(); if ($providerId) { $session['providerIdFullName'] = $providerId; $provider = \app\models\Providers::findOne($providerId); $session['providerIdFullNameName'] = $provider->name; $this->redirect('/' . $this->id); } $arrPriceType = \yii\helpers\ArrayHelper::map(\app\models\PriceType::find()->all(), 'id', 'name'); if ($typePrice) { $session['typePrice'] = $typePrice; $session['typePriceName'] = $arrPriceType[$typePrice]; $this->redirect('/' . $this->id); } $searchModel = new DiscountsSearch(); $arParams = Yii::$app->request->queryParams; $arParams['DiscountsSearch']['providers_id'] = $session['providerIdFullName']; // if ($session['typePrice']) $arParams['DiscountsSearch']['price_type_id'] = $session['typePrice']; $dataProvider = $searchModel->search($arParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'providerName' => $session['providerIdFullNameName'], 'arrPriceType' => $arrPriceType, 'typePrice' => $session['typePrice'], 'typePriceName' => $session['typePriceName']]); }