示例#1
0
 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]);
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * 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']]);
 }
示例#4
0
 /**
  * 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']]);
 }
示例#5
0
 /**
  * Finds the PriceType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PriceType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PriceType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPriceType()
 {
     return $this->hasOne(PriceType::className(), ['id' => 'price_type_id']);
 }