예제 #1
0
 /**
  * Creates a new Brands model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Brands();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->BrandId]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #2
0
 public function actionChain()
 {
     \yii::$app->user->setIdentity(\common\models\User::findByUsername('admin'));
     $usersData = \yii::$app->oldcmsdb->createCommand("SELECT * FROM tc_est_groups")->query();
     while ($row = $usersData->read()) {
         $attributes = array('Id' => $row['est_grp_id'], 'name' => htmlspecialchars_decode($row['est_grp_name'], ENT_QUOTES), 'description' => htmlspecialchars_decode($row['est_grp_desc'], ENT_QUOTES), 'guid' => $row['est_grp_url'], 'status' => $row['status'], 'ip' => $row['IP'], 'createdOn' => $row['insertdate'], 'updatedOn' => $row['insertdate'], 'createdBy' => 40, 'updatedBy' => 40);
         if (($brand = Brands::findOne($attributes['Id'])) !== null) {
         } else {
             $brand = new Brands();
         }
         $attributes['logo'] = $this->importimagefromstr($row['logo'], $brand->logoPath, 'chainLogo');
         $chainImage = \yii::$app->oldcmsdb->createCommand("select * from tc_est_media where est_flag = 'chainMainImage' and est_id='" . $row['est_grp_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 = 'chainMainMenu' and est_id='" . $row['est_grp_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)) {
             echo "Chain Id:" . $attributes['Id'] . " name:" . $attributes['name'] . ": imported\n";
         } else {
             echo "Chain Id:" . $attributes['Id'] . " name:" . $attributes['name'] . ": not imported\n";
         }
     }
 }