Beispiel #1
0
 public function actionMainform($isFancy = 0)
 {
     $model = new SimpleformModel();
     $model->scenario = 'forrent';
     if (isset($_POST['SimpleformModel'])) {
         $request = Yii::app()->request;
         $isForBuy = $request->getPost('isForBuy', 0);
         $model->attributes = $_POST['SimpleformModel'];
         if ($isForBuy) {
             $model->scenario = 'forbuy';
         }
         if ($model->validate()) {
             /* if($_POST['SimpleformModel']['type'] != Apartment::TYPE_RENTING){
                                $model->time_inVal = NULL;
                                $model->time_outVal = NULL;
                                $model->date_start = NULL;
                                $model->date_end = NULL;
                            }elseif ($model->time_in || $model->time_out) {
             				$model->time_inVal = $this->getI18nTimeIn($model->time_in);
             				$model->time_outVal = $this->getI18nTimeOut($model->time_out);
             			}*/
             //$types = Apartment::getI18nTypesArray();
             //$model->type = $types[$model->type];
             $notifier = new Notifier();
             $notifier->raiseEvent('onNewBooking', $model);
             Yii::app()->user->setFlash('success', tt('Operation successfully complete. Your order will be reviewed by administrator.'));
         }
     }
     $user = null;
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
     }
     $type = Apartment::getTypesWantArray();
     if ($isFancy) {
         $this->excludeJs();
         $this->renderPartial('simpleform', array('model' => $model, 'type' => $type, 'user' => $user, 'isFancy' => true), false, true);
     } else {
         $this->render('simpleform', array('model' => $model, 'type' => $type, 'user' => $user, 'isFancy' => false));
     }
 }