Merge branch 'master' of https://gitlab.techware.co.in/timeout/timeOut into jansa
# Conflicts:
# application/models/Webservice_model.php
Showing
... | @@ -408,864 +408,865 @@ class Webservice_model extends CI_Model { | ... | @@ -408,864 +408,865 @@ class Webservice_model extends CI_Model { |
} | } | ||
} else { | } else { | ||
$res = array('status'=>1,'data' => []); | $res = array('status'=>1,'data' => []); | ||
}}else { | |||
$res = array('status'=>1,'data' => []); | |||
} | } | ||
} else { | }else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function event($data) { | |||
function event($data) { | try { | ||
$user_id = $this->auth_token_get($data['auth_token']); | |||
try { | if($user_id > 0) { | ||
$user_id = $this->auth_token_get($data['auth_token']); | $event_id = $data['event_id']; | ||
if($user_id > 0) { | $this->db->query("SET SESSION group_concat_max_len = 20000"); | ||
$event_id = $data['event_id']; | $rs = $this->db->query("SELECT IF(host_categories.show_layout = 0,'false','true') AS is_layout,IF(events.has_payment = 0,'false','true') AS is_payment_required,IF(favourite.is_favorite = 1,'true','false') AS is_favorite,events.event_id, CAST(AVG (review.rate) AS DECIMAL (12,1)) AS rate, (SELECT COUNT(booking.id) FROM booking WHERE booking.event_id = events.event_id) AS attendees, events.event_name,events.event_discription AS event_description,events.seat_pricing, events.custom_seat_layout, venue.layout, venue.layout_details,venue.venue_name,venue.venue_details,venue.location,venue.location_lat AS lat,venue.location_lng AS lng,venue.venue_name AS address_name,venue.location AS address, GROUP_CONCAT(DISTINCT `event_gallery`.`media_url`) AS media_url,IF(favourite.status = 1,'true','false') AS fav_status, GROUP_CONCAT(DISTINCT tags.tag_name) AS tag, GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date,event_date_time.time)) AS date_time, events.max_booking FROM events INNER JOIN event_date_time ON events.event_id = event_date_time.event_id INNER JOIN venue ON venue.id = events.venue_id LEFT JOIN `event_gallery` ON `events`.`event_id` = `event_gallery`.`event_id` AND `event_gallery`.`status` != 0 LEFT JOIN booking on booking.event_id = events.event_id LEFT JOIN favourite ON favourite.event_id = events.event_id AND favourite.user_id = ".$user_id." AND favourite.status = 1 LEFT JOIN event_tags ON events.event_id = event_tags.event_id LEFT JOIN tags on tags.tag_id = event_tags.tag_id LEFT JOIN review ON events.event_id = review.event_id INNER JOIN host_categories ON venue.host_cat_id = host_categories.host_cat_id WHERE event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d') AND events.event_id = ".$event_id." GROUP BY events.event_id, event_date_time.event_id")->row(); | ||
$this->db->query("SET SESSION group_concat_max_len = 20000"); | if(count($rs)>0){ | ||
$rs = $this->db->query("SELECT IF(host_categories.show_layout = 0,'false','true') AS is_layout,IF(events.has_payment = 0,'false','true') AS is_payment_required,IF(favourite.is_favorite = 1,'true','false') AS is_favorite,events.event_id, CAST(AVG (review.rate) AS DECIMAL (12,1)) AS rate, (SELECT COUNT(booking.id) FROM booking WHERE booking.event_id = events.event_id) AS attendees, events.event_name,events.event_discription AS event_description,events.seat_pricing, events.custom_seat_layout, venue.layout, venue.layout_details,venue.venue_name,venue.venue_details,venue.location,venue.location_lat AS lat,venue.location_lng AS lng,venue.venue_name AS address_name,venue.location AS address, GROUP_CONCAT(DISTINCT `event_gallery`.`media_url`) AS media_url,IF(favourite.status = 1,'true','false') AS fav_status, GROUP_CONCAT(DISTINCT tags.tag_name) AS tag, GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date,event_date_time.time)) AS date_time, events.max_booking FROM events INNER JOIN event_date_time ON events.event_id = event_date_time.event_id INNER JOIN venue ON venue.id = events.venue_id LEFT JOIN `event_gallery` ON `events`.`event_id` = `event_gallery`.`event_id` AND `event_gallery`.`status` != 0 LEFT JOIN booking on booking.event_id = events.event_id LEFT JOIN favourite ON favourite.event_id = events.event_id AND favourite.user_id = ".$user_id." AND favourite.status = 1 LEFT JOIN event_tags ON events.event_id = event_tags.event_id LEFT JOIN tags on tags.tag_id = event_tags.tag_id LEFT JOIN review ON events.event_id = review.event_id INNER JOIN host_categories ON venue.host_cat_id = host_categories.host_cat_id WHERE event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d') AND events.event_id = ".$event_id." GROUP BY events.event_id, event_date_time.event_id")->row(); | $resultData = array(); | ||
if(count($rs)>0){ | $event_layout = ''; | ||
$resultData = array(); | $colorData = array(); | ||
$event_layout = ''; | $booking = $this->db->where('event_id',$event_id)->select('ticket_details')->get('booking')->result(); | ||
$colorData = array(); | if(count($booking) > 0){ | ||
$booking = $this->db->where('event_id',$event_id)->select('ticket_details')->get('booking')->result(); | foreach ($booking as $row) { | ||
if(count($booking) > 0){ | $priceData[] = json_decode($row->ticket_details); | ||
foreach ($booking as $row) { | if(count($priceData) > 0){ | ||
$priceData[] = json_decode($row->ticket_details); | foreach ($priceData as $value) { | ||
if(count($priceData) > 0){ | // $colorData[$value->color] = isset($colorData[$value->color]) ? + $colorData[$value->color] + $value->no_ticket: $value->no_ticket; | ||
foreach ($priceData as $value) { | |||
// $colorData[$value->color] = isset($colorData[$value->color]) ? + $colorData[$value->color] + $value->no_ticket: $value->no_ticket; | |||
} | |||
} | } | ||
} | } | ||
} | } | ||
} | |||
if($rs->layout!=''){ | if($rs->layout!=''){ | ||
if($rs->custom_seat_layout!=''){ | if($rs->custom_seat_layout!=''){ | ||
$pricelist = json_decode($rs->custom_seat_layout, TRUE); | $pricelist = json_decode($rs->custom_seat_layout, TRUE); | ||
$price = min(array_column($pricelist, 'price')); | $price = min(array_column($pricelist, 'price')); | ||
$event_layout = $rs->custom_seat_layout; | $event_layout = $rs->custom_seat_layout; | ||
} else { | |||
$pricelist = json_decode($rs->layout_details, TRUE); | |||
$price = min(array_column($pricelist, 'price')); | |||
$event_layout = $rs->layout_details; | |||
} | |||
} else { | } else { | ||
$pricelist = json_decode($rs->seat_pricing, TRUE); | $pricelist = json_decode($rs->layout_details, TRUE); | ||
$price = $pricelist['price']; | $price = min(array_column($pricelist, 'price')); | ||
$event_layout = $rs->seat_pricing; | $event_layout = $rs->layout_details; | ||
} | } | ||
$event_layout = json_decode($event_layout); | } else { | ||
$event_layouts = array(); | $pricelist = json_decode($rs->seat_pricing, TRUE); | ||
if(is_array($event_layout)){ | $price = $pricelist['price']; | ||
foreach ($event_layout as $value) { | $event_layout = $rs->seat_pricing; | ||
if(isset($colorData[$value->color])) { | } | ||
$avaliable = $value->capacity - $colorData[$value->color]; | $event_layout = json_decode($event_layout); | ||
} else { | $event_layouts = array(); | ||
$avaliable = $value->capacity; | if(is_array($event_layout)){ | ||
} | foreach ($event_layout as $value) { | ||
$priceLayout = array('class_name' => $value->color, | if(isset($colorData[$value->color])) { | ||
'rate'=>$value->price, | $avaliable = $value->capacity - $colorData[$value->color]; | ||
'total_tickets'=>$value->capacity, | } else { | ||
'available_tickets'=>$avaliable, | $avaliable = $value->capacity; | ||
"max_ticket"=>$rs->max_booking | |||
); | |||
array_push($event_layouts, $priceLayout); | |||
} | } | ||
} else { | $priceLayout = array('class_name' => $value->color, | ||
$event_layouts[] = array('class_name' => null, | 'rate'=>$value->price, | ||
'rate'=>$event_layout->price, | 'total_tickets'=>$value->capacity, | ||
'total_tickets'=>null, | 'available_tickets'=>$avaliable, | ||
'available_tickets'=>null, | |||
"max_ticket"=>$rs->max_booking | "max_ticket"=>$rs->max_booking | ||
); | ); | ||
array_push($event_layouts, $priceLayout); | |||
} | } | ||
} else { | |||
$event_layouts[] = array('class_name' => null, | |||
'rate'=>$event_layout->price, | |||
'total_tickets'=>null, | |||
'available_tickets'=>null, | |||
"max_ticket"=>$rs->max_booking | |||
); | |||
} | |||
$dates = explode(',', $rs->date_time); | $dates = explode(',', $rs->date_time); | ||
$time_spec = array(); | $time_spec = array(); | ||
$data_array = array(); | $data_array = array(); | ||
foreach ($dates as $rss) { | foreach ($dates as $rss) { | ||
list($id,$date,$time) = explode('#', $rss); | list($id,$date,$time) = explode('#', $rss); | ||
if($date == date("Y-m-d")){ | if($date == date("Y-m-d")){ | ||
$time_array = explode(':', $time); | $time_array = explode(':', $time); | ||
if($time_array['0'] > date('H')) { | if($time_array['0'] > date('H')) { | ||
$time_spec[] = array('id'=>$id, 'date'=>$date, 'time'=>$time); | |||
$data_array[$date][] = array('id'=>$id, 'time'=>$time); | |||
} | |||
} else { | |||
$data_array[$date][] = array('id'=>$id, 'time'=>$time); | |||
$time_spec[] = array('id'=>$id, 'date'=>$date, 'time'=>$time); | $time_spec[] = array('id'=>$id, 'date'=>$date, 'time'=>$time); | ||
$data_array[$date][] = array('id'=>$id, 'time'=>$time); | |||
} | } | ||
} else { | |||
$data_array[$date][] = array('id'=>$id, 'time'=>$time); | |||
} | $time_spec[] = array('id'=>$id, 'date'=>$date, 'time'=>$time); | ||
$date_list = array(); | |||
foreach ($data_array as $key => $value) { | |||
$date_list[] = array('date'=>$key, 'time'=>$value); | |||
} | } | ||
$tags = explode(',', $rs->tag); | |||
$media_url = explode(',', $rs->media_url); | |||
$resData = array( | |||
'event_id'=>$rs->event_id, | |||
'name'=>$rs->event_name, | |||
'description'=>$rs->event_description, | |||
'rating'=>$rs->rate, | |||
'total_attendees'=>$rs->attendees == ''? '0': $rs->attendees, | |||
'layout_image'=>$rs->layout, | |||
'is_favorite'=>$rs->is_favorite === 'true'? true: false, | |||
'is_payment_required'=>$rs->is_payment_required === 'true'? true: false, | |||
'is_layout'=>$rs->is_layout === 'true'? true: false, | |||
'photos'=>$media_url, | |||
'time'=>$time_spec[0]['time'], | |||
'date'=>$time_spec[0]['date'], | |||
'date_list'=>$date_list, | |||
'classes'=>$event_layouts, | |||
'latitude'=>$rs->lat, | |||
'address_name'=>$rs->address_name, | |||
'address'=>$rs->address, | |||
'longitude'=>$rs->lng | |||
); | |||
$res = array('status'=>1,'data'=>$resData); | } | ||
} else { | $date_list = array(); | ||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | foreach ($data_array as $key => $value) { | ||
$date_list[] = array('date'=>$key, 'time'=>$value); | |||
} | } | ||
$tags = explode(',', $rs->tag); | |||
$media_url = explode(',', $rs->media_url); | |||
$resData = array( | |||
'event_id'=>$rs->event_id, | |||
'name'=>$rs->event_name, | |||
'description'=>$rs->event_description, | |||
'rating'=>$rs->rate, | |||
'total_attendees'=>$rs->attendees == ''? '0': $rs->attendees, | |||
'layout_image'=>$rs->layout, | |||
'is_favorite'=>$rs->is_favorite === 'true'? true: false, | |||
'is_payment_required'=>$rs->is_payment_required === 'true'? true: false, | |||
'is_layout'=>$rs->is_layout === 'true'? true: false, | |||
'photos'=>$media_url, | |||
'time'=>$time_spec[0]['time'], | |||
'date'=>$time_spec[0]['date'], | |||
'date_list'=>$date_list, | |||
'classes'=>$event_layouts, | |||
'latitude'=>$rs->lat, | |||
'address_name'=>$rs->address_name, | |||
'address'=>$rs->address, | |||
'longitude'=>$rs->lng | |||
); | |||
$res = array('status'=>1,'data'=>$resData); | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function generateAuth($userId,$auth_token) { | |||
$this->db->insert('customer_auth',array('user_id'=>$userId, 'auth_token'=>$auth_token)); | |||
} | |||
function auth_token_get($token) { | |||
$rs = $this->db->select('user_id')->where('auth_token', $token)->get('customer_auth')->row(); | |||
if(count($rs) > 0) { | |||
return $rs->user_id; | |||
} else { | } else { | ||
return 0; | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
} | |||
function send_mail($subject,$email,$message,$attach=null) { | |||
$ci =& get_instance(); | |||
$ci->load->library('email'); | |||
$ci->email->initialize(array( | |||
'protocol' => 'smtp', | |||
'smtp_host' => 'smtp.sendgrid.net', | |||
'smtp_user' => '[email protected]', | |||
'smtp_pass' => 'Golden_123', | |||
'smtp_port' => 587, | |||
'crlf' => "\r\n", | |||
'newline' => "\r\n" | |||
)); | |||
$ci->email->from('[email protected]', 'TimeOut'); | |||
$ci->email->to($email); | |||
$ci->email->cc('[email protected]'); | |||
$ci->email->subject($subject); | |||
$ci->email->message($message); | |||
if($attach!=null) { | |||
$ci->email->attach($attach); | |||
} | |||
return $ci->email->send(); | |||
} | |||
function get_category_list($data) { | } catch(Exception $e) { | ||
try { | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function generateAuth($userId,$auth_token) { | |||
$this->db->insert('customer_auth',array('user_id'=>$userId, 'auth_token'=>$auth_token)); | |||
} | |||
$user_id = $this->auth_token_get($data['auth_token']); | function auth_token_get($token) { | ||
if($user_id > 0) { | $rs = $this->db->select('user_id')->where('auth_token', $token)->get('customer_auth')->row(); | ||
if(isset($data['query'])) { | if(count($rs) > 0) { | ||
$where = ' AND event_category.category LIKE '."'".$data['query'].'%'."'"; | return $rs->user_id; | ||
} else { | } else { | ||
$where = ''; | return 0; | ||
} | } | ||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | } | ||
if($lang->language == 'ar') { | function send_mail($subject,$email,$message,$attach=null) { | ||
$cat_field = 'event_category.category_ar'; | $ci =& get_instance(); | ||
} else { | $ci->load->library('email'); | ||
$cat_field = 'event_category.category'; | $ci->email->initialize(array( | ||
} | 'protocol' => 'smtp', | ||
'smtp_host' => 'smtp.sendgrid.net', | |||
'smtp_user' => '[email protected]', | |||
'smtp_pass' => 'Golden_123', | |||
'smtp_port' => 587, | |||
'crlf' => "\r\n", | |||
'newline' => "\r\n" | |||
)); | |||
$ci->email->from('[email protected]', 'TimeOut'); | |||
$ci->email->to($email); | |||
$ci->email->cc('[email protected]'); | |||
$ci->email->subject($subject); | |||
$ci->email->message($message); | |||
if($attach!=null) { | |||
$ci->email->attach($attach); | |||
} | |||
return $ci->email->send(); | |||
} | |||
$result = $this->db->query("SELECT events.venue_id AS region_id,event_category.cat_id AS category_id, $cat_field AS category_name, event_category.category_image AS category_image, event_category.category_description AS category_description FROM event_category LEFT JOIN events ON events.category_id = event_category.cat_id WHERE event_category.status = 1 ".$where." GROUP BY event_category.cat_id")->result(); | function get_category_list($data) { | ||
try { | |||
if(count($result)>0){ | $user_id = $this->auth_token_get($data['auth_token']); | ||
$resultData = array(); | if($user_id > 0) { | ||
$resultData['category'] = $result; | if(isset($data['query'])) { | ||
$res = array('status'=>1,'data'=>$resultData); | $where = ' AND event_category.category LIKE '."'".$data['query'].'%'."'"; | ||
} else { | |||
$res = array('status'=>1,'data' => []); | |||
} | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $where = ''; | ||
} | } | ||
} catch(Exception $e) { | $lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
if($lang->language == 'ar') { | |||
$cat_field = 'event_category.category_ar'; | |||
} else { | |||
$cat_field = 'event_category.category'; | |||
} | |||
function add_favorites($data) { | $result = $this->db->query("SELECT events.venue_id AS region_id,event_category.cat_id AS category_id, $cat_field AS category_name, event_category.category_image AS category_image, event_category.category_description AS category_description FROM event_category LEFT JOIN events ON events.category_id = event_category.cat_id WHERE event_category.status = 1 ".$where." GROUP BY event_category.cat_id")->result(); | ||
try{ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$res_count = $this->db->where('event_id',$data['event_id'])->where('user_id',$user_id)->get('favourite')->num_rows(); | if(count($result)>0){ | ||
$resultData = array(); | |||
$resultData['category'] = $result; | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | |||
$res = array('status'=>1,'data' => []); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
$favoriteList = array('user_id'=>$user_id, 'event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | |||
if($res_count > 0) { | function add_favorites($data) { | ||
$data=array('event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | try{ | ||
$this->db->where('user_id',$user_id); | $user_id = $this->auth_token_get($data['auth_token']); | ||
$this->db->where('event_id',$data['event_id']); | if($user_id > 0) { | ||
$id = $this->db->update('favourite',$data); | |||
}else{ | $res_count = $this->db->where('event_id',$data['event_id'])->where('user_id',$user_id)->get('favourite')->num_rows(); | ||
$id = $this->db->insert('favourite',$favoriteList); | $favoriteList = array('user_id'=>$user_id, 'event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | ||
} | |||
if($id) { | if($res_count > 0) { | ||
$res = array('status'=>1); | $data=array('event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | ||
$this->db->where('user_id',$user_id); | |||
$this->db->where('event_id',$data['event_id']); | |||
$id = $this->db->update('favourite',$data); | |||
}else { | }else{ | ||
$res = array('status'=>0,'message'=>'Add Favorite failed please try again','code'=>'ER14'); | |||
} | |||
} else { | $id = $this->db->insert('favourite',$favoriteList); | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | } | ||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
if($id) { | |||
function get_cities_list($data) { | $res = array('status'=>1); | ||
try { | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
}else { | |||
$res = array('status'=>0,'message'=>'Add Favorite failed please try again','code'=>'ER14'); | |||
} | |||
// language | } else { | ||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
if($lang->language == 'ar') { | |||
$region_name = 'region.name_ar'; | |||
} else { | |||
$region_name = 'region.name'; | |||
} | |||
// End | |||
$result = $this->db->query("SELECT region.id AS city_id, $region_name AS city_name, region.region_icon AS city_image FROM region WHERE region.status = 1 GROUP BY region.name")->result(); | |||
if(count($result)>0){ | |||
$resultData = array(); | |||
$resultData['cities'] = $result; | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | |||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function get_cities_list($data) { | |||
try { | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
function update_city($data) { | |||
try{ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
if(isset($data['city_id']) && !empty($data['city_id'])){ | |||
$re = $this->db->select('name')->where('id', $data['city_id'])->where('status', 1)->get('region')->row(); | |||
$cityName = $re->name; | |||
$cityId = $data['city_id']; | |||
}else{ | // language | ||
$radius = 25; | $lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | ||
$data = $this->db->query("SELECT id,name,status, (((acos(sin((".$data['latitude']."*pi()/180)) * sin((region_lat*pi()/180)) + cos((".$data['latitude']."*pi()/180)) * cos((region_lat*pi()/180)) * cos(((".$data['longitude']." - region_lng)*pi()/180))))*180/pi())*60*1.1515) as distance FROM region HAVING distance < ".$radius." AND status = '1' ORDER BY distance ASC LIMIT 1")->result_array(); | |||
if(!empty($data)){ | if($lang->language == 'ar') { | ||
$cityId = $data[0]['id']; | $region_name = 'region.name_ar'; | ||
$cityName = $data[0]['name']; | |||
} | |||
} | |||
if(!empty($cityId)){ | |||
$this->db->where('customer_id', $user_id); | |||
$this->db->update('customer', array('city' => $cityName)); | |||
$resultArray = array('city_id'=>$cityId,'city_name'=>$cityName); | |||
$res = array('status'=>1, 'data'=>$resultArray); | |||
}else { | |||
$res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | |||
} | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $region_name = 'region.name'; | ||
} | } | ||
} catch(Exception $e) { | // End | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $result = $this->db->query("SELECT region.id AS city_id, $region_name AS city_name, region.region_icon AS city_image FROM region WHERE region.status = 1 GROUP BY region.name")->result(); | ||
} | if(count($result)>0){ | ||
return $res; | $resultData = array(); | ||
} | $resultData['cities'] = $result; | ||
$res = array('status'=>1,'data'=>$resultData); | |||
function booking_summary($data) { | |||
try { | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$bookingId = $data['booking_id']; | |||
$ticketDetails = $this->db->query("SELECT ticket_details FROM booking WHERE bookId = '$bookingId'")->row(); | |||
$res = json_decode($ticketDetails->ticket_details); | |||
$kk['ticket_rate'] = "$res->price"; | |||
$settingsDetails = $this->db->query("SELECT instruction_en AS instruction,contact_number FROM privacy_policy")->row_array(); | |||
$result = $this->db->query("SELECT booking.qrcode,events.event_id,events.has_payment AS is_payment_required,events.event_name, `event_gallery`.`media_url` AS event_image,event_date_time.date, booking.bookId AS ticket_id,event_date_time.time,venue.location_lat AS latitude, venue.location_lng AS longitude, venue.venue_name AS address_name, venue.location AS address, booking.amount AS total_rate, booking.no_of_ticket AS ticket_count, customer.name AS profile_name, customer.profile_image AS profile_photo FROM events LEFT JOIN `event_gallery` ON `events`.`event_id` = `event_gallery`.`event_id` AND `event_gallery`.`media_type` = 0 LEFT JOIN booking ON booking.event_id = events.event_id RIGHT JOIN event_date_time ON event_date_time.id = booking.event_date_id LEFT JOIN venue ON venue.id = events.venue_id LEFT JOIN customer ON customer.customer_id = booking.customer_id WHERE booking.bookId = '$bookingId' AND booking.customer_id = ".$user_id."")->row_array(); | |||
if(count($result)>0 && count($settingsDetails)>0){ | |||
$result['is_payment_required'] = ($result['is_payment_required'] == 1) ? true: false; | |||
$resultData = array(); | |||
$resultData = array_merge($settingsDetails, $result,$kk); | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | |||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | |||
} | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function payment($data) { | function update_city($data) { | ||
try{ | try{ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
if($user_id > 0) { | if($user_id > 0) { | ||
$this->db->where('customer_id', $user_id); | if(isset($data['city_id']) && !empty($data['city_id'])){ | ||
$this->db->where('status', 1); | $re = $this->db->select('name')->where('id', $data['city_id'])->where('status', 1)->get('region')->row(); | ||
$this->db->where('id', $data['booking_id']); | $cityName = $re->name; | ||
$id = $this->db->update('booking', array('payment_status' => 1)); | $cityId = $data['city_id']; | ||
if($id) { | |||
$res = array('status'=>1); | |||
}else { | |||
$res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER11'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
}else{ | |||
$radius = 25; | |||
$data = $this->db->query("SELECT id,name,status, (((acos(sin((".$data['latitude']."*pi()/180)) * sin((region_lat*pi()/180)) + cos((".$data['latitude']."*pi()/180)) * cos((region_lat*pi()/180)) * cos(((".$data['longitude']." - region_lng)*pi()/180))))*180/pi())*60*1.1515) as distance FROM region HAVING distance < ".$radius." AND status = '1' ORDER BY distance ASC LIMIT 1")->result_array(); | |||
function event_rating($data) { | if(!empty($data)){ | ||
try{ | $cityId = $data[0]['id']; | ||
$user_id = $this->auth_token_get($data['auth_token']); | $cityName = $data[0]['name']; | ||
if($user_id > 0) { | } | ||
$ratingDetails = array( | |||
'event_id'=>$data['event_id'], | |||
'customer_id'=>$user_id, | |||
'rate'=>$data['rating'], | |||
'feedback'=>$data['description'] | |||
); | |||
$id = $this->db->insert('review', $ratingDetails); | |||
if($id) { | |||
$res = array('status'=>1); | |||
}else { | |||
$res = array('status'=>0,'message'=>'Event Rating failed please try again','code'=>'ER11'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | } | ||
} catch(Exception $e) { | if(!empty($cityId)){ | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $this->db->where('customer_id', $user_id); | ||
} | $this->db->update('customer', array('city' => $cityName)); | ||
return $res; | |||
} | |||
$resultArray = array('city_id'=>$cityId,'city_name'=>$cityName); | |||
$res = array('status'=>1, 'data'=>$resultArray); | |||
}else { | |||
$res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function update_notification_email_status($data) { | |||
try{ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$notData = array('notification_status'=>$data['notification_status'], 'email_status'=>$data['email_status']); | function booking_summary($data) { | ||
$this->db->where('id', $user_id); | try { | ||
$this->db->where('status', 1); | $user_id = $this->auth_token_get($data['auth_token']); | ||
$this->db->where('user_type', 3); | if($user_id > 0) { | ||
$status = $this->db->update('users', $notData); | $bookingId = $data['booking_id']; | ||
if ($status){ | $ticketDetails = $this->db->query("SELECT ticket_details FROM booking WHERE bookId = '$bookingId'")->row(); | ||
$res = array('status'=>1); | $res = json_decode($ticketDetails->ticket_details); | ||
}else { | $kk['ticket_rate'] = "$res->price"; | ||
$res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | $settingsDetails = $this->db->query("SELECT instruction_en AS instruction,contact_number FROM privacy_policy")->row_array(); | ||
} | $result = $this->db->query("SELECT booking.qrcode,events.event_id,events.has_payment AS is_payment_required,events.event_name, `event_gallery`.`media_url` AS event_image,event_date_time.date, booking.bookId AS ticket_id,event_date_time.time,venue.location_lat AS latitude, venue.location_lng AS longitude, venue.venue_name AS address_name, venue.location AS address, booking.amount AS total_rate, booking.no_of_ticket AS ticket_count, customer.name AS profile_name, customer.profile_image AS profile_photo FROM events LEFT JOIN `event_gallery` ON `events`.`event_id` = `event_gallery`.`event_id` AND `event_gallery`.`media_type` = 0 LEFT JOIN booking ON booking.event_id = events.event_id RIGHT JOIN event_date_time ON event_date_time.id = booking.event_date_id LEFT JOIN venue ON venue.id = events.venue_id LEFT JOIN customer ON customer.customer_id = booking.customer_id WHERE booking.bookId = '$bookingId' AND booking.customer_id = ".$user_id."")->row_array(); | ||
if(count($result)>0 && count($settingsDetails)>0){ | |||
$result['is_payment_required'] = ($result['is_payment_required'] == 1) ? true: false; | |||
$resultData = array(); | |||
$resultData = array_merge($settingsDetails, $result,$kk); | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
public function update_profile($data) { | function payment($data) { | ||
try{ | |||
try{ | $user_id = $this->auth_token_get($data['auth_token']); | ||
$user_id = $this->auth_token_get($data['auth_token']); | if($user_id > 0) { | ||
$img_error = 0; | $this->db->where('customer_id', $user_id); | ||
if($user_id > 0) { | $this->db->where('status', 1); | ||
$post_data = $data; | $this->db->where('id', $data['booking_id']); | ||
unset($post_data['file']); | $id = $this->db->update('booking', array('payment_status' => 1)); | ||
unset($post_data['auth_token']); | if($id) { | ||
$res = array('status'=>1); | |||
if(isset($data['email'])){ | }else { | ||
$this->db->select('customer.email'); | $res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER11'); | ||
$this->db->where('customer.email',$data['email']); | } | ||
$this->db->where('customer_id !=',$user_id); | } else { | ||
$this->db->where('users.status !=',2); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
$this->db->from('users'); | } | ||
$this->db->join('customer','customer.customer_id = users.id'); | } catch(Exception $e) { | ||
$num = $this->db->get()->num_rows(); | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
if($num > 0) | } | ||
{ | return $res; | ||
$res = array('status'=>0,'message'=>'Email address already exist','code'=>'ER32'); | } | ||
return $res; | |||
} | |||
} | |||
if(isset($data['file'])){ | |||
$img=$data['file']['name']; | |||
$expbanner = explode('.',$img); | |||
$img_ext = strtolower($expbanner[1]); | |||
$rand = rand(10000,99999); | |||
$encname = time().$rand; | |||
if($img_ext=='png' || $img_ext=='jpeg' || $img_ext == 'jpg' || $img_ext == 'gif'){ | |||
$bannername = $encname.'.'.$img_ext; | |||
$imagePath="./assets/uploads/".$bannername; | |||
$post_data['profile_image'] = "assets/uploads/".$bannername; | |||
move_uploaded_file($data['file']["tmp_name"],$imagePath); | |||
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data); | |||
if($state){ | |||
$img_error = 1; | |||
} else { | |||
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid Image type','code'=>'ER41'); | |||
} | |||
} else { | |||
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data); | |||
if($state){ | |||
$img_error = 1; | |||
} else { | |||
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | |||
} | |||
} | |||
if($img_error == 1) { | |||
$this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.profile_image AS image,customer.gender,users.id AS userId, customer.city'); | |||
$this->db->where('users.id',$user_id); | |||
$this->db->from('users'); | |||
$this->db->join('customer','customer.customer_id = users.id'); | |||
$result = $this->db->get()->row(); | |||
if($result){ | |||
$res = array('status'=>1,'data'=>$result); | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} | |||
} else { | function event_rating($data) { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | try{ | ||
} | $user_id = $this->auth_token_get($data['auth_token']); | ||
} | if($user_id > 0) { | ||
catch(Exception $e) { | $ratingDetails = array( | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | 'event_id'=>$data['event_id'], | ||
} | 'customer_id'=>$user_id, | ||
return $res; | 'rate'=>$data['rating'], | ||
} | 'feedback'=>$data['description'] | ||
); | |||
$id = $this->db->insert('review', $ratingDetails); | |||
if($id) { | |||
$res = array('status'=>1); | |||
}else { | |||
$res = array('status'=>0,'message'=>'Event Rating failed please try again','code'=>'ER11'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function booking($data) { | |||
try{ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$post_data = $data; | |||
unset($post_data['auth_token']); | |||
$post_data['customer_id'] = $user_id; | |||
$post_data['ticket_details'] = json_encode($post_data['ticket_details']); | |||
$post_data['status'] = 3; | |||
$code = 'TO'; | |||
$ymd = date('ymd'); | |||
$squence = rand(1111,9999); | |||
$squence = str_pad($squence,4,0,STR_PAD_LEFT); | |||
$post_data['bookId'] = $code.$ymd.$squence; | |||
$post_data['qrcode'] = genQRcode($post_data['bookId']); | |||
$rs = $this->db->insert('booking', $post_data); | |||
$id = $this->db->insert_id(); | |||
if($id){ | |||
$res = array('status'=>1,'data'=>array('bookingCode'=>$post_data['bookId'])); | |||
} else { | |||
$res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function update_notification_email_status($data) { | |||
try{ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$notData = array('notification_status'=>$data['notification_status'], 'email_status'=>$data['email_status']); | |||
$this->db->where('id', $user_id); | |||
$this->db->where('status', 1); | |||
$this->db->where('user_type', 3); | |||
$status = $this->db->update('users', $notData); | |||
if ($status){ | |||
$res = array('status'=>1); | |||
}else { | |||
$res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function generateQR($data) { | |||
return 'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'; | |||
} | |||
function cancel($data) { | public function update_profile($data) { | ||
try { | |||
$user_id = $this->auth_token_get($data['auth_token']); | try{ | ||
if($user_id > 0) { | $user_id = $this->auth_token_get($data['auth_token']); | ||
$res_count = $this->db->where('bookId',$data['booking_id'])->where('status',1)->get('booking')->num_rows(); | $img_error = 0; | ||
if($res_count > 0) { | if($user_id > 0) { | ||
$rs = $this->db->where('bookId',$data['booking_id'])->update('booking',array('status'=>0)); | $post_data = $data; | ||
if($rs) { | unset($post_data['file']); | ||
$res = array('status'=>1,'data'=>null); | unset($post_data['auth_token']); | ||
if(isset($data['email'])){ | |||
$this->db->select('customer.email'); | |||
$this->db->where('customer.email',$data['email']); | |||
$this->db->where('customer_id !=',$user_id); | |||
$this->db->where('users.status !=',2); | |||
$this->db->from('users'); | |||
$this->db->join('customer','customer.customer_id = users.id'); | |||
$num = $this->db->get()->num_rows(); | |||
if($num > 0) | |||
{ | |||
$res = array('status'=>0,'message'=>'Email address already exist','code'=>'ER32'); | |||
return $res; | |||
} | |||
} | |||
if(isset($data['file'])){ | |||
$img=$data['file']['name']; | |||
$expbanner = explode('.',$img); | |||
$img_ext = strtolower($expbanner[1]); | |||
$rand = rand(10000,99999); | |||
$encname = time().$rand; | |||
if($img_ext=='png' || $img_ext=='jpeg' || $img_ext == 'jpg' || $img_ext == 'gif'){ | |||
$bannername = $encname.'.'.$img_ext; | |||
$imagePath="./assets/uploads/".$bannername; | |||
$post_data['profile_image'] = "assets/uploads/".$bannername; | |||
move_uploaded_file($data['file']["tmp_name"],$imagePath); | |||
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data); | |||
if($state){ | |||
$img_error = 1; | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Cancel submission failed','code'=>'ER25'); | $res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | ||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid booking code','code'=>'ER24'); | $res = array('status'=>0,'message'=>'Invalid Image type','code'=>'ER41'); | ||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $state = $this->db->where('customer_id',$user_id)->update('customer',$post_data); | ||
if($state){ | |||
$img_error = 1; | |||
} else { | |||
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | |||
} | |||
} | |||
if($img_error == 1) { | |||
$this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.profile_image AS image,customer.gender,users.id AS userId, customer.city'); | |||
$this->db->where('users.id',$user_id); | |||
$this->db->from('users'); | |||
$this->db->join('customer','customer.customer_id = users.id'); | |||
$result = $this->db->get()->row(); | |||
if($result){ | |||
$res = array('status'=>1,'data'=>$result); | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } | ||
} | catch(Exception $e) { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
function favouritelist($data) { | return $res; | ||
try { | } | ||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$where = array( | |||
'favourite.status'=>1, | |||
'favourite.is_favorite'=>1, | |||
'favourite.user_id'=>$user_id, | |||
'events.status'=>1 | |||
); | |||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | |||
if($lang->language == 'ar') { | |||
$cat_field = 'event_category.category_ar'; | function booking($data) { | ||
try{ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$post_data = $data; | |||
unset($post_data['auth_token']); | |||
$post_data['customer_id'] = $user_id; | |||
$post_data['ticket_details'] = json_encode($post_data['ticket_details']); | |||
$post_data['status'] = 3; | |||
$code = 'TO'; | |||
$ymd = date('ymd'); | |||
$squence = rand(1111,9999); | |||
$squence = str_pad($squence,4,0,STR_PAD_LEFT); | |||
$post_data['bookId'] = $code.$ymd.$squence; | |||
$post_data['qrcode'] = genQRcode($post_data['bookId']); | |||
$rs = $this->db->insert('booking', $post_data); | |||
$id = $this->db->insert_id(); | |||
if($id){ | |||
$res = array('status'=>1,'data'=>array('bookingCode'=>$post_data['bookId'])); | |||
} else { | |||
$res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
function generateQR($data) { | |||
return 'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'; | |||
} | |||
function cancel($data) { | |||
try { | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$res_count = $this->db->where('bookId',$data['booking_id'])->where('status',1)->get('booking')->num_rows(); | |||
if($res_count > 0) { | |||
$rs = $this->db->where('bookId',$data['booking_id'])->update('booking',array('status'=>0)); | |||
if($rs) { | |||
$res = array('status'=>1,'data'=>null); | |||
} else { | } else { | ||
$cat_field = 'event_category.category'; | $res = array('status'=>0,'message'=>'Cancel submission failed','code'=>'ER25'); | ||
} | } | ||
$result = $this->db->select("events.event_id,event_gallery.media_url,(SELECT COUNT(booking.id) FROM booking WHERE booking.event_id = events.event_id) AS attendees, | } else { | ||
$cat_field AS category,events.event_name,CAST(AVG (review.rate) AS DECIMAL (12,1)) AS rating,venue.location,IF(favourite.is_favorite = 0,'false','true') AS is_favorite,IF(events.provider_id = 0,'false','true') AS is_editors_choice,events.seat_pricing,events.custom_seat_layout,venue.layout,venue.layout_details")->where($where)->from('favourite')->join('review', 'review.event_id = favourite.event_id','LEFT')->join('events', 'events.event_id = favourite.event_id')->join('booking', 'booking.event_id = events.event_id','LEFT')->join('venue', 'venue.id = events.venue_id')->join('event_category', 'events.category_id = event_category.cat_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->group_by('events.event_id')->get()->result(); | $res = array('status'=>0,'message'=>'Invalid booking code','code'=>'ER24'); | ||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
if(count($result)>0){ | } catch(Exception $e) { | ||
$response = array(); | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
foreach ($result as $rs) { | } | ||
if($rs->layout!=''){ | return $res; | ||
if($rs->custom_seat_layout!=''){ | } | ||
$pricelist = json_decode($rs->custom_seat_layout, TRUE); | |||
$price = min(array_column($pricelist, 'price')); | |||
} else { | function favouritelist($data) { | ||
$pricelist = json_decode($rs->layout_details, TRUE); | try { | ||
$price = min(array_column($pricelist, 'price')); | $user_id = $this->auth_token_get($data['auth_token']); | ||
} | if($user_id > 0) { | ||
$where = array( | |||
'favourite.status'=>1, | |||
'favourite.is_favorite'=>1, | |||
'favourite.user_id'=>$user_id, | |||
'events.status'=>1 | |||
); | |||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | |||
if($lang->language == 'ar') { | |||
$cat_field = 'event_category.category_ar'; | |||
} else { | |||
$cat_field = 'event_category.category'; | |||
} | |||
$result = $this->db->select("events.event_id,event_gallery.media_url,(SELECT COUNT(booking.id) FROM booking WHERE booking.event_id = events.event_id) AS attendees, | |||
$cat_field AS category,events.event_name,CAST(AVG (review.rate) AS DECIMAL (12,1)) AS rating,venue.location,IF(favourite.is_favorite = 0,'false','true') AS is_favorite,IF(events.provider_id = 0,'false','true') AS is_editors_choice,events.seat_pricing,events.custom_seat_layout,venue.layout,venue.layout_details")->where($where)->from('favourite')->join('review', 'review.event_id = favourite.event_id','LEFT')->join('events', 'events.event_id = favourite.event_id')->join('booking', 'booking.event_id = events.event_id','LEFT')->join('venue', 'venue.id = events.venue_id')->join('event_category', 'events.category_id = event_category.cat_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->group_by('events.event_id')->get()->result(); | |||
if(count($result)>0){ | |||
$response = array(); | |||
foreach ($result as $rs) { | |||
if($rs->layout!=''){ | |||
if($rs->custom_seat_layout!=''){ | |||
$pricelist = json_decode($rs->custom_seat_layout, TRUE); | |||
$price = min(array_column($pricelist, 'price')); | |||
} else { | } else { | ||
$pricelist = json_decode($rs->seat_pricing, TRUE); | $pricelist = json_decode($rs->layout_details, TRUE); | ||
$price = $pricelist['price']; | $price = min(array_column($pricelist, 'price')); | ||
} | } | ||
$resData = array( | } else { | ||
'event_id'=>$rs->event_id, | $pricelist = json_decode($rs->seat_pricing, TRUE); | ||
'image'=>$rs->media_url, | $price = $pricelist['price']; | ||
'attendees'=>$rs->attendees, | |||
'category'=>$rs->category, | |||
'name'=>$rs->event_name, | |||
'rating'=>$rs->rating, | |||
'location'=>$rs->location, | |||
'rate'=>$price, | |||
'location'=>$rs->location, | |||
'is_favorite'=>$rs->is_favorite === 'true'? true: false, | |||
'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false | |||
); | |||
array_push($response, $resData); | |||
} | } | ||
$res = array('status'=>1,'data'=>$response); | $resData = array( | ||
} else { | 'event_id'=>$rs->event_id, | ||
$res = array('status'=>1,'data' => []); | 'image'=>$rs->media_url, | ||
'attendees'=>$rs->attendees, | |||
'category'=>$rs->category, | |||
'name'=>$rs->event_name, | |||
'rating'=>$rs->rating, | |||
'location'=>$rs->location, | |||
'rate'=>$price, | |||
'location'=>$rs->location, | |||
'is_favorite'=>$rs->is_favorite === 'true'? true: false, | |||
'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false | |||
); | |||
array_push($response, $resData); | |||
} | } | ||
$res = array('status'=>1,'data'=>$response); | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function bookedlist_old($data) { | function bookedlist_old($data) { | ||
try { | try { | ||
$per_page = 10; | $per_page = 10; | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
if($user_id > 0) { | if($user_id > 0) { | ||
$count = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count,(CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status')->where('booking.customer_id',$user_id)->from('booking')->join('transaction','transaction.booking_id = booking.bookId AND transaction.status = 1', 'LEFT')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->order_by('booking.id','DESC')->get()->num_rows(); | $count = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count,(CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status')->where('booking.customer_id',$user_id)->from('booking')->join('transaction','transaction.booking_id = booking.bookId AND transaction.status = 1', 'LEFT')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->order_by('booking.id','DESC')->get()->num_rows(); | ||
if($count > 0) { | if($count > 0) { | ||
if(isset($data['page'])) { | if(isset($data['page'])) { | ||
$page = $data['page']; | $page = $data['page']; | ||
} else { | } else { | ||
$page = 1; | $page = 1; | ||
} | } | ||
$page_limit = ($page - 1) * $per_page; | $page_limit = ($page - 1) * $per_page; | ||
if($count > $page_limit) { | if($count > $page_limit) { | ||
$result = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count, | $result = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count, | ||
(CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status')->where('booking.customer_id',$user_id)->from('booking')->join('transaction','transaction.booking_id = booking.bookId', 'LEFT')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->where('booking.payment_status', 1)->order_by('booking.id','DESC')->limit($per_page,$page_limit)->get()->result(); | (CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status')->where('booking.customer_id',$user_id)->from('booking')->join('transaction','transaction.booking_id = booking.bookId', 'LEFT')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->where('booking.payment_status', 1)->order_by('booking.id','DESC')->limit($per_page,$page_limit)->get()->result(); | ||
echo $this->db->last_query(); | |||
$meta = array('total_pages'=>ceil($count/$per_page), | |||
'total'=>$count, | |||
'current_page'=>$page, | |||
'per_page'=>$per_page | |||
); | |||
$response = array('bookings'=>$result,'meta'=>$meta); | echo $this->db->last_query(); | ||
$res = array('status'=>1,'data'=>$response); | $meta = array('total_pages'=>ceil($count/$per_page), | ||
} else { | 'total'=>$count, | ||
$res = array('status'=>1,'data' => []); | 'current_page'=>$page, | ||
} | 'per_page'=>$per_page | ||
); | |||
$response = array('bookings'=>$result,'meta'=>$meta); | |||
$res = array('status'=>1,'data'=>$response); | |||
} else { | } else { | ||
$res = array('status'=>1,'data' => []); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function bookedlist($data) { | function bookedlist($data) { | ||
try { | try { | ||
$per_page = 10; | $per_page = 10; | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
if($user_id > 0) { | if($user_id > 0) { | ||
$result1 = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count, | $result1 = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count, | ||
(CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status, transaction.status AS t_status,events.has_payment')->where('booking.customer_id',$user_id)->from('booking')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('transaction','transaction.booking_id = booking.bookId','LEFT')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->order_by('booking.id','DESC')->get()->result_array(); | (CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status, transaction.status AS t_status,events.has_payment')->where('booking.customer_id',$user_id)->from('booking')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('transaction','transaction.booking_id = booking.bookId','LEFT')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->order_by('booking.id','DESC')->get()->result_array(); | ||
foreach ($result1 as $value) { | foreach ($result1 as $value) { | ||
if($value['t_status'] != '2' AND $value['t_status'] != '0' ) { | if($value['t_status'] != '2' AND $value['t_status'] != '0' ) { | ||
$data_arr[] = $value; | $data_arr[] = $value; | ||
} | |||
} | } | ||
$count = count($data_arr); | } | ||
if($count > 0) { | $count = count($data_arr); | ||
if($count > 0) { | |||
if(isset($data['page'])) { | if(isset($data['page'])) { | ||
$page = $data['page']; | $page = $data['page']; | ||
} else { | } else { | ||
$page = 1; | $page = 1; | ||
} | } | ||
$page_limit = ($page - 1) * $per_page; | $page_limit = ($page - 1) * $per_page; | ||
if($count > $page_limit) { | if($count > $page_limit) { | ||
$result = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count, | $result = $this->db->select('booking.bookId AS booking_id,booking.event_id,events.event_name,event_gallery.media_url AS event_image,venue.location,event_date_time.date,event_date_time.time,booking.no_of_ticket AS ticket_count, | ||
(CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status, transaction.status AS t_status,events.has_payment')->where('booking.customer_id',$user_id)->from('booking')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('transaction','transaction.booking_id = booking.bookId','LEFT')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->order_by('booking.id','DESC')->get()->result_array(); | (CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status, transaction.status AS t_status,events.has_payment')->where('booking.customer_id',$user_id)->from('booking')->join('events','booking.event_id = events.event_id')->join('event_date_time','booking.event_date_id = event_date_time.id')->join('transaction','transaction.booking_id = booking.bookId','LEFT')->join('venue', 'venue.id = events.venue_id')->join('event_gallery', 'events.event_id = event_gallery.event_id AND event_gallery.media_type = 0', 'LEFT')->order_by('booking.id','DESC')->get()->result_array(); | ||
$data_arr = array(); | $data_arr = array(); | ||
foreach ($result as $value) { | foreach ($result as $value) { | ||
if($value['t_status'] != '2' AND $value['t_status'] != '0' ) { | if($value['t_status'] != '2' AND $value['t_status'] != '0' ) { | ||
$data_arr[] = $value; | $data_arr[] = $value; | ||
$bookList = array_slice($data_arr, $page_limit, $per_page, false); | $bookList = array_slice($data_arr, $page_limit, $per_page, false); | ||
} | |||
} | } | ||
$meta = array('total_pages'=>ceil($count/$per_page), | |||
'total'=>$count, | |||
'current_page'=>$page, | |||
'per_page'=>$per_page | |||
); | |||
$response = array('bookings'=>$bookList,'meta'=>$meta); | |||
$res = array('status'=>1,'data'=>$response); | |||
} else { | |||
$res = array('status'=>1,'data' => []); | |||
} | } | ||
$meta = array('total_pages'=>ceil($count/$per_page), | |||
'total'=>$count, | |||
'current_page'=>$page, | |||
'per_page'=>$per_page | |||
); | |||
$response = array('bookings'=>$bookList,'meta'=>$meta); | |||
$res = array('status'=>1,'data'=>$response); | |||
} else { | } else { | ||
$res = array('status'=>1,'data' => []); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function get_settings($data) { | function get_settings($data) { | ||
try { | try { | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
if($user_id > 0) { | if($user_id > 0) { | ||
$settingsDetails = $this->db->query("SELECT privacy_policy_en,terms_and_conditions_en,contact_number FROM privacy_policy")->row_array(); | $settingsDetails = $this->db->query("SELECT privacy_policy_en,terms_and_conditions_en,contact_number FROM privacy_policy")->row_array(); | ||
$notificationDetails = $this->db->query("SELECT notification_status, email_status FROM users WHERE id = ".$user_id."")->row_array(); | $notificationDetails = $this->db->query("SELECT notification_status, email_status FROM users WHERE id = ".$user_id."")->row_array(); | ||
if(count($settingsDetails)>0 && count($notificationDetails)>0){ | if(count($settingsDetails)>0 && count($notificationDetails)>0){ | ||
$resultData = array_merge($settingsDetails, $notificationDetails); | $resultData = array_merge($settingsDetails, $notificationDetails); | ||
$resultArray = array( | $resultArray = array( | ||
'privacy_policy'=>$resultData['privacy_policy_en'], | 'privacy_policy'=>$resultData['privacy_policy_en'], | ||
'terms_and_conditions'=>$resultData['terms_and_conditions_en'], | 'terms_and_conditions'=>$resultData['terms_and_conditions_en'], | ||
'contact_number'=>$resultData['contact_number'], | 'contact_number'=>$resultData['contact_number'], | ||
'notification_status'=>$resultData['notification_status'] == 0? 0: 1, | 'notification_status'=>$resultData['notification_status'] == 0? 0: 1, | ||
'email_status'=>$resultData['email_status'] == 0? 0: 1 | 'email_status'=>$resultData['email_status'] == 0? 0: 1 | ||
); | ); | ||
$res = array('status'=>1,'data'=>$resultArray); | $res = array('status'=>1,'data'=>$resultArray); | ||
} else { | |||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | |||
} | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function forgot_password($data) { | function forgot_password($data) { | ||
try { | try { | ||
$res_count = $this->db->select('customer.customer_id')->where('users.status=',1)->where('customer.phone',$data['phone'])->from('customer')->join('users','customer.customer_id = users.id')->get()->row_array(); | $res_count = $this->db->select('customer.customer_id')->where('users.status=',1)->where('customer.phone',$data['phone'])->from('customer')->join('users','customer.customer_id = users.id')->get()->row_array(); | ||
if($res_count!='') { | if($res_count!='') { | ||
$rs = $this->db->where('id',$res_count['customer_id'])->update('users',array('password'=> md5($data['new_password']))); | $rs = $this->db->where('id',$res_count['customer_id'])->update('users',array('password'=> md5($data['new_password']))); | ||
if($rs) { | if($rs) { | ||
$res = array('status'=>1,'data'=>null); | $res = array('status'=>1,'data'=>null); | ||
} else { | |||
$res = array('status'=>0,'message'=>'Updation failed Please try again','code'=>'ER15'); | |||
} | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Phone Number Does not exists','code'=>'ER19'); | $res = array('status'=>0,'message'=>'Updation failed Please try again','code'=>'ER15'); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Phone Number Does not exists','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
function get_last_booking($data) { | } | ||
try { | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0) { | |||
$result = $this->db->query("SELECT IF(review.event_id = '','false','true') AS is_last_booking_rated, booking.id AS booking_id, events.event_id AS event_id, events.event_name, `event_gallery`.`media_url` AS event_image,UNIX_TIMESTAMP(event_date_time.date) AS date, booking.amount AS amount FROM events LEFT JOIN `event_gallery` ON `events`.`event_id` = `event_gallery`.`event_id` AND `event_gallery`.`media_type` = 0 LEFT JOIN booking ON booking.event_id = events.event_id RIGHT JOIN event_date_time ON event_date_time.id = booking.event_date_id LEFT JOIN venue ON venue.id = events.venue_id LEFT JOIN customer ON customer.customer_id = booking.customer_id LEFT JOIN review ON review.event_id = booking.event_id WHERE booking.customer_id = ".$user_id." ORDER BY booking.id DESC LIMIT 1")->row_array(); | |||
if(count($result)>0){ | |||
$resultData = array( | |||
'is_last_booking_rated'=>$result['is_last_booking_rated'] === 'true'? true: false, | |||
'booking_id'=>$result['booking_id'], | |||
'event_id'=>$result['event_id'], | |||
'event_name'=>$result['event_name'], | |||
'event_image'=>$result['event_image'], | |||
'amount'=>$result['amount'], | |||
'date'=>$result['date'] | |||
); | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | function get_last_booking($data) { | ||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | try { | ||
} | $user_id = $this->auth_token_get($data['auth_token']); | ||
if($user_id > 0) { | |||
$result = $this->db->query("SELECT IF(review.event_id = '','false','true') AS is_last_booking_rated, booking.id AS booking_id, events.event_id AS event_id, events.event_name, `event_gallery`.`media_url` AS event_image,UNIX_TIMESTAMP(event_date_time.date) AS date, booking.amount AS amount FROM events LEFT JOIN `event_gallery` ON `events`.`event_id` = `event_gallery`.`event_id` AND `event_gallery`.`media_type` = 0 LEFT JOIN booking ON booking.event_id = events.event_id RIGHT JOIN event_date_time ON event_date_time.id = booking.event_date_id LEFT JOIN venue ON venue.id = events.venue_id LEFT JOIN customer ON customer.customer_id = booking.customer_id LEFT JOIN review ON review.event_id = booking.event_id WHERE booking.customer_id = ".$user_id." ORDER BY booking.id DESC LIMIT 1")->row_array(); | |||
if(count($result)>0){ | |||
$resultData = array( | |||
'is_last_booking_rated'=>$result['is_last_booking_rated'] === 'true'? true: false, | |||
'booking_id'=>$result['booking_id'], | |||
'event_id'=>$result['event_id'], | |||
'event_name'=>$result['event_name'], | |||
'event_image'=>$result['event_image'], | |||
'amount'=>$result['amount'], | |||
'date'=>$result['date'] | |||
); | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
} catch(Exception $e) { | } else { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
return $res; | } catch(Exception $e) { | ||
} | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | |||
return $res; | |||
} | |||
function filters($data) { | function filters($data) { | ||
try { | try { | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
if($user_id > 0) { | if($user_id > 0) { | ||
$locality = $this->db->select('id AS city_id,locality AS city_name')->where('status',1)->get('locality')->result(); | $locality = $this->db->select('id AS city_id,locality AS city_name')->where('status',1)->get('locality')->result(); | ||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | $lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | ||
if($lang->language == 'ar') { | if($lang->language == 'ar') { | ||
$cat_field = 'event_category.category_ar'; | $cat_field = 'event_category.category_ar'; | ||
} else { | |||
$cat_field = 'event_category.category'; | |||
} | |||
//$category = $this->db->select('cat_id AS category_id, "$cat_field" AS category,category_image')->where('status',1)->get('event_category')->result(); | |||
$category = $this->db->query("SELECT cat_id AS category_id, $cat_field AS category,category_image FROM event_category WHERE status = 1")->result(); | |||
$dateArray = [["date_id" => "All Days","date" => "1"],["date_id" => "Today","date" => "2"],["date_id" => "Tomorrow","date" => "3"], | |||
["date_id" => "This week","date" => "4"],["date_id" => "Weekend","date" => "5"],["date_id" => "Later","date" => "6"]]; | |||
if(!EMPTY($locality)) { | |||
$locality = $locality; | |||
}else{ | |||
$locality = 'null'; | |||
} | |||
if(!EMPTY($category)) { | |||
$category = $category; | |||
}else{ | |||
$category = 'null'; | |||
} | |||
if(isset($dateArray)){ | |||
$resultData = array(); | |||
$resData = array( | |||
'cities'=>$locality, | |||
'categories'=>$category, | |||
'dates'=>$dateArray | |||
); | |||
$res = array('status'=>1,'data'=>$resData); | |||
} else { | |||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | |||
} | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $cat_field = 'event_category.category'; | ||
} | } | ||
} catch(Exception $e) { | //$category = $this->db->select('cat_id AS category_id, "$cat_field" AS category,category_image')->where('status',1)->get('event_category')->result(); | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $category = $this->db->query("SELECT cat_id AS category_id, $cat_field AS category,category_image FROM event_category WHERE status = 1")->result(); | ||
} | $dateArray = [["date_id" => "All Days","date" => "1"],["date_id" => "Today","date" => "2"],["date_id" => "Tomorrow","date" => "3"], | ||
return $res; | ["date_id" => "This week","date" => "4"],["date_id" => "Weekend","date" => "5"],["date_id" => "Later","date" => "6"]]; | ||
} | |||
if(!EMPTY($locality)) { | |||
$locality = $locality; | |||
}else{ | |||
$locality = 'null'; | |||
} | |||
if(!EMPTY($category)) { | |||
$category = $category; | |||
}else{ | |||
$category = 'null'; | |||
} | |||
if(isset($dateArray)){ | |||
$resultData = array(); | |||
$resData = array( | |||
'cities'=>$locality, | |||
'categories'=>$category, | |||
'dates'=>$dateArray | |||
); | |||
$res = array('status'=>1,'data'=>$resData); | |||
} else { | |||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | |||
} | |||
} else { | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | } | ||
?> | } | ||
\ No newline at end of file | ?> | ||
\ No newline at end of file |
Please
register
or
sign in
to comment