$this->load->helper('text'); $refer = $this->db->query("select * from `referral_management` where `id`=1 ")->row(); //$data['fixed_status']=$refer->fixed_status; $refamt = $refer->fixed_amt; $refcur = $refer->currency; $type = $refer->type; $trip_amt = $refer->trip_amt; $trip_per = $refer->trip_per; $rent_amt = $refer->rent_amt; $rent_per = $refer->rent_per; $ref_total = get_currency_value_lys1($refcur, 'USD', $refamt); if ($type == 1) { $trip_amt0 = $trip_amt; $rent_amt0 = $rent_amt; $trip = get_currency_value_lys1($refcur, 'USD', $trip_amt); $rent = get_currency_value_lys1($refcur, 'USD', $trip_amt); } if ($type == 0) { $trip = $trip_per / 100 * $ref_total; $rent = $rent_per / 100 * $ref_total; } $current = $this->session->userdata("locale_currency"); if ($current == '') { $current_code = $this->Common_model->getTableData('currency', array('default' => 1))->row()->currency_code; } else { $current_code = $current; } ?> <div id="dashboard_container" class="clearfix"> <div id="dashboard_left" class="col-md-3 col-sm-3 col-xs-12 padding-zero">
function form() { $id = $this->input->get('id'); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $data['guests'] = $this->input->get('guest'); $user_id = $this->input->get('user_id'); $currency = $this->input->get('currency'); $this->session->set_userdata('locale_currency', $currency); $param = $id; $data['checkin'] = $checkin; $data['checkout'] = $checkout; $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); $pay = $this->Common_model->getTableData('paywhom', array('id' => 1)); $paywhom = $pay->result(); $paywhom = $paywhom[0]->whom; $id = $param; if ($ckin[0] == "mm") { //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Sorry! Access denied.')); redirect('rooms/' . $id, "refresh"); } if ($ckout[0] == "mm") { // $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Sorry! Access denied.')); redirect('rooms/' . $id, "refresh"); } $xprice = $this->Common_model->getTableData('price', array('id' => $param))->row(); /* if($this->input->get()) { $price = $this->input->get('subtotal'); } else {*/ $price = $xprice->night; //} $placeid = $xprice->id; $guests = $xprice->guests; if (isset($xprice->cleaning)) { $cleaning = $xprice->cleaning; } else { $cleaning = 0; } if (isset($xprice->security)) { $security = $xprice->security; } else { $security = 0; } $data['cleaning'] = $cleaning; $data['security'] = $security; if (isset($xprice->week)) { $Wprice = $xprice->week; } else { $Wprice = 0; } if (isset($xprice->month)) { $Mprice = $xprice->month; } else { $Mprice = 0; } if ($paywhom) { $query = $this->Common_model->getTableData('list', array('id' => $id))->row(); $email = $query->email; } else { $query = $this->Common_model->getTableData('users', array('role_id' => 2))->row(); $email = $query->email; } $query = $this->Common_model->getTableData('list', array('id' => $id)); $list = $query->row(); $data['address'] = $list->address; $data['room_type'] = $list->room_type; $data['total_guests'] = $list->capacity; $data['tit'] = $list->title; $data['manual'] = $list->house_rule; $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]); $days = ceil($diff / (3600 * 24)); /*$amt = $price * $days * $data['guests'];*/ if ($data['guests'] > $guests) { $diff_days = $data['guests'] - $guests; $amt = get_currency_value1($id, $price) * $days + $days * get_currency_value1($id, $xprice->addguests) * $diff_days; $data['extra_guest_price'] = get_currency_value1($id, $xprice->addguests) * $diff_days; } else { $amt = get_currency_value1($id, $price) * $days; } //Entering it into data variables $data['id'] = $id; $data['price'] = $xprice->night; $data['days'] = $days; $data['full_cretids'] = 'off'; $data['commission'] = 0; if ($days >= 7 && $days < 30) { if (!empty($Wprice)) { $finalAmount = $Wprice; $differNights = $days - 7; $perDay = $Wprice / 7; $per_night = $price = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Wprice + $addAmount; } $amt = $finalAmount; } } else { $finalAmount = $amt; } if ($days >= 30) { if (!empty($Mprice)) { $finalAmount = $Mprice; $differNights = $days - 30; $perDay = $Mprice / 30; $per_night = $price = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Mprice + $addAmount; } $amt = $finalAmount; } } else { $finalAmount = $amt; } //Update the daily price $data['price'] = $xprice->night; //Cleaning fee if ($cleaning != 0) { $amt = $amt + get_currency_value1($id, $cleaning); } if ($security != 0) { $amt = $amt + get_currency_value1($id, $security); } else { $amt = $amt; } $session_coupon = $this->session->userdata("coupon"); if ($this->input->get('contact')) { $amt = get_currency_value_lys($contact_result->currency, get_currency_code(), $contact_result->price); $this->session->set_userdata("total_price_'" . $id . "'_'" . $this->dx_auth->get_user_id() . "'", $amt); } else { //$amt=$this->session->userdata("total_price_'".$id."'_'".$this->dx_auth->get_user_id()."'"); } $this->session->set_userdata("total_price_'" . $id . "'_'" . $this->dx_auth->get_user_id() . "'", $amt); $this->session->unset_userdata('coupon_code_used'); //Coupon Starts if ($this->input->post('apply_coupon')) { $is_coupon = 0; //Get All coupons $query = $this->Common_model->get_coupon(); $row = $query->result_array(); $list_id = $this->input->post('hosting_id'); $coupon_code = $this->input->post('coupon_code'); $user_id = $this->dx_auth->get_user_id(); if ($coupon_code != "") { $is_list_already = $this->Common_model->getTableData('coupon_users', array('list_id' => $list_id, 'user_id' => $user_id)); $is_coupon_already = $this->Common_model->getTableData('coupon_users', array('used_coupon_code' => $coupon_code, 'user_id' => $user_id, 'status' => 0)); //Check the list is already access with the coupon by the host or not /*if($is_list_already->num_rows() != 0) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Sorry! You cannot use coupons for this list')); redirect('rooms/'.$list_id, "refresh"); } //Check the host already used the coupon or not else*/ if ($is_coupon_already->num_rows() != 0) { $this->session->unset_userdata('coupon_code_used'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon is invalid'))); redirect('rooms/' . $list_id, "refresh"); } else { //Coupon Discount calculation foreach ($row as $code) { if ($coupon_code == $code['couponcode']) { //Currecy coversion $is_coupon = 1; $current_currency = get_currency_code(); $coupon_currency = $code['currency']; //if($current_currency == $coupon_currency) $Coupon_amt = $code['coupon_price']; //else //$Coupon_amt = get_currency_value_coupon($code['coupon_price'],$coupon_currency); } } if ($is_coupon == 1) { //echo $Coupon_amt.'<br>'; $list_currency = $this->db->where('id', $list_id)->get('list')->row()->currency; //if($coupon_currency != $list_currency) $Coupon_amt = get_currency_value_lys1($coupon_currency, get_currency_code(), $Coupon_amt); //echo $Coupon_amt.'<br>';exit; //echo $amt.'<br>'; if ($Coupon_amt >= $amt) { $this->session->unset_userdata('coupon_code_used'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! There is equal money or more money in your coupon to book this list.'))); redirect('rooms/' . $list_id, "refresh"); } else { //Get the result amount & store the coupon informations //echo $Coupon_amt;exit; $amt = $amt - $Coupon_amt; //echo $amt;exit; $insertData = array('list_id' => $list_id, 'used_coupon_code' => $coupon_code, 'user_id' => $user_id, 'status' => 0); //echo $Coupon_amt.' - '.$amt;exit; //echo get_currency_value1($list_id,$amt);exit; if ($amt < 1) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your payment should be greater than 0.'))); redirect('rooms/' . $id, "refresh"); } $this->Common_model->inserTableData('coupon_users', $insertData); $this->db->where('couponcode', $coupon_code)->update('coupon', array('status' => 1)); $this->session->set_userdata("total_price_'" . $list_id . "'_'" . $user_id . "'", $amt); $this->session->set_userdata('coupon_code_used', 1); $this->session->set_userdata('coupon_code', $coupon_code); } } else { $this->session->unset_userdata('coupon_code_used'); $this->session->unset_userdata('coupon_code'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon does not match.'))); redirect('rooms/' . $list_id, "refresh"); } } } else { $this->session->unset_userdata('coupon_code_used'); $this->session->unset_userdata('coupon_code'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon does not match.'))); redirect('rooms/' . $list_id, "refresh"); } } else { $this->session->unset_userdata('coupon_code_used'); $this->session->unset_userdata('coupon_code'); } //Coupon Ends $data['subtotal'] = $amt; //if($this->session->userdata("total_price_'".$id."'_'".$this->dx_auth->get_user_id()."'") == "") //{ echo 'total';exit; //redirect('rooms/'.$param, "refresh"); // $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Please! Try Again')); //} //check admin premium condition and apply so for $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $amt + get_currency_value_lys($row->currency, get_currency_code(), $fix); $data['commission'] = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $per = $row->percentage_amount; $camt = floatval($finalAmount * $per / 100); $amt = $amt + $camt; $data['commission'] = $camt; } } else { $amt = $amt; } // Coupon Code Starts if ($amt > 110) { if ($this->db->select('referral_amount')->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount != 0) { $data['amt'] = $amt; $data['referral_amount'] = $this->db->select('referral_amount')->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount; } else { $data['amt'] = $amt; } } else { $data['amt'] = $amt; } if ($amt < 0) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your payment should be greater than 0.'))); redirect('rooms/' . $id, "refresh"); } if ($amt < 10) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your payment should be greater than or equal to 10.'))); redirect('rooms/' . $id, "refresh"); } $data['result'] = $this->Common_model->getTableData('payments')->result(); $array_items = array('list_id' => '', 'Lcheckin' => '', 'Lcheckout' => '', 'number_of_guests' => '', 'formCheckout' => ''); $this->session->unset_userdata($array_items); //$id = $list_id; $checkin_time = get_gmt_time(strtotime($checkin)); $checkout_time = get_gmt_time(strtotime($checkout)); $travel_dates = array(); $seasonal_prices = array(); $total_nights = 1; $total_price = 0; $is_seasonal = 0; $i = $checkin_time; while ($i < $checkout_time) { $checkin_date = date('m/d/Y', $i); $checkin_date = explode('/', $checkin_date); $travel_dates[$total_nights] = $checkin_date[1] . $checkin_date[0] . $checkin_date[2]; $i = get_gmt_time(strtotime('+1 day', $i)); $total_nights++; } for ($i = 1; $i < $total_nights; $i++) { $seasonal_prices[$travel_dates[$i]] = ""; } //Store seasonal price of a list in an array $seasonal_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id)); $seasonal_result = $seasonal_query->result_array(); if ($seasonal_query->num_rows() > 0) { foreach ($seasonal_result as $time) { //Get Seasonal price $seasonalprice_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id, 'start_date' => $time['start_date'], 'end_date' => $time['end_date'])); $seasonalprice = $seasonalprice_query->row()->price; //Days between start date and end date -> seasonal price $start_time = $time['start_date']; $end_time = $time['end_date']; $i = $start_time; while ($i <= $end_time) { $start_date = date('m/d/Y', $i); $s_date = explode('/', $start_date); $s_date = $s_date[1] . $s_date[0] . $s_date[2]; $seasonal_prices[$s_date] = $seasonalprice; $i = get_gmt_time(strtotime('+1 day', $i)); } } //Total Price for ($i = 1; $i < $total_nights; $i++) { if ($seasonal_prices[$travel_dates[$i]] == "") { $xprice = $this->Common_model->getTableData('price', array('id' => $id))->row(); $total_price = get_currency_value1($id, $total_price) + get_currency_value1($id, $xprice->night); } else { $total_price = get_currency_value1($id, $total_price) + $seasonal_prices[$travel_dates[$i]]; $is_seasonal = 1; } } //Additional Guests if ($data['guests'] > $guests) { $days = $total_nights - 1; $diff_guests = $data['guests'] - $guests; $total_price = get_currency_value1($id, $total_price) + $days * get_currency_value1($id, $xprice->addguests) * $diff_guests; $data['extra_guest_price'] = get_currency_value1($id, $xprice->addguests) * $diff_guests; } //Cleaning if ($cleaning != 0) { $total_price = $total_price + get_currency_value1($id, $cleaning); } if ($security != 0) { $total_price = $total_price + get_currency_value1($id, $security); } //Admin Commission //$data['commission'] = 0; } if ($is_seasonal == 1) { //Total days $days = $total_nights; //Final price $data['subtotal'] = $total_price; $data['avg_price'] = $total_price / ($days - 1); //echo $data['avg_price'];exit; $amt = $data['subtotal']; $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $amt + get_currency_value_lys($row->currency, get_currency_code(), $fix); $data['commission'] = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $per = $row->percentage_amount; $camt = floatval($finalAmount * $per / 100); $amt = $amt + $camt; $data['commission'] = $camt; } } else { $amt = $amt; } $data['amt'] = $amt; $this->session->set_userdata('topay', $amt); } $data['env'] = 'mobile'; $this->session->set_userdata('mobile_user_id', $user_id); $data['result'] = $this->Common_model->getTableData('payments')->result(); $data['countries'] = $this->Common_model->getCountries()->result(); $data['title'] = get_meta_details('Confirm_your_booking', 'title'); $data["meta_keyword"] = 'mobile'; $data["meta_description"] = get_meta_details('Confirm_your_booking', 'meta_description'); $data['message_element'] = "payments/view_booking"; $this->load->view('template', $data); }
function form($param = '') { $refer = $this->db->query("select * from `referral_management` where `id`=1 ")->row(); //$data['fixed_status']=$refer->fixed_status; $refamt = $refer->fixed_amt; $refcur = $refer->currency; $type = $refer->type; $trip_amt = $refer->trip_amt; $trip_per = $refer->trip_per; $rent_amt = $refer->rent_amt; $rent_per = $refer->rent_per; $ref_total = get_currency_value2($refcur, 'USD', $refamt); if ($type == 1) { $trip_amt0 = $trip_amt; $rent_amt0 = $rent_amt; $trip = get_currency_value2($refcur, 'USD', $trip_amt); $rent = get_currency_value2($refcur, 'USD', $rent_amt); } if ($type == 0) { $trip = $trip_per / 100 * $ref_total; $rent = $rent_per / 100 * $ref_total; $current = $this->session->userdata("locale_currency"); } $check_paypal = $this->db->where('is_enabled', 1)->get('payments')->num_rows(); if ($check_paypal == 0) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate("Payment gateway is not enabled. Please contact admin."))); redirect('rooms/' . $param); } if ($this->input->get('contact')) { $contact_key = $this->input->get('contact'); $contact_result = $this->Common_model->getTableData('contacts', array('contact_key' => $contact_key))->row(); if ($contact_result->status == 10) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Access denied.'))); redirect('rooms/' . $param, "refresh"); } if ($contact_result->userby != $this->dx_auth->get_user_id()) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('You are not a valid user to use this link.'))); redirect('rooms/' . $param, "refresh"); } $checkin = $contact_result->checkin; $checkout = $contact_result->checkout; $daysexist = $this->db->query("SELECT id,list_id,booked_days FROM `calendar` WHERE `list_id` = '" . $param . "' AND (`booked_days` >= '" . get_gmt_time(strtotime($checkin)) . "' AND `booked_days` <= '" . get_gmt_time(strtotime($checkout)) . "') GROUP BY `list_id`"); if ($daysexist->num_rows() == 1) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Already Those dates are booked'))); redirect('rooms/' . $param, "refresh"); } $data['guests'] = $contact_result->no_quest; $data['contact_key'] = $contact_result->contact_key; $data['offer'] = $contact_result->offer; } else { if ($this->session->userdata('formCheckout')) { $checkin = $this->session->userdata('Lcheckin'); $checkout = $this->session->userdata('Lcheckout'); $data['guests'] = $this->session->userdata('number_of_guests'); } else { if ($this->input->get()) { $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $data['guests'] = $this->input->get('guest'); } else { $checkin = $this->input->post('checkin'); $checkout = $this->input->post('checkout'); $data['guests'] = $this->input->post('number_of_guests'); } } } $data['checkin'] = $checkin; $data['checkout'] = $checkout; $date1 = new DateTime(date('Y-m-d H:i:s', strtotime($checkin))); $date2 = new DateTime(date('Y-m-d H:i:s', strtotime($checkout))); $interval = $date1->diff($date2); if ($interval->days >= 28) { $data['flash_message'] = "Your reservation is 28 or more days. So, the cacellation policy will be changed to Long Term."; } $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); $id = $param; if ($ckin[0] == "mm") { //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Sorry! Access denied.')); redirect('rooms/' . $id, "refresh"); } if ($ckout[0] == "mm") { // $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Sorry! Access denied.')); redirect('rooms/' . $id, "refresh"); } $xprice = $this->Common_model->getTableData('price', array('id' => $param))->row(); // print_r($xprice); /* if($this->input->get()) { $price = $this->input->get('subtotal'); } else {*/ $price = $xprice->night; // print_r($price); //} $placeid = $xprice->id; $guests = $xprice->guests; if (isset($xprice->cleaning)) { $cleaning = $xprice->cleaning; } else { $cleaning = 0; } if (isset($xprice->security)) { $security = $xprice->security; } else { $security = 0; } $data['cleaning'] = $cleaning; //print_r($data); $data['security'] = $security; //print_r($data); if (isset($xprice->week)) { $Wprice = $xprice->week; } else { $Wprice = 0; } if (isset($xprice->month)) { $Mprice = $xprice->month; } else { $Mprice = 0; } $query = $this->Common_model->getTableData('list', array('id' => $id)); $list = $query->row(); $data['address'] = $list->address; $data['room_type'] = $list->room_type; $data['total_guests'] = $list->capacity; $data['tit'] = $list->title; $data['manual'] = $list->house_rule; $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]); $days = ceil($diff / (3600 * 24)); /*$amt = $price * $days * $data['guests'];*/ if ($data['guests'] > $guests) { $diff_days = $data['guests'] - $guests; $amt = get_currency_value1($id, $price) * $days + $days * get_currency_value1($id, $xprice->addguests) * $diff_days; $data['extra_guest_price'] = get_currency_value1($id, $xprice->addguests) * $diff_days; } else { $amt = get_currency_value1($id, $price) * $days; } //Entering it into data variables $data['id'] = $id; $data['price'] = $xprice->night; //exit; $data['days'] = $days; $data['full_cretids'] = 'off'; $data['commission'] = 0; if ($days >= 7 && $days < 30) { if (!empty($Wprice)) { $finalAmount = $Wprice; $differNights = $days - 7; $perDay = $Wprice / 7; $per_night = $price = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Wprice + $addAmount; } $amt = $finalAmount; } } else { $finalAmount = $amt; } if ($days >= 30) { if (!empty($Mprice)) { $finalAmount = $Mprice; $differNights = $days - 30; $perDay = $Mprice / 30; $per_night = $price = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Mprice + $addAmount; } $amt = $finalAmount; } } else { $finalAmount = $amt; } //Update the daily price $data['price'] = $xprice->night; //Cleaning fee if ($cleaning != 0) { $amt = $amt + get_currency_value1($id, $cleaning); // print_r($amt); } if ($security != 0) { $amt = $amt + get_currency_value1($id, $security); // print_r($amt); } else { $amt = $amt; } $session_coupon = $this->session->userdata("coupon"); if ($this->input->get('contact')) { $amt = get_currency_value_lys($contact_result->currency, get_currency_code(), $contact_result->price); $data['subtotal'] = $amt; $this->session->set_userdata("total_price_'" . $id . "'_'" . $this->dx_auth->get_user_id() . "'", $amt); $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); /*if($row->is_premium == 1) { if($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $amt + get_currency_value_lys($row->currency,get_currency_code(),$fix); $data['commission'] = get_currency_value_lys($row->currency,get_currency_code(),$fix); } else { $per = $row->percentage_amount; $camt = floatval(($amt * $per) / 100); $amt = $amt + $camt; $data['commission'] = round($camt,2); $this->session->set_userdata('contact_commission',$camt); } } else { $amt = $amt; }*/ } else { // $amt=$this->session->userdata("total_price_'".$id."'_'".$this->dx_auth->get_user_id()."'"); } $this->session->set_userdata("total_price_'" . $id . "'_'" . $this->dx_auth->get_user_id() . "'", $amt); $this->session->unset_userdata('coupon_code_used'); //Coupon Starts if ($this->input->post('apply_coupon')) { $is_coupon = 0; //Get All coupons $query = $this->Common_model->get_coupon(); $row = $query->result_array(); $list_id = $this->input->post('hosting_id'); $coupon_code = $this->input->post('coupon_code'); $user_id = $this->dx_auth->get_user_id(); if ($coupon_code != "") { $is_list_already = $this->Common_model->getTableData('coupon_users', array('list_id' => $list_id, 'user_id' => $user_id)); $is_coupon_already = $this->Common_model->getTableData('coupon_users', array('used_coupon_code' => $coupon_code, 'user_id' => $user_id, 'status' => 1)); //Check the list is already access with the coupon by the host or not /*if($is_list_already->num_rows() != 0) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Sorry! You cannot use coupons for this list')); redirect('rooms/'.$list_id, "refresh"); } //Check the host already used the coupon or not else*/ if ($is_coupon_already->num_rows() != 0) { $this->session->unset_userdata('coupon_code_used'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon is invalid'))); redirect('rooms/' . $list_id, "refresh"); } else { //Coupon Discount calculation foreach ($row as $code) { if ($coupon_code == $code['couponcode']) { //Currecy coversion $is_coupon = 1; $current_currency = get_currency_code(); $coupon_currency = $code['currency']; //if($current_currency == $coupon_currency) $Coupon_amt = $code['coupon_price']; //else //$Coupon_amt = get_currency_value_coupon($code['coupon_price'],$coupon_currency); } } if ($is_coupon == 1) { //echo $Coupon_amt.'<br>'; $list_currency = $this->db->where('id', $list_id)->get('list')->row()->currency; //if($coupon_currency != $list_currency) $Coupon_amt = get_currency_value_lys1($coupon_currency, get_currency_code(), $Coupon_amt); //echo $Coupon_amt.'<br>';exit; //echo $amt.'<br>'; if ($Coupon_amt >= $amt) { $this->session->unset_userdata('coupon_code_used'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! There is equal money or more money in your coupon to book this list.'))); redirect('rooms/' . $list_id, "refresh"); } else { //Get the result amount & store the coupon informations //echo $Coupon_amt;exit; $amt = $amt - $Coupon_amt; //echo $Coupon_amt.' - '.$amt; //echo get_currency_value1($list_id,$amt);exit; if ($amt < get_currency_value_lys('USD', get_currency_code(), 1)) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your payment should be greater than 0.'))); redirect('rooms/' . $id, "refresh"); } $insertData = array('list_id' => $list_id, 'used_coupon_code' => $coupon_code, 'user_id' => $user_id, 'status' => 0); $this->Common_model->inserTableData('coupon_users', $insertData); /* $this->db->where('couponcode',$coupon_code)->update('coupon',array('status'=>1));*/ $this->session->set_userdata("total_price_'" . $list_id . "'_'" . $user_id . "'", $amt); $this->session->set_userdata('coupon_code_used', 1); $this->session->set_userdata('coupon_code', $coupon_code); $this->session->set_userdata('coupon_amt', $Coupon_amt); //echo $this->session->userdata("coupon_amt");exit; } } else { $this->session->unset_userdata('coupon_code_used'); $this->session->unset_userdata('coupon_code'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon does not match.'))); redirect('rooms/' . $list_id, "refresh"); } } } else { $this->session->unset_userdata('coupon_code_used'); $this->session->unset_userdata('coupon_code'); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon does not match.'))); redirect('rooms/' . $list_id, "refresh"); } } else { $this->session->unset_userdata('coupon_code_used'); $this->session->unset_userdata('coupon_code'); } //Coupon Ends //echo $amt;exit; if ($is_coupon != 1) { if (!$this->input->get('contact')) { $data['subtotal'] = round($amt, 2); } } else { $data['subtotal'] = round($amt, 2); //echo "$data"; } //if($this->session->userdata("total_price_'".$id."'_'".$this->dx_auth->get_user_id()."'") == "") //{ echo 'total';exit; //redirect('rooms/'.$param, "refresh"); // $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error','Please! Try Again')); //} //check admin premium condition and apply so for $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); //if($is_coupon != 1) //{ //if(!$this->input->get('contact')) //{ if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $amt + get_currency_value_lys($row->currency, get_currency_code(), $fix); $data['commission'] = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $per = $row->percentage_amount; $finalAmount = $finalAmount + $cleaning + $security; $camt = floatval($finalAmount * $per / 100); $amt = $amt + $camt; $data['commission'] = round($camt, 2); } } else { $amt = $amt; } // } // } // Coupon Code Starts $ref_total1 = $ref_total + 10; if ($amt > get_currency_value1($id, $ref_total1)) { if ($this->db->select('referral_amount')->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount != 0) { $data['amt'] = $amt; $data['referral_amount'] = $this->db->select('referral_amount')->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount; } else { $data['amt'] = $amt; } } else { $data['amt'] = $amt; } if ($amt < 0) { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your payment should be greater than 0.'))); redirect('rooms/' . $id, "refresh"); } if ($amt <= get_currency_value_lys('USD', get_currency_code(), 10)) { $validation_amt = get_currency_value1($id, 10); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate("Sorry! Your payment should be greater than or equal to {$validation_amt}."))); redirect('rooms/' . $id, "refresh"); } $data['result'] = $this->Common_model->getTableData('payments')->result(); $array_items = array('list_id' => '', 'Lcheckin' => '', 'Lcheckout' => '', 'number_of_guests' => '', 'formCheckout' => ''); $this->session->unset_userdata($array_items); //$id = $list_id; $checkin_time = get_gmt_time(strtotime($checkin)); $checkout_time = get_gmt_time(strtotime($checkout)); $travel_dates = array(); $seasonal_prices = array(); $total_nights = 1; $total_price = 0; $is_seasonal = 0; $i = $checkin_time; //print_r($i); //exit; while ($i < $checkout_time) { $checkin_date = date('m/d/Y', $i); $checkin_date = explode('/', $checkin_date); $travel_dates[$total_nights] = $checkin_date[1] . $checkin_date[0] . $checkin_date[2]; $i = get_gmt_time(strtotime('+1 day', $i)); $total_nights++; } for ($i = 1; $i < $total_nights; $i++) { $seasonal_prices[$travel_dates[$i]] = ""; } //Store seasonal price of a list in an array // $seasonal_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id)); $seasonal_result = $seasonal_query->result_array(); //print_r($seasonal_result); if ($seasonal_query->num_rows() > 0) { foreach ($seasonal_result as $time) { //Get Seasonal price $seasonalprice_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id, 'start_date' => $time['start_date'], 'end_date' => $time['end_date'])); $seasonalprice = $seasonalprice_query->row()->price; //Days between start date and end date -> seasonal price $start_time = $time['start_date']; $end_time = $time['end_date']; $i = $start_time; //print_r($i); //exit; while ($i <= $end_time) { $start_date = date('m/d/Y', $i); $s_date = explode('/', $start_date); //print_r($s_data); $s_date = $s_date[1] . $s_date[0] . $s_date[2]; $seasonal_prices[$s_date] = $seasonalprice; //print_r($seasonal_prices[$s_date]); $i = get_gmt_time(strtotime('+1 day', $i)); } } //Total Price //print_r($total_nights); for ($i = 1; $i < $total_nights; $i++) { if ($seasonal_prices[$travel_dates[$i]] == "") { $xprice = $this->Common_model->getTableData('price', array('id' => $id))->row(); //print_r($xprice); $total_price = get_currency_value1($id, $total_price) + get_currency_value1($id, $xprice->night); // echo "$total_price"; } else { $total_price = get_currency_value1($id, $total_price) + get_currency_value1($id, $seasonal_prices[$travel_dates[$i]]); //echo "$total_price"; $is_seasonal = 1; } } //Additional Guests if ($data['guests'] > $guests) { $days = $total_nights - 1; $diff_guests = $data['guests'] - $guests; $total_price = get_currency_value1($id, $total_price) + $days * get_currency_value1($id, $xprice->addguests) * $diff_guests; $data['extra_guest_price'] = get_currency_value1($id, $xprice->addguests) * $diff_guests; } // print_r($data['subtotal']); // $data['avg_price'] = $data['subtotal']/$days; //price if ($is_seasonal == 1) { $data['avg_price'] = $data['subtotal'] / ($days + 1); } else { $data['price'] = $xprice->night; } //price //print_r($data['avg_price']); //Cleaning if ($cleaning != 0) { $cleaning_price = get_currency_value1($id, $cleaning); $total_price = $total_price + get_currency_value1($id, $cleaning); } if ($security != 0) { $total_price = $total_price + get_currency_value1($id, $security); } //Admin Commission //$data['commission'] = 0; } if ($is_seasonal == 1) { //Total days $days = $total_nights; //Final price $data['avg_price'] = ($total_price - $data['security'] - $data['cleaning']) / ($days - 1); // $data['avg_price'] = get_currency_value1($id,$total_price)/($days-1); if ($contact_key != '') { $amt = $data['subtotal']; $total_price = $amt; } else { $amt = $data['avg_price']; } $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $amt + get_currency_value_lys($row->currency, get_currency_code(), $fix); $data['commission'] = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $per = $row->percentage_amount; $percentage = $per / 100; $amount = $total_price * $percentage; $data['commission'] = $amount; /* $per = $row->percentage_amount; $camt = floatval(($data['avg_price'] * $per) / 100); //print_r($camt); $amt = $amt + $camt; // print_r($amt); $data['commission'] = round($camt,2); //print_r($data['commission']);*/ } } else { $amt = $amt; } if ($this->session->userdata('coupon_code_used') == 1) { if ($contact_key != '') { //echo "success"; $total_price = $amt + $this->session->userdata("coupon_amt"); $data['subtotal'] = $total_price - $this->session->userdata("coupon_amt"); $data['amt'] = $data['subtotal'] + $data['commission']; // $amt=$data['amt']+$cleaning+$security+$data['commission']; $amt = $data['amt']; $this->session->set_userdata('topay', $amt); } else { $amt = $amt - $this->session->userdata("coupon_amt"); $data['subtotal'] = $total_price - $this->session->userdata("coupon_amt"); $data['amt'] = $data['subtotal'] + $data['commission']; // $amt=$data['amt']+$cleaning+$security+$data['commission']; $amt = $data['amt']; // print_r($amt); $this->session->set_userdata('topay', $amt); } } else { $data['subtotal'] = $total_price; //print_r($data['subtotal']); //$data['amt'] = $data['avg_price'] * ($days-1)+$cleaning+$security+$data['commission']; $data['amt'] = $total_price + $data['commission']; $amt = $data['amt']; // $amt; exit; $this->session->set_userdata('topay', $amt); } } //$data['subtotal']= $data['subtotal']+$cleaning_price; $data['amt'] = round($amt, 2); $data['policy'] = $this->Common_model->getTableData('cancellation_policy', array('id' => $list->cancellation_policy))->row()->name; // Advertisement popup 1 start $data['PagePopupContent'] = GetPagePopupContent('step2'); // Advertisement popup 1 end $data['countries'] = $this->Common_model->getCountries()->result(); $data['title'] = get_meta_details('Confirm_your_booking', 'title'); $data["meta_keyword"] = get_meta_details('Confirm_your_booking', 'meta_keyword'); $data["meta_description"] = get_meta_details('Confirm_your_booking', 'meta_description'); $data['message_element'] = "payments/view_booking"; $this->load->view('template', $data); }