Exemple #1
0
 /**
  * Functions
  */
 public static function emailBookingDetails($bookingId, $view = 'emails.emailMaster', $subject = 'Booking Amendment - Ref No: ')
 {
     $hotel_bookings = [];
     if ($bookings = Session::get('rate_box_details')) {
         $rate_keys = array_keys($bookings);
         foreach ($rate_keys as $rate_key) {
             $hotel_id = explode('_', $rate_key)[0];
             $hotel_bookings[$hotel_id][] = $bookings[$rate_key];
             $hotel_bookings[$hotel_id]['hotel_name'] = $bookings[$rate_key]['hotel_name'];
             $hotel_bookings[$hotel_id]['hotel_address'] = $bookings[$rate_key]['hotel_address'];
             $hotel_bookings[$hotel_id]['room_identity'] = $bookings[$rate_key]['room_identity'];
         }
     }
     $bookingInfo = Booking::with('client')->with('flightDetail')->where('id', $bookingId)->first();
     $user = Auth::user();
     $booking = $bookingInfo->toArray();
     //        dd($booking);
     $mail = Mail::send($view, array('booking' => $booking), function ($message) use($user, $booking, $subject, $hotel_bookings) {
         $message->to('*****@*****.**', $user->first_name)->subject($subject . $booking['reference_number']);
     });
     if ($mail) {
         return true;
     }
     return false;
 }
 public function getBalanceSheet()
 {
     if (Auth::check()) {
         $reference_number = Input::has('reference_number') ? Input::get('reference_number') : '%';
         $user_id = Auth::id();
         $agent_id = Input::get('agent_id');
         $payments_query = Payment::whereHas('user', function ($q) use($agent_id) {
             $q->where('user_id', 'like', '%' . $agent_id . '%');
         })->with('agent')->select(array('payment_date_time AS date', 'amount AS debit', 'details', 'id'));
         $invoices_query = Booking::whereHas('user', function ($q) use($agent_id) {
             $q->where('user_id', 'like', '%' . $agent_id . '%');
         })->join('invoices', 'invoices.booking_id', '=', 'bookings.id')->select(array('arrival_date AS date', 'reference_number AS details', 'amount as credit'))->where('val', '=', 1);
         if (Entrust::hasRole('Agent')) {
             $payments_query->where('user_id', $user_id);
             $invoices_query->where('user_id', $user_id);
         }
         if (Input::get('get_payments')) {
             Session::flash('activate_payments_tab', 'active');
             $from_d = Input::get('from_d');
             $to_d = Input::get('to_d');
             $payments = $payments_query->whereBetween('payment_date_time', array($from_d, $to_d))->get();
             $invoices = $invoices_query->whereBetween('arrival_date', array($from_d, $to_d))->get();
         } else {
             $payments = $payments_query->get();
             $invoices = $invoices_query->get();
         }
         //dd($pay);
         if (Entrust::hasRole('Admin')) {
             $bookings = Booking::with('user')->where('reference_number', 'like', '%' . $reference_number . '%')->get();
         } else {
             $bookings = Booking::whereHas('user', function ($q) {
                 $q->where('users.id', $this->_user->id);
             })->where('reference_number', 'like', $reference_number)->get();
         }
         $merged_data = array_merge($payments->toArray(), $invoices->toArray());
         foreach ($merged_data as $key => $row) {
             $c[$key] = $row['date'];
         }
         if (!empty($merged_data)) {
             array_multisort($c, SORT_ASC, $merged_data);
         }
         $total = 0;
         if (Input::has('get_payment')) {
             return View::make('accounts.index', compact('bookings', 'payments', 'merged_data', 'total'))->withInput();
         }
         return View::make('accounts.index', compact('bookings', 'payments', 'merged_data', 'invoice', 'total', 'agent_id'));
     }
     return App::abort(404);
 }
 /**
  * Display the specified booking.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $booking = Booking::with('voucher')->with('client')->with('flightDetail')->where('id', $id)->first();
     } catch (ModelNotFoundException $e) {
         return Redirect::to('/404');
     }
     return View::make('bookings.show', compact('booking', 'clients', 'flightDetails', 'vouchers'));
 }
 public function bookingList()
 {
     $arr = [];
     $arr = getallheaders();
     $b = null;
     $count = null;
     if (isset($arr['Range'])) {
         $response_array = array();
         $response_array['Accept-Ranges'] = 'items';
         $range = $arr['Range'];
         $response_array['Range-Unit'] = 'items';
         $arr = explode('-', $arr['Range']);
         $items = $arr[1] - $arr[0] + 1;
         $skip = $arr[0];
         $skip = $skip < 0 ? 0 : $skip;
         $c = null;
         if (isset($_GET['query'])) {
             /*query variables*/
             $query = $_GET['query'];
             $startdate = $_GET['startdate'];
             $enddate = $_GET['enddate'] == '' ? date('Y-m-d') : $_GET['enddate'];
             $status_arr = array();
             if ($_GET['pending'] == 'true') {
                 array_push($status_arr, 0);
             }
             if ($_GET['paid'] == 'true') {
                 array_push($status_arr, 1);
             }
             if ($_GET['occupied'] == 'true') {
                 array_push($status_arr, 2);
             }
             if ($_GET['ended'] == 'true') {
                 array_push($status_arr, 3);
             }
             if ($_GET['preparing'] == 'true') {
                 array_push($status_arr, 4);
             }
             if ($_GET['cancelled'] == 'true') {
                 array_push($status_arr, 5);
             }
             if ($_GET['overdue'] == 'true') {
                 array_push($status_arr, 6);
             }
             $status_arr = count($status_arr) > 0 ? $status_arr : array(0, 1, 2, 3, 4, 5, 6);
             /*end of query variables*/
             $count = Booking::with('reservedRoom_grp.room.roomDetails', 'remarksHistory')->where('id', 'LIKE', "%{$query}%")->orWhereRaw("concat_ws(' ',firstname,lastname) LIKE '%{$query}%'")->orWhere('firstname', 'LIKE', "%{$query}%")->orWhere('lastname', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%")->get()->count();
             if (isset($_GET['orderBy']) && $_GET['orderBy'] != '') {
                 $orderBy = $_GET['orderBy'];
                 $count = Booking::with('reservedRoom_grp.room.roomDetails', 'remarksHistory')->where(function ($query1) use($query) {
                     $query1->where('id', 'LIKE', "%{$query}%")->orWhereRaw("concat_ws(' ',firstname,lastname) LIKE '%{$query}%'")->orWhere('firstname', 'LIKE', "%{$query}%")->orWhere('lastname', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%");
                 })->where(function ($date) use($startdate, $enddate) {
                     $date->whereBetween('check_in', array($startdate, $enddate))->orWhereBetween('check_out', array($startdate, $enddate))->orWhereRaw('"' . $startdate . '" between check_in and check_out')->orWhereRaw('"' . $enddate . '" between check_in and check_out');
                 })->where(function ($status) use($status_arr) {
                     $status->whereIn('status', $status_arr);
                 })->get()->count();
                 $b = Booking::with('reservedRoom_grp.room.roomDetails', 'remarksHistory')->where(function ($query1) use($query) {
                     $query1->where('id', 'LIKE', "%{$query}%")->orWhereRaw("concat_ws(' ',firstname,lastname) LIKE '%{$query}%'")->orWhere('firstname', 'LIKE', "%{$query}%")->orWhere('lastname', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%");
                 })->orWhere(function ($date) use($startdate, $enddate) {
                     $date->whereBetween('check_in', array($startdate, $enddate))->orWhereBetween('check_out', array($startdate, $enddate))->orWhereRaw('"' . $startdate . '" between check_in and check_out')->orWhereRaw('"' . $enddate . '" between check_in and check_out');
                 })->where(function ($status) use($status_arr) {
                     $status->whereIn('status', $status_arr);
                 })->orderBy("{$orderBy}", 'DESC')->skip($skip)->take($items)->get();
             } else {
                 $orderBy = $_GET['orderBy'];
                 $count = Booking::all()->count();
                 $b = Booking::with('reservedRoom_grp.room.roomDetails', 'remarksHistory')->where('id', 'LIKE', "%{$query}%")->orWhereRaw("concat_ws(' ',firstname,lastname) LIKE '%{$query}%'")->orWhere('firstname', 'LIKE', "%{$query}%")->orWhere('lastname', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%")->skip($skip)->take($items)->get();
             }
             $response = Response::make($b, 200);
             $response_array['Content-Ranges'] = 'itemss ' . $range . '/' . $count;
             $response->header('Content-Range', $response_array['Content-Ranges'])->header('Accept-Ranges', 'items')->header('Range-Unit', 'items')->header('Total-Items', $count)->header('Flash-Message', 'Now showing pages ' . $arr[0] . '-' . $arr[1] . ' out of ' . $count);
             return $response;
         } else {
             $count = Booking::all()->count();
             if (isset($_GET['orderBy']) && $_GET['orderBy'] != '') {
                 $orderBy = $_GET['orderBy'];
                 $b = Booking::with('reservedRoom_grp.room.roomDetails', 'remarksHistory')->orderBy("{$orderBy}", 'DESC')->skip($skip)->take($items)->get();
             } else {
                 $b = Booking::with('reservedRoom_grp.room.roomDetails', 'remarksHistory')->skip($skip)->take($items)->get();
             }
         }
         $response = Response::make($b, 200);
         $response_array['Content-Ranges'] = 'items ' . $range . '/' . $count;
         $response->header('Content-Range', $response_array['Content-Ranges'])->header('Accept-Ranges', 'items')->header('Range-Unit', 'items')->header('Total-Items', $count)->header('Flash-Message', 'Now showing pages ' . $arr[0] . '-' . $arr[1] . ' out of ' . $count);
         return $response;
     }
     $b = Booking::all();
     $response = Response::make($b, 200);
     $response->header('Content-Ranges', 'test');
     return $response;
 }
 public function ajax_todayDeparture()
 {
     $today = date('Y-m-d');
     $today_stats = Booking::with('reservedRoom_grp.room.roomDetails')->where(function ($query) use($today) {
         $query->where('status', 3)->orWhere(function ($query) use($today) {
             $query->where('check_out', 'like', "%{$today}%")->where(function ($query1) {
                 $query1->where('status', '!=', '5')->orWhere('status', '!=', 4);
             });
         });
     })->get();
     $cpage = 'dashboard';
     $bookings = [];
     foreach ($today_stats as $stats) {
         array_push($bookings, $stats);
     }
     //return $today;
     return $bookings;
 }