/** * Finds the Theatre model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Theatre the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Theatre::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Theatre::find(); $query->andFilterWhere(['state' => AppActiveRecord::STATUS_DELETE]); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->andFilterWhere([Theatre::tableName() . '.status' => '0']); $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'cityId' => $this->cityId, 'gpsLat' => $this->gpsLat, 'gpsLong' => $this->gpsLong, 'status' => $this->status, 'hotelId' => $this->hotelId, 'noofscreens' => $this->noofscreens, 'zoneId' => $this->zoneId, 'localityId' => $this->localityId, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'entityType' => $this->entityType, 'state' => $this->state]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'facility', $this->facility])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'tollfree', $this->tollfree])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'facebookUrl', $this->facebookUrl])->andFilterWhere(['like', 'pincode', $this->pincode])->andFilterWhere(['like', 'landmark', $this->landmark])->andFilterWhere(['like', 'bookingNumber', $this->bookingNumber])->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Theatre::find()->where('status!=0'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]); $query->andWhere("not ((`state`=" . AppActiveRecord::STATUS_DRAFT . ") AND (`createdBy`!=" . \yii::$app->user->id . "))"); if (!($this->load($params) && $this->validate())) { $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]); return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'cityId' => $this->cityId, 'gpsLat' => $this->gpsLat, 'gpsLong' => $this->gpsLong, 'status' => $this->status, 'hotelId' => $this->hotelId, 'noofscreens' => $this->noofscreens, 'zoneId' => $this->zoneId, 'localityId' => $this->localityId, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'entityType' => $this->entityType, 'state' => $this->state]); if ($this->state !== null) { if ($this->state == AppActiveRecord::STATUS_DRAFT) { $query->andFilterWhere(['state' => $this->state, 'createdBy' => \yii::$app->user->id]); } else { $query->andFilterWhere(['state' => $this->state]); } } else { $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]); } $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'facility', $this->facility])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'tollfree', $this->tollfree])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'facebookUrl', $this->facebookUrl])->andFilterWhere(['like', 'pincode', $this->pincode])->andFilterWhere(['like', 'landmark', $this->landmark])->andFilterWhere(['like', 'bookingNumber', $this->bookingNumber])->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
<?php echo $form->field($model, 'status')->hiddenInput(['value' => 1])->label(''); ?> <?php echo $form->field($model, 'sync_source')->hiddenInput(['value' => 'New'])->label(''); ?> <?php echo $form->field($model, 'cityId')->dropDownList(ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\City::find()->andWhere(['status' => 1])->All(), 'Id', 'name'))); ?> <?php echo $form->field($model, 'theaterId')->widget(DepDrop::classname(), ['options' => ['id' => strtolower($model->formName()) . '-theaterId'], 'data' => ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\Theatre::find()->andWhere(['status' => 1, 'cityId' => $model->cityId])->All(), 'Id', 'name')), 'type' => DepDrop::TYPE_SELECT2, 'pluginOptions' => ['depends' => [strtolower($model->formName()) . '-cityid'], 'placeholder' => 'Select Theater', 'url' => Url::to(['/movieschedule/movie-theater-map/autosuggest'])]]); if (isset($model->movieId)) { echo $form->field($model, 'movieId')->textInput(['disabled' => 'disabled']); //echo $form->field($model, '')->label('moviename',['moviename'=>'atul']); echo Html::label('Movie Name - ' . $model->moviename, 'movieId'); } else { echo $form->field($model, 'movieId')->widget(Select2::className(), ['options' => ['class' => 'form-control', 'placeholder' => 'Search for a Movie.'], 'pluginOptions' => ['createSearchChoice' => new JsExpression("function(term, data) {\n\t\tif (\$(data).filter(function() {\n\t\treturn this.text.localeCompare(term) === 0;\n\t\t}).length === 0) {\n\t\treturn {\n\t\tid: term,\n\t\ttext: term\n\t\t};\n\t\t}\n\t\t}"), 'minimumInputLength' => 2, 'maximumInputLength' => 10, 'initSelection' => new JsExpression('function (element, callback) { }'), 'ajax' => ["url" => Yii::$app->urlManager->createUrl(['/movieschedule/movie-theater-map/movieautosuggest']), "dataType" => 'json', "data" => new JsExpression('function(term, page) { return { "search": term }; }'), "results" => new JsExpression('function(data, page) { return { results: data }; }')]]]);
/** * @return \yii\db\ActiveQuery */ public function getTheatre() { return $this->hasOne(Theatre::className(), ['Id' => 'theatreId']); }
/** * Function for locality auto suggestion */ public function actionAutosuggest() { $request = Yii::$app->request->post(); //var_dump($request); list($city) = $request['depdrop_parents']; if ($city == 'Loading ...') { $city = ''; } //$model = new Locality; $data = \common\models\Theatre::find()->where(['status' => 1, 'cityId' => $city])->all(); $dataLoc = array(); foreach ($data as $value) { $obj = new \stdClass(); $obj->id = $value->Id; $obj->name = $value->name; $dataLoc[] = $obj; } //echo "<pre>"; //var_dump($dataLoc); $result = new \stdClass(); $result->output = $dataLoc; $result->selected = ""; header('Content-Type: application/json'); echo Json::encode($result); \yii::$app->end(); }