コード例 #1
0
 public function actionCreate()
 {
     $model = new Floor();
     $model->dpid = $this->companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('Floor');
         $se = new Sequence("floor");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         //var_dump($model);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('floor/index', 'companyId' => $this->companyId));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Floor();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Floor'])) {
         $Floor = Floor::model()->findByAttributes(array('hostel_id' => $_POST['Floor']['hostel_id'], 'floor_no' => $_POST['Floor']['floor_no']));
         $model->attributes = $_POST['Floor'];
         $model->hostel_id = $_POST['Floor']['hostel_id'];
         if ($Floor != NULL) {
             $err_flag = 1;
         }
         if ($model->save() && $err_flag == 0) {
             $this->redirect(array('/hostel/room/create/', 'id' => $model->id));
         } elseif ($err_flag == 1) {
             Yii::app()->user->setFlash('errorMessage', UserModule::t("The floor number is already taken!"));
             $this->redirect(array('create', 'hostel_id' => $_POST['Floor']['hostel_id']));
         }
     }
     $this->render('create', array('model' => $model));
 }