/**
  * Store a newly created voucher in storage.
  *
  * @return Response
  */
 public function store($booking_id)
 {
     $bookings = Session::pull('rate_box_details');
     $vouchers = Voucher::arrangeHotelBookingsVoucherwise($bookings, $booking_id);
     foreach ($vouchers as $voucher) {
         $create_voucher = Voucher::create($voucher);
         for ($c = 0; $c < count($voucher) - 6; $c++) {
             $voucher[$c]['voucher_id'] = $create_voucher->id;
             $voucher[$c]['amount'] = $voucher[$c]['room_cost'];
             RoomBooking::create($voucher[$c]);
         }
     }
     Session::forget('add_new_voucher');
     //        Booking::where('id', $booking_id)->update('user_id', Auth::user()->id);
     //		$validator = Validator::make($data = Input::all(), Voucher::$rules);
     //
     //		if ($validator->fails())
     //		{
     //			return Redirect::back()->withErrors($validator)->withInput();
     //		}
     //
     //		Voucher::create($data);
     return Redirect::route('bookings.show', [$booking_id]);
 }
 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');
 }
示例#3
0
function modBooking()
{
    require_once $GLOBALS['where_scs'] . '/lib/lib.booking.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    YuiLib::load(array('selector' => 'selector-beta-min.js'));
    $lang =& DoceboLanguage::createInstance('conference', 'lms');
    $room_id = Get::req('id', DOTY_INT, 0);
    $booking = new RoomBooking();
    $acl_man =& Docebo::user()->getAclManager();
    $user_booked = $booking->getRoomSubscriptions($room_id);
    if (isset($_POST['confirm'])) {
        foreach ($user_booked as $user) {
            $booking->setApproved($user['idUser'], $room_id, isset($_POST['user_' . $user['idUser']]) ? 1 : 0);
            Util::jump_to('index.php?modname=conference&op=list');
        }
    } else {
        cout(getTitleArea($lang->def('_MOD_BOOKING_TITLE')) . '<div class="std_block">');
        $conference = new Conference_Manager();
        $tb = new Table(0, $lang->def('_USER_BOOKED'), $lang->def('_USER_BOOKED'));
        $cont_h = array($lang->def('_FULLNAME'), $lang->def('_BOOKING_DATE'), '');
        $type_h = array('', 'align_center', 'align_center');
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        $user_selected = 0;
        $max_user_selectable = $conference->getRoomMaxParticipants($room_id);
        $array_unchecked = array();
        cout(Form::openForm('user_booking_form', 'index.php?modname=conference&amp;op=modbooking&amp;id=' . $room_id));
        foreach ($user_booked as $user) {
            $user_info = $acl_man->getUser($user['idUser'], false);
            $cont = array();
            if ($user_info[ACL_INFO_FIRSTNAME] !== '' && $user_info[ACL_INFO_LASTNAME]) {
                $cont[] = $user_info[ACL_INFO_FIRSTNAME] . ' ' . $user_info[ACL_INFO_LASTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
            } elseif ($user_info[ACL_INFO_FIRSTNAME] !== '') {
                $cont[] = $user_info[ACL_INFO_FIRSTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
            } elseif ($user_info[ACL_INFO_LASTNAME] !== '') {
                $cont[] = $user_info[ACL_INFO_LASTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
            } else {
                $cont[] = $acl_man->relativeId($user_info[ACL_INFO_USERID]);
            }
            $cont[] = Format::date($user['date'], 'datetime');
            $cont[] = '<div class="form_line_l"><input class="check" type="checkbox" id="user_' . $user['idUser'] . '" name="user_' . $user['idUser'] . '" value="1" ' . ($user['valid'] ? 'checked="checked"' : '') . '/></div>';
            if ($user['valid']) {
                $user_selected++;
            } else {
                $array_unchecked[] = 'user_' . $user['idUser'];
            }
            $tb->addBody($cont);
        }
        reset($user_booked);
        addJs($GLOBALS['where_lms_relative'] . '/modules/conference/', 'conference.js');
        cout('<script>' . "\n" . 'var num_checked = ' . $user_selected . ';' . "\n" . 'var max_checked =' . $max_user_selectable . ';' . "\n");
        cout('unchecked = new Array(');
        $first = true;
        foreach ($array_unchecked as $unchecked) {
            if ($first) {
                cout('"' . $unchecked . '"');
                $first = false;
            } else {
                cout(',"' . $unchecked . '"');
            }
        }
        cout(');' . "\n");
        cout('</script>' . "\n" . $tb->getTable() . Form::openButtonSpace() . Form::getButton('confirm', 'confirm', $lang->def('_CONFIRM')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm());
        foreach ($user_booked as $user) {
            cout('<script>YAHOO.util.Event.addListener("user_' . $user['idUser'] . '", "click", onClick);</script>');
        }
        cout('<script>controlChecked();</script>');
        cout('</div>');
    }
}
 /**
  * Remove the specified roombooking from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     RoomBooking::destroy($id);
     return Redirect::route('roombookings.index');
 }