示例#1
0
 public function deleteRoom(Request $request)
 {
     $input = $request->all();
     $room = Room::find($input['id']);
     $room->delete();
     return $this->showRoom();
 }
 public function actionMultipleGrid()
 {
     /**
      * Reservations
      */
     $reservationsQuery = Reservation::find();
     $reservationsSearchModel = new ReservationSearch();
     if (isset($_GET['ReservationSearch'])) {
         $reservationsSearchModel->load(Yii::$app->request->get());
         $reservationsQuery->joinWith(['customer']);
         $reservationsQuery->andFilterWhere(['LIKE', 'customer.name', $reservationsSearchModel->getAttribute('customer.name')]);
         $reservationsQuery->andFilterWhere(['LIKE', 'customer.surname', $reservationsSearchModel->getAttribute('customer.surname')]);
         $reservationsQuery->andFilterWhere(['id' => $reservationsSearchModel->id, 'customer_id' => $reservationsSearchModel->customer_id, 'room_id' => $reservationsSearchModel->room_id, 'price_per_day' => $reservationsSearchModel->price_per_day]);
     }
     $resultQueryAveragePricePerDay = $reservationsQuery->average('price_per_day');
     $dataProvider = new ActiveDataProvider(['query' => $reservationsQuery, 'sort' => ['sortParam' => 'reservations-sort-param'], 'pagination' => ['pageSize' => 10, 'pageParam' => 'reseravations-page-param']]);
     $reservationsDataProvider = new ActiveDataProvider(['query' => $reservationsQuery, 'sort' => ['sortParam' => 'reservations-sort-param'], 'pagination' => ['pageSize' => 10, 'pageParam' => 'reservations-page-param']]);
     /**
      * Rooms
      */
     $roomsQuery = Room::find();
     $roomsSearchModel = new Room();
     if (isset($_GET['Room'])) {
         $roomsSearchModel->load(Yii::$app->request->get());
         $roomsQuery->andFilterWhere(['id' => $roomsSearchModel->id, 'floor' => $roomsSearchModel->floor, 'room_number' => $roomsSearchModel->room_number, 'has_conditioner' => $roomsSearchModel->has_conditioner, 'has_phone' => $roomsSearchModel->has_phone, 'has_tv' => $roomsSearchModel->has_tv, 'available_from' => $roomsSearchModel->available_from]);
     }
     $roomsDataProvider = new ActiveDataProvider(['query' => $roomsQuery, 'sort' => ['sortParam' => 'rooms-sort-param'], 'pagination' => ['pageSize' => 10, 'pageParam' => 'rooms-page-param']]);
     return $this->render('multipleGrid', ['reservationsDataProvider' => $reservationsDataProvider, 'reservationsSearchModel' => $reservationsSearchModel, 'roomsDataProvider' => $roomsDataProvider, 'roomsSearchModel' => $roomsSearchModel, 'resultQueryAveragePricePerDay' => $resultQueryAveragePricePerDay]);
 }
