Merge branch 'master' into 'dev_production'
Master
See merge request !97
Showing
... | @@ -4,13 +4,13 @@ | ... | @@ -4,13 +4,13 @@ |
[3] Collaborator ID : BAYANPAY | [3] Collaborator ID : BAYANPAY | ||
[4] Bayan URL : https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet | [4] Bayan URL : https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet | ||
[5] Block Existence Indicator : 1110100 | [5] Block Existence Indicator : 1110100 | ||
[6] DataBlock1 : TransactionDataBlock1 : 10111111|1565768157|http://localhost/timeOut/Api/paymentSuccessUrl|http://localhost/timeOut/Api/paymentFailureUrl|INTERNET|CC|01|SAR | [6] DataBlock1 : TransactionDataBlock1 : 11111111|1565949321|200|http://localhost/timeOut/Api/paymentSuccessUrl|http://localhost/timeOut/Api/paymentFailureUrl|INTERNET|CC|01|SAR | ||
[7] DataBlock2 : billingDataBlock : 0000000000000| | [7] DataBlock2 : billingDataBlock : 1000000011000|Dev|[email protected]|919995559194 | ||
[8] DataBlock3 : shippingDataBlock : 000000000000| | [8] DataBlock3 : shippingDataBlock : 100000000001|Dev|919995559194 | ||
[9] DataBlock4 : paymentDataBlock : NULL | [9] DataBlock4 : paymentDataBlock : NULL | ||
[10] DataBlock5 : merchantDataBlock : 0000000000| | [10] DataBlock5 : merchantDataBlock : 1110000000|490|128|TO1908161619 | ||
[11] DataBlock6 : otherDataBlock : NULL | [11] DataBlock6 : otherDataBlock : NULL | ||
[12] DataBlock7 : DCCDataBlock : NULL | [12] DataBlock7 : DCCDataBlock : NULL | ||
[13] beforeEncryptionString : 1110100||10111111|1565768157|http://localhost/timeOut/Api/paymentSuccessUrl|http://localhost/timeOut/Api/paymentFailureUrl|INTERNET|CC|01|SAR||0000000000000|||000000000000|||0000000000| | [13] beforeEncryptionString : 1110100||11111111|1565949321|200|http://localhost/timeOut/Api/paymentSuccessUrl|http://localhost/timeOut/Api/paymentFailureUrl|INTERNET|CC|01|SAR||1000000011000|Dev|[email protected]|919995559194||100000000001|Dev|919995559194||1110000000|490|128|TO1908161619 | ||
[14] EncryptedString : 6SLNoOCXnCfuN+p+4JSpYIoQEIYGwFXo5BVHgqPFLZ3AQzcZ0mBSn61URC66o1a13cH7XNEUJ5j4ssaNmGD+xJi4d1WQMv4zJcqsDRuR8QEWcst/wvbI/chd0qTkElo18kqv324p+odC5W0k2NTHoYUj0ospvVu5moa4dXbl8ikUPMk1siZW+aIb7ZUGDHRefDKTenHjMvbJsvaANWH12SU84ZCFkg40+n0YZeAPIUe3yXHH91BMyYfShu4K2pj7 | [14] EncryptedString : S7fVSoNGH4bne+vZCz3T1hU1jYM1Wo9nk7xgNovOGFPqdJ8JZaCs5fRYysGksWJe4Nid+xoi654uECYUpOXw4LFWQ3KhU7ih8k9TxJfm7v5crHFlq0Tbwl6ghhmwJcGDQos/PYiP4jT0kUWm1IEUrrMksj82dYIDhG3+gPydjzkNrSJLblaQ/FUg6Jl5nHvO73/gdIqQSCgUNcDn3qKbO/3ApXUBuLpJJs28a42HpwYPke7q7etbFHNaiIjPlVSjjFepxARZ8yTBO26QmrLpF12Fai0EN8CetlBjmjnVByJc7PW78wS6hy7DYIKg5uccprmiRiaeW1f1vvCBsAy45g== | ||
[15] BayanPostData : 201901291000002||BAYANPAY||6SLNoOCXnCfuN+p+4JSpYIoQEIYGwFXo5BVHgqPFLZ3AQzcZ0mBSn61URC66o1a13cH7XNEUJ5j4ssaNmGD+xJi4d1WQMv4zJcqsDRuR8QEWcst/wvbI/chd0qTkElo18kqv324p+odC5W0k2NTHoYUj0ospvVu5moa4dXbl8ikUPMk1siZW+aIb7ZUGDHRefDKTenHjMvbJsvaANWH12SU84ZCFkg40+n0YZeAPIUe3yXHH91BMyYfShu4K2pj7 | [15] BayanPostData : 201901291000002||BAYANPAY||S7fVSoNGH4bne+vZCz3T1hU1jYM1Wo9nk7xgNovOGFPqdJ8JZaCs5fRYysGksWJe4Nid+xoi654uECYUpOXw4LFWQ3KhU7ih8k9TxJfm7v5crHFlq0Tbwl6ghhmwJcGDQos/PYiP4jT0kUWm1IEUrrMksj82dYIDhG3+gPydjzkNrSJLblaQ/FUg6Jl5nHvO73/gdIqQSCgUNcDn3qKbO/3ApXUBuLpJJs28a42HpwYPke7q7etbFHNaiIjPlVSjjFepxARZ8yTBO26QmrLpF12Fai0EN8CetlBjmjnVByJc7PW78wS6hy7DYIKg5uccprmiRiaeW1f1vvCBsAy45g== | ||
\ No newline at end of file | \ No newline at end of file |
... | @@ -30,21 +30,26 @@ class Webservice_model extends CI_Model { | ... | @@ -30,21 +30,26 @@ class Webservice_model extends CI_Model { |
function login($data){ | function login($data){ | ||
try{ | try{ | ||
$this->db->select("region.id AS city_id,region.name AS city, | $sql = "SELECT region.id AS city_id, customer.name AS user_name,customer.phone, customer.email, | ||
customer.name AS user_name,customer.phone, | customer.profile_image AS profile_photo, IF(customer.phone_verified=0,'false', 'true') AS is_phone_verified, IF(customer.city='', 'false', 'true') AS is_location_updated, | ||
customer.email,customer.profile_image AS profile_photo, | users.id AS user_id | ||
IF(customer.phone_verified=0,'false','true') AS is_phone_verified, | FROM users | ||
IF(customer.city='','false','true') AS is_location_updated, | INNER JOIN customer ON (customer.customer_id=users.id) | ||
users.id AS user_id"); | LEFT JOIN region ON (region.id=customer.city) | ||
$this->db->where('users.status',1); | WHERE users.status = 1 | ||
$this->db->where('users.password',md5($data['password'])); | AND users.password = '".md5($data['password'])."' | ||
$this->db->where('customer.email',$data['email']); | AND customer.email = '".$data['email']."'"; | ||
$this->db->from('users'); | $result = $this->db->query($sql)->row(); | ||
$this->db->join('customer','customer.customer_id=users.id'); | |||
$this->db->join('region','region.id=customer.city','left'); | |||
$result = $this->db->get()->row(); | |||
if($result){ | if($result){ | ||
$auth_token = md5(microtime().rand()); | $auth_token = md5(microtime().rand()); | ||
$countryData = $this->getCountryData($result->user_id); | |||
$lang = $countryData['language_code']; | |||
if(!empty($lanTrans = langTranslator($result->city_id,'REG',$lang))){ | |||
$result->city = $lanTrans['region_name']; | |||
} | |||
if($result->city_id != ''){ | if($result->city_id != ''){ | ||
$cityId = $result->city_id; | $cityId = $result->city_id; | ||
$cityName = $result->city; | $cityName = $result->city; | ||
... | @@ -63,9 +68,8 @@ class Webservice_model extends CI_Model { | ... | @@ -63,9 +68,8 @@ class Webservice_model extends CI_Model { |
'is_phone_verified'=>$result->is_phone_verified === 'true'? true: false, | 'is_phone_verified'=>$result->is_phone_verified === 'true'? true: false, | ||
'is_location_updated'=>$result->is_location_updated === 'true'? true: false, | 'is_location_updated'=>$result->is_location_updated === 'true'? true: false, | ||
); | ); | ||
$this->db->update('customer',array('language'=>$data['language']), | $this->db->update('customer',array('country_id'=>$data['country_id']), | ||
array('customer_id'=>$result->user_id)); | array('customer_id'=>$result->user_id)); | ||
$response = array('user'=>$resultArray,'auth_token'=>$auth_token); | $response = array('user'=>$resultArray,'auth_token'=>$auth_token); | ||
$this->generateAuth($result->user_id,$auth_token); | $this->generateAuth($result->user_id,$auth_token); | ||
$res = array('status'=>1,'data'=>$response); | $res = array('status'=>1,'data'=>$response); | ||
... | @@ -83,7 +87,7 @@ class Webservice_model extends CI_Model { | ... | @@ -83,7 +87,7 @@ class Webservice_model extends CI_Model { |
$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); | $this->db->where('customer_id', $user_id); | ||
$id = $this->db->update('customer', array('language' => $data['language'])); | $id = $this->db->update('customer', array('country_id'=>$data['country_id'])); | ||
if($id) { | if($id) { | ||
$res = array('status'=>1); | $res = array('status'=>1); | ||
}else { | }else { | ||
... | @@ -98,11 +102,11 @@ class Webservice_model extends CI_Model { | ... | @@ -98,11 +102,11 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function availability($data) { | function availability($data) { | ||
try{ | try{ | ||
$is_email_available = "true"; | $is_email_available = "true"; | ||
$is_phone_available = "true"; | $is_phone_available = "true"; | ||
$data['phone'] = preg_replace('/\D/', '', $data['phone']); | |||
$res_count = $this->db->where('email',$data['email'])->or_where('phone',$data['phone'])->get('customer')->result(); | $res_count = $this->db->where('email',$data['email'])->or_where('phone',$data['phone'])->get('customer')->result(); | ||
if(count($res_count) > 0) { | if(count($res_count) > 0) { | ||
foreach ($res_count as $rs) { | foreach ($res_count as $rs) { | ||
... | @@ -126,11 +130,10 @@ class Webservice_model extends CI_Model { | ... | @@ -126,11 +130,10 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function register($data) { | function register($data) { | ||
try{ | try{ | ||
$email = $data['email']; | $email = $data['email']; | ||
$phone = $data['phone']; | $phone = preg_replace('/\D/', '', $data['phone']); | ||
$res_count = $this->db->query("SELECT * FROM customer | $res_count = $this->db->query("SELECT * FROM customer | ||
INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3' | INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3' | ||
WHERE users.status!='2' AND | WHERE users.status!='2' AND | ||
... | @@ -159,27 +162,23 @@ class Webservice_model extends CI_Model { | ... | @@ -159,27 +162,23 @@ class Webservice_model extends CI_Model { |
'phone'=>$data['phone'], | 'phone'=>$data['phone'], | ||
'email'=>$data['email'], | 'email'=>$data['email'], | ||
'name'=>$data['name'], | 'name'=>$data['name'], | ||
'language'=>$data['language'] | 'country_id'=>$data['country_id'] | ||
); | ); | ||
$this->db->insert('customer', $customer_data); | $this->db->insert('customer', $customer_data); | ||
$email = $data['email']; | $email = $data['email']; | ||
$subject = "New account created successfully"; | $subject = "New account created successfully"; | ||
$message = "Hi, Welcome to TimeOut. Please use username: ".$email. | $message = "Hi, Welcome to TimeOut. Please use username: ".$email. | ||
" for access your account"; | " for access your account"; | ||
if(isset($template['registration_mail']) && !empty($template['registration_mail'])){ | if(isset($template['registration_mail']) && !empty($template['registration_mail'])){ | ||
$message = str_replace(array('{:email}'), | $message = str_replace(array('{:email}'), | ||
array($email),$template['registration_mail']); | array($email),$template['registration_mail']); | ||
} | } | ||
$this->send_mail($subject,$email,$message); | $this->send_mail($subject,$email,$message); | ||
if(isset($template['registration_sms']) && !empty($template['registration_sms'])){ | if(isset($template['registration_sms']) && !empty($template['registration_sms'])){ | ||
$message = str_replace(array('{:email}'), | $message = str_replace(array('{:email}'), | ||
array($email),$template['registration_sms']); | array($email),$template['registration_sms']); | ||
} | } | ||
$this->sendSMS($data['phone'],$message); | $this->sendSMS($data['phone'],$message); | ||
$this->db->select("customer.name AS user_name,customer.phone,customer.email,customer.profile_image AS profile_photo,users.id AS user_id, IF(customer.phone_verified = 0,'false','true') AS is_phone_verified"); | $this->db->select("customer.name AS user_name,customer.phone,customer.email,customer.profile_image AS profile_photo,users.id AS user_id, IF(customer.phone_verified = 0,'false','true') AS is_phone_verified"); | ||
$this->db->where('users.id',$id); | $this->db->where('users.id',$id); | ||
$this->db->from('users'); | $this->db->from('users'); | ||
... | @@ -211,19 +210,18 @@ class Webservice_model extends CI_Model { | ... | @@ -211,19 +210,18 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function profile_details($data) { | function profile_details($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) { | ||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$lang = $this->getUserLang($user_id); | $settings = getSettings(); | ||
$field = 'faq_en'; | $sql = "SELECT faq FROM translator_policies WHERE language_code='$lang'"; | ||
if($lang == 'ar'){ | $settingsDetails = $this->db->query($sql)->row_array(); | ||
$field = 'faq_ar'; | $settingsDetails['contact_number'] = $settings['contact_number']; | ||
} | |||
$settingsDetails = $this->db->query("SELECT $field AS faq,contact_number FROM privacy_policy")->row_array(); | |||
$userDetails = $this->db->query("SELECT customer.name AS name, customer.profile_image AS profile_photo,customer.gender AS gender, customer.email, customer.dob, customer.profile_city AS city_name, users.notification_status, users.email_status FROM customer INNER JOIN users ON users.id = customer.customer_id WHERE customer.customer_id = ".$user_id." AND users.status = 1 ")->row_array(); | $userDetails = $this->db->query("SELECT customer.name AS name, customer.profile_image AS profile_photo,customer.gender AS gender, customer.email, customer.dob, customer.profile_city AS city_name, users.notification_status, users.email_status FROM customer INNER JOIN users ON users.id = customer.customer_id WHERE customer.customer_id = ".$user_id." AND users.status = 1 ")->row_array(); | ||
if(count($settingsDetails)>0 && count($userDetails)){ | if(count($settingsDetails)>0 && count($userDetails)){ | ||
$resultData = array(); | $resultData = array(); | ||
... | @@ -241,35 +239,33 @@ class Webservice_model extends CI_Model { | ... | @@ -241,35 +239,33 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function discover($data) { | function discover($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) { | ||
$where = ''; | $where = ''; | ||
$lang = $this->getUserLang($user_id); | $countryData = $this->getCountryData($user_id); | ||
$lang = $countryData['language_code']; | |||
$cityField = "region.name AS city"; | $rate = (!empty($countryData['conversion_rate']))?$countryData['conversion_rate']:1; | ||
if($lang == 'ar') { | $sql = "SELECT region.id FROM customer | ||
$cityField = 'region.name_ar AS city'; | |||
} | |||
$sql = "SELECT region.id,$cityField FROM customer | |||
INNER JOIN region ON customer.city=region.id | INNER JOIN region ON customer.city=region.id | ||
WHERE customer.customer_id='$user_id' AND region.status='1'"; | WHERE customer.customer_id='$user_id' AND region.status='1'"; | ||
$cityName = $this->db->query($sql)->row_array(); | $cityName = $this->db->query($sql)->row_array(); | ||
$cityName['city'] = (empty($cityName))?'null':$cityName['city']; | if(!empty($cityName)){ | ||
$regData = langTranslator($cityName['id'],'REG',$lang); | |||
$cityName['city'] = $regData['region_name']; | |||
} else { | |||
$cityName['city'] = 'null'; | |||
} | |||
if(isset($data['category_id'])) { | if(isset($data['category_id'])) { | ||
$where = ' AND events.category_id = '.$data['category_id']; | $where = ' AND events.category_id = '.$data['category_id']; | ||
} | } | ||
$case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; | $case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; | ||
if(isset($data['latitude']) && isset($data['longitude'])) { | if(isset($data['latitude']) && isset($data['longitude'])) { | ||
$radius = 25; | $radius = 25; | ||
$res = $this->db->query("SELECT events.event_id,venue.id,venue.status, (((acos(sin((".$data['latitude']."*pi()/180)) * sin((venue.location_lat*pi()/180)) + cos((".$data['latitude']."*pi()/180)) * cos((venue.location_lat*pi()/180)) * cos(((".$data['longitude']." - venue.location_lng)*pi()/180))))*180/pi())*60*1.1515) as distance FROM venue RIGHT JOIN events ON events.venue_id = venue.id HAVING distance < ".$radius." AND venue.status = '1'")->result_array(); | $res = $this->db->query("SELECT events.event_id,venue.id,venue.status, (((acos(sin((".$data['latitude']."*pi()/180)) * sin((venue.location_lat*pi()/180)) + cos((".$data['latitude']."*pi()/180)) * cos((venue.location_lat*pi()/180)) * cos(((".$data['longitude']." - venue.location_lng)*pi()/180))))*180/pi())*60*1.1515) as distance FROM venue RIGHT JOIN events ON events.venue_id = venue.id HAVING distance < ".$radius." AND venue.status = '1'")->result_array(); | ||
$otherV = ''; | $otherV = ''; | ||
foreach($res as $key => $value){ | foreach($res as $key => $value){ | ||
if ($otherV) $otherV .= ','; | if ($otherV) $otherV .= ','; | ||
... | @@ -281,11 +277,9 @@ class Webservice_model extends CI_Model { | ... | @@ -281,11 +277,9 @@ class Webservice_model extends CI_Model { |
$where = ' AND events.category_id IN (0)'; | $where = ' AND events.category_id IN (0)'; | ||
} | } | ||
} | } | ||
if(isset($cityName['id'])) { | if(isset($cityName['id'])) { | ||
$where .= ' AND venue.region_id = '.$cityName['id']; | $where .= ' AND venue.region_id = '.$cityName['id']; | ||
} | } | ||
if(isset($data['filters'])){ | if(isset($data['filters'])){ | ||
$filtersElement = json_decode($data['filters'], true); | $filtersElement = json_decode($data['filters'], true); | ||
$locality_id_Array = $filtersElement['cities']; | $locality_id_Array = $filtersElement['cities']; | ||
... | @@ -294,11 +288,9 @@ class Webservice_model extends CI_Model { | ... | @@ -294,11 +288,9 @@ class Webservice_model extends CI_Model { |
$dateId = preg_replace("/[^a-zA-Z 0-9]+/", "", $dateId_Array); | $dateId = preg_replace("/[^a-zA-Z 0-9]+/", "", $dateId_Array); | ||
$categoryId_Array = $filtersElement['category']; | $categoryId_Array = $filtersElement['category']; | ||
$categoryId = preg_replace("/[^a-zA-Z 0-9]+/", "", $categoryId_Array); | $categoryId = preg_replace("/[^a-zA-Z 0-9]+/", "", $categoryId_Array); | ||
if($categoryId!=''){ | if($categoryId!=''){ | ||
$where = ' AND events.category_id='.$categoryId; | $where = ' AND events.category_id='.$categoryId; | ||
} | } | ||
if($dateId != '') { | if($dateId != '') { | ||
switch ($dateId) { | switch ($dateId) { | ||
case '1': | case '1': | ||
... | @@ -336,14 +328,12 @@ class Webservice_model extends CI_Model { | ... | @@ -336,14 +328,12 @@ class Webservice_model extends CI_Model { |
break; | break; | ||
} | } | ||
} | } | ||
if($locality_id!=''){ | if($locality_id!=''){ | ||
$venue_res = $this->db->select('id')->where('locality_id',$locality_id)->get('venue')->result_array(); | $venue_res = $this->db->select('id')->where('locality_id',$locality_id)->get('venue')->result_array(); | ||
$list = implode(',', array_map(function($v) { return $v['id']; }, $venue_res)); | $list = implode(',', array_map(function($v) { return $v['id']; }, $venue_res)); | ||
$where .= ' AND events.venue_id IN('.$list.')'; | $where .= ' AND events.venue_id IN('.$list.')'; | ||
} | } | ||
} | } | ||
$resCount = $this->db->query(" | $resCount = $this->db->query(" | ||
SELECT GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date, | SELECT GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date, | ||
event_date_time.time)) AS date_time | event_date_time.time)) AS date_time | ||
... | @@ -359,11 +349,9 @@ class Webservice_model extends CI_Model { | ... | @@ -359,11 +349,9 @@ class Webservice_model extends CI_Model { |
favourite.user_id = $user_id AND favourite.status = 1 | favourite.user_id = $user_id AND favourite.status = 1 | ||
WHERE events.status = 1 $where | WHERE events.status = 1 $where | ||
GROUP BY events.event_id")->result(); | GROUP BY events.event_id")->result(); | ||
if(empty($resCount)){ | if(empty($resCount)){ | ||
return array('status'=>1,'data'=>array('city_name'=>$cityName['city'])); | return array('status'=>1,'data'=>array('city_name'=>$cityName['city'])); | ||
} | } | ||
foreach ($resCount AS $key => $rs) { | foreach ($resCount AS $key => $rs) { | ||
if(!empty($dates = explode(',',$rs->date_time))){ | if(!empty($dates = explode(',',$rs->date_time))){ | ||
$checkTime = 0; | $checkTime = 0; | ||
... | @@ -386,19 +374,13 @@ class Webservice_model extends CI_Model { | ... | @@ -386,19 +374,13 @@ class Webservice_model extends CI_Model { |
} | } | ||
} | } | ||
$count = count($resCount); | $count = count($resCount); | ||
if($count > 0) { | if($count > 0) { | ||
$page = (isset($data['page']))?$data['page']:1; | $page = (isset($data['page']))?$data['page']:1; | ||
$page_limit = ($page - 1)*$per_page; | $page_limit = ($page - 1)*$per_page; | ||
if($lang == 'ar') { | |||
$cat_field = 'event_category.category_ar'; | |||
} else { | |||
$cat_field = 'event_category.category_en'; | |||
} | |||
if($count > $page_limit) { | if($count > $page_limit) { | ||
$result = $this->db->query(" | $result = $this->db->query(" | ||
SELECT events.seat_pricing,events.custom_seat_layout,venue.location_lat AS latitude,venue.location_lng AS longitude,venue.layout,venue.layout_details,events.event_id AS event_id, events.event_name AS name,events.event_name_ar AS name_ar,`event_gallery`.`media_url` AS image, (SELECT SUM(booking.no_of_ticket) FROM booking WHERE booking.event_id = events.event_id AND booking.status IN (1,2)) AS attendees, $cat_field AS category, CAST(AVG (review.rate) AS DECIMAL (12,1)) AS rating, venue.venue_name, venue.location, IF(events.avg_price = 0, '100','150') AS rate, IF(events.provider_id = 1,'true','false') AS is_editors_choice, IF(favourite.is_favorite = 1, 'true','false') AS is_favorite, GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date,event_date_time.time)) AS date_time | SELECT events.seat_pricing,events.custom_seat_layout,event_category.cat_id,venue.id AS venue_id,venue.location_lat AS latitude,venue.location_lng AS longitude,venue.layout,venue.layout_details,events.event_id AS event_id,event_gallery.media_url AS image, (SELECT SUM(booking.no_of_ticket) FROM booking WHERE booking.event_id = events.event_id AND booking.status IN (1,2)) AS attendees,CAST(AVG (review.rate) AS DECIMAL (12,1)) AS rating,venue.location, IF(events.avg_price = 0, '100','150') AS rate, IF(events.provider_id = 1,'true','false') AS is_editors_choice, IF(favourite.is_favorite = 1, 'true','false') AS is_favorite, GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date,event_date_time.time)) AS date_time | ||
FROM events | FROM events | ||
INNER JOIN venue ON venue.id = events.venue_id | INNER JOIN venue ON venue.id = events.venue_id | ||
INNER JOIN event_date_time ON events.event_id = event_date_time.event_id | INNER JOIN event_date_time ON events.event_id = event_date_time.event_id | ||
... | @@ -412,7 +394,6 @@ class Webservice_model extends CI_Model { | ... | @@ -412,7 +394,6 @@ class Webservice_model extends CI_Model { |
WHERE events.status = 1 $where $case | WHERE events.status = 1 $where $case | ||
GROUP BY events.event_id | GROUP BY events.event_id | ||
LIMIT $page_limit,$per_page")->result(); | LIMIT $page_limit,$per_page")->result(); | ||
$response = array(); | $response = array(); | ||
foreach ($result as $key=>$rs) { | foreach ($result as $key=>$rs) { | ||
if(!empty($dates = explode(',',$rs->date_time)) && count($dates) > 0){ | if(!empty($dates = explode(',',$rs->date_time)) && count($dates) > 0){ | ||
... | @@ -425,37 +406,48 @@ class Webservice_model extends CI_Model { | ... | @@ -425,37 +406,48 @@ class Webservice_model extends CI_Model { |
} | } | ||
if($checkTime == count($dates)) continue; | if($checkTime == count($dates)) continue; | ||
} else continue; | } else continue; | ||
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 = $rate*min(array_column($pricelist, 'price')); | ||
} else { | } else { | ||
$pricelist = json_decode($rs->layout_details, TRUE); | $pricelist = json_decode($rs->layout_details, TRUE); | ||
$price = min(array_column($pricelist, 'price')); | $price = $rate*min(array_column($pricelist, 'price')); | ||
} | } | ||
} else { | } else { | ||
$pricelist = json_decode($rs->seat_pricing, TRUE); | $pricelist = json_decode($rs->seat_pricing, TRUE); | ||
$price = $pricelist['price']; | $price = $rate*$pricelist['price']; | ||
} | |||
$transData = array('event'=>'','category'=>'','venue'=>''); | |||
if(!empty($lanTrans = langTranslator($rs->event_id,'EVT',$lang))){ | |||
$transData['event'] = $lanTrans['event_name']; | |||
} | } | ||
if(!empty($lanTrans = langTranslator($rs->cat_id,'CAT',$lang))){ | |||
$transData['category'] = $lanTrans['category_name']; | |||
} | |||
if(!empty($lanTrans = langTranslator($rs->venue_id,'VEN',$lang))){ | |||
$transData['venue'] = $lanTrans['venue_name']; | |||
} | |||
$resData = array( | $resData = array( | ||
'id' => "$key", | 'id' => "$key", | ||
'event_id'=>$rs->event_id, | 'event_id'=>$rs->event_id, | ||
'image'=>$rs->image, | 'image'=>$rs->image, | ||
'attendees'=>(!empty($rs->attendees))?$rs->attendees:'0', | 'attendees'=>(!empty($rs->attendees))?$rs->attendees:'0', | ||
'category'=>$rs->category, | 'category'=>$transData['category'], | ||
'name'=>($lang == 'en')?$rs->name:$rs->name_ar, | 'name'=>$transData['event'], | ||
'rating'=>(!empty($rs->rating))?$rs->rating:'0', | 'rating'=>(!empty($rs->rating))?$rs->rating:'0', | ||
'location'=>$rs->venue_name.', '.$rs->location, | 'location'=>$transData['venue'].', '.$rs->location, | ||
'rate'=>$price, | 'rate'=>$price, | ||
'is_editors_choice'=>$rs->is_editors_choice, | 'is_editors_choice'=>$rs->is_editors_choice, | ||
'is_favorite'=>$rs->is_favorite === 'true'? true: false, | 'is_favorite'=>$rs->is_favorite === 'true'? true: false, | ||
'latitude'=>$rs->latitude, | 'latitude'=>$rs->latitude, | ||
'longitude'=>$rs->longitude | 'longitude'=>$rs->longitude, | ||
'currency_symbol'=>$countryData['currency_symbol'] | |||
); | ); | ||
array_push($response, $resData); | array_push($response, $resData); | ||
} | } | ||
$sql = "SELECT booking.id,review.rate | $sql = "SELECT booking.id,review.rate | ||
FROM booking | FROM booking | ||
LEFT JOIN review ON review.event_id=booking.event_id AND | LEFT JOIN review ON review.event_id=booking.event_id AND | ||
... | @@ -463,7 +455,6 @@ class Webservice_model extends CI_Model { | ... | @@ -463,7 +455,6 @@ class Webservice_model extends CI_Model { |
WHERE booking.customer_id = ".$user_id." AND booking.status='2' | WHERE booking.customer_id = ".$user_id." AND booking.status='2' | ||
ORDER BY booking.id DESC LIMIT 1"; | ORDER BY booking.id DESC LIMIT 1"; | ||
$lastBooking = $this->db->query($sql)->row_array(); | $lastBooking = $this->db->query($sql)->row_array(); | ||
if($lastBooking['id'] != ''){ | if($lastBooking['id'] != ''){ | ||
if($lastBooking['rate'] != ''){ | if($lastBooking['rate'] != ''){ | ||
$lastBooking = "false"; | $lastBooking = "false"; | ||
... | @@ -478,7 +469,6 @@ class Webservice_model extends CI_Model { | ... | @@ -478,7 +469,6 @@ class Webservice_model extends CI_Model { |
'current_page'=>$page, | 'current_page'=>$page, | ||
'per_page'=>$per_page | 'per_page'=>$per_page | ||
); | ); | ||
if(count($result)>0){ | if(count($result)>0){ | ||
$resultData = array(); | $resultData = array(); | ||
$resultData['is_last_booking_avail'] = $lastBooking; | $resultData['is_last_booking_avail'] = $lastBooking; | ||
... | @@ -505,73 +495,78 @@ class Webservice_model extends CI_Model { | ... | @@ -505,73 +495,78 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function event($data) { | function event($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) { | ||
$event_id = $data['event_id']; | $event_id = $data['event_id']; | ||
$cTime = date("H:i", strtotime('+15 minutes')); | $cTime = date("H:i", strtotime('+15 minutes')); | ||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$rate = (!empty($countryData['conversion_rate']))?$countryData['conversion_rate']:1; | |||
$this->db->query("SET SESSION group_concat_max_len = 20000"); | $this->db->query("SET SESSION group_concat_max_len = 20000"); | ||
$rs = $this->db->query(" | $sql = "SELECT host_categories.show_layout AS is_layout,venue.id AS venue_id, | ||
SELECT host_categories.show_layout AS is_layout,events.has_payment AS is_payment_required, | events.has_payment AS is_payment_required,favourite.is_favorite AS is_favorite, | ||
favourite.is_favorite AS is_favorite,events.event_id, events.event_name, | events.seat_pricing,events.custom_seat_layout,events.event_id, | ||
events.event_name_ar,events.event_description AS event_description, | venue.layout, venue.layout_details,venue.location,venue.location AS address, | ||
events.event_description_ar,events.seat_pricing, events.custom_seat_layout, | venue.location_lat AS lat,venue.location_lng AS lng,events.max_booking, | ||
venue.layout, venue.layout_details,venue.venue_name,venue.venue_details, | GROUP_CONCAT(DISTINCT event_gallery.media_url) AS media_url, | ||
venue.location,venue.location_lat AS lat,venue.location_lng AS lng, | |||
venue.venue_name AS address_name,venue.venue_name_ar AS address_name_ar, | |||
venue.location AS address, events.max_booking, | |||
GROUP_CONCAT(DISTINCT tags.tag_name) AS tag, | |||
GROUP_CONCAT(DISTINCT tags.tag_name_ar) AS tag_ar, | |||
GROUP_CONCAT(DISTINCT `event_gallery`.`media_url`) AS media_url, | |||
GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date, | GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date, | ||
event_date_time.time)) AS date_time | event_date_time.time)) AS date_time | ||
FROM events | 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 | INNER JOIN venue ON venue.id=events.venue_id | ||
INNER JOIN event_date_time ON events.event_id=event_date_time.event_id | |||
INNER JOIN host_categories ON venue.host_cat_id = host_categories.host_cat_id | |||
LEFT JOIN event_gallery ON events.event_id=event_gallery.event_id AND | LEFT JOIN event_gallery ON events.event_id=event_gallery.event_id AND | ||
event_gallery.status != 0 | 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 | ||
LEFT JOIN favourite ON favourite.event_id = events.event_id AND favourite.user_id=$user_id AND favourite.status = 1 | 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('Y-m-d')."' AND events.event_id=$event_id | WHERE event_date_time.date>='".date('Y-m-d')."' AND events.event_id=$event_id | ||
GROUP BY events.event_id, event_date_time.event_id")->row(); | GROUP BY events.event_id, event_date_time.event_id"; | ||
$rs = $this->db->query($sql)->row(); | |||
if(count($rs)>0){ | if(count($rs) > 0){ | ||
$event_layout = ''; | $event_layout = ''; | ||
$colorData = array(); | $colorData = array(); | ||
$resultData = array(); | $resultData = array(); | ||
$sql = "SELECT AVG(review.rate) AS rate FROM review WHERE event_id=$event_id"; | |||
$sql = "SELECT AVG(review.rate) AS rate | |||
FROM review WHERE event_id=$event_id"; | |||
$rating = $this->db->query($sql)->row_array(); | $rating = $this->db->query($sql)->row_array(); | ||
$rate = isset($rating['rate'])&&!empty($rating['rate'])? | $rate = isset($rating['rate'])&&!empty($rating['rate'])?round($rating['rate'],1):'0.0'; | ||
round($rating['rate'],1):'0.0'; | |||
$sql = "SELECT SUM(booking.no_of_ticket) AS attend FROM booking | $sql = "SELECT SUM(booking.no_of_ticket) AS attend FROM booking | ||
WHERE status IN (1,2) AND event_id=$event_id"; | WHERE status IN (1,2) AND event_id=$event_id"; | ||
$atten = $this->db->query($sql)->row_array(); | $atten = $this->db->query($sql)->row_array(); | ||
$atte = isset($atten['attend'])&&!empty($atten['attend'])? | $atte = isset($atten['attend'])&&!empty($atten['attend'])?$atten['attend']:'0'; | ||
$atten['attend']:'0'; | |||
if($rs->layout!=''){ | if(!empty($rs->layout)){ | ||
if($rs->custom_seat_layout!=''){ | if(!empty($rs->custom_seat_layout)){ | ||
$event_layout = $rs->custom_seat_layout; | $seatLayout = $rs->custom_seat_layout; | ||
if(!empty($seatLayout) && !empty($seatLayout = json_decode($seatLayout,true))){ | |||
foreach ($seatLayout AS $key => $seat) { | |||
$seatLayout[$key]['price'] = $seat['price']*$rate; | |||
} | |||
} | |||
$event_layout = json_encode($seatLayout); | |||
} else { | } else { | ||
$event_layout = $rs->layout_details; | $seatLayout = $rs->layout_details; | ||
if(!empty($seatLayout) && !empty($seatLayout = json_decode($seatLayout,true))){ | |||
foreach ($seatLayout AS $key => $seat) { | |||
$seatLayout[$key]['price'] = $seat['price']*$rate; | |||
} | |||
} | |||
$event_layout = json_encode($seatLayout); | |||
} | } | ||
} else { | } else { | ||
$event_layout = $rs->seat_pricing; | $seatLayout = $rs->seat_pricing; | ||
if(!empty($seatLayout) && !empty($seatLayout = json_decode($seatLayout,true))){ | |||
$seatLayout['price'] = $seatLayout['price']*$rate; | |||
} | |||
$event_layout = json_encode($seatLayout); | |||
} | } | ||
$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); | ||
$sTime = $date.' '.$time; | $sTime = $date.' '.$time; | ||
... | @@ -585,29 +580,34 @@ class Webservice_model extends CI_Model { | ... | @@ -585,29 +580,34 @@ class Webservice_model extends CI_Model { |
foreach ($data_array as $key => $value) { | foreach ($data_array as $key => $value) { | ||
$date_list[] = array('date'=>$key, 'time'=>$value); | $date_list[] = array('date'=>$key, 'time'=>$value); | ||
} | } | ||
$custDesc = ''; | |||
$lang = $this->getUserLang($user_id); | |||
if($rs->is_layout == 1 && !empty($pData = json_decode($rs->seat_pricing, TRUE))){ | if($rs->is_layout == 1 && !empty($pData = json_decode($rs->seat_pricing, TRUE))){ | ||
if($lang == 'en'){ | $cSymbol = $countryData['currency_symbol']; | ||
$rs->event_description .= '<p>'.$pData['price_details'].' '.'(SAR '.$pData['price'].')'.'</p>'; | if(isset($pData['price_details_'.$lang]) && !empty($pData['price_details_'.$lang])){ | ||
} | $custDesc = '<p>'.$pData['price_details_'.$lang].' ('.$cSymbol.' '.$pData['price']*$rate.')</p>'; | ||
if($lang == 'ar'){ | |||
$rs->event_description_ar .= '<p>'.$pData['price_details_ar'].' '.'(SAR '.$pData['price'].')'.'</p>'; | |||
} | |||
} | } | ||
} | |||
$event_layouts = []; | $event_layouts = []; | ||
if(isset($data['event_date_id']) && !empty($eDateId = $data['event_date_id'])){ | if(isset($data['event_date_id']) && !empty($eDateId = $data['event_date_id'])){ | ||
$param = array('user_id'=>$user_id,'event_id'=>$event_id,'time_id'=>$eDateId); | $param = array('user_id'=>$user_id,'event_id'=>$event_id,'time_id'=>$eDateId); | ||
$event_layouts = $this->checkSeatAvailability($param); | $event_layouts = $this->checkSeatAvailability($param); | ||
} | } | ||
$tags = ($lang == 'en')? explode(',', $rs->tag) : explode(',', $rs->tag_ar); | $transData = array('event'=>'','description'=>'','category'=>'','venue'=>''); | ||
if(!empty($lanTrans = langTranslator($rs->event_id,'EVT',$lang))){ | |||
$transData['event'] = $lanTrans['event_name']; | |||
$transData['description'] = $lanTrans['event_description'].$custDesc; | |||
} | |||
if(!empty($lanTrans = langTranslator($rs->venue_id,'VEN',$lang))){ | |||
$transData['venue'] = $lanTrans['venue_name']; | |||
} | |||
$media_url = explode(',', $rs->media_url); | $media_url = explode(',', $rs->media_url); | ||
$resData = array( | $resData = array( | ||
'event_id'=>$rs->event_id, | 'event_id'=>$rs->event_id, | ||
'name'=>($lang == 'en')?$rs->event_name:$rs->event_name_ar, | 'name'=>$transData['event'], | ||
'description'=>($lang == 'en')?$rs->event_description:$rs->event_description_ar, | 'description'=>$transData['description'], | ||
'rating'=>$rate, | 'rating'=>$rate, | ||
'total_attendees'=>$atte, | 'total_attendees'=>$atte, | ||
'layout_image'=>$rs->layout, | 'layout_image'=>$rs->layout, | ||
... | @@ -620,32 +620,24 @@ class Webservice_model extends CI_Model { | ... | @@ -620,32 +620,24 @@ class Webservice_model extends CI_Model { |
'date_list'=>$date_list, | 'date_list'=>$date_list, | ||
'classes'=>$event_layouts, | 'classes'=>$event_layouts, | ||
'latitude'=>$rs->lat, | 'latitude'=>$rs->lat, | ||
'address_name'=>($lang == 'en')?$rs->address_name:$rs->address_name_ar, | 'address_name'=>$transData['venue'], | ||
'address'=>$rs->address, | 'address'=>$rs->address, | ||
'longitude'=>$rs->lng | 'longitude'=>$rs->lng, | ||
'currency_symbol'=>$countryData['currency_symbol'] | |||
); | ); | ||
$res = array('status'=>1,'data'=>$resData); | $res = array('status'=>1,'data'=>$resData); | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | $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'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
} catch(Exception $e) { | } catch(Exception $e) { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | } | ||
return $res; | return $res; | ||
} | } | ||
function getUserLang($user_id){ | |||
$lang = $this->db->select('language')->where('customer_id',$user_id)->get('customer')->row(); | |||
return $lang->language; | |||
} | |||
function generateAuth($userId,$auth_token) { | function generateAuth($userId,$auth_token) { | ||
$this->db->insert('customer_auth',array('user_id'=>$userId, 'auth_token'=>$auth_token)); | $this->db->insert('customer_auth',array('user_id'=>$userId, 'auth_token'=>$auth_token)); | ||
} | } | ||
... | @@ -671,7 +663,6 @@ class Webservice_model extends CI_Model { | ... | @@ -671,7 +663,6 @@ class Webservice_model extends CI_Model { |
'crlf' => "\r\n", | 'crlf' => "\r\n", | ||
'newline' => "\r\n" | 'newline' => "\r\n" | ||
)); | )); | ||
$ci->email->from('[email protected]', 'TimeOut'); | $ci->email->from('[email protected]', 'TimeOut'); | ||
$ci->email->to($email); | $ci->email->to($email); | ||
$ci->email->cc('[email protected]'); | $ci->email->cc('[email protected]'); | ||
... | @@ -683,20 +674,17 @@ class Webservice_model extends CI_Model { | ... | @@ -683,20 +674,17 @@ class Webservice_model extends CI_Model { |
return $ci->email->send(); | return $ci->email->send(); | ||
} | } | ||
function sendSMS($phone_no, $message) { | function sendSMS($phone_no, $message) { | ||
$phone_no = trim($phone_no); | $phone_no = trim($phone_no); | ||
$phone_no = trim($phone_no,'+'); | $phone_no = trim($phone_no,'+'); | ||
if(empty($phone_no) && count($phone_no) < 10 && empty($message)){ | if(empty($phone_no) && count($phone_no) < 10 && empty($message)){ | ||
return; | return; | ||
} | } | ||
$user = "eventstimeout"; | $user = "eventstimeout"; | ||
$senderid = "SMSCountry"; | $senderid = "SMSCountry"; | ||
$password = "timeout2030"; | $password = "timeout2030"; | ||
$url = "http://www.smscountry.com/SMSCwebservice_Bulk.aspx"; | $url = "http://www.smscountry.com/SMSCwebservice_Bulk.aspx"; | ||
$message = urlencode($message); | $message = urlencode($message); | ||
if($ch = curl_init()){ | if($ch = curl_init()){ | ||
$ret = curl_setopt ($ch, CURLOPT_URL, $url); | $ret = curl_setopt ($ch, CURLOPT_URL, $url); | ||
curl_setopt ($ch, CURLOPT_POST, 1); | curl_setopt ($ch, CURLOPT_POST, 1); | ||
... | @@ -710,30 +698,22 @@ class Webservice_model extends CI_Model { | ... | @@ -710,30 +698,22 @@ class Webservice_model extends CI_Model { |
function get_category_list($data) { | function get_category_list($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) { | ||
if(isset($data['query'])) { | |||
$where = ' AND event_category.category LIKE '."'%".$data['query'].'%'."'"; | |||
} else { | |||
$where = ''; | $where = ''; | ||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
if(isset($data['query'])) { | |||
$where = ' AND TC.category_name LIKE '."'%".$data['query'].'%'."'"; | |||
} | } | ||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | $sql = "SELECT TC.category_id,TC.category_name,TC.category_image | ||
FROM translator_category AS TC | |||
if($lang->language == 'ar') { | INNER JOIN event_category AS ECAT ON (ECAT.cat_id=TC.category_id) | ||
$cat_field = 'event_category.category_ar AS category_name'; | WHERE ECAT.status = 1 AND TC.language_code='$lang' $where | ||
$cat_field .= ',event_category.category_image_ar AS category_image'; | GROUP BY ECAT.cat_id ORDER BY ECAT.priority"; | ||
} else { | $result = $this->db->query($sql)->result(); | ||
$cat_field = 'event_category.category_en AS category_name'; | if(count($result) > 0){ | ||
$cat_field .= ',event_category.category_image AS category_image'; | $res = array('status' => 1,'data' => array('category'=>$result)); | ||
} | |||
$result = $this->db->query("SELECT events.venue_id AS region_id,event_category.cat_id AS category_id, $cat_field,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 ORDER BY event_category.priority")->result(); | |||
if(count($result)>0){ | |||
$resultData = array(); | |||
$resultData['category'] = $result; | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | } else { | ||
$res = array('status'=>1,'data' => []); | $res = array('status'=>1,'data' => []); | ||
} | } | ||
... | @@ -746,37 +726,25 @@ class Webservice_model extends CI_Model { | ... | @@ -746,37 +726,25 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function add_favorites($data) { | function add_favorites($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) { | ||
$res_count = $this->db->where('event_id',$data['event_id'])->where('user_id',$user_id)->get('favourite')->num_rows(); | $res_count = $this->db->where('event_id',$data['event_id'])->where('user_id',$user_id)->get('favourite')->num_rows(); | ||
$favoriteList = array('user_id'=>$user_id, 'event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | $favoriteList = array('user_id'=>$user_id, 'event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | ||
if($res_count > 0) { | if($res_count > 0) { | ||
$data=array('event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | $data=array('event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | ||
$this->db->where('user_id',$user_id); | $this->db->where('user_id',$user_id); | ||
$this->db->where('event_id',$data['event_id']); | $this->db->where('event_id',$data['event_id']); | ||
$id = $this->db->update('favourite',$data); | $id = $this->db->update('favourite',$data); | ||
}else{ | }else{ | ||
$id = $this->db->insert('favourite',$favoriteList); | $id = $this->db->insert('favourite',$favoriteList); | ||
} | } | ||
if($id) { | if($id) { | ||
$res = array('status'=>1); | $res = array('status'=>1); | ||
}else { | }else { | ||
$res = array('status'=>0,'message'=>'Add Favorite failed please try again','code'=>'ER14'); | $res = array('status'=>0,'message'=>'Add Favorite failed please try again','code'=>'ER14'); | ||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
... | @@ -786,24 +754,16 @@ class Webservice_model extends CI_Model { | ... | @@ -786,24 +754,16 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function get_cities_list($data) { | function get_cities_list($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) { | ||
// language | $countryData = $this->getCountryData($user_id); | ||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | $lang = $countryData['language_code']; | ||
if($lang->language == 'ar') { | |||
$region_name = 'region.name_ar'; | $result = $this->db->query("SELECT REG.id AS city_id, REG.region_icon AS city_image,TREG.region_name AS city_name FROM region AS REG INNER JOIN translator_region AS TREG ON (TREG.region_id = REG.id) WHERE REG.status = 1 AND TREG.language_code='$lang' GROUP BY city_name")->result(); | ||
} 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){ | if(count($result)>0){ | ||
$resultData = array(); | $res = array('status'=>1,'data'=>array('cities'=>$result)); | ||
$resultData['cities'] = $result; | |||
$res = array('status'=>1,'data'=>$resultData); | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
... | @@ -816,32 +776,38 @@ class Webservice_model extends CI_Model { | ... | @@ -816,32 +776,38 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function update_city($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']); | ||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
if($user_id > 0) { | if($user_id > 0) { | ||
if(isset($data['city_id']) && !empty($data['city_id'])){ | 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(); | $re = $this->db->query("SELECT TREG.region_name FROM region AS REG | ||
$cityName = $re->name; | INNER JOIN translator_region AS TREG ON (TREG.region_id = REG.id) | ||
WHERE REG.status='1' AND TREG.language_code='$lang' AND | |||
REG.id='".$data['city_id']."' | |||
GROUP BY REG.id")->row(); | |||
$cityName = $re->region_name; | |||
$cityId = $data['city_id']; | $cityId = $data['city_id']; | ||
}else{ | }else{ | ||
$radius = 25; | $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(); | $data = $this->db->query(" | ||
SELECT REG.id,TREG.region_name,REG.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 AS REG | |||
INNER JOIN translator_region AS TREG ON (TREG.region_id = REG.id) | |||
WHERE REG.status = '1' AND TREG.language_code='$lang' | |||
HAVING distance < ".$radius." | |||
ORDER BY distance ASC LIMIT 1")->row_array(); | |||
if(!empty($data)){ | if(!empty($data)){ | ||
$cityId = $data[0]['id']; | $cityId = $data['id']; | ||
$cityName = $data[0]['name']; | $cityName = $data['region_name']; | ||
} | } | ||
} | } | ||
if(!empty($cityId)){ | if(!empty($cityId)){ | ||
$this->db->where('customer_id', $user_id); | $this->db->where('customer_id', $user_id); | ||
$this->db->update('customer', array('city' => $cityId)); | $this->db->update('customer', array('city' => $cityId)); | ||
$res = array('status'=>1, 'data'=>array('city_id'=>$cityId,'city_name'=>$cityName)); | |||
$resultArray = array('city_id'=>$cityId,'city_name'=>$cityName); | |||
$res = array('status'=>1, 'data'=>$resultArray); | |||
}else { | }else { | ||
$res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | $res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | ||
} | } | ||
... | @@ -854,32 +820,53 @@ class Webservice_model extends CI_Model { | ... | @@ -854,32 +820,53 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function booking_summary($data) { | function booking_summary($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) { | ||
$bookingId = $data['booking_id']; | $bookId = $data['booking_id']; | ||
$ticketDetails = $this->db->query("SELECT ticket_details FROM booking WHERE bookId = '$bookingId'")->row(); | |||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$sql = "SELECT ticket_details FROM booking WHERE bookId='$bookId'"; | |||
$ticketDetails = $this->db->query($sql)->row(); | |||
$res = json_decode($ticketDetails->ticket_details); | $res = json_decode($ticketDetails->ticket_details); | ||
if(!empty($res)){ | if(!empty($res)){ | ||
$kk['ticket_rate'] = "$res->price"; | $kk['ticket_rate'] = "$res->price"; | ||
} | } | ||
$settingsDetails = $this->db->query("SELECT instruction_en AS instruction,contact_number FROM privacy_policy")->row_array(); | |||
$lang = $this->getUserLang($user_id); | |||
if($lang == 'en'){ | $settings = getSettings(); | ||
$cat_filed = 'events.event_name AS event_name'; | $sql = "SELECT instruction FROM translator_policies WHERE language_code='$lang'"; | ||
$cat_filed .= ',venue.venue_name AS address_name'; | $settingsDetails = $this->db->query($sql)->row_array(); | ||
}else{ | $settingsDetails['contact_number'] = $settings['contact_number']; | ||
$cat_filed = 'events.event_name_ar AS event_name'; | |||
$cat_filed .= ',venue.venue_name_ar AS address_name'; | $sql = "SELECT booking.qrcode,events.event_id,events.venue_id, | ||
events.has_payment AS is_payment_required,event_date_time.date, | |||
event_gallery.media_url AS event_image,booking.bookId AS ticket_id, | |||
event_date_time.time,venue.location_lat AS latitude,venue.location_lng AS longitude, | |||
venue.location AS address,booking.amount AS total_rate,customer.name AS profile_name, | |||
booking.no_of_ticket AS ticket_count,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 = '$bookId' AND booking.customer_id = ".$user_id; | |||
$result = $this->db->query($sql)->row_array(); | |||
if(count($result) > 0 && count($settingsDetails) > 0){ | |||
if(!empty($lanTrans = langTranslator($result['event_id'],'EVT',$lang))){ | |||
$result['event_name'] = $lanTrans['event_name']; | |||
} | |||
if(!empty($lanTrans = langTranslator($result['venue_id'],'VEN',$lang))){ | |||
$result['address_name'] = $lanTrans['venue_name']; | |||
} | } | ||
$result = $this->db->query("SELECT booking.qrcode,events.event_id,events.has_payment AS is_payment_required,$cat_filed, `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.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(); | ||
$result['is_payment_required'] = ($result['is_payment_required'] == 1) ? true: false; | |||
$resultData = array_merge($settingsDetails, $result,!empty($kk)?$kk:[]); | $resultData = array_merge($settingsDetails, $result,!empty($kk)?$kk:[]); | ||
$res = array('status'=>1,'data'=>$resultData); | $res = array('status'=>1,'data'=>$resultData); | ||
} else { | } else { | ||
... | @@ -894,7 +881,6 @@ class Webservice_model extends CI_Model { | ... | @@ -894,7 +881,6 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function payment($data) { | function payment($data) { | ||
try{ | try{ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
... | @@ -917,7 +903,6 @@ class Webservice_model extends CI_Model { | ... | @@ -917,7 +903,6 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function event_rating($data) { | function event_rating($data) { | ||
try{ | try{ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
... | @@ -943,13 +928,10 @@ class Webservice_model extends CI_Model { | ... | @@ -943,13 +928,10 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function update_notification_email_status($data) { | function update_notification_email_status($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) { | ||
$notData = array('notification_status'=>$data['notification_status'], 'email_status'=>$data['email_status']); | $notData = array('notification_status'=>$data['notification_status'], 'email_status'=>$data['email_status']); | ||
$this->db->where('id', $user_id); | $this->db->where('id', $user_id); | ||
$this->db->where('status', 1); | $this->db->where('status', 1); | ||
... | @@ -969,9 +951,7 @@ class Webservice_model extends CI_Model { | ... | @@ -969,9 +951,7 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
public function update_profile($data) { | public function update_profile($data) { | ||
try{ | try{ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
$img_error = 0; | $img_error = 0; | ||
... | @@ -979,7 +959,6 @@ class Webservice_model extends CI_Model { | ... | @@ -979,7 +959,6 @@ class Webservice_model extends CI_Model { |
$post_data = $data; | $post_data = $data; | ||
unset($post_data['file']); | unset($post_data['file']); | ||
unset($post_data['auth_token']); | unset($post_data['auth_token']); | ||
if(isset($data['email'])){ | if(isset($data['email'])){ | ||
$this->db->select('customer.email'); | $this->db->select('customer.email'); | ||
$this->db->where('customer.email',$data['email']); | $this->db->where('customer.email',$data['email']); | ||
... | @@ -991,7 +970,6 @@ class Webservice_model extends CI_Model { | ... | @@ -991,7 +970,6 @@ class Webservice_model extends CI_Model { |
if($num > 0) | if($num > 0) | ||
{ | { | ||
$res = array('status'=>0,'message'=>'Email address already exist','code'=>'ER32'); | $res = array('status'=>0,'message'=>'Email address already exist','code'=>'ER32'); | ||
return $res; | return $res; | ||
} | } | ||
} | } | ||
... | @@ -1023,7 +1001,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1023,7 +1001,6 @@ class Webservice_model extends CI_Model { |
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | $res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | ||
} | } | ||
} | } | ||
if($img_error == 1) { | 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->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->where('users.id',$user_id); | ||
... | @@ -1036,7 +1013,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1036,7 +1013,6 @@ class Webservice_model extends CI_Model { |
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
... | @@ -1047,7 +1023,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1047,7 +1023,6 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function booking($data) { | function booking($data) { | ||
try{ | try{ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
... | @@ -1055,38 +1030,82 @@ class Webservice_model extends CI_Model { | ... | @@ -1055,38 +1030,82 @@ class Webservice_model extends CI_Model { |
$post_data = $data; | $post_data = $data; | ||
$post_data['customer_id'] = $user_id; | $post_data['customer_id'] = $user_id; | ||
$post_data['ticket_details'] = json_encode($post_data['ticket_details']); | $post_data['ticket_details'] = json_encode($post_data['ticket_details']); | ||
$post_data['status'] = (isset($post_data['has_payment']) && $post_data['has_payment'] == 0)?'1':'3'; | $post_data['status'] = '3'; | ||
unset($post_data['auth_token'],$post_data['has_payment']); | |||
if(isset($post_data['has_payment']) && $post_data['has_payment'] == 0){ | |||
$post_data['status'] = '1'; | |||
} | |||
if(isset($post_data['promo_code']) && !empty($post_data['promo_code']) && | |||
isset($post_data['discounted_price']) && !empty($post_data['discounted_price'])){ | |||
$promoData = $this->db->get_where('promocode_management',array('status'=>'1', | |||
'promocode_name'=>$post_data['promo_code']))->row_array(); | |||
$promo_id = $promoData['promocode_id']; | |||
$redeem_amount = $post_data['amount']-$post_data['discounted_price']; | |||
$post_data['amount'] = $redeem_amount; | |||
$this->db->insert('promocode_used', | |||
array('user_id'=>$user_id,'event_id'=>$post_data['event_id'], | |||
'promocode_id'=>$promo_id,'redeem_amount'=>$redeem_amount, | |||
'created_date'=>date('Y-m-d H:i:s'))); | |||
} | |||
$invite_ids = (isset($post_data['friends_ids']))?$post_data['friends_ids']:''; | |||
$invite_phone = (isset($post_data['invite_list']))?$post_data['invite_list']:''; | |||
unset($post_data['auth_token'],$post_data['has_payment'],$post_data['friends_ids'], | |||
$post_data['promo_code'],$post_data['discounted_price'],$post_data['invite_list']); | |||
$code = 'TO'; | $code = 'TO'; | ||
$ymd = date('ymd'); | $ymd = date('ymd'); | ||
$squence = rand(1111,9999); | $squence = rand(1111,9999); | ||
$squence = str_pad($squence,4,0,STR_PAD_LEFT); | $squence = str_pad($squence,4,0,STR_PAD_LEFT); | ||
$post_data['bookId'] = $code.$ymd.$squence; | $book_id = $code.$ymd.$squence; | ||
$post_data['bookId'] = $book_id; | |||
$post_data['qrcode'] = genQRcode($post_data['bookId']); | $post_data['qrcode'] = genQRcode($post_data['bookId']); | ||
$post_data['booking_date'] = date('Y-m-d H:i:s'); | $post_data['booking_date'] = date('Y-m-d H:i:s'); | ||
$rs = $this->db->insert('booking', $post_data); | $rs = $this->db->insert('booking', $post_data); | ||
$id = $this->db->insert_id(); | $id = $this->db->insert_id(); | ||
if($id){ | if($id){ | ||
$res = array('status'=>1,'data'=>array('bookingCode'=>$post_data['bookId'])); | $res = array('status'=>1,'data'=>array('bookingCode'=>$post_data['bookId'])); | ||
$insertArr = array(); | |||
$inStatus = ($post_data['status'] == 1)?'1':'0'; | |||
if(!empty($invite_ids)){ | |||
foreach($invite_ids AS $userId) { | |||
$insertArr[] = array('book_id'=>$book_id,'phone'=>'', | |||
'user_id'=>$userId,'status'=>$inStatus); | |||
} | |||
} | |||
if(!empty($invite_phone)){ | |||
foreach($invite_phone AS $key => $phone) { | |||
$phone = preg_replace('/\D/','',$phone); | |||
$insertArr[] = array('book_id'=>$book_id,'user_id'=>'', | |||
'phone'=>$phone,'status'=>$inStatus); | |||
} | |||
} | |||
if(!empty($insertArr)){ | |||
$this->db->insert_batch('event_invites',$insertArr); | |||
} | |||
if($post_data['status'] == 1){ | if($post_data['status'] == 1){ | ||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$bkData = $this->db->query(" | $bkData = $this->db->query(" | ||
SELECT EVT.event_name,CUST.name,CUST.email,CUST.phone, | SELECT TEVT.event_name,CUST.name,CUST.email,CUST.phone, | ||
CONCAT(EDATE.date,' ',EDATE.time) AS show_time | CONCAT(EDATE.date,' ',EDATE.time) AS show_time | ||
FROM booking AS BK | FROM booking AS BK | ||
INNER JOIN events AS EVT ON (EVT.event_id=BK.event_id) | INNER JOIN events AS EVT ON (EVT.event_id=BK.event_id) | ||
INNER JOIN translator_event AS TEVT ON (TEVT.event_id=EVT.event_id) | |||
INNER JOIN customer AS CUST ON (CUST.customer_id=BK.customer_id) | INNER JOIN customer AS CUST ON (CUST.customer_id=BK.customer_id) | ||
INNER JOIN event_date_time AS EDATE ON (EDATE.id=BK.event_date_id) | INNER JOIN event_date_time AS EDATE ON (EDATE.id=BK.event_date_id) | ||
WHERE BK.bookId='".$post_data['bookId']."' AND EVT.status='1' AND | WHERE BK.bookId='".$post_data['bookId']."' AND EVT.status='1' AND | ||
BK.status='1' AND EDATE.status='1'")->row_array(); | BK.status='1' AND EDATE.status='1' AND TEVT.language_code='$lang'")->row_array(); | ||
$subject = "Your Tickets - TimeOut"; | $subject = "Your Tickets - TimeOut"; | ||
$showTime = date("d'S F Y - h:i, (l)",strtotime($bkData['show_time'])); | $showTime = date("d'S F Y - h:i, (l)",strtotime($bkData['show_time'])); | ||
$msgContent = "Hi, Your booking is confirmed for the event '". | $msgContent = "Hi, Your booking is confirmed for the event '". | ||
$bkData['event_name']."' and show is on '".$showTime."'. | $bkData['event_name']."' and show is on '".$showTime."'. | ||
Booking ID ".$post_data['bookId']; | Booking ID ".$post_data['bookId']; | ||
$message = "<html><body><p>".$msgContent."</p></body></html>"; | $message = "<html><body><p>".$msgContent."</p></body></html>"; | ||
$template = getNotifTemplate(); | $template = getNotifTemplate(); | ||
if(isset($template['booking_mail']) && !empty($template['booking_mail'])){ | if(isset($template['booking_mail']) && !empty($template['booking_mail'])){ | ||
$msgContent = str_replace( | $msgContent = str_replace( | ||
... | @@ -1095,7 +1114,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1095,7 +1114,6 @@ class Webservice_model extends CI_Model { |
$template['booking_mail']); | $template['booking_mail']); | ||
} | } | ||
$this->send_mail($subject,$bkData['email'],$message); | $this->send_mail($subject,$bkData['email'],$message); | ||
if(isset($template['booking_sms']) && !empty($template['booking_sms'])){ | if(isset($template['booking_sms']) && !empty($template['booking_sms'])){ | ||
$msgContent = str_replace( | $msgContent = str_replace( | ||
array('{:event_name}','{:booking_id}','{:time}'), | array('{:event_name}','{:booking_id}','{:time}'), | ||
... | @@ -1103,6 +1121,20 @@ class Webservice_model extends CI_Model { | ... | @@ -1103,6 +1121,20 @@ class Webservice_model extends CI_Model { |
$template['booking_sms']); | $template['booking_sms']); | ||
} | } | ||
$this->sendSMS($bkData['phone'],$msgContent); | $this->sendSMS($bkData['phone'],$msgContent); | ||
$msg = "Hi, You are invited for the event '".$bkData['event_name']."', and show is on '".$showTime."'. Booking ID ".$post_data['bookId']; | |||
if(!empty($invite_ids)){ | |||
foreach($invite_ids AS $userId) { | |||
$usrData = $this->db->get_where('customer', | |||
array('customer_id'=>$userId))->row_array(); | |||
$this->sendSMS($usrData['phone'],$msg); | |||
} | |||
} | |||
if(!empty($invite_phone)){ | |||
foreach($invite_phone AS $key => $phone) { | |||
$this->sendSMS($phone,$msg); | |||
} | |||
} | |||
} | } | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37'); | $res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37'); | ||
... | @@ -1116,8 +1148,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1116,8 +1148,6 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function generateQR($data) { | function generateQR($data) { | ||
return 'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'; | return 'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'; | ||
} | } | ||
... | @@ -1140,30 +1170,29 @@ class Webservice_model extends CI_Model { | ... | @@ -1140,30 +1170,29 @@ class Webservice_model extends CI_Model { |
} else { | } else { | ||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
} | } | ||
} catch(Exception $e) { | } catch(Exception $e) { | ||
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
} | } | ||
return $res; | return $res; | ||
} | } | ||
function favouritelist($data) { | function favouritelist($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) { | ||
$lang = $this->getUserLang($user_id); | $countryData = $this->getCountryData($user_id); | ||
$lang = $countryData['language_code']; | |||
if($lang == 'ar') { | $rate = (!empty($countryData['conversion_rate']))?$countryData['conversion_rate']:1; | ||
$cat_field = 'event_category.category_ar AS category'; | |||
$cat_field .= ',events.event_name_ar AS event_name'; | |||
} else { | |||
$cat_field = 'event_category.category_en AS category'; | |||
$cat_field .= ',events.event_name AS event_name'; | |||
} | |||
$result = $this->db->query(" | $result = $this->db->query(" | ||
SELECT events.event_id, event_gallery.media_url, (SELECT COUNT(booking.id) FROM booking WHERE booking.event_id = events.event_id) AS attendees, event_category.category AS category, events.event_name AS 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, GROUP_CONCAT(DISTINCT CONCAT_WS('#', event_date_time.id, event_date_time.date, event_date_time.time)) AS date_time | SELECT (SELECT COUNT(booking.id) FROM booking WHERE booking.event_id=events.event_id) AS | ||
attendees, events.event_id, event_gallery.media_url,event_category.cat_id, | |||
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, | |||
GROUP_CONCAT(DISTINCT CONCAT_WS('#', event_date_time.id, event_date_time.date, | |||
event_date_time.time)) AS date_time | |||
FROM favourite | FROM favourite | ||
INNER JOIN events ON events.event_id=favourite.event_id | INNER JOIN events ON events.event_id=favourite.event_id | ||
INNER JOIN venue ON venue.id=events.venue_id | INNER JOIN venue ON venue.id=events.venue_id | ||
... | @@ -1177,61 +1206,60 @@ class Webservice_model extends CI_Model { | ... | @@ -1177,61 +1206,60 @@ class Webservice_model extends CI_Model { |
favourite.user_id='$user_id' AND events.status=1 AND | favourite.user_id='$user_id' AND events.status=1 AND | ||
event_date_time.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') | event_date_time.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') | ||
GROUP BY events.event_id")->result(); | GROUP BY events.event_id")->result(); | ||
if(empty($result)){ | if(empty($result)){ | ||
return array('status'=>1,'data' => []); | return array('status'=>1,'data' => []); | ||
} | } | ||
foreach ($result AS $key => $rs) { | foreach ($result AS $key => $rs) { | ||
if(!empty($dates = explode(',',$rs->date_time))){ | if(!empty($dates = explode(',',$rs->date_time))){ | ||
$checkTime = 0; | $checkTime = 0; | ||
foreach ($dates as $date) { | foreach ($dates as $date) { | ||
if(empty($date)){ | if(empty($date)){ unset($result[$key]); continue; } | ||
unset($result[$key]); | |||
continue; | |||
} | |||
$dArr = explode('#', $date); | $dArr = explode('#', $date); | ||
if($dArr[1] == date("Y-m-d") && | if($dArr[1] == date("Y-m-d") && | ||
$dArr[1].' '.$dArr[2] < date("Y-m-d H:i", strtotime('+15 minutes'))){ | $dArr[1].' '.$dArr[2] < date("Y-m-d H:i", strtotime('+15 minutes'))){ | ||
$checkTime += 1; | $checkTime += 1; | ||
} | } | ||
} | } | ||
if($checkTime == count($dates)){ | if($checkTime == count($dates)){ unset($result[$key]); } | ||
unset($result[$key]); | } else { unset($result[$key]); } | ||
} | } | ||
} else { | |||
unset($result[$key]); | |||
} | |||
} | |||
if(($count = count($result)) > 0){ | if(($count = count($result)) > 0){ | ||
$response = array(); | $response = array(); | ||
foreach ($result as $rs) { | foreach ($result as $rs) { | ||
if($rs->layout!=''){ | |||
if($rs->custom_seat_layout!=''){ | $transData = array('event'=>'','category'=>'','venue'=>''); | ||
if(!empty($lanTrans = langTranslator($rs->event_id,'EVT',$lang))){ | |||
$transData['event'] = $lanTrans['event_name']; | |||
} | |||
if(!empty($lanTrans = langTranslator($rs->cat_id,'CAT',$lang))){ | |||
$transData['category'] = $lanTrans['category_name']; | |||
} | |||
if($rs->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')) * $rate; | ||
} else { | } else { | ||
$pricelist = json_decode($rs->layout_details, TRUE); | $pricelist = json_decode($rs->layout_details, TRUE); | ||
$price = min(array_column($pricelist, 'price')); | $price = min(array_column($pricelist, 'price')) * $rate; | ||
} | } | ||
} else { | } else { | ||
$pricelist = json_decode($rs->seat_pricing, TRUE); | $pricelist = json_decode($rs->seat_pricing, TRUE); | ||
$price = $pricelist['price']; | $price = $pricelist['price'] * $rate; | ||
} | } | ||
$lang = $this->getUserLang($user_id); | $lang = $this->getCountryData($user_id); | ||
$resData = array( | $resData = array( | ||
'event_id'=>$rs->event_id, | 'event_id'=>$rs->event_id, | ||
'image'=>$rs->media_url, | 'image'=>$rs->media_url, | ||
'attendees'=>$rs->attendees, | 'attendees'=>$rs->attendees, | ||
'category'=>$rs->category, | 'category'=>$transData['category'], | ||
'name'=>$rs->event_name, | 'name'=>$transData['event'], | ||
'rating'=>$rs->rating, | 'rating'=>$rs->rating, | ||
'location'=>$rs->location, | |||
'rate'=>$price, | 'rate'=>$price, | ||
'location'=>$rs->location, | 'location'=>$rs->location, | ||
'is_favorite'=>$rs->is_favorite === 'true'? true: false, | 'is_favorite'=>$rs->is_favorite === 'true'? true: false, | ||
'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false | 'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false, | ||
'currency_symbol'=>$countryData['currency_symbol'] | |||
); | ); | ||
array_push($response, $resData); | array_push($response, $resData); | ||
} | } | ||
... | @@ -1254,7 +1282,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1254,7 +1282,6 @@ class Webservice_model extends CI_Model { |
$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']; | ||
... | @@ -1263,14 +1290,13 @@ class Webservice_model extends CI_Model { | ... | @@ -1263,14 +1290,13 @@ class Webservice_model extends CI_Model { |
} | } | ||
$page_limit = ($page - 1) * $per_page; | $page_limit = ($page - 1) * $per_page; | ||
if($count > $page_limit) { | if($count > $page_limit) { | ||
$lang = $this->getUserLang($user_id); | $lang = $this->getCountryData($user_id); | ||
if($lang == 'en'){ | if($lang == 'en'){ | ||
$cat_field = 'events.event_name AS event_name'; | $cat_field = 'events.event_name AS event_name'; | ||
}else{ | }else{ | ||
$cat_field = 'events.event_name_ar AS event_name'; | $cat_field = 'events.event_name_ar AS event_name'; | ||
} | } | ||
$result = $this->db->select("booking.bookId AS booking_id,booking.event_id,$cat_field,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,$cat_field,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(); | ||
... | @@ -1303,10 +1329,11 @@ class Webservice_model extends CI_Model { | ... | @@ -1303,10 +1329,11 @@ class Webservice_model extends CI_Model { |
$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->query(" | $count = $this->db->query(" | ||
SELECT id FROM booking AS BOK | SELECT BOK.id FROM booking AS BOK | ||
INNER JOIN events AS EVT ON (EVT.event_id=BOK.event_id) | INNER JOIN events AS EVT ON (EVT.event_id=BOK.event_id) | ||
WHERE BOK.customer_id='$user_id' AND BOK.status IN (0,1,2) AND | INNER JOIN event_date_time AS EDT ON (EVT.event_id=EVT.event_id) | ||
EVT.status='1'")->num_rows(); | WHERE BOK.customer_id='$user_id' AND BOK.status IN (0,1,2) AND EVT.status='1' | ||
GROUP BY BOK.id")->num_rows(); | |||
if($count > 0) { | if($count > 0) { | ||
if(isset($data['page'])) { | if(isset($data['page'])) { | ||
... | @@ -1316,29 +1343,33 @@ class Webservice_model extends CI_Model { | ... | @@ -1316,29 +1343,33 @@ class Webservice_model extends CI_Model { |
} | } | ||
$page_limit = ($page - 1) * $per_page; | $page_limit = ($page - 1) * $per_page; | ||
if($count > $page_limit) { | if($count > $page_limit) { | ||
$lang = $this->getUserLang($user_id); | $countryData = $this->getCountryData($user_id); | ||
if($lang == 'en'){ | $lang = $countryData['language_code']; | ||
$event_name = 'events.event_name AS event_name'; | |||
}else{ | $sql = "SELECT booking.bookId AS booking_id,event_date_time.date, | ||
$event_name = 'events.event_name_ar AS event_name'; | translator_event.event_name,event_gallery.media_url AS event_image, | ||
} | venue.location,event_date_time.time,booking.event_id, | ||
$result = $this->db->select("booking.bookId AS booking_id,booking.event_id,$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, | booking.no_of_ticket AS ticket_count,events.has_payment, | ||
(CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 ELSE 2 END) AS booking_status, events.has_payment")->where('booking.customer_id',$user_id)->where_in('booking.status',array(0,1,2))->from('booking')->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')->group_by('booking.id')->order_by('booking.id','DESC')->limit($per_page,$page_limit)->get()->result_array(); | (CASE booking.status WHEN 1 THEN 0 WHEN 2 THEN 1 WHEN 0 THEN 2 | ||
ELSE 2 END) AS booking_status | |||
// $data_arr = array(); | FROM booking | ||
INNER JOIN events ON booking.event_id = events.event_id | |||
// foreach ($result as $value) { | INNER JOIN event_date_time ON booking.event_date_id = event_date_time.id | ||
// $data_arr[] = $value; | INNER JOIN venue ON venue.id = events.venue_id | ||
// $bookList = array_slice($data_arr, $page_limit, $per_page, false); | INNER JOIN translator_event ON translator_event.event_id = events.event_id | ||
// } | LEFT JOIN event_gallery ON events.event_id = event_gallery.event_id AND event_gallery.media_type = 0 | ||
WHERE booking.customer_id = '$user_id' AND booking.status IN(0, 1, 2) AND | |||
translator_event.language_code = '$lang' | |||
GROUP BY booking.id | |||
ORDER BY booking.id DESC | |||
LIMIT $page_limit, $per_page"; | |||
$result = $this->db->query($sql)->result_array(); | |||
$meta = array('total_pages'=>ceil($count/$per_page), | $meta = array('total_pages'=>ceil($count/$per_page), | ||
'total'=>$count, | 'total'=>$count, | ||
'current_page'=>$page, | 'current_page'=>$page, | ||
'per_page'=>$per_page | 'per_page'=>$per_page | ||
); | ); | ||
$response = array('bookings'=>$result,'meta'=>$meta); | $response = array('bookings'=>$result,'meta'=>$meta); | ||
$res = array('status'=>1,'data'=>$response); | $res = array('status'=>1,'data'=>$response); | ||
} else { | } else { | ||
$res = array('status'=>1,'data' => []); | $res = array('status'=>1,'data' => []); | ||
... | @@ -1359,23 +1390,20 @@ class Webservice_model extends CI_Model { | ... | @@ -1359,23 +1390,20 @@ class Webservice_model extends CI_Model { |
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) { | ||
$settings = getSettings(); | |||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$lang = $this->getUserLang($user_id); | $sql = "SELECT privacy_policy,terms_and_conditions | ||
$fields = 'privacy_policy_en AS privacy_policy, | FROM translator_policies WHERE language_code='$lang'"; | ||
terms_and_conditions_en AS terms_and_conditions,'; | $setDetails = $this->db->query($sql)->row_array(); | ||
if($lang == 'ar'){ | $setDetails['contact_number'] = $settings['contact_number']; | ||
$fields = 'privacy_policy_ar AS privacy_policy, | |||
terms_and_conditions_ar AS terms_and_conditions,'; | |||
} | |||
$settingsDetails = $this->db->query("SELECT $fields contact_number FROM privacy_policy") | $sql = "SELECT notification_status, email_status FROM users WHERE id=".$user_id; | ||
->row_array(); | $notifDetails = $this->db->query($sql)->row_array(); | ||
$notificationDetails = $this->db->query("SELECT notification_status, email_status | if(count($setDetails) > 0 && count($notifDetails) > 0){ | ||
FROM users WHERE id = ".$user_id."") | $resultData = array_merge($setDetails, $notifDetails); | ||
->row_array(); | |||
if(count($settingsDetails)>0 && count($notificationDetails)>0){ | |||
$resultData = array_merge($settingsDetails, $notificationDetails); | |||
$resultArray = array( | $resultArray = array( | ||
'privacy_policy'=>$resultData['privacy_policy'], | 'privacy_policy'=>$resultData['privacy_policy'], | ||
'terms_and_conditions'=>$resultData['terms_and_conditions'], | 'terms_and_conditions'=>$resultData['terms_and_conditions'], | ||
... | @@ -1415,19 +1443,32 @@ class Webservice_model extends CI_Model { | ... | @@ -1415,19 +1443,32 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
function get_last_booking($data) { | function get_last_booking($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) { | ||
$cat_feild = ''; | $cat_feild = ''; | ||
$lang = $this->getUserLang($user_id); | $countryData = $this->getCountryData($user_id); | ||
if($lang == 'en'){ | $lang = $countryData['language_code']; | ||
$cat_field = 'events.event_name AS event_name'; | |||
}else{ | $sql = "SELECT IF(review.event_id = '','false','true') AS is_last_booking_rated, | ||
$cat_field = 'events.event_name_ar AS event_name'; | booking.id AS booking_id, events.event_id AS event_id, | ||
} | event_gallery.media_url AS event_image,UNIX_TIMESTAMP(event_date_time.date) AS date, | ||
$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,$cat_field, `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." AND booking.status='2' ORDER BY booking.id DESC LIMIT 1")->row_array(); | booking.amount AS amount,translator_event.event_name | ||
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 | |||
INNER JOIN translator_event ON translator_event.event_id = events.event_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' AND booking.status='2' AND | |||
translator_event.language_code='$lang' | |||
ORDER BY booking.id DESC LIMIT 1"; | |||
$result = $this->db->query($sql)->row_array(); | |||
if(count($result)>0){ | if(count($result)>0){ | ||
$resultData = array( | $resultData = array( | ||
'is_last_booking_rated'=>$result['is_last_booking_rated'] === 'true'? true: false, | 'is_last_booking_rated'=>$result['is_last_booking_rated'] === 'true'? true: false, | ||
... | @@ -1438,7 +1479,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1438,7 +1479,6 @@ class Webservice_model extends CI_Model { |
'amount'=>$result['amount'], | 'amount'=>$result['amount'], | ||
'date'=>$result['date'] | 'date'=>$result['date'] | ||
); | ); | ||
$res = array('status'=>1,'data'=>$resultData); | $res = array('status'=>1,'data'=>$resultData); | ||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
... | @@ -1456,52 +1496,31 @@ class Webservice_model extends CI_Model { | ... | @@ -1456,52 +1496,31 @@ class Webservice_model extends CI_Model { |
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) { | ||
$lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | $countryData = $this->getCountryData($user_id); | ||
if($lang->language == 'ar') { | $lang = $countryData['language_code']; | ||
$loc_field = 'locality.locality_ar AS city_name'; | |||
$sql = "SELECT LOC.id AS city_id,TLOC.locality_name AS city_name | |||
$cat_field = 'event_category.category_ar AS category'; | FROM locality AS LOC | ||
$cat_field .= ',event_category.category_image_ar AS category_image'; | INNER JOIN customer AS CUST ON (CUST.city=LOC.region_id) | ||
INNER JOIN translator_locality AS TLOC ON (TLOC.locality_id=LOC.id) | |||
$dateArray = [["date_id"=>'كل الأيام',"date"=>"1"],["date_id"=>'اليوم',"date"=>"2"],["date_id"=>'غدا',"date"=>"3"],["date_id"=>'هذا الاسبوع',"date"=>"4"],["date_id"=>'عطلة نهاية الاسبوع',"date"=>"5"],["date_id"=>'في وقت لاحق',"date"=>"6"]]; | WHERE CUST.customer_id='$user_id' AND LOC.status='1' AND TLOC.language_code='$lang' | ||
} else { | GROUP BY LOC.id"; | ||
$loc_field = 'locality.locality_en AS city_name'; | |||
$cat_field = 'event_category.category_en AS category'; | |||
$cat_field .= ',event_category.category_image AS category_image'; | |||
$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"]]; | |||
} | |||
$sql = "SELECT locality.id AS city_id, $loc_field FROM locality | |||
INNER JOIN customer ON customer.city=locality.region_id | |||
WHERE customer.customer_id='$user_id' AND locality.status='1'"; | |||
$locality = $this->db->query($sql)->result(); | $locality = $this->db->query($sql)->result(); | ||
$category = $this->db->query("SELECT cat_id AS category_id, $cat_field | $sql = "SELECT ECAT.cat_id AS category_id,TCAT.category_name AS category, | ||
FROM event_category | TCAT.category_image AS category_image | ||
WHERE status = 1 | FROM event_category AS ECAT | ||
ORDER BY event_category.priority")->result(); | INNER JOIN translator_category AS TCAT ON (TCAT.category_id=ECAT.cat_id) | ||
WHERE ECAT.status = 1 | |||
GROUP BY ECAT.cat_id | |||
ORDER BY ECAT.priority"; | |||
$category = $this->db->query($sql)->result(); | |||
$locality = (!empty($locality))?$locality:array(); | |||
$category = (!empty($category))?$category:array(); | |||
if(!EMPTY($locality)) { | if(!empty($locality) && !empty($category)){ | ||
$locality = $locality; | $res = array('status'=>1,'data'=>array('cities'=>$locality,'categories'=>$category)); | ||
}else{ | |||
$locality = array(); | |||
} | |||
if(!EMPTY($category)) { | |||
$category = $category; | |||
}else{ | |||
$category = array(); | |||
} | |||
if(isset($dateArray)){ | |||
$resultData = array(); | |||
$resData = array( | |||
'cities'=>$locality, | |||
'categories'=>$category, | |||
'dates'=>$dateArray | |||
); | |||
$res = array('status'=>1,'data'=>$resData); | |||
} else { | } else { | ||
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
} | } | ||
... | @@ -1563,6 +1582,8 @@ class Webservice_model extends CI_Model { | ... | @@ -1563,6 +1582,8 @@ class Webservice_model extends CI_Model { |
if($user_id > 0) { | if($user_id > 0) { | ||
$per_page = 10; | $per_page = 10; | ||
$str = urldecode(strtolower($data['query'])); | $str = urldecode(strtolower($data['query'])); | ||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$this->db->query("SET SESSION group_concat_max_len = 20000"); | $this->db->query("SET SESSION group_concat_max_len = 20000"); | ||
$sql = "SELECT GROUP_CONCAT(DISTINCT CONCAT_WS('#',EDATE.id,EDATE.date,EDATE.time)) | $sql = "SELECT GROUP_CONCAT(DISTINCT CONCAT_WS('#',EDATE.id,EDATE.date,EDATE.time)) | ||
... | @@ -1570,19 +1591,20 @@ class Webservice_model extends CI_Model { | ... | @@ -1570,19 +1591,20 @@ class Webservice_model extends CI_Model { |
FROM events AS EVT | FROM events AS EVT | ||
INNER JOIN venue AS VEN ON (VEN.id=EVT.venue_id) | INNER JOIN venue AS VEN ON (VEN.id=EVT.venue_id) | ||
INNER JOIN event_date_time AS EDATE ON (EVT.event_id=EDATE.event_id) | INNER JOIN event_date_time AS EDATE ON (EVT.event_id=EDATE.event_id) | ||
INNER JOIN event_gallery AS IMG ON | LEFT JOIN event_gallery AS IMG ON (IMG.event_id=EVT.event_id AND | ||
(IMG.event_id=EVT.event_id AND IMG.media_type=0) | IMG.media_type=0 AND IMG.status='1' ) | ||
WHERE (EVT.event_name LIKE '%$str%' OR | WHERE EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | ||
EVT.event_name_ar LIKE '%$str%') AND | VEN.status='1' AND EDATE.status='1' AND | ||
EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | EVT.event_id IN (SELECT event_id FROM translator_event | ||
VEN.status='1' AND IMG.status='1' AND EDATE.status='1' | WHERE event_name LIKE '%$str%' OR | ||
GROUP BY EVT.event_id"; | event_description LIKE '%$str%' | ||
GROUP BY EVT.event_id)"; | |||
$resCount = $this->db->query($sql)->result(); | $resCount = $this->db->query($sql)->result(); | ||
if(empty($resCount)){ | if(empty($resCount)){ | ||
return array('status'=>1,'data'=>array('events'=>[],'meta'=>$meta)); | return array('status'=>1,'data'=>array('events'=>[],'meta'=>$meta)); | ||
} | } | ||
foreach ($resCount AS $key => $rs) { | foreach ($resCount AS $key => $rs) { | ||
if(!empty($dates = explode(',',$rs->date_time))){ | if(!empty($dates = explode(',',$rs->date_time))){ | ||
$checkTime = 0; | $checkTime = 0; | ||
... | @@ -1603,42 +1625,36 @@ class Webservice_model extends CI_Model { | ... | @@ -1603,42 +1625,36 @@ class Webservice_model extends CI_Model { |
} else { | } else { | ||
unset($resCount[$key]); | unset($resCount[$key]); | ||
} | } | ||
} | } | ||
$count = count($resCount); | $count = count($resCount); | ||
$page = (isset($data['page']))?$data['page']:1; | $page = (isset($data['page']))?$data['page']:1; | ||
$page_limit = ($page - 1) * $per_page; | $page_limit = ($page - 1) * $per_page; | ||
$meta = array('total_pages'=>ceil($count/$per_page),'total'=>$count, | $meta = array('total_pages'=>ceil($count/$per_page),'total'=>$count, | ||
'current_page'=>$page,'per_page'=>$per_page); | 'current_page'=>$page,'per_page'=>$per_page); | ||
if($count > 0 && $count > $page_limit) { | if($count > 0 && $count > $page_limit) { | ||
$lang = $this->getUserLang($user_id); | |||
if($lang == 'en') $event_name = 'events.event_name AS event_name'; | |||
else $event_name = 'events.event_name_ar AS event_name'; | |||
$limit = $page_limit.','.$per_page; | $limit = $page_limit.','.$per_page; | ||
$this->db->query("SET SESSION group_concat_max_len = 20000"); | $this->db->query("SET SESSION group_concat_max_len = 20000"); | ||
$sql = "SELECT EVT.event_id,EVT.event_name,VEN.location, | $sql = "SELECT EVT.event_id,VEN.location,IMG.media_url AS event_image, | ||
IMG.media_url AS event_image, | |||
GROUP_CONCAT(DISTINCT CONCAT_WS('#',EDATE.id,EDATE.date,EDATE.time)) | GROUP_CONCAT(DISTINCT CONCAT_WS('#',EDATE.id,EDATE.date,EDATE.time)) | ||
AS date_time | AS date_time,TEVT.event_name | ||
FROM events AS EVT | FROM events AS EVT | ||
INNER JOIN venue AS VEN ON (VEN.id=EVT.venue_id) | INNER JOIN venue AS VEN ON (VEN.id=EVT.venue_id) | ||
INNER JOIN event_date_time AS EDATE ON (EVT.event_id=EDATE.event_id) | INNER JOIN event_date_time AS EDATE ON (EVT.event_id=EDATE.event_id) | ||
INNER JOIN event_gallery AS IMG ON | INNER JOIN translator_event AS TEVT ON (TEVT.event_id=EVT.event_id) | ||
(IMG.event_id=EVT.event_id AND IMG.media_type=0) | LEFT JOIN event_gallery AS IMG ON (IMG.event_id=EVT.event_id AND | ||
WHERE (EVT.event_name LIKE '%$str%' OR | IMG.media_type=0 AND IMG.status='1') | ||
EVT.event_name_ar LIKE '%$str%') AND | WHERE EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | ||
EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | VEN.status='1' AND EDATE.status='1' AND | ||
VEN.status='1' AND IMG.status='1' AND EDATE.status='1' | EVT.event_id IN (SELECT event_id FROM translator_event | ||
WHERE (event_name LIKE '%$str%' OR | |||
event_description LIKE '%$str%') | |||
GROUP BY event_id) | |||
GROUP BY EVT.event_id | GROUP BY EVT.event_id | ||
ORDER BY EVT.event_id DESC | ORDER BY EVT.event_id DESC | ||
LIMIT $limit"; | LIMIT $limit"; | ||
$result = $this->db->query($sql)->result(); | |||
$result = $this->db->query($sql)->result(); | |||
foreach ($result AS $key => $rs) { | foreach ($result AS $key => $rs) { | ||
if(!empty($dates = explode(',',$rs->date_time)) && count($dates) > 0){ | if(!empty($dates = explode(',',$rs->date_time)) && count($dates) > 0){ | ||
$checkTime = 0; | $checkTime = 0; | ||
... | @@ -1657,7 +1673,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1657,7 +1673,6 @@ class Webservice_model extends CI_Model { |
} | } | ||
unset($result[$key]->date_time); | unset($result[$key]->date_time); | ||
} | } | ||
$res = array('status'=>1,'data'=>array('events'=>$result,'meta'=>$meta)); | $res = array('status'=>1,'data'=>array('events'=>$result,'meta'=>$meta)); | ||
} else { | } else { | ||
$res = array('status'=>1,'data'=>array('events'=>[],'meta'=>$meta)); | $res = array('status'=>1,'data'=>array('events'=>[],'meta'=>$meta)); | ||
... | @@ -1671,12 +1686,10 @@ class Webservice_model extends CI_Model { | ... | @@ -1671,12 +1686,10 @@ class Webservice_model extends CI_Model { |
return $res; | return $res; | ||
} | } | ||
public function checkSeatAvailability($data = ''){ | public function checkSeatAvailability($data = ''){ | ||
$user_id = $data['user_id']; | $user_id = $data['user_id']; | ||
$event_id = $data['event_id']; | $event_id = $data['event_id']; | ||
$evtTimeId = $data['time_id']; | $evtTimeId = $data['time_id']; | ||
$lyCapacity = array(); | $lyCapacity = array(); | ||
$capacity = $usrBooked = $maxBooking = 0; | $capacity = $usrBooked = $maxBooking = 0; | ||
$sql = "SELECT EDATE.date,EDATE.time,EVT.custom_seat_layout,EVT.seat_pricing, | $sql = "SELECT EDATE.date,EDATE.time,EVT.custom_seat_layout,EVT.seat_pricing, | ||
... | @@ -1689,41 +1702,34 @@ class Webservice_model extends CI_Model { | ... | @@ -1689,41 +1702,34 @@ class Webservice_model extends CI_Model { |
EDATE.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; | EDATE.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; | ||
$evtSql = $this->db->query($sql); | $evtSql = $this->db->query($sql); | ||
$evtData = $evtSql->row_array(); | $evtData = $evtSql->row_array(); | ||
if(!empty($user_id)){ | if(!empty($user_id)){ | ||
$sql = "SELECT SUM(BOK.no_of_ticket) AS bookCount | $sql = "SELECT SUM(BOK.no_of_ticket) AS bookCount | ||
FROM booking AS BOK | FROM booking AS BOK | ||
INNER JOIN event_date_time AS EDATE ON (BOK.event_date_id=EDATE.id) | INNER JOIN event_date_time AS EDATE ON (BOK.event_date_id=EDATE.id) | ||
WHERE BOK.event_id='$event_id' AND BOK.customer_id='$user_id' AND | WHERE BOK.event_id='$event_id' AND BOK.customer_id='$user_id' AND | ||
EDATE.id='$evtTimeId' AND BOK.status IN (1,2)"; | EDATE.id='$evtTimeId' AND BOK.status IN (1,2)"; | ||
$result = $this->db->query($sql)->row_array(); | $result = $this->db->query($sql)->row_array(); | ||
$usrBooked = (!empty($result))?$result['bookCount']:0; | $usrBooked = (!empty($result))?$result['bookCount']:0; | ||
} | } | ||
$maxBooking = $evtData['max_booking']-$usrBooked; | $maxBooking = $evtData['max_booking']-$usrBooked; | ||
if($evtData['show_layout'] == 0){ | if($evtData['show_layout'] == 0){ | ||
$lyout = json_decode($evtData['seat_pricing'],true); | $lyout = json_decode($evtData['seat_pricing'],true); | ||
$lyCapacity['price'] = $lyout['price']; | $lyCapacity['price'] = $lyout['price']; | ||
$lyCapacity['capacity'] = $lyout['capacity']; | $lyCapacity['capacity'] = $lyout['capacity']; | ||
} else { | } else { | ||
$lyout = (!empty($evtData['custom_seat_layout'])) | $lyout = (!empty($evtData['custom_seat_layout'])) | ||
?json_decode($evtData['custom_seat_layout'],true) | ?json_decode($evtData['custom_seat_layout'],true) | ||
:json_decode($evtData['layout_details'],true); | :json_decode($evtData['layout_details'],true); | ||
foreach($lyout AS $custLy) { | foreach($lyout AS $custLy) { | ||
$lyCapacity[$custLy['color']] = array('price'=>$custLy['price'], | $lyCapacity[$custLy['color']] = array('price'=>$custLy['price'], | ||
'capacity'=>$custLy['capacity'], | 'capacity'=>$custLy['capacity'], | ||
'weekend_price'=>$custLy['weekend_price']); | 'weekend_price'=>$custLy['weekend_price']); | ||
} | } | ||
} | } | ||
$sql = "SELECT BOOK.no_of_ticket,BOOK.ticket_details | $sql = "SELECT BOOK.no_of_ticket,BOOK.ticket_details | ||
FROM booking AS BOOK | FROM booking AS BOOK | ||
INNER JOIN event_date_time AS EDATE ON (BOOK.event_date_id=EDATE.id) | INNER JOIN event_date_time AS EDATE ON (BOOK.event_date_id=EDATE.id) | ||
WHERE BOOK.event_id='$event_id' AND BOOK.event_date_id='$evtTimeId'"; | WHERE BOOK.event_id='$event_id' AND BOOK.event_date_id='$evtTimeId'"; | ||
if(!empty($result = $this->db->query($sql)->result_array())){ | if(!empty($result = $this->db->query($sql)->result_array())){ | ||
foreach($result AS $value) { | foreach($result AS $value) { | ||
if($evtData['show_layout'] == 0){ | if($evtData['show_layout'] == 0){ | ||
... | @@ -1736,7 +1742,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1736,7 +1742,6 @@ class Webservice_model extends CI_Model { |
} | } | ||
} | } | ||
} | } | ||
$event_layouts = array(); | $event_layouts = array(); | ||
if($evtData['show_layout'] == 0){ | if($evtData['show_layout'] == 0){ | ||
$capacity = $lyCapacity['capacity']; | $capacity = $lyCapacity['capacity']; | ||
... | @@ -1748,7 +1753,6 @@ class Webservice_model extends CI_Model { | ... | @@ -1748,7 +1753,6 @@ class Webservice_model extends CI_Model { |
foreach($lyCapacity AS $block => $sData) { | foreach($lyCapacity AS $block => $sData) { | ||
$capacity = $sData['capacity']; | $capacity = $sData['capacity']; | ||
$lyCapacity[$block]['capacity'] = ($capacity < $maxBooking)? $capacity : $maxBooking; | $lyCapacity[$block]['capacity'] = ($capacity < $maxBooking)? $capacity : $maxBooking; | ||
$event_layouts[] = array('rate' => $lyCapacity[$block]['price'], | $event_layouts[] = array('rate' => $lyCapacity[$block]['price'], | ||
'class_name' => $block, | 'class_name' => $block, | ||
'max_ticket' => $lyCapacity[$block]['capacity']); | 'max_ticket' => $lyCapacity[$block]['capacity']); | ||
... | @@ -1759,32 +1763,41 @@ class Webservice_model extends CI_Model { | ... | @@ -1759,32 +1763,41 @@ class Webservice_model extends CI_Model { |
public function sync_contacts($data){ | public function sync_contacts($data){ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
$respArr = array('status'=>0,'code'=>'918','message'=>'Something Went Wrong..Try Again'); | $respArr = array('status'=>0,'code'=>'918','message'=>'Data Missing'); | ||
if(empty($data)){ | if(empty($data)){ | ||
return $respArr; | return $respArr; | ||
} | } | ||
$phNumbers = ''; | $phNumbers = ''; | ||
foreach($data['contacts'] AS $key => $number) { | foreach($data['contacts'] AS $key => $number) { | ||
$number = preg_replace('/\D/', '', $number); | |||
$eCond = ($key != count($data['contacts'])-1)?' OR ':''; | $eCond = ($key != count($data['contacts'])-1)?' OR ':''; | ||
if(strlen($number) > 10){ | if(strlen($number) > 9){ | ||
$phNumbers .= " phone LIKE '%".substr($number, strlen($number)-10)."' ".$eCond; | $phNumbers .= " phone LIKE '%".substr($number, strlen($number)-9)."' ".$eCond; | ||
} else { | } else { | ||
$phNumbers .= " phone LIKE '%".$number."' ".$eCond; | $phNumbers .= " phone LIKE '%".$number."' ".$eCond; | ||
} | } | ||
} | } | ||
$result = $this->db->query("SELECT name,phone,profile_image FROM customer WHERE (".$phNumbers.") AND customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2'))"); | $result = $this->db->query("SELECT CUST.customer_id,CUST.name,CUST.phone,CUST.profile_image, | ||
CHT.type AS friend_status | |||
FROM customer AS CUST | |||
LEFT JOIN chats AS CHT ON ((CUST.customer_id=CHT.from_user OR CUST.customer_id=CHT.to_user) AND CHT.type=1) | |||
if(!empty($result) && !empty($result = $result->result_array())){ | WHERE (".$phNumbers.") AND | ||
customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND | |||
customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2'))"); | |||
$respArr['status'] = 1; | $respArr['status'] = 1; | ||
if(!empty($result) && !empty($result = $result->result_array())){ | |||
$respArr['data'] = $result; | $respArr['data'] = $result; | ||
}else{ | |||
$respArr['message'] = 'No Data Found'; | |||
} | } | ||
return $respArr; | return $respArr; | ||
} | } | ||
public function update_friend_request($data){ | public function update_friend_request($data){ | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
$status = $this->db->query("UPDATE chats SET type = ".$data['add_as_friend']." WHERE from_user = $user_id AND to_user = ".$data['user_id']); | $status = $this->db->query("UPDATE chats SET type='".$data['add_as_friend']."' | ||
WHERE from_user='".$data['user_id']."' AND to_user='".$user_id."'"); | |||
return ($status)?1:0; | return ($status)?1:0; | ||
} | } | ||
... | @@ -1809,10 +1822,11 @@ class Webservice_model extends CI_Model { | ... | @@ -1809,10 +1822,11 @@ class Webservice_model extends CI_Model { |
public function get_friend_requests($data){ | public function get_friend_requests($data){ | ||
$respArr = array('status'=>0,'code'=>'918','message'=>'No Request for you'); | $respArr = array('status'=>0,'code'=>'918','message'=>'No Request for you'); | ||
$user_id = $this->auth_token_get($data['auth_token']); | $user_id = $this->auth_token_get($data['auth_token']); | ||
$this->db->select("name,phone,profile_image"); | $result = $this->db->query("SELECT CUST.name,CUST.phone,CUST.profile_image,CUST.customer_id | ||
$this->db->join('customer','customer.customer_id = chats.to_user'); | FROM customer AS CUST | ||
$result=$this->db->get_where('chats',array('to_user'=>$user_id,'type'=>'0'))->result_array(); | INNER JOIN chats AS CHT ON (CUST.customer_id = CHT.from_user) | ||
if(!empty($result)){ | WHERE type='0' AND to_user='".$user_id."'"); | ||
if(!empty($result) && !empty($result = $result->result())){ | |||
$respArr['status'] = 1; | $respArr['status'] = 1; | ||
$respArr['data'] = $result; | $respArr['data'] = $result; | ||
} | } | ||
... | @@ -1825,11 +1839,19 @@ class Webservice_model extends CI_Model { | ... | @@ -1825,11 +1839,19 @@ class Webservice_model extends CI_Model { |
$result = $this->db->query("SELECT from_user,to_user,type FROM chats WHERE (from_user=$user_id OR to_user=$user_id) AND type IN('0','1')")->result_array(); | $result = $this->db->query("SELECT from_user,to_user,type FROM chats WHERE (from_user=$user_id OR to_user=$user_id) AND type IN('0','1')")->result_array(); | ||
if(!empty($result)){ | if(!empty($result)){ | ||
foreach ($result as $key => $value) { | foreach ($result as $key => $value) { | ||
if($value['to_user'] == $user_id && $value['type'] == 0){ | if($value['type'] == 0){ | ||
continue; | continue; | ||
} | } | ||
$this->db->select("name,phone,profile_image"); | $fromUsrId = ''; | ||
$cust = $this->db->get_where('customer',array('customer_id'=>$value['to_user'])); | if($value['to_user']==$user_id){ | ||
$fromUsrId = $value['from_user']; | |||
} else if ($value['from_user'] == $user_id){ | |||
$fromUsrId = $value['to_user']; | |||
} else { | |||
continue; | |||
} | |||
$this->db->select("name,phone,profile_image,customer_id"); | |||
$cust = $this->db->get_where('customer',array('customer_id'=>$fromUsrId)); | |||
if(!empty($cust) && !empty($cust = $cust->row_array())){ | if(!empty($cust) && !empty($cust = $cust->row_array())){ | ||
$custData[] = $cust; | $custData[] = $cust; | ||
} | } | ||
... | @@ -1840,8 +1862,111 @@ class Webservice_model extends CI_Model { | ... | @@ -1840,8 +1862,111 @@ class Webservice_model extends CI_Model { |
return $respArr; | return $respArr; | ||
} | } | ||
} | public function getCountry() { | ||
?> | try { | ||
$rs = $this->db->query("SELECT * FROM country WHERE status = 1 ORDER BY country_name")->result(); | |||
if(count($rs) > 0) { | |||
$res = array('status'=>'success','data'=>$rs); | |||
} else { | |||
$res = array('status'=>'error','message'=>'No records found','code'=>'ER13'); | |||
} | |||
} catch(Exception $e) { | |||
$res = array('status'=>'error','message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | |||
} | |||
return $res; | |||
} | |||
public function getCountryData($user_id){ | |||
$ctryData = ''; | |||
if(!empty($user_id)){ | |||
$sql = "SELECT CTRY.* FROM customer AS CUST | |||
INNER JOIN country AS CTRY ON (CTRY.country_id=CUST.country_id) | |||
WHERE CUST.customer_id='$user_id'"; | |||
$ctryData = $this->db->query($sql)->row_array(); | |||
} | |||
if(empty($ctryData)){ | |||
$ctryData = $this->db->query("SELECT * FROM country WHERE language_code='EN'")->row_array(); | |||
} | |||
return $ctryData; | |||
} | |||
public function validate_promo_code($data =array()){ | |||
$user_id = $this->auth_token_get($data['auth_token']); | |||
if($user_id > 0){ | |||
$date = date('Y-m-d'); | |||
$promoCode = $data['promo_code']; | |||
$tot_cost = $data['tot_cost']; | |||
$promoData = $this->db->query("SELECT PROM.* | |||
FROM promocode_management AS PROM | |||
WHERE PROM.promocode_name='$promoCode' AND PROM.status='1' AND | |||
PROM.start_date<='$date' AND PROM.end_date>='$date' AND | |||
PROM.use_limit>(SELECT count(id) FROM promocode_used AS PU | |||
WHERE PU.promocode_id=PROM.promocode_id AND | |||
PU.status=1)"); | |||
if(empty($promoData) || empty($promoData = $promoData->row_array())){ | |||
$respArr['status'] = 0; | |||
$respArr['code'] = 980; | |||
$respArr['message'] = 'Invalid Promocode'; | |||
return $respArr; | |||
} | |||
$eventData = $this->db->query("SELECT VEN.region_id,EVT.category_id FROM events AS EVT | |||
INNER JOIN venue AS VEN ON (VEN.id = EVT.venue_id) | |||
WHERE EVT.event_id='".$promoData['event_id']."' AND EVT.status='1'"); | |||
if(empty($eventData) || empty($eventData = $eventData->row_array())){ | |||
$respArr['status'] = 0; | |||
$respArr['code'] = 980; | |||
$respArr['message'] = 'Promocode Invalid or Expired'; | |||
return $respArr; | |||
} | |||
if(!empty($promoData['event_id']) && $promoData['event_id'] != $data['event_id']){ | |||
$respArr['status'] = 0; | |||
$respArr['code'] = 981; | |||
$respArr['message'] = 'Promocode is not Valid for this Event'; | |||
return $respArr; | |||
} | |||
if(!empty($promoData['category_id']) && $promoData['category_id'] != $eventData['category_id']){ | |||
$respArr['status'] = 0; | |||
$respArr['code'] = 982; | |||
$respArr['message'] = 'Promocode is not Valid for this Category'; | |||
return $respArr; | |||
} | |||
if(!empty($promoData['city_id']) && $promoData['city_id'] != $eventData['region_id']){ | |||
$respArr['status'] = 0; | |||
$respArr['code'] = 983; | |||
$respArr['message'] = 'Promocode is not Valid for this City'; | |||
return $respArr; | |||
} | |||
if(!empty($promoData['min_order_amount']) && $promoData['min_order_amount'] > $tot_cost){ | |||
$respArr['status'] = 1; | |||
$respArr['code'] = 984; | |||
$respArr['data'] = array('message'=>'Minimum amount is not satisfied', | |||
'minimum_amount'=>$promoData['min_order_amount']); | |||
return $respArr; | |||
} | |||
$discAmt = 0; | |||
if($promoData['discount_type'] == 1){ | |||
$discAmt = ($tot_cost * $promoData['discount_percentage'])/100; | |||
} else { | |||
$discAmt = ($tot_cost<=$promoData['discount_percentage'])?$tot_cost:$promoData['discount_percentage']; | |||
} | |||
$discAmt = (!empty($maxReedem = $promoData['max_redeem']) && $maxReedem < $discAmt)?$maxReedem:$discAmt; | |||
$tot_cost = $tot_cost-$discAmt; | |||
$tot_cost = ($tot_cost <= 0)?0:$tot_cost; | |||
$countryData = $this->getCountryData($user_id); | |||
$lang = $countryData['language_code']; | |||
$promDetails = langTranslator($promoData['promocode_id'],'PROMO',$lang); | |||
$datas['discounted_price'] = $tot_cost; | |||
$datas['terms_and_conditions'] = $promDetails['promocode_tc']; | |||
$datas['description'] = $promDetails['promocode_desc']; | |||
$respArr['status'] = 1; | |||
$respArr['data'] = $datas; | |||
return $respArr; | |||
}else{ | |||
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | |||
} | |||
} | |||
} | |||
?> |
assets/uploads/155198272834057.jpg
deleted
100644 → 0
336 KB
assets/uploads/155198325710806.jpg
deleted
100644 → 0
73.9 KB
assets/uploads/155198367294335.jpg
deleted
100644 → 0
73.9 KB
assets/uploads/155198442755827.jpg
deleted
100644 → 0
36.7 KB
assets/uploads/155201869666702.gif
deleted
100644 → 0
226 KB
assets/uploads/155205608765242.png
deleted
100644 → 0
5.6 KB
assets/uploads/155205608995897.png
deleted
100644 → 0
5.6 KB
assets/uploads/155205843357036.gif
deleted
100644 → 0
226 KB