/**
  * Show the form for editing the specified booking.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $booking = Booking::find($id);
     $clients = Client::all();
     $cars = Car::all();
     return View::make('bookings.edit', compact('booking', 'cars', 'clients'));
 }
 public function postManage()
 {
     $booking = Booking::find(Input::get('id'));
     if ($booking) {
         $booking->status = Input::get('status');
         $booking->save();
         return Redirect::to('bookings/manage')->with('message', 'Booking Updated');
     }
     return Redirect::back()->with('message', 'Something went wrong, please try again');
 }
Exemple #3
0
 public function thankyou($payment_reference = null, $charge = null)
 {
     $charge = Session::get('charge');
     $payment_reference = Session::get('payment_reference');
     if ($payment_reference) {
         $booking = Booking::find($payment_reference);
         $booking->receipt = array('stripe_id' => $charge->id, 'payment_reference' => Session::get('payment_reference'), 'amount' => $charge->amount);
         $booking->save();
         Tour::where('dates.id', (int) $booking->tour_date)->decrement('dates.$.spaces');
         $tour = Tour::find($booking->id);
         Mail::send('emails.stripebooking', compact('booking', 'tour'), function ($message) {
             $message->to('*****@*****.**', 'Not Normal Tours')->subject('New Booking at Not Normal Tours');
         });
         return View::make('pages.thankyou');
     }
     return View::make('pages.thankyou');
 }
 public function sendBookingEmails($booking)
 {
     $ehi_users = User::getEhiUsers();
     Mail::send('emails/transport-mail', array('booking' => Booking::find($booking->id)), function ($message) use($booking, $ehi_users) {
         $message->attach(public_path() . '/temp-files/transport.pdf')->subject('New Transfer : ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->bcc('*****@*****.**');
         if (!empty($ehi_users)) {
             foreach ($ehi_users as $ehi_user) {
                 $message->to($ehi_user->email, $ehi_user->first_name);
             }
         }
     });
     /**
      * Excursions
      */
     if ($booking->excursion->count()) {
         Mail::send('emails/excursion-mail', array('booking' => $booking), function ($message) use($booking, $ehi_users) {
             $message->attach(public_path() . '/temp-files/excursions.pdf')->subject('New Excursions : ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel');
             $message->to('*****@*****.**', 'Excursions');
             $message->bcc('*****@*****.**', 'Admin');
             if (!empty($ehi_users)) {
                 foreach ($ehi_users as $ehi_user) {
                     $message->to($ehi_user->email, $ehi_user->first_name);
                 }
             }
         });
     }
     /**
      * Hotel Vouchers
      */
     $vouchers = $booking->voucher;
     foreach ($vouchers as $voucher) {
         $hotel_users = DB::table('users')->leftJoin('hotel_user', 'users.id', '=', 'hotel_user.user_id')->where('hotel_user.hotel_id', $voucher->hotel_id)->get();
         Mail::send('emails/voucher-mail', array('voucher' => $voucher), function ($message) use($booking, $hotel_users, $voucher) {
             $message->attach(public_path() . '/temp-files/voucher' . $voucher->id . '.pdf')->subject('Booking Voucher : ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->bcc('*****@*****.**', 'SriLankaHotels.Travel');
             if (!empty($hotel_users)) {
                 foreach ($hotel_users as $hotel_user) {
                     $message->to($hotel_user->email, $hotel_user->first_name);
                 }
             }
         });
     }
     /**
      * Bookings
      */
     $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
     Mail::send('emails/booking-mail', array('booking' => Booking::getBookingData($booking->id)), function ($message) use($booking, $emails, $ehi_users) {
         $message->attach(public_path() . '/temp-files/booking' . $booking->id . '.pdf')->subject('New Booking: ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->bcc('*****@*****.**', 'Admin');
         foreach ($emails as $emailaddress) {
             $message->to($emailaddress, 'Admin');
         }
         if (!empty($ehi_users)) {
             foreach ($ehi_users as $ehi_user) {
                 $message->to($ehi_user->email, $ehi_user->first_name);
             }
         }
     });
     /**
      * Invoice
      *
      *
      * Logged user
      */
     if ($user = $booking->user) {
         Mail::send('emails/invoice-mail', array('booking' => Booking::getBookingData($booking->id)), function ($message) use($user, $booking, $emails) {
             $message->subject('Booking Invoice : ' . $booking->reference_number)->attach(public_path() . '/temp-files/invoice' . $booking->id . '.pdf');
             $message->to($user->email, $user->first_name . ' ' . $user->last_name);
             $message->to('*****@*****.**', 'Accounts');
             if (!empty($ehi_users)) {
                 foreach ($ehi_users as $ehi_user) {
                     $message->to($ehi_user->email, $ehi_user->first_name);
                 }
             }
         });
     } else {
         /**
          * Invoice
          * Guest User
          */
         Mail::send('emails/invoice-mail', array('booking' => Booking::getBookingData($booking->id)), function ($message) use($booking, $emails) {
             $message->to($booking->email, $booking->name)->subject('Booking Created : ' . $booking->reference_number)->attach(public_path() . '/temp-files/invoice' . $booking->id . '.pdf');
             $message->to('*****@*****.**', 'Accounts');
             if (!empty($ehi_users)) {
                 foreach ($ehi_users as $ehi_user) {
                     $message->to($ehi_user->email, $ehi_user->first_name);
                 }
             }
         });
     }
 }
 /**
  * Update the specified excursionbooking in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($booking_id, $id)
 {
     $excursionbooking = ExcursionBooking::findOrFail($id);
     $booking = Booking::getBookingData($booking_id);
     if (Input::has('val')) {
         if (Input::get('val') == 0) {
             $excursionbooking->val = 0;
             $excursionbooking->save();
             $ehi_users = User::getEhiUsers();
             $pdf = PDF::loadView('emails/excursion-cancellation', array('booking' => $booking));
             $pdf->save(public_path() . '/temp-files/excursion-cancellations.pdf');
             Mail::send('emails/excursion-mail', array('booking' => Booking::find($booking->id)), function ($message) use($booking, $ehi_users) {
                 $message->attach(public_path() . '/temp-files/excursions.pdf')->subject('Cancel Excursion : ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel');
                 $message->to('*****@*****.**', 'Excursions');
                 $message->to('*****@*****.**', 'Admin');
                 if (!empty($ehi_users)) {
                     foreach ($ehi_users as $ehi_user) {
                         $message->to($ehi_user->email, $ehi_user->first_name);
                     }
                 }
             });
             // Cancellation email
             Invoice::amendInvoice($booking);
             Booking::amendBooking($booking_id);
             // Service Voucher
             $pdf = PDF::loadView('emails/service-voucher', array('booking' => $booking));
             $pdf->setPaper('a4')->save(public_path() . '/temp-files/service_voucher_' . $booking->id . '.pdf');
             $ehi_users = User::getEhiUsers();
             //$booking = Booking::getBookingData($booking->id);
             Mail::send('emails/service-voucher-mail', array('booking' => $booking), function ($message) use($booking, $ehi_users) {
                 $message->attach(public_path() . '/temp-files/service_voucher_' . $booking->id . '.pdf')->subject('Amended Service Voucher: ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->bcc('*****@*****.**', 'Admin');
                 $message->to(Auth::user()->email, Auth::user()->first_name);
                 if (!empty($ehi_users)) {
                     foreach ($ehi_users as $ehi_user) {
                         $message->to($ehi_user->email, $ehi_user->first_name);
                     }
                 }
             });
             $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
             $pdf = PDF::loadView('emails/booking', array('booking' => $booking));
             $pdf->save(public_path() . '/temp-files/booking_' . $booking->id . '.pdf');
             Mail::send('emails/booking-mail', array('booking' => $booking), function ($message) use($booking, $emails, $ehi_users) {
                 $message->attach(public_path() . '/temp-files/booking_' . $booking->id . '.pdf')->subject('Amended Booking: ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->bcc('*****@*****.**', 'Admin');
                 //                foreach ($emails as $emailaddress) {
                 //                    $message->to($emailaddress, 'Admin');
                 //                }
                 if (!empty($ehi_users)) {
                     foreach ($ehi_users as $ehi_user) {
                         $message->to($ehi_user->email, $ehi_user->first_name);
                     }
                 }
             });
             $pdf = PDF::loadView('emails/invoice', array('booking' => $booking));
             $pdf->save(public_path() . '/temp-files/invoice_' . $booking->id . '.pdf');
             Mail::send('emails/invoice-mail', array('booking' => $booking), function ($message) use($booking, $emails, $ehi_users) {
                 $message->attach(public_path() . '/temp-files/invoice_' . $booking->id . '.pdf')->subject('Amended Invoice: ' . $booking->reference_number)->from('*****@*****.**', 'SriLankaHotels.Travel')->bcc('*****@*****.**', 'Admin');
                 //                foreach ($emails as $emailaddress) {
                 //                    $message->bcc($emailaddress, 'SysAdmin');
                 //                }
                 if (!empty($ehi_users)) {
                     foreach ($ehi_users as $ehi_user) {
                         $message->to($ehi_user->email, $ehi_user->first_name);
                     }
                 }
             });
             return Redirect::back();
         }
     }
     $validator = Validator::make($data = Input::all(), ExcursionBooking::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $excursionbooking->update($data);
     return Redirect::back();
 }
 public function deleteAjax()
 {
     $booking_id = Input::get('booking_id');
     $booking_item_id = Input::get('id');
     $booking = Booking::find($booking_id);
     if (!$booking) {
         return Response::json(array('status' => 'KO', 'message' => 'Réservation inconnue'));
     }
     $user = $booking->user;
     $booking_item = BookingItem::find($booking_item_id);
     $ressource = $booking_item->ressource;
     if ($booking->items()->count() == 1) {
         BookingItem::destroy($booking_item_id);
         Booking::destroy($booking_id);
     } else {
         BookingItem::destroy($booking_item_id);
     }
     try {
         $this->sendDeletedBookingNotification($booking_item, $ressource, $booking, $user);
     } catch (\Exception $e) {
     }
     if (Request::ajax()) {
         return Response::json(array('status' => 'OK', 'id' => $booking_item_id));
     }
     return Redirect::route('booking_list')->with('mSuccess', 'La réservation a été supprimée');
 }
Exemple #7
0
 public function complete()
 {
     $booking = Booking::find(Input::get('payment_reference'));
     $booking->receipt = Input::all();
     $booking->save();
     return true;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $booking = Booking::find($id);
     $booking->delete();
     return Response::json(array('code' => '200', 'info' => 'Booking has been deleted.'));
 }
Exemple #9
0
    });
    Route::get('booking/{id}', function ($id) {
        //    $hotel_users = DB::table('users')->leftJoin('hotel_user', 'users.id', '=', 'hotel_user.user_id')
        //        ->where('hotel_user.hotel_id', 1065)
        //        ->get();
        $booking = Booking::find($id);
        $pdf = PDF::loadView('emails/booking', array('booking' => $booking));
        return $pdf->stream();
    });
    Route::get('invoice/{id}', function ($id) {
        $booking = Booking::find($id);
        $pdf = PDF::loadView('emails/invoice', array('booking' => $booking));
        return $pdf->stream();
    });
    Route::get('service-voucher/{id}', function ($id) {
        $booking = Booking::find($id);
        $pdf = PDF::loadView('emails/service-voucher', array('booking' => $booking));
        return $pdf->stream();
    });
});
//auto complete route
Route::post('auto-complete', array('as' => 'auto-complete', 'uses' => 'HotelController@autoComplete'));
// Online Hotel Payments To gateway
Route::any('/payments-send', array('as' => 'online-hotel-payments', 'uses' => 'HsbcPaymentsController@sendPayment'));
// Online Hotel Payments email
Route::any('/online-hotel-payments-send-email', array('as' => 'online-hotel-payments-send-email', 'uses' => 'BookingsController@storeAllDataAndSendEmails'));
Route::any('/online-agent-payments-send-email', array('as' => 'online-agent-payments-send-email', 'uses' => 'PageController@storeAllDataAndSendEmails'));
Route::get('/online-hotel-payments', function () {
    return View::make('payment_send');
});
Route::any('/send-payment-gateway', array('as' => 'send-payment-gateway', 'uses' => 'HsbcPaymentsController@sendToPaymentGateway'));
 /**
  * GET /bookings/delete?id=
  */
 public function delete()
 {
     self::authorize_user();
     $booking = Booking::find($_GET['id']);
     $booking->delete();
     self::redirect_to('bookings/index');
 }