示例#3
0
 /**
  * Lists all Room models.
  * @return mixed
  */
 public function actionIndex()
 {
     //$searchModel = new RoomSearch();
     //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $query = Room::find()->where(['status' => 'Y']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#4
0
 public function search($params)
 {
     $query = Room::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'location_id' => $this->location_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#5
0
 public function actionBackupRoomTable()
 {
     $sql = "CREATE TABLE IF NOT EXISTS room (id int not null, floor int not null, room_number int not null, has_conditioner int not null,has_tv int not null, has_phone int not null, available_from date not null, price_per_day float, description text,fileImage text)";
     \Yii::$app->dbSqlite->createCommand($sql)->execute();
     $sql = 'DELETE FROM room';
     \Yii::$app->dbSqlite->createCommand($sql)->execute();
     $rooms = Room::find()->all();
     foreach ($rooms as $room) {
         \Yii::$app->dbSqlite->createCommand()->insert('room', $room->attributes)->execute();
     }
 }
示例#6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Room::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'floor' => $this->floor, 'room_number' => $this->room_number, 'has_conditioner' => $this->has_conditioner, 'has_tv' => $this->has_tv, 'has_phone' => $this->has_phone, 'available_from' => $this->available_from, 'price_per_day' => $this->price_per_day]);
     $query->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
示例#7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Room::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['roomid' => $this->roomid, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'roomname', $this->roomname])->andFilterWhere(['like', 'roomnum', $this->roomnum])->andFilterWhere(['like', 'capacity', $this->capacity])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'color', $this->color])->andFilterWhere(['like', 'photo', $this->photo])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
示例#8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Room::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'house_id' => $this->house_id]);
     $query->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
示例#9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Room::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'room_num' => $this->room_num, 'status' => $this->status, 'id_card' => $this->id_card, 'price' => $this->price]);
     $query->andFilterWhere(['like', 'room_type', $this->room_type])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Room::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     /* if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        } */
     $query->andFilterWhere(['id' => $this->id, 'available' => $this->available]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#11
0
 public function actionBackupRoomTable()
 {
     //$sql = 'CREATE TABLE IF NOT EXISTS room (id int not null, floor int not null, room_number int not null, has_conditioner int not null, has_tv int not null, has_phone int not null, available_from int not null, price_per_day float, description text)';
     //Yii::$app->dbSqlite->createCommand($sql)->execute();
     $sql = 'delete from room';
     Yii::$app->dbSqlite->createCommand($sql)->execute();
     $models = Room::find()->all();
     foreach ($models as $model) {
         //Yii::$app->dbSqlite->createCommand()->insert('room', $model->attributes)->execute();
         $modelLite = new RoomLite();
         $modelLite->id = $model->id;
         $modelLite->attributes = $model->attributes;
         $modelLite->save(false);
     }
     $sqliteModels = RoomLite::find()->all();
     return $this->render('backupRoomTable', compact('sqliteModels'));
 }
示例#12
0
 /**
  * Delete a Guest of a Room.
  *
  * @param  Request  $request
  * @param  int  $rid
  * @param  int  $pid
  * @return Response
  */
 public function destroy(Request $request, $rid, $pid)
 {
     try {
         $room = Room::find($rid);
         if (!$room) {
             return response()->error(404, 'Room Not Found');
         }
         $profile = Profile::find($pid);
         if (!$profile) {
             return response()->error(404, 'Profile Not Found');
         }
         $room->guests()->detach($profile);
         $room->decrement('guest_count');
         return response()->success();
     } catch (Exception $e) {
         return response()->error($e);
     }
 }
示例#13
0
 function postCapnhat($id)
 {
     // Get data
     $input['id'] = $id;
     $input['name'] = Input::get('name');
     $input['description'] = Input::get('description');
     // Validate
     $rules = ['id' => 'required|numeric|exists:rooms,id', 'name' => 'required|min:2|max:250', 'description' => 'required|min:2|max:250'];
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         $errors_validate = $validator->messages()->all();
         return back()->with('errors_validate', $errors_validate)->withInput();
     }
     // If validate Ok
     $the_shift = Room::find($input['id'])->update($input);
     add_message('Cập nhật thành công');
     return back();
 }
 public function actionMultiGrid()
 {
     $query = Reservation::find();
     $searchModel = new ReservationSearch();
     if (isset($_GET['ReservationSearch'])) {
         $searchModel->load(\Yii::$app->request->get());
         $query->joinWith(['customer']);
         $query->andFilterWhere(['LIKE', 'customer.surname', $searchModel->getAttribute('customer.surname')]);
         $query->andFilterWhere(['id' => $searchModel->id, 'customer_id' => $searchModel->customer_id, 'room_id' => $searchModel->room_id, 'price_per_day' => $searchModel->price_per_day]);
     }
     $allAvgPc = $query->average('price_per_day');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 2]]);
     $Roomquery = \app\models\Room::find();
     $RoomsearchModel = new \app\models\Room();
     if (isset($_GET['Room'])) {
         $RoomsearchModel->load(\Yii::$app->request->get());
         $Roomquery->andFilterWhere(['id' => $RoomsearchModel->id, 'floor' => $RoomsearchModel->floor, 'room_number' => $RoomsearchModel->room_number, 'has_conditioner' => $RoomsearchModel->has_conditioner, 'has_phone' => $RoomsearchModel->has_conditioner, 'has_tv' => $RoomsearchModel->has_conditioner, 'available_from' => $RoomsearchModel->has_conditioner]);
     }
     $RoomdataProvider = new ActiveDataProvider(['query' => $Roomquery, 'sort' => ['sortParam' => 'rooms-sort'], 'pagination' => ['pageSize' => 2, 'pageParam' => 'rooms-page']]);
     return $this->render("multiGrid", ['reservationsDataProvider' => $dataProvider, 'reservationsSearchModel' => $searchModel, 'roomsDataProvider' => $RoomdataProvider, 'roomsSearchModel' => $RoomsearchModel]);
 }
