コード例 #1
0
 public function postReservation()
 {
     $rType = Input::get('rType');
     $cType = Input::get('cType');
     $checkCottage = Input::get('checkCottage');
     $chosenCottages = explode(",", $checkCottage);
     $kid = Input::get('kid');
     $adult = Input::get('adult');
     $email = Input::get('email');
     $date = date('Y-m-d', strtotime(Input::get('date')));
     $time = date('H:i', strtotime(Input::get('time')));
     $chosenDay = Input::get('chosenDay');
     $package = Input::get('roomPackage');
     $room = Input::get('room');
     if ($rType == 1) {
         if (empty($cType) || empty($checkCottage) || empty($adult)) {
             return View::make('index')->with('mt', "HOME")->with('alert', 'fail')->with('msg', 'failed to reserve cottage please fill all the required fields. Please choose cottage type, cottage and atleast 1 adult.');
         }
     }
     if ($rType == 2) {
         if (empty($room) || empty($package) || empty($time)) {
             return View::make('index')->with('mt', "HOME")->with('alert', 'fail')->with('msg', 'failed to reserve room fill all the required fields. Please choose time, room and room package ');
         }
     }
     if (empty($email)) {
         $email = Input::get('emailRes');
         $userInfo = UserInfo::where('email', '=', str_replace(' ', '', $email))->first();
     } else {
         $userInfo = UserInfo::where('user_id', '=', Auth::User()['id'])->first();
     }
     $season = Input::get('seasoncode');
     // 1: regular 2:week and holidays 3: summer (mar,apr,may)
     $addPerson = Input::get('addPerson');
     $addBed = Input::get('addBed');
     $addLinen = Input::get('addLinen');
     $addTowel = Input::get('addTowel');
     $addPillow = Input::get('addPillow');
     $totalAdd = 0;
     if (!empty($addPerson)) {
         $totalAdd = $totalAdd + $addPerson * (int) AdditionalPrice::where('additional', '=', 'AdditionalPerson')->first()['price'];
     }
     if (!empty($addBed)) {
         $totalAdd = $totalAdd + $addBed * (int) AdditionalPrice::where('additional', '=', 'ExtraBed')->first()['price'];
     }
     if (!empty($addLinen)) {
         $totalAdd = $totalAdd + $addLinen * (int) AdditionalPrice::where('additional', '=', 'ExtraLinen')->first()['price'];
     }
     if (!empty($addTowel)) {
         $totalAdd = $totalAdd + $addTowel * (int) AdditionalPrice::where('additional', '=', 'ExtraTowel')->first()['price'];
     }
     if (!empty($addPillow)) {
         $totalAdd = $totalAdd + $addPillow * (int) AdditionalPrice::where('additional', '=', 'ExtraPillow')->first()['price'];
     }
     $getcountcheck = count(explode(",", $checkCottage)) - 1;
     $cottageType = CottageType::where('Cottage_ID', '=', $cType)->first();
     $price = (int) $cottageType['price'];
     if ($chosenDay == "1") {
         if ($season == "1") {
             $priceAdult = PricingSwimming::where('day', '=', 'Morning')->where('desc_a', '=', 'Adult')->first();
             $priceKid = PricingSwimming::where('day', '=', 'Morning')->where('desc_a', '=', 'Kids')->first();
         } elseif ($season == "2") {
             $priceAdult = PricingSwimming::where('day', '=', 'Weekend And Holiday Morning')->where('desc_a', '=', 'Adult')->first();
             $priceKid = PricingSwimming::where('day', '=', 'Weekend And Holiday Morning')->where('desc_a', '=', 'Kids')->first();
         } else {
             $priceAdult = PricingSwimming::where('day', '=', 'Summer Morning')->where('desc_a', '=', 'Adult')->first();
             $priceKid = PricingSwimming::where('day', '=', 'Summer Morning')->where('desc_a', '=', 'Kids')->first();
         }
     } else {
         if ($season == "1") {
             $priceAdult = PricingSwimming::where('day', '=', 'Overnight')->where('desc_a', '=', 'Adult')->first();
             $priceKid = PricingSwimming::where('day', '=', 'Overnight')->where('desc_a', '=', 'Kids')->first();
         } elseif ($season == "2") {
             $priceAdult = PricingSwimming::where('day', '=', 'Weekend And Holiday Overnight')->where('desc_a', '=', 'Adult')->first();
             $priceKid = PricingSwimming::where('day', '=', 'Weekend And Holiday Overnight')->where('desc_a', '=', 'Kids')->first();
         } else {
             $priceAdult = PricingSwimming::where('day', '=', 'Summer Overnight')->where('desc_a', '=', 'Adult')->first();
             $priceKid = PricingSwimming::where('day', '=', 'Summer Overnight')->where('desc_a', '=', 'Kids')->first();
         }
     }
     if (!empty($priceAdult) && !empty($priceKid)) {
         $cottageprice = $getcountcheck * $price;
         $kidprice = $kid * (int) $priceKid['price'];
         $adultprice = $adult * (int) $priceAdult['price'];
         $total = $cottageprice + $kidprice + $adultprice;
     }
     if (!empty($package)) {
         $total = (int) RoomPackage::where('packid', '=', $package)->first()['Price'] + $totalAdd;
     }
     $getReservation = new CottageReservation();
     $getReservation['user_id'] = $userInfo['user_id'];
     $getReservation['reservation_type'] = $rType;
     $getReservation['cottage_type'] = $cType;
     $getReservation['cottagelist_id'] = $checkCottage;
     $getReservation['day_type'] = $chosenDay;
     $getReservation['reservation_date'] = $date;
     $getReservation['room_id'] = $room;
     $getReservation['package_id'] = $package;
     $getReservation['check_in_datetime'] = $time;
     $getReservation['check_out_datetime'] = "";
     $getReservation['num_adult'] = $adult;
     $getReservation['num_kid'] = $kid;
     $getReservation['status'] = "Pending";
     $getReservation['total_amount'] = $total;
     $getReservation['season'] = $season;
     if (!$getReservation->save()) {
         return Redirect::route('home');
     } else {
         if ($rType == 1) {
             if (!empty($priceAdult)) {
                 $this->postCharges($getReservation['id'], $rType, "Swimming_Entrance", $priceAdult['idp'], $adult);
             }
             if (!empty($priceKid)) {
                 $this->postCharges($getReservation['id'], $rType, "Swimming_Entrance", $priceKid['idp'], $kid);
             }
             if (!empty($checkCottage)) {
                 $this->postCharges($getReservation['id'], $rType, "Cottages", $checkCottage, count($chosenCottages) - 1);
             }
         } else {
             if (!empty($addPerson)) {
                 //$totalAdd = $totalAdd + ($addPerson * (int)AdditionalPrice::where('additional','=','AdditionalPerson')->first()['price']);
                 $this->postCharges($getReservation['id'], $rType, "Additional_room", AdditionalPrice::where('additional', '=', 'AdditionalPerson')->first()['aid'], $addPerson);
             }
             if (!empty($addBed)) {
                 //$totalAdd = $totalAdd + ($addBed * (int)AdditionalPrice::where('additional','=','ExtraBed')->first()['price']);
                 $this->postCharges($getReservation['id'], $rType, "Additional_room", AdditionalPrice::where('additional', '=', 'ExtraBed')->first()['aid'], $addBed);
             }
             if (!empty($addLinen)) {
                 //$totalAdd = $totalAdd + ($addLinen * (int)AdditionalPrice::where('additional','=','ExtraLinen')->first()['price']);
                 $this->postCharges($getReservation['id'], $rType, "Additional_room", AdditionalPrice::where('additional', '=', 'ExtraLinen')->first()['aid'], $addLinen);
             }
             if (!empty($addTowel)) {
                 //$totalAdd = $totalAdd + ($addTowel * (int)AdditionalPrice::where('additional','=','ExtraTowel')->first()['price']);
                 $this->postCharges($getReservation['id'], $rType, "Additional_room", AdditionalPrice::where('additional', '=', 'ExtraTowel')->first()['aid'], $addTowel);
             }
             if (!empty($addPillow)) {
                 //$totalAdd = $totalAdd + ($addPillow * (int)AdditionalPrice::where('additional','=','ExtraPillow')->first()['price']);
                 $this->postCharges($getReservation['id'], $rType, "Additional_room", AdditionalPrice::where('additional', '=', 'ExtraPillow')->first()['aid'], $addPillow);
             }
             if (!empty($package)) {
                 //$totalAdd = $totalAdd + ($addPillow * (int)AdditionalPrice::where('additional','=','ExtraPillow')->first()['price']);
                 $this->postCharges($getReservation['id'], $rType, "Package_room", (int) RoomPackage::where('packid', '=', $package)->first()['packid'], 1);
             }
         }
         $emailcontent = array('fname' => $userInfo['firstname'], 'lname' => $userInfo['lastname'], 'link' => URL::route('getReservation_step2', $getReservation['id']));
         Mail::send('emails.confirmation.reservation', $emailcontent, function ($message) {
             $email = Input::get('email');
             if (empty($email)) {
                 $email = Input::get('emailRes');
             }
             $message->to($email, 'Kalugdan Garden Resort')->subject('Kalugdan Garden Resort Confirmation Email');
         });
         return Redirect::route('getReservation_step2', $getReservation['id'])->with('id', $getReservation['id'])->with('mt', "HOME")->with('id', $getReservation['id'])->with('alert', 'success')->with('msg', 'You have successfully reserve.');
         //return View::make('reservation.reservation_step2')->with('mt', "HOME")->with('id',$getReservation['id'])->with('alert', 'success')->with('msg', 'You have successfully reserve.');
     }
 }
