Esempio n. 1
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'name ASC';
     $this->allRec = RoomType::model()->findAll($criteria);
     $this->render('index');
 }
 /**
  * Get the rows for the call sheet by querying the database
  * @return array ReserverationSheetRows
  */
 private function populateRows()
 {
     $roomTypes = RoomType::model()->findAll();
     $rows = array();
     foreach ($roomTypes as $roomType) {
         $reservationSheetRow = new ReservationSheetRow();
         $reservationSheetRow->populate($roomType, $this->dates);
         $this->rows[] = $reservationSheetRow;
     }
 }
 public function testUpdate()
 {
     $this->resetRoomTypesTable();
     $roomType = new RoomType();
     $roomType->setAttributes(array('description' => 'Double Room', 'quantity' => 2));
     $this->testAdd();
     $roomType->setAttribute('description', 'Tripple Room');
     $roomType->save();
     $criteria = new CDbCriteria();
     $criteria->condition = 'description=:description';
     $criteria->params = array(':description' => 'Tripple Room');
     $roomType = RoomType::model()->find($criteria);
     $this->assertNotNull($roomType);
 }
 /**
  * @param model $reservation
  * @return boolean True if availble/ false if not
  */
 public function isReservationAvailable($reservation)
 {
     $this->_connection = Yii::app()->db;
     /**
      * Find the type of room we're trying to reserve.
      */
     $roomType = RoomType::model()->findByPk($reservation->getAttribute('roomid'));
     if ($roomType === null) {
         return false;
     }
     $this->dropTemporaryTable();
     $this->createTemporaryTable();
     $this->populateTemporaryTable($reservation->getAttribute('datefrom'), $reservation->getAttribute('dateto'));
     $this->updateRoomCounts($reservation);
     $roomCount = $this->findMaxRoomCount();
     $reservation->setAttribute('roomsavailable', $roomType->getAttribute('quantity') - $this->findMaxRoomCount());
     if ($roomCount >= $roomType->getAttribute('quantity')) {
         return false;
     }
     return true;
 }
$form = $this->beginWidget('CActiveForm', array('id' => 'reservation-form'));
?>
<fieldset>
	<legend>
		<p class="note">Fields with <span class="required">*</span> are required.</p>
	</legend>
	
	<?php 
echo $form->errorSummary($model, "Sorry we were unable to reserve that room:");
?>
	<div class="row">
	<?php 
echo $form->labelEx($model, 'roomid');
?>
	<?php 
echo $form->dropDownList($model, 'roomid', CHtml::listData(RoomType::model()->findAll(), 'id', 'description'));
?>
	<?php 
echo $form->error($model, 'roomid');
?>
	</div>
	<div class="row">
	<?php 
echo $form->labelEx($model, 'datefrom');
$this->widget('zii.widgets.jui.CJuiDatePicker', array('attribute' => 'datefrom', 'model' => $model, 'options' => array('dateFormat' => 'yy-mm-dd'), 'htmlOptions' => array('style' => 'height:20px;')));
?>
	</div>
	<div class="row">
	<?php 
$numberOfNights = array();
for ($i = 1; $i <= 30; $i++) {
 /**
  * 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 = RoomType::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }