/**
  * Finds the BrandsCityMap model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BrandsCityMap the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BrandsCityMap::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 = BrandsCityMap::find()->where('status=0');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'chainId' => $this->chainId, 'cityId' => $this->cityId, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'pricefortwo', $this->pricefortwo])->andFilterWhere(['like', 'cusinies', $this->cusinies])->andFilterWhere(['like', 'specilities', $this->specilities])->andFilterWhere(['like', 'whichType', $this->whichType])->andFilterWhere(['like', 'crowd', $this->crowd])->andFilterWhere(['like', 'entityType', $this->entityType])->andFilterWhere(['like', 'facebookUrl', $this->facebookUrl])->andFilterWhere(['like', 'serves', $this->serves])->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'ip', $this->ip]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChainCityMap()
 {
     return $this->hasOne(BrandsCityMap::className(), ['Id' => 'chainCityMapid']);
 }
 public function actionCitychain()
 {
     \yii::$app->user->setIdentity(\common\models\User::findByUsername('admin'));
     $usersData = \yii::$app->oldcmsdb->createCommand("SELECT * \n                    FROM \n                        tc_group_city_mapping")->query();
     while ($row = $usersData->read()) {
         $attributes = array('Id' => $row['id'], 'chainId' => $row['chain_id'], 'cityId' => $row['city_id'], 'name' => htmlspecialchars_decode($row['establishment_name'], ENT_QUOTES), 'website' => $row['establishment_website'], 'pricefortwo' => $row['price_for_two'], 'cusinies' => $row['cusinies'], 'specilities' => $row['specilities'], 'whichType' => $row['est_which_type'], 'crowd' => $row['crowd'], 'type' => $row['establishment_type'], 'facebookUrl' => $row['facebook_url'], 'serves' => $row['serves'], 'guid' => $row['guid'], 'createdBy' => 40, 'updatedBy' => 40, 'createdOn' => $row['insert_date'], 'updatedOn' => $row['modified_date'], 'status' => $row['status']);
         if (($brand = BrandsCityMap::findOne($attributes['Id'])) !== null) {
         } else {
             $brand = new BrandsCityMap();
         }
         $chainImage = \yii::$app->oldcmsdb->createCommand("select * from tc_est_media where est_flag = 'chainCityMapp' and est_id='" . $row['id'] . "' and status=1 order by est_priority")->query();
         $images = [];
         while ($img = $chainImage->read()) {
             $images[] = ['media_id' => $img['est_media_id'], 'media_name' => $img['est_media_name'], 'media_caption' => $img['est_media_caption'], 'flag' => $img['est_flag'], 'created_by' => $img['created_by'], 'insertdate' => $img['insertdate'], 'IP' => $img['IP'], 'priority' => $img['est_priority']];
         }
         $attributes['media'] = Import::importMediaData($images, $brand->imagePath);
         $chainmenu = \yii::$app->oldcmsdb->createCommand("select * from tc_est_media where est_flag = 'chainmenu' and est_id='" . $row['id'] . "' and status=1 order by est_priority")->query();
         $images = [];
         while ($img = $chainmenu->read()) {
             $images[] = ['media_id' => $img['est_media_id'], 'media_name' => $img['est_media_name'], 'media_caption' => $img['est_media_caption'], 'flag' => $img['est_flag'], 'created_by' => $img['created_by'], 'insertdate' => $img['insertdate'], 'IP' => $img['IP'], 'priority' => $img['est_priority']];
         }
         $attributes['menu'] = Import::importMediaData($images, $brand->menuimagePath);
         $brand->detachBehavior('timestamp');
         $brand->detachBehavior('user');
         $brand->setAttributes($attributes);
         $brand->Id = $attributes['Id'];
         if ($brand->save(false, null, $attributes, false)) {
             echo "Map Id:" . $attributes['Id'] . ": imported\n";
         } else {
             echo "Map Id:" . $attributes['Id'] . ": not imported\n";
         }
     }
 }
 /**
  * Validate Chain City Map
  * @return mixed
  */
 public function actionValidate($id = 0)
 {
     if ($id) {
         if (($model = BrandsCityMap::findOne($id)) !== null) {
         } else {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     } else {
         $model = new BrandsCityMap();
     }
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
 }
Esempio n. 6
0
    <?php 
// $form->field($model, 'sourceId')->textInput()
?>
    
   <?php 
// $form->field($model, 'chainId')->dropDownList(ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\Brands::find()->andWhere(['status' => 1])->All(), 'Id', 'name')))
?>
 
    
   <?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, 'chainId')->widget(DepDrop::classname(), ['options' => ['id' => Html::getInputId($model, 'chainId')], 'data' => ArrayHelper::merge(['' => 'Select'], ArrayHelper::map(\common\models\BrandsCityMap::find()->andWhere(['status' => 1, 'cityId' => $model->cityId])->All(), 'Id', 'name')), 'type' => DepDrop::TYPE_SELECT2, 'pluginOptions' => ['depends' => [Html::getInputId($model, 'cityId')], 'placeholder' => 'Select Chain', 'url' => Url::to(['/chaincitymap/brands-city-map/autosuggest'])], 'select2Options' => ['pluginEvents' => ['change' => "function(v){//debug(v);\n                                                                                            if(typeof v.val != 'undefined'){\n                                                                                                jQuery('#" . $form->id . "').FormHelper('load','" . Url::to(['/restaurant/restaurant/loadchain']) . "');\n                                                                                            }else{\n                                                                                                jQuery('#" . $form->id . "').FormHelper('unlockfields');\n                                                                                            }\n                                                                                        }"]]]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 255]);
?>

    <?php 
if ($model->name != '') {
    ?>
        
    <?php 
    Callout::begin(['options' => ['class' => 'callout-danger', 'header' => 'Password Logic']]);
    ?>
     <p></p>
    <ul>
Esempio n. 7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChainCityMaps()
 {
     return $this->hasMany(BrandsCityMap::className(), ['chainId' => 'Id']);
 }