コード例 #1
0
 /**
  * Creates a new BrandsCityMap model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new BrandsCityMap();
     $modelBrandsCityField = new BrandsCityFieldStatusMap();
     $settings = array('BrandsCityMap' => $model, 'BrandsCityFieldStatusMap' => $modelBrandsCityField);
     if ($model->load(Yii::$app->request->post()) && $modelBrandsCityField->load(Yii::$app->request->post())) {
         // foreach ($settings as $setting) {
         $model->save();
         //}
         $model->link('chainFieldStatusMaps', $modelBrandsCityField);
         Yii::$app->session->setFlash("restaurant_notification", Yii::t("app", "Restaurant has been Mapped!"));
         return $this->redirect(['view', 'id' => $model->Id]);
     } else {
         return $this->render('create', ['model' => $model, 'modelBrandsCityField' => $modelBrandsCityField]);
     }
 }
コード例 #2
0
 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";
         }
     }
 }