示例#1
0
 public function index()
 {
     $conditions = array("list.is_featured" => 1, "list.is_enable" => 1, "list.status" => 1, "list_photo.is_featured" => 1, "list_photo.is_featured" => 1, "list.banned" => 0);
     $limit = array(30);
     $data['lists'] = $this->Rooms_model->get_rooms_byImage($conditions, NULL, $limit);
     $limit = array(3);
     $orderby = array("id", "desc");
     $conditionL = array("list.is_enable" => 1, "list.status" => 1);
     $data['latest_ads'] = $this->Rooms_model->get_rooms($conditionL, NULL, $limit, $orderby);
     $this->db->distinct()->select()->select('neigh_city.id')->where('neigh_city.is_home', 1);
     $this->db->from('neigh_city')->order_by("id", "random")->limit(8, 0);
     /*$this->db->join('neigh_city_place', 'neigh_city_place.city_name = neigh_city.city_name');
     		$this->db->join('neigh_post', 'neigh_post.city = neigh_city_place.city_name');
     		$this->db->where('neigh_city_place.is_featured',1)->where('neigh_post.is_featured',1);*/
     $data['cities'] = $this->db->get();
     $this->db->select()->from("list")->limit(4, 0);
     $data['rooms'] = $this->db->get();
     // Advertisement popup 1 start
     $data['PagePopupContent'] = GetPagePopupContent('home');
     // Advertisement popup 1 end
     $data["title"] = $this->dx_auth->get_site_title();
     $data["meta_keyword"] = $this->Common_model->getTableData('settings', array('code' => 'META_KEYWORD'))->row()->string_value;
     $data["meta_description"] = $this->Common_model->getTableData('settings', array('code' => 'META_DESCRIPTION'))->row()->string_value;
     $data['message_element'] = "home/view_home";
     $this->load->view('template', $data);
 }
