/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Roomrequest::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $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)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $reg = Registration::model()->findByAttributes(array('student_id' => $_REQUEST['studentid'])); $student = Students::model()->findByAttributes(array('id' => $_REQUEST['studentid'])); $model->student_id = $student->first_name . ' ' . $student->last_name; $model->food_preference = $reg->food_preference; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Registration'])) { $model->attributes = $_POST['Registration']; $model->student_id = $_REQUEST['studentid']; $register = Registration::model()->findByAttributes(array('student_id' => $_REQUEST['studentid'])); if ($register != NULL) { $request = Roomrequest::model()->findByAttributes(array('student_id' => $register->student_id, 'status' => 'C')); if ($request != NULL) { $request->status = 'S'; $request->save(); } $model->status = 'S'; $register->save(); } if ($model->save()) { $bed_info = Allotment::model()->findAll('status=:x AND student_id IS NULL', array(':x' => 'C')); if ($bed_info == NULL) { $this->redirect(array('/hostel/allotment/roominfo/')); } else { $this->redirect(array('/hostel/room/roomlist', 'id' => $model->student_id, 'floor_id' => $_POST['floor'])); } } } $this->render('update', array('model' => $model)); }
public function actionRoomrequest() { $model = new Roomrequest(); if (isset($_REQUEST['studentid']) && isset($_REQUEST['allotid'])) { $model->student_id = $_REQUEST['studentid']; $model->allot_id = $_REQUEST['allotid']; $model->status = 'C'; $model->created_at = date('Y-m-d H:i:s'); $model->save(); } $this->render('roomrequest', array('model' => $model, 'floor' => $_REQUEST['floor'])); }
<td width="247" valign="top"> <?php $this->renderPartial('/settings/hostel_left'); ?> </td> <td valign="top"> <div class="cont_right"> <div class="yellow_bx" style="background-image:none;width:90%;padding-bottom:45px;"> <div class="y_bx_head" style="width:90%"> <h1><?php echo Yii::t('hostel', 'Notifications'); ?> </h1> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $request = Roomrequest::model()->findAll('status=:x order by created_at DESC limit 1', array(':x' => 'C')); if ($request != NULL) { $i = 1; foreach ($request as $request_1) { echo '<tr>'; $student = Students::model()->findByAttributes(array('id' => $request_1->student_id)); $reg = Registration::model()->findByAttributes(array('student_id' => $request_1->student_id)); if ($request_1->allot_id != NULL) { $allot = Allotment::model()->findByAttributes(array('id' => $request_1->allot_id)); if ($student != NULL) { echo '<td align="center">' . $i . '</td>'; echo '<td align="center"><strong>' . ucfirst($student->last_name . ' ' . $student->first_name) . '</td>'; echo '<td align="center">' . $i . '</td>'; echo '<td align="center">' . $i . '</td>'; echo $i . ' <strong>' . ucfirst($student->first_name . ' ' . $student->last_name) . ' has been requested for changing room to' . ' ' . $allot->room_no . ' ' . $allot->bed_no . ' ' . '</strong>[ ' . CHtml::link(Yii::t('hostel', 'Allot'), array('/hostel/allotment/create', 'studentid' => $request_1->student_id, 'allotid' => $request_1->allot_id)) . ' ]<br>'; $i++;
<div id="othleft-sidebar"> <!--<div class="lsearch_bar"> <input type="text" value="Search" class="lsearch_bar_left" name=""> <input type="button" class="sbut" name=""> <div class="clear"></div> </div>--> <?php $cnt = Roomrequest::model()->findAll('status=:x', array(':x' => 'C')); function t($message, $category = 'cms', $params = array(), $source = null, $language = null) { return $message; } $this->widget('zii.widgets.CMenu', array('encodeLabel' => false, 'activateItems' => true, 'activeCssClass' => 'list_active', 'items' => array(array('label' => '' . '<h1>' . Yii::t('hostel', 'Manage Room') . '</h1>'), array('label' => '' . Yii::t('hostel', 'List Room Details') . '<span>' . Yii::t('hostel', 'All Room Details') . '</span>', 'url' => array('/hostel/Room/manage'), 'linkOptions' => array('class' => 'lbook_ico'), 'active' => Yii::app()->controller->id == 'room' and Yii::app()->controller->action->id == 'manage'), array('label' => '' . Yii::t('hostel', 'Search Room') . '<span>' . Yii::t('hostel', 'Search All Rooms') . '</span>', 'url' => array('/hostel/Room/roomsearch'), 'linkOptions' => array('class' => 'sroom_ico'), 'active' => Yii::app()->controller->id == 'room' and Yii::app()->controller->action->id == 'roomsearch'), array('label' => '' . Yii::t('hostel', 'Hostel Details') . '<span>' . Yii::t('hostel', 'Add New Hostel Details') . '</span>', 'url' => array('/hostel/Hosteldetails/manage'), 'linkOptions' => array('class' => 'lbook_ico'), 'active' => Yii::app()->controller->id == 'hosteldetails' and (Yii::app()->controller->action->id == 'create' or Yii::app()->controller->action->id == 'manage' or Yii::app()->controller->action->id == 'view' or Yii::app()->controller->action->id == 'update')), array('label' => '' . Yii::t('hostel', 'Add Room Details') . '<span>' . Yii::t('hostel', 'Add New Room Details') . '</span>', 'url' => array('/hostel/Floor/create'), 'linkOptions' => array('class' => 'abook_ico'), 'active' => Yii::app()->controller->id == 'floor' and Yii::app()->controller->action->id == 'create'), array('label' => '' . Yii::t('hostel', 'Add Mess Details') . '<span>' . Yii::t('hostel', 'Add New Mess Details') . '</span>', 'url' => array('/hostel/foodInfo/manage'), 'linkOptions' => array('class' => 'abook_ico'), 'active' => Yii::app()->controller->id == 'foodInfo' and (Yii::app()->controller->action->id == 'create' or Yii::app()->controller->action->id == 'manage' or Yii::app()->controller->action->id == 'update' or Yii::app()->controller->action->id == 'view')), array('label' => '' . '<h1>' . Yii::t('hostel', 'Room') . '</h1>'), array('label' => '' . Yii::t('hostel', 'Allot Room') . '<span>' . Yii::t('hostel', 'Allot New Room') . '</span>', 'url' => array('/hostel/registration/create'), 'linkOptions' => array('class' => 'aroom_ico'), 'active' => Yii::app()->controller->id == 'registration' and Yii::app()->controller->action->id == 'create' or Yii::app()->controller->id == 'room' and (Yii::app()->controller->action->id == 'change' or Yii::app()->controller->action->id == 'roomlist') or Yii::app()->controller->id == 'allotment' and Yii::app()->controller->action->id == 'create'), array('label' => '' . Yii::t('hostel', 'Change Room') . '<span>' . Yii::t('hostel', 'Manage Rooms') . '</span>', 'url' => array('/hostel/Room/roomchange'), 'linkOptions' => array('class' => 'c_room_ico'), 'active' => Yii::app()->controller->id == 'room' and Yii::app()->controller->action->id == 'roomchange'), array('label' => '' . Yii::t('hostel', 'Vacate') . '<span>' . Yii::t('hostel', 'Manage Rooms') . '</span>', 'url' => array('/hostel/Vacate/roomvacate'), 'linkOptions' => array('class' => 'vroom_ico'), 'active' => Yii::app()->controller->id == 'vacate' and (Yii::app()->controller->action->id == 'roomvacate' or Yii::app()->controller->action->id == 'create' or Yii::app()->controller->action->id == 'view')), array('label' => '' . '<h1>' . Yii::t('hostel', 'Settings') . '</h1>'), array('label' => '' . Yii::t('hostel', 'View Student Details') . '<span>' . Yii::t('hostel', 'All Student Details') . '</span>', 'url' => array('/hostel/MessManage/manage'), 'linkOptions' => array('class' => 'vsd_ico'), 'active' => Yii::app()->controller->id == 'messManage' and (Yii::app()->controller->action->id == 'manage' or Yii::app()->controller->action->id == 'messdetails' or Yii::app()->controller->action->id == 'Payfees') or Yii::app()->controller->id == 'allotment' and Yii::app()->controller->action->id == 'view' or Yii::app()->controller->id == 'messmanage' and Yii::app()->controller->action->id == 'payfees'), array('label' => '' . Yii::t('hostel', 'Mess Manage') . '<span>' . Yii::t('hostel', 'Manage Mess Details') . '</span>', 'url' => array('/hostel/MessManage/messinfo'), 'linkOptions' => array('class' => 'm_manage_ico'), 'active' => Yii::app()->controller->id == 'messManage' and Yii::app()->controller->action->id == 'messinfo' or Yii::app()->controller->id == 'registration' and Yii::app()->controller->action->id == 'Change'), array('label' => '' . Yii::t('hostel', 'View Mess Dues') . '<span>' . Yii::t('hostel', 'Manage Mess Dues') . '</span>', 'url' => array('/hostel/settings/settings'), 'linkOptions' => array('class' => 'vmd_ico'), 'active' => Yii::app()->controller->id == 'settings' and Yii::app()->controller->action->id == 'settings'), array('label' => '' . Yii::t('hostel', 'Notifications(' . count($cnt) . ')') . '<span>' . Yii::t('hostel', 'View Notifications') . '</span>', 'url' => array('/hostel/settings/notifications'), 'linkOptions' => array('class' => 'notify_ico'), 'active' => Yii::app()->controller->id == 'settings' and Yii::app()->controller->action->id == 'notifications')))); ?> </div> <script type="text/javascript"> $(document).ready(function () { //Hide the second level menu $('#othleft-sidebar ul li ul').hide(); //Show the second level menu if an item inside it active $('li.list_active').parent("ul").show(); $('#othleft-sidebar').children('ul').children('li').children('a').click(function () { if($(this).parent().children('ul').length>0){ $(this).parent().children('ul').toggle(); } });