public static function getTotalBookingAmount($booking) { $total = 0; $total += Booking::getTotalVoucherAmount($booking); $total += Booking::getTotalCancelledVoucherAmount($booking); $total += TransportPackage::getTotalTransportationAmount($booking); $total += ExcursionBooking::getTotalExcursionBookingAmount($booking); return $total; }
public function index() { if (Session::has('st_date')) { $st_date = Session::get('st_date'); } else { $st_date = date("Y/m/d"); } //Session::flush(); if (Session::has('ed_date')) { $ed_date = Session::get('ed_date'); } else { $ed_date = date("Y/m/d", strtotime($st_date . ' + 2 days')); } $tour = Tour::take(5)->get(); $excursion = Excursion::take(5)->get(); $user_review = HotelReview::take(3)->get(); $transport_packages = TransportPackage::take(5)->get(); return View::make('index')->with(array('tour' => $tour, 'excursion' => $excursion, 'user_review' => $user_review, 'st_date' => $st_date, 'ed_date' => $ed_date, 'transport_packages' => $transport_packages)); }
/** * * Predefined Transport List * */ public function transportList() { $vehicle_id = array(); $vehicles = Vehicle::where('val', 1)->get(); // filtering $vehicle = Vehicle::lists('vehicle_type', 'id'); $city = array('76' => 'Any') + City::lists('city', 'id'); //$city['%'] = 'Any'; if (Session::has('st_date')) { $st_date = Session::get('st_date'); } else { $st_date = date("Y/m/d"); } if (Session::has('ed_date')) { $ed_date = Session::get('ed_date'); } else { $ed_date = date("Y/m/d", strtotime($st_date . ' + 2 days')); } if (Input::has('vehicle')) { $get_vehicle = Input::get('vehicle'); $vehicle_id[] = $get_vehicle; } else { $get_vehicle_ids = Vehicle::select('id')->get(); foreach ($get_vehicle_ids as $get_vehicle_id) { $vehicle_id[] = $get_vehicle_id->id; } } if (Input::has('price_range_transport')) { $price_range_array = Input::get('price_range_transport'); $price_range = explode(';', $price_range_array); $min_rate = $price_range[0]; $max_rate = $price_range[1]; $min_trans_rate = $min_rate; $max_trans_rate = $max_rate; } else { $min_rate = 0; $max_rate = 10000000; $min_trans_rate = TransportPackage::min('rate'); $max_trans_rate = TransportPackage::max('rate'); } if (Input::has('from')) { $from = Input::get('from'); } else { $from = '%'; } if (Input::has('from')) { $to = Input::get('to'); } else { $to = '%'; } // dd($from.'/'.$to); if (Input::has('transport_days')) { $days = Input::get('transport_days'); } else { $days = '%'; } //dd($min_rate.'/'.$max_rate); $transport_packages = TransportPackage::WhereHas('Vehicle', function ($r) use($vehicle_id) { $r->whereIn('id', $vehicle_id); })->where('val', 1)->where('rate', '>=', $min_rate)->where('rate', '<=', $max_rate)->where('origin', 'LIKE', $from)->where('destination', 'LIKE', $to)->where('days', 'LIKE', $days)->paginate(9); return View::make('transport.transport_list')->with(array('transport_packages' => $transport_packages, 'min_trans_rate' => $min_trans_rate, 'max_trans_rate' => $max_trans_rate, 'vehicle' => $vehicle, 'city' => $city, 'vehicles' => $vehicles, 'st_date' => $st_date, 'ed_date' => $ed_date)); }
//echo number_format(TransportPackage::getPredefinedTripTotal($booking), 2); ?> </td> </tr> <?php } ?> <?php } ?> <?php } ?> <tr style="background: lightgrey"> <th>Total</th> <td align="right"><strong>USD. <?php echo number_format(TransportPackage::getTotalTransportationAmount($booking), 2); ?> </strong></td> </tr> </table>
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'); }
public static function getTotalTransportationAmount($booking) { $total = TransportPackage::getCustomTripTotal($booking) + TransportPackage::getPredefinedTripTotal($booking); return $total; }
. Path (Origin to Destination) : <?php echo City::find($trip->transportPackage->origin)->city; echo City::find($trip->transportPackage->destination)->city; ?> @ <?php echo number_format($trip->transportPackage->rate * $trip->transportPackage->millage, 2); ?> </p> </td> <td align="right"> <?php echo number_format(TransportPackage::getPredefinedTripTotal($booking), 2); ?> </td> </tr> <?php } ?> <?php } ?> <?php } ?> <?php
?> at <?php echo date('H:i', strtotime($trip->from)); ?> . Path (Origin to Destination) : <?php echo $trip->locations; ?> </p> <?php } ?> </td> <td align="right"> <?php echo number_format(TransportPackage::getCustomTripTotal($booking), 2); ?> </td> </tr> <?php } ?> <?php if ($booking->predefinedTrip->count()) { ?> <?php foreach ($booking->predefinedTrip as $trip) { ?>