/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($app_id) { if (Yii::app()->user->checkAccess($this->id . '.' . $this->action->id)) { $model = new Allotment(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Allotment'])) { $model->attributes = $_POST['Allotment']; $model->applicant_id = $app_id; if ($model->save()) { $this->redirect(Yii::app()->user->returnUrl); } } $this->render('create', array('model' => $model, 'applicant' => Applicant::model()->findByPk($app_id))); } else { $this->accessDenied(); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Room(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Room'])) { //print_r($_POST['Room']); //exit; //$roomdetails=Room::model()->findByAttributes(array('room_no'=>$_POST['Room']['room_no'])); //if($roomdetails==NULL) //{ $model->attributes = $_POST['Room']; $list = $_POST['Room']; //echo $list['floor'];exit; $cnt = count($list['room_no']); for ($i = 0; $i < $cnt; $i++) { $model = new Room(); $model->room_no = $list['room_no'][$i]; $model->no_of_bed = $list['no_of_bed'][$i]; $model->created = date('Y-m-d'); $model->floor = $list['floor']; $count = $list['no_of_bed'][$i]; $letter = 'a'; $model->save(); for ($j = 1; $j <= $count; $j++) { $model_1 = new Allotment(); $model_1->room_no = $model->id; $model_1->bed_no = $letter; $model_1->floor = $list['floor'][$i]; $model_1->status = 'C'; $model_1->save(); $letter++; } } $this->redirect(array('/hostel/room/manage')); //$this->redirect(array('/RoomDetails/create/','id'=>$_POST['Room']['room_no'])); //} } $this->render('create', array('model' => $model)); }