public function price_check($str) { if ($str < round(get_currency_value_lys('USD', $this->input->post('currency'), 10))) { $this->form_validation->set_message('price_check', 'Coupon Price should be above or equal to ' . $this->input->post('currency') . ' ' . round(get_currency_value_lys('USD', $this->input->post('currency'), 10)) . '.'); return FALSE; } else { return TRUE; } }
function form_android() { $id = $this->input->get('id'); $checkin = $this->input->get('checkin'); $checkout = $this->input->get('checkout'); $data['guests'] = $this->input->get('guest'); $user_id = $this->input->get('user_id'); $currency = $this->input->get('currency'); $this->session->set_userdata('locale_currency', $currency); $param = $id; $data['checkin'] = $checkin; $data['checkout'] = $checkout; $ckin = explode('/', $checkin); $ckout = explode('/', $checkout); $pay = $this->Common_model->getTableData('paywhom', array('id' => 1)); $paywhom = $pay->result(); $paywhom = $paywhom[0]->whom; $id = $param; $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; $data['cancellation_policy'] = $list->cancellation_policy; $data['house_rule'] = $list->house_rule; $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]); $days = ceil($diff / (3600 * 24)); /*$amt = $price * $days * $data['guests'];*/ if ($data['guests'] > $guests) { $diff_days = $data['guests'] - $guests; $amt = $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 . "'_'" . $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 = $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 + get_currency_value_lys($row->currency, get_currency_code(), $fix); $data['commission'] = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $per = $row->percentage_amount; $camt = floatval($amt * $per / 100); $amt = $amt + $camt; $data['commission'] = $camt; } } else { $amt = $amt; } // Coupon Code Starts //print_r($amt);exit; if ($amt > 110) { $da = array(); $this->db->select('*'); $this->db->where('id', $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"); echo '[{"status":"Sorry! Your payment should be greater than 0."}]'; exit; } $data['result'] = $this->Common_model->getTableData('payments')->result(); $array_items = array('list_id' => '', 'Lcheckin' => '', 'Lcheckout' => '', 'number_of_guests' => '', 'formCheckout' => ''); $this->session->unset_userdata($array_items); //$id = $list_id; $checkin_time = get_gmt_time(strtotime($checkin)); $checkout_time = get_gmt_time(strtotime($checkout)); $travel_dates = array(); $seasonal_prices = array(); $total_nights = 1; $total_price = 0; $is_seasonal = 0; $i = $checkin_time; while ($i < $checkout_time) { $checkin_date = date('m/d/Y', $i); $checkin_date = explode('/', $checkin_date); $travel_dates[$total_nights] = $checkin_date[1] . $checkin_date[0] . $checkin_date[2]; $i = get_gmt_time(strtotime('+1 day', $i)); $total_nights++; } for ($i = 1; $i < $total_nights; $i++) { $seasonal_prices[$travel_dates[$i]] = ""; } //Store seasonal price of a list in an array $seasonal_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id)); $seasonal_result = $seasonal_query->result_array(); if ($seasonal_query->num_rows() > 0) { foreach ($seasonal_result as $time) { //Get Seasonal price $seasonalprice_query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $id, 'start_date' => $time['start_date'], 'end_date' => $time['end_date'])); $seasonalprice = $seasonalprice_query->row()->price; //Days between start date and end date -> seasonal price $start_time = $time['start_date']; $end_time = $time['end_date']; $i = $start_time; while ($i <= $end_time) { $start_date = date('m/d/Y', $i); $s_date = explode('/', $start_date); $s_date = $s_date[1] . $s_date[0] . $s_date[2]; $seasonal_prices[$s_date] = $seasonalprice; $i = get_gmt_time(strtotime('+1 day', $i)); } } //Total Price for ($i = 1; $i < $total_nights; $i++) { if ($seasonal_prices[$travel_dates[$i]] == "") { $xprice = $this->Common_model->getTableData('price', array('id' => $id))->row(); $total_price = $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 + get_currency_value_lys($row->currency, get_currency_code(), $fix); $data['commission'] = get_currency_value_lys($row->currency, get_currency_code(), $fix); } else { $per = $row->percentage_amount; $camt = floatval($amt * $per / 100); $amt = $amt + $camt; $data['commission'] = $camt; } } else { $amt = $amt; } $data['amt'] = $amt; $this->session->set_userdata('topay', $amt); } $data['img'] = getListImage($id); echo '[' . json_encode($data) . ']'; exit; }
<p> <span><?php if ($list_staus->num_rows() == 0) { echo 'List Deletion'; } else { echo $row->name; } ?> </span> <?php if (isset($topay) && $topay != '' && $paid != 1) { if ($hostpaid != 1 && $guestpaid != 1) { // $topay = get_currency_value2($currency,$topay); ?> <br> <span><?php echo get_currency_symbol($row->list_id) . get_currency_value_lys($currency, get_currency_code(), $topay); ?> </span> <?php } } ?> </p> </div> <?php } ?> </li> <?php } } else {
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; }
function currency_converter() { $from = $this->input->post('from'); $to = $this->input->post('to'); $amount = $this->input->post('amount'); //print_r($amount); echo round(get_currency_value_lys($from, $to, $amount)); exit; }
public function special() { $contact_id = $this->input->post('contact_id'); $message = $this->input->post('comment'); //Update the status,price $updateKey = array('id' => $contact_id); $updateData = array(); $updateData['status'] = 3; $updateData['offer'] = 1; $updateData['currency'] = get_currency_code(); $updateData['price'] = $this->input->post('price'); $updateData['original_price'] = $this->input->post('price_original'); if ($updateData['price'] <= get_currency_value_lys('USD', get_currency_code(), 10)) { $validation_amt = get_currency_value_lys('USD', get_currency_code(), 10); echo "Sorry! Your special offer amount should be greater than or equal to {$validation_amt}."; exit; } else { $this->Contacts_model->update_contact($updateKey, $updateData); } extract($this->input->post()); $currency_symbol = $this->Common_model->getTableData('currency', array('currency_code' => get_currency_code()))->row()->currency_symbol; $price = $currency_symbol . $this->input->post('price'); //Email the confirmation link to the traveller $result = $this->Common_model->getTableData('contacts', array('id' => $contact_id))->row(); $traveller_id = $result->userby; $key = $result->contact_key; $list_id = $result->list_id; $title = $this->Common_model->getTableData('list', array('id' => $list_id))->row()->title; $host_email = $this->Common_model->getTableData('users', array('id' => $this->dx_auth->get_user_id()))->row()->email; $traveller_email = $this->Common_model->getTableData('users', array('id' => $traveller_id))->row()->email; //send message to traveller $host_id = $result->userto; $travellername = $this->Common_model->getTableData('users', array('id' => $traveller_id))->row()->username; $hostname = $this->Common_model->getTableData('users', array('id' => $this->dx_auth->get_user_id()))->row()->username; $list_title = $this->Common_model->getTableData('list', array('id' => $list_id))->row()->title; $insertData = array('list_id' => $list_id, 'contact_id' => $contact_id, 'userby' => $host_id, 'userto' => $traveller_id, 'message' => '<b>Contact Request granted by ' . $hostname . '</b><br><br>' . $message, 'created' => local_to_gmt(), 'message_type' => 8); $this->Message_model->sentMessage($insertData, ucfirst($hostname), ucfirst($travellername), $list_title, $contact_id); $updateData1['is_respond'] = 1; $updateKey1['contact_id'] = $contact_id; $updateKey1['userto'] = $host_id; $this->Message_model->updateMessage($updateKey1, $updateData1); $admin_name = $this->dx_auth->get_site_title(); $admin_email = $this->dx_auth->get_site_sadmin(); $link = base_url() . 'payments/index/' . $list_id . '?contact=' . $key; $email_name = 'special_request_granted_to_host'; $splVars = array("{price}" => $price, "{traveller_username}" => $travellername, "{host_email}" => $host_email, "{guest_email}" => $traveller_email, "{checkin}" => $checkin, "{checkout}" => $checkout, "{message}" => $message, "{site_name}" => $this->dx_auth->get_site_title(), "{host_username}" => ucfirst($hostname), "{title}" => $list_title); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); $email_name = 'special_request_granted_to_guest'; $splVars = array("{price}" => $price, "{link}" => $link, "{host_email}" => $host_email, "{guest_email}" => $traveller_email, "{traveller_username}" => $travellername, "{checkin}" => $checkin, "{checkout}" => $checkout, "{message}" => $message, "{site_name}" => $this->dx_auth->get_site_title(), "{host_username}" => ucfirst($hostname), "{title}" => $list_title); $this->Email_model->sendMail($traveller_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); if ($host_email != $admin_email && $traveller_email != $admin_email) { $email_name = 'special_request_granted_to_admin'; $splVars = array("{price}" => $price, "{traveller_username}" => $travellername, "{host_email}" => $host_email, "{guest_email}" => $traveller_email, "{checkin}" => $checkin, "{checkout}" => $checkout, "{guest}" => $data['guests'], "{message}" => $message, "{site_name}" => $this->dx_auth->get_site_title(), "{host_username}" => ucfirst($hostname), "{title}" => $list_title); $this->Email_model->sendMail($admin_email, $host_email, ucfirst($admin_name), $email_name, $splVars); } }
public function trips_success() { $reservation_id = $this->session->userdata('reservation_id'); $is_block = $this->session->userdata('is_block'); $comment = $this->session->userdata('comment'); $checkin = $this->session->userdata('checkin'); $checkout = $this->session->userdata('checkout'); $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"); } $token = $_GET['token']; $payer_id = $_GET['PayerID']; // GetExpressCheckoutDetails $get_ec_return = $this->paypal_ec->get_ec($token); if (isset($get_ec_return['ec_status']) && $get_ec_return['ec_status'] === true) { // at this point, you have all of the data for the transaction. // you may want to save the data for future action. what's left to // do is to collect the money -- you do that by call DoExpressCheckoutPayment // via $this->paypal_ec->do_ec(); // // I suggest to save all of the details of the transaction. You get all that // in $get_ec_return array if (get_currency_code() == 'INR' || get_currency_code() == 'MYR' || get_currency_code() == 'ARS' || get_currency_code() == 'CNY' || get_currency_code() == 'IDR' || get_currency_code() == 'KRW' || get_currency_code() == 'VND' || get_currency_code() == 'ZAR') { $currency_code = 'USD'; $amt = get_currency_value_lys(get_currency_code(), $currency_code, $data['commission']); } else { $currency_code = get_currency_code(); $amt = $data['commission']; } $ec_details = array('token' => $token, 'payer_id' => $payer_id, 'currency' => $currency_code, 'amount' => $get_ec_return['PAYMENTREQUEST_0_AMT'], 'IPN_URL' => site_url('payments/ipn'), 'type' => 'sale'); // DoExpressCheckoutPayment $do_ec_return = $this->paypal_ec->do_ec($ec_details); if (isset($do_ec_return['ec_status']) && $do_ec_return['ec_status'] === true) { // at this point, you have collected payment from your customer // you may want to process the order now. /* echo "<h1>Thank you. We will process your order now.</h1>"; echo "<pre>"; echo "\nGetExpressCheckoutDetails Data\n" . print_r($get_ec_return, true); echo "\n\nDoExpressCheckoutPayment Data\n" . print_r($do_ec_return, true); echo "</pre>";exit; */ if (!$this->dx_auth->is_logged_in() || !$this->facebook_lib->logged_in()) { //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error',translate('Session expired, please try again.'))); //redirect('users/signin'); } if (isset($do_ec_return['L_SHORTMESSAGE0']) && $do_ec_return['L_SHORTMESSAGE0'] === 'Duplicate Request') { redirect('home'); } $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;*/ $query1 = $this->db->where('id', $row->userby)->get('users'); $traveler_name = $query1->row()->username; $traveler_email = $query1->row()->email; //$query2 = $this->Users_model->get_user_by_id($row->userto); $query2 = $this->db->where('id', $row->userto)->get('users'); $host_name = $query2->row()->username; $host_email = $query2->row()->email; $list_title = $this->Common_model->getTableData('list', array('id' => $row->list_id))->row()->title; $traveler = $this->Common_model->getTableData('profiles', array('id' => $row->userby))->row(); $host = $this->Common_model->getTableData('profiles', array('id' => $row->userto))->row(); $data_acceptpay['reservation_id'] = $reservation_id; $data_acceptpay['amount'] = round($this->session->userdata('accept_amount'), 2); $data_acceptpay['currency'] = get_currency_code(); $data_acceptpay['created'] = time(); $this->db->insert('accept_pay', $data_acceptpay); //Traveller Info if (!empty($traveler)) { $FnameT = $traveler->Fname; $LnameT = $traveler->Lname; $liveT = $traveler->live; $phnumT = $traveler->phnum; } else { $FnameT = ''; $LnameT = ''; $liveT = ''; $phnumT = ''; } //Host Info if (!empty($host)) { $FnameH = $host->Fname; $LnameH = $host->Lname; $liveH = $host->live; $phnumH = $host->phnum; } else { $FnameH = ''; $LnameH = ''; $liveH = ''; $phnumH = ''; } //for calendar if ($is_block == 'on') { $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['list_id'] = $row->list_id; $insertData['group_id'] = $countJ + 1; $insertData['availability'] = 'Booked'; $insertData['booked_using'] = 'Other'; $checkin = date('m/d/Y', $checkin); $checkout = date('m/d/Y', $checkout); $days = getDaysInBetween($checkin, $checkout); $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'] = $val; $this->Trips_model->insert_calendar($insertData); $i++; } } $list_data = $this->db->where('id', $row->list_id)->get('list')->row(); //Send Message Notification To Traveler $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userto, 'userto' => $row->userby, 'message' => "Congratulation, Your reservation request is granted by" . $host_name . " for " . $list_title, 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, 1); $updateData['is_respond'] = 1; $updateKey['reservation_id'] = $reservation_id; $updateKey['userto'] = $row->userto; $this->Message_model->updateMessage($updateKey, $updateData); $referral_code_check1 = $this->db->where('id', $row->userto)->get('users'); if ($referral_code_check1->row()->list_referral_code) { $own_referral_code = $referral_code_check1->row()->list_referral_code; $referral_code_check2 = $this->db->where('referral_code', $own_referral_code)->get('users'); if ($referral_code_check2->num_rows() != 0) { $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userto, 'userto' => $referral_code_check2->row()->id, 'message' => "Congratulation, You have earned \$." . $rent . " by " . $host_name, 'created' => local_to_gmt(), 'message_type' => 9); $this->Message_model->sentMessage($insertData, 1); $this->db->set('list_referral_code', '')->where('id', $referral_code_check1->row()->id)->update('users'); // $this->db->set('cancel_list_referral_code',$own_referral_code)->where('id',$referral_code_check1->row()->id)->update('users'); $amt_check = $this->db->where('id', $referral_code_check2->row()->id)->get('users'); $rent1 = $referral_code_check1->row()->ref_rent; $trip1 = $referral_code_check1->row()->ref_trip; if ($amt_check->row()->referral_amount) { $amt = $rent1 + $amt_check->row()->referral_amount; } else { $amt = $rent1; } $this->db->set('referral_amount', $amt)->where('id', $referral_code_check2->row()->id)->update('users'); $email_name = 'referral_credit'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{friend_name}" => $host_name, "{user_name}" => $referral_code_check2->row()->username, '{amount}' => '$' . $rent); $this->Email_model->sendMail($referral_code_check2->row()->email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } } $referral_code_check3 = $this->db->where('id', $row->userby)->get('users'); if ($referral_code_check3->row()->trips_referral_code) { $own_referral_code = $referral_code_check3->row()->trips_referral_code; // echo $own_referral_code; // exit; $referral_code_check4 = $this->db->where('referral_code', $own_referral_code)->get('users'); if ($referral_code_check4->num_rows() != 0) { $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userby, 'userto' => $referral_code_check4->row()->id, 'message' => "Congratulation, You have earned \$" . $trip . "by" . $referral_code_check3->row()->username, 'created' => local_to_gmt(), 'message_type' => 9); $this->Message_model->sentMessage($insertData, 1); $this->db->set('trips_referral_code', '')->where('id', $referral_code_check3->row()->id)->update('users'); // $this->db->set('cancel_trips_referral_code',$own_referral_code)->where('id',$referral_code_check3->row()->id)->update('users'); $amt_check1 = $this->db->where('id', $referral_code_check4->row()->id)->get('users'); $rent2 = $referral_code_check3->row()->ref_rent; $trip2 = $referral_code_check3->row()->ref_trip; $amt_check1 = $this->db->where('id', $referral_code_check4->row()->id)->get('users'); if ($amt_check1->row()->referral_amount) { $amt1 = $trip2 + $amt_check1->row()->referral_amount; } else { $amt1 = $trip2; } $this->db->set('referral_amount', $amt1)->where('id', $referral_code_check4->row()->id)->update('users'); $email_name = 'referral_credit'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{friend_name}" => $referral_code_check3->row()->username, "{username}" => $referral_code_check4->row()->username, "{amount}" => '$' . $trip); $this->Email_model->sendMail($referral_code_check4->row()->email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } } $updateKey = array('id' => $reservation_id); $updateData = array(); $updateData['status '] = 3; $updateData['is_payed'] = 0; $this->Trips_model->update_reservation($updateKey, $updateData); if ($list_data->optional_address == '') { $optional_address = ' -'; } else { $optional_address = $list_data->optional_address; } if ($list_data->state == '') { $state = ' -'; } else { $state = $list_data->state; } //Send Mail To Traveller $email_name = 'traveler_reservation_granted'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_name}" => $list_title, "{host_name}" => ucfirst($host_name), "{Fname}" => $FnameH, "{Lname}" => $LnameH, "{livein}" => $liveH, "{phnum}" => $phnumH, "{comment}" => $comment, "{street_address}" => $list_data->street_address, "{optional_address}" => $optional_address, "{city}" => $list_data->city, "{state}" => $state, "{country}" => $list_data->country, "{zipcode}" => $list_data->zip_code); $this->Email_model->sendMail($traveler_email, $host_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Host $email_name = 'host_reservation_granted'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name), "{Fname}" => $FnameT, "{Lname}" => $LnameT, "{livein}" => $liveT, "{phnum}" => $phnumT, "{comment}" => $comment); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Administrator $email_name = 'admin_reservation_granted'; $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('Your reservation request accept process successfully completed.'))); redirect('trips/request/' . $reservation_id); } else { $this->_error($do_ec_return); } } else { $this->_error($get_ec_return); } }
function price_check($value) { $convert_value = round(get_currency_value_lys('USD', $this->input->post('currency'), 300)); if ($value <= $convert_value) { return TRUE; } else { $this->form_validation->set_message('price_check', 'Amount should be less than or equal to ' . $convert_value . $this->input->post('currency')); return FALSE; } }
function braintree_success() { $result = Braintree_Transaction::sale(array('amount' => get_currency_value_lys(get_currency_code(), 'USD', $this->session->userdata('subtotal')), "paymentMethodNonce" => $_POST['payment_method_nonce'], 'options' => array('submitForSettlement' => true))); $transaction = $result->transaction; if ($transaction->status == "authorized" || $transaction->status == "submitted_for_settlement") { $custom = $this->session->userdata('custom'); $data = array(); $list = array(); $data = explode('@', $custom); $contact_key = $data[9]; $list['list_id'] = $data[0]; $list['userby'] = $data[1]; $query1 = $this->Common_model->getTableData('list', array('id' => $list['list_id'])); $buyer_id = $query1->row()->user_id; $list['userto'] = $buyer_id; $list['checkin'] = $data[2]; $list['checkout'] = $data[3]; $list['no_quest'] = $data[4]; $date1 = new DateTime(date('Y-m-d H:i:s', $list['checkin'])); $date2 = new DateTime(date('Y-m-d H:i:s', $list['checkout'])); $interval = $date1->diff($date2); if ($interval->days >= 28) { $list['policy'] = 5; } else { $list['policy'] = $query1->row()->cancellation_policy; } $amt = $data[14]; $list['transaction_id'] = "{$transaction->id}"; $list['price'] = $this->session->userdata('subtotal'); $currency = $data[15]; $list['payment_id'] = 2; $list['credit_type'] = 1; $is_travelCretids = $data[5]; $user_travel_cretids = $data[6]; $list['currency'] = get_currency_code(); if ($currency != 'USD') { $list['admin_commission'] = $data[8]; $list['cleaning'] = $data[10]; $list['security'] = $data[11]; $list['topay'] = $amt - $data[8]; } else { $list['admin_commission'] = $data[8]; $list['cleaning'] = $data[10]; $list['security'] = $data[11]; $list['topay'] = $amt - $data[8]; } $list['guest_count'] = $data[13]; if ($list['no_quest'] > $list['guest_count']) { if ($currency != 'USD') { $list['extra_guest_price'] = $data[12]; } else { $list['extra_guest_price'] = $data[12]; } } if ($this->session->userdata('contact_key') != '') { $updateKey = array('contact_key' => $this->session->userdata('contact_key')); $updateData = array(); $list['contacts_offer'] = $this->session->userdata('contacts_offer'); $updateData['status'] = 10; $this->Contacts_model->update_contact($updateKey, $updateData); } if ($contact_key != "None") { $list['status'] = 1; $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['list_id'] = $list['list_id']; $insertData['group_id'] = $countJ + 1; $insertData['availability'] = 'Booked'; $insertData['booked_using'] = 'Other'; $checkin = date('m/d/Y', $list['checkin']); $checkout = date('m/d/Y', $list['checkout']); $days = getDaysInBetween($checkin, $checkout); $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'] = $val; $this->Trips_model->insert_calendar($insertData); $i++; } } else { $listid1 = $list['list_id']; $instance_book = $this->db->where('id', $listid1)->get('list')->row()->instance_book; //echo $this->db->last_query(); if ($instance_book == 1) { $list['status'] = 3; } else { $list['status'] = 1; } } if ($list['price'] > $rent) { $user_id = $list['userby']; $details = $this->Referrals_model->get_details_by_Iid($user_id); $row = $details->row(); $count = $details->num_rows(); if ($count > 0) { $details1 = $this->Referrals_model->get_details_refamount($row->invite_from); $amt_check2 = $this->db->where('id', $row->invite_from)->get('users'); $user = $this->Users_model->get_user_by_id($this->dx_auth->get_user_id())->row(); $trip1 = $user->ref_trip; $rent1 = $user->ref_rent; if ($amt_check2->num_rows() == 0) { $insertData = array(); $insertData['user_id'] = $row->invite_from; $insertData['count_trip'] = 1; $insertData['amount'] = $trip1; $this->Referrals_model->insertReferralsAmount($insertData); } else { $count_trip = $amt_check2->row()->count_trip; $amount = $amt_check2->row()->amount; $updateKey = array('id' => $row->id); $updateData = array(); $updateData['count_trip'] = $count_trip + 1; $updateData['amount'] = $amount + $trip1; $this->Referrals_model->updateReferralsAmount($updateKey, $updateData); } } } $q = $query1->result(); $row_list = $query1->row(); $iUser_id = $q[0]->user_id; $details2 = $this->Referrals_model->get_details_by_Iid($iUser_id); $row = $details2->row(); $count = $details2->num_rows(); if ($count > 0) { $user = $this->Users_model->get_user_by_id($this->dx_auth->get_user_id())->row(); $trip1 = $user->ref_trip; $rent1 = $user->ref_rent; $details3 = $this->Referrals_model->get_details_refamount($row->invite_from); $amt_check3 = $this->db->where('id', $row->invite_from)->get('users'); if ($amt_check3->num_rows() == 0) { $insertData = array(); $insertData['user_id'] = $row->invite_from; $insertData['count_book'] = 1; $insertData['amount'] = $rent1; $this->Referrals_model->insertReferralsAmount($insertData); } else { $count_book = $amt_check3->row()->count_book; $amount = $amt_check3->row()->amount; $updateKey = array('id' => $row->id); $updateData = array(); $updateData['count_trip'] = $count_book + 1; $updateData['amount'] = $amount + $rent1; $this->Referrals_model->updateReferralsAmount($updateKey, $updateData); } } $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $query3 = $this->Common_model->getTableData('users', array('id' => $list['userby'])); $rows = $query3->row(); $username = $rows->username; $user_id = $rows->id; $email_id = $rows->email; $query4 = $this->Users_model->get_user_by_id($buyer_id); $buyer_name = $query4->row()->username; $buyer_email = $query4->row()->email; //Check md5('No Travel Cretids') || md5('Yes Travel Cretids') if ($is_travelCretids == '7c4f08a53f4454ea2a9fdd94ad0c2eeb') { $query5 = $this->Referrals_model->get_details_refamount($user_id); $amount = $query5->row()->amount; $updateKey = array('user_id ' => $user_id); $updateData = array(); $updateData['amount'] = $amount - $user_travel_cretids; $this->Referrals_model->updateReferralsAmount($updateKey, $updateData); $list['credit_type'] = 2; $list['ref_amount'] = $user_travel_cretids; $row = $query4->row(); //sent mail to administrator $email_name = 'tc_book_to_admin'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A'), "{traveler_email_id}" => $email_id, "{checkin}" => date('d-m-Y', $list['checkin']), "{checkout}" => date('d-m-Y', $list['checkout']), "{market_price}" => $user_travel_cretids + $list['price'], "{payed_amount}" => $list['price'], "{travel_credits}" => $user_travel_cretids, "{host_name}" => ucfirst($buyer_name), "{host_email_id}" => $buyer_email); //Send Mail $this->Email_model->sendMail($admin_email, $email_id, ucfirst($username), $email_name, $splVars); //sent mail to buyer $email_name = 'tc_book_to_host'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{username}" => ucfirst($buyer_name), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A'), "{traveler_email_id}" => $email_id, "{checkin}" => date('d-m-Y', $list['checkin']), "{checkout}" => date('d-m-Y', $list['checkout']), "{market_price}" => $list['price']); //Send Mail if ($buyer_email != '0') { $this->Email_model->sendMail($buyer_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } } $list['book_date'] = local_to_gmt(); if ($this->session->userdata('coupon_code_used') == 1) { $list['coupon'] = $this->session->userdata('coupon_code'); $this->db->where('couponcode', $list['coupon'])->update('coupon', array('status' => 1)); $this->db->where('used_coupon_code', $list['coupon'])->update('coupon_users', array('status' => 1)); $this->session->unset_userdata('coupon_code'); $this->session->unset_userdata('coupon_code_used'); } else { $list['coupon'] = 0; } //Actual insertion into the database $this->Common_model->insertData('reservation', $list); $reservation_id = $this->db->insert_id(); $reservation_result = $this->Common_model->getTableData('reservation', array('id' => $reservation_id))->row(); $currency_symbol = $this->Common_model->getTableData('currency', array('currency_code' => $reservation_result->currency))->row()->currency_symbol; $price = $reservation_result->currency . ' ' . $currency_symbol . $reservation_result->price; $host_price = $reservation_result->currency . ' ' . $currency_symbol . $reservation_result->topay; if ($interval->days >= 28) { $conversation = $this->db->where('userto', $list['userto'])->where('userby', $list['userby'])->order_by('id', 'desc')->get('messages'); $conversation1 = $this->db->where('userto', $list['userby'])->where('userby', $list['userto'])->order_by('id', 'desc')->get('messages'); if ($conversation->num_rows() != 0) { $conversation_id = $conversation->row()->id; } elseif ($conversation1->num_rows() != 0) { $conversation_id = $conversation1->row()->id; } else { $conversation_id = $reservation_id . '1'; } //Send Message Notification $insertData = array('list_id' => $list['list_id'], 'reservation_id' => $reservation_id, 'conversation_id' => $conversation_id, 'userby' => 1, 'userto' => $list['userby'], 'message' => "Your reservation is 28 days or more. So, Long Term cancellation policy applied for " . $row_list->title, 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, $isCoversation = 0, ucfirst($buyer_name), ucfirst($username), $row_list->title, $reservation_id); //Send Message Notification $insertData = array('list_id' => $list['list_id'], 'reservation_id' => $reservation_id, 'conversation_id' => $conversation_id, 'userby' => 1, 'userto' => $list['userto'], 'message' => ucfirst($username) . " reservation is 28 days or more. So, Long Term cancellation policy applied for " . $row_list->title, 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, ucfirst($buyer_name), ucfirst($username), $row_list->title, $reservation_id); } //Send Message Notification if ($instance_book == 1) { $insertData = array('list_id' => $list['list_id'], 'reservation_id' => $reservation_id, 'conversation_id' => $reservation_id, 'userby' => $list['userto'], 'userto' => $list['userby'], 'message' => 'Your reservation is successfully done ', 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, $isCoversation = 0, ucfirst($username), ucfirst($buyer_name), $row_list->title, $reservation_id); $message_id = $this->db->insert_id(); $insertData = array('list_id' => $list['list_id'], 'reservation_id' => $reservation_id, 'conversation_id' => $reservation_id, 'userby' => $list['userby'], 'userto' => $list['userto'], 'message' => 'You have a new reservation from ' . ucfirst($username), 'created' => local_to_gmt(), 'message_type' => 1); } else { $insertData = array('list_id' => $list['list_id'], 'reservation_id' => $reservation_id, 'userby' => $list['userby'], 'userto' => $list['userto'], 'message' => 'You have a new reservation request from ' . ucfirst($username), 'created' => local_to_gmt(), 'message_type' => 1); } $this->Message_model->sentMessage($insertData, ucfirst($buyer_name), ucfirst($username), $row_list->title, $reservation_id); $message_id = $this->db->insert_id(); $actionurl = site_url('trips/request/' . $reservation_id); // date_default_timezone_set('Asia/Kolkata'); //Reservation Notification To Host $email_name = 'host_reservation_notification'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{username}" => ucfirst($buyer_name), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A', time()), "{traveler_email_id}" => $email_id, "{checkin}" => date('m/d/Y', $list['checkin']), "{checkout}" => date('m/d/Y', $list['checkout']), "{market_price}" => $host_price, "{action_url}" => $actionurl); //Send Mail // if ($buyer_email != '0') { $this->Email_model->sendMail($buyer_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } //Reservation Notification To Traveller $email_name = 'traveller_reservation_notification'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($username)); //Send Mail $this->Email_model->sendMail($email_id, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Reservation Notification To Administrator $email_name = 'admin_reservation_notification'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A', time()), "{traveler_email_id}" => $email_id, "{checkin}" => date('m/d/Y', $list['checkin']), "{checkout}" => date('m/d/Y', $list['checkout']), "{market_price}" => $price, "{payed_amount}" => $list['price'], "{travel_credits}" => $user_travel_cretids, "{host_name}" => ucfirst($buyer_name), "{host_email_id}" => $buyer_email); //Send Mail $this->Email_model->sendMail($admin_email, $email_id, ucfirst($username), $email_name, $splVars); // if($is_block == 'on') // { $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; } $insertData1['list_id'] = $list['list_id']; //$insertData['reservation_id'] = $reservation_id; $insertData1['group_id'] = $countJ + 1; $insertData1['availability'] = 'Not Available'; $insertData1['booked_using'] = 'Other'; $checkin = date('m/d/Y', $list['checkin']); $checkout = date('m/d/Y', $list['checkout']); $days = getDaysInBetween($checkin, $checkout); // print_r($days);exit; $count = count($days); $i = 1; foreach ($days as $val) { if ($count == 1) { $insertData1['style'] = 'single'; } else { if ($count > 1) { if ($i == 1) { $insertData1['style'] = 'left'; } else { if ($count == $i) { $insertData1['notes'] = ''; $insertData1['style'] = 'right'; } else { $insertData1['notes'] = ''; $insertData1['style'] = 'both'; } } } } $insertData1['booked_days'] = $val; $this->Trips_model->insert_calendar($insertData1); $i++; } $referral_amount = $this->db->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount; if ($referral_amount > $ref_total) { $this->db->set('referral_amount', $referral_amount - $ref_total)->where('id', $this->dx_auth->get_user_id())->update('users'); } // else //{ // $this->db->set('referral_amount',0)->where('id',$this->dx_auth->get_user_id())->update('users'); //} $data['title'] = "Payment Success !"; $data['message_element'] = "payments/paypal_success"; $this->load->view('template', $data); } else { if ($this->session->userdata('call_back') == 'mobile') { $message_element = 'payments/paypal_cancel_mobile'; } else { $message_element = 'payments/paypal_cancel'; } $data['title'] = "Payment Cancelled !"; $data['message_element'] = $message_element; $this->load->view('template', $data); } }
</span></span> <span class="data col-md-8 col-sm-7 col-xs-12"><span class="inner"><?php echo get_currency_symbol($result->list_id) . get_currency_value_lys($result->currency, get_currency_code(), $subtotal); if ($result->contacts_offer == 1) { $special_offer = '(Special offer used.)'; } else { $special_offer = ''; } ?> <!--<li class="clearfix"> <span class="label"><span class="inner"><span class="checkout_icon" id="icon_cal"></span><?php echo translate("Total Payout"); ?> </span></span> <span class="data"><span class="inner"><?php echo get_currency_symbol($result->list_id) . get_currency_value_lys($result->currency, get_currency_code(), $subtotal) . $special_offer; ?> --> <?php if ($result->coupon == 1) { echo ' (Coupon code used)'; } ?> </span></span> </li> <li class="clearfix bottom"> <span class="label col-md-4 col-sm-5 col-xs-12" style="padding:10px 10px 0 10px;" ><span class="inner"><span class="checkout_icon" id="icon_cal"></span> <?php if ($result->status == 1) { ?>
?> " /> </p> <?php $currency_symbol = $this->Common_model->getTableData('currency', array('currency_code' => get_currency_code()))->row()->currency_symbol; ?> <p align="center"><b>Price <?php echo $currency_symbol; ?> :</b> <input type="text" id="price_special" name="price_special" value="<?php echo get_currency_value_lys($result->currency, get_currency_code(), $subtotal); ?> " /></p> <input type="hidden" id="price_original" name="price_original" value="<?php echo get_currency_value_lys($result->currency, get_currency_code(), $price_original); ?> " /></p> <p align="center">Enter the price for the reservation including all additional costs</p> <p></p> <p><?php echo translate("Optional message") . "..."; ?> </p> <p><textarea class="comment_contact" name="comment_special" id="comment_special"></textarea></p> <p> <input type="button" class="accept_button" name="offered" value="<?php echo "Send message"; ?> " onclick="javascript:req_action('special');" />
?> </div> <div class="line_reg" style="z-index:<?php echo $j; ?> ;" id="square_<?php echo $i; ?> "> <span class="startcap"></span> <span class="content"></span> <span class="endcap"><b><?php echo get_currency_symbol($list_id) . get_currency_value1($list_id, $price); ?> </b></span> </div> <!--Edit calender ---> <?php echo get_currency_symbol($list_id) . get_currency_value_lys($listcurrency, get_currency_code(), $price); ?> </b></span> </div> <!--edit calender --> </div> </div> <?php } ?> <?php $day_count++; $day_nextmonth++; $i++;
function refund($param) { $ci =& get_instance(); $conditions = array("reservation.id" => $param); $data['result'] = $row = $ci->Trips_model->get_reservation($conditions)->row(); $query = $ci->Users_model->get_user_by_id($row->userby); $data['booker_name'] = $query->row()->username; $query1 = $ci->Users_model->get_user_by_id($row->userto); $data['hotelier_name'] = $query1->row()->username; $data['currency_code'] = $data['result']->currency; $cancellation_policy = $ci->Common_model->getTableData('cancellation_policy', array('id' => $row->policy))->row(); if ($row->status == 6) { if (round($row->cleaning + $row->security + $row->extra_guest_price + before_checkin_guest($param), 2) != 0) { $refund_data['guest_topay'] = round($row->cleaning + $row->security + $row->extra_guest_price + before_checkin_guest($param), 2); } if (round(before_checkin_host($param), 2) != 0) { if ($row->host_penalty == 0) { $host_penalty = $ci->Common_model->getTableData('host_cancellation_penalty', array('user_id' => $row->userto)); if ($host_penalty->num_rows() != 0) { if (round(before_checkin_host($param), 2) > get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount)) { $refund_data['host_penalty'] = get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $refund_data['host_topay'] = round(before_checkin_host($param), 2) - get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $penalty_data['update_penalty'] = 0; } else { $refund_data['host_penalty'] = get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], round(before_checkin_host($param), 2)); $refund_data['host_topay'] = 0; $penalty_data['update_penalty'] = $host_penalty->row()->amount - get_currency_value_lys($data['currency_code'], $host_penalty->row()->currency, round(before_checkin_host($param), 2)); $ci->Common_model->updateTableData('reservation', 0, array('id' => $data['result']->id), array('host_penalty' => $refund_data['host_penalty'])); //$ci->Common_model->updateTableData('host_cancellation_penalty',0,array('id'=>$host_penalty->row()->id),array('amount'=>$penalty_data['update_penalty'])); } $ci->Common_model->updateTableData('host_cancellation_penalty', 0, array('id' => $host_penalty->row()->id), array('amount' => $penalty_data['update_penalty'])); } else { $refund_data['host_topay'] = round(before_checkin_host($param), 2); } } else { $refund_data['host_topay'] = round(before_checkin_host($param), 2) - $data['result']->host_penalty; } } else { //$data['host_topay'] = round($ci->before_checkin_host($param),2); } } if ($row->status == 12) { $additional_fees_guest = 0; $additional_fees_host = 0; if ($cancellation_policy->cleaning_status == 1) { $additional_fees_guest += $row->cleaning; } else { $additional_fees_host += $row->cleaning; } if ($cancellation_policy->security_status == 1) { $additional_fees_guest += $row->security; } else { $additional_fees_host += $row->cleaning; } if ($cancellation_policy->additional_status == 1) { $additional_fees_guest += $row->extra_guest_price; } else { $additional_fees_host += $row->cleaning; } if (round($additional_fees_guest + after_checkin_guest($param), 2) != 0) { $refund_data['guest_topay'] = round($additional_fees_guest + after_checkin_guest($param), 2); } if (round($additional_fees_host + after_checkin_host($param), 2) != 0) { if ($row->host_penalty == 0) { $host_penalty = $ci->Common_model->getTableData('host_cancellation_penalty', array('user_id' => $row->userto)); if ($host_penalty->num_rows() != 0) { if (round($additional_fees_host + after_checkin_host($param), 2) > get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount)) { $refund_data['host_penalty'] = get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $refund_data['host_topay'] = round($additional_fees_host + after_checkin_host($param), 2) - get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $penalty_data['update_penalty'] = 0; } else { $refund_data['host_penalty'] = round($additional_fees_host + after_checkin_host($param), 2); $refund_data['host_topay'] = 0; $refund_data['update_penalty'] = $host_penalty->row()->amount - get_currency_value_lys($data['currency_code'], $host_penalty->row()->currency, round($additional_fees_host + after_checkin_host($param), 2)); $ci->Common_model->updateTableData('reservation', 0, array('id' => $data['result']->id), array('host_penalty' => $refund_data['host_penalty'])); //$ci->Common_model->updateTableData('host_cancellation_penalty',0,array('id'=>$host_penalty->row()->id),array('amount'=>$penalty_data['update_penalty'])); } $ci->Common_model->updateTableData('host_cancellation_penalty', 0, array('id' => $host_penalty->row()->id), array('amount' => $penalty_data['update_penalty'])); } else { $refund_data['host_topay'] = round($additional_fees_host + after_checkin_host($param), 2); } } else { $refund_data['host_topay'] = round($additional_fees_host + after_checkin_host($param), 2) - $data['result']->host_penalty; } } } if ($row->status == 7 || $row->status == 10 || $row->status == 8 || $row->status == 9) { if ($data['result']->host_penalty == 0) { $host_penalty = $ci->Common_model->getTableData('host_cancellation_penalty', array('user_id' => $row->userto)); if ($host_penalty->num_rows() != 0) { if ($data['result']->topay > get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount)) { $refund_data['host_penalty'] = get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $host_to_pay_penalty_data['host_to_pay_penalty'] = get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $refund_data['topay'] = $data['result']->topay - get_currency_value_lys($host_penalty->row()->currency, $data['currency_code'], $host_penalty->row()->amount); $penalty_data['update_penalty'] = 0; } else { $host_to_pay_penalty_data['host_to_pay_penalty'] = $data['result']->topay; $refund_data['topay'] = 0; $penalty_data['update_penalty'] = $host_penalty->row()->amount - get_currency_value_lys($data['currency_code'], $host_penalty->row()->currency, $data['result']->topay); $refund_data['host_penalty'] = $penalty_data['update_penalty']; $ci->Common_model->updateTableData('reservation', 0, array('id' => $data['result']->id), array('host_penalty' => $host_to_pay_penalty_data['host_to_pay_penalty'])); //$ci->Common_model->updateTableData('host_cancellation_penalty',0,array('id'=>$host_penalty->row()->id),array('amount'=>$penalty_data['update_penalty'])); } $ci->Common_model->updateTableData('host_cancellation_penalty', 0, array('id' => $host_penalty->row()->id), array('amount' => $penalty_data['update_penalty'])); } else { $refund_data['topay'] = $data['result']->topay; } } else { $refund_data['topay'] = $data['result']->topay - $data['result']->host_penalty; } } else { if ($row->status == 13 || $row->status == 4 || $row->status == 2) { //$refund_data['commission_status'] = 0; $refund_data['topay'] = $data['result']->price; } else { $refund_data['topay'] = $data['result']->topay; } } if ($data['result']->coupon != 0) { $data['coupon_price'] = $ci->Common_model->getTableData('coupon', array('couponcode' => $data['result']->coupon))->row()->coupon_price; $data['coupon_currency'] = $ci->Common_model->getTableData('coupon', array('couponcode' => $data['result']->coupon))->row()->currency; if ($row->status == 5 || $row->status == 7 || $row->status == 8 || $row->status == 9 || $row->status == 10) { $refund_data['topay'] = $refund_data['topay'] + $data['coupon_price']; } if (isset($refund_data['host_topay'])) { $refund_data['host_topay'] = $refund_data['host_topay'] + $data['coupon_price']; } } $ci->Common_model->updateTableData('reservation', 0, array('id' => $param), $refund_data); return json_encode($refund_data); }
function toPay() { $result = $this->input->post(); //print_r($result['to_pay']); if (isset($result['to_pay'])) { $this->session->set_userdata('host_topay', $result['to_pay']); } $check_paypal = $this->db->where('is_enabled', 1)->where('payment_name', 'Paypal')->get('payments')->num_rows(); if ($check_paypal == 0) { $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate("Payment gateway is not enabled. Please enable it."))); redirect_admin('payment/finance'); } if ($this->input->post('payviapaypal')) { $check_paypal = $this->db->where('is_enabled', 1)->where('payment_name', 'Paypal')->get('payments')->num_rows(); $list_id = $this->input->post('list_id'); $reservation_id = $this->input->post('reservation_id'); $amount = $this->input->post('to_pay'); $business = $this->input->post('biz_id'); $currency_code = $this->input->post('currency'); // Verify return $custom = $list_id . ',' . $reservation_id . ',' . $business . ',' . $amount; /*if($currency_code == 'INR' || $currency_code == 'MYR' || $currency_code == 'ARS' || $currency_code == 'CNY' || $currency_code == 'IDR' || $currency_code == 'KRW' || $currency_code == 'VND' || $currency_code == 'ZAR' || $currency_code == 'MXN') {*/ $currency_code1 = 'USD'; $amount = get_currency_value_lys($currency_code, $currency_code1, $amount); $this->session->set_userdata('currency_code', $currency_code1); /*} else { $currency_code1 = $currency_code; $amount = $amount; $this->session->set_userdata('currency_code',$currency_code1); }*/ $this->session->set_userdata('custom', $custom); $currency = $currency_code1; $result = $this->Common_model->getTableData('reservation', array('id' => $reservation_id))->row(); $host_payout_id = $business; // echo $host_payout_id->email;exit; // Set request-specific fields. $vEmailSubject = 'PayPal payment'; $emailSubject = urlencode($vEmailSubject); $receiverType = urlencode($host_payout_id); $currency = urlencode($currency_code1); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Receivers // Use '0' for a single receiver. In order to add new ones: (0, 1, 2, 3...) // Here you can modify to obtain array data from database. $receivers = array(0 => array('receiverEmail' => "{$host_payout_id}", 'amount' => "{$amount}", 'uniqueID' => "{$reservation_id}", 'note' => " payment of commissions")); $receiversLenght = count($receivers); // Add request-specific fields to the request string. $nvpStr = "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE=USD"; $receiversArray = array(); for ($i = 0; $i < $receiversLenght; $i++) { $receiversArray[$i] = $receivers[$i]; } foreach ($receiversArray as $i => $receiverData) { $receiverEmail = urlencode($receiverData['receiverEmail']); $amount = urlencode($receiverData['amount']); $uniqueID = urlencode($receiverData['uniqueID']); $note = urlencode($receiverData['note']); $nvpStr .= "&L_EMAIL{$i}={$receiverEmail}&L_Amt{$i}={$amount}&L_UNIQUEID{$i}={$uniqueID}&L_NOTE{$i}={$note}"; } //echo $receiverEmail;exit; $this->session->set_userdata('payout_id', $receiverEmail); // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = $this->PPHttpPost('MassPay', $nvpStr); //echo $nvpStr;exit; if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { //exit('MassPay Completed Successfully: ' . print_r($httpParsedResponseAr, true)); $this->session->set_userdata('paid_to', 'common'); redirect_admin('payment/paypal_success/' . $reservation_id); } else { $this->session->set_userdata('error_msg', str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0'])); //exit('MassPay failed: ' . print_r($httpParsedResponseAr['L_LONGMESSAGE0'], true));exit; redirect_admin('payment/paypal_cancel'); } } else { if ($this->input->post('payviapaypal_guest')) { //echo $this->input->post('host_to_pay');exit; $check_paypal = $this->db->where('is_enabled', 1)->where('payment_name', 'Paypal')->get('payments')->num_rows(); if ($check_paypal == 0) { $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate("Payment gateway is not enabled. Please enable it."))); redirect_admin('payment/finance'); } $list_id = $this->input->post('list_id'); $reservation_id = $this->input->post('reservation_id'); $amount = $this->input->post('guest_to_pay'); $business = $this->input->post('guest_biz_id'); $currency_code = $this->input->post('currency'); // Verify return $custom = $list_id . ',' . $reservation_id . ',' . $business . ',' . $amount; /*if($currency_code == 'INR' || $currency_code == 'MYR' || $currency_code == 'ARS' || $currency_code == 'CNY' || $currency_code == 'IDR' || $currency_code == 'KRW' || $currency_code == 'VND' || $currency_code == 'ZAR' || $currency_code == 'MXN') {*/ $currency_code1 = 'USD'; $amount = get_currency_value_lys($currency_code, $currency_code1, $amount); $this->session->set_userdata('currency_code', $currency_code1); /*} else { $currency_code1 = $currency_code; $amount = $amount; $this->session->set_userdata('currency_code',$currency_code1); }*/ $this->session->set_userdata('custom', $custom); $currency = $currency_code1; $result = $this->Common_model->getTableData('reservation', array('id' => $reservation_id))->row(); $host_payout_id = $business; // echo $host_payout_id->email;exit; // Set request-specific fields. $vEmailSubject = 'PayPal payment'; $emailSubject = urlencode($vEmailSubject); $receiverType = urlencode($host_payout_id); $currency = urlencode($currency_code1); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Receivers // Use '0' for a single receiver. In order to add new ones: (0, 1, 2, 3...) // Here you can modify to obtain array data from database. $receivers = array(0 => array('receiverEmail' => "{$host_payout_id}", 'amount' => "{$amount}", 'uniqueID' => "{$reservation_id}", 'note' => " payment of commissions")); $receiversLenght = count($receivers); // Add request-specific fields to the request string. $nvpStr = "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE=USD"; $receiversArray = array(); for ($i = 0; $i < $receiversLenght; $i++) { $receiversArray[$i] = $receivers[$i]; } foreach ($receiversArray as $i => $receiverData) { $receiverEmail = urlencode($receiverData['receiverEmail']); $amount = urlencode($receiverData['amount']); $uniqueID = urlencode($receiverData['uniqueID']); $note = urlencode($receiverData['note']); $nvpStr .= "&L_EMAIL{$i}={$receiverEmail}&L_Amt{$i}={$amount}&L_UNIQUEID{$i}={$uniqueID}&L_NOTE{$i}={$note}"; } //echo $receiverEmail;exit; $this->session->set_userdata('payout_id', $receiverEmail); // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = $this->PPHttpPost('MassPay', $nvpStr); //echo $nvpStr;exit; if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { //exit('MassPay Completed Successfully: ' . print_r($httpParsedResponseAr, true)); $this->session->set_userdata('paid_to', 'guest'); redirect_admin('payment/paypal_success/' . $reservation_id); } else { $this->session->set_userdata('error_msg', str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0'])); //exit('MassPay failed: ' . print_r($httpParsedResponseAr['L_LONGMESSAGE0'], true));exit; redirect_admin('payment/paypal_cancel'); } } } if ($this->input->post('payviapaypal_host')) { $check_paypal = $this->db->where('is_enabled', 1)->where('payment_name', 'Paypal')->get('payments')->num_rows(); if ($check_paypal == 0) { $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate("Payment gateway is not enabled. Please enable it."))); redirect_admin('payment/finance'); } $list_id = $this->input->post('list_id'); $reservation_id = $this->input->post('reservation_id'); $amount = $this->input->post('host_to_pay'); $business = $this->input->post('host_biz_id'); $currency_code = $this->input->post('currency'); // Verify return $custom = $list_id . ',' . $reservation_id . ',' . $business . ',' . $amount; /*if($currency_code == 'INR' || $currency_code == 'MYR' || $currency_code == 'ARS' || $currency_code == 'CNY' || $currency_code == 'IDR' || $currency_code == 'KRW' || $currency_code == 'VND' || $currency_code == 'ZAR' || $currency_code == 'MXN') {*/ $currency_code1 = 'USD'; $amount = get_currency_value_lys($currency_code, $currency_code1, $amount); $this->session->set_userdata('currency_code', $currency_code1); /*} else { $currency_code1 = $currency_code; $amount = $amount; $this->session->set_userdata('currency_code',$currency_code1); }*/ $this->session->set_userdata('custom', $custom); $currency = $currency_code1; $result = $this->Common_model->getTableData('reservation', array('id' => $reservation_id))->row(); $host_payout_id = $business; // echo $host_payout_id->email;exit; // Set request-specific fields. $vEmailSubject = 'PayPal payment'; $emailSubject = urlencode($vEmailSubject); $receiverType = urlencode($host_payout_id); $currency = urlencode($currency_code1); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Receivers // Use '0' for a single receiver. In order to add new ones: (0, 1, 2, 3...) // Here you can modify to obtain array data from database. $receivers = array(0 => array('receiverEmail' => "{$host_payout_id}", 'amount' => "{$amount}", 'uniqueID' => "{$reservation_id}", 'note' => " payment of commissions")); $receiversLenght = count($receivers); // Add request-specific fields to the request string. $nvpStr = "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE=USD"; $receiversArray = array(); for ($i = 0; $i < $receiversLenght; $i++) { $receiversArray[$i] = $receivers[$i]; } foreach ($receiversArray as $i => $receiverData) { $receiverEmail = urlencode($receiverData['receiverEmail']); $amount = urlencode($receiverData['amount']); $uniqueID = urlencode($receiverData['uniqueID']); $note = urlencode($receiverData['note']); $nvpStr .= "&L_EMAIL{$i}={$receiverEmail}&L_Amt{$i}={$amount}&L_UNIQUEID{$i}={$uniqueID}&L_NOTE{$i}={$note}"; } //echo $receiverEmail;exit; $this->session->set_userdata('payout_id', $receiverEmail); // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = $this->PPHttpPost('MassPay', $nvpStr); //echo $nvpStr;exit; if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { $this->session->set_userdata('paid_to', 'host'); //exit('MassPay Completed Successfully: ' . print_r($httpParsedResponseAr, true)); redirect_admin('payment/paypal_success/' . $reservation_id); } else { $this->session->set_userdata('error_msg', str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0'])); //exit('MassPay failed: ' . print_r($httpParsedResponseAr['L_LONGMESSAGE0'], true));exit; redirect_admin('payment/paypal_cancel'); } } else { if ($this->input->post('payviapaypal_accept_pay')) { $accept_pay_result = $this->Common_model->getTableData('accept_pay', array('id' => $this->input->post('accept_pay')))->row(); $check_paypal = $this->db->where('is_enabled', 1)->where('payment_name', 'Paypal')->get('payments')->num_rows(); if ($check_paypal == 0) { $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate("Payment gateway is not enabled. Please enable it."))); redirect_admin('payment/finance'); } $list_id = $this->input->post('list_id'); $reservation_id = $this->input->post('reservation_id'); $amount = $accept_pay_result->amount; $business = $this->input->post('biz_host_id'); $currency_code = $accept_pay_result->currency; // Verify return $custom = $list_id . ',' . $reservation_id . ',' . $business . ',' . $amount; $this->session->set_userdata('custom', $custom); $currency = $currency_code; $result = $this->Common_model->getTableData('reservation', array('id' => $reservation_id))->row(); $host_payout_id = $business; // echo $host_payout_id->email;exit; // Set request-specific fields. $vEmailSubject = 'PayPal payment'; $emailSubject = urlencode($vEmailSubject); $receiverType = urlencode($host_payout_id); $currency = urlencode($currency_code); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Receivers // Use '0' for a single receiver. In order to add new ones: (0, 1, 2, 3...) // Here you can modify to obtain array data from database. $receivers = array(0 => array('receiverEmail' => "{$host_payout_id}", 'amount' => "{$amount}", 'uniqueID' => "{$reservation_id}", 'note' => " payment of commissions")); $receiversLenght = count($receivers); // Add request-specific fields to the request string. $nvpStr = "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE=USD"; $receiversArray = array(); for ($i = 0; $i < $receiversLenght; $i++) { $receiversArray[$i] = $receivers[$i]; } foreach ($receiversArray as $i => $receiverData) { $receiverEmail = urlencode($receiverData['receiverEmail']); $amount = urlencode($receiverData['amount']); $uniqueID = urlencode($receiverData['uniqueID']); $note = urlencode($receiverData['note']); $nvpStr .= "&L_EMAIL{$i}={$receiverEmail}&L_Amt{$i}={$amount}&L_UNIQUEID{$i}={$uniqueID}&L_NOTE{$i}={$note}"; } $this->session->set_userdata('payout_id', $receiverEmail); // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = $this->PPHttpPost('MassPay', $nvpStr); //echo $nvpStr;exit; if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { //exit('MassPay Completed Successfully: ' . print_r($httpParsedResponseAr, true)); redirect_admin('payment/paypal_commission_success/' . $accept_pay_result->id); } else { $this->session->set_userdata('error_msg', str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0'])); //exit('MassPay failed: ' . print_r($httpParsedResponseAr['L_LONGMESSAGE0'], true));exit; redirect_admin('payment/paypal_cancel'); } } else { if ($this->input->post('payviabraintree')) { $transaction_id = $this->input->post('braintree_id'); if ($this->input->post('guest_to_pay')) { $topay_amount = $this->input->post('guest_to_pay'); } else { $topay_amount = $this->input->post('to_pay'); } $clientToken = Braintree_ClientToken::generate(array()); if ($clientToken == '401') { $data['message'] = "Braintree business account is misconfigured."; $data['status'] = 'braintree'; $data['message_element'] = "administrator/payment/paypal_cancel"; $this->load->view('administrator/admin_template', $data); } else { $result = Braintree_Transaction::refund($transaction_id, get_currency_value_lys($this->input->post('currency'), 'USD', $topay_amount)); if ($result->success == 1) { $result->success; # true $refund = $result->transaction; $refund->type; # 'credit' $refund->refundedTransactionId; # original transaction ID Braintree_Transaction::find($refund->refundedTransactionId)->refundId; $reservation_id = $this->input->post('reservation_id'); $result = $this->Common_model->getTableData('reservation', array('id' => $reservation_id))->row(); $list_id = $result->list_id; $checkin = $result->checkin; $checkout = $result->checkout; $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $query = $this->Users_model->get_user_by_id($result->userby); $traveler_name = $query->row()->username; $traveler_email = $query->row()->email; $query1 = $this->Users_model->get_user_by_id($result->userto); $hotelier_name = $query1->row()->username; $hotelier_email = $query1->row()->email; $currency_symbol = $this->Common_model->getTableData('currency', array('currency_code' => $result->currency))->row()->currency_symbol; $refund_amt = $currency_symbol . $topay_amount; $conversation = $this->db->where('userto', $result->userto)->where('userby', 1)->order_by('id', 'desc')->get('messages'); if ($conversation->num_rows() != 0) { foreach ($conversation->result() as $row3) { if ($row3->conversation_id != 0) { $conversation_id = $row3->conversation_id; } else { $conversation1 = $this->db->where('userto', 1)->where('userby', $result->userto)->order_by('id', 'desc')->get('messages'); if ($conversation1->num_rows() != 0) { foreach ($conversation1->result() as $row2) { if ($row2->conversation_id != 0) { $conversation_id = $row2->conversation_id; } } } else { $conversation_id = 0; } } } } else { $conversation1 = $this->db->where('userto', 1)->where('userby', $result->userto)->order_by('id', 'desc')->get('messages'); if ($conversation1->num_rows() != 0) { foreach ($conversation1->result() as $row1) { if ($row1->conversation_id != 0) { $conversation_id = $row1->conversation_id; } } } else { $conversation_id = 0; } } $name = ''; /*if($result->status != 1 && $result->status != 2 && $result->status != 4 && $result->status != 5 && $result->status != 6 ) { //Reservation Notification To Host // $host_payout_id = get_userPayout($result->userto)->email; $name = $hotelier_name; $email_name = 'refund_host'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(),"{currency}"=>$currency_symbol,"{price}"=>$result->price,"{account}" => "Credit Card","{traveler_name}" => ucfirst($traveler_name), "{host_name}" => ucfirst($hotelier_name), "{list_title}" => get_list_by_id($list_id)->title, "{payed_date}" => date("F j, Y",time()), "{checkin}" => date("F j, Y",$checkin), "{checkout}" => date("F j, Y",$checkout), "{refund_amt}" => $refund_amt); //Send Mail $this->Email_model->sendMail($hotelier_email,$admin_email,ucfirst($admin_name),$email_name,$splVars); if(!isset($conversation_id)) { $insertData = array( 'list_id' => $result->list_id, 'reservation_id' => $result->id, 'userby' => 1, 'userto' => $result->userto, 'message' => "Admin refund $refund_amt to you.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 3 ); } else { $insertData = array( 'list_id' => $result->list_id, 'reservation_id' => $result->id, 'conversation_id' => $conversation_id, 'userby' => 1, 'userto' => $result->userto, 'message' => "Admin refund $refund_amt to you.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 3 ); } $refund_data['userto'] = $result->userto; $this->Message_model->sentMessage($insertData); } else {*/ //Reservation Notification To Guest $name = $traveler_name; //$host_payout_id = get_userPayout($result->userby)->email; $name = $traveler_name; $email_name = 'refund_guest'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{currency}" => $currency_symbol, "{price}" => $result->price, "{account}" => "Credit Card", "{traveler_name}" => ucfirst($traveler_name), "{host_name}" => ucfirst($hotelier_name), "{list_title}" => get_list_by_id($list_id)->title, "{payed_date}" => date("F j, Y", time()), "{checkin}" => date("F j, Y", $checkin), "{checkout}" => date("F j, Y", $checkout), "{refund_amt}" => $refund_amt); //Send Mail $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); if (!isset($conversation_id)) { $insertData = array('list_id' => $result->list_id, 'reservation_id' => $result->id, 'userby' => 1, 'userto' => $result->userby, 'message' => "Admin refund {$refund_amt} to you.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 3); } else { $insertData = array('list_id' => $result->list_id, 'reservation_id' => $result->id, 'conversation_id' => $conversation_id, 'userby' => 1, 'userto' => $result->userby, 'message' => "Admin refund {$refund_amt} to you.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 3); } $refund_data['userto'] = $result->userby; $this->Message_model->sentMessage($insertData); //} $refund_data['reservation_id'] = $result->id; $refund_data['payout_id'] = 'Creditcard'; $refund_data['created'] = time(); $this->Common_model->inserTableData('refund', $refund_data); $admin_to_email = $this->db->where('id', 1)->get('users')->row()->email; //Reservation Notification To Admin $email_name = 'refund_admin'; $splVars = array("{name}" => $name, "{traveler_email}" => $traveler_email, "{host_email}" => $hotelier_email, "{site_name}" => $this->dx_auth->get_site_title(), "{currency}" => $currency_symbol, "{price}" => $result->price, "{account}" => "Credit Card", "{traveler_name}" => ucfirst($traveler_name), "{host_name}" => ucfirst($hotelier_name), "{list_title}" => get_list_by_id($list_id)->title, "{payed_date}" => date("F j, Y", time()), "{checkin}" => date("F j, Y", $checkin), "{checkout}" => date("F j, Y", $checkout), "{refund_amt}" => $refund_amt); //Send Mail $this->Email_model->sendMail($admin_to_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); $this->db->where('id', $this->input->post('reservation_id'))->update('reservation', array('is_payed_guest' => 1)); if ($result->is_payed_host == 1 && $result->is_payed_guest == 1) { $this->db->where('id', $this->input->post('reservation_id'))->update('reservation', array('is_payed' => 1)); } if (!$this->input->post('host_biz_id')) { $this->db->where('id', $this->input->post('reservation_id'))->update('reservation', array('is_payed' => 1)); } $data['status'] = 'braintree'; $data['message_element'] = "administrator/payment/paypal_success"; $this->load->view('administrator/admin_template', $data); } else { $data['message'] = $result->message; $data['status'] = 'braintree'; $data['message_element'] = "administrator/payment/paypal_cancel"; $this->load->view('administrator/admin_template', $data); } } } else { if ($this->input->post('payviabraintree_accept_pay')) { $transaction_id = $this->input->post('accept_braintree_id'); $accept_pay_result = $this->Common_model->getTableData('accept_pay', array('id' => $this->input->post('accept_pay')))->row(); $clientToken = Braintree_ClientToken::generate(array()); if ($clientToken == '401') { $data['message'] = "Braintree business account is misconfigured."; $data['status'] = 'braintree'; $data['message_element'] = "administrator/payment/paypal_cancel"; $this->load->view('administrator/admin_template', $data); } else { $result = Braintree_Transaction::refund($transaction_id, get_currency_value_lys($this->input->post('currency'), 'USD', $accept_pay_result->amount)); if ($result->success == 1) { $result->success; # true $refund = $result->transaction; $refund->type; # 'credit' $refund->refundedTransactionId; # original transaction ID Braintree_Transaction::find($refund->refundedTransactionId)->refundId; $accept_pay_result = $this->db->where('id', $this->input->post('accept_pay'))->get('accept_pay')->row(); $is_payed = $accept_pay_result->status; if ($is_payed == 0) { $result = $this->Common_model->getTableData('reservation', array('id' => $accept_pay_result->reservation_id))->row(); $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $query = $this->Users_model->get_user_by_id($result->userby); $traveler_name = $query->row()->username; $traveler_email = $query->row()->email; $query1 = $this->Users_model->get_user_by_id($result->userto); $hotelier_name = $query1->row()->username; $hotelier_email = $query1->row()->email; $currency_symbol = $this->Common_model->getTableData('currency', array('currency_code' => $accept_pay_result->currency))->row()->currency_symbol; $refund_amt = $currency_symbol . $accept_pay_result->amount; $conversation = $this->db->where('userto', $result->userto)->where('userby', 1)->order_by('id', 'desc')->get('messages'); if ($conversation->num_rows() != 0) { foreach ($conversation->result() as $row3) { if ($row3->conversation_id != 0) { $conversation_id = $row3->conversation_id; } else { $conversation1 = $this->db->where('userto', 1)->where('userby', $result->userto)->order_by('id', 'desc')->get('messages'); if ($conversation1->num_rows() != 0) { foreach ($conversation1->result() as $row2) { if ($row2->conversation_id != 0) { $conversation_id = $row2->conversation_id; } } } else { $conversation_id = 0; } } } } else { $conversation1 = $this->db->where('userto', 1)->where('userby', $result->userto)->order_by('id', 'desc')->get('messages'); if ($conversation1->num_rows() != 0) { foreach ($conversation1->result() as $row1) { if ($row1->conversation_id != 0) { $conversation_id = $row1->conversation_id; } } } else { $conversation_id = 0; } } $name = ''; //Reservation Notification To Host // $host_payout_id = get_userPayout($result->userto)->email; $name = $hotelier_name; $email_name = 'refund_host_commission'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{currency}" => $currency_symbol, "{host_name}" => ucfirst($hotelier_name), "{account}" => "Braintree", "{list_title}" => get_list_by_id($result->list_id)->title, "{payed_date}" => date("F j, Y", time()), "{refund_amt}" => $refund_amt); //Send Mail $this->Email_model->sendMail($hotelier_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); if (!isset($conversation_id)) { $insertData = array('list_id' => $result->list_id, 'reservation_id' => $result->id, 'userby' => 1, 'userto' => $result->userto, 'message' => "Admin refund {$refund_amt} to you for Host reservation accept commission.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 3); } else { $insertData = array('list_id' => $result->list_id, 'reservation_id' => $result->id, 'conversation_id' => $conversation_id, 'userby' => 1, 'userto' => $result->userto, 'message' => "Admin refund {$refund_amt} to you for Host reservation accept commission.", 'created' => date('m/d/Y g:i A'), 'message_type ' => 3); } $refund_data['userto'] = $result->userto; $this->Message_model->sentMessage($insertData); $refund_data['reservation_id'] = $accept_pay_result->reservation_id; $refund_data['payout_id'] = 'Creditcard'; $refund_data['created'] = time(); $refund_data['accept_status'] = 1; $this->Common_model->inserTableData('refund', $refund_data); $admin_to_email = $this->db->where('id', 1)->get('users')->row()->email; //Reservation Notification To Admin $email_name = 'refund_host_commission_admin'; $splVars = array("{name}" => $name, "{traveler_email}" => $traveler_email, "{host_email}" => $hotelier_email, "{site_name}" => $this->dx_auth->get_site_title(), "{currency}" => $currency_symbol, "{account}" => "Braintree", "{host_name}" => ucfirst($hotelier_name), "{list_title}" => get_list_by_id($result->list_id)->title, "{payed_date}" => date("F j, Y", time()), "{refund_amt}" => $refund_amt); //Send Mail $this->Email_model->sendMail($admin_to_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); $this->db->where('id', $this->input->post('accept_pay'))->update('accept_pay', array('status' => 1)); $data['status'] = 'braintree'; $data['message_element'] = "administrator/payment/paypal_success"; $this->load->view('administrator/admin_template', $data); } } else { $data['message'] = $result->message; $data['status'] = 'braintree'; $data['message_element'] = "administrator/payment/paypal_cancel"; $this->load->view('administrator/admin_template', $data); } } } else { $this->form_validation->set_error_delimiters('<p style="clear:both;color: #FF0000;">', '</p>'); if ($this->input->post('send')) { $list_id = $this->input->post('list_id'); $reservation_id = $this->input->post('reservation_id'); // $this->form_validation->set_rules('comment','Message','required|trim|xss_clean'); //if($this->form_validation->run()) //{ if ($this->input->post('payout_userto1') != 0) { $payout_id = $this->input->post('payout_userto1'); } else { if ($this->input->post('payout_userto2') != 0) { $payout_id = $this->input->post('payout_userto2'); } } if ($this->input->post('payout_userby1') != 0) { $payout_id = $this->input->post('payout_userby1'); } else { if ($this->input->post('payout_userby2') != 0) { $payout_id = $this->input->post('payout_userby2'); } } $insertData = array('list_id' => $list_id, 'reservation_id' => $reservation_id, 'userby' => $this->dx_auth->get_user_id(), 'userto' => $payout_id, 'message' => $this->input->post('comment'), 'message_type ' => 3); $this->Message_model->sentMessage($insertData, 1); $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('success', translate("Message successfully sent."))); redirect_admin('payment/details/' . $reservation_id); //} $result = $this->db->where('reservation.id', $reservation_id)->get('reservation'); if ($result->num_rows() != 0) { $conditions = array("reservation.id" => $reservation_id); $data['result'] = $row = $this->Trips_model->get_reservation($conditions)->row(); $query = $this->Users_model->get_user_by_id($row->userby); $data['booker_name'] = $query->row()->username; $query1 = $this->Users_model->get_user_by_id($row->userto); $data['hotelier_name'] = $query1->row()->username; $data['currency_code'] = $data['result']->currency; if ($data['result']->coupon != 0) { $data['coupon_price'] = $this->Common_model->getTableData('coupon', array('couponcode' => $data['result']->coupon))->row()->coupon_price; $data['coupon_currency'] = $this->Common_model->getTableData('coupon', array('couponcode' => $data['result']->coupon))->row()->currency; } $data['currency_symbol'] = $this->Common_model->getTableData('currency', array('currency_code' => $data['result']->currency))->row()->currency_symbol; $data['message_element'] = "administrator/payment/view_details"; $this->load->view('administrator/admin_template', $data); } else { redirect_admin('payment/finance'); } } } } } } }
public function cancel_travel($params1 = '', $params2 = '', $params3 = '') { if ($params1 != '') { $conditions = array('reservation.id' => $params1); $row = $this->Trips_model->get_reservation($conditions)->row(); if ($row->status == 12 || $row->status == 6) { echo translate('This reservation is already cancelled by Guest.'); exit; } else { if ($row->status == 5 || $row->status == 11) { echo translate('This reservation is already cancelled by Host.'); exit; } } } if ($this->input->post('reservation_id')) { $reservation_id = $this->input->post('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(); $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; $updateKey = array('id' => $reservation_id); $updateData = array(); $check_user = $this->db->where('user_id', $this->dx_auth->get_user_id())->where('id', $row->list_id)->get('list'); if ($check_user->num_rows() == 1) { if ($row->status == 7) { $updateData['status'] = 11; } else { $updateData['status'] = 5; } if ($row->status == 1) { $updateData['status'] = 13; } $host_cancellation = $this->Common_model->getTableData('host_cancellation_policy', array('id' => 1))->row(); $check_free_cancellation_limit = $this->db->query("SELECT * FROM (`reservation`) WHERE `userto` = " . $this->dx_auth->get_user_id() . " AND from_unixtime(cancel_date) >= DATE_SUB(CURRENT_TIMESTAMP(),INTERVAL " . $host_cancellation->months . " MONTH) AND (`status` = 5 OR `status` = 11)"); if ($check_free_cancellation_limit->num_rows() >= $host_cancellation->free_cancellation) { $free_cancellation_limit = 0; $date1 = new DateTime(date('Y-m-d H:i:s')); $date2 = new DateTime(date('Y-m-d H:i:s', $row->checkin)); $interval = $date1->diff($date2); if ($interval->days < $host_cancellation->days) { $penalty_amount = $host_cancellation->before_amount; } else { $penalty_amount = $host_cancellation->after_amount; } $check_already_penalty = $this->Common_model->getTableData('host_cancellation_penalty', array('user_id' => $this->dx_auth->get_user_id())); if ($check_already_penalty->num_rows() != 0) { $update_penalty['amount'] = $check_already_penalty->row()->amount + get_currency_value_lys($host_cancellation->currency, $check_already_penalty->row()->currency, $penalty_amount); $update_penalty_key['id'] = $check_already_penalty->row()->id; $this->Common_model->updateTableData('host_cancellation_penalty', 0, $update_penalty_key, $update_penalty); } else { $insert_penalty['amount'] = $penalty_amount; $insert_penalty['user_id'] = $this->dx_auth->get_user_id(); $insert_penalty['currency'] = $host_cancellation->currency; $this->Common_model->inserTableData('host_cancellation_penalty', $insert_penalty); } $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => 1, 'userto' => $row->userto, 'message' => "You're cross the free cancellation limit. So, Admin will take {$penalty_amount}" . $host_cancellation->currency . " penalty amount from your next payout.", 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, 1); $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => 1, 'userto' => 1, 'message' => "{$host_name} cross the free cancellation limit. So, You will earn {$penalty_amount}" . $host_cancellation->currency . " penalty amount from {$host_name} next payout.", 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, 1); } else { $free_cancellation_limit = $host_cancellation->free_cancellation - $check_free_cancellation_limit->num_rows(); } $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userto, 'userto' => $row->userby, 'message' => "Sorry, Your reservation is cancelled by {$host_name} for {$list_title}.", 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, 1); } else { if ($row->status == 7) { $updateData['status'] = 12; } else { $updateData['status'] = 6; } if ($row->status == 1) { $updateData['status'] = 13; } $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userby, 'userto' => $row->userto, 'message' => "Sorry, Your list reservation is cancelled by {$traveler_name} for {$list_title}.", 'created' => local_to_gmt(), 'message_type' => 3); $this->Message_model->sentMessage($insertData, 1); } $updateData['cancel_date'] = time(); $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); /* $cancel_trip_referral_query = $this->db->select('cancel_trips_referral_code')->where('id',$row->userby)->get('users'); if($cancel_trip_referral_query->num_rows()!=0) { if($cancel_trip_referral_query->row()->cancel_trips_referral_code != '') { $this->db->set('trips_referral_code',$cancel_trip_referral_query->row()->cancel_trips_referral_code)->where('id',$row->userby)->update('users'); $this->db->set('cancel_trips_referral_code','')->where('id',$row->userby)->update('users'); $referral_by = $this->db->where('referral_code',$cancel_trip_referral_query->row()->cancel_trips_referral_code)->get('users'); if($referral_by->num_rows()!=0) { $referral_amount = $referral_by->row()->referral_amount-25; $this->db->set('referral_amount',$referral_amount)->where('referral_code',$cancel_trip_referral_query->row()->cancel_trips_referral_code)->update('users'); } } } $cancel_list_referral_query = $this->db->select('cancel_list_referral_code')->where('id',$row->userto)->get('users'); if($cancel_list_referral_query->num_rows()!=0) { if($cancel_list_referral_query->row()->cancel_list_referral_code != '') { $this->db->set('list_referral_code',$cancel_list_referral_query->row()->cancel_list_referral_code)->where('id',$row->userto)->update('users'); $this->db->set('cancel_list_referral_code','')->where('id',$row->userto)->update('users'); $referral_by = $this->db->where('referral_code',$cancel_list_referral_query->row()->cancel_list_referral_code)->get('users'); if($referral_by->num_rows()!=0) { $referral_amount = $referral_by->row()->referral_amount-75; $this->db->set('referral_amount',$referral_amount)->where('referral_code',$cancel_list_referral_query->row()->cancel_list_referral_code)->update('users'); } } } */ $comment = $this->input->post('comment'); $this->db->where('list_id', $row->list_id)->where('booked_days >=', $row->checkin)->where('booked_days <=', $row->checkout)->delete('calendar'); if ($row->status == 3) { $status = 'Confirmed'; } else { if ($row->status == 7) { $status = 'After Checkin'; } else { $status = 'Pending'; } } if ($updateData['status '] == 5 || $updateData['status '] == 11) { if (isset($penalty_amount)) { $penalty = 'From your next payout we will take ' . $penalty_amount . $host_cancellation->currency . ' penalty amount.'; $admin_penalty = 'From ' . $host_name . ' next payout You will earn ' . $penalty_amount . $host_cancellation->currency . ' penalty amount.'; } else { $penalty = ''; $admin_penalty = ''; } //if(isset($free_cancellation_limit)) //{ $free_cancellation = 'Remaining Free cancellation: ' . $free_cancellation_limit; //} //Send Mail To Host $email_name = 'host_reservation_cancel'; $splVars = array("{penalty}" => $penalty, "{cancellation_limit}" => $free_cancellation, "{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{comment}" => $comment, "{traveler_name}" => ucfirst($host_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($traveler_name)); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Traveller $email_name = 'traveler_reservation_cancel'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{user_type}" => 'Host', "{status}" => $status, "{comment}" => $comment, "{traveler_name}" => ucfirst($host_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($traveler_name)); $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); //Send Mail To Administrator $email_name = 'admin_reservation_cancel'; $splVars = array("{penalty}" => $admin_penalty, "{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{traveler_name}" => ucfirst($host_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($traveler_name)); $this->Email_model->sendMail($admin_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); } else { $admin_penalty = ''; $free_cancellation = ''; //Send Mail To Host $email_name = 'host_reservation_cancel'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{comment}" => $comment, "{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 Traveller $email_name = 'traveler_reservation_cancel'; $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{user_type}" => 'Guest', "{status}" => $status, "{comment}" => $comment, "{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_cancel'; $splVars = array("{penalty}" => $admin_penalty, "{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{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 cancelled the trip.'))); if ($params3 == '') { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Reservation Cancelled Successfully.'))); redirect('travelling/your_trips'); } else { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Reservation Cancelled Successfully.'))); redirect('listings/my_reservation'); } } else { $conditions = array('reservation.id' => $params1); $row = $this->Trips_model->get_reservation($conditions)->row(); if ($this->Trips_model->get_reservation($conditions)->num_rows() == 0) { redirect('info'); } $check_user = $this->db->where('user_id', $this->dx_auth->get_user_id())->where('id', $row->list_id)->get('list'); if ($check_user->num_rows() == 1) { $data['user_type'] = 'host'; } else { $data['user_type'] = 'guest'; } $checkin = $row->checkin; $checkout = $row->checkout; $diff1 = $checkout - $checkin; $days1 = ceil($diff1 / (3600 * 24)); $diff2 = local_to_gmt() - $checkin; $days2 = ceil($diff2 / (3600 * 24)); $policy = $this->Common_model->getTableData('cancellation_policy', array('id' => $row->policy))->row(); $data['policy_name'] = $policy->name; $date1 = new DateTime(date('Y-m-d H:i:s', $row->checkin)); $date2 = new DateTime(date('Y-m-d H:i:s')); $interval = $date1->diff($date2); if ($row->status != 7) { if ($policy->list_before_status == 0) { $data['nights'] = 0; $data['non_nights'] = ceil($diff1 / (3600 * 24)); } else { if ($policy->list_before_days <= $interval->days) { $data['nights'] = $days = $interval->days; $data['non_nights'] = 0; } else { $data['nights'] = $days = ceil($diff1 / (3600 * 24)) - $policy->list_non_refundable_nights; if ($policy->list_non_refundable_nights > ceil($diff1 / (3600 * 24))) { $data['non_nights'] = ceil($diff1 / (3600 * 24)); } else { $data['non_nights'] = $policy->list_non_refundable_nights; } } } } else { if ($row->status == 7) { } } $data['reservation_id'] = $params1; $data['list_id'] = $params2; $this->load->view(THEME_FOLDER . '/travelling/view_cancel_travel', $data); } }
public function braintree_success() { $result = Braintree_Transaction::sale(array('amount' => get_currency_value_lys(get_currency_code(), 'USD', $this->session->userdata('list_commission')), "paymentMethodNonce" => $_POST['payment_method_nonce'], 'options' => array('submitForSettlement' => true))); $transaction = $result->transaction; /* if($result->success == 1) { if($result->message == "Amount must be greater than zero.") { $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error',$result->message)); redirect('rooms/'.$this->input->post('custom',true), "refresh"); } */ if (!$this->dx_auth->is_logged_in() || !$this->facebook_lib->logged_in()) { //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error',translate('Session expired, please try again.'))); //redirect('users/signin'); } if ($transaction->status == "authorized" || $transaction->status == "submitted_for_settlement") { $listId = $this->input->post('custom', true); $condition = array('id' => $listId); $data['status'] = 1; $data['list_pay'] = 1; $data['is_enable'] = 1; $data['payment'] = 1; $this->Common_model->updateTableData('list', NULL, $condition, $data); if (!$this->dx_auth->is_logged_in() || !$this->facebook_lib->logged_in()) { //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error',translate('Session expired, please try again.'))); //redirect('users/signin'); } $query_user = $this->Common_model->getTableData('users', array('id' => $this->dx_auth->get_user_id()))->row(); $username = $query_user->username; $insertData = array('list_id' => $listId, 'conversation_id' => $listId, 'userby' => $this->dx_auth->get_user_id(), 'userto' => 1, 'message' => "{$username} created a new list.", 'created' => time(), 'message_type ' => 10); $this->Message_model->sentMessage($insertData); $host_email = $query_user->email; $admin_email = $this->dx_auth->get_site_sadmin(); $admin_name = $this->dx_auth->get_site_title(); $admin_to_email = $this->Common_model->getTableData('users', array('id' => 1))->row()->email; $query_list = $this->Common_model->getTableData('list', array('id' => $listId))->row(); $currency = $query_list->currency; $price = $query_list->price; $title = $query_list->title; $link = base_url() . 'rooms/' . $listId; $email_name = 'list_create_host'; $splVars = array("{host_name}" => $username, "{price}" => $currency . $price, "{link}" => $link, "{list_title}" => $title, "{site_name}" => $this->dx_auth->get_site_title()); $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); $email_name = 'list_create_admin'; $splVars = array("{host_name}" => $username, "{price}" => $currency . $price, "{link}" => $link, "{list_title}" => $title, "{site_name}" => $this->dx_auth->get_site_title()); $this->Email_model->sendMail($admin_to_email, $admin_email, ucfirst($admin_name), $email_name, $splVars); $data_listpay['list_id'] = $listId; $data_listpay['amount'] = $this->session->userdata('list_commission'); $data_listpay['currency'] = get_currency_code(); $data_listpay['created'] = time(); $this->db->insert('list_pay', $data_listpay); $data['title'] = "Payment Success !"; $data['message_element'] = "payments/paypal_success"; $this->load->view('template', $data); //redirect('rooms/edit/'.$listId, 'refresh'); //$this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success',translate('Rooms added successfully.'))); //redirect('rooms/'.$listId, 'refresh'); } else { $data['title'] = "Payment Cancelled !"; $data['message_element'] = "payments/paypal_cancel"; $this->load->view('template', $data); } /* } else { $data['title']="Payment Cancelled !"; $data['message_element'] = "payments/paypal_cancel"; $this->load->view('template',$data); } */ }
<td class="clsName"><?php echo translate_admin('Coupon Code'); ?> </td> <td><?php echo $result->coupon; ?> </td> </tr> <tr> <td class="clsName"><?php echo translate_admin('Coupon Price'); ?> </td> <td><?php echo $currency_code . ' ' . $currency_symbol . get_currency_value_lys($coupon_currency, $currency_code, $coupon_price); ?> </td> </tr> <?php } if (!isset($commission_status)) { ?> <tr> <td class="clsName"><?php echo translate_admin('Admin Commision'); ?> </td> <td><?php echo $currency_code . ' ' . $currency_symbol . $result->admin_commission; ?>