Ejemplo n.º 1
0
 public function destroy($id)
 {
     $room = Room::with('schedules')->find($id);
     if ($room->schedules->count() > 0) {
         Session::flash('message', 'Tidak dapat menghapus ruangan! Ruangan ini digunakan dalam jadwal belajar');
     } else {
         Room::destroy($id);
         Session::flash('message', 'Sukses menghapus ruangan!');
     }
 }
Ejemplo n.º 2
0
 public function getRooms()
 {
     $email = Input::get('email');
     $pass = Input::get('password');
     if (Auth::attempt(array('email' => $email, 'password' => $pass))) {
         $user = User::where('email', '=', $email)->first();
         $building = $user->buildings->first();
         if (!empty($building)) {
             $rooms = Room::with('Layouts')->where('building_id', '=', $building->id)->get();
             return Response::json($rooms, 200);
         } else {
             return Response::json(array('message' => 'Something went wrong'), 500);
         }
     } else {
         return Response::json(array('message' => 'Wrong email or password'), 404);
     }
 }
 public function thisYearList()
 {
     $today = date("Y");
     if (isset($_GET['filtertype'])) {
         if ($_GET['filtertype'] != 1) {
             $today = isset($_GET['year1']) ? $_GET['year1'] : date("Y");
             $room = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($today) {
                 $query->whereRaw('YEAR(check_in) = ' . $today);
             }))->select('id', 'name')->get();
             $output = [];
             return $room;
         } else {
             $year1 = isset($_GET['year1']) ? $_GET['year1'] : date("Y");
             $year2 = isset($_GET['year2']) ? $_GET['year2'] : date("Y");
             $year1_result = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($year1) {
                 $query->whereRaw('YEAR(check_in) = ' . $year1);
             }))->select('id', 'name')->get();
             $year2_result = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($year2) {
                 $query->whereRaw('YEAR(check_in) = ' . $year2);
             }))->select('id', 'name')->get();
             $result = array();
             $result['year1'] = $year1_result;
             $result['year2'] = $year2_result;
             return $result;
         }
     }
     $booking_recent = ReservedRoom::with('room.roomDetails2')->whereRaw('YEAR(check_in) = ' . $today)->get();
     $room = Room::with('roomQty')->with(array('roomQty.roomReserved' => function ($query) use($today) {
         $query->whereRaw('YEAR(check_in) = ' . $today);
     }))->select('id', 'name')->get();
     $output = [];
     return $room;
     if (!empty($booking_recent)) {
         $output['booking'] = $booking_recent;
         $output['rooms'] = $room;
         return $output;
     } else {
         return '0';
     }
 }
 Route::get('dashboard/success_booking', 'DashboardController@todayBookingSuccess');
 Route::get('dashboard/cancelled_booking', 'DashboardController@todayBookingCancelled');
 Route::get('dashboard/pending_booking', 'DashboardController@todayBookingPending');
 Route::get('dashboard/arrival', 'DashboardController@todayArrival');
 Route::get('dashboard/departure', 'DashboardController@todayDeparture');
 Route::get('dashboard/occupied', 'DashboardController@todayBookingOccupied');
 Route::get('dashboard/preparing', 'DashboardController@todayBookingPreparing');
 Route::get('reservation/list/ajax', 'BookingController@thisYearList');
 Route::get('activity', 'ActivitiesController@index');
 Route::get('room', 'RoomController@index');
 Route::get('room/all', 'RoomController@allrooms');
 Route::get('room/search/{query}', function ($query) {
     $r = RoomQty::where('room_no', $query)->first();
     if (!empty($r)) {
         $room_id = $r->room_id;
         $rooms = Room::with('roomQty', 'roomImages.photo')->where('id', $room_id)->get();
         //return 'heyt';
         return $rooms;
     } else {
         return '0';
     }
     return 'hey';
 });
 Route::get('user', 'UsersController@index');
 Route::post('user/create', 'UsersController@store');
 Route::post('user/{id}/delete', 'UsersController@destroy');
 Route::post('user/{id}/update', 'UsersController@update');
 Route::get('settings', function () {
     $cpage = 'settings';
     return View::make('adminview.settings.index', compact('cpage'));
 });
 public function ajaxLiveMonitoring()
 {
     $i = array();
     $today = Date('Y-m-d');
     $i['checkin'] = Date('Y-m-d');
     $i['checkout'] = new DateTime('tomorrow');
     $i['checkout'] = $i['checkout']->format('Y-m-d') . ' 11:59:00';
     $room = Room::with(array('roomQty.roomReserved' => function ($query) use($i) {
         $query->where(function ($query2) use($i) {
             $query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
         })->where(function ($query3) {
             $query3->where('status', '!=', 5)->orWhere('status', '!=', 3);
         });
     }))->get();
     foreach ($room as $i => $r) {
         foreach ($r->roomQty as $x => $r_qty) {
             if (count($r_qty->roomReserved) > 0) {
                 if ($r_qty->roomReserved[0]->isOverdue()) {
                     $room[$i]->roomQty[$x]->roomReserved[0]->status = 6;
                     //means overdue
                 }
             }
         }
     }
     return $room;
 }
 public function availability()
 {
     $i = Input::all();
     if (isset($i['checkin']) && isset($i['checkout'])) {
         return $i;
         //return $i;
         $available_rooms = 0;
         $room1 = Room::with(array('roomQty.roomReserved' => function ($query) use($i) {
             $query->where(function ($query2) use($i) {
                 $query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
             })->where(function ($query3) {
                 $query3->where('status', '!=', 5)->where('status', '!=', 3);
             });
         }))->get();
         return $room1;
     }
 }