示例#15
0
 public function actionGrid()
 {
     $queryReservation = Reservation::find();
     $queryRoom = Room::find();
     $searchReservation = new ReservationSearch();
     $searchRoom = new Room();
     if (isset($_GET['ReservationSearch'])) {
         $searchReservation->load(Yii::$app->request->get());
         $queryReservation->joinWith(['customer']);
         $queryReservation->andFilterWhere(['LIKE', 'customer.surname', $searchReservation->getAttribute('customer.surname')]);
         $queryReservation->andFilterWhere(['id' => $searchReservation->id, 'room_id' => $searchReservation->room_id, 'customer_id' => $searchReservation->customer_id, 'price_per_day' => $searchReservation->price_per_day]);
     }
     $avg = $queryReservation->average('price_per_day');
     if (isset($_GET['Room'])) {
         $searchRoom->load(Yii::$app->request->get());
         $queryRoom->andFilterWhere(['id' => $searchRoom->id, 'floor' => $searchRoom->floor, 'room_number' => $searchRoom->room_number, 'has_conditioner' => $searchRoom->has_conditioner, 'has_tv' => $searchRoom->has_tv, 'has_phone' => $searchRoom->has_phone, 'available_from' => $searchRoom->available_from, 'price_per_day' => $searchRoom->price_per_day, 'description' => $searchRoom->description]);
     }
     $dataReservation = new ActiveDataProvider(['query' => $queryReservation, 'sort' => ['sortParam' => 'reservations_sort_param'], 'pagination' => ['pageSize' => 3, 'pageParam' => 'reservations_page_param']]);
     $dataRoom = new ActiveDataProvider(['query' => $queryRoom, 'sort' => ['sortParam' => 'rooms_sort_param'], 'pagination' => ['pageSize' => 3, 'pageParam' => 'rooms_sort_param']]);
     return $this->render('grid', ['dataReservation' => $dataReservation, 'dataRoom' => $dataRoom, 'searchReservation' => $searchReservation, 'searchRoom' => $searchRoom, 'averagePrice' => $avg]);
 }
 /**
  * Creates a new Assignation model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($room_id = null, $location_id = null)
 {
     $model = new Assignation();
     $model->room_id = Room::find()->where(['name' => Yii::$app->params['defaultRoom']])->one()->id;
     if (!empty($room_id)) {
         $model->room_id = $room_id;
     }
     if (!empty($location_id)) {
         $model->location_id = $location_id;
         $equipment = Equipment::find()->where(['location_id' => $location_id, 'available' => 1])->one();
         $model->equipment_id = empty($equipment) ? null : $equipment->id;
         if (empty($room_id)) {
             $model->room_id = $equipment->location->room_id;
         }
     }
     $this->layout = '/main2';
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('index');
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionBackupRoomTable()
 {
     $sql = "DROP TABLE IF EXISTS room";
     \Yii::$app->dbSqlite->createCommand($sql)->execute();
     $sql = 'CREATE TABLE IF NOT EXISTS room (
         id int not null, floor int not null,
         room_number int not null,
         has_conditioner int not null,
         has_tv int not null, 
         has_phone int not null,
         available_from date not null,
         price_per_day float,
         description text)';
     \Yii::$app->dbSqlite->createCommand($sql)->execute();
     $models = Room::find()->all();
     foreach ($models as $m) {
         \Yii::$app->dbSqlite->createCommand()->insert('room', $m->attributes)->execute();
     }
     $sql = 'SELECT * FROM room';
     $sqliteModels = \Yii::$app->dbSqlite->createCommand($sql)->queryAll();
     return $this->render('backupRoomTable', ['sqliteModels' => $sqliteModels]);
 }
 public function searchRequest(Request $request)
 {
     if ($request->ajax() && !Auth::guest()) {
         $target_id = $request->target_id;
         switch ($request->mode) {
             case 'friends':
                 $query = ['user_id' => Auth::user()->id, 'friends_id' => $target_id, 'friends_request' => 1, 'created_at' => Carbon::now()];
                 Friends::insert($query);
                 $friend = User::find($target_id);
                 return ['name' => $friend->name, 'image' => $friend->image, 'email' => $friend->email];
                 break;
             case 'room':
                 $room = Room::find($target_id);
                 $query = ['room_id' => $room->id, 'user_id' => Auth::user()->id, 'created_at' => Carbon::now()];
                 DB::table('room_user')->insert($query);
                 $room_info = '                           
                 <li>
                     <a href="/room/' . $room->id . '">
                         <div class="navigation__inner--tab-body--list--box">
                             ' . Html::image($room->image, null, ['width' => '50', 'height' => '50', 'class' => 'navigation__inner--tab-body--list--box-image z-depth-1']) . '
                             <div class="navigation__inner--tab-body--list--box-description">
                                 <ul>
                                     <li>' . $room->name . '</li>
                                     <li>Belong num</li>
                                 </ul>
                             </div>
                         </div>
                     </a>
                 </li>
                 <hr>
                 ';
                 return ['name' => $room->name, 'image' => $room->image, 'email' => 'Created At:' . $room->created_at, 'room' => $room_info];
                 break;
         }
         return $request->mode;
     }
 }
示例#19
0
?>
</h1>		
	
	<div class="assignation-index">
	
	<p></p>
	
	<?php 
$locationQuery = Location::find()->joinWith(['room'])->where(['location.active' => 1, 'room.available' => 1]);
if (!empty(Yii::$app->request->queryParams['AssignationSearch']) && !empty(Yii::$app->request->queryParams['AssignationSearch']['room'])) {
    $locationQuery->andWhere(['room.id' => Yii::$app->request->queryParams['AssignationSearch']['room']]);
}
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'room', 'value' => 'room.name', 'label' => Yii::t('app', 'Room ID'), 'filter' => ArrayHelper::map(Room::find()->orderBy('name ASC')->where(['available' => 1])->all(), 'id', 'name'), 'filterInputOptions' => ['id' => 'search-assignation-room-id', 'class' => 'form-control']], ['attribute' => 'location', 'value' => 'location.location', 'label' => Yii::t('app', 'Location ID'), 'filter' => ArrayHelper::map($locationQuery->orderBy('name ASC')->all(), 'id', 'fullLocation'), 'filterInputOptions' => ['id' => 'search-assignation-location-id', 'class' => 'form-control']], ['attribute' => 'client', 'value' => 'client.client_id', 'label' => Yii::t('app', 'Client ID')], ['attribute' => 'full_name', 'value' => 'client.full_name', 'label' => Yii::t('app', 'Full Name')], 'start_time', 'end_time', ['class' => 'yii\\grid\\ActionColumn', 'template' => ' {view} {update} {delete} {extend_time} {terminate} {report}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['title' => Yii::t('app', 'View')]);
}, 'update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => Yii::t('app', 'Update')]);
}, 'delete' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('app', 'Delete'), 'data-confirm' => '¿Borrar esta asignación?', 'data-method' => 'POST']);
}, 'extend_time' => function ($url, $model, $key) {
    return Html::a('<a data-toggle="modal" href="#extendTime" data-model="' . $model->id . '"><span class="glyphicon glyphicon-time"></span></a>', $url);
}, 'terminate' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-pause"></span>', $url, ['title' => Yii::t('app', 'Terminate assignation')]);
}, 'report' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-alert"></span>', $url, ['title' => Yii::t('app', 'report an incident')]);
}], 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'view') {
        return Url::to(['assignation/view?id=' . $model->id]);
    }
示例#20
0
    <!--?php $form = ActiveForm::begin(); ?-->
	<?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'options' => ['enctype' => 'multipart/form-data']]);
//$model->room_id = Room::find()->where(['name'=>Yii::$app->params['defaultRoom']])->one()->id;
?>

	<!--?= $form->field($model, 'date')->textInput() ?-->
	<?php 
echo $form->field($model, 'date')->widget(DateTimePicker::classname(), ['type' => DateTimePicker::TYPE_INPUT, 'pluginOptions' => ['minuteStep' => 1, 'autoclose' => true, 'format' => 'yyyy-mm-dd H:ii:s', 'todayBtn' => true]]);
?>
	
    <!--?= $form->field($model, 'room_id')->textInput(['maxlength' => 10]) ?-->
	
	<?php 
echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Room::find()->orderBy('name ASC')->all(), 'id', 'name'), ['prompt' => 'Selecciona un Salón', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl('incident/list-locations?id=') . '"+$(this).val(), function(data){
					$("#incident-location_id").html(data);
				})']);
?>

	<!--?= $form->field($model, 'location_id')->dropDownList(
			ArrayHelper::map(
				Location::find()->all(),
				'id',
				'location'
			),
			[
				'prompt' => 'Selecciona una Ubicación',
				'onchange' => '$.post("'.Yii::$app->urlManager->createUrl('incident/list-equipment-types?id=').'"+$(this).val(), function(data){
					$("#incident-equipment_type_id").html(data);
				})',
示例#21
0
文件: grid.php 项目: soanni/yii2news
<?php

use yii\grid\GridView;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use app\models\Room;
use app\models\Customer;
use app\components\GridViewReservation;
$filterRoom = ArrayHelper::map(Room::find()->all(), 'id', function ($model) {
    return sprintf('Floor: %d - Number: %d', $model->floor, $model->room_number);
});
//    $sum = 0;
//    $avg = 0;
//    if(count($data->getModels()) > 0){
//        foreach($data->getModels() as $m){
//            $sum += $m->price_per_day;
//        }
//        $avg = $sum/sizeof($data->getModels());
//    }
//    $filterCustomer = ArrayHelper::map(Customer::find()->all(),'id',function($model){
//        $name = $model->name;
//        $surname = $model->surname;
//        return "$name $surname";
//    });
echo Html::a('Detail dependent dropdown(AJAX)', Url::to(['reservations/detail-dependent-dropdown']), ['class' => 'btn btn-primary']);
?>
<h2>Reservations</h2>
<?php 
echo GridViewReservation::widget(['dataProvider' => $dataReservation, 'filterModel' => $searchReservation, 'showFooter' => true, 'columns' => [['header' => 'Room', 'filter' => Html::activeDropDownList($searchReservation, 'room_id', $filterRoom, ['prompt' => '--All--']), 'attribute' => 'room.room_number'], ['header' => 'Customer', 'attribute' => 'customer.surname'], 'price_per_day' => ['attribute' => 'price_per_day', 'header' => 'Daily price', 'footer' => sprintf('Average: %0.1f', $averagePrice)], 'date_from', 'date_to', 'reservation_date']]);
?>
    <?php 
$form = ActiveForm::begin();
?>
    <div class="model">
        <?php 
echo $form->errorSummary([$customer, $reservation]);
?>
        <h2>Customer</h2>
        <?php 
echo $form->field($customer, 'name')->textInput();
echo $form->field($customer, 'surname')->textInput();
echo $form->field($customer, 'phone_number')->textInput();
?>
        <h2>Reservation</h2>
        <?php 
echo $form->field($reservation, 'room_id')->dropDownList(ArrayHelper::map(Room::find()->all(), 'id', function ($room) {
    return sprintf('Room #%d. Floor #%d', $room->room_number, $room->floor);
}));
echo $form->field($reservation, 'price_per_day')->textInput();
echo $form->field($reservation, 'date_from')->widget(DatePicker::className(), ['dateFormat' => 'yyyy/MM/dd']);
echo $form->field($reservation, 'date_to')->widget(DatePicker::className(), ['dateFormat' => 'yyyy/MM/dd']);
?>
    </div>
    <div class="form-group">
        <?php 
echo Html::submitButton('Send', ['class' => 'btn btn-primary']);
?>
    </div>
    <?php 
ActiveForm::end();
?>
示例#23
0
 public function actionIndexWithRelationships()
 {
     $room_id = Yii::$app->request->get('room_id', null);
     $reservation_id = Yii::$app->request->get('reservation_id', null);
     $customer_id = Yii::$app->request->get('customer_id', null);
     $roomSelected = null;
     $reservationSelected = null;
     $customerSelected = null;
     if ($room_id != null) {
         $roomSelected = Room::findOne($room_id);
         $rooms = array($roomSelected);
         $reservations = $roomSelected->reservations;
         $customers = $roomSelected->customers;
     } elseif ($reservation_id != null) {
         $reservationSelected = Reservation::findOne($reservation_id);
         $rooms = array($reservationSelected->room);
         $reservations = array($reservationSelected);
         $customers = array($reservationSelected->customer);
     } elseif ($customer_id != null) {
         $customerSelected = Customer::findOne($customer_id);
         $rooms = $customerSelected->rooms;
         $reservations = $customerSelected->reservations;
         $customers = array($customerSelected);
     } else {
         $rooms = Room::find()->all();
         $reservations = Reservation::find()->all();
         $customers = Customer::find()->all();
     }
     return $this->render('indexWithRelationShips', compact('roomSelected', 'reservationSelected', 'customerSelected', 'rooms', 'reservations', 'customers'));
 }
示例#24
0
?>

    <?php 
echo $form->field($model, 'description')->textInput(['maxlength' => 175]);
?>

    <?php 
echo $form->field($model, 'serial_number')->textInput(['maxlength' => 175]);
?>

    <?php 
echo $form->field($model, 'status_id')->dropDownList(ArrayHelper::map(Status::find()->all(), 'id', 'status'));
?>

    <?php 
echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Room::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'location')->textInput(['maxlength' => 45]);
?>

    <?php 
echo $form->field($model, 'available')->Checkbox([], true);
?>

    <?php 
echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(EquipmentType::find()->all(), 'id', 'name'));
?>

    <div class="form-group">
示例#25
0
 public function postEditRoom(Request $request)
 {
     if (Session::get('member')->property_id != null) {
         if (Session::get('member')->type > 1) {
             return redirect()->back()->withErrors(['คุณไม่มีสิทธิ์เข้าใช้งานส่วนนี้'])->withInput();
         }
     }
     $messages = ['code.required' => 'กรุณาใส่รหัสห้อง', 'name.required' => 'กรุณาใส่ชื่อห้อง', 'price.required' => 'กรุณาใส่ราคาห้อง', 'description.required' => 'กรุณาอธิบายห้องของคุณ'];
     $validator = Validator::make($request->all(), ['code' => 'required', 'name' => 'required', 'price' => 'required', 'description' => 'required'], $messages);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $room = \App\Models\Room::find($request->c);
     $room->code = $request->code;
     $room->name = $request->name;
     $room->price = $request->price;
     $room->description = $request->description;
     $room->save();
     return redirect('/property/add-room');
 }
示例#26
0
<?php

use app\models\Room;
use yii\grid\GridView;
use app\components\GridViewReservation;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
$roomsFilterData = ArrayHelper::map(Room::find()->all(), 'id', function ($model, $defaultValue) {
    return sprintf('Floor: %d - Number: %d', $model->floor, $model->room_number);
});
$sumOfPricesPerDay = 0;
$averagePricePerDay = 0;
$numberOfRows = count($reservationsDataProvider->getModels());
if ($numberOfRows > 0) {
    foreach ($reservationsDataProvider->getModels() as $m) {
        $sumOfPricesPerDay += $m->price_per_day;
    }
    $averagePricePerDay = $sumOfPricesPerDay / $numberOfRows;
}
echo "<h2>Reservations</h2>" . GridViewReservation::widget(['showFooter' => true, 'dataProvider' => $reservationsDataProvider, 'filterModel' => $reservationsSearchModel, 'columns' => ['id', ['header' => 'Room', 'filter' => Html::activeDropDownList($reservationsSearchModel, 'room_id', $roomsFilterData, ['prompt' => '--- all']), 'content' => function ($model) {
    return $model->room->floor;
}], ['header' => 'Customer', 'attribute' => 'customer.nameAndSurname'], ['header' => 'Customer (name)', 'attribute' => 'customer.name'], ['header' => 'Customer (surname)', 'attribute' => 'customer.surname'], 'room_id', ['attribute' => 'price_per_day', 'footer' => sprintf('Average: %0.2f', $resultQueryAveragePricePerDay)], 'date_from', 'date_to', 'reservation_date', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'header' => 'Actions']]]);
echo "<h2>Rooms</h2>" . GridViewReservation::widget(['dataProvider' => $roomsDataProvider, 'filterModel' => $roomsSearchModel, 'columns' => ['id', 'floor', 'room_number', 'has_conditioner:boolean', 'has_phone:boolean', 'has_tv:boolean', 'available_from']]);
示例#27
0
 public function getRoomList()
 {
     $list = Room::find()->where(['status' => 'Y'])->all();
     return ArrayHelper::map($list, 'roomid', 'roomname');
 }
示例#28
0
 /**
  * Delete a Room of an Accommodation.
  *
  * @param  RoomRequest  $request
  * @param  int  $aid
  * @param  int  $rid
  * @return Response
  */
 public function destroy(RoomRequest $request, $aid, $rid)
 {
     try {
         $accommodation = Accommodation::find($aid);
         if (!$accommodation) {
             return response()->error(404, 'Accommodation Not Found');
         }
         $cid = $accommodation->conference()->first()->getKey();
         $user = $this->isConferenceManager($request, $cid);
         if (!$user) {
             return response()->error(403, 'You are not a manager of this conference!');
         }
         $room = Room::find($rid);
         if (!$room) {
             return response()->error(404, 'Room Not Found');
         }
         $room->delete();
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
示例#29
0
//$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Todas las asignaciones');
?>

<h1 align="center"><?php 
echo 'Todas las Asignaciones', Html::a('Regresar', ['index'], ['class' => 'btn btn-success btn-md', 'style' => 'float:right; margin-left:4px;']), Html::a('', ['assignations'], ['class' => 'btn btn-primary btn-md glyphicon glyphicon-refresh', 'style' => 'float:right;']);
?>
</h1>	

<div class="assignation-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<?php 
$locationQuery = Location::find()->joinWith(['room'])->where(['location.active' => 1, 'room.available' => 1]);
if (!empty(Yii::$app->request->queryParams['AssignationSearch']) && !empty(Yii::$app->request->queryParams['AssignationSearch']['room'])) {
    $locationQuery->andWhere(['room.id' => Yii::$app->request->queryParams['AssignationSearch']['room']]);
}
?>
	
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'date', ['attribute' => 'client', 'value' => 'client.client_id', 'label' => Yii::t('app', 'Client ID')], ['attribute' => 'room', 'value' => 'room.name', 'label' => Yii::t('app', 'Room ID'), 'filter' => ArrayHelper::map(Room::find()->where(['available' => 1])->all(), 'id', 'name')], ['attribute' => 'location', 'value' => 'location.location', 'label' => Yii::t('app', 'Location ID'), 'filter' => ArrayHelper::map($locationQuery->all(), 'id', 'fullLocation'), 'filterInputOptions' => ['id' => 'search-assignation-location-id', 'class' => 'form-control']], ['attribute' => 'equipment', 'value' => 'equipment.inventory', 'label' => Yii::t('app', 'Inventory')], 'purpose', 'duration', 'start_time', 'end_time']]);
?>

</div>
        <?php 
echo $form->errorSummary([$customer, $reservation]);
?>
        <h2>Customer</h2>
        <?php 
echo $form->field($customer, "name")->textInput();
?>
        <?php 
echo $form->field($customer, "surname")->textInput();
?>
        <?php 
echo $form->field($customer, "phone_number")->textInput();
?>
        <h2>Reservation</h2>
        <?php 
echo $form->field($reservation, "room_id")->dropDownList(ArrayHelper::map(Room::find()->all(), 'id', function ($room, $defaultValue) {
    return sprintf('Room n.%d at floor %d', $room->room_number, $room->floor);
}));
?>
        <?php 
echo $form->field($reservation, "price_per_day")->textInput();
?>
        <?php 
echo $form->field($reservation, "date_from")->widget(DatePicker::classname(), ['language' => 'zh-cn', 'dateFormat' => 'yyyy/MM/dd']);
?>
        <?php 
echo $form->field($reservation, "date_to")->widget(DatePicker::classname(), ['language' => 'zh-cn', 'dateFormat' => 'yyyy/MM/dd']);
?>
    </div>
    <div class="form-group">
        <?php