コード例 #2
0
        $priceAdult = PricingSwimming::where('day', '=', 'Weekend And Holiday Overnight')->where('desc_a', '=', 'Adult')->first();
        $priceKid = PricingSwimming::where('day', '=', 'Weekend And Holiday Overnight')->where('desc_a', '=', 'Kids')->first();
    } else {
        $priceAdult = PricingSwimming::where('day', '=', 'Summer Overnight')->where('desc_a', '=', 'Adult')->first();
        $priceKid = PricingSwimming::where('day', '=', 'Summer Overnight')->where('desc_a', '=', 'Kids')->first();
    }
}
$room = RoomPackage::where('packid', '=', $reservation['package_id'])->first();
$cottageprice = $getcountcheck * $price;
$kidprice = $reservation['num_kid'] * (int) $priceKid['price'];
$adultprice = $reservation['num_adult'] * (int) $priceAdult['price'];
$addtotal = 0;
$charges = Charges::where('transaction_id', '=', $reservation['id'])->where('reservation_type', '=', $reservation['reservation_type'])->where('product_type', '=', "Additional_room")->get();
if (!empty($charges)) {
    foreach ($charges as $charge) {
        $AdditionalPrice = AdditionalPrice::where('aid', '=', $charge['product_id'])->first();
        $addtotal = $addtotal + $AdditionalPrice['price'] * $charge['qty'];
    }
}
?>
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <div class="step_tabs text-uppercase">
       <h3>Reservation</h3>
      </div>
      <div class="create_event">
        <form id="eventPart1" method="post" action="{{URL::Route('postReservation')}}" enctype="multipart/form-data">
          <h1 class="text-uppercase nmt" style="margin-bottom:6px;font-weight:600;">Hi {{$userInfo['firstname']}} </h1>
          <span>This is your total computation for your reservation.</span><br>
          <span>Status:{{$reservation['status']}}<span>