Exemplo n.º 1
0
 protected function findModel($id)
 {
     if (($model = Complex::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested complex does not exist.');
     }
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Complex::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'organization_id' => $this->organization_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function actionGetPrices()
 {
     $categoryId = (int) yii::$app->request->post('id');
     $categoryModel = Category::findOne($categoryId);
     if (yii::$app->has('organization') && ($organization = yii::$app->organization->get())) {
         $services = Service::find()->where('(calculator = "" OR calculator IS NULL) AND organization_id = :org_id', [':org_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
         $complexes = Complex::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
     } else {
         $services = Service::find()->where('calculator = "" OR calculator IS NULL')->orderBy('sort DESC, id ASC')->all();
         $complexes = Complex::find()->orderBy('sort DESC, id ASC')->all();
     }
     $priceModel = new Price();
     $json = [];
     $json['HtmlBlock'] = $this->renderPartial('order-type/net/services', ['priceModel' => $priceModel, 'categoryId' => $categoryId, 'services' => $services, 'complexes' => $complexes, 'categoryModel' => $categoryModel]);
     die(json_encode($json));
 }