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); }
if ($count != 0) { echo $count . ' ' . translate("Listings"); } else { echo translate("N/A"); } ?> </h4> <ul> <?php if ($ans->num_rows > 0) { foreach ($ans->result() as $a) { $CI =& get_instance(); $distance = $CI->getDistanceBetweenPointsNew($lat, $long, $a->lat, $a->long); //echo $distance.'-'.$a->id;exit; if ($distance <= 15) { $url = getListImage($a->id); echo '<li> <div class="related_listing_left col-xs-4 col-sm-4 col-md-4"> <a href=' . base_url() . 'rooms/' . $a->id . ' id="related_listing_photo"><img alt="no image" height="56" src="' . $url . '" title="no image" width="71" /> </a> </div>'; echo '<div class="related_listing_right col-xs-8 col-sm-8 col-md-8">'; echo '<div class="distance">' . $distance . " Miles" . '</div>'; echo anchor('rooms/' . $a->id, $a->title); echo '<div class="subtitle">' . get_currency_symbol($a->id) . get_currency_value1($room_id, $a->price) . '/night <br />' . $a->room_type . '</div> </div>'; echo '<div class="clear"></div> </li>'; } } }
if (!empty($sort)) { if ($sort == "active") { echo 'Result >> Active Listings'; $this->db->where('is_enable', 1); } if ($sort == "hide") { echo 'Result >> Hidden Listings'; $this->db->where('is_enable', 0); } } $query = $this->db->select('list.*,lys_status.calendar as calendar_status,lys_status.overview as overview_status,lys_status.price as price_status,lys_status.photo as photo_status,lys_status.address as address_status,lys_status.listing as listing_status')->join('lys_status', "lys_status.id=list.id")->where("list.user_id", $id)->get('list'); if ($query->num_rows > 0) { ?> <?php foreach ($query->result() as $row) { $url = getListImage($row->id); echo '<li class="listing"><div class="thumbnail">'; echo '<a class="image_link" href="' . base_url() . 'rooms/' . $row->id . '" linkindex="98"><img title="' . $row->title . '" src="' . $url . '" class="search_thumbnail"></a> </div>'; echo '<div class="listing-info"><h3>'; echo anchor('rooms/' . $row->id, $row->title); echo '</h3>'; echo '<span class="actions"><span class="action_button">'; echo anchor('rooms/lys_next/edit/' . $row->id, translate("Edit Listing"), array('class' => 'icon edit')); echo '</span><span class="action_button">'; echo anchor('rooms/' . $row->id, translate("View Listing"), array('class' => 'icon view')); echo '</span><span class="action_button">'; echo anchor('calendar/single/' . $row->id, translate("View Calendar"), array('class' => 'icon calendar')); echo '</span><span class="action_button" onclick="return delete_list();">'; echo anchor('rooms/deletelisting/' . $row->id, translate("Delete Listing"), array('class' => 'icon delete')); echo '</span><span class="actions"><span class="action_button">'; echo anchor('statistics/view_statistics_graph/' . $row->id, translate("View statistics"), array('class' => 'icon edit'));
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; }
</div></li> </ul> <!-- <tr class="even" id="room_<?php echo $list->id; ?> "> <td class="place_image imgwidth"><a class="thumbnail" href="<?php echo base_url() . 'rooms/' . $list->id; ?> "><img width="75" height="50" title="Test room" src="<?php echo getListImage($list->id); ?> " alt="Test room"><span><img width="100" height="100" title="Test room" src="<?php echo getListImage($list->id); ?> " alt="Test room"></span></a> </td> <td class="main"><div class="first-line title"><a href="<?php echo base_url() . 'rooms/' . $list->id; ?> "><?php echo $list->title; ?> </a></div> <div><?php echo $list->address; ?> </div></td> </tr>-->
<?php if ($mosts->num_rows() != 0) { foreach ($mosts->result() as $row) { $profpic = $this->Gallery->profilepic($row->user_id, 1); $overall = getreviewoflist($row->user_id, $row->id); ?> <div class="clsSub_Most_View_Blk clearfix"> <div class="Sub_Most_View_Lft clsFloatLeft"> <a href="<?php echo site_url() . "rooms/" . $row->id; ?> "> <img src="<?php echo getListImage($row->id); ?> " alt="<?php echo $row->title; ?> " title="<?php echo $row->title; ?> " height="77" width="116" /> </a> <p><?php echo $row->review; ?> review</p> </div> <div class="Sub_Most_View_Rgt clsFloatRight">
echo translate("Please provide your billing details now and the place shall be booked for your purpose"); ?> </p> <div class="clear"></div> </div> </div> <div id="property_details" class="Box bookit_Box"> <div class="Box_Head bookhead"> <h2><?php echo translate("2. Property details"); ?> </h2> </div> <div class="Box_Content"> <img src="<?php echo getListImage($id); ?> " class="main_photo"/> <div id="hosting_details"> <h2><a href=<?php echo base_url() . 'rooms/' . $id; ?> target="_blank"><?php echo $tit; ?> </a></h2> <div id="hosting_address" class="rounded_more"> <?php //echo $address; ?>
<!-- Stylesheets --> <link href="<?php echo css_url(); ?> /edit_listing.css" media="screen" rel="stylesheet" type="text/css" /> <!-- End of inclusion of style sheets --> <!--Required Data from db --> <div class="container_bg" id="View_Edit_List"> <div id="View_Edit_Heading"> <div class="heading_content clearfix"> <div class="edit_listing_photo"> <?php $url = getListImage($room_id); ?> <img alt="Host_pic" height="65" src="<?php echo $url; ?> " /> </div> <div class="listing_info"> <h3><?php echo anchor('rooms/' . $room_id, $list->title, array('id' => "listing_title_banner")); ?> </h3> <?php echo anchor('rooms/' . $room_id, translate('View Listing'), array('class' => "clsLink2_Bg")); ?> <span id="availability-error-message"></span> </span> </div> <div class="edit_view_all_list"> <?php echo anchor('hosting', translate('View All Listing'), array('class' => 'btn large blue'));
function view_listing() { $user_id = $this->input->get('user_id'); $this->session->set_userdata('DX_user_id', $user_id); $result = $this->db->where('id', $user_id)->from('users')->get(); if ($result->num_rows() != 0) { $lists = $this->db->where('user_id', $user_id)->from('list')->get(); if ($lists->num_rows() != 0) { echo "["; foreach ($lists->result() as $row) { $search = array('\'', '"', '(', ')', '!', '{', '[', '}', ']', '<', '>'); $replace = array('&sq', '&dq', '&obr', '&cbr', '&ex', '&obs', '&oabr', '&cbs', '&cabr'); $desc_replace = str_replace($search, $replace, $row->desc); $desc_tags = stripslashes($desc_replace); $url = getListImage($row->id); $json[] = "{ \"room_id\":" . $row->id . ",\"title\":\"" . $row->title . "\",\"desc\":\"" . $desc_tags . "\",\"address\":\"" . $row->address . "\",\n\t\t\"country\":\"" . $row->country . "\",\"price\":\"" . $row->price . "\",\"image_src\":\"" . $url . "\",\"currency\":\"" . $row->currency . "\"},"; } $count = count($json); $end = $count - 1; $slice = array_slice($json, 0, $end); foreach ($slice as $row) { echo $row; } $comma = end($json); $json = substr_replace($comma, "", -1); echo $json; echo "]"; } else { echo "[{\"status\":\"No List\"}]"; } } else { echo "[{\"status\":\"Please logged in\"}]"; } }
</script> <!-- End of style sheets inclusion --> <?php $id = $this->uri->segment(3); $query = $this->db->get_where('list', array('id' => $id)); $q = $query->result(); $query2 = $this->db->get_where('amnities', array('id' => $id)); $r = $query2->result(); ?> <div class="container_bg" id="View_Edit_List"> <div id="View_Edit_Heading"> <div class="heading_content clearfix"> <div class="heading_content"> <div class="edit_listing_photo"> <?php $url = getListImage($this->uri->segment(3)); ?> <img alt="Host_pic" height="65" src="<?php echo $url; ?> " /> </div> <div class="listing_info"> <h3><?php echo anchor('rooms/' . $this->uri->segment(3), $q[0]->title, array('id' => "listing_title_banner")); ?> </h3> <?php echo anchor('rooms/' . $this->uri->segment(3), translate('View Listing'), array('class' => "clsLink2_Bg")); ?> <span id="availability-error-message"></span> </div> <div class="edit_view_all_list"> <?php
public function neighborhoods() { $conditions = array("list.is_enable" => 1, "list.status" => 1); //$limit = array(12); $orderby = array("page_viewed", "desc"); $mosts = $this->Rooms_model->get_rooms($conditions, NULL, $orderby); //$items= ''; if ($mosts->num_rows() != 0) { echo "[ "; foreach ($mosts->result() as $row) { $items[] = $row->country; //$itemsid[] = $row->id; } //echo'<pre>';print_r(array_unique($items));exit; $result_id = array(); $i = 0; $result_country = array_unique($items); //print_r($result_country);exit; $final_country = array(); $i = 0; foreach ($result_country as $row_country) { if ($i < 12) { $final_country[] = $row_country; $i++; } } //print_r($final_country); foreach ($final_country as $rows_country) { $conditions = array("country" => $rows_country); $mosts1 = $this->Rooms_model->get_rooms($conditions, NULL, $orderby); foreach ($mosts1->result() as $row_ids) { $list_id[] = $row_ids->id; } $count = count($list_id); //$json[] = "{ \"id\":".$id.",\"title\":\"".$row->title."\",\"country\":\"".$country."\",\"image_url\":\"".$image."\" },"; $json[] = "{\"country\":\"" . $rows_country . "\",\"image_url\":\"" . getListImage($list_id[$count - 1]) . "\"},"; } $count = count($json); $end = $count - 1; $slice = array_slice($json, 0, $end); foreach ($slice as $row) { echo $row; } $comma = end($json); $json = substr_replace($comma, "", -1); echo $json; echo " ]"; } }
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; }