Ejemplo n.º 1
0
 public function getHotelCancellationPeriods($hotel_id)
 {
     $cancellation = CancellationPolicy::where('hotel_id', $hotel_id)->get();
     return !empty($cancellation) ? $cancellation : false;
 }
 /**
  * Remove the specified cancelationpolicy from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($hotel_id, $id)
 {
     Session::put('manage', 'policies');
     CancellationPolicy::destroy($id);
     return Redirect::route('control-panel.hotel.hotels.edit', $hotel_id);
 }
Ejemplo n.º 3
0
 public function cancelVoucher($voucherid)
 {
     $percentage_charged = 0;
     $voucher = Voucher::findOrFail($voucherid);
     $daysToBooking = Voucher::getDaysToBooking($voucher)->days;
     $cancellation_policies = CancellationPolicy::where('hotel_id', $voucher->hotel_id)->get();
     foreach ($cancellation_policies as $policy) {
         if ($daysToBooking >= $policy->from && $daysToBooking <= $policy->to) {
             $percentage_charged = $policy->percentage_charged;
             break;
         } else {
             if (empty($policy->to)) {
                 $percentage_charged = $policy->percentage_charged;
                 break;
             }
         }
     }
     $bookingAmount = Voucher::getVoucherAmount($voucher);
     $cancellation_amount = $bookingAmount * $percentage_charged * 0.01;
     $voucher->val = 0;
     $voucher->cancellation_amount = $cancellation_amount;
     $voucher->save();
     $agent_user = $voucher->booking->user;
     $pdf = PDF::loadView('emails/cancellation-voucher', array('voucher' => $voucher));
     $pdf->save(public_path() . '/temp-files/cancellation-voucher.pdf');
     $hotel = Hotel::findOrFail($voucher->hotel_id);
     $hotel_users = $hotel->user;
     Mail::send('emails/cancellation-voucher-mail', array('voucher' => $voucher), function ($message) use($voucher, $agent_user, $hotel_users) {
         $message->attach(public_path() . '/temp-files/cancellation-voucher.pdf')->subject('Cancellation Voucher :' . $voucher->reference_number)->from('*****@*****.**');
         if (!empty($hotel_users)) {
             foreach ($hotel_users as $hotel_user) {
                 $message->to($hotel_user->email, $hotel_user->first_name);
             }
         }
         if (!empty($agent_user)) {
             $message->to($agent_user->email, $agent_user->first_name);
         }
     });
     Booking::getTotalBookingAmount($voucher->booking);
     return Redirect::back();
 }