/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new MessFee();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['MessFee'])) {
         $model->attributes = $_POST['MessFee'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Allotment();
     $model_1 = new MessFee();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Allotment'])) {
         $model_1 = new MessFee();
         $data = Allotment::model()->findByAttributes(array('student_id' => $_REQUEST['studentid']));
         $allot = Allotment::model()->findByAttributes(array('id' => $_REQUEST['allotid']));
         if ($data != NULL) {
             if ($allot->status == 'S') {
                 $this->redirect(array('alloterror'));
             }
             $vacate = new Vacate();
             $request = Roomrequest::model()->findByAttributes(array('student_id' => $data->student_id, 'status' => 'C'));
             if ($request != NULL) {
                 $request->status = 'S';
                 $request->save();
             }
             //$bed=RoomDetails::model()->findByAttributes(array('bed_no'=>$data->bed_no));
             $data->student_id = NULL;
             $data->status = 'C';
             $data->created = '';
             $vacate->student_id = $_REQUEST['studentid'];
             $vacate->room_no = $data->room_no;
             $vacate->allot_id = $data->id;
             $vacate->status = 'C';
             $vacate->admit_date = $data->created;
             $vacate->vacate_date = date('Y-m-d');
             $vacate->save();
             $data->save();
         } else {
             $model_1->student_id = $_REQUEST['studentid'];
             $model_1->created = date('Y-m-d');
             $model_1->status = 'C';
             $model_1->save();
         }
         $allot->student_id = $_REQUEST['studentid'];
         $allot->status = 'S';
         $allot->floor = $_REQUEST['floor_id'];
         $allot->created = date('Y-m-d');
         $allot->save();
         $this->redirect(array('view', 'id' => $allot->id));
         //$bed->save();
         //else
         //{
         //$model_1->student_id=$allot->id;
         //}
         //$model->attributes=$_POST['Allotment'];
         //$model->student_id=$_REQUEST['studentid'];
         //$model->status='S';
         //$bed_info=RoomDetails::model()->findByAttributes(array('bed_no'=>$_POST['Allotment']['bed_no'],'status'=>'C'));
         //if($bed_info==NULL)
         //{
         //$this->redirect(array('/allotment/roominfo/'));
         //}
         //else
         //{
         //$model->room_no=$bed_info->room_no;
         //if($model->save())
         //}
     }
     $this->render('create', array('model' => $model));
 }