示例#2
0
 public function index()
 {
     //Get the checkin and chekout dates
     $checkin = '';
     $checkout = '';
     $stack = array();
     $room_types = array();
     $checkin = $this->input->post('checkin');
     $checkout = $this->input->post('checkout');
     $nof_guest = $this->input->post('number_of_guests');
     if ($this->input->post('room_types1')) {
         $room_types1 = $this->input->post('room_types1');
         $data['room_types1'] = $room_types1;
     }
     if ($this->input->post('room_types2')) {
         $room_types2 = $this->input->post('room_types2');
         $data['room_types2'] = $room_types2;
     }
     if ($this->input->post('room_types3')) {
         $room_types3 = $this->input->post('room_types3');
         $data['room_types3'] = $room_types3;
     }
     if ($this->input->post('room_types4')) {
         $room_types1 = $this->input->post('room_types4');
         $data['room_types1'] = $room_types1;
     }
     if ($this->input->post('room_types5')) {
         $room_types2 = $this->input->post('room_types5');
         $data['room_types2'] = $room_types2;
     }
     if ($this->input->post('room_types6')) {
         $room_types3 = $this->input->post('room_types6');
         $data['room_types3'] = $room_types3;
     }
     if ($this->input->post('room_types11')) {
         $room_types1 = $this->input->post('room_types11');
         $data['room_types1'] = $room_types1;
     }
     if ($this->input->post('room_types22')) {
         $room_types2 = $this->input->post('room_types22');
         $data['room_types2'] = $room_types2;
     }
     if ($this->input->post('room_types33')) {
         $room_types3 = $this->input->post('room_types33');
         $data['room_types3'] = $room_types3;
     }
     $min = $this->input->post('min');
     $max = $this->input->post('max');
     //get starred list status
     $star = $this->input->get('starred');
     $page = $this->input->get('page', 1);
     $data['page'] = $page;
     $array_items = array('Vcheckin' => '', 'Vcheckout' => '', 'Vcheckout' => '');
     $this->session->unset_userdata($array_items);
     if ($this->input->post('checkin') != '' || $this->input->post('checkin') != 'mm/dd/yy') {
         $freshdata = array('Vcheckin' => $this->input->post('checkin'), 'Vcheckout' => $this->input->post('checkout'), 'Vnumber_of_guests' => $this->input->post('number_of_guests'));
         $this->session->set_userdata($freshdata);
     }
     if ($this->input->post('location')) {
         $location = $this->input->post('location');
         //$this->session->unset_userdata('location1');
         //$this->session->set_userdata('location',$location);
     } else {
         if ($this->input->get('location')) {
             $location = $this->input->get('location');
         } else {
             if ($this->session->userdata('ajax_search_location') != '') {
                 //$location = $this->session->userdata('ajax_search_location');
             }
         }
     }
     $ser = $this->input->post('searchbox');
     if ($this->input->post('searchbox') != '') {
         $location = $this->input->post('searchbox');
         //$this->session->unset_userdata('location');
         //$this->session->set_userdata('location1',$location);
     }
     if (!isset($location)) {
         $location = '';
     }
     if (isset($location)) {
         $pieces = explode(",", $location);
         $data['pieces'] = $pieces;
         $check = $this->input->post('checkin');
         if (isset($check)) {
             $checkin = $this->input->post('checkin');
             //$this->session->set_userdata('checkin',$checkin);
         } else {
             $checkin = 'mm/dd/yy';
         }
         $check_out = $this->input->post('checkout');
         if (isset($check_out)) {
             $checkout = $this->input->post('checkout');
             //$this->session->set_userdata('checkout',$checkout);
         } else {
             $checkout = 'mm/dd/yy';
         }
         if ($this->input->post('number_of_guests')) {
             $number_of_guests = $this->input->post('number_of_guests');
             //$this->session->set_userdata('number_of_guests',$number_of_guests);
         } else {
             $number_of_guests = '1';
         }
         /*	if(!$this->input->post('location'))
         		{
         			$location = $this->session->userdata('location');			
         		}
         		if($location == '')
         			{
         				$location = $this->session->userdata('location1');
         			}
         			if($this->input->get('location'))
         			{
         				$location = $this->input->get('location');
         			}*/
         if (!$this->input->post('checkin')) {
             //$checkin = $this->session->userdata('checkin');
         }
         if (!$this->input->post('checkout')) {
             //$checkout = $this->session->userdata('checkout');
         }
         if (!$this->input->post('number_of_guests')) {
             //$number_of_guests = $this->session->userdata('number_of_guests');
         }
         $data['property_type'] = $this->Common_model->getTableData('property_type')->result_array();
         $data['query'] = $location;
         $data['checkin'] = $checkin;
         $data['checkout'] = $checkout;
         $data['number_of_guests'] = $number_of_guests;
         $data['room_types'] = $room_types;
         $data['min'] = $min;
         $data['max'] = $max;
         $data['amnities'] = $this->Rooms_model->get_amnities();
         $data['lat'] = $this->input->post('lat');
         $data['lng'] = $this->input->post('lng');
         if ($this->input->post('lat') != '') {
             $this->session->set_userdata('lat', $data['lat']);
             $this->session->set_userdata('lng', $data['lng']);
         } else {
             $data['lat'] = $this->session->userdata('lat');
             $data['lng'] = $this->session->userdata('lng');
         }
         //echo $this->input->post('lat1');exit;
     }
     $data['wishlist_category'] = $this->Common_model->getTableData('wishlists', array('user_id' => $this->dx_auth->get_user_id()));
     $data['user_wishlist'] = $this->Common_model->getTableData('user_wishlist', array('user_id' => $this->dx_auth->get_user_id()));
     // $data['query']            = '';
     //$data['property_type']    = $this->Common_model->getTableData('property_type')->result_array();
     // Advertisement popup 1 start
     $data['PagePopupContent'] = GetPagePopupContent('search');
     // Advertisement popup 1 end
     $data['title'] = get_meta_details('Search_Elements', 'title');
     $data["meta_keyword"] = get_meta_details('Search_Elements', 'meta_keyword');
     $data["meta_description"] = get_meta_details('Search_Elements', 'meta_description');
     $data['message_element'] = 'view_search_result';
     $this->load->view('template', $data);
 }
