function getDaysInBetween($startdate, $enddate) { $period = (strtotime($enddate) - strtotime($startdate)) / (60 * 60 * 24); $dateinfo = get_gmt_time(strtotime($startdate)); do { $days[] = $dateinfo; $dateinfo = date('m/d/Y', $dateinfo); $pre_dateinfo = date('m/d/Y', strtotime('+1 day', strtotime($dateinfo))); $dateinfo = get_gmt_time(strtotime($pre_dateinfo)); $period--; } while ($period >= 0); return $days; }
public function expire() { $sql = "select *from reservation"; $query = $this->db->query($sql); $res = $query->result_array(); $date = date("F j, Y, g:i a"); $date = get_gmt_time(strtotime($date)); foreach ($res as $reservation) { $timestamp = $reservation['book_date']; $book_date = date("F j, Y, g:i a", $timestamp); $book_date = strtotime($book_date); $gmtTime = get_gmt_time(strtotime('+1 day', $timestamp)); if ($gmtTime <= $date && $reservation['status'] == 1) { $reservation_id = $reservation['id']; $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $conditions = array('reservation.id' => $reservation_id); $row = $this->Trips_model->get_reservation($conditions)->row(); $query1 = $this->Users_model->get_user_by_id($row->userby); $traveler_name = $query1->row()->username; $traveler_email = $query1->row()->email; $query2 = $this->Users_model->get_user_by_id($row->userto); $host_name = $query2->row()->username; $host_email = $query2->row()->email; $list_title = $this->Common_model->getTableData('list', array('id' => $row->list_id))->row()->title; $updateKey = array('id' => $reservation_id); $updateData = array(); $updateData['status '] = 2; $this->Trips_model->update_reservation($updateKey, $updateData); //Send Mail To Traveller $email_name = 'traveler_reservation_expire'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name)); $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Host $email_name = 'host_reservation_expire'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name)); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Administrator $email_name = 'admin_reservation_expire'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name)); $this->Email_model->sendMail($admin_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } } }
public function ajax_refresh_subtotal() { $id = $this->input->get('hosting_id'); $this->session->unset_userdata("total_price_'" . $id . "'_'" . $this->dx_auth->get_user_id() . "'"); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $data['guests'] = $this->input->get('number_of_guests'); $capacity = $this->Common_model->getTableData('list', array('id' => $id))->row()->capacity; $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); $xprice = $this->Common_model->getTableData('price', array('id' => $id))->row(); $guests = $xprice->guests; $per_night = $xprice->night; if (isset($xprice->cleaning)) { $cleaning = $xprice->cleaning; } else { $cleaning = 0; } if (isset($xprice->security)) { $security = $xprice->security; } else { $security = 0; } if (isset($xprice->night)) { $price = $xprice->night; } else { $price = 0; } if (isset($xprice->week)) { $Wprice = $xprice->week; } else { $Wprice = 0; } if (isset($xprice->month)) { $Mprice = $xprice->month; } else { $Mprice = 0; } $guest_count = $xprice->guests; //check admin premium condition and apply so for $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); //Seasonal Price //1. Store all the dates between checkin and checkout in an array $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]] == "") { $total_price = $total_price + $xprice->night; } else { $total_price = $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 = $total_price + $days * $xprice->addguests * $diff_guests; $extra_guest = 1; $extra_guest_price = $xprice->addguests * $diff_guests; } //Cleaning if ($cleaning != 0) { $total_price = $total_price + $cleaning; } if ($security != 0) { $total_price = $total_price + $security; } //Admin Commission $data['commission'] = 0; if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $total_price + $fix; $data['commission'] = $fix; } else { $per = $row->percentage_amount; $camt = floatval($total_price * $per / 100); $amt = $total_price + $camt; $data['commission'] = $camt; } } } if ($is_seasonal == 1) { //Total days $days = $total_nights; //Final price $data['price'] = $total_price; } else { if ($ckin[0] == "mm" && $ckout[0] == "mm" or $ckin[0] == "" && $ckout[0] == "" or $checkin == 'Check in' or $checkout == 'Check out') { $days = 0; $data['price'] = $price; if ($Wprice == 0) { $data['Wprice'] = $price * 7; } else { $data['Wprice'] = $Wprice; } if ($Mprice == 0) { $data['Mprice'] = $price * 30; } else { $data['Mprice'] = $Mprice; } $data['commission'] = 0; if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $price + $fix; $data['commission'] = $fix; $Fprice = $amt; } else { $per = $row->percentage_amount; $camt = floatval($price * $per / 100); $amt = $price + $camt; $data['commission'] = $camt; $Fprice = $amt; } if ($Wprice == 0) { $data['Wprice'] = $price * 7; } else { $data['Wprice'] = $Wprice; } if ($Mprice == 0) { $data['Mprice'] = $price * 30; } else { $data['Mprice'] = $Mprice; } } } else { $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]); $days = ceil($diff / (3600 * 24)); $price = $price * $days; //Additional guests if ($data['guests'] > $guests) { $diff_days = $data['guests'] - $guests; $price = $price + $days * $xprice->addguests * $diff_days; $extra_guest = 1; $extra_guest_price = $xprice->addguests * $diff_days; } if ($Wprice == 0) { $data['Wprice'] = $price * 7; } else { $data['Wprice'] = $Wprice; } if ($Mprice == 0) { $data['Mprice'] = $price * 30; } else { $data['Mprice'] = $Mprice; } $data['commission'] = 0; if ($days >= 7 && $days < 30) { if (!empty($Wprice)) { $finalAmount = $Wprice; $differNights = $days - 7; $perDay = $Wprice / 7; $per_night = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Wprice + $addAmount; } $price = $finalAmount; //Additional guests if ($data['guests'] > $guests) { $diff_days = $data['guests'] - $guests; $price = $price + $days * $xprice->addguests * $diff_days; $extra_guest = 1; $extra_guest_price = $xprice->addguests * $diff_days; } } } if ($days >= 30) { if (!empty($Mprice)) { $finalAmount = $Mprice; $differNights = $days - 30; $perDay = $Mprice / 30; $per_night = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Mprice + $addAmount; } $price = $finalAmount; //Additional guests if ($data['guests'] > $guests) { $diff_days = $data['guests'] - $guests; $price = $price + $days * $xprice->addguests * $diff_days; $extra_guest = 1; $extra_guest_price = $xprice->addguests * $diff_days; } } } if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $price + $fix; $data['commission'] = $fix; $Fprice = $amt; } else { $per = $row->percentage_amount; $camt = floatval($price * $per / 100); $amt = $price + $camt; $data['commission'] = $camt; $Fprice = $amt; } if ($Wprice == 0) { $data['Wprice'] = $price * 7; } else { $data['Wprice'] = $Wprice; } if ($Mprice == 0) { $data['Mprice'] = $price * 30; } else { $data['Mprice'] = $Mprice; } } $xprice = $this->Common_model->getTableData('list', array('id' => $id))->row(); if ($cleaning != 0) { $price = $price + $cleaning; } if ($security != 0) { $price = $price + $security; } $data['price'] = $price; } } $query = $this->db->query("SELECT id,list_id FROM `calendar` WHERE `list_id` = '" . $id . "' AND (`booked_days` = '" . get_gmt_time(strtotime($checkin)) . "' OR `booked_days` = '" . get_gmt_time(strtotime($checkout)) . "') GROUP BY `list_id`"); $rows = $query->num_rows(); $daysexist = $this->db->query("SELECT id,list_id,booked_days FROM `calendar` WHERE `list_id` = '" . $id . "' AND (`booked_days` >= '" . get_gmt_time(strtotime($checkin)) . "' AND `booked_days` <= '" . get_gmt_time(strtotime($checkout)) . "') GROUP BY `list_id`"); $rowsexist = $daysexist->num_rows(); if ($rowsexist > 0) { if (isset($extra_guest)) { if ($extra_guest == 1) { echo '{"available":false,"extra_guest":1,"extra_guest_price":"' . get_currency_symbol($id) . get_currency_value1($id, $extra_guest_price) . '","total_price":' . $data['price'] . ',"reason_message":"Those dates are not available"}'; } } else { echo '{"available":false,"total_price":' . $data['price'] . ',"reason_message":"Those dates are not available"}'; } } else { if ($data['guests'] > $capacity) { echo '{"available":false,"total_price":' . $data['price'] . ',"reason_message":"' . $capacity . ' guest(s) only allowed"}'; } else { $this->session->set_userdata("total_price_'" . $id . "'_'" . $this->dx_auth->get_user_id() . "'", $data['price']); $staggered_price = ""; if ($days >= 30) { $staggered_price = ',"staggered_price":"' . get_currency_symbol($id) . get_currency_value1($id, $data['price']) . '","staggered":false'; } if (isset($extra_guest)) { if ($extra_guest == 1) { echo '{"service_fee":"' . get_currency_symbol($id) . get_currency_value_lys($row->currency, get_currency_code(), $data['commission']) . '","extra_guest_price":"' . get_currency_symbol($id) . get_currency_value1($id, $extra_guest_price) . '","extra_guest":1,"reason_message":"","price_per_night":"' . get_currency_symbol($id) . get_currency_value1($id, $per_night) . '","nights":' . $days . ',"available":true,"can_instant_book":false,"total_price":"' . get_currency_symbol($id) . get_currency_value1($id, $data['price']) . '"' . $staggered_price . '}'; } } else { echo '{"service_fee":"' . get_currency_symbol($id) . get_currency_value_lys($row->currency, get_currency_code(), $data['commission']) . '","reason_message":"","price_per_night":"' . get_currency_symbol($id) . get_currency_value1($id, $per_night) . '","nights":' . $days . ',"available":true,"can_instant_book":false,"total_price":"' . get_currency_symbol($id) . get_currency_value1($id, $data['price']) . '"' . $staggered_price . '}'; } } } }
function after_checkin() { $date = date("F j, Y, g:i a"); $date = get_gmt_time(strtotime($date)); $result = $this->Common_model->getTableData('reservation', array('status' => 7)); if ($result->num_rows() != 0) { foreach ($result->result() as $row_status) { $timestamp = $row_status->checkout; $checkout = date("F j, Y, g:i a", $timestamp); $checkout = strtotime($checkout); $gmtTime = get_gmt_time(strtotime('+1 day', $timestamp)); if ($gmtTime <= $date) { $reservation_id = $row_status->id; $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $conditions = array('reservation.id' => $reservation_id); $row = $this->Trips_model->get_reservation($conditions)->row(); $updateKey = array('id' => $reservation_id); $updateData = array(); $updateData['status '] = 8; $this->Trips_model->update_reservation($updateKey, $updateData); $conditions = array('reservation.id' => $reservation_id); $row = $this->Trips_model->get_reservation($conditions)->row(); $before_status = $row->status; if ($this->Users_model->get_user_by_id($row->userby)) { $query1 = $this->Users_model->get_user_by_id($row->userby); } else { //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error',translate('Your List was deleted.'))); //redirect('travelling/your_trips'); } $traveler_name = $query1->row()->username; $traveler_email = $query1->row()->email; $query2 = $this->Users_model->get_user_by_id($row->userto); $host_name = $query2->row()->username; $host_email = $query2->row()->email; $list_title = $this->Common_model->getTableData('list', array('id' => $row->list_id))->row()->title; $username = $traveler_name; if ($row->list_id) { $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userby, 'userto' => $row->userto, 'message' => "{$username} wants the review from you.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 4); $this->Message_model->sentMessage($insertData); //Send Mail To Traveller $email_name = 'checkout_traveler'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name)); $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Host $email_name = 'checkout_host'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name)); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Administrator $email_name = 'checkout_admin'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name)); $this->Email_model->sendMail($admin_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success',translate('You are successfully checked out.'))); //redirect('travelling/previous_trips'); } } } } echo '<h2>Cron Successfully Runned.</h2>'; }
<li class="top col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_check_in"></span><?php echo translate("Check in"); ?> </span></span> <span class="data col-md-9 col-sm-9 col-xs-12"><span class="inner"> <?php echo get_user_times(get_gmt_time(strtotime($checkin)), get_user_timezone()); ?> <em class="check_in_out_time"><?php echo translate("(Flexible check in time)"); ?> </em></span></span> </li> <li class="col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_check_out"></span><?php echo translate("Check out"); ?> </span></span> <span class="data col-md-9 col-sm-9 col-xs-12"><span class="inner"> <?php echo get_user_times(get_gmt_time(strtotime($checkout)), get_user_timezone()); ?> <em class="check_in_out_time"><?php echo translate("(Flexible check out time)"); ?> </em></span></span> </li> <li class=" col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_nights"></span><?php echo translate("Nights"); ?> </span></span> <span class="data col-md-9 col-sm-9 col-xs-12"><span class="inner"><?php echo $days; ?> </span></span> </li> <li class="bottom col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_person"></span><?php
?> <!--<?php $timestamp = $result->book_date; // $timestamp = strtotime('+1 day',$timestamp); $book_date = date('m/d/Y', $timestamp); // $gmtTime = get_gmt_time($timestamp); $gmtTime = get_gmt_time(strtotime('+24 hours', $timestamp)); //$gmtTime = get_gmt_time(strtotime('-20 minutes',$gmtTime)); //$date=gmdate("Year: %Y Month: %m Day: %d - %h:%i %a",$gmdate); $date = gmdate('D, d M Y H:i:s +\\G\\M\\T', $gmtTime); ?> --> <?php $timestamp = $result->book_date; $book_date = date('m/d/Y', $timestamp); $gmtTime = get_gmt_time(strtotime('+24 hours', $timestamp)); //$gmtTime = get_gmt_time(strtotime('-20 minutes',$gmtTime)); //$date=gmdate("Year: %Y Month: %m Day: %d - %h:%i %a",$gmdate); $date = gmdate('D, d M Y H:i:s +\\G\\M\\T', $gmtTime); ?> <div id="expire" style="font-size:20px;"></div> <?php } else { ?> <?php echo translate("Status"); ?> <?php } ?> </span></span>
</span></span> </li> <li class="clearfix bottom"> <span class="label" ><span class="inner"><span class="checkout_icon" id="icon_cal"></span> <?php if ($result->status == 1) { ?> <?php echo translate("Expires in"); ?> <?php $timestamp = $result->book_date; $book_date = date('m/d/Y', $timestamp); $gmtTime = get_gmt_time(strtotime('+24 hours', $timestamp)); $gmtTime = get_gmt_time(strtotime('-18 minutes', $gmtTime)); $date = gmdate('D, d M Y H:i:s \\G\\M\\T', $gmtTime); ?> <div id="expire" style="font-size:20px;"></div> <?php } else { ?> <?php echo translate("Status"); ?> <?php } ?> </span></span> <?php
function form() { $id = $this->input->get('id'); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $data['guests'] = $this->input->get('guest'); $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->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->manual; $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 = $price * $days + $days * $xprice->addguests * $diff_days; } else { $amt = $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; } } 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; } } //Update the daily price $data['price'] = $xprice->night; //Cleaning fee if ($cleaning != 0) { $amt = $amt + $cleaning; } else { $amt = $amt; } $session_coupon = $this->session->userdata("coupon"); if ($this->input->get('contact')) { $amt = $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()."'"); } //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)); //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->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) { if ($Coupon_amt >= get_currency_value1($list_id, $amt)) { $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 $amt = $amt - $Coupon_amt; $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); } } else { $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->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Your coupon does not match.'))); redirect('rooms/' . $list_id, "refresh"); } } //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 + $fix; $data['commission'] = $fix; } else { $per = $row->percentage_amount; $camt = floatval($amt * $per / 100); $amt = $amt + $camt; $data['commission'] = $camt; } } else { $amt = $amt; } // Coupon Code Starts //print_r($amt);exit; if ($amt > 110) { $da = array(); $this->db->select('*'); $this->db->where('id', $this->dx_auth->get_user_id()); $this->db->from('users'); $value = $this->db->get()->result(); foreach ($value as $val) { $da = $val->referral_amount; } if ($da != 0) { $data['amt'] = $amt; $data['referral_amount'] = $da; } 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"); } $dat['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 = $total_price + $xprice->night; } else { $total_price = $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 = $total_price + $days * $xprice->addguests * $diff_guests; } //Cleaning if ($cleaning != 0) { $total_price = $total_price + $cleaning; } //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 + $fix; $data['commission'] = $fix; } else { $per = $row->percentage_amount; $camt = floatval($amt * $per / 100); $amt = $amt + $camt; $data['commission'] = $camt; } } else { $amt = $amt; } $data['amt'] = $amt; $this->session->set_userdata('topay', $amt); } $data['img'] = getListImage($id); $data['env'] = 'mobile'; $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 availability() { $checkin = $this->input->get('checkin'); $checkin_time = $checkin; $checkin_time = get_gmt_time(strtotime($checkin_time)); $checkout = $this->input->get('checkout'); $checkout_time = $checkout; $checkout_time = get_gmt_time(strtotime($checkout_time)); $id = $this->input->get('room_id'); $conditions = array("id" => $id); $result = $this->Common_model->getTableData('list', $conditions); if ($result->num_rows() == 0) { echo "[ { \"status\":\"Access Denied\" } ]"; } else { $status = 1; $daysexist = $this->db->query("SELECT id,list_id,booked_days FROM `calendar` WHERE `list_id` = '" . $id . "' AND (`booked_days` >= '" . $checkin_time . "' AND `booked_days` <= '" . $checkout_time . "') GROUP BY `id`"); $rowsexist = $daysexist->num_rows(); if ($rowsexist > 0) { $status = 0; } if ($status == 0) { echo "[ { \"status\":\"NO\" } ]"; } else { echo "[ { \"status\":\"YES\" } ]"; } } }
public function modify_calendar() { if ($this->dx_auth->is_logged_in() || $this->facebook_lib->logged_in()) { /* $from = $this->input->post('from'); $to = $this->input->post('to'); $amount = $this->input->post('amount'); $min_currency= round(get_currency_value_lys($from,$to,$amount)); echo $min_currency; */ //Seasonal Price $availability = $this->input->post('availability'); $pricevalue = $this->input->post('seasonal_price'); $id = $this->input->post('hosting_id'); echo $id; $cur_code = $this->db->where('id', $id)->from('list')->get()->row()->currency; $cur_val = $this->db->where('currency_code', $cur_code)->from('currency_converter')->get()->row()->currency_value; $currency_value = round($cur_val * 10); $currency_maxvalue = $currency_value * 1000; echo $currency_maxvalue; if ($availability == "Available" && $pricevalue != "" && $pricevalue >= $currency_value && $pricevalue <= $currency_maxvalue) { $month = $this->input->get('month', TRUE); $year = $this->input->get('year', TRUE); $startdate = $this->input->post('starting_date'); $starttime = get_gmt_time(strtotime($startdate)); $enddate = $this->input->post('stopping_date'); $endtime = get_gmt_time(strtotime($enddate)); $pdata = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => $cur_code); // print_r($pdata); // echo $pricevalue;echo $availability; $update = 0; $query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $pdata['list_id'])); $res = $query->result_array(); $count = 1; foreach ($res as $row) { $from = $row['start_date']; $to = $row['end_date']; if ($starttime == $from && $endtime == $to) { $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $updatedata = array('price' => $pdata['price']); $this->Common_model->updateTableData('seasonalprice', NULL, $condition, $updatedata); $update = 1; } else { if ($starttime == $from && $endtime == $from) { //update $starttime_update = get_gmt_time(strtotime('+1 day', $starttime)); $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $updatedata = array('start_date' => $starttime_update); $this->Common_model->updateTableData('seasonalprice', NULL, $condition, $updatedata); //insert $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); $update = 1; } else { if ($starttime == $to && $endtime == $to) { //update $endtime_update = get_gmt_time(strtotime('-1 day', $endtime)); $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $updatedata = array('end_date' => $endtime_update); $this->Common_model->updateTableData('seasonalprice', NULL, $condition, $updatedata); //insert $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); $update = 1; } else { if ($starttime > $from && $starttime < $to && ($endtime > $from && $endtime < $to)) { //update $endtime_update = get_gmt_time(strtotime('+1 day', $endtime)); $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $updatedata = array('start_date' => $endtime_update); $this->Common_model->updateTableData('seasonalprice', NULL, $condition, $updatedata); //insert 1 $starttime_update = get_gmt_time(strtotime('-1 day', $starttime)); $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $row['price'], 'start_date' => $row['start_date'], 'end_date' => $starttime_update, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); //insert 2 $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); $update = 1; } else { if ($starttime <= $from && $starttime < $to && ($endtime > $from && $endtime < $to) || $starttime < $from && $starttime < $to && $endtime == $from) { //update $endtime_update = get_gmt_time(strtotime('+1 day', $endtime)); $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $updatedata = array('start_date' => $endtime_update); $this->Common_model->updateTableData('seasonalprice', NULL, $condition, $updatedata); //insert 1 $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); $update = 1; } else { if ($starttime > $from && $starttime < $to && ($endtime > $from && $endtime >= $to) || $starttime == $to && ($endtime > $from && $endtime > $to)) { //update $starttime_update = get_gmt_time(strtotime('-1 day', $starttime)); $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $updatedata = array('end_date' => $starttime_update); $this->Common_model->updateTableData('seasonalprice', NULL, $condition, $updatedata); //insert 1 $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); $update = 1; } else { if ($starttime < $from && $starttime < $to && ($endtime > $from && $endtime > $to) || $starttime == $from && $endtime > $to & $startime < $to || $starttime < $from && $starttime < $to && $endtime == $to) { //Delete $condition = array('list_id' => $pdata['list_id'], 'start_date' => $from, 'end_date' => $to); $this->Common_model->deleteTableData('seasonalprice', $condition); //insert 1 if ($count == 1) { $insertdata1 = array('list_id' => $this->input->post('hosting_id'), 'price' => $this->input->post('seasonal_price'), 'start_date' => $starttime, 'end_date' => $endtime, 'currency' => get_currency_code()); $this->db->insert('seasonalprice', $insertdata1); } $update = 1; } } } } } } } $count++; } if ($update == 0) { $this->db->insert('seasonalprice', $pdata); } } elseif ($availability == "Available" && $pricevalue < $currency_value) { exit; } elseif ($availability == "Available" && $pricevalue >= $currency_maxvalue) { exit; } elseif ($availability != "Available" && $this->input->post('notes') == 'Notes...') { exit; } $day = date("d"); $month = $this->input->get('month', TRUE); $year = $this->input->get('year', TRUE); $booked_from = $this->input->post('starting_date_original'); $booked_to = $this->input->post('stopping_date_original'); $list_id = $this->input->post('hosting_id'); $grouping_uid = $this->input->post('grouping_uid'); $insertData = array('list_id' => $this->input->post('hosting_id'), 'availability' => $this->input->post('availability'), 'value' => $this->input->post('value_native'), 'currency' => $this->input->post('currency'), 'notes' => rawurlencode($this->input->post('notes')), 'booked_using' => $this->input->post('booking_service')); if (!empty($grouping_uid)) { if ($insertData['availability'] == 'Available') { $conditions = array('group_id' => $grouping_uid); $this->Trips_model->delete_calendar(NULL, $conditions); } else { if ($insertData['availability'] == 'Booked') { $updateKey = array('group_id' => $grouping_uid); $updateData = $insertData; $this->Trips_model->update_calendar($updateKey, $updateData); } else { $updateKey = array('group_id' => $grouping_uid); $updateData = $insertData; $this->Trips_model->update_calendar($updateKey, $updateData); } } } else { if ($insertData['availability'] == 'Booked' || $insertData['availability'] == 'Not Available') { $this->db->select_max('group_id'); $group_id = $this->db->get('calendar')->row()->group_id; if (empty($group_id)) { echo $countJ = 0; } else { $countJ = $group_id; } $insertData['group_id'] = $countJ + 1; $days = getDaysInBetweenC($booked_from, $booked_to); $count = count($days); $i = 1; foreach ($days as $val) { if ($count == 1) { $insertData['style'] = 'single'; } else { if ($count > 1) { if ($i == 1) { $insertData['style'] = 'left'; } else { if ($count == $i) { $insertData['notes'] = ''; $insertData['style'] = 'right'; } else { $insertData['notes'] = ''; $insertData['style'] = 'both'; } } } } $insertData['booked_days'] = get_gmt_time(strtotime($val)); $insertData['created'] = local_to_gmt(); $this->Trips_model->insert_calendar($insertData); $i++; } } } $first_day = mktime(0, 0, 0, $month, 1, $year); $days_in_month = cal_days_in_month(0, $month, $year); $day_of_week = date('N', $first_day); $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $title = $months[$month - 1]; if ($day_of_week == 7) { $blank = 0; } else { $blank = $day_of_week; } if ($month - 1 == 0) { $prevmonth = 1; $prevyear = $year - 1; } else { $prevmonth = $month - 1; $prevyear = $year; } $day_prevmonth = cal_days_in_month(0, $prevmonth, $prevyear) - ($blank - 1); if ($month == 01) { $prev_month = 12; $prev_year = $year - 1; } else { $prev_month = $month - 1; $prev_year = $year; } if ($month == 12) { $next_month = 01; $next_year = $year + 1; } else { $next_month = $month + 1; $next_year = $year; } $day_num = 1; $day_count = 1; $datenow = time(); $monthnow = date('n', $datenow); $yearnow = date('Y', $datenow); $daynow = date('j', $datenow); $schedules = ''; $firstDay = $prev_year . '-' . $prev_month . '-' . $day_prevmonth; $conditions = array('list_id' => $list_id); $result = $this->Trips_model->get_calendar($conditions)->result(); //Previous Months Days while ($blank > 0) { $full_date = $prev_month . '/' . $day_prevmonth . '/' . $prev_year; $pre_schedules = '{cl: "av", sty: "both", isa: 1},'; foreach ($result as $row) { if (get_gmt_time(strtotime($full_date)) == $row->booked_days) { $pre_schedules = '{cl: "tp", sty: "' . $row->style . '", isa: 0, id: ' . $row->id . ', notes: "' . $row->notes . '", st: 4, sst: "' . $row->booked_using . '", gid: ' . $row->group_id . ', reservation_value: ' . $row->value . '},'; } } $schedules .= $pre_schedules; $blank = $blank - 1; $day_count++; $day_prevmonth++; } //Current Months Days while ($day_num <= $days_in_month) { $full_date = $month . '/' . $day_num . '/' . $year; $pre_schedules = '{cl: "av", sty: "both", isa: 1},'; foreach ($result as $row) { if (get_gmt_time(strtotime($full_date)) == $row->booked_days) { if ($row->value != '') { $value = ', reservation_value: ' . $row->value; } else { $value = ''; } if ($row->availability == 'Not Available') { $c1 = 'bs'; $st = 2; } else { $c1 = 'tp'; $st = 4; } $pre_schedules = '{cl: "' . $c1 . '", sty: "' . $row->style . '", isa: 0, id: ' . $row->id . ', notes: "' . $row->notes . '", st: ' . $st . ', sst: "' . $row->booked_using . '", gid: ' . $row->group_id . $value . '},'; } } $schedules .= $pre_schedules; $day_num++; $day_count++; if ($day_count > 7) { $day_count = 1; } } //Next Months Days $day_nextmonth = 1; while ($day_count > 1 && $day_count <= 7) { $full_date = $next_month . '/' . $day_nextmonth . '/' . $next_year; $pre_schedules = '{cl: "av", sty: "both", isa: 1},'; foreach ($result as $row) { if (get_gmt_time(strtotime($full_date)) == $row->booked_days) { if ($row->value != '') { $value = ', reservation_value: ' . $row->value; } else { $value = ''; } if ($row->availability == 'Not Available') { $c1 = 'bs'; $st = 2; } else { $c1 = 'tp'; $st = 4; } $pre_schedules = '{cl: "' . $tp . '", sty: "' . $row->style . '", isa: 0, id: ' . $row->id . ', notes: "' . $row->notes . '", st: ' . $st . ', sst: "' . $row->booked_using . '", gid: ' . $row->group_id . $value . '},'; } } $schedules .= $pre_schedules; $day_count++; $day_nextmonth++; } echo 'update_calendar_data(0, ' . $list_id . ', [[' . substr($schedules, 0, -1) . ']]); after_submit();'; } else { redirect('users/signin'); } }
public function getFeeds() { //Get the checkin and chekout dates $checkin = ''; $checkout = ''; $stack = array(); $room_types = array(); $property_type_id = array(); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $nof_guest = $this->input->get('guests'); $room_types = $this->input->get('room_types'); $min = $this->input->get('price_min'); $max = $this->input->get('price_max'); $keywords = $this->input->get('keywords'); $min_bedrooms = $this->input->get('min_bedrooms'); $min_bathrooms = $this->input->get('min_bathrooms'); $min_beds = $this->input->get('min_beds'); $property_type_id = $this->input->get('property_type_id'); $hosting_amenities = $this->input->get('hosting_amenities'); if ($checkin != '--' && $checkout != '--' && $checkin != "yy-mm-dd" && $checkout != "yy-mm-dd" && $checkin != '' && $checkout != '') { $ans = $this->db->query("SELECT id,list_id FROM `calendar` WHERE `booked_days` = '" . get_gmt_time(strtotime($checkin)) . "' OR `booked_days` = '" . get_gmt_time(strtotime($checkout)) . "' GROUP BY `list_id`"); $a = $ans->result(); $this->db->flush_cache(); // Now after the checkin is completed if (!empty($a)) { foreach ($a as $a1) { array_push($stack, $a1->list_id); } } } $condition = ''; $location = $this->input->get('location'); $pieces = explode(",", $location); $print = ""; $len = count($pieces); $condition .= "(`is_enable` != '0')"; if ($location != '') { $i = 1; foreach ($pieces as $address) { $this->db->flush_cache(); $address = $this->db->escape_like_str($address); if ($i == $len) { $and = ""; } else { $and = " AND "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`address` LIKE '%" . $address . "%'" . $and; if ($i == $len) { $condition .= ")"; } $i++; } } if (!empty($min_bedrooms)) { $condition .= " AND (`bedrooms` = '" . $min_bedrooms . "')"; } if (!empty($min_bathrooms)) { $condition .= " AND (`bathrooms` = '" . $min_bathrooms . "')"; } if (!empty($min_beds)) { $condition .= " AND (`beds` = '" . $min_beds . "')"; } if (!empty($stack)) { $condition .= " AND (`id` NOT IN(" . implode(',', $stack) . "))"; } if ($nof_guest > 1) { $condition .= " AND (`capacity` = '" . $nof_guest . "')"; } if (is_array($room_types)) { if (count($room_types) > 0) { $i = 1; foreach ($room_types as $room_type) { if ($i == count($room_types)) { $and = ""; } else { $and = " AND "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`room_type` = '" . $room_type . "'" . $and; if ($i == count($room_types)) { $condition .= ")"; } $i++; } } } if (is_array($hosting_amenities)) { if (count($hosting_amenities) > 0) { $i = 1; foreach ($hosting_amenities as $amenity) { if ($i == count($hosting_amenities)) { $and = ""; } else { $and = " AND "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`amenities` LIKE '%" . $amenity . "%'" . $and; if ($i == count($hosting_amenities)) { $condition .= ")"; } $i++; } } } if (isset($min)) { if ($min > 0) { $condition .= " AND (`price` >= '" . $min . "')"; } } else { if (isset($max)) { $min = 0; } } if (isset($max)) { if ($max > $min) { $condition .= " AND (`price` <= '" . $max . "')"; } } if (is_array($property_type_id)) { if (count($property_type_id) > 0) { $i = 1; foreach ($property_type_id as $property_id) { if ($i == count($property_type_id)) { $and = ""; } else { $and = " OR "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`property_id` = '" . $property_id . "'" . $and; if ($i == count($property_type_id)) { $condition .= ")"; } $i++; } } } if (!empty($keywords)) { $keywords = $this->db->escape_like_str($keywords); $condition .= " AND (`address` LIKE '%" . $keywords . "%' OR `title` LIKE '%" . $keywords . "%' OR `desc` LIKE '%" . $keywords . "%')"; } //Final query $condition .= " AND (`status` != '0') AND (`user_id` != '0') AND (`address` != '0')"; $data['query'] = $this->db->query("SELECT * FROM (`list`) WHERE {$condition}"); $this->load->view('rss_xml', $data); }
/** * To post the affiliate questions * * @access public * @param nil * @return void */ function manageAffiliates() { //Load model $this->load->model('settings_model'); //load validation library $this->load->library('form_validation'); //Load Form Helper $this->load->helper('form'); //Intialize values for library and helpers $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag')); if (!isset($this->loggedInUser->id)) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You can not access to this page'))); redirect('info'); } $condition = array('sales.refid' => $this->loggedInUser->user_name); $this->outputData['affiliate_sales'] = $this->affiliate_model->getAffiliateSales($condition); // get affiliate sales total $condition1 = array('sales.refid' => $this->loggedInUser->user_name); $this->outputData['affiliate_sales_total'] = $this->affiliate_model->getSalesTotal($condition1); // get affiliate welcome messages $condition2 = array('affiliate_welcome_msg.refid' => $this->loggedInUser->user_name, 'msg_status' => 0); $msg_result = $this->affiliate_model->getAffiliateWelcomeMsg($condition2); $msg_num_rows = $msg_result->num_rows(); $msg_result_row = $msg_result->row(); if (isset($msg_result_row->welcome_msg)) { $this->outputData['affiliate_welcome_msg'] = $msg_result_row->welcome_msg; } //Innermenu tab selection $this->outputData['innerClass5'] = ''; $this->outputData['innerClass5'] = 'selected'; if ($this->input->post('welcomemsg')) { //Set rules $this->form_validation->set_rules('welcome_message', 'lang:welcome_message_validation', 'required|trim|xss_clean'); if ($this->form_validation->run()) { $welcome_msg = $this->input->post('welcome_message'); if ($msg_num_rows == 0) { //prepare insert data $insertData = array(); $insertData['refid'] = $this->loggedInUser->user_name; $insertData['welcome_msg'] = $welcome_msg; //print_r($insertData); //Add Category $this->affiliate_model->addAffiliateWelcomeMsg($insertData); $this->session->set_flashdata('flash_message', $this->common_model->admin_flash_message('success', $this->lang->line('updated_success'))); //$this->load->view('affiliate/affilateCenter',$this->outputData); } else { $updateKey1 = array('affiliate_welcome_msg.refid' => $this->loggedInUser->user_name, 'id' => $msg_result_row->id); $updateData1 = array(); $updateData1['welcome_msg '] = $welcome_msg; //Update Site Settings $this->affiliate_model->updateAffiliateWelcomeMeg($updateKey1, $updateData1); $this->session->set_flashdata('flash_message', $this->common_model->admin_flash_message('success', $this->lang->line('updated_success'))); } } } // get affiliate welcome messages $condition2 = array('affiliate_welcome_msg.refid' => $this->loggedInUser->user_name); $msg_result = $this->affiliate_model->getAffiliateWelcomeMsg($condition2); $msg_num_rows = $msg_result->num_rows(); $msg_result_row = $msg_result->row(); if (isset($msg_result_row->welcome_msg)) { $this->outputData['affiliate_welcome_msg'] = $msg_result_row->welcome_msg; } // insert total affiliate amount $this->load->model('affiliate_model'); $this->load->model('user_model'); $results = $this->affiliate_model->getReleasePayments(); //pr($results->result()); if ($results->num_rows() > 0) { foreach ($results->result() as $row) { //prepare insert data $insertData = array(); $insertData['refid'] = $row->refid; $insertData['account_type'] = $row->account_type; $insertData['payment'] = $row->total; // get user $condition = array('users.user_name' => $insertData['refid']); $user_data = $this->user_model->getUsers($condition); //$user_data_result = $user_data->result(); $user_data_row = $user_data->row(); $user_id = 0; if (isset($user_data_row->id)) { if ($user_data_row->id != '') { $user_id = $user_data_row->id; } } $insertData['user_id'] = $user_id; $insertData['created_date'] = get_est_time(); $date_with_time = show_date($insertData['created_date']); $arr = explode(' ', $date_with_time); //pr($arr_str); for ($i = 0; $i < count($arr); $i++) { $mon = $arr[0]; $year = $arr[2]; } $created_date_forrmat = $mon . ", " . $year; $insertData['created_date_format'] = $created_date_forrmat; $insertData['is_released'] = '0'; $unrelease_condition = array('refid' => $row->refid, 'is_released' => '0'); $unrelease_results = $this->affiliate_model->getUnReleasePayments($unrelease_condition); $unreleased_row = $unrelease_results->row(); $released_condition = array('refid' => $row->refid, 'is_released' => '1'); $released_results = $this->affiliate_model->getUnReleasePayments($released_condition); $released_row = $released_results->row(); if ($unrelease_results->num_rows() > 0) { $updateKey['payment'] = $row->total; $cond = array('affiliate_unreleased_payments.refid' => $row->refid, 'affiliate_unreleased_payments.id' => $unreleased_row->id); $result = $this->affiliate_model->updateUnReleasedPayments(TRUE, $updateKey, $cond); } else { if ($released_results->num_rows() > 0) { foreach ($released_results->result() as $row1) { $sales_total = $row->total; $released_total = $row1->total; $check_balance = $sales_total - $released_total; if ($check_balance > 0) { //prepare insert data $insertData1 = array(); $insertData1['refid'] = $row->refid; $insertData1['account_type'] = $row->account_type; $insertData1['payment'] = $check_balance; $user_id; $insertData1['user_id'] = $user_id; $insertData1['created_date'] = get_gmt_time(); $insertData1['created_date_format'] = $created_date_forrmat; $insertData1['is_released'] = '0'; $condition = array('users.user_name' => $insertData1['refid']); $this->affiliate_model->addUnReleasedPayments($insertData1); } } } } if ($unrelease_results->num_rows() == 0 and $released_results->num_rows() == 0) { $this->affiliate_model->addUnReleasedPayments($insertData); } } } //exit; $cond = array('affiliate_released_payments.refid' => $this->loggedInUser->user_name); $released_amount = $this->affiliate_model->getReleasedPayments($cond); $this->outputData['released_amount'] = $released_amount; $this->load->view('affiliate/affilateCenter', $this->outputData); }
function submission_cc($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"); } $checkin = $this->input->post('checkin'); $checkout = $this->input->post('checkout'); $number_of_guests = $this->input->post('number_of_guests'); $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); $id = $this->uri->segment(3); if ($this->session->userdata('mobile_user_id')) { $user_id = $this->session->userdata('mobile_user_id'); $this->session->unset_userdata('mobile_user_id'); } else { $user_id = $this->dx_auth->get_user_id(); } if ($ckin[0] == "mm") { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Access denied.'))); redirect('rooms/' . $id, "refresh"); } if ($ckout[0] == "mm") { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Access denied.'))); redirect('rooms/' . $id, "refresh"); } $xprice = $this->Common_model->getTableData('price', array('id' => $this->uri->segment(3)))->row(); $price = $xprice->night; $placeid = $xprice->id; $guests = $xprice->guests; $extra_guest_price = $xprice->addguests; if (isset($xprice->cleaning)) { $cleaning = $xprice->cleaning; } else { $cleaning = 0; } if (isset($xprice->security)) { $security = $xprice->security; } else { $security = 0; } 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)); $q = $query->result(); $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]); $days = ceil($diff / (3600 * 24)); $user_travel_cretids = 0; if ($this->session->userdata('travel_cretids')) { $amt = $this->session->userdata('travel_cretids'); $user_travel_cretids = $this->session->userdata('user_travel_cretids'); $is_travelCretids = md5('Yes Travel Cretids'); } else { if ($number_of_guests > $guests) { $diff_days = $number_of_guests - $guests; $amt = $price * $days + $days * $xprice->addguests * $diff_days; } else { $amt = $price * $days; } if ($days >= 7 && $days < 30) { if (!empty($Wprice)) { $finalAmount = $Wprice; $differNights = $days - 7; $perDay = $Wprice / 7; $per_night = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Wprice + $addAmount; } $amt = $finalAmount; } } if ($days >= 30) { if (!empty($Mprice)) { $finalAmount = $Mprice; $differNights = $days - 30; $perDay = $Mprice / 30; $per_night = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Mprice + $addAmount; } $amt = $finalAmount; } } //Cleaning fee if ($cleaning != 0) { $amt = $amt + $cleaning; } if ($security != 0) { $amt = $amt + $cleaning; } else { $amt = $amt; } $to_pay = 0; $admin_commission = 0; //Amount from session // $amt=$this->session->userdata("total_price_'".$id."'_'".$this->dx_auth->get_user_id()."'"); //commission calculation $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $to_pay = $amt; $fix = $row->fixed_amount; $amt = $amt + get_currency_value_lys($row->currency, get_currency_code(), $fix); //$amt = $this->session->userdata('topay'); $admin_commission = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $to_pay = $amt; $per = $row->percentage_amount; $percentage = $per / 100; $admin_commission = $percentage * $to_pay; /* $camt = floatval(($amt * $per) / 100); $amt = $amt + $camt; $amt = $amt; $admin_commission = $camt+get_currency_value_lys($row->currency,get_currency_code(),$camt); */ // print_r($admin_commission); } } else { $amt = $amt; $to_pay = $amt; print_r($to_pay); } $is_travelCretids = md5('No Travel Cretids'); } //echo $amt;exit; if ($contact_key != '') { $contact_result = $this->db->where('contact_key', $contact_key)->get('contacts')->row(); $amt = $contact_result->price + $contact_result->admin_commission; $this->session->set_userdata('contacts_offer', $contact_result->offer); } $ref_total1 = $ref_total + 10; if ($amt > $ref_total1) { if ($this->db->select('referral_amount')->where('id', $user_id)->get('users')->row()->referral_amount != 0) { $referral_amount = $this->db->select('referral_amount')->where('id', $user_id)->get('users')->row()->referral_amount; if ($referral_amount > $ref_total) { $final_amt = get_currency_value1($id, $amt) - get_currency_value($ref_total); } else { $final_amt = $amt - $referral_amount; } $amt = $final_amt; } else { $amt = $amt; } } else { $amt = $amt; } $amount = $amt; if ($contact_key == "") { $contact_key = "None"; } //Entering it into data variables $row = $this->Common_model->getTableData('payment_details', array('code' => 'PAYPAL_ID'))->row(); $paymode = $this->db->where('payment_name', 'Paypal')->get('payments')->row()->is_live; if ($this->session->userdata('final_amount') != '') { $amt = $this->session->userdata('final_amount'); $this->session->unset_userdata('final_amount'); } else { $amt = get_currency_value1($id, $amt) + $admin_commission; } //seasonal price $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)); // echo "<pre>"; // print_r($i); $total_nights++; } for ($i = 1; $i < $total_nights; $i++) { $seasonal_prices[$travel_dates[$i]] = ""; } $seasonal_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id)); $seasonal_result = $seasonal_query->result_array(); // echo "<pre>"; // print_r($seasonal_result); if ($seasonal_query->num_rows() > 0) { foreach ($seasonal_result as $time) { $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)); //echo "<pre>"; //print_r($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) + $seasonal_prices[$travel_dates[$i]]; //echo "$total_price"; $is_seasonal = 1; } } // echo "$total_price"; //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; //echo "$total_price"; $data['extra_guest_price'] = get_currency_value1($id, $xprice->addguests) * $diff_guests; } //echo "$total_price"; //Cleaning if ($cleaning != 0) { $total_price = $total_price + get_currency_value1($id, $cleaning); // echo "$total_price"; } if ($security != 0) { $total_price = $total_price + get_currency_value1($id, $security); // echo "$total_price"; } $data['avg_price'] = $total_price / $days; $per_night = $data['avg_price']; $topay = $per_night * $days - $this->session->userdata("coupon_amt"); $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); $percentage = $per / 100; $amount = $per_night * $days * $percentage; $admin_commission = $amount; $amt = $admin_commission + $topay; $total_price = $total_price - $this->session->userdata("coupon_amt"); } // echo "$total_price"; //Seasonal price $this->session->set_userdata('subtotal', $amt); /*if($this->session->userdata('booking_currency_symbol')) {*/ //$custom = $id.'@'.$user_id.'@'.get_gmt_time(strtotime($checkin)).'@'.get_gmt_time(strtotime($checkout)).'@'.$number_of_guests.'@'.$is_travelCretids.'@'.$user_travel_cretids.'@'.$to_pay.'@'.$admin_commission.'@'.$contact_key.'@'.$cleaning.'@'.$security.'@'.$extra_guest_price.'@'.$guests.'@'.$amt.'@'.$this->session->userdata('booking_currency_symbol'); /*} else {*/ //print_r($to_pay); //print_r($admin_commission); //print_r($amt); $custom = $id . '@' . $user_id . '@' . get_gmt_time(strtotime($checkin)) . '@' . get_gmt_time(strtotime($checkout)) . '@' . $number_of_guests . '@' . $is_travelCretids . '@' . $user_travel_cretids . '@' . get_currency_value1($id, $total_price) . '@' . $admin_commission . '@' . $contact_key . '@' . get_currency_value1($id, $cleaning) . '@' . get_currency_value1($id, $security) . '@' . get_currency_value1($id, $extra_guest_price) . '@' . $guests . '@' . $amt . '@' . $this->session->userdata('booking_currency_symbol'); //print_r($custom); //exit; //$custom = $id.'@'.$user_id.'@'.get_gmt_time(strtotime($checkin)).'@'.get_gmt_time(strtotime($checkout)).'@'.$number_of_guests.'@'.$is_travelCretids.'@'.$user_travel_cretids.'@'.$to_pay.'@'.$admin_commission.'@'.$contact_key.'@'.$cleaning.'@'.$security.'@'.$extra_guest_price.'@'.$guests.'@'.$amt.'@'.$this->session->userdata('booking_currency_symbol').'@'.$per_night; //$custom = $id.'@'.$user_id.'@'.get_gmt_time(strtotime($checkin)).'@'.get_gmt_time(strtotime($checkout)).'@'.$number_of_guests.'@'.$is_travelCretids.'@'.$user_travel_cretids.'@'.$amt.'@'.$admin_commission.'@'.$contact_key.'@'.$cleaning.'@'.$security.'@'.$extra_guest_price.'@'.$guests.'@'.$to_pay.'@'.$this->session->userdata('booking_currency_symbol').'@'.$per_night; //} $this->session->set_userdata('custom', $custom); $clientToken = Braintree_ClientToken::generate(array()); if ($clientToken == '401') { $username = $this->dx_auth->get_username(); $list_title = $this->Common_model->getTableData('list', array('id' => $id))->row()->title; $email = $this->Common_model->getTableData('users', array('id' => $this->dx_auth->get_user_id()))->row()->email; $admin_email = $this->Common_model->getTableData('users', array('id' => 1))->row()->email; $admin_email_from = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $email_name = 'payment_issue_to_admin'; $splVars = array("{payment_type}" => 'Braintree', "{site_name}" => $this->dx_auth->get_site_title(), "{username}" => ucfirst($username), "{list_title}" => $list_title, '{email_id}' => $email); $this->Email_model->sendMail($admin_email, $admin_email_from, ucfirst($admin_name), $email_name, $splVars); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate("Braintree business account is misconfigured. Please contact your Administrator."))); redirect('rooms/' . $id, "refresh"); } $data['title'] = "Payments"; $data["meta_keyword"] = ""; $data["meta_description"] = ""; $data['clientToken'] = $clientToken; $data['message_element'] = "payments/checkout"; $this->load->view('template', $data); }
function submission($param = '', $contact_key) { $checkin = $this->input->post('checkin'); $checkout = $this->input->post('checkout'); $number_of_guests = $this->input->post('number_of_guests'); $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); $pay = $this->Common_model->getTableData('paywhom', array('id' => 1)); $paywhom = $pay->result(); $paywhom = $paywhom[0]->whom; $id = $this->uri->segment(3); if ($ckin[0] == "mm") { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Access denied.'))); redirect('rooms/' . $id, "refresh"); } if ($ckout[0] == "mm") { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Access denied.'))); redirect('rooms/' . $id, "refresh"); } $xprice = $this->Common_model->getTableData('price', array('id' => $this->uri->segment(3)))->row(); $price = $xprice->night; //$price = $xprice->night; $placeid = $xprice->id; $guests = $xprice->guests; $extra_guest_price = $xprice->addguests; if (isset($xprice->cleaning)) { $cleaning = $xprice->cleaning; } else { $cleaning = 0; } if (isset($xprice->security)) { $security = $xprice->security; } else { $security = 0; } 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)); $q = $query->result(); $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]); $days = ceil($diff / (3600 * 24)); $user_travel_cretids = 0; if ($this->session->userdata('travel_cretids')) { $amt = $this->session->userdata('travel_cretids'); $user_travel_cretids = $this->session->userdata('user_travel_cretids'); $is_travelCretids = md5('Yes Travel Cretids'); } else { if ($number_of_guests > $guests) { $diff_days = $number_of_guests - $guests; $amt = $price * $days + $days * $xprice->addguests * $diff_days; } else { $amt = $price * $days; } if ($days >= 7 && $days < 30) { if (!empty($Wprice)) { $finalAmount = $Wprice; $differNights = $days - 7; $perDay = $Wprice / 7; $per_night = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Wprice + $addAmount; } $amt = $finalAmount; } } if ($days >= 30) { if (!empty($Mprice)) { $finalAmount = $Mprice; $differNights = $days - 30; $perDay = $Mprice / 30; $per_night = round($perDay, 2); if ($differNights > 0) { $addAmount = $differNights * $per_night; $finalAmount = $Mprice + $addAmount; } $amt = $finalAmount; } } //Cleaning fee if ($cleaning != 0) { $amt = $amt + $cleaning; } if ($security != 0) { $amt = $amt + $cleaning; } else { $amt = $amt; } $to_pay = 0; $admin_commission = 0; //Amount from session // $amt=$this->session->userdata("total_price_'".$id."'_'".$this->dx_auth->get_user_id()."'"); //commission calculation $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $to_pay = $amt; $fix = $row->fixed_amount; $amt = $amt + $fix; //$amt = $this->session->userdata('topay'); $admin_commission = $fix; } else { $to_pay = $amt; $per = $row->percentage_amount; $camt = floatval($amt * $per / 100); $amt = $amt + $camt; $amt = $amt; $admin_commission = $camt; } } else { $amt = $amt; $to_pay = $amt; } $is_travelCretids = md5('No Travel Cretids'); } //echo $amt;exit; if ($contact_key != '') { $contact_result = $this->db->where('contact_key', $contact_key)->get('contacts')->row(); $amt = $contact_result->price + $contact_result->admin_commission; } if ($amt > 110) { if ($this->db->select('referral_amount')->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount != 0) { $referral_amount = $this->db->select('referral_amount')->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount; if ($referral_amount > 100) { $final_amt = get_currency_value1($id, $amt) - get_currency_value(100); } else { $final_amt = $amt - $referral_amount; } $amt = $final_amt; } else { $amt = $amt; } } else { $amt = $amt; } if ($contact_key == "") { $contact_key = "None"; } //Entering it into data variables $row = $this->Common_model->getTableData('payment_details', array('code' => 'PAYPAL_ID'))->row(); $paymode = $this->db->where('payment_name', 'Paypal')->get('payments')->row()->is_live; $custom = $id . '@' . $this->dx_auth->get_user_id() . '@' . get_gmt_time(strtotime($checkin)) . '@' . get_gmt_time(strtotime($checkout)) . '@' . $number_of_guests . '@' . $is_travelCretids . '@' . $user_travel_cretids . '@' . get_currency_value1($id, $to_pay) . '@' . get_currency_value1($id, $admin_commission) . '@' . $contact_key . '@' . get_currency_value1($id, $cleaning) . '@' . get_currency_value1($id, $security) . '@' . get_currency_value1($id, $extra_guest_price) . '@' . $guests; $this->session->set_userdata('custom', $custom); if ($this->session->userdata('final_amount') != '') { $amt = $this->session->userdata('final_amount'); $this->session->unset_userdata('final_amount'); } else { $amt = get_currency_value1($id, $amt); } $to_buy = array('desc' => 'Purchase from ACME Store', 'currency' => get_currency_code(), 'type' => 'sale', 'return_URL' => site_url('payments/paypal_success'), 'cancel_URL' => site_url('payments/paypal_cancel'), 'shipping_amount' => 0, 'get_shipping' => false); // I am just iterating through $this->product from defined // above. In a live case, you could be iterating through // the content of your shopping cart. //foreach($this->product as $p) { $temp_product = array('name' => $this->dx_auth->get_site_title() . ' Transaction', 'number' => $placeid, 'quantity' => 1, 'amount' => $amt); // add product to main $to_buy array $to_buy['products'][] = $temp_product; //} // enquire Paypal API for token $set_ec_return = $this->paypal_ec->set_ec($to_buy); if (isset($set_ec_return['ec_status']) && $set_ec_return['ec_status'] === true) { // redirect to Paypal $this->paypal_ec->redirect_to_paypal($set_ec_return['TOKEN']); // You could detect your visitor's browser and redirect to Paypal's mobile checkout // if they are on a mobile device. Just add a true as the last parameter. It defaults // to false // $this->paypal_ec->redirect_to_paypal( $set_ec_return['TOKEN'], true); } else { $this->_error($set_ec_return); } }
public function filter() { //$roomid = $this->input->get('roomid'); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $guest = $this->input->get('guest'); $room_type = $this->input->get('room_type'); $price = $this->input->get('price'); $amenities = $this->input->get('amenities'); $beds = $this->input->get('beds'); $bedrooms = $this->input->get('bedrooms'); $bathrooms = $this->input->get('bathrooms'); $data1['checkin'] = get_gmt_time(strtotime($checkin)); $data1['checkout'] = get_gmt_time(strtotime($checkout)); $query = $this->db->query('select * from `list` where `capacity` = "' . $guest . '" AND `room_type` = "' . $room_type . '" AND `price` = "' . $price . '" AND `amenities` = "' . $amenities . '" AND `beds` = "' . $beds . '" AND `bedrooms` = "' . $bedrooms . '" AND `bathrooms` = "' . $bathrooms . '"'); //print_r($this->db->last_query()); if ($query->num_rows() != 0) { foreach ($query->result() as $row) { $data['id'] = $row->id; $data['user_id'] = $row->user_id; $data['country'] = $row->country; $data['city'] = $row->city; $data['state'] = $row->state; $data['room_type'] = $row->room_type; $data['email'] = $this->db->where('id', $data['user_id'])->get('profiles')->row('email'); $data['title'] = $row->title; $data['price'] = $row->price; $data['capacity'] = $row->capacity; $data['currency'] = $row->currency; $data['currency_symbol'] = $this->db->where('currency_code', $data['currency'])->get('currency')->row('currency_symbol'); $data['image'] = $this->db->where('list_id', $data['id'])->get('list_photo')->row('image'); $data['src'] = $this->db->where('email', $data['email'])->get('profile_picture')->row('src'); $fil[] = $data; } echo json_encode($fil); } else { echo '[{"status":"No List Found"}]'; } }
public function ajax_get_results() { $this->load->library("Ajax_pagination"); //get starred list status $star = $this->input->get('starred'); //Get the checkin and chekout dates $checkin = ''; $checkout = ''; $stack = array(); $room_types = array(); $property_type_id = array(); $this->session->set_userdata('ajax_search_location', $this->input->get('location')); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $nof_guest = $this->input->get('guests'); $room_types = $this->input->get('room_types'); $this->session->set_userdata('Vcheckin', $checkin); $this->session->set_userdata('Vcheckout', $checkout); $this->session->set_userdata('Vnumber_of_guests', $nof_guest); $search_view = $this->input->get('search_view'); $min = $this->input->get('price_min'); $max = $this->input->get('price_max'); $keywords = $this->input->get('keywords'); $search_by_map = $this->input->get('search_by_map'); $sw_lat = $this->input->get('sw_lat'); $sw_lng = $this->input->get('sw_lng'); $ne_lat = $this->input->get('ne_lat'); $ne_lng = $this->input->get('ne_lng'); $min_bedrooms = $this->input->get('min_bedrooms'); $property_type = $this->input->get('property_type'); $min_bathrooms = $this->input->get('min_bathrooms'); $min_beds = $this->input->get('min_beds'); $min_bed_type = $this->input->get('min_bed_type'); $instance_book = $this->input->get('instance_book'); $property_type_id = $this->input->get('property_type_id'); $hosting_amenities = $this->input->get('hosting_amenities'); $page = $this->input->get('page'); $sort = $this->input->get('sort'); $lat = $this->session->userdata('lat'); $lng = $this->session->userdata('lng'); /*if(empty($sort)) { $sort = 1; }*/ $data['page'] = $page; if ($checkin != '--' && $checkout != '--' && $checkin != "yy-mm-dd" && $checkout != "yy-mm-dd") { // Specify the start date. This date can be any English textual format $date_from = $checkin; $date_from = strtotime($date_from); // Convert date to a UNIX timestamp // Specify the end date. This date can be any English textual format $date_to = $checkout; $date_to = strtotime($date_to); // Convert date to a UNIX timestamp $arr = array(); // Loop from the start date to end date and output all dates inbetween for ($i = $date_from; $i <= $date_to; $i += 86400) { $arr[] = $i; } $ans = $this->db->query("SELECT id,list_id FROM `calendar` WHERE `booked_days` = '" . get_gmt_time(strtotime($checkin)) . "' OR `booked_days` = '" . get_gmt_time(strtotime($checkout)) . "' GROUP BY `list_id`"); if ($ans->num_rows() == 0) { $ans = $this->db->where_in('booked_days', $arr)->group_by('list_id')->get('calendar'); } $a = $ans->result(); $this->db->flush_cache(); // Now after the checkin is completed if (!empty($a)) { foreach ($a as $a1) { array_push($stack, $a1->list_id); } } } $condition = ''; $location = $this->input->get('location'); $FileName = str_replace("'", "", $location); $FileName4 = str_replace("-", "", $FileName); //$FileName5 = str_replace(" ", ",", $FileName4); $pieces = explode(",", $FileName4); $print = ""; $len = count($pieces); $condition .= "(`status` != '0')"; if ($search_by_map) { $condition .= "AND (`lat` BETWEEN {$sw_lat} AND {$ne_lat}) AND (`long` BETWEEN {$sw_lng} AND {$ne_lng})"; } else { if ($location != '') { $i = 1; //$condition .= " AND (`address` LIKE '%".$pieces[0]."%')"; $condition .= " AND ((`address` LIKE '%" . $pieces[0] . "%') OR (`state` LIKE '%" . $pieces[0] . "%') OR (`city` LIKE '%" . $pieces[0] . "%') OR (`country` LIKE '%" . $pieces[0] . "%') OR (`desc` LIKE '%" . $pieces[0] . "%') OR (`room_type` LIKE '%" . $pieces[0] . "%') OR (`title` LIKE '%" . $pieces[0] . "%') )"; } } if (!empty($min_bedrooms)) { $condition .= " AND (`bedrooms` = '" . $min_bedrooms . "')"; } if ($property_type != 0) { $condition .= " AND (`property_id` = '" . $property_type . "')"; } if (!empty($min_bathrooms)) { $condition .= " AND (`bathrooms` = '" . $min_bathrooms . "')"; } if (!empty($min_beds)) { $condition .= " AND (`beds` = '" . $min_beds . "')"; } if (!empty($instance_book)) { $condition .= " AND (`instance_book` = '1')"; } if (!empty($min_bed_type)) { $condition .= " AND (`bed_type` = '" . $min_bed_type . "')"; } if (!empty($stack)) { $condition .= " AND (`id` NOT IN(" . implode(',', $stack) . "))"; } if ($nof_guest > 1) { $condition .= " AND (`capacity` >= '" . $nof_guest . "')"; } if (is_array($room_types)) { if (count($room_types) > 0) { $i = 1; foreach ($room_types as $room_type) { if ($i == count($room_types)) { $and = ""; } else { $and = " AND "; } $or = " OR "; if ($i == 1) { $condition .= " AND ("; } $condition .= "`room_type` LIKE '%" . $room_type . "%'" . $or . "`neighbor` = '" . $room_type . "'" . $or . "`neighbor` = '" . $room_type . "'" . $or . "`room_type` = '" . $room_type . "'" . $or . "`room_type` = '" . $room_type . "'" . $and; if ($i == count($room_types)) { $condition .= ")"; } $i++; } } } if (is_array($hosting_amenities)) { if (count($hosting_amenities) > 0) { $i = 1; foreach ($hosting_amenities as $amenity) { if ($i == count($hosting_amenities)) { $and = ""; } else { $and = " AND "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`amenities` LIKE '%" . $amenity . "%'" . $and; if ($i == count($hosting_amenities)) { $condition .= ")"; } $i++; } } } if (is_array($property_type_id)) { if (count($property_type_id) > 0) { $i = 1; foreach ($property_type_id as $property_id) { if ($i == count($property_type_id)) { $and = ""; } else { $and = " OR "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`property_id` = '" . $property_id . "'" . $and; if ($i == count($property_type_id)) { $condition .= ")"; } $i++; } } } if (!empty($keywords)) { $keywords = $this->db->escape_like_str($keywords); $condition .= " AND (`address` LIKE '%" . $keywords . "%' OR `title` LIKE '%" . $keywords . "%' OR `desc` LIKE '%" . $keywords . "%')"; } //Final query $condition .= " AND (`status` != '0') AND (`user_id` != '0') AND (`address` != '0') AND (`is_enable` = '1') AND (`banned` = '0')"; // Get offset and limit for page viewing $start = (int) $page; // Number of record showing per page $per_page = 20; if ($start > 0) { $offset = ($start - 1) * $per_page; } else { $offset = $start * $per_page; } if ($sort == 2) { $order = "ORDER BY price ASC"; } else { if ($sort == 3) { $order = "ORDER BY price DESC"; } else { if ($sort == 4) { $order = "ORDER BY id DESC"; } else { $order = "ORDER BY id ASC"; } } } $query_status = $this->db->where($condition)->get('list'); if ($query_status->num_rows() != 0) { foreach ($query_status->result() as $row_status) { $result_status = $this->db->where('id', $row_status->id)->get('lys_status'); if ($result_status->num_rows() != 0) { $result_status = $result_status->row(); $total = $result_status->calendar + $result_status->price + $result_status->overview + $result_status->photo + $result_status->address + $result_status->listing; if ($total != 6) { $condition .= " AND (`id` != '" . $row_status->id . "')"; } } } } if ($min == '' && $max == '') { } else { $query_price = $this->db->where($condition)->get('list'); if ($query_price->num_rows() != 0) { foreach ($query_price->result() as $row_price) { $check_price = get_currency_value1($row_price->id, $row_price->price); $max = get_currency_value_lys(get_currency_code(), 'USD', $max); if ($max == 10000) { $max = $max * 1000000000; $max = get_currency_value1($row_price->id, $max); } else { $max = get_currency_value_lys('USD', get_currency_code(), $max); } //echo $max. ' - '.$check_price;exit; if ($this->input->get('new_search')) { if ($check_price <= $max && $check_price >= $min) { } else { $condition .= " AND (`id` != '" . $row_price->id . "')"; } } else { if ($check_price <= $max || $check_price >= $min) { } else { $condition .= " AND (`id` != '" . $row_price->id . "')"; } } } } } //My ShortLists if ($search_view == 2) { $constraint = ""; $shortlists = $this->db->where('id', $this->dx_auth->get_user_id())->get('users')->row()->shortlist; $my_lists = explode(',', $shortlists); $i = 1; foreach ($my_lists as $list) { if ($i == count($my_lists)) { $OR = ""; } else { $OR = " OR "; } $data['query'] = $this->db->query("SELECT * FROM (`list`) WHERE {$condition} {$order} LIMIT {$offset},{$per_page}"); if ($data['query']->num_rows() != 0) { foreach ($data['query']->result() as $row) { if ($row->id == $list) { $constraint .= "`id`= '" . $list . "'" . $OR; } else { } } } $i++; } if ($constraint == '') { $data['query'] = $this->db->query("SELECT * FROM (`list`) where {$condition} AND id=0 {$order} LIMIT {$offset},{$per_page}"); $total_rows = 0; } else { $data['query'] = $this->db->query("SELECT * FROM (`list`) where {$condition} AND {$constraint} {$order} LIMIT {$offset},{$per_page}"); $total_rows = $this->db->query("SELECT * FROM (`list`) where {$condition} AND {$constraint}")->num_rows(); } } else { $data['query'] = $this->db->query("SELECT * FROM (`list`) WHERE {$condition} {$order} LIMIT {$offset},{$per_page}"); $this->session->unset_userdata('query'); $this->session->set_userdata('query', "SELECT * FROM (`list`) WHERE {$condition} ORDER BY id DESC"); $total_rows = $this->db->query("SELECT * FROM (`list`) WHERE {$condition}")->num_rows(); } //echo $this->db->last_query();exit; $config['base_url'] = site_url('search') . '?checkin=' . urlencode($checkin) . '&checkout=' . urlencode($checkout) . '&guests=' . $nof_guest . '&location=' . urlencode($location) . '&min_bathrooms=' . $min_bathrooms . '&min_bedrooms=' . $min_bedrooms . '&min_beds=' . $min_beds . '&min_bed_type=' . $min_bed_type . '&per_page=' . $per_page . '&search_view=1&sort=' . $sort . '&lat=' . $lat . '&lng=' . $lng; $config['per_page'] = $per_page; $config['cur_page'] = $start; $config['total_rows'] = $total_rows; $this->ajax_pagination->initialize($config); $pagination = $this->ajax_pagination->create_links(false); $tCount = $data['query']->num_rows(); $properties = ''; $sno = 1; foreach ($data['query']->result() as $row) { //main photo $url = getListImage($row->id); //for map slider full list images $images = $this->Gallery->get_imagesG($row->id); $picture_ids = ''; foreach ($images->result() as $image) { $picture_ids .= '"' . $image->list_id . '/' . $image->name . '",'; } $profile_pic = $this->Gallery->profilepic($row->user_id, 2); if ($tCount == $sno) { $comma = ''; } else { $comma = ','; } $neighbor = $row->neighbor; $final_price = get_currency_value1($row->id, $row->price); if ($final_price <= $max && $final_price >= $min) { } /*Offer price calculate*/ if ($checkin != '--' && $checkout != '--' && $checkin != "yy-mm-dd" && $checkout != "yy-mm-dd") { $daysdiff = (strtotime($checkout) - strtotime($checkin)) / (60 * 60 * 24); } //My shortlist $short_listed = 0; $cur_user_id = $this->dx_auth->get_user_id(); if ($cur_user_id) { $wishlist_result = $this->Common_model->getTableData('user_wishlist', array('user_id' => $cur_user_id)); if ($wishlist_result->num_rows() != 0) { foreach ($wishlist_result->result() as $wishlist) { if ($wishlist->list_id == $row->id) { $short_listed = 1; } } } } ///// review count $conditions_starrev = array('list_id' => $row->id, 'userto' => $row->user_id); $result_rev = $this->Trips_model->get_review($conditions_starrev); $overall_review_count = $result_rev->num_rows(); ////// star rating display $conditions_star = array('list_id' => $row->id, 'userto' => $row->user_id); $data['stars'] = $this->Trips_model->get_review_sum($conditions_star)->row(); if ($overall_review_count > 0) { $accuracy = $data['stars']->accuracy * 2 * 10 / $overall_review_count; $cleanliness = $data['stars']->cleanliness * 2 * 10 / $overall_review_count; $communication = $data['stars']->communication * 2 * 10 / $overall_review_count; $checkin = $data['stars']->checkin * 2 * 10 / $overall_review_count; $location = $data['stars']->location * 2 * 10 / $overall_review_count; $value = $data['stars']->value * 2 * 10 / $overall_review_count; $overall = ($accuracy + $cleanliness + $communication + $checkin + $location + $value) / 6; } else { $overall = 0; } /*$slider = '<ul class="rslides" id="slider'.$row->id.'">'; $conditions = array("list_id" =>$row->id); $image = $this->Gallery->get_imagesG(NULL, $conditions); $j = 0; if($image->num_rows() != 0) { foreach($image->result() as $image_list) { $j++; $image = base_url()."images/".$image_list->list_id."/".$image_list->name; $slider .='<li data="'.$j.'"> <img width="216" height="144" data="'.$j.'" alt="" src="'.$image.'" style="position: absolute; top: 0px; left: 0px; z-index: 2; opacity: 1;height:130px !important"> </li>'; } } $slider .= '</ul>';*/ /*end of offer calculate */ // Discount label 1 start //echo $instance_book; exit; $dis_price = $this->Common_model->getTableData('price', array('id' => $row->id))->row(); $d_price = $dis_price->previous_price; if ($dis_price->night < $d_price) { $discount_amt = ($d_price - $dis_price->night) / $d_price * 100; $discount = round($discount_amt) . '%'; } else { $discount = 0; } // Discount label 1 end $properties .= '{ "user_thumbnail_url":"' . $profile_pic . '", "user_is_superhost":false, "lat":' . $row->lat . ', "has_video":false, "room_type":"' . $row->room_type . '", "recommendation_count":0, "lng":' . $row->long . ', "user_id":' . $row->user_id . ', "user_name":"' . get_user_by_id($row->user_id)->username . '", "symbol":"' . get_currency_symbol($row->id) . '", "currency_code":"' . get_currency_code() . '", "review_count":' . $row->review . ', "address":"' . $row->address . '", ' . ' "discount":"' . $discount . '", ' . ' "state":"' . $row->state . '", "city":"' . $row->city . '", "instant_book":"' . $row->instance_book . '", "name":"' . $row->title . '", "picture_ids":[' . substr($picture_ids, 0, -1) . '], "hosting_thumbnail_url":"' . $url . '", "id":' . $row->id . ', "page_viewed":' . $row->page_viewed . ', "price":' . $final_price . ', ' . ' ' . ' "short_listed":' . $short_listed . ' }' . $comma; // Discount label 1 end (Replace) $sno++; } $startlist = 1 + $offset; $endlist = $offset + $per_page; if ($total_rows == 0) { $startlist = 0; } if ($endlist > $total_rows) { $endlist = $total_rows; } $ajax_result = '{ "results_count_html":"\\n<b>' . $startlist . ' – ' . $endlist . '</b> of <b>' . $total_rows . ' Rentals</b>", "results_count_top_html":" ' . $total_rows . ' ' . translate('Rentals') . ' - ' . $pieces[0] . '\\n", "view_type":' . $search_view . ', "results_pagination_html":"' . $pagination . '\\n", "present_standby_option":false, "lat":"' . $lat . '", "lng":"' . $lng . '", "properties":['; $ajax_result .= $properties; $ajax_result .= '], "banner_info":{} }'; echo $ajax_result; }
if (isset($_POST['all_day_event'])) { $all_day_event = '1'; $start_hour = '0'; $start_min = '0'; $end_hour = '0'; $end_min = '0'; $start_time = date_to_unixtime($_POST['start_date'] . ' ' . $start_hour . ':' . $start_min); $end_time = date_to_unixtime($_POST['end_date'] . ' ' . $end_hour . ':' . $end_min); } else { $all_day_event = '0'; $start_min = $_POST['start_min']; $start_hour = $_POST['start_hour']; $end_hour = $_POST['end_hour']; $end_min = $_POST['end_min']; $start_time = get_gmt_time(date_to_unixtime($_POST['start_date'] . ' ' . $start_hour . ':' . $start_min)); $end_time = get_gmt_time(date_to_unixtime($_POST['end_date'] . ' ' . $end_hour . ':' . $end_min)); } if ($_POST['repeat_type'] != REPEAT_NONE) { $repeat_end_time = isset($_POST['repeat_forever']) ? '0' : date_to_unixtime($_POST['repeat_end_date']); } else { $repeat_end_time = 0; } $shift_day = 0; //shift the selected weekdays to GMT time if (!isset($_POST['all_day_event'])) { $shifted_start_hour = $start_hour - $timezone_offset; if ($shifted_start_hour > 23) { $shifted_start_hour = $shifted_start_hour - 24; $shift_day = 1; } elseif ($shifted_start_hour < 0) { $shifted_start_hour = 24 + $shifted_start_hour;
?> </span> <br><br><span class="endcap"><b><?php echo get_currency_symbol($list_id) . " " . get_currency_value1($list_id, $price); ?> </b></span> </td> <?php } else { $full_date = $next_month . '/' . $day_nextmonth . '/' . $next_year; $pre_schedules = '<td id="day_' . $i . '" class="realday available"> <span class="dom">' . $day_nextmonth . '</span><br><br><span class="endcap"><b>' . get_currency_symbol($list_id) . ' ' . get_currency_value1($list_id, $price) . '</b></span> </td>'; foreach ($result as $row) { if (get_gmt_time(strtotime($full_date)) == $row->booked_days) { $pre_schedules = '<td id="day_' . $i . '" class="realday unavailable"> <span class="dom">' . $day_nextmonth . '</span><br><br><span class="endcap"><b>' . get_currency_symbol($list_id) . ' ' . get_currency_value1($list_id, $price) . '</b></span> </td>'; } } echo $pre_schedules; } $day_count++; $day_nextmonth++; $i++; $j++; if ($k == 7) { $k = 0; echo '</tr>'; }
public function expire($id) { $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $reservation_id = $id; $conditions = array('reservation.id' => $reservation_id); $row = $this->Trips_model->get_reservation($conditions)->row(); $date = date("F j, Y, g:i a"); $date = get_gmt_time(strtotime($date)); $timestamp = $row->book_date; $book_date = date("F j, Y, g:i a", $timestamp); $book_date = strtotime($book_date); $gmtTime = get_gmt_time(strtotime('+1 day', $timestamp)); if ($gmtTime <= $date && $row->status == 1) { $query1 = $this->Users_model->get_user_by_id($row->userby); $traveler_name = $query1->row()->username; $traveler_email = $query1->row()->email; $query2 = $this->Users_model->get_user_by_id($row->userto); $host_name = $query2->row()->username; $host_email = $query2->row()->email; $list_title = $this->Common_model->getTableData('list', array('id' => $row->list_id))->row()->title; //Send Message Notification $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userto, 'userto' => $row->userby, 'message' => "Sorry, Your reservation request is expired by {$host_name} for {$list_title}.", 'created' => local_to_gmt(), 'message_type ' => 2); $this->Message_model->sentMessage($insertData); $message_id = $this->db->insert_id(); $updateData1['is_respond'] = 1; $updateKey1['reservation_id'] = $reservation_id; $updateKey1['userto'] = $row->userto; $this->Message_model->updateMessage($updateKey1, $updateData1); $updateKey = array('id' => $reservation_id); $updateData = array(); $updateData['status '] = 2; $this->Trips_model->update_reservation($updateKey, $updateData); // payment_helper called for refund amount for host and guest as per host and guest cancellation policy refund($reservation_id); $price = $x->row()->price; $currencycode = $x->row()->currency; $currency = $this->Common_model->getTableData('currency', array('currency_code' => $currencycode))->row()->currency_symbol; $checki = $x->row()->checkin; $checkin = date("F j, Y", $checki); $checko = $x->row()->checkout; $checkout = date("F j, Y", $checko); //Send Mail To Traveller $email_name = 'traveler_reservation_expire'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name), "{price}" => $price, "{currency}" => $currency, "{checkin}" => $checkin, "{checkout}" => $checkout, "{type}" => 'Reservation'); $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Host $email_name = 'host_reservation_expire'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name), "{price}" => $price, "{currency}" => $currency, "{checkin}" => $checkin, "{checkout}" => $checkout, "{type}" => 'Reservation'); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); if ($host_email != $admin_email && $traveler_email != $admin_email) { //Send Mail To Administrator $email_name = 'admin_reservation_expire'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name), "{price}" => $price, "{currency}" => $currency, "{checkin}" => $checkin, "{checkout}" => $checkout, "{type}" => 'Reservation'); $this->Email_model->sendMail($admin_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } } }
<div class="tile_container"> <div class="day"><?php echo $day_nextmonth; ?> </div> <div class="line_reg" id="square_<?php echo $i; ?> "> <span class="startcap"></span> <span class="content"></span> <span class="endcap"></span> </div> </div> </div> <?php } else { //seasonal rate $date = $next_month . '/' . $day_nextmonth . '/' . $next_year; $price = getDailyPrice($list_id, get_gmt_time(strtotime($date)), $list_price); ?> <div class="tile" id="tile_<?php echo $i; ?> " onMouseDown="click_down(<?php echo $i; ?> );" onMouseUp="click_up(<?php echo $i; ?> );" onMouseOver="range_add(<?php echo $i; ?> );" onMouseOut="range_remove(<?php echo $i;
$link_back = isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '' ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI']; $db = new db(); switch ($task) { case 'send': if ($_REQUEST['message'] == '') { $feedback .= 'Message is empty'; } else { if ($receipient_id > 0) { if ($db->query("SELECT * FROM messages_users WHERE user_id='{$receipient_id}'") && $db->next_record()) { $has_permission = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $db->f('acl_write')); } else { $has_permission = true; } if ($has_permission) { $msg_id = $db->nextid("messages_messages"); $db->query("INSERT INTO messages_messages (id,user_id,sender_id,ctime, text) VALUES ('{$msg_id}','{$receipient_id}','{$GO_SECURITY->user_id}','" . get_gmt_time() . "','" . smart_addslashes($_REQUEST['message']) . "')"); $db->query("INSERT INTO messages_new (id) VALUES ('{$msg_id}')"); } else { $feedback .= "You are not allowed to send message to the receipient"; } } else { $feedback .= 'You did not specify receipient'; } } break; case 'delete': if (is_array($_REQUEST['msgs'])) { $db->query("DELETE FROM messages_messages WHERE id in (" . implode(',', $_REQUEST['msgs']) . ")"); $db->query("DELETE FROM messages_new WHERE id in (" . implode(',', $_REQUEST['msgs']) . ")"); } break;
public function ajax_get_results() { $this->load->library("Ajax_pagination"); //get starred list status $star = $this->input->get('starred'); //Get the checkin and chekout dates $checkin = ''; $checkout = ''; $stack = array(); $room_types = array(); $property_type_id = array(); $this->session->set_userdata('ajax_search_location', $this->input->get('location')); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $nof_guest = $this->input->get('guests'); $room_types = $this->input->get('room_types'); $search_view = $this->input->get('search_view'); $min = $this->input->get('price_min'); $max = $this->input->get('price_max'); $keywords = $this->input->get('keywords'); $search_by_map = $this->input->get('search_by_map'); $sw_lat = $this->input->get('sw_lat'); $sw_lng = $this->input->get('sw_lng'); $ne_lat = $this->input->get('ne_lat'); $ne_lng = $this->input->get('ne_lng'); $min_bedrooms = $this->input->get('min_bedrooms'); $property_type = $this->input->get('property_type'); $min_bathrooms = $this->input->get('min_bathrooms'); $min_beds = $this->input->get('min_beds'); $min_bed_type = $this->input->get('min_bed_type'); $property_type_id = $this->input->get('property_type_id'); $hosting_amenities = $this->input->get('hosting_amenities'); $page = $this->input->get('page'); $sort = $this->input->get('sort'); /* if(empty($sort)) { $sort = 1; } */ $data['page'] = $page; if ($checkin != '--' && $checkout != '--' && $checkin != "yy-mm-dd" && $checkout != "yy-mm-dd") { // Specify the start date. This date can be any English textual format $date_from = $checkin; $date_from = strtotime($date_from); // Convert date to a UNIX timestamp // Specify the end date. This date can be any English textual format $date_to = $checkout; $date_to = strtotime($date_to); // Convert date to a UNIX timestamp $arr = array(); // Loop from the start date to end date and output all dates inbetween for ($i = $date_from; $i <= $date_to; $i += 86400) { $arr[] = $i; } $ans = $this->db->query("SELECT id,list_id FROM `calendar` WHERE `booked_days` = '" . get_gmt_time(strtotime($checkin)) . "' OR `booked_days` = '" . get_gmt_time(strtotime($checkout)) . "' GROUP BY `list_id`"); if ($ans->num_rows() == 0) { $ans = $this->db->where_in('booked_days', $arr)->group_by('list_id')->get('calendar'); } $a = $ans->result(); $this->db->flush_cache(); // Now after the checkin is completed if (!empty($a)) { foreach ($a as $a1) { array_push($stack, $a1->list_id); } } } $condition = ''; $location = $this->input->get('location'); $pieces = explode(",", $location); $print = ""; $len = count($pieces); $condition .= "(`status` != '0')"; if ($search_by_map) { $condition .= "AND (`lat` BETWEEN {$sw_lat} AND {$ne_lat}) AND (`long` BETWEEN {$sw_lng} AND {$ne_lng})"; } else { if ($location != '') { $i = 1; foreach ($pieces as $address) { $this->db->flush_cache(); $address = $this->db->escape_like_str($address); if ($i == $len) { $and = ""; } else { $and = " AND "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`address` LIKE '%" . $address . "%' OR `neighbor` LIKE '%" . $address . "%'" . $and; if ($i == $len) { $condition .= ")"; } $i++; } } } if (!empty($min_bedrooms)) { $condition .= " AND (`bedrooms` = '" . $min_bedrooms . "')"; } if ($property_type != 1) { $condition .= " AND (`property_id` = '" . $property_type . "')"; } if (!empty($min_bathrooms)) { $condition .= " AND (`bathrooms` = '" . $min_bathrooms . "')"; } if (!empty($min_beds)) { $condition .= " AND (`beds` = '" . $min_beds . "')"; } if (!empty($min_bed_type)) { $condition .= " AND (`bed_type` = '" . $min_bed_type . "')"; } if (!empty($stack)) { $condition .= " AND (`id` NOT IN(" . implode(',', $stack) . "))"; } if ($nof_guest > 1) { $condition .= " AND (`capacity` >= '" . $nof_guest . "')"; } if (is_array($room_types)) { if (count($room_types) > 0) { $i = 1; foreach ($room_types as $room_type) { if ($i == count($room_types)) { $and = ""; } else { $and = " AND "; } $or = " OR "; if ($i == 1) { $condition .= " AND ("; } $condition .= "`room_type` = '" . $room_type . "'" . $or . "`neighbor` = '" . $room_type . "'" . $or . "`neighbor` = '" . $room_type . "'" . $or . "`room_type` = '" . $room_type . "'" . $or . "`room_type` = '" . $room_type . "'" . $and; if ($i == count($room_types)) { $condition .= ")"; } $i++; } } } if (is_array($hosting_amenities)) { if (count($hosting_amenities) > 0) { $i = 1; foreach ($hosting_amenities as $amenity) { if ($i == count($hosting_amenities)) { $and = ""; } else { $and = " AND "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`amenities` LIKE '%" . $amenity . "%'" . $and; if ($i == count($hosting_amenities)) { $condition .= ")"; } $i++; } } } if (isset($min)) { if ($min > 0) { $condition .= " AND (`price` >= '" . $min . "')"; } } else { if (isset($max)) { $min = 0; } } if (isset($max)) { if ($max > $min) { $condition .= " AND (`price` <= '" . $max . "')"; } } if (is_array($property_type_id)) { if (count($property_type_id) > 0) { $i = 1; foreach ($property_type_id as $property_id) { if ($i == count($property_type_id)) { $and = ""; } else { $and = " OR "; } if ($i == 1) { $condition .= " AND ("; } $condition .= "`property_id` = '" . $property_id . "'" . $and; if ($i == count($property_type_id)) { $condition .= ")"; } $i++; } } } if (!empty($keywords)) { $keywords = $this->db->escape_like_str($keywords); $condition .= " AND (`address` LIKE '%" . $keywords . "%' OR `title` LIKE '%" . $keywords . "%' OR `desc` LIKE '%" . $keywords . "%')"; } //Final query $condition .= " AND (`status` != '0') AND (`user_id` != '0') AND (`address` != '0') AND (`is_enable` = '1')"; // Get offset and limit for page viewing $start = (int) $page; // Number of record showing per page $per_page = 20; if ($start > 0) { $offset = ($start - 1) * $per_page; } else { $offset = $start * $per_page; } if ($sort == 2) { $order = "ORDER BY price ASC"; } else { if ($sort == 3) { $order = "ORDER BY price DESC"; } else { if ($sort == 4) { $order = "ORDER BY id DESC"; } else { $order = "ORDER BY id ASC"; } } } //My ShortLists if ($search_view == 2) { $constraint = ""; $shortlists = $this->db->where('id', $this->dx_auth->get_user_id())->get('users')->row()->shortlist; $my_lists = explode(',', $shortlists); $i = 1; foreach ($my_lists as $list) { if ($i == count($my_lists)) { $OR = ""; } else { $OR = " OR "; } $data['query'] = $this->db->query("SELECT * FROM (`list`) WHERE {$condition} {$order} LIMIT {$offset},{$per_page}"); if ($data['query']->num_rows() != 0) { foreach ($data['query']->result() as $row) { if ($row->id == $list) { $constraint .= "`id`= '" . $list . "'" . $OR; } else { } } } $i++; } if ($constraint == '') { $data['query'] = $this->db->query("SELECT * FROM (`list`) where {$condition} AND id=0 {$order} LIMIT {$offset},{$per_page}"); $total_rows = 0; } else { $data['query'] = $this->db->query("SELECT * FROM (`list`) where {$condition} AND {$constraint} {$order} LIMIT {$offset},{$per_page}"); $total_rows = $this->db->query("SELECT * FROM (`list`) where {$condition} AND {$constraint}")->num_rows(); } } else { $data['query'] = $this->db->query("SELECT * FROM (`list`) WHERE {$condition} {$order} LIMIT {$offset},{$per_page}"); $this->session->unset_userdata('query'); $this->session->set_userdata('query', "SELECT * FROM (`list`) WHERE {$condition} ORDER BY id DESC"); $total_rows = $this->db->query("SELECT * FROM (`list`) WHERE {$condition}")->num_rows(); } $config['base_url'] = site_url('search') . '?checkin=' . urlencode($checkin) . '&checkout=' . urlencode($checkout) . '&guests=' . $nof_guest . '&location=' . urlencode($location) . '&min_bathrooms=' . $min_bathrooms . '&min_bedrooms=' . $min_bedrooms . '&min_beds=' . $min_beds . '&min_bed_type=' . $min_bed_type . '&per_page=' . $per_page . '&search_view=1&sort=' . $sort; $config['per_page'] = $per_page; $config['cur_page'] = $start; $config['total_rows'] = $total_rows; $this->ajax_pagination->initialize($config); $pagination = $this->ajax_pagination->create_links(false); $tCount = $data['query']->num_rows(); $properties = ''; $sno = 1; foreach ($data['query']->result() as $row) { //main photo $url = getListImage($row->id); //for map slider full list images $images = $this->Gallery->get_imagesG($row->id); $picture_ids = ''; foreach ($images->result() as $image) { $picture_ids .= '"' . $image->list_id . '/' . $image->name . '",'; } $profile_pic = $this->Gallery->profilepic($row->user_id, 2); if ($tCount == $sno) { $comma = ''; } else { $comma = ','; } $neighbor = $row->neighbor; $final_price = get_currency_value1($row->id, $row->price); /* Offer price calculate */ if ($checkin != '--' && $checkout != '--' && $checkin != "yy-mm-dd" && $checkout != "yy-mm-dd") { $daysdiff = (strtotime($checkout) - strtotime($checkin)) / (60 * 60 * 24); } //My shortlist $short_listed = 0; $cur_user_id = $this->dx_auth->get_user_id(); if ($cur_user_id) { $shortlist = $this->Common_model->getTableData('users', array('id' => $cur_user_id))->row()->shortlist; $my = explode(',', $shortlist); foreach ($my as $list) { if ($list == $row->id) { $short_listed = 1; } } } /* end of offer calculate */ $properties .= '{ "user_thumbnail_url":"' . $profile_pic . '", "user_is_superhost":false, "lat":' . $row->lat . ', "has_video":false, "recommendation_count":0, "lng":' . $row->long . ', "user_id":' . $row->user_id . ', "user_name":"' . get_user_by_id($row->user_id)->username . '", "symbol":"' . get_currency_symbol($row->id) . '", "review_count":' . $row->review . ', "address":"' . $row->address . '", "name":"' . $row->title . '", "picture_ids":[' . substr($picture_ids, 0, -1) . '], "hosting_thumbnail_url":"' . $url . '", "id":' . $row->id . ', "page_viewed":' . $row->page_viewed . ', "price":' . $final_price . ', "short_listed":' . $short_listed . ' }' . $comma; $sno++; } $startlist = 1 + $offset; $endlist = $offset + $per_page; if ($endlist > $total_rows) { $endlist = $total_rows; } $ajax_result = '{ "results_count_html":"\\n<b>' . $startlist . ' – ' . $endlist . '</b> of <b>' . $total_rows . ' listings</b>", "results_count_top_html":" ' . $total_rows . ' ' . translate('results') . '\\n", "view_type":' . $search_view . ', "results_pagination_html":"' . $pagination . '\\n", "present_standby_option":false, "properties":['; $ajax_result .= $properties; $ajax_result .= '], "banner_info":{}, "sort":' . $sort . ' }'; echo $ajax_result; }