Ejemplo n.º 1
0
 public function destroy($kitTypeID)
 {
     // This Shall be fun!
     // We have to deconstruct the types based on the forign key dependencys
     // First iterate all the kits, for each kit remove all contents,
     // and then all bookings (and all booking details)
     // then finally we can remove the kit type and then all the logs for that
     // kit type.
     foreach (Kits::where('KitType', '=', $kitTypeID)->get() as $kit) {
         foreach (KitContents::where("KitID", '=', $kit->ID)->get() as $content) {
             KitContents::destroy($content->ID);
         }
         foreach (Booking::where("KitID", '=', $kit->ID)->get() as $booking) {
             foreach (BookingDetails::where("BookingID", '=', $booking->ID)->get() as $detail) {
                 BookingDetails::destroy($detail->ID);
             }
             Booking::destroy($booking->ID);
         }
         Kits::destroy($kit->ID);
     }
     KitTypes::destroy($kitTypeID);
     // Do the logs last, as all the deletes will log the changes of deleting the bits.
     Logs::where('LogKey1', '=', $kitTypeID)->delete();
     return "OK";
 }
Ejemplo n.º 2
0
 /**
  * Performs the registration customer/ticket search and displays the results.
  */
 public function search()
 {
     $ticket = Input::get('ticket');
     $name = Input::get('name');
     if (empty($ticket) && empty($name)) {
         return Redirect::route('register')->with('message', 'You must provide at least one of the search criteria');
     }
     if (!empty($ticket)) {
         $bookings = Booking::where(function ($query) use($ticket) {
             $query->where('bookings.numbers', $ticket)->orWhere('bookings.numbers', 'LIKE', "{$ticket},%")->orWhere('bookings.numbers', 'LIKE', "{$ticket} ,%")->orWhere('bookings.numbers', 'LIKE', "%,{$ticket},%")->orWhere('bookings.numbers', 'LIKE', "%, {$ticket},%")->orWhere('bookings.numbers', 'LIKE', "%, {$ticket} ,%")->orWhere('bookings.numbers', 'LIKE', "%,{$ticket} ,%")->orWhere('bookings.numbers', 'LIKE', "%, {$ticket}")->orWhere('bookings.numbers', 'LIKE', "%,{$ticket}");
         })->orderBy('bookings.first')->orderBy('bookings.last')->get();
     }
     if (!empty($name) && (!isset($bookings) or $bookings->count() == 0)) {
         $parts = explode(' ', $name);
         if (count($parts) > 1) {
             $bookings = Booking::where(function ($query) use($parts) {
                 $query->where('bookings.first', 'LIKE', "%{$parts[0]}%")->where('bookings.last', 'LIKE', "%{$parts[1]}%");
             })->orderBy('bookings.first')->orderBy('bookings.last')->get();
         } else {
             $bookings = Booking::where(function ($query) use($name) {
                 $query->where('bookings.first', 'LIKE', "%{$name}%")->orWhere('bookings.last', 'LIKE', "%{$name}%");
             })->orderBy('bookings.first')->orderBy('bookings.last')->get();
         }
     }
     $booking_count = $bookings->count();
     if ($booking_count == 0) {
         return Redirect::route('register')->withInput()->with('message', 'No booking found!');
     }
     $this->layout->with('subtitle', 'Register a delegate');
     $this->layout->content = View::make('registrations.register')->with('bookings', $bookings);
 }
 public function register($leadership_event_id, $booking_id)
 {
     $input = Input::all();
     $validator = Validator::make($input, Booking::$rules);
     if ($validator->passes()) {
         $booking = Booking::findOrFail($booking_id);
         $booking->registration_date = new Datetime();
         $booking->first = Input::get('first');
         $booking->last = Input::get('last');
         $booking->email = Input::get('email');
         $booking->contact_number = Input::get('contact_number');
         $booking->church = Input::get('church');
         $booking->role = Input::get('role');
         $booking->notes = Input::get('notes');
         $booking->save();
         return Redirect::route('registration', array($leadership_event_id))->with('info', 'Registration complete!');
     } else {
         $event = LeadershipEvent::find($leadership_event_id);
         $bookings = Booking::where('id', $booking_id)->get();
         $bookings->each(function ($booking) {
             // Should actually only be one...
             $booking->first = Input::get('first');
             $booking->last = Input::get('last');
             $booking->email = Input::get('email');
             $booking->contact_number = Input::get('contact_number');
             $booking->church = Input::get('church');
             $booking->role = Input::get('role');
             $booking->notes = Input::get('notes');
         });
         $this->layout->with('subtitle', $event->name());
         $this->layout->withErrors($validator);
         $this->layout->content = View::make('registration.index')->with('event', $event)->with('bookings', $bookings)->with('errors', $validator->messages());
     }
 }
