Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public function findReservationsForRoomTypeInRange($start, $end, $room_type_id)
 {
     //        $dstart = new \DateTime($start);
     //        $interval = $dstart->diff(new \DateTime($end))->format('%a');
     //
     //        $output = [];
     //        for( $ctr = 0; $ctr <= $interval; $ctr++) {
     //            $caldate = $dstart->format('Y-m-d');
     //            $output[$caldate] = $this->findAllBy('cal_date', $caldate, ['reserve_room_id', 'room_id', 'status', 'modifier']);
     //            $dstart->add(new \DateInterval('P1D'));
     //        }
     //
     //        $rooms = Room::where('room_type_id', $room_type_id)->get();
     //
     //        return $this->pivotRoomsByDates($rooms, $output);
     $dates = Calendar::getInclusiveDates($start, $end);
 }
Exemplo n.º 3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, ReserveRoomRepository $reserveRoomRepo)
 {
     $roomTypes = BookingRoomTypes::all();
     $firstRoomType = $roomTypes->last();
     $now = new \DateTime('now');
     $startdate = $request->get('startdate', $now->format('Y-m-d'));
     $enddate = $request->get('enddate', $now->add(new \DateInterval('P10D'))->format('Y-m-d'));
     $room_type_id = $request->get('room_type_id', $firstRoomType->room_type_id);
     $reservation = new Reservation();
     if ($request->has('reserve_code')) {
         $reserve_code = $request->get('reserve_code');
         $reservation = Reservation::where('reserve_code', $reserve_code)->get()->first();
     }
     $calendar = $reserveRoomRepo->findReserveRoomsByRangeAndRoomType($startdate, $enddate, $room_type_id);
     $dates = Calendar::getInclusiveDates($startdate, $enddate);
     $partners = Partner::all();
     $request->flash();
     $cardTypes = ['AMEX', 'JBC', 'Visa', 'Mastercard', 'BDO Card', 'Express Net', 'Megalink', 'BancNet', 'BPI'];
     return view('reservations.index', compact('calendar', 'roomTypes', 'dates', 'startdate', 'enddate', 'reservation', 'partners', 'cardTypes'));
 }