public function storeAllData() { $data = Session::pull('MyBookingData'); if (Session::has('rate_box_details') || Session::has('transport_cart_box') || Session::has('predefined_transport') || Session::has('excursion_cart_details')) { if ($booking = Booking::create($data)) { $ehi_users = User::getEhiUsers(); if (Auth::check()) { //DB::table('booking_user')->insert(array('booking_id' => $booking->id, 'user_id' => $user->id)); if (Session::has('client-list')) { $clients = Session::pull('client-list'); foreach ($clients as $client) { $client['booking_id'] = $booking->id; $client['gender'] === 'male' ? $client['gender'] = 1 : ($client['gender'] = 0); Client::create($client); } } $flight_data = []; $flight_data['booking_id'] = $booking->id; $flight_data['date'] = $data['date_arrival']; $flight_data['time'] = $data['arrival_time']; $flight_data['flight'] = $data['arrival_flight']; $flight_data['flight_type'] = 1; FlightDetail::create($flight_data); //departure flight data $flight_data['date'] = $data['date_departure']; $flight_data['time'] = $data['departure_time']; $flight_data['flight'] = $data['departure_flight']; $flight_data['flight_type'] = 0; FlightDetail::create($flight_data); } /** * transport - custom trips */ $a = 0; if (Session::has('transport_cart_box')) { $custom_trips = Session::pull('transport_cart_box'); $a++; $x = 1; foreach ($custom_trips as $custom_trip) { $custom_trip['from'] = date('Y-m-d H:i', strtotime($custom_trip['pick_up_date'] . ' ' . $custom_trip['pick_up_time_hour'] . ':' . $custom_trip['pick_up_time_minutes'])); $custom_trip['to'] = date('Y-m-d H:i', strtotime($custom_trip['drop_off_date'] . ' ' . $custom_trip['drop_off_time_hour'] . ':' . $custom_trip['drop_off_time_minutes'])); $custom_trip['reference_number'] = 'TR' . ($booking->reference_number * 1000 + $x++); $custom_trip['booking_id'] = $booking->id; $custom_trip['locations'] = $custom_trip['destination_1'] . ',' . $custom_trip['destination_2'] or '' . ',' . $custom_trip['destination_3']; $custom_trip['amount'] = rand(100, 200); CustomTrip::create($custom_trip); } } /** * predefined package bookings */ if (Session::has('predefined_transport')) { $a++; $predefined_packages = Session::pull('predefined_transport'); foreach ($predefined_packages as $predefined_package) { $package = []; $package['transport_package_id'] = $predefined_package['predefine_id']; $package['booking_id'] = $booking->id; $package['pick_up_date_time'] = $predefined_package['check_in_date']; $package['amount'] = TransportPackage::find($predefined_package['predefine_id'])->rate; PredefinedTrip::create($package); } } /** * Send Transportation Email to All EHI users */ $pdf = PDF::loadView('emails/transport', array('booking' => $booking)); $pdf->save('public/temp-files/transport' . $booking->id . '.pdf'); // if ($a > 0) { // Mail::send('emails/transport-mail', array( // 'booking' => Booking::find($booking->id) // ), function ($message) use ($booking, $ehi_users) { // $message->attach('public/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 (Session::has('excursion_cart_details')) { $excursions = Session::pull('excursion_cart_details'); $x = 1; foreach ($excursions as $excursion) { $excursionBooking = ExcursionRate::with(array('city', 'excursion', 'excursionTransportType'))->where('city_id', $excursion['city_id'])->where('excursion_transport_type_id', $excursion['excursion_transport_type'])->where('excursion_id', $excursion['excursion'])->first(); $excursionBookingData = array('booking_id' => $booking->id, 'city_id' => $excursionBooking->city_id, 'excursion_transport_type_id' => $excursionBooking->excursion_transport_type_id, 'excursion_id' => $excursionBooking->excursion_id, 'unit_price' => $excursionBooking->rate, 'pax' => $excursion['excursion_pax'], 'date' => $excursion['excursion_date'], 'reference_number' => 'EX' . ($booking->reference_number * 1000 + $x++)); ExcursionBooking::create($excursionBookingData); } $pdf = PDF::loadView('emails/excursion', array('booking' => $booking)); $pdf->save('public/temp-files/excursions.pdf'); // Mail::send('emails/excursion-mail', array( // 'booking' => $booking // ), function ($message) use ($booking, $ehi_users) { // $message->attach('public/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 bookings */ if (Session::has('rate_box_details')) { $bookings = Session::pull('rate_box_details'); $vouchers = Voucher::arrangeHotelBookingsVoucherwise($bookings, $booking->id); foreach ($vouchers as $voucher) { $created_voucher = Voucher::create($voucher); for ($c = 0; $c < count($voucher) - 6; $c++) { $voucher[$c]['voucher_id'] = $created_voucher->id; $RoomBooking = RoomBooking::create($voucher[$c]); } // voucher $pdf = PDF::loadView('emails/voucher', array('voucher' => $created_voucher)); $pdf->save('public/temp-files/voucher' . $created_voucher->id . '.pdf'); // $hotel_users = DB::table('users')->leftJoin('hotel_user', 'users.id', '=', 'hotel_user.user_id') // ->where('hotel_user.hotel_id', $created_voucher->hotel_id) // ->get(); // // Mail::send('emails/voucher-mail', array( // 'voucher' => Voucher::find($created_voucher->id) // ), function ($message) use ($booking, $hotel_users,$created_voucher) { // $message->attach('public/temp-files/voucher'.$created_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); // } // }); } } //Booking details // $pdf = PDF::loadView('emails/booking', array('booking' => $booking)); // $pdf->save('public/temp-files/booking'.$booking->id.'.pdf'); // $ehi_users = User::getEhiUsers(); // $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**'); // // Mail::send('emails/booking-mail', array( // 'booking' => Booking::getBookingData($booking->id) // ), function ($message) use ($booking, $emails, $ehi_users) { // $message->attach('public/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::create(array('booking_id' => $booking->id, 'amount' => Booking::getTotalBookingAmount($booking), 'count' => 1)); //Invoice $pdf = PDF::loadView('emails/invoice', array('booking' => $booking)); $pdf->save('public/temp-files/invoice' . $booking->id . '.pdf'); $pdf = PDF::loadView('emails/service-voucher', array('booking' => $booking)); $pdf->save('public/temp-files/service-voucher.pdf'); // 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/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 { // // 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/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); // } // } // }); // } if (!Auth::check()) { Session::flash('global', 'Emails have been sent to the Respective parties'); return View::make('pages.message'); } } return $booking; } else { return Redirect::back(); } return Redirect::route('bookings.index'); }
/** * Remove the specified predefinedtrip from storage. * * @param int $id * @return Response */ public function destroy($id) { PredefinedTrip::destroy($id); return Redirect::route('predefinedtrips.index'); }