function get_currency_value1($id, $amount, $currency) { $rate = 0; $this->load->helper("cookie"); $current = $currency; $list_currency = $this->db->where('id', $id)->get('list')->row()->currency; if ($current == '') { $list_currency1 = $this->db->where('default', 1)->get('currency')->row()->currency_code; $params = array('amount' => $amount, 'currFrom' => $list_currency, 'currInto' => $list_currency1); $rate = round(google_convert($params)); if ($rate != 0) { return $rate; } else { return 0; } } $params = array('amount' => $amount, 'currFrom' => $list_currency, 'currInto' => $current); $rate = round(google_convert($params)); if ($rate != 0) { return $rate; } else { return 0; } }
function get_currency_value_coupon($amount, $currency) { $rate = 0; $currency_from = $currency; //echo $amount; $ci =& get_instance(); $ci->load->helper("cookie"); //var_dump($ci->session->userdata("default_currency_cookie")); $currency_to = $ci->session->userdata("locale_currency"); if ($currency_to == '') { $ci->load->model('Common_model'); $currency_to = $ci->Common_model->getTableData('currency', array('default' => '1'))->row()->currency_code; } $params = array('amount' => $amount, 'currFrom' => $currency_from, 'currInto' => $currency_to); //$ci->load->library('GoogleCurrencyConvertor',$params); $rate = round(google_convert($params)); //var_dump($rate); if ($rate != 0) { return $rate; } else { return $amount; } //$googleCurrencyConvertor = new GoogleCurrencyConvertor("1","INR","USD"); }
public function selected_view() { $room_id = $this->input->get('room_id'); $conditions = array("id" => $room_id, "list.is_enable" => 1, "list.status" => 1); $result = $this->Common_model->getTableData('list', $conditions); if ($result->num_rows() != 0) { foreach ($result->result() as $row) { $id = $row->id; $user_id = $row->user_id; $address = $row->address; $country = ''; $city = ''; $state = ''; $cancellation_policy = $row->cancellation_policy; $room_type = $row->room_type; $bedrooms = $row->bedrooms; $beds = $row->beds; $bed_type = $row->bed_type; $bathrooms = $row->bathrooms; $title = $row->title; $desc = $row->desc; $capacity = $row->capacity; $price = $row->price; $email = $row->email; $phone = $row->phone; $review = $row->review; $lat = $row->lat; $long = $row->long; $property_id = $row->property_id; $street_view = $row->street_view; $sublet_price = $row->sublet_price; $sublet_status = $row->sublet_status; $sublet_startdate = $row->sublet_startdate; $sublet_enddate = $row->sublet_enddate; $currency = $row->currency; $manual = $row->manual; $page_viewed = $row->page_viewed; $neighbor = $row->neighbor; $amenities = $row->amenities; $price_query = $this->db->where('id', $room_id)->from('price')->get(); if ($price_query->num_rows() != 0) { foreach ($price_query->result() as $row) { if ($currency == 'USD' || $currency == '0') { $price = $price; $cleaning_fee = $row->cleaning; $extra_guest_fee = $row->addguests . '/guest after' . $row->guests; $Wprice = $row->week; $Mprice = $row->month; } else { $params_price = array('amount' => $price, 'currFrom' => $currency, 'currInto' => 'USD'); $params_clean = array('amount' => $row->cleaning, 'currFrom' => $currency, 'currInto' => 'USD'); $params_guest = array('amount' => $row->addguests, 'currFrom' => $currency, 'currInto' => 'USD'); $params_week = array('amount' => $row->week, 'currFrom' => $currency, 'currInto' => 'USD'); $params_month = array('amount' => $row->month, 'currFrom' => $currency, 'currInto' => 'USD'); $price = round(google_convert($params_price)); $cleaning_fee = round(google_convert($params_clean)); $extra_guest_fee = round(google_convert($params_guest)); $Wprice = round(google_convert($params_week)); $Mprice = round(google_convert($params_month)); } } } else { $Wprice = ''; $Mprice = ''; $cleaning_fee = ''; $price = ''; $extra_guest_fee = ''; } $conditions = array("id" => $room_id, "list.is_enable" => 1, "list.status" => 1); $result = $this->Common_model->getTableData('list', $conditions); $today_month = date("F"); $today_date = date("j"); $today_year = date("Y"); $conditions_statistics = array("list_id" => $room_id, "date" => trim($today_date), "month" => trim($today_month), "year" => trim($today_year)); $result_statistics = $this->Common_model->add_page_statistics($room_id, $conditions_statistics); $list = $list = $result->row(); $title = $list->title; $page_viewed = $list->page_viewed; $page_viewed = $this->Trips_model->update_pageViewed($room_id, $page_viewed); $id = $room_id; $checkin = $this->session->userdata('Vcheckin'); $checkout = $this->session->userdata('Vcheckout'); $guests = $this->session->userdata('Vnumber_of_guests'); $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); //check admin premium condition and apply so for $query = $this->Common_model->getTableData('paymode', array('id' => 2)); $row = $query->row(); if ($ckin[0] == "mm" && $ckout[0] == "mm" or $ckin[0] == "" && $ckout[0] == "") { if ($Wprice == 0) { $data['Wprice'] = $price * 7; } else { $data['Wprice'] = $Wprice; } if ($Mprice == 0) { $data['Mprice'] = $price * 30; } else { $data['Mprice'] = $Mprice; } if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $price + $fix; $commission = $fix; $Fprice = $amt; } else { $per = $row->percentage_amount; $camt = floatval($price * $per / 100); $amt = $price + $camt; $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)); if ($guests > $guests) { $price = $price * $days + $days * $xprice->addguests; } else { $price = $price * $days; } if ($Wprice == 0) { $data['Wprice'] = $price * 7; } else { $data['Wprice'] = $Wprice; } if ($Mprice == 0) { $data['Mprice'] = $price * 30; } else { $data['Mprice'] = $Mprice; } $commission = 0; if ($row->is_premium == 1) { if ($row->is_fixed == 1) { $fix = $row->fixed_amount; $amt = $price + $fix; $commission = $fix; $Fprice = $amt; } else { $per = $row->percentage_amount; $camt = floatval($price * $per / 100); $amt = $price + $camt; $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; } } } $conditions = array('list_id' => $room_id); $image_query = $this->db->select('name')->where('list_id', $room_id)->where('is_featured', 1)->from('list_photo')->get(); if ($image_query->num_rows() != 0) { foreach ($image_query->result() as $row) { $image_name = $row->name; } $image = base_url() . 'images/' . $room_id . '/' . $image_name; } else { $image = base_url() . 'images/no_image.jpg'; } $conditions = array('list_id' => $room_id, 'userto' => $list->user_id); $result = $this->Trips_model->get_review($conditions); $conditions = array('list_id' => $room_id, 'userto' => $list->user_id); $stars = $this->Trips_model->get_review_sum($conditions)->row(); $title = substr($title, 0, 70); $level = explode(',', $address); $keys = array_keys($level); $country = $level[end($keys)]; if (is_numeric($country) || ctype_alnum($country)) { $country = $level[$keys[count($keys) - 2]]; } if (is_numeric($country) || ctype_alnum($country)) { $country = $level[$keys[count($keys) - 3]]; } $search = array('\'', '"', '(', ')', '!', '{', '[', '}', ']'); $replace = array('&sq', '&dq', '&obr', '&cbr', '&ex', '&obs', '&oabr', '&cbs', '&cabr'); $desc_replace = str_replace($search, $replace, $desc); $desc_tags = stripslashes($desc_replace); $amenities = $this->db->get_where('list', array('id' => $room_id))->row()->amenities; $property_type = $this->db->get_where('property_type', array('id' => $property_id))->row()->type; $in_arr = explode(',', $amenities); $result = $this->db->get('amnities'); $user_name = $this->db->where('id', $user_id)->select('username')->from('users')->get(); if ($user_name->num_rows() != 0) { foreach ($user_name->result() as $row) { $hoster_name = $row->username; } } else { $hoster_name = 'No Username'; } echo "[ { \"id\":" . $room_id . ",\"user_id\":" . $user_id . ",\"hoster_name\":\"" . $hoster_name . "\",\"title\":\"" . $title . "\",\"country\":\"" . $country . "\",\"city\":\"" . $city . "\",\"state\":\"" . $state . "\",\"cancellation_policy\":\"" . $cancellation_policy . "\",\"address\":\"" . $address . "\",\"image_url\":\"" . base_url() . "files/timthumb.php?src=" . $image . "&h=309&w=598&zc=&q=100\",\r\n\t \"room_type\":\"" . $room_type . "\",\"bedrooms\":" . $bedrooms . ",\"bathrooms\":" . $bathrooms . ",\"bed_type\":\"" . $bed_type . "\",\r\n\t \"desc\":\"" . $desc_tags . "\",\"capacity\":" . $capacity . ",\"price\":\"\$" . $price . "\",\"cleaning_fee\":\"\$" . $cleaning_fee . "\",\"extra_guest_fee\":\"\$" . $extra_guest_fee . "\",\"weekly_price\":\"\$" . $Wprice . "\",\"monthly_price\":\"\$" . $Mprice . "\",\"email\":\"" . $email . "\",\"phone\":\"" . $phone . "\",\"review\":\"" . $review . "\",\"lat\":" . $lat . ",\"long\":" . $long . ",\"property_type\":\"" . $property_type . "\",\"street_view\":" . $street_view . ",\"sublet_price\":" . $sublet_price . ",\"sublet_status\":" . $sublet_status . ",\"sublet_startdate\":\"" . $sublet_startdate . "\",\"sublet_enddate\":\"" . $sublet_enddate . "\",\"currency\":\"" . $currency . "\",\"manual\":\"" . $manual . "\",\"page_viewed\":" . $page_viewed . ",\"neighbor\":\"" . $neighbor . "\",\"amenities\":\""; if ($result->num_rows() != 0) { if ($amenities) { foreach ($result->result() as $row) { if (in_array($row->id, $in_arr)) { $json[] = $row->name . ","; } } $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 "} ]"; exit; } } else { $json[] = ''; } echo "\"} ]"; } } else { echo "[ { \"status\":\"Access Denied\" } ]"; } }
public function edit_price($param = '') { if ($this->dx_auth->is_logged_in() || $this->facebook_lib->logged_in()) { if ($param == "") { redirect('info/deny'); } $conditions = array("id" => $param, "user_id" => $this->dx_auth->get_user_id()); $result = $this->Common_model->getTableData('list', $conditions); if ($result->num_rows() == 0) { redirect('info/deny'); } $data['room_id'] = $param; $this->form_validation->set_error_delimiters('<p style="clear:both;color: #FF0000;">', '</p>'); $default_curr = $this->db->where('default', 1)->get('currency')->row()->currency_code; if ($this->input->post()) { $this->form_validation->set_rules('nightly', 'Nightly', 'required'); if ($this->form_validation->run()) { if ($this->session->userdata('locale_currency') != '') { if ($this->session->userdata('locale_currency') != $result->row()->currency) { $neight_price_data = array('amount' => $this->input->post('nightly'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $neigh_price = round(google_convert($neight_price_data)); $weekly_price_data = array('amount' => $this->input->post('weekly'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $week_price = round(google_convert($weekly_price_data)); $monthly_price_data = array('amount' => $this->input->post('monthly'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $month_price = round(google_convert($monthly_price_data)); $extra_price_data = array('amount' => $this->input->post('extra'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $extra_price = round(google_convert($extra_price_data)); $guests_price_data = array('amount' => $this->input->post('guests'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $guest_price = round(google_convert($guests_price_data)); $security_price_data = array('amount' => $this->input->post('security'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $security_price = round(google_convert($security_price_data)); $cleaning_price_data = array('amount' => $this->input->post('cleaning'), 'currFrom' => $this->session->userdata("locale_currency"), 'currInto' => $result->row()->currency); $cleaning_price = round(google_convert($cleaning_price_data)); } else { $neigh_price = $this->input->post('nightly'); $week_price = $this->input->post('weekly'); $month_price = $this->input->post('monthly'); $extra_price = $this->input->post('extra'); $guest_price = $this->input->post('guests'); $security_price = $this->input->post('security'); $cleaning_price = $this->input->post('cleaning'); } } elseif ($default_curr != $result->row()->currency) { $neight_price_data = array('amount' => $this->input->post('nightly'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $neigh_price = round(google_convert($neight_price_data)); $weekly_price_data = array('amount' => $this->input->post('weekly'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $week_price = round(google_convert($weekly_price_data)); $monthly_price_data = array('amount' => $this->input->post('monthly'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $month_price = round(google_convert($monthly_price_data)); $extra_price_data = array('amount' => $this->input->post('extra'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $extra_price = round(google_convert($extra_price_data)); $guests_price_data = array('amount' => $this->input->post('guests'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $guest_price = round(google_convert($guests_price_data)); $security_price_data = array('amount' => $this->input->post('security'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $security_price = round(google_convert($security_price_data)); $cleaning_price_data = array('amount' => $this->input->post('cleaning'), 'currFrom' => $default_curr, 'currInto' => $result->row()->currency); $cleaning_price = round(google_convert($cleaning_price_data)); } else { $neigh_price = $this->input->post('nightly'); $week_price = $this->input->post('weekly'); $month_price = $this->input->post('monthly'); $extra_price = $this->input->post('extra'); $guest_price = $this->input->post('guests'); $security_price = $this->input->post('security'); $cleaning_price = $this->input->post('cleaning'); } $data = array('currency' => $this->input->post('currency'), 'night' => $neigh_price, 'week' => $week_price, 'month' => $month_price, 'addguests' => $extra_price, 'guests' => $guest_price, 'security' => $security_price, 'cleaning' => $cleaning_price, 'currency' => $this->input->post('to')); $list_id = $param; $this->Common_model->updateTableData('price', $list_id, NULL, $data); $data1 = array(); $data1['price'] = $neigh_price; $this->Common_model->updateTableData('list', $list_id, NULL, $data1); $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Price updated successfully.'))); redirect('rooms/edit_price/' . $param); } } $data['list'] = $this->Common_model->getTableData('list', array('id' => $param))->row(); $data['list_price'] = $this->Common_model->getTableData('price', array('id' => $param))->row(); $data['title'] = get_meta_details('Edit_the_price_information_for_your_site', 'title'); $data["meta_keyword"] = get_meta_details('Edit_the_price_information_for_your_site', 'meta_keyword'); $data["meta_description"] = get_meta_details('Edit_the_price_information_for_your_site', 'meta_description'); $data['message_element'] = 'rooms/view_edit_price'; $this->load->view('template', $data); } else { redirect('users/signin'); } }
function get_currency_value_coupon1($id, $amount) { $rate = 0; //echo $amount; $ci =& get_instance(); $ci->load->helper("cookie"); //var_dump($ci->session->userdata("default_currency_cookie")); $current = $ci->session->userdata("locale_currency"); $list_currency = $ci->db->where('id', $id)->get('list')->row()->currency; if ($current == '') { $list_currency1 = $ci->db->where('default', 1)->get('currency')->row()->currency_code; $params = array('amount' => $amount, 'currFrom' => $list_currency, 'currInto' => $list_currency1); //$ci->load->library('GoogleCurrencyConvertor',$params); $rate = round(google_convert($params), 2); //$current = 'USD'; if ($rate != 0) { return $rate; } else { return 0; } } $params = array('amount' => $amount, 'currFrom' => $list_currency, 'currInto' => $current); //$ci->load->library('GoogleCurrencyConvertor',$params); $rate = round(google_convert($params), 2); //var_dump($rate); if ($rate != 0) { return $rate; } else { return 0; } //$googleCurrencyConvertor = new GoogleCurrencyConvertor("1","INR","USD"); }