/**
  * On rebuild of the search index, rebuild all space records
  *
  * @param type $event
  */
 public static function onSearchRebuild($event)
 {
     foreach (Room::model()->findAll() as $obj) {
         if ($obj->visibility != Space::VISIBILITY_NONE) {
             Yii::app()->search->add($obj);
         }
     }
 }
Exemple #2
0
 public function deleteRoom($id)
 {
     $result = Room::model()->findByAttributes(array('id' => $id));
     $result->status = '0';
     if ($result->save()) {
         $data = array('code' => 200, 'message' => 'SUCCESS');
     }
     return $data;
 }
Exemple #3
0
 /**
  * This is method for getInfo
  * @param  [int] roomId 
  * @return [array] {
  *         code:200,
  *         mes:'',
  *         data:{
  *         		roomId:1221,
  *         		roomName:'',
  *         		floor:3,
  *         		seats:8,
  *         		pic:'http://q.qlogo.cn/qqapp/1104566934/4F54EC3310FD140F55B1BCC91A06C328/100',
  *         		doneTime:[1,2,3,48],(every part instead half hour)
  *         }
  * }
  */
 public function getInfo()
 {
     $data = Room::model()->findByAttributes(array('id' => $this->roomId, 'hubId' => $this->location, 'status' => 1));
     if ($data) {
         $my = self::mySelect($this->date, $this->userId, $this->roomId, $this->location);
         $other = self::otherSelect($this->date, $this->userId, $this->roomId, $this->location);
         $value = array('info' => $data, 'my' => $my, 'other' => $other);
         return array('code' => '200', 'mes' => '', 'data' => $value);
     } else {
         return '';
     }
 }
 public function actionDeleteall($id)
 {
     $hostel = Hosteldetails::model()->findByAttributes(array('id' => $id));
     $hostel->is_deleted = '1';
     $hostel->save();
     $floor = Floor::model()->findAllByAttributes(array('hostel_id' => $id));
     foreach ($floor as $floor1) {
         $room = Room::model()->findAllByAttributes(array('floor' => $floor1->id));
         foreach ($room as $room1) {
             $allot = Allotment::model()->findAllByAttributes(array('room_no' => $room1->id));
             foreach ($allot as $allot1) {
                 $allot1->delete();
                 $floor1->delete();
                 $room1->delete();
             }
         }
     }
     $this->redirect(array('manage'));
 }
 /**
  * Returns the current selected space by parameter guid
  *
  * If space doesnt exists or there a no permissions and exception
  * will thrown.
  *
  * @return Room
  * @throws CHttpException
  */
 public function getRoom()
 {
     if ($this->room != null) {
         return $this->room;
     }
     // Get Space GUID by parameter
     $guid = Yii::app()->request->getQuery('sguid');
     if ($guid == "") {
         // Workaround for older version
         $guid = Yii::app()->request->getQuery('guid');
     }
     // Try Load the room
     $this->room = Room::model()->findByAttributes(array('guid' => $guid));
     if ($this->room == null) {
         throw new CHttpException(404, Yii::t('RoomsModule.behaviors_RoomsControllerBehavior', 'Room not found!'));
     }
     $this->checkAccess();
     // Store current space to stash
     Yii::app()->params['currentRoom'] = $this->room;
     return $this->room;
 }
 public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
 {
     if (substr($pathInfo, 0, 2) == "s/") {
         $parts = explode('/', $pathInfo, 3);
         if (isset($parts[1])) {
             $room = Room::model()->findByAttributes(array('guid' => $parts[1]));
             if ($room !== null) {
                 $_GET['sguid'] = $room->guid;
                 if (!isset($parts[2]) || substr($parts[2], 0, 4) == 'home') {
                     $temp = 1;
                     return 'rooms/room/index' . str_replace('home', '', $parts[2], $temp);
                 } else {
                     return $parts[2];
                 }
             } else {
                 throw new CHttpException('404', Yii::t('RoomsModule.components_RoomUrlRule', 'Room not found!'));
             }
         }
     }
     return false;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new RoomDetails();
     $room = Room::model()->findByAttributes(array('room_no' => $_REQUEST['id']));
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $cnt = '';
     if (isset($_POST['RoomDetails'])) {
         $roomdetails = RoomDetails::model()->findAllByAttributes(array('room_no' => $_POST['RoomDetails']['room_no']));
         $cnt = count($roomdetails);
         if ($cnt < $room->no_of_bed) {
             $model->attributes = $_POST['RoomDetails'];
             $model->status = 'C';
             if ($model->save()) {
                 //$this->redirect(array('/RoomDetails/create/','id'=>$room->id));
                 $this->redirect(array('view', 'id' => $model->id));
             }
             $cnt++;
         } else {
             $this->redirect(array('/Room/error/'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemple #8
0
                            <td align="center"><?php 
    echo Yii::t('hostel', 'Room No');
    ?>
</td>
                            <td align="center"><?php 
    echo Yii::t('hostel', 'Availability');
    ?>
</td>
                        </tr>
                        <?php 
    if ($list == NULL) {
        echo '<tr><td align="center" colspan="6"><strong>' . Yii::t('hostel', 'No data available') . '</strong></td></tr>';
    } else {
        foreach ($list as $list_1) {
            $allot = Allotment::model()->findAllByAttributes(array('room_no' => $list_1->room_no));
            $room = Room::model()->findByAttributes(array('id' => $list_1->room_no));
            $floor = Floor::model()->findByAttributes(array('id' => $room->floor));
            $hostel = Hosteldetails::model()->findByAttributes(array('id' => $floor->hostel_id));
            ?>
                        <tr>
                            <td align="center">
                                <?php 
            echo $hostel->hostel_name;
            ?>
                            <td align="center">
                                <?php 
            echo $floor->floor_no;
            ?>
                            </td>
                            <td align="center">
                                <?php 
 /**
  * Manages all models.
  */
 public function actionAdmin($room)
 {
     $model = new MacroControl('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['MacroControl'])) {
         $model->attributes = $_GET['MacroControl'];
     }
     $model->room_id = $room;
     $this->render('admin', array('model' => $model, 'mRoom' => Room::model()->findByPk($room)));
 }
Exemple #10
0
 public static function getRoomOptions()
 {
     return CHtml::listData(Room::model()->findAll(), 'ID', 'Name');
 }
Exemple #11
0
 /**
  * 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 $id the ID of the model to be loaded
  * @return Room the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Room::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'number', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('number'), 'data-content' => $model->getAttributeDescription('number')]]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'start_time', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('start_time'), 'data-content' => $model->getAttributeDescription('start_time')]]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'end_time', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('end_time'), 'data-content' => $model->getAttributeDescription('end_time')]]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->dropDownListGroup($model, 'room_id', ['widgetOptions' => ['data' => CHtml::listData(Room::model()->findAll(), 'id', 'id')]]);
?>
        </div>
		    </div>
</fieldset>

    <?php 
$this->widget('bootstrap.widgets.TbButton', ['context' => 'primary', 'encodeLabel' => false, 'buttonType' => 'submit', 'label' => '<i class="fa fa-search">&nbsp;</i> ' . Yii::t('ListnerModule.listner', 'Искать Расписание')]);
?>

<?php 
$this->endWidget();
 /**
  * Возвращает модель по указанному идентификатору
  * Если модель не будет найдена - возникнет HTTP-исключение.
  *
  * @param integer идентификатор нужной модели
  *
  * @return void
  */
 public function loadModel($id)
 {
     $model = Room::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('BranchModule.branch', 'Запрошенная страница не найдена.'));
     }
     return $model;
 }
Exemple #14
0
echo $form->labelEx($model, 'Finish');
?>
		<?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'Finish', 'value' => $model->Finish, 'options' => array('changeYear' => true, 'yearRange' => '2000:2050', 'language' => 'es', 'dateFormat' => 'yy-mm-dd', 'monthNames' => array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"), 'monthNamesShort' => array("Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"), 'dayNames' => array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"), 'dayNamesMin' => array('Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'), 'defaultDate' => $model->Finish, 'firstDay' => 1), 'htmlOptions' => array('placeholder' => 'yyyy-mm-dd', 'style' => 'width:100%;')));
?>
		<?php 
echo $form->error($model, 'Finish');
?>
	</div>
	
	<div class="row" style="width: 25%; float: left; margin-left: 5%;">
		<?php 
echo $form->labelEx($model, 'RoomID');
?>
		<?php 
echo $form->dropDownList($model, 'RoomID', CHtml::listData(Room::model()->findAll($criteria), 'ID', 'Name'), array('empty' => '-- Selecciona la habitacion --', 'style' => 'width: 100%;'));
?>
		<?php 
echo $form->error($model, 'RoomID');
?>
	</div>
	
	<div class="row" style="width: 18%; float: left; margin-left: 8%;">
		<h1 style="font-size: 18pt !important;">Total: <span style="font-size: 28pt !important;" id="pvp">0</span>&euro;</h1>
	</div>
	
	<div style="clear:both;"></div>
	
	<div class="row" style="width: 15%; float: left;">
		<?php 
echo $form->labelEx($model, 'Pax');
 /**
  * After Save Addons
  */
 protected function afterSave()
 {
     if ($this->status != self::VISIBILITY_NONE) {
         Yii::app()->search->update($this);
     } else {
         Yii::app()->search->delete($this);
     }
     $userId = $this->created_by;
     if ($this->isNewRecord) {
         // Create new wall record for this room
         $wall = new Wall();
         $wall->object_model = 'Room';
         $wall->object_id = $this->id;
         $wall->save();
         $this->wall_id = $wall->id;
         $this->wall = $wall;
         Room::model()->updateByPk($this->id, array('wall_id' => $wall->id));
         // Auto add creator as admin
         $membership = new RoomMembership();
         $membership->room_id = $this->id;
         $membership->user_id = $userId;
         $membership->status = RoomMembership::STATUS_MEMBER;
         $membership->invite_role = 1;
         $membership->admin_role = 1;
         $membership->share_role = 1;
         $membership->save();
         $activity = new Activity();
         $activity->content->created_by = $userId;
         $activity->content->room_id = $this->id;
         $activity->content->user_id = $userId;
         $activity->content->visibility = Content::VISIBILITY_PUBLIC;
         $activity->created_by = $userId;
         $activity->type = "ActivityRoomCreated";
         $activity->save();
         $activity->fire();
     }
     Yii::app()->cache->delete('userRooms_' . $userId);
     parent::afterSave();
 }
                    <input type='text' class="form-control" value="<?php 
echo $model->end_time;
?>
" name="Schedule[end_time]" />
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>

    </div>
    <div class="row">
        <div class="col-sm-7">
            <?php 
echo $form->dropDownListGroup($model, 'room_id', ['widgetOptions' => ['data' => CHtml::listData(Room::model()->findAll($model->branch), 'id', 'alias'), 'htmlOptions' => ['empty' => '--выберите--', 'encode' => false]]]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-8">
            <div class="form-group">
                <?php 
echo $form->hiddenField($model, 'teacher_id');
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'teacher_id', 'source' => CController::createUrl('/listner/schedule/teacher?branch=' . $model->room->branch_id . '&subject=' . $model->subject), 'options' => ['minLength' => '2', 'select' => 'js:function( event, ui ) {
                                $("#teacher_id").val( ui.item.label );
                                $("#Schedule_user_id").val( ui.item.value );
                                return false;
                            }'], 'htmlOptions' => ['onfocus' => 'js: this.value = null; $("#teacher_ids").val(null); $("#Schedule_user_id").val(null);', 'class' => 'input-xxlarge search-query popover-help form-control', 'placeholder' => "Введите имя преопдавателя, если вы случайно нажали, то просто обновите страницу или нажмите назад"]));
?>
            </div>
Exemple #17
0
<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'vacate-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
if (Yii::app()->controller->action->id == 'create') {
    $student_details = Allotment::model()->findByAttributes(array('student_id' => $_REQUEST['id'], 'status' => 'S'));
    $room = Room::model()->findByAttributes(array('id' => $student_details->room_no));
}
?>
<div class="formCon" >
<div class="formConInner">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
 <tr>
    <td><?php 
//echo $form->labelEx($model,'Student');
?>
</td>
    <td>&nbsp;</td>
    <td><?php 
echo $form->hiddenField($model, 'student_id', array('size' => 20, 'value' => $student_details->student_id));
?>
		<?php 
echo $form->error($model, 'student_id');
?>
</td>
 *
 * @property String $inputId is the ID of the input HTML Element
 * @property Int $maxRooms the maximum of rooms for this input
 * @property String $roomSearchUrl the url of the search, to find the rooms
 * @property String $currentValue is the current value of the parent field.
 *
 * @package humhub.modules_core.user
 * @since 0.5
 */
?>

<?php 
// Resolve guids to room tags
$newValue = "";
foreach (explode(",", $currentValue) as $guid) {
    $room = Room::model()->findByAttributes(array('guid' => trim($guid)));
    if ($room != null) {
        $imageUrl = $room->getProfileImage()->getUrl();
        $name = CHtml::encode($room->name);
        $newValue .= '<li class="roomInput" id="' . $room->guid . '"><img class="img-rounded" alt="24x24" data-src="holder.js/24x24" style="width: 24px; height: 24px;" src="' . $imageUrl . '" alt="' . $name . 'r" width="24" height="24">' . addslashes($name) . '<i class="fa fa-times-circle"></i></li>';
    }
}
?>


<script type="text/javascript">

    $('#<?php 
echo $inputId;
?>
').roompicker({
 protected function findRoom($t, $b, $x)
 {
     return Room::model()->findBySql("SELECT * FROM spbp_branch_room" . " WHERE id <> ALL(SELECT t1.id FROM spbp_branch_room t1 " . "JOIN spbp_listner_schedule t2 " . "ON t2.room_id = t1.id WHERE t2.start_time = '{$t}')  " . "AND branch_id = '{$b}' AND capacity>='{$x}' ORDER BY capacity")->id;
 }
Exemple #20
0
<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'room-details-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
$room = Room::model()->findByAttributes(array('id' => $_REQUEST['id']));
?>
		<div class="row">
		<?php 
echo $form->labelEx($model, Yii::t('hostel', 'Room No'));
?>
          <?php 
echo $form->textField($model, 'room_no', array('size' => 20, 'value' => $room->room_no));
?>
		<?php 
echo $form->error($model, 'room_no');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, Yii::t('hostel', 'Bed No'));
?>
		<?php 
echo $form->textField($model, 'bed_no', array('size' => 20));
?>
 public function actionBook()
 {
     if (isset($_POST['llegada']) && isset($_POST['salida']) && isset($_POST['maxPersonas']) && isset($_POST['habitaciones']) && isset($_POST['habitacion']) && isset($_POST['total']) && isset($_POST['room']) && floatval($_POST['total']) > 0) {
         Yii::app()->session['llegada'] = $_POST['llegada'];
         Yii::app()->session['salida'] = $_POST['salida'];
         Yii::app()->session['maxPersonas'] = $_POST['maxPersonas'];
         Yii::app()->session['habitaciones'] = $_POST['habitaciones'];
         Yii::app()->session['habitacion'] = $_POST['habitacion'];
         Yii::app()->session['total'] = $_POST['total'];
         Yii::app()->session['room'] = $_POST['room'];
         if (isset(Yii::app()->user->id)) {
             $error = false;
             $errors = [];
             $roomsToBook = [];
             $roomsAvailable = [];
             foreach (TypeRoom::model()->findAllByAttributes(array('status' => 'ACTIVE')) as $i => $type) {
                 $roomsToBook[$type->id] = 0;
                 $roomsAvailable[$type->id] = Room::model()->countByAttributes(array('type_id' => $type->id, 'status' => 'VACANT'));
             }
             foreach ($_POST['room'] as $i => $room) {
                 $roomsToBook[$room]++;
             }
             foreach ($roomsToBook as $i => $roomToBook) {
                 if ($roomToBook > 0 && $roomsAvailable[$i] < $roomToBook) {
                     $errors[$i] = 'no available';
                     $error = true;
                 }
             }
             if ($error) {
                 Yii::app()->session['noAvailable'] = $errors;
                 $this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
             } else {
                 $reservation = new Reservation();
                 $reservation->user_id = Yii::app()->user->id;
                 $reservation->arrival_date = date('Y-m-d', strtotime($_POST['llegada']));
                 $reservation->departure_date = date('Y-m-d', strtotime($_POST['salida']));
                 $reservation->number_people = $_POST['maxPersonas'];
                 $reservation->booked_date = date('Y-m-d H:i:s');
                 $reservation->status = 'CREATED';
                 $reservation->total = $_POST['total'];
                 if ($reservation->save()) {
                     foreach ($roomsToBook as $i => $roomToBook) {
                         if ($roomToBook > 0) {
                             $rooms_booked = new RoomsBooked();
                             $rooms_booked->reservation_id = $reservation->id;
                             $rooms_booked->type_room_id = $i;
                             $rooms_booked->quantity = $roomToBook;
                             if (!$rooms_booked->save()) {
                                 $error = true;
                                 break;
                             }
                         }
                     }
                     if (!$error) {
                         $this->redirect(Yii::app()->request->getBaseUrl(true) . '/site/pay/' . $reservation->id);
                     } else {
                         $this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
                     }
                 } else {
                     $this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
                 }
             }
         } else {
             $this->redirect(Yii::app()->request->getBaseUrl(true) . '#login/rp');
         }
     } else {
         $this->redirect(Yii::app()->request->getBaseUrl(true) . '#reservar');
     }
 }
Exemple #22
0
/* @var $this BookController */
/* @var $model Book */
$this->breadcrumbs = array('Reservas' => array('admin'), 'Listado');
$this->menu = array(array('label' => 'Nueva Reserva', 'url' => array('create')), array('label' => 'Listado Reservas', 'url' => array('admin')), array('label' => 'Nueva Habitacion', 'url' => array('/booking/room/create')), array('label' => 'Listado Habitaciones', 'url' => array('/booking/room/admin')), array('label' => 'Nueva Temporada', 'url' => array('/booking/season/create')), array('label' => 'Listado Temporadas', 'url' => array('/booking/season/admin')));
?>

<h1 class="header">Planning de reservas</h1>

<?php 
$criteriaRooms = new CDbCriteria();
$criteriaRooms->condition = 'UserID = :userid';
$criteriaRooms->params = array(':userid' => Yii::app()->user->ID);
$criteriaRooms->order = 'Name Desc';
$criteriaBooks = new CDbCriteria();
$criteriaBooks->condition = 'UserID = :userid';
$criteriaBooks->params = array(':userid' => Yii::app()->user->ID);
$criteriaBooks->order = 'ID';
$this->widget('ext.planning.EPlanning', array('model' => Room::model()->findAll($criteriaRooms), 'books' => Book::model()->findAll($criteriaBooks)));
?>

<div style="width:40%;padding-left: 20%;margin-top: 5%;">

<table cellpadding="0" cellspacing="2">
	<tr>
		<td width="10%" style="border: 1px solid #333;">&nbsp;</td><td>Libre</td><td>&nbsp;</td>
		<td width="10%" style="border: 1px solid #333;background: red;">&nbsp;</td><td>Reservado</td><td>&nbsp;</td>
		<td width="10%" style="border: 1px solid #333;background: #888;">&nbsp;</td><td>Cobrada</td><td>&nbsp;</td>
	</tr>
</table>

</div>
 /**
  * Returns a list of all rooms where this RoomModule is
  * enabled.
  *
  * @return Array Room
  */
 public function getRoomModuleRooms()
 {
     $rooms = array();
     foreach (Room::model()->findAll() as $s) {
         if ($s->isModuleEnabled($this->owner->getId())) {
             $rooms[] = $s;
         }
     }
     return $rooms;
 }
Exemple #24
0
 public function actionGet_data()
 {
     //	var_dump($_POST);
     $count = Room::model()->count();
     $criteria = new CDbCriteria();
     if ($_POST['searchPhrase'] != '') {
         $criteria->condition = 'style like ' . '"%' . $_POST['searchPhrase'] . '%" or  boat like ' . '"%' . $_POST['searchPhrase'] . '%" or company like ' . '"%' . $_POST['searchPhrase'] . '%"';
     }
     if (isset($_POST['sort']['id'])) {
         $criteria->order = " id  {$_POST['sort']['id']} ";
     } else {
         if (isset($_POST['sort']['style'])) {
             $criteria->order = "style {$_POST['sort']['style']} ";
         } else {
             if (isset($_POST['sort']['boat'])) {
                 $criteria->order = "boat {$_POST['sort']['boat']} ";
             } else {
                 if (isset($_POST['sort']['company'])) {
                     $criteria->order = "company {$_POST['sort']['company']}' ";
                 }
             }
         }
     }
     //	var_dump($criteria);
     //$criteria->condition= ;
     $criteria->limit = $_POST['rowCount'];
     $criteria->offset = (intval($_POST['current']) - 1) * $_POST['rowCount'];
     $model = Room::model()->findAll($criteria);
     //	var_dump($model);
     $arr = array();
     foreach ($model as $o) {
         $json = array('id' => intval($o->id), 'style' => $o->style, 'boat' => $o->boat, 'company' => $o->company);
         array_push($arr, $json);
     }
     //	var_dump( $arr);
     echo json_encode(array('rowCount' => $_POST['rowCount'], 'current' => $_POST['current'], 'rows' => $arr, 'total' => $count));
 }
Exemple #25
0
    <?php 
$this->renderPartial('/settings/hostel_left');
?>
 </td>
    <td valign="top"> 
    <div class="cont_right">
    <h1><?php 
echo Yii::t('hostel', 'Allot Room');
?>
</h1>
 <div class="formCon" >
<div class="formConInner">
 		<?php 
if (isset($_REQUEST['id']) && isset($_REQUEST['floor_id'])) {
    $floordetails = Floor::model()->findByAttributes(array('id' => $_REQUEST['floor_id']));
    $room = Room::model()->findAllByAttributes(array('floor' => $_REQUEST['floor_id']));
    //$hostel=Hosteldetails::model()->findByAttributes(array('id'=>$floordetails->hostel_id));
    ?>
			
            <div class="pdtab_Con" style="padding-top:0px;">
                             <table width="100%" cellpadding="0" cellspacing="0" border="0" >
							<tr class="pdtab-h">
								<td align="center"><?php 
    echo Yii::t('hostel', 'Floor');
    ?>
</td>
								<td align="center"><?php 
    echo Yii::t('hostel', 'Room No');
    ?>
</td>
								<td align="center"><?php 
 public function actionRoom()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $start = $_GET['start_time'];
         $branch_id = $_GET['branch_id'];
         if ($_GET['group_id'] == 0) {
             $number = 1;
         } else {
             $number = count(Group::model()->findByPk($_GET['group_id'])->positions) + 1;
         }
         if ($_GET['flag'] == "on") {
             $number = 1;
         }
         if (!Room::model()->findBySql("SELECT * FROM spbp_branch_room" . " WHERE id <> ALL(SELECT t1.id FROM spbp_branch_room t1 " . "JOIN spbp_listner_schedule t2 " . "ON t2.room_id = t1.id WHERE t2.start_time = '{$start}')  " . "AND branch_id = '{$branch_id}' AND capacity>='{$number}' ORDER BY capacity")->id) {
             echo "No room";
         }
     }
 }
Exemple #27
0
<?php

/* @var $this BookController */
/* @var $model Book */
$this->breadcrumbs = array('Reservas' => array('admin'), 'Listado');
$this->menu = array(array('label' => 'Nueva Reserva', 'url' => array('create')), array('label' => 'Planning Mensual', 'url' => array('planning')), array('label' => 'Nueva Habitacion', 'url' => array('/booking/room/create')), array('label' => 'Listado Habitaciones', 'url' => array('/booking/room/admin')), array('label' => 'Nueva Temporada', 'url' => array('/booking/season/create')), array('label' => 'Listado Temporadas', 'url' => array('/booking/season/admin')));
?>

<h1 class="header">Listado de reservas</h1>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'book-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => "function(){\n\t\t\t\t\t\t\tjQuery('#date_start').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['es'], {'dateFormat':'yy-mm-dd'}));\n\t\t\t\t\t\t\tjQuery('#date_finish').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['es'], {'dateFormat':'yy-mm-dd'}));\n\t\t\t\t\t\t}", 'columns' => array(array('name' => 'CustomerID', 'value' => '$data->customer->FullName', 'filter' => CHtml::listData(Customer::model()->findAll(), 'ID', 'FullName'), 'headerHtmlOptions' => array('style' => 'width:40%;text-align:left !important;'), 'htmlOptions' => array('style' => 'width:40%;text-align:left;')), array('name' => 'RoomID', 'value' => '$data->room->Name', 'filter' => CHtml::listData(Room::model()->findAll(), 'ID', 'Name'), 'headerHtmlOptions' => array('style' => 'width:25%;text-align:left !important;'), 'htmlOptions' => array('style' => 'width:25%;text-align:left;')), array('name' => 'Start', 'filter' => false, 'value' => 'date("d-m-Y", strtotime($data->Start))'), array('name' => 'Finish', 'filter' => false, 'value' => 'date("d-m-Y", strtotime($data->Finish))'), array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'buttons' => array('update' => array('label' => 'Editar', 'imageUrl' => Yii::app()->baseURL . '/images/edit.png'), 'delete' => array('label' => 'Borrar', 'imageUrl' => Yii::app()->baseURL . '/images/delete.png')), 'deleteConfirmation' => 'Si aceptas eliminaras este registro definitivamente.')), 'emptyText' => 'No hay registros. <a href="' . $this->createURL('create') . '">Picha</a> para crear uno.', 'summaryText' => 'Mostrando del {start} al {end} de {count} registro(s).'));
Exemple #28
0
 /**
  *	Billing and Print
  */
 public function actionGeneratePrint()
 {
     $model = Book::model()->findByPK($_GET["id"]);
     // Change Book status
     $model->Type = 1;
     $model->save();
     $items = array();
     $startDate = strtotime($model->Start);
     $finishDate = strtotime($model->Finish);
     $roomID = $model->RoomID;
     $Pax = $model->Pax;
     // Create Invoice
     $modelInvoice = new Invoice();
     $modelInvoice->UserID = Yii::app()->user->ID;
     $modelInvoice->CustomerID = $model->CustomerID;
     $modelInvoice->Date = date("Y-m-d");
     $criteriaNextNumber = new CDbCriteria();
     $criteriaNextNumber->condition = 'UserID = :userid';
     $criteriaNextNumber->params = array(':userid' => Yii::app()->user->ID);
     $criteriaNextNumber->order = 'Number Desc';
     $modelInvoice->Number = Invoice::model()->find($criteriaNextNumber)->ID + 1;
     $modelInvoice->SerieID = Serie::model()->findByAttributes(array('Pred' => '1'))->ID;
     $modelInvoice->BookID = $model->ID;
     $modelInvoice->save();
     $days = round(($finishDate - $startDate) / 86400);
     $price = 0;
     // Calculate Room price
     if (Room::model()->findByPK($roomID)->Type == 0) {
         for ($i = 0; $i < $days; $i++) {
             $date = $startDate + $i * 86400;
             $season = Book::model()->getSeason(date("Y-m-d", $date));
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
             $modelCharge->InvoiceID = $modelInvoice->ID;
             $modelCharge->IVA = User::model()->findByPK(Yii::app()->user->ID)->IVA;
             switch ($season) {
                 case 0:
                     $items[] = array($model->room->PriceLow, $model->room->Name . " (Temporada Baja).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceLow;
                     $modelCharge->Text = $model->room->Name . " (Temporada Baja).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceLow;
                     break;
                 case 1:
                     $items[] = array($model->room->PriceMed, $model->room->Name . " (Temporada Media).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceMed;
                     $modelCharge->Text = $model->room->Name . " (Temporada Media).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceMed;
                     break;
                 case 2:
                     $items[] = array($model->room->PriceBig, $model->room->Name . " (Temporada Alta).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceBig;
                     $modelCharge->Text = $model->room->Name . " (Temporada Alta).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceBig;
                     break;
             }
             $modelCharge->save();
         }
     } else {
         for ($i = 0; $i < $days; $i++) {
             $date = $startDate + $i * 86400;
             $season = Book::model()->getSeason(date("Y-m-d", $date));
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
             $modelCharge->InvoiceID = $modelInvoice->ID;
             $modelCharge->IVA = User::model()->findByPK(Yii::app()->user->ID)->IVA;
             switch ($season) {
                 case 0:
                     $items[] = array(Room::model()->findByPK($roomID)->PriceLow * $Pax, $model->room->Name . " (" . $Pax . " personas Temporada Baja).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceLow * $Pax;
                     $modelCharge->Text = $model->room->Name . " (" . $Pax . " personas Temporada Baja).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceLow * $Pax;
                     break;
                 case 1:
                     $items[] = array(Room::model()->findByPK($roomID)->PriceMed * $Pax, $model->room->Name . " (" . $Pax . " personas Temporada Media).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceMed * $Pax;
                     $modelCharge->Text = $model->room->Name . " (" . $Pax . " personas Temporada Media).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceMed * $Pax;
                     break;
                 case 2:
                     $items[] = array(Room::model()->findByPK($roomID)->PriceBig * $Pax, $model->room->Name . " (" . $Pax . " personas Temporada Alta).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceBig * $Pax;
                     $modelCharge->Text = $model->room->Name . " (" . $Pax . " personas Temporada Alta).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceBig * $Pax;
                     break;
             }
             $modelCharge->save();
         }
     }
     // Add extras to price
     if ($model->ID > 0) {
         $criteria = new CDbCriteria();
         $criteria->condition = "UserID = :userid AND BookID = :bookid";
         $criteria->params = array(':userid' => Yii::app()->user->ID, ':bookid' => $model->ID);
         $modelExtra = Extra::model()->findAll($criteria);
         foreach ($modelExtra as $extra) {
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
             $modelCharge->InvoiceID = $modelInvoice->ID;
             $modelCharge->IVA = User::model()->findByPK(Yii::app()->user->ID)->IVA;
             $items[] = array($extra->Value, $extra->Name . " (Suplemento)");
             $modelCharge->Text = $extra->Name . " (Suplemento)";
             $modelCharge->Price = $extra->Value;
             $price = $price + $extra->Value;
             $modelCharge->save();
         }
     }
     // Apply discount to price
     if ($model->ID > 0) {
         $modelDiscount = Discount::model()->findAll($criteria);
         foreach ($modelDiscount as $discount) {
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
             $modelCharge->InvoiceID = $modelInvoice->ID;
             $modelCharge->IVA = User::model()->findByPK(Yii::app()->user->ID)->IVA;
             $items[] = array(-($discount->Value * $price) / 100, $discount->Name . " (Descuento)");
             $modelCharge->Text = $discount->Name . " (Descuento)";
             $modelCharge->Price = -($discount->Value * $price / 100);
             $price = $price + -($discount->Value * $price) / 100;
             $modelCharge->save();
         }
     }
     // Print invoice
     set_time_limit(600);
     # mPDF
     $pdf = Yii::app()->ePdf->mpdf('', 'A4', '', '', '', '', '', '', '', '', 'P');
     $pdf->writeHTMLfooter = false;
     $pdf->writeHTMLheader = false;
     $pdf->DeflMargin = 25;
     $pdf->DefrMargin = 25;
     $pdf->tMargin = 15;
     $pdf->bMargin = 15;
     $pdf->w = 297;
     //manually set width
     $pdf->h = 209.8;
     //manually set height
     $pdf->WriteHTML($this->renderPartial('printbill', array('model' => $model, 'items' => $items, 'price' => $price), true));
     # Outputs ready PDF
     $pdf->Output('Factura_' . date("d/m/Y") . '.pdf', 'D');
 }