示例#3
0
 public function index($room_id = '', $preview = '')
 {
     // if($this->dx_auth->get_user_id() != "")
     // {
     // 	$conditions             = array("id" => $room_id, "list.status" => 1, "list.is_enable"=>1, "list.list_pay"=>1);
     //  }
     //  else {
     $conditions = array("id" => $room_id, "list.status" => 1);
     //  }
     $result = $this->Common_model->getTableData('list', $conditions);
     $conditions1 = array("id" => $room_id);
     $lys_status = $this->Common_model->getTableData('lys_status', $conditions1)->row();
     $total_status = $lys_status->calendar + $lys_status->price + $lys_status->overview + $lys_status->address + $lys_status->photo + $lys_status->listing;
     if ($result->row()->user_id != $this->dx_auth->get_user_id()) {
         if ($result->row()->is_enable != 1 || $result->row()->list_pay != 1 || $total_status != 6) {
             redirect('info');
         }
     }
     $data['preview'] = $preview;
     ////////////////For viewing page statistics -Update///////////
     $today_month = date("F");
     $today_date = date("j");
     $today_year = date("Y");
     $conditions_statistics = array("list_id" => $room_id, "date" => trim($today_date), "month" => trim($today_month), "year" => trim($today_year));
     $result_statistics = $this->Common_model->add_page_statistics($room_id, $conditions_statistics);
     //////////////////////////
     if ($result->num_rows() == 0) {
         redirect('info/deny');
     }
     $data['list'] = $list = $result->row();
     $title = $list->title;
     $page_viewed = $list->page_viewed;
     $data['page_viewed'] = $this->Trips_model->update_pageViewed($room_id, $page_viewed);
     $id = $room_id;
     $checkin = $this->session->userdata('Vcheckin');
     $checkout = $this->session->userdata('Vcheckout');
     $data['guests'] = $this->session->userdata('Vnumber_of_guests');
     $ckin = explode('/', $checkin);
     $ckout = explode('/', $checkout);
     $xprice = $this->Common_model->getTableData('price', array('id' => $id))->row();
     $guests = $xprice->guests;
     if (isset($xprice->cleaning)) {
         $data['cleaning'] = $xprice->cleaning;
     } else {
         $data['cleaning'] = 0;
     }
     if (isset($xprice->security)) {
         $data['security'] = $xprice->security;
     } else {
         $data['security'] = 0;
     }
     if (isset($xprice->night)) {
         $price = $xprice->night;
     } else {
         $price = 0;
     }
     if (isset($xprice->week)) {
         $Wprice = $xprice->week;
     } else {
         $Wprice = 0;
     }
     if (isset($xprice->month)) {
         $Mprice = $xprice->month;
     } else {
         $Mprice = 0;
     }
     $data['guest_price'] = $xprice->addguests;
     $data['extra_guest'] = $xprice->guests;
     // Discount label 2 start
     if ($price < $xprice->previous_price) {
         $discount = ($xprice->previous_price - $price) / $xprice->previous_price * 100;
         $data['discount'] = $discount;
     } else {
         $data['discount'] = 0;
     }
     // Discount label 2 end
     //check admin premium condition and apply so for
     $query = $this->Common_model->getTableData('paymode', array('id' => 2));
     $row = $query->row();
     if ($ckin[0] == "mm" && $ckout[0] == "mm" or $ckin[0] == "" && $ckout[0] == "" or $checkin == 'Check in' or $checkout == 'Check out') {
         $data['price'] = $price;
         if ($Wprice == 0) {
             $data['Wprice'] = $price * 7;
         } else {
             $data['Wprice'] = $Wprice;
         }
         if ($Mprice == 0) {
             $data['Mprice'] = $price * 30;
         } else {
             $data['Mprice'] = $Mprice;
         }
         if ($row->is_premium == 1) {
             if ($row->is_fixed == 1) {
                 $fix = $row->fixed_amount;
                 $amt = $price + $fix;
                 $data['commission'] = $fix;
                 $Fprice = $amt;
             } else {
                 $per = $row->percentage_amount;
                 $camt = floatval($price * $per / 100);
                 $amt = $price + $camt;
                 $data['commission'] = $camt;
                 $Fprice = $amt;
             }
             if ($Wprice == 0) {
                 $data['Wprice'] = $price * 7;
             } else {
                 $data['Wprice'] = $Wprice;
             }
             if ($Mprice == 0) {
                 $data['Mprice'] = $price * 30;
             } else {
                 $data['Mprice'] = $Mprice;
             }
         }
     } else {
         $diff = strtotime($ckout[2] . '-' . $ckout[0] . '-' . $ckout[1]) - strtotime($ckin[2] . '-' . $ckin[0] . '-' . $ckin[1]);
         $days = ceil($diff / (3600 * 24));
         if ($data['guests'] > $guests) {
             $price = $price * $days + $days * $xprice->addguests;
         } else {
             $price = $price * $days;
         }
         //Entering it into data variables
         $data['price'] = $price;
         if ($Wprice == 0) {
             $data['Wprice'] = $price * 7;
         } else {
             $data['Wprice'] = $Wprice;
         }
         if ($Mprice == 0) {
             $data['Mprice'] = $price * 30;
         } else {
             $data['Mprice'] = $Mprice;
         }
         $data['commission'] = 0;
         if ($row->is_premium == 1) {
             if ($row->is_fixed == 1) {
                 $fix = $row->fixed_amount;
                 $amt = $price + $fix;
                 $data['commission'] = $fix;
                 $Fprice = $amt;
             } else {
                 $per = $row->percentage_amount;
                 $camt = floatval($price * $per / 100);
                 $amt = $price + $camt;
                 $data['commission'] = $camt;
                 $Fprice = $amt;
             }
             if ($Wprice == 0) {
                 $data['Wprice'] = $price * 7;
             } else {
                 $data['Wprice'] = $Wprice;
             }
             if ($Mprice == 0) {
                 $data['Mprice'] = $price * 30;
             } else {
                 $data['Mprice'] = $Mprice;
             }
         }
     }
     $conditions = array('list_id' => $room_id);
     $data['images'] = $this->Gallery->get_imagesG(NULL, $conditions);
     $data['amnities'] = $this->Rooms_model->get_amnities();
     $conditions = array('list_id' => $room_id, 'userto' => $list->user_id);
     $data['result'] = $this->Trips_model->get_review($conditions);
     $conditions = array('list_id' => $room_id, 'userto' => $list->user_id);
     $data['stars'] = $this->Trips_model->get_review_sum($conditions)->row();
     $data['room_id'] = $room_id;
     $price = $this->Common_model->getTableData('price', array('id' => $room_id));
     $data['prices'] = $price->row();
     $data['lat'] = $list->lat;
     $data['long'] = $list->long;
     $data['policy'] = $this->Common_model->getTableData('cancellation_policy', array('id' => $list->cancellation_policy))->row()->name;
     $data['city'] = $list->city;
     $data['state'] = $list->state;
     $data['country'] = $list->country;
     $data['street_address'] = $list->street_address;
     $data['optional_address'] = $list->optional_address;
     $data['zip_code'] = $list->zip_code;
     $data['instance_book'] = $list->instance_book;
     // wishlist count 1 start
     // wishlist count 1 end
     // Advertisement popup 1 start
     $data['PagePopupContent'] = GetPagePopupContent('rooms');
     // Advertisement popup 1 end
     $data['title'] = substr($title, 0, 70);
     $data["meta_keyword"] = "";
     $data["meta_description"] = "";
     $data['fb_app_id'] = $this->db->get_where('settings', array('code' => 'SITE_FB_API_ID'))->row()->string_value;
     $data['message_element'] = "rooms/view_edit_confirm";
     $this->load->view('template', $data);
 }
