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]);
 }
Exemple #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $room = new Room();
     $room->event_id = Event::all()->first()->id;
     $room->length = 200;
     $room->width = 400;
     //need 25 tables of 6 people
     $room->save();
 }
Exemple #3
0
 public function deleteRoom(Request $request)
 {
     $input = $request->all();
     $room = Room::find($input['id']);
     $room->delete();
     return $this->showRoom();
 }
 public function create(Request $request)
 {
     $name = $request->room_name;
     $created_at = Carbon::now();
     $query = ['name' => $name, 'created_at' => $created_at];
     Room::insert($query);
     return redirect('home');
 }
 public function index()
 {
     $rooms = Room::orderBy('created_at', 'desc')->get();
     if (Session::has('message')) {
         Session::reflash('message');
     }
     return view('home.home', compact('rooms'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $eventId)
 {
     $room = Room::where('event_id', '=', $eventId)->first();
     if (!$room) {
         return $this->respondNotFound('Room does not exist');
     }
     $room->delete();
     return $this->respondDeleteSuccess('Room deleted');
 }
 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;
 }
 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();
     }
 }
 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]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ---------------------------------------------------------------------
     // CONFERENCE 2
     // ---------------------------------------------------------------------
     $conference = Conference::find(2);
     $accommodation = ['name' => 'Shangri-La Hotel Vancouver', 'address' => '1128 West Georgia Street', 'city' => 'Vancouver', 'country' => 'Canada'];
     $accommodation = new Accommodation($accommodation);
     $accommodation->conference()->associate($conference);
     $accommodation->save();
     $room = ['room_no' => '100', 'guest_count' => 0, 'capacity' => 2];
     $room = new Room($room);
     $room->accommodation()->associate($accommodation);
     $room->save();
     $room = ['room_no' => '101', 'guest_count' => 0, 'capacity' => 3];
     $room = new Room($room);
     $room->accommodation()->associate($accommodation);
     $room->save();
     $room = ['room_no' => '102', 'guest_count' => 0, 'capacity' => 4];
     $room = new Room($room);
     $room->accommodation()->associate($accommodation);
     $room->save();
     $accommodation = ['name' => 'The Fairmont Hotel Vancouver', 'address' => '900 West Georgia Street', 'city' => 'Vancouver', 'country' => 'Canada'];
     $accommodation = new Accommodation($accommodation);
     $accommodation->conference()->associate($conference);
     $accommodation->save();
     $room = ['room_no' => '200', 'guest_count' => 0, 'capacity' => 2];
     $room = new Room($room);
     $room->accommodation()->associate($accommodation);
     $room->save();
     $room = ['room_no' => '201', 'guest_count' => 0, 'capacity' => 3];
     $room = new Room($room);
     $room->accommodation()->associate($accommodation);
     $room->save();
     $room = ['room_no' => '202', 'guest_count' => 0, 'capacity' => 4];
     $room = new Room($room);
     $room->accommodation()->associate($accommodation);
     $room->save();
 }
 public function testSetRoomScheduleRoom()
 {
     $roomsched = new RoomSchedule();
     $room = new Room();
     $room->setRoomName("SCS Lab A");
     $room->setBuilding("SCS");
     $roomsched->setRoomName($room->getRoomName());
     $roomsched->setBuilding($room->getBuilding());
     $this->assertEquals("SCS Lab A", $room->getRoomName());
     $this->assertEquals("SCS Lab A", $roomsched->getRoomName());
     $this->assertEquals($room->getBuilding(), $roomsched->getBuilding());
 }
 /**
  * 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;
 }
Exemple #13
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;
 }
Exemple #14
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;
 }
Exemple #15
0
 public function search($input)
 {
     $query = Room::query();
     $columns = Schema::getColumnListing('rooms');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
 public function findReserveRoomsByRangeAndRoomType($start, $end, $roomType)
 {
     $dates = Calendar::getInclusiveDates($start, $end, 'Y-m-d');
     $rooms = Room::where('room_type_id', $roomType)->get();
     $sql = "select rr_id, reserve_code, room_id, status, if(checkin < '{$start}', '{$start}', checkin) as 'calstart',  if(checkin < '{$start}', 'extendleft', '') as 'startmodifier', if(checkout > '{$end}', 'extendright', '') as 'endmodifier',(datediff('{$end}', '{$start}') + if(datediff(checkout, '{$end}') < 0, datediff(checkout, '{$end}'), 0) + if(datediff('{$start}', checkin) < 0, datediff('{$start}', checkin), 0)) as 'computedlength' from reserve_rooms where checkin <= '{$end}' and checkout >= '{$start}' and room_id > 0 and room_type_id = {$roomType} order by room_id, checkin";
     $rr = DB::select($sql);
     $calendar = [];
     foreach ($rooms as $room) {
         foreach ($dates as $day) {
             $calendar[$room->door_name][$day] = $this->getRoomsForDate($rr, $room->room_id, $day);
         }
     }
     ksort($calendar);
     return $calendar;
 }
 /**
  * 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;
 }
Exemple #18
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;
 }
 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'));
 }
 /**
  * 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);
     }
 }
Exemple #21
0
 public function editMatkul($id_course)
 {
     $course = Course::where('seksi', $id_course)->first();
     //get all prodi information
     $prodis = Prodi::all();
     //transform prodi to associative array
     $prodi_arr = array();
     foreach ($prodis as $prodi) {
         $prodi_arr[$prodi->id] = $prodi->prodi;
     }
     $kode_dosen = $course->Kode_Dosen;
     //need to pass filled data to this view (extra parameter)
     $room = Room::room_name();
     $room_arr = Helpers::toAssociativeArrays($room);
     $waktu_kuliah = WaktuKuliah::waktuMap();
     $waktu_opts = Helpers::toAssociativeArrays($waktu_kuliah);
     return view('lecturers.editcourse')->with('prodi_options', $prodi_arr)->with('Kode_Dosen', $kode_dosen)->with('room_options', $room_arr)->with('course', $course)->with('waktu_options', $waktu_opts);
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('partials.navigation', function ($view) {
         if (Auth::guest()) {
             //とりあえず
             $rooms = Room::take(10)->get();
             $friends = User::all();
             $view->with(['rooms' => $rooms, 'friends' => $friends]);
         } else {
             $user_id = Auth::user()->id;
             $rooms = User::find($user_id)->room;
             $friends_id_lists = User::find($user_id)->friends->lists('friends_id');
             $friends = User::whereIn('id', $friends_id_lists)->get();
             $friends_request = Friends::where('friends_id', $user_id)->where('friends_request', 1)->get();
             //$friends_request = Friends::whereIn('user_id' , $friends_request_lists)->get();
             $view->with(['rooms' => $rooms, 'friends' => $friends, 'friends_request' => $friends_request]);
         }
     });
 }
 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]);
 }
 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]);
 }
 /**
  * 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 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;
     }
 }
Exemple #27
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRoom()
 {
     return $this->hasOne(Room::className(), ['id' => 'room_id']);
 }
Exemple #28
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>
 /**
  * Finds the Room model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Room the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Room::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #30
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]);
    }