Ejemplo n.º 4
0
 public static function totalCreditFromAllBookings()
 {
     $bookings = Booking::where('user_id', Auth::id())->get();
     $total = 0;
     foreach ($bookings as $booking) {
         $total += Booking::getTotalBookingAmount($booking);
     }
     return $total;
 }
Ejemplo n.º 5
0
 public function update(Request $request, $id)
 {
     $booking = Booking::where('id', $id)->first();
     $booking->arrive_date = $request->input('arrive_date');
     $booking->leave_date = $request->input('leave_date');
     $booking->personal_ids = $request->input('personal_ids');
     $booking->room_id = $request->input('room_id');
     $booking->save();
     return $booking;
 }
 public function view()
 {
     /*
             $user = Auth::user();
             $personal_bookings = Booking::where('user_id', '=', $user->id);
             $bookings_of_my_spaces = Booking::where('space_owner_id', '=', $user->id);
             $my_spaces = Listing::where('owner_id', '=', $user->id)->get(array('title', 'id'));
     */
     $userid = Auth::user()->id;
     $user = User::findOrFail($userid);
     $personal_bookings = $user->booking;
     $bookings_of_my_spaces = Booking::where('space_owner_id', '=', $userid)->get();
     // $bookings_of_my_spaces = $user->bookings_by_others;
     $my_spaces = $user->listing;
     return View::make('dashboard.DashboardView')->with('name', $user->name)->with('email', $user->email)->with('personal_bookings', $personal_bookings)->with('bookings_of_my_spaces', $bookings_of_my_spaces)->with('my_spaces', $my_spaces);
 }
 public function paymentGet()
 {
     if (isset($_GET)) {
         $amount = HsbcPayment::null2unknown($_GET["vpc_Amount"]);
         $locale = HsbcPayment::null2unknown($_GET["vpc_Locale"]);
         $batchNo = HsbcPayment::null2unknown($_GET["vpc_BatchNo"]);
         $command = HsbcPayment::null2unknown($_GET["vpc_Command"]);
         $message = HsbcPayment::null2unknown($_GET["vpc_Message"]);
         $version = HsbcPayment::null2unknown($_GET["vpc_Version"]);
         $cardType = HsbcPayment::null2unknown($_GET["vpc_Card"]);
         $orderInfo = HsbcPayment::null2unknown($_GET["vpc_OrderInfo"]);
         $receiptNo = HsbcPayment::null2unknown($_GET["vpc_ReceiptNo"]);
         $merchantID = HsbcPayment::null2unknown($_GET["vpc_Merchant"]);
         $authorizeID = HsbcPayment::null2unknown($_GET["vpc_AuthorizeId"]);
         $merchTxnRef = HsbcPayment::null2unknown($_GET["vpc_MerchTxnRef"]);
         $transactionNo = HsbcPayment::null2unknown($_GET["vpc_TransactionNo"]);
         $acqResponseCode = HsbcPayment::null2unknown($_GET["vpc_AcqResponseCode"]);
         $txnResponseCode = HsbcPayment::null2unknown($_GET["vpc_TxnResponseCode"]);
         $verType = array_key_exists("vpc_VerType", $_GET) ? $_GET["vpc_VerType"] : "No Value Returned";
         $verStatus = array_key_exists("vpc_VerStatus", $_GET) ? $_GET["vpc_VerStatus"] : "No Value Returned";
         $token = array_key_exists("vpc_VerToken", $_GET) ? $_GET["vpc_VerToken"] : "No Value Returned";
         $verSecurLevel = array_key_exists("vpc_VerSecurityLevel", $_GET) ? $_GET["vpc_VerSecurityLevel"] : "No Value Returned";
         $enrolled = array_key_exists("vpc_3DSenrolled", $_GET) ? $_GET["vpc_3DSenrolled"] : "No Value Returned";
         $xid = array_key_exists("vpc_3DSXID", $_GET) ? $_GET["vpc_3DSXID"] : "No Value Returned";
         $acqECI = array_key_exists("vpc_3DSECI", $_GET) ? $_GET["vpc_3DSECI"] : "No Value Returned";
         $authStatus = array_key_exists("vpc_3DSstatus", $_GET) ? $_GET["vpc_3DSstatus"] : "No Value Returned";
         $payment_info = HsbcPayment::where('HSBC_payment_id', $merchTxnRef);
         if ($payment_info) {
             $qsi_res_code = HsbcPayment::getResponseDescription($txnResponseCode);
             $pay = array();
             $pay = array('paid_amount' => $amount / 100, 'vpc_txn_res_code' => $txnResponseCode, 'qsi_res_code' => $qsi_res_code, 'vpc_message' => $message, 'vpc_receipt_number' => $receiptNo, 'vpc_txn_no' => $transactionNo, 'vpc_acq_res_code' => $acqResponseCode, 'vpc_bank_auth_id' => $authorizeID, 'vpc_batch_no' => $batchNo, 'card_type' => $cardType, 'vpc_merchant' => $merchantID, 'vpc_command' => $command, 'vpc_version' => $version, 'vpc_Locale' => $locale, 'vpc_OrderInfo' => $orderInfo);
             $HSBC_payments = DB::table('hsbc_payments')->where('HSBC_payment_id', $merchTxnRef)->update($pay);
             if (substr_count($orderInfo, 'A') != 0) {
                 if ($txnResponseCode == 0) {
                     $mybooking = 0;
                     $payment = DB::table('payments')->where('HSBC_payment_id', $merchTxnRef)->update(array('my_booking' => $mybooking));
                     $booking = Booking::where('payment_reference_number', $orderInfo)->first();
                     $this->sendBookingEmails($booking);
                 }
             }
             if (substr_count($orderInfo, 'B') != 0) {
                 if ($txnResponseCode == 0) {
                     $mybooking = 0;
                     $payment = DB::table('payments')->where('HSBC_payment_id', $merchTxnRef)->update(array('my_booking' => $mybooking));
                     $booking = Booking::where('payment_reference_number', $orderInfo)->first();
                     $this->sendBookingEmails($booking);
                 }
             }
             if (substr_count($orderInfo, 'O') != 0) {
                 if ($txnResponseCode == 0) {
                     $mybooking = 0;
                     $payment = DB::table('payments')->where('HSBC_payment_id', $merchTxnRef)->update(array('my_booking' => $mybooking));
                     $booking = Booking::where('payment_reference_number', $orderInfo)->first();
                     $payment = Payment::where('reference_number', $orderInfo)->first();
                     //dd($booking->email);
                     //                        Mail::send('emails/online-payment', array(
                     //                            'payment' => $payment,
                     //                            'booking' => $booking
                     //                        ), function ($message) use ($booking) {
                     //                            $message->subject('Online Payment Receipt : ' . $booking->reference_number)
                     //                                ->from('*****@*****.**', 'SriLankaHotels.Travel')
                     //                                ->bcc('*****@*****.**')
                     //                                ->to('*****@*****.**');
                     //                        });
                     Mail::send('emails/online-payment', array('booking' => $booking, 'payment' => $payment), function ($message) use($booking, $payment) {
                         $message->subject('Payment : ' . $payment->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->to($booking->email, $booking->booking_name)->bcc('*****@*****.**', 'Admin');
                     });
                     Session::flash('global', 'Thank you for paying online. </br> We have emailed you the online payment invoice');
                     // return View::make('pages.message');
                 }
                 Session::flash('global', 'Sorry Your Payment was unsuccessful!');
                 //  return View::make('pages.message');
             }
             if (substr_count($orderInfo, 'AP') != 0) {
                 if ($txnResponseCode == 0) {
                     $mybooking = 0;
                     $payment = DB::table('payments')->where('HSBC_payment_id', $merchTxnRef)->update(array('my_booking' => $mybooking));
                     $booking = Booking::where('payment_reference_number', $orderInfo)->first();
                     $this->sendBookingEmails($booking);
                 }
             }
             $url = "http://srilankahotels.travel/message";
             header("Location: {$url}");
             exit;
         } else {
             die("An error occurred. Please contact administrator");
         }
     } else {
         header("Location:index.php");
         exit;
     }
 }
 public function update($id)
 {
     $today = date("Y-m-d H:i:s");
     $i = Input::all();
     $bookingRemarks = '';
     $addition = 0;
     $deduction = 0;
     if ($i['savethis'] == true) {
         $addition -= $i['price_addition'];
         $deduction += $i['price_deduction'];
     }
     $booking = Booking::where('id', $id)->with('reservedRoom.room.roomDetails')->first();
     //$booking = ReservedRoom::where('id', $id)->with('room.roomDetails')->first();
     $old_status = $booking->status;
     $current_price = $booking->price;
     $current_price += $addition + $deduction;
     if (!empty($booking)) {
         $booking->status = $i['status'];
         if ($i['status'] == 5) {
             $booking->cancelled_at = $today;
             $booking->paid = 0;
             $booking->price = 0;
             $booking->cancelled_remarks = $i['cancelled_remarks'];
         } else {
             if ($i['status'] == 1) {
                 $booking->paid = $i['paid'];
             } else {
                 //$booking->paid=0;
                 $booking->price = $current_price;
                 $booking->cancelled_remarks = '';
                 $booking->cancelled_at = '0000-00-00 00:00:00';
             }
         }
         if ($booking->save()) {
             if ($i['savethis'] == true) {
                 $newBookingRemarks = new BookingRemarksHistory();
                 $newBookingRemarks->additional = $addition;
                 $newBookingRemarks->deduction = $deduction;
                 $newBookingRemarks->remarks = $i['bookingremarks'];
                 $newBookingRemarks->booking_id = $id;
                 $newBookingRemarks->save();
             }
             $roomReserved = ReservedRoom::where('booking_id', $booking->id)->get();
             foreach ($roomReserved as $rr) {
                 $rr->status = $i['status'];
                 $rr->save();
             }
             $a = new Activity();
             $a->actor = Auth::id();
             $a->location = 3;
             $a->logs = 'Updated booking ID of:' . $booking->id . ' by ' . $booking->firstname . ' ' . $booking->lastname . ' from ' . $this->bookingStatus($old_status) . ' to ' . $this->bookingStatus($booking->status);
             //before to after status.
             $a->save();
             return $booking;
         } else {
             return '0';
             //means failed
         }
     }
 }
 });
 Route::get('getbookinglist', 'BookingController@bookingList');
 Route::post('getbookinglist/search', 'BookingController@searchList');
 Route::post('getbookinginfo/{id}', 'BookingController@searchBooking');
 Route::post('booking/{id}/update', 'BookingController@update');
 Route::post('booking/{id}/payment', 'BookingController@payment');
 Route::post('currentbooking/save', function () {
     $i = Input::all();
     $membershipDiscount = null;
     if (isset($i['membership_id'])) {
         $membership = Customer::where('membership_id', $i['membership_id'])->first();
         if ($membership) {
             $membershipDiscount = $membership->current_discount;
         }
     }
     $booking = Booking::where('id', $i['booking_id'])->first();
     if ($booking) {
         $booking->firstname = $i['firstname'];
         $booking->lastname = $i['lastname'];
         $booking->address = $i['address'];
         $booking->contact_number = $i['contact_no'];
         $booking->status = 1;
         $booking->save();
         $reservation = ReservedRoom::where('booking_id', $i['booking_id'])->get();
         if (count($reservation) > 0) {
             foreach ($reservation as $r) {
                 $r->firstname = Input::has('firstname') ? $i['firstname'] : 'WALK-IN';
                 $r->lastname = Input::has('lastname') ? $i['lastname'] : 'WALK-IN';
                 $r->address = Input::has('address') ? $i['address'] : 'WALK-IN';
                 $r->contact_number = Input::has('contact_no') ? $i['contact_no'] : 'WALK-IN';
                 $r->status = 1;
Ejemplo n.º 10
0
 public static function getBookingData($booking_id)
 {
     return Booking::where('id', $booking_id)->with('client')->with('flightDetail')->with('voucher')->with('invoice')->with('customTrip')->with('predefinedTrip')->first();
 }
 public function todayBookingSuccess()
 {
     $today = date('Y-m-d');
     //$today_stats = ReservedRoom::where('created_at','>', $today)->get();
     $today_stats = Booking::where('created_at', '>', $today)->get();
     $cpage = 'dashboard';
     return View::make('adminview.dashboard.success_bookings', compact('cpage', 'success_bookings'));
 }
Ejemplo n.º 12
0
 public function destroy($kitID)
 {
     $kit = Kits::find($kitID);
     foreach (Booking::where('KitID', '=', $kitID)->get() as $book) {
         foreach (BookingDetails::where('BookingID', '=', $book->ID)->get() as $detail) {
             BookingDetails::destroy($detail->ID);
         }
         Booking::destroy($book->ID);
     }
     foreach ($kit->contents as $content) {
         KitContents::destroy($content->ID);
     }
     Kits::destroy($kitID);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $bookings = Booking::where('userId', $id)->get();
     return Response::json($bookings);
 }
 public function getIndex()
 {
     return View::make('bookings.index')->with('bookings', Booking::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'DESC')->paginate(10));
 }
Ejemplo n.º 15
0
 public static function getWeekStats()
 {
     $dateTime = new \DateTime('First Monday of this month');
     $startUts = $dateTime->format('U');
     $dateTime->modify('+6 week');
     $endUts = $dateTime->format('U');
     $bookings = Booking::where('startUts', '>=', $startUts)->where('startUts', '<', $endUts)->where('user_id', UserFrosting::getInstance()->user->id)->get(['startUts', 'status']);
     $data = array();
     foreach ($bookings as $booking) {
         $week = strftime('%G W%V', $booking->startUts);
         if (!isset($data[$week])) {
             $data[$week] = array('period' => $week, 'new' => 0, 'accepted' => 0, 'rejected' => 0);
         }
         $data[$week][$booking->status]++;
     }
     $response = new \StdClass();
     $response->data = $data;
     $response->json = json_encode(array_values($data));
     $response->title = strftime('%e %b', $startUts) . ' - ' . strftime('%e %b', $endUts - 10800);
     return $response;
 }
 public function bookingStep2($id)
 {
     $i = Input::all();
     $i['checkin'] = $i['checkin'] . ' 12:00:00';
     //
     $i['checkout'] = $i['checkout'] . ' 11:59:00';
     $total_price = null;
     $tax = null;
     $booking_session = [];
     $count = 0;
     //for test
     $count1 = 0;
     //for test
     $booked_room = [];
     //all picked rooms from available rooms
     $booked_room_id = [];
     //foreach(Session::get('reservation')['reservation_room'] as $rooms){
     $count++;
     $room_id = $id;
     $available_rooms = [];
     $room_qty = RoomQty::with(array('roomPrice', 'roomReserved' => function ($query) use($i, $room_id) {
         $query->where(function ($query2) use($i, $room_id) {
             $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);
         });
     }))->where('status', 1)->where('room_id', $room_id)->get();
     foreach ($room_qty as $available) {
         if (count($available->roomReserved) == 0) {
             array_push($available_rooms, $available);
         } else {
         }
     }
     if (!empty($available_rooms)) {
         for ($counter = 0; $counter < $i['quantity']; $counter++) {
             array_push($booked_room, $available_rooms[$counter]);
         }
     } else {
         return '0';
         //not available
     }
     //} //end of foreach
     $total_price = 0;
     if (!isset($_GET['bookingId'])) {
         $new_booking = new Booking();
         $new_booking->firstname = 'WALK-IN';
         $new_booking->lastname = 'WALK-IN';
         $new_booking->address = 'WALK-IN';
         $new_booking->contact_number = '000';
         $new_booking->check_in = $i['checkin'];
         $new_booking->check_out = $i['checkout'];
         $new_booking->email_address = 'WALK-IN';
         $new_booking->code = 'N/A';
         $new_booking->status = 0;
         $new_booking->save();
     }
     foreach ($booked_room as $b) {
         $ci = new Carbon($i['checkin']);
         $co = new Carbon($i['checkout']);
         $total_nights = $co->diff($ci)->days;
         $total_nights += 1;
         $total_price += $total_nights * $b->roomPrice->price;
         $total_price2 = $total_nights * $b->roomPrice->price;
         //$tax = $total_price2 * 0.12;
         //$total_price2+=$tax;
         $reserveRoom = new ReservedRoom();
         $reserveRoom->room_id = $b->id;
         $reserveRoom->room_type = $b->room_id;
         $reserveRoom->booking_id = isset($_GET['bookingId']) ? $_GET['bookingId'] : $new_booking->id;
         $reserveRoom->check_in = $i['checkin'];
         $reserveRoom->check_out = $i['checkout'];
         $reserveRoom->code = 'N/A';
         /*$reserveRoom->firstname = 'WALK-IN';
         		$reserveRoom->lastname = 'WALK-IN';*/
         $reserveRoom->price = $total_price2;
         /*$reserveRoom->address = 'WALK-IN';
         		$reserveRoom->contact_number = '000';
         		$reserveRoom->email_address = 'WALK-IN';*/
         $reserveRoom->status = '0';
         if ($reserveRoom->save()) {
             array_push($booked_room_id, $reserveRoom->id);
         }
     }
     if (isset($_GET['bookingId'])) {
         $existing_booking = Booking::where('id', $_GET['bookingId'])->first();
         if ($existing_booking) {
             $existing_booking->price = $total_price;
         }
     } else {
         $new_booking->price = $total_price;
         $new_booking->save();
     }
     //	return Session::get('reservation');
     //return $booked_room;
     //return $counter;
     //return $room_qty1;
     $booking_session['booking_id'] = isset($_GET['bookingId']) ? $_GET['bookingId'] : $new_booking->id;
     $booking_session['rooms'] = $booked_room_id;
     return $booking_session;
 }