示例#4
0
 function paypal_success()
 {
     $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
         $currency_code = $this->session->userdata('currency_code_payment');
         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 = 'USD';
             //$currency_code = $this->session->userdata('booking_currency_symbol');
             $amt = get_currency_value_lys($currency_code, $currency_code, $amt);
         } else {
             //$currency_code = $this->session->userdata('booking_currency_symbol');
             $currency_code = $currency_code;
             $amt = $amt;
         }
         $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 (isset($do_ec_return['L_SHORTMESSAGE0']) && $do_ec_return['L_SHORTMESSAGE0'] === 'Duplicate Request') {
                 redirect('home');
             }
             $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");
             }
             $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['price'] = $data[14];
             $currency = $data[15];
             $list['payment_id'] = 2;
             $list['credit_type'] = 1;
             $list['transaction_id'] = 0;
             $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'] = $this->session->userdata('subtotal');
             } else {
                 $list['admin_commission'] = $data[8];
                 $list['cleaning'] = $data[10];
                 $list['security'] = $data[11];
                 $list['topay'] = $this->session->userdata('subtotal');
             }
             $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();
                 $updateData['status'] = 10;
                 $list['contacts_offer'] = $this->session->userdata('contacts_offer');
                 $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) {
                     $user = $this->Users_model->get_user_by_id($this->dx_auth->get_user_id())->row();
                     $trip1 = $user->ref_trip;
                     $rent1 = $user->ref_rent;
                     $details1 = $this->Referrals_model->get_details_refamount($row->invite_from);
                     $amt_check = $this->db->where('id', $row->invite_from)->get('users');
                     if ($amt_check->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 = $details1->row()->count_trip;
                         $amount = $amt_check->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_check1 = $this->db->where('id', $row->invite_from)->get('users');
                 if ($amt_check1->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_check1->row()->count_book;
                     $amount = $amt_check1->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, 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, 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');
             // }
             if ($this->session->userdata('call_back') == 'mobile') {
                 $message_element = 'payments/paypal_success_mobile';
             } else {
                 // Advertisement popup 2 start
                 $data['PagePopupContent'] = GetPagePopupContent('step4');
                 // Advertisement popup 2 end
                 $message_element = 'payments/paypal_success';
             }
             $data['title'] = "Payment Success !";
             $data['message_element'] = $message_element;
             $this->load->view('template', $data);
         } else {
             $this->_error($do_ec_return);
         }
     } else {
         $this->_error($get_ec_return);
     }
 }