Merge branch 'master' into 'dev_production'
Master
See merge request !97
Showing
| ... | ... | @@ -4,13 +4,13 @@ |
| [3] Collaborator ID : BAYANPAY | ||
| [4] Bayan URL : https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet | ||
| [5] Block Existence Indicator : 1110100 | ||
| [6] DataBlock1 : TransactionDataBlock1 : 10111111|1565768157|http://localhost/timeOut/Api/paymentSuccessUrl|http://localhost/timeOut/Api/paymentFailureUrl|INTERNET|CC|01|SAR | ||
| [7] DataBlock2 : billingDataBlock : 0000000000000| | ||
| [8] DataBlock3 : shippingDataBlock : 000000000000| | ||
| [6] DataBlock1 : TransactionDataBlock1 : 11111111|1565949321|200|http://localhost/timeOut/Api/paymentSuccessUrl|http://localhost/timeOut/Api/paymentFailureUrl|INTERNET|CC|01|SAR | ||
| [7] DataBlock2 : billingDataBlock : 1000000011000|Dev|[email protected]|919995559194 | ||
| [8] DataBlock3 : shippingDataBlock : 100000000001|Dev|919995559194 | ||
| [9] DataBlock4 : paymentDataBlock : NULL | ||
| [10] DataBlock5 : merchantDataBlock : 0000000000| | ||
| [10] DataBlock5 : merchantDataBlock : 1110000000|490|128|TO1908161619 | ||
| [11] DataBlock6 : otherDataBlock : 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| | ||
| [14] EncryptedString : 6SLNoOCXnCfuN+p+4JSpYIoQEIYGwFXo5BVHgqPFLZ3AQzcZ0mBSn61URC66o1a13cH7XNEUJ5j4ssaNmGD+xJi4d1WQMv4zJcqsDRuR8QEWcst/wvbI/chd0qTkElo18kqv324p+odC5W0k2NTHoYUj0ospvVu5moa4dXbl8ikUPMk1siZW+aIb7ZUGDHRefDKTenHjMvbJsvaANWH12SU84ZCFkg40+n0YZeAPIUe3yXHH91BMyYfShu4K2pj7 | ||
| [15] BayanPostData : 201901291000002||BAYANPAY||6SLNoOCXnCfuN+p+4JSpYIoQEIYGwFXo5BVHgqPFLZ3AQzcZ0mBSn61URC66o1a13cH7XNEUJ5j4ssaNmGD+xJi4d1WQMv4zJcqsDRuR8QEWcst/wvbI/chd0qTkElo18kqv324p+odC5W0k2NTHoYUj0ospvVu5moa4dXbl8ikUPMk1siZW+aIb7ZUGDHRefDKTenHjMvbJsvaANWH12SU84ZCFkg40+n0YZeAPIUe3yXHH91BMyYfShu4K2pj7 | ||
| \ No newline at end of file | ||
| [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 : S7fVSoNGH4bne+vZCz3T1hU1jYM1Wo9nk7xgNovOGFPqdJ8JZaCs5fRYysGksWJe4Nid+xoi654uECYUpOXw4LFWQ3KhU7ih8k9TxJfm7v5crHFlq0Tbwl6ghhmwJcGDQos/PYiP4jT0kUWm1IEUrrMksj82dYIDhG3+gPydjzkNrSJLblaQ/FUg6Jl5nHvO73/gdIqQSCgUNcDn3qKbO/3ApXUBuLpJJs28a42HpwYPke7q7etbFHNaiIjPlVSjjFepxARZ8yTBO26QmrLpF12Fai0EN8CetlBjmjnVByJc7PW78wS6hy7DYIKg5uccprmiRiaeW1f1vvCBsAy45g== | ||
| [15] BayanPostData : 201901291000002||BAYANPAY||S7fVSoNGH4bne+vZCz3T1hU1jYM1Wo9nk7xgNovOGFPqdJ8JZaCs5fRYysGksWJe4Nid+xoi654uECYUpOXw4LFWQ3KhU7ih8k9TxJfm7v5crHFlq0Tbwl6ghhmwJcGDQos/PYiP4jT0kUWm1IEUrrMksj82dYIDhG3+gPydjzkNrSJLblaQ/FUg6Jl5nHvO73/gdIqQSCgUNcDn3qKbO/3ApXUBuLpJJs28a42HpwYPke7q7etbFHNaiIjPlVSjjFepxARZ8yTBO26QmrLpF12Fai0EN8CetlBjmjnVByJc7PW78wS6hy7DYIKg5uccprmiRiaeW1f1vvCBsAy45g== | ||
| \ No newline at end of file |
| ... | ... | @@ -30,21 +30,26 @@ class Webservice_model extends CI_Model { |
| function login($data){ | ||
| try{ | ||
| $this->db->select("region.id AS city_id,region.name AS city, | ||
| customer.name AS user_name,customer.phone, | ||
| customer.email,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, | ||
| users.id AS user_id"); | ||
| $this->db->where('users.status',1); | ||
| $this->db->where('users.password',md5($data['password'])); | ||
| $this->db->where('customer.email',$data['email']); | ||
| $this->db->from('users'); | ||
| $this->db->join('customer','customer.customer_id=users.id'); | ||
| $this->db->join('region','region.id=customer.city','left'); | ||
| $result = $this->db->get()->row(); | ||
| $sql = "SELECT region.id AS city_id, customer.name AS user_name,customer.phone, customer.email, | ||
| 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, | ||
| users.id AS user_id | ||
| FROM users | ||
| INNER JOIN customer ON (customer.customer_id=users.id) | ||
| LEFT JOIN region ON (region.id=customer.city) | ||
| WHERE users.status = 1 | ||
| AND users.password = '".md5($data['password'])."' | ||
| AND customer.email = '".$data['email']."'"; | ||
| $result = $this->db->query($sql)->row(); | ||
| if($result){ | ||
| $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 != ''){ | ||
| $cityId = $result->city_id; | ||
| $cityName = $result->city; | ||
| ... | ... | @@ -63,9 +68,8 @@ class Webservice_model extends CI_Model { |
| 'is_phone_verified'=>$result->is_phone_verified === '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)); | ||
| $response = array('user'=>$resultArray,'auth_token'=>$auth_token); | ||
| $this->generateAuth($result->user_id,$auth_token); | ||
| $res = array('status'=>1,'data'=>$response); | ||
| ... | ... | @@ -83,7 +87,7 @@ class Webservice_model extends CI_Model { |
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $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) { | ||
| $res = array('status'=>1); | ||
| }else { | ||
| ... | ... | @@ -98,11 +102,11 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function availability($data) { | ||
| try{ | ||
| $is_email_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(); | ||
| if(count($res_count) > 0) { | ||
| foreach ($res_count as $rs) { | ||
| ... | ... | @@ -126,11 +130,10 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function register($data) { | ||
| try{ | ||
| $email = $data['email']; | ||
| $phone = $data['phone']; | ||
| $phone = preg_replace('/\D/', '', $data['phone']); | ||
| $res_count = $this->db->query("SELECT * FROM customer | ||
| INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3' | ||
| WHERE users.status!='2' AND | ||
| ... | ... | @@ -159,27 +162,23 @@ class Webservice_model extends CI_Model { |
| 'phone'=>$data['phone'], | ||
| 'email'=>$data['email'], | ||
| 'name'=>$data['name'], | ||
| 'language'=>$data['language'] | ||
| 'country_id'=>$data['country_id'] | ||
| ); | ||
| $this->db->insert('customer', $customer_data); | ||
| $email = $data['email']; | ||
| $subject = "New account created successfully"; | ||
| $message = "Hi, Welcome to TimeOut. Please use username: ".$email. | ||
| " for access your account"; | ||
| if(isset($template['registration_mail']) && !empty($template['registration_mail'])){ | ||
| $message = str_replace(array('{:email}'), | ||
| array($email),$template['registration_mail']); | ||
| } | ||
| $this->send_mail($subject,$email,$message); | ||
| if(isset($template['registration_sms']) && !empty($template['registration_sms'])){ | ||
| $message = str_replace(array('{:email}'), | ||
| array($email),$template['registration_sms']); | ||
| } | ||
| $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->where('users.id',$id); | ||
| $this->db->from('users'); | ||
| ... | ... | @@ -211,19 +210,18 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function profile_details($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $lang = $this->getUserLang($user_id); | ||
| $field = 'faq_en'; | ||
| if($lang == 'ar'){ | ||
| $field = 'faq_ar'; | ||
| } | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $settings = getSettings(); | ||
| $sql = "SELECT faq FROM translator_policies WHERE language_code='$lang'"; | ||
| $settingsDetails = $this->db->query($sql)->row_array(); | ||
| $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(); | ||
| if(count($settingsDetails)>0 && count($userDetails)){ | ||
| $resultData = array(); | ||
| ... | ... | @@ -241,35 +239,33 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function discover($data) { | ||
| try { | ||
| $per_page = 10; | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $where = ''; | ||
| $lang = $this->getUserLang($user_id); | ||
| $cityField = "region.name AS city"; | ||
| if($lang == 'ar') { | ||
| $cityField = 'region.name_ar AS city'; | ||
| } | ||
| $sql = "SELECT region.id,$cityField FROM customer | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $rate = (!empty($countryData['conversion_rate']))?$countryData['conversion_rate']:1; | ||
| $sql = "SELECT region.id FROM customer | ||
| INNER JOIN region ON customer.city=region.id | ||
| WHERE customer.customer_id='$user_id' AND region.status='1'"; | ||
| $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'])) { | ||
| $where = ' AND events.category_id = '.$data['category_id']; | ||
| } | ||
| $case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; | ||
| if(isset($data['latitude']) && isset($data['longitude'])) { | ||
| $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(); | ||
| $otherV = ''; | ||
| foreach($res as $key => $value){ | ||
| if ($otherV) $otherV .= ','; | ||
| ... | ... | @@ -281,11 +277,9 @@ class Webservice_model extends CI_Model { |
| $where = ' AND events.category_id IN (0)'; | ||
| } | ||
| } | ||
| if(isset($cityName['id'])) { | ||
| $where .= ' AND venue.region_id = '.$cityName['id']; | ||
| } | ||
| if(isset($data['filters'])){ | ||
| $filtersElement = json_decode($data['filters'], true); | ||
| $locality_id_Array = $filtersElement['cities']; | ||
| ... | ... | @@ -294,11 +288,9 @@ class Webservice_model extends CI_Model { |
| $dateId = preg_replace("/[^a-zA-Z 0-9]+/", "", $dateId_Array); | ||
| $categoryId_Array = $filtersElement['category']; | ||
| $categoryId = preg_replace("/[^a-zA-Z 0-9]+/", "", $categoryId_Array); | ||
| if($categoryId!=''){ | ||
| $where = ' AND events.category_id='.$categoryId; | ||
| } | ||
| if($dateId != '') { | ||
| switch ($dateId) { | ||
| case '1': | ||
| ... | ... | @@ -336,14 +328,12 @@ class Webservice_model extends CI_Model { |
| break; | ||
| } | ||
| } | ||
| if($locality_id!=''){ | ||
| $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)); | ||
| $where .= ' AND events.venue_id IN('.$list.')'; | ||
| } | ||
| } | ||
| $resCount = $this->db->query(" | ||
| SELECT GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date, | ||
| event_date_time.time)) AS date_time | ||
| ... | ... | @@ -359,11 +349,9 @@ class Webservice_model extends CI_Model { |
| favourite.user_id = $user_id AND favourite.status = 1 | ||
| WHERE events.status = 1 $where | ||
| GROUP BY events.event_id")->result(); | ||
| if(empty($resCount)){ | ||
| return array('status'=>1,'data'=>array('city_name'=>$cityName['city'])); | ||
| } | ||
| foreach ($resCount AS $key => $rs) { | ||
| if(!empty($dates = explode(',',$rs->date_time))){ | ||
| $checkTime = 0; | ||
| ... | ... | @@ -386,19 +374,13 @@ class Webservice_model extends CI_Model { |
| } | ||
| } | ||
| $count = count($resCount); | ||
| if($count > 0) { | ||
| $page = (isset($data['page']))?$data['page']:1; | ||
| $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) { | ||
| $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 | ||
| INNER JOIN venue ON venue.id = events.venue_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 { |
| WHERE events.status = 1 $where $case | ||
| GROUP BY events.event_id | ||
| LIMIT $page_limit,$per_page")->result(); | ||
| $response = array(); | ||
| foreach ($result as $key=>$rs) { | ||
| if(!empty($dates = explode(',',$rs->date_time)) && count($dates) > 0){ | ||
| ... | ... | @@ -425,37 +406,48 @@ class Webservice_model extends CI_Model { |
| } | ||
| if($checkTime == count($dates)) continue; | ||
| } else continue; | ||
| if($rs->layout!=''){ | ||
| if($rs->custom_seat_layout!=''){ | ||
| $pricelist = json_decode($rs->custom_seat_layout, TRUE); | ||
| $price = min(array_column($pricelist, 'price')); | ||
| $price = $rate*min(array_column($pricelist, 'price')); | ||
| } else { | ||
| $pricelist = json_decode($rs->layout_details, TRUE); | ||
| $price = min(array_column($pricelist, 'price')); | ||
| $price = $rate*min(array_column($pricelist, 'price')); | ||
| } | ||
| } else { | ||
| $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( | ||
| 'id' => "$key", | ||
| 'event_id'=>$rs->event_id, | ||
| 'image'=>$rs->image, | ||
| 'attendees'=>(!empty($rs->attendees))?$rs->attendees:'0', | ||
| 'category'=>$rs->category, | ||
| 'name'=>($lang == 'en')?$rs->name:$rs->name_ar, | ||
| 'category'=>$transData['category'], | ||
| 'name'=>$transData['event'], | ||
| 'rating'=>(!empty($rs->rating))?$rs->rating:'0', | ||
| 'location'=>$rs->venue_name.', '.$rs->location, | ||
| 'location'=>$transData['venue'].', '.$rs->location, | ||
| 'rate'=>$price, | ||
| 'is_editors_choice'=>$rs->is_editors_choice, | ||
| 'is_favorite'=>$rs->is_favorite === 'true'? true: false, | ||
| 'latitude'=>$rs->latitude, | ||
| 'longitude'=>$rs->longitude | ||
| 'longitude'=>$rs->longitude, | ||
| 'currency_symbol'=>$countryData['currency_symbol'] | ||
| ); | ||
| array_push($response, $resData); | ||
| } | ||
| $sql = "SELECT booking.id,review.rate | ||
| FROM booking | ||
| LEFT JOIN review ON review.event_id=booking.event_id AND | ||
| ... | ... | @@ -463,7 +455,6 @@ class Webservice_model extends CI_Model { |
| WHERE booking.customer_id = ".$user_id." AND booking.status='2' | ||
| ORDER BY booking.id DESC LIMIT 1"; | ||
| $lastBooking = $this->db->query($sql)->row_array(); | ||
| if($lastBooking['id'] != ''){ | ||
| if($lastBooking['rate'] != ''){ | ||
| $lastBooking = "false"; | ||
| ... | ... | @@ -478,7 +469,6 @@ class Webservice_model extends CI_Model { |
| 'current_page'=>$page, | ||
| 'per_page'=>$per_page | ||
| ); | ||
| if(count($result)>0){ | ||
| $resultData = array(); | ||
| $resultData['is_last_booking_avail'] = $lastBooking; | ||
| ... | ... | @@ -505,73 +495,78 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function event($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $event_id = $data['event_id']; | ||
| $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"); | ||
| $rs = $this->db->query(" | ||
| SELECT host_categories.show_layout AS is_layout,events.has_payment AS is_payment_required, | ||
| favourite.is_favorite AS is_favorite,events.event_id, events.event_name, | ||
| events.event_name_ar,events.event_description AS event_description, | ||
| events.event_description_ar,events.seat_pricing, events.custom_seat_layout, | ||
| venue.layout, venue.layout_details,venue.venue_name,venue.venue_details, | ||
| venue.location,venue.location_lat AS lat,venue.location_lng AS lng, | ||
| venue.venue_name AS address_name,venue.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, | ||
| event_date_time.time)) AS date_time | ||
| FROM events | ||
| INNER JOIN event_date_time ON events.event_id=event_date_time.event_id | ||
| INNER JOIN venue ON venue.id=events.venue_id | ||
| LEFT JOIN event_gallery ON events.event_id=event_gallery.event_id AND | ||
| event_gallery.status != 0 | ||
| LEFT JOIN booking on booking.event_id = events.event_id | ||
| LEFT JOIN favourite ON favourite.event_id = events.event_id AND favourite.user_id=$user_id AND favourite.status = 1 | ||
| LEFT JOIN event_tags ON events.event_id = event_tags.event_id | ||
| LEFT JOIN tags on tags.tag_id = event_tags.tag_id | ||
| LEFT JOIN review ON events.event_id = review.event_id | ||
| INNER JOIN host_categories ON venue.host_cat_id = host_categories.host_cat_id | ||
| WHERE event_date_time.date>='".date('Y-m-d')."' AND events.event_id=$event_id | ||
| GROUP BY events.event_id, event_date_time.event_id")->row(); | ||
| if(count($rs)>0){ | ||
| $sql = "SELECT host_categories.show_layout AS is_layout,venue.id AS venue_id, | ||
| events.has_payment AS is_payment_required,favourite.is_favorite AS is_favorite, | ||
| events.seat_pricing,events.custom_seat_layout,events.event_id, | ||
| venue.layout, venue.layout_details,venue.location,venue.location AS address, | ||
| venue.location_lat AS lat,venue.location_lng AS lng,events.max_booking, | ||
| GROUP_CONCAT(DISTINCT event_gallery.media_url) AS media_url, | ||
| GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date, | ||
| event_date_time.time)) AS date_time | ||
| FROM events | ||
| 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 | ||
| event_gallery.status != 0 | ||
| LEFT JOIN favourite ON favourite.event_id = events.event_id AND | ||
| favourite.user_id=$user_id AND favourite.status = 1 | ||
| 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"; | ||
| $rs = $this->db->query($sql)->row(); | ||
| if(count($rs) > 0){ | ||
| $event_layout = ''; | ||
| $colorData = 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(); | ||
| $rate = isset($rating['rate'])&&!empty($rating['rate'])? | ||
| round($rating['rate'],1):'0.0'; | ||
| $rate = isset($rating['rate'])&&!empty($rating['rate'])?round($rating['rate'],1):'0.0'; | ||
| $sql = "SELECT SUM(booking.no_of_ticket) AS attend FROM booking | ||
| WHERE status IN (1,2) AND event_id=$event_id"; | ||
| $atten = $this->db->query($sql)->row_array(); | ||
| $atte = isset($atten['attend'])&&!empty($atten['attend'])? | ||
| $atten['attend']:'0'; | ||
| if($rs->layout!=''){ | ||
| if($rs->custom_seat_layout!=''){ | ||
| $event_layout = $rs->custom_seat_layout; | ||
| $atte = isset($atten['attend'])&&!empty($atten['attend'])?$atten['attend']:'0'; | ||
| if(!empty($rs->layout)){ | ||
| if(!empty($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 { | ||
| $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 { | ||
| $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); | ||
| $time_spec = array(); | ||
| $data_array = array(); | ||
| foreach ($dates as $rss) { | ||
| list($id,$date,$time) = explode('#', $rss); | ||
| $sTime = $date.' '.$time; | ||
| ... | ... | @@ -585,29 +580,34 @@ class Webservice_model extends CI_Model { |
| foreach ($data_array as $key => $value) { | ||
| $date_list[] = array('date'=>$key, 'time'=>$value); | ||
| } | ||
| $lang = $this->getUserLang($user_id); | ||
| $custDesc = ''; | ||
| if($rs->is_layout == 1 && !empty($pData = json_decode($rs->seat_pricing, TRUE))){ | ||
| if($lang == 'en'){ | ||
| $rs->event_description .= '<p>'.$pData['price_details'].' '.'(SAR '.$pData['price'].')'.'</p>'; | ||
| } | ||
| if($lang == 'ar'){ | ||
| $rs->event_description_ar .= '<p>'.$pData['price_details_ar'].' '.'(SAR '.$pData['price'].')'.'</p>'; | ||
| $cSymbol = $countryData['currency_symbol']; | ||
| if(isset($pData['price_details_'.$lang]) && !empty($pData['price_details_'.$lang])){ | ||
| $custDesc = '<p>'.$pData['price_details_'.$lang].' ('.$cSymbol.' '.$pData['price']*$rate.')</p>'; | ||
| } | ||
| } | ||
| $event_layouts = []; | ||
| 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); | ||
| $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); | ||
| $resData = array( | ||
| 'event_id'=>$rs->event_id, | ||
| 'name'=>($lang == 'en')?$rs->event_name:$rs->event_name_ar, | ||
| 'description'=>($lang == 'en')?$rs->event_description:$rs->event_description_ar, | ||
| 'name'=>$transData['event'], | ||
| 'description'=>$transData['description'], | ||
| 'rating'=>$rate, | ||
| 'total_attendees'=>$atte, | ||
| 'layout_image'=>$rs->layout, | ||
| ... | ... | @@ -620,32 +620,24 @@ class Webservice_model extends CI_Model { |
| 'date_list'=>$date_list, | ||
| 'classes'=>$event_layouts, | ||
| 'latitude'=>$rs->lat, | ||
| 'address_name'=>($lang == 'en')?$rs->address_name:$rs->address_name_ar, | ||
| 'address_name'=>$transData['venue'], | ||
| 'address'=>$rs->address, | ||
| 'longitude'=>$rs->lng | ||
| 'longitude'=>$rs->lng, | ||
| 'currency_symbol'=>$countryData['currency_symbol'] | ||
| ); | ||
| $res = array('status'=>1,'data'=>$resData); | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
| } | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
| } | ||
| } catch(Exception $e) { | ||
| $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
| } | ||
| return $res; | ||
| } | ||
| 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) { | ||
| $this->db->insert('customer_auth',array('user_id'=>$userId, 'auth_token'=>$auth_token)); | ||
| } | ||
| ... | ... | @@ -671,7 +663,6 @@ class Webservice_model extends CI_Model { |
| 'crlf' => "\r\n", | ||
| 'newline' => "\r\n" | ||
| )); | ||
| $ci->email->from('[email protected]', 'TimeOut'); | ||
| $ci->email->to($email); | ||
| $ci->email->cc('[email protected]'); | ||
| ... | ... | @@ -682,7 +673,6 @@ class Webservice_model extends CI_Model { |
| } | ||
| return $ci->email->send(); | ||
| } | ||
| function sendSMS($phone_no, $message) { | ||
| $phone_no = trim($phone_no); | ||
| ... | ... | @@ -690,13 +680,11 @@ class Webservice_model extends CI_Model { |
| if(empty($phone_no) && count($phone_no) < 10 && empty($message)){ | ||
| return; | ||
| } | ||
| $user = "eventstimeout"; | ||
| $senderid = "SMSCountry"; | ||
| $password = "timeout2030"; | ||
| $url = "http://www.smscountry.com/SMSCwebservice_Bulk.aspx"; | ||
| $message = urlencode($message); | ||
| if($ch = curl_init()){ | ||
| $ret = curl_setopt ($ch, CURLOPT_URL, $url); | ||
| curl_setopt ($ch, CURLOPT_POST, 1); | ||
| ... | ... | @@ -710,30 +698,22 @@ class Webservice_model extends CI_Model { |
| function get_category_list($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $where = ''; | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| if(isset($data['query'])) { | ||
| $where = ' AND event_category.category LIKE '."'%".$data['query'].'%'."'"; | ||
| } else { | ||
| $where = ''; | ||
| $where = ' AND TC.category_name LIKE '."'%".$data['query'].'%'."'"; | ||
| } | ||
| $lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | ||
| if($lang->language == 'ar') { | ||
| $cat_field = 'event_category.category_ar AS category_name'; | ||
| $cat_field .= ',event_category.category_image_ar AS category_image'; | ||
| } else { | ||
| $cat_field = 'event_category.category_en AS category_name'; | ||
| $cat_field .= ',event_category.category_image AS category_image'; | ||
| } | ||
| $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); | ||
| $sql = "SELECT TC.category_id,TC.category_name,TC.category_image | ||
| FROM translator_category AS TC | ||
| INNER JOIN event_category AS ECAT ON (ECAT.cat_id=TC.category_id) | ||
| WHERE ECAT.status = 1 AND TC.language_code='$lang' $where | ||
| GROUP BY ECAT.cat_id ORDER BY ECAT.priority"; | ||
| $result = $this->db->query($sql)->result(); | ||
| if(count($result) > 0){ | ||
| $res = array('status' => 1,'data' => array('category'=>$result)); | ||
| } else { | ||
| $res = array('status'=>1,'data' => []); | ||
| } | ||
| ... | ... | @@ -746,37 +726,25 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function add_favorites($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $res_count = $this->db->where('event_id',$data['event_id'])->where('user_id',$user_id)->get('favourite')->num_rows(); | ||
| $favoriteList = array('user_id'=>$user_id, 'event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | ||
| if($res_count > 0) { | ||
| $data=array('event_id'=>$data['event_id'], 'is_favorite'=>$data['is_favorite']); | ||
| $this->db->where('user_id',$user_id); | ||
| $this->db->where('event_id',$data['event_id']); | ||
| $id = $this->db->update('favourite',$data); | ||
| }else{ | ||
| $id = $this->db->insert('favourite',$favoriteList); | ||
| } | ||
| if($id) { | ||
| $res = array('status'=>1); | ||
| }else { | ||
| $res = array('status'=>0,'message'=>'Add Favorite failed please try again','code'=>'ER14'); | ||
| } | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
| } | ||
| ... | ... | @@ -786,24 +754,16 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function get_cities_list($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| // language | ||
| $lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | ||
| if($lang->language == 'ar') { | ||
| $region_name = 'region.name_ar'; | ||
| } else { | ||
| $region_name = 'region.name'; | ||
| } | ||
| // End | ||
| $result = $this->db->query("SELECT region.id AS city_id, $region_name AS city_name, region.region_icon AS city_image FROM region WHERE region.status = 1 GROUP BY region.name")->result(); | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $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(); | ||
| if(count($result)>0){ | ||
| $resultData = array(); | ||
| $resultData['cities'] = $result; | ||
| $res = array('status'=>1,'data'=>$resultData); | ||
| $res = array('status'=>1,'data'=>array('cities'=>$result)); | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
| } | ||
| ... | ... | @@ -816,32 +776,38 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function update_city($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| if($user_id > 0) { | ||
| if(isset($data['city_id']) && !empty($data['city_id'])){ | ||
| $re = $this->db->select('name')->where('id', $data['city_id'])->where('status', 1)->get('region')->row(); | ||
| $cityName = $re->name; | ||
| $re = $this->db->query("SELECT TREG.region_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' AND | ||
| REG.id='".$data['city_id']."' | ||
| GROUP BY REG.id")->row(); | ||
| $cityName = $re->region_name; | ||
| $cityId = $data['city_id']; | ||
| }else{ | ||
| $radius = 25; | ||
| $data = $this->db->query("SELECT id,name,status, (((acos(sin((".$data['latitude']."*pi()/180)) * sin((region_lat*pi()/180)) + cos((".$data['latitude']."*pi()/180)) * cos((region_lat*pi()/180)) * cos(((".$data['longitude']." - region_lng)*pi()/180))))*180/pi())*60*1.1515) as distance FROM region HAVING distance < ".$radius." AND status = '1' ORDER BY distance ASC LIMIT 1")->result_array(); | ||
| $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)){ | ||
| $cityId = $data[0]['id']; | ||
| $cityName = $data[0]['name']; | ||
| $cityId = $data['id']; | ||
| $cityName = $data['region_name']; | ||
| } | ||
| } | ||
| if(!empty($cityId)){ | ||
| $this->db->where('customer_id', $user_id); | ||
| $this->db->update('customer', array('city' => $cityId)); | ||
| $resultArray = array('city_id'=>$cityId,'city_name'=>$cityName); | ||
| $res = array('status'=>1, 'data'=>$resultArray); | ||
| $res = array('status'=>1, 'data'=>array('city_id'=>$cityId,'city_name'=>$cityName)); | ||
| }else { | ||
| $res = array('status'=>0,'message'=>'Update failed please try again','code'=>'ER15'); | ||
| } | ||
| ... | ... | @@ -854,32 +820,53 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function booking_summary($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $bookingId = $data['booking_id']; | ||
| $ticketDetails = $this->db->query("SELECT ticket_details FROM booking WHERE bookId = '$bookingId'")->row(); | ||
| $bookId = $data['booking_id']; | ||
| $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); | ||
| if(!empty($res)){ | ||
| $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'){ | ||
| $cat_filed = 'events.event_name AS event_name'; | ||
| $cat_filed .= ',venue.venue_name AS address_name'; | ||
| }else{ | ||
| $cat_filed = 'events.event_name_ar AS event_name'; | ||
| $cat_filed .= ',venue.venue_name_ar AS address_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){ | ||
| $settings = getSettings(); | ||
| $sql = "SELECT instruction FROM translator_policies WHERE language_code='$lang'"; | ||
| $settingsDetails = $this->db->query($sql)->row_array(); | ||
| $settingsDetails['contact_number'] = $settings['contact_number']; | ||
| $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']; | ||
| } | ||
| $resultData = array(); | ||
| $result['is_payment_required'] = ($result['is_payment_required'] == 1) ? true: false; | ||
| $resultData = array(); | ||
| $resultData = array_merge($settingsDetails, $result,!empty($kk)?$kk:[]); | ||
| $res = array('status'=>1,'data'=>$resultData); | ||
| } else { | ||
| ... | ... | @@ -894,7 +881,6 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function payment($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| ... | ... | @@ -917,7 +903,6 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function event_rating($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| ... | ... | @@ -943,13 +928,10 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function update_notification_email_status($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $notData = array('notification_status'=>$data['notification_status'], 'email_status'=>$data['email_status']); | ||
| $this->db->where('id', $user_id); | ||
| $this->db->where('status', 1); | ||
| ... | ... | @@ -969,9 +951,7 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| public function update_profile($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| $img_error = 0; | ||
| ... | ... | @@ -979,7 +959,6 @@ class Webservice_model extends CI_Model { |
| $post_data = $data; | ||
| unset($post_data['file']); | ||
| unset($post_data['auth_token']); | ||
| if(isset($data['email'])){ | ||
| $this->db->select('customer.email'); | ||
| $this->db->where('customer.email',$data['email']); | ||
| ... | ... | @@ -991,7 +970,6 @@ class Webservice_model extends CI_Model { |
| if($num > 0) | ||
| { | ||
| $res = array('status'=>0,'message'=>'Email address already exist','code'=>'ER32'); | ||
| return $res; | ||
| } | ||
| } | ||
| ... | ... | @@ -1023,7 +1001,6 @@ class Webservice_model extends CI_Model { |
| $res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32'); | ||
| } | ||
| } | ||
| if($img_error == 1) { | ||
| $this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.profile_image AS image,customer.gender,users.id AS userId, customer.city'); | ||
| $this->db->where('users.id',$user_id); | ||
| ... | ... | @@ -1036,7 +1013,6 @@ class Webservice_model extends CI_Model { |
| $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
| } | ||
| } | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
| } | ||
| ... | ... | @@ -1047,7 +1023,6 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function booking($data) { | ||
| try{ | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| ... | ... | @@ -1055,38 +1030,82 @@ class Webservice_model extends CI_Model { |
| $post_data = $data; | ||
| $post_data['customer_id'] = $user_id; | ||
| $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'; | ||
| unset($post_data['auth_token'],$post_data['has_payment']); | ||
| $post_data['status'] = '3'; | ||
| 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'; | ||
| $ymd = date('ymd'); | ||
| $squence = rand(1111,9999); | ||
| $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['booking_date'] = date('Y-m-d H:i:s'); | ||
| $rs = $this->db->insert('booking', $post_data); | ||
| $id = $this->db->insert_id(); | ||
| if($id){ | ||
| $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){ | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $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 | ||
| FROM booking AS BK | ||
| 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 event_date_time AS EDATE ON (EDATE.id=BK.event_date_id) | ||
| 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"; | ||
| $showTime = date("d'S F Y - h:i, (l)",strtotime($bkData['show_time'])); | ||
| $msgContent = "Hi, Your booking is confirmed for the event '". | ||
| $bkData['event_name']."' and show is on '".$showTime."'. | ||
| Booking ID ".$post_data['bookId']; | ||
| $message = "<html><body><p>".$msgContent."</p></body></html>"; | ||
| $template = getNotifTemplate(); | ||
| if(isset($template['booking_mail']) && !empty($template['booking_mail'])){ | ||
| $msgContent = str_replace( | ||
| ... | ... | @@ -1095,7 +1114,6 @@ class Webservice_model extends CI_Model { |
| $template['booking_mail']); | ||
| } | ||
| $this->send_mail($subject,$bkData['email'],$message); | ||
| if(isset($template['booking_sms']) && !empty($template['booking_sms'])){ | ||
| $msgContent = str_replace( | ||
| array('{:event_name}','{:booking_id}','{:time}'), | ||
| ... | ... | @@ -1103,6 +1121,20 @@ class Webservice_model extends CI_Model { |
| $template['booking_sms']); | ||
| } | ||
| $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 { | ||
| $res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37'); | ||
| ... | ... | @@ -1116,8 +1148,6 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function generateQR($data) { | ||
| return 'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'; | ||
| } | ||
| ... | ... | @@ -1140,30 +1170,29 @@ class Webservice_model extends CI_Model { |
| } else { | ||
| $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); | ||
| } | ||
| } catch(Exception $e) { | ||
| $res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); | ||
| } | ||
| return $res; | ||
| } | ||
| function favouritelist($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $lang = $this->getUserLang($user_id); | ||
| if($lang == 'ar') { | ||
| $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'; | ||
| } | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $rate = (!empty($countryData['conversion_rate']))?$countryData['conversion_rate']:1; | ||
| $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 | ||
| INNER JOIN events ON events.event_id=favourite.event_id | ||
| INNER JOIN venue ON venue.id=events.venue_id | ||
| ... | ... | @@ -1177,61 +1206,60 @@ class Webservice_model extends CI_Model { |
| favourite.user_id='$user_id' AND events.status=1 AND | ||
| event_date_time.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') | ||
| GROUP BY events.event_id")->result(); | ||
| if(empty($result)){ | ||
| return array('status'=>1,'data' => []); | ||
| } | ||
| foreach ($result AS $key => $rs) { | ||
| if(!empty($dates = explode(',',$rs->date_time))){ | ||
| $checkTime = 0; | ||
| foreach ($dates as $date) { | ||
| if(empty($date)){ | ||
| unset($result[$key]); | ||
| continue; | ||
| } | ||
| if(empty($date)){ unset($result[$key]); continue; } | ||
| $dArr = explode('#', $date); | ||
| if($dArr[1] == date("Y-m-d") && | ||
| $dArr[1].' '.$dArr[2] < date("Y-m-d H:i", strtotime('+15 minutes'))){ | ||
| $checkTime += 1; | ||
| } | ||
| } | ||
| if($checkTime == count($dates)){ | ||
| unset($result[$key]); | ||
| } | ||
| } else { | ||
| unset($result[$key]); | ||
| } | ||
| if($checkTime == count($dates)){ unset($result[$key]); } | ||
| } else { unset($result[$key]); } | ||
| } | ||
| if(($count = count($result)) > 0){ | ||
| $response = array(); | ||
| 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); | ||
| $price = min(array_column($pricelist, 'price')); | ||
| $price = min(array_column($pricelist, 'price')) * $rate; | ||
| } else { | ||
| $pricelist = json_decode($rs->layout_details, TRUE); | ||
| $price = min(array_column($pricelist, 'price')); | ||
| $price = min(array_column($pricelist, 'price')) * $rate; | ||
| } | ||
| } else { | ||
| $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( | ||
| 'event_id'=>$rs->event_id, | ||
| 'image'=>$rs->media_url, | ||
| 'attendees'=>$rs->attendees, | ||
| 'category'=>$rs->category, | ||
| 'name'=>$rs->event_name, | ||
| 'category'=>$transData['category'], | ||
| 'name'=>$transData['event'], | ||
| 'rating'=>$rs->rating, | ||
| 'location'=>$rs->location, | ||
| 'rate'=>$price, | ||
| 'location'=>$rs->location, | ||
| 'is_favorite'=>$rs->is_favorite === 'true'? true: false, | ||
| 'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false | ||
| 'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false, | ||
| 'currency_symbol'=>$countryData['currency_symbol'] | ||
| ); | ||
| array_push($response, $resData); | ||
| } | ||
| ... | ... | @@ -1254,7 +1282,6 @@ class Webservice_model extends CI_Model { |
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| 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(); | ||
| if($count > 0) { | ||
| if(isset($data['page'])) { | ||
| $page = $data['page']; | ||
| ... | ... | @@ -1263,14 +1290,13 @@ class Webservice_model extends CI_Model { |
| } | ||
| $page_limit = ($page - 1) * $per_page; | ||
| if($count > $page_limit) { | ||
| $lang = $this->getUserLang($user_id); | ||
| $lang = $this->getCountryData($user_id); | ||
| if($lang == 'en'){ | ||
| $cat_field = 'events.event_name AS event_name'; | ||
| }else{ | ||
| $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, | ||
| (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 { |
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $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) | ||
| WHERE BOK.customer_id='$user_id' AND BOK.status IN (0,1,2) AND | ||
| EVT.status='1'")->num_rows(); | ||
| INNER JOIN event_date_time AS EDT ON (EVT.event_id=EVT.event_id) | ||
| 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(isset($data['page'])) { | ||
| ... | ... | @@ -1316,29 +1343,33 @@ class Webservice_model extends CI_Model { |
| } | ||
| $page_limit = ($page - 1) * $per_page; | ||
| if($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'; | ||
| } | ||
| $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, | ||
| (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(); | ||
| // $data_arr = array(); | ||
| // foreach ($result as $value) { | ||
| // $data_arr[] = $value; | ||
| // $bookList = array_slice($data_arr, $page_limit, $per_page, false); | ||
| // } | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $sql = "SELECT booking.bookId AS booking_id,event_date_time.date, | ||
| translator_event.event_name,event_gallery.media_url AS event_image, | ||
| venue.location,event_date_time.time,booking.event_id, | ||
| 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 | ||
| FROM booking | ||
| INNER JOIN events ON booking.event_id = events.event_id | ||
| INNER JOIN event_date_time ON booking.event_date_id = event_date_time.id | ||
| INNER JOIN venue ON venue.id = events.venue_id | ||
| 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), | ||
| 'total'=>$count, | ||
| 'current_page'=>$page, | ||
| 'per_page'=>$per_page | ||
| ); | ||
| $response = array('bookings'=>$result,'meta'=>$meta); | ||
| $res = array('status'=>1,'data'=>$response); | ||
| } else { | ||
| $res = array('status'=>1,'data' => []); | ||
| ... | ... | @@ -1359,23 +1390,20 @@ class Webservice_model extends CI_Model { |
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $settings = getSettings(); | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $lang = $this->getUserLang($user_id); | ||
| $fields = 'privacy_policy_en AS privacy_policy, | ||
| terms_and_conditions_en AS terms_and_conditions,'; | ||
| if($lang == 'ar'){ | ||
| $fields = 'privacy_policy_ar AS privacy_policy, | ||
| terms_and_conditions_ar AS terms_and_conditions,'; | ||
| } | ||
| $sql = "SELECT privacy_policy,terms_and_conditions | ||
| FROM translator_policies WHERE language_code='$lang'"; | ||
| $setDetails = $this->db->query($sql)->row_array(); | ||
| $setDetails['contact_number'] = $settings['contact_number']; | ||
| $settingsDetails = $this->db->query("SELECT $fields contact_number FROM privacy_policy") | ||
| ->row_array(); | ||
| $sql = "SELECT notification_status, email_status FROM users WHERE id=".$user_id; | ||
| $notifDetails = $this->db->query($sql)->row_array(); | ||
| $notificationDetails = $this->db->query("SELECT notification_status, email_status | ||
| FROM users WHERE id = ".$user_id."") | ||
| ->row_array(); | ||
| if(count($settingsDetails)>0 && count($notificationDetails)>0){ | ||
| $resultData = array_merge($settingsDetails, $notificationDetails); | ||
| if(count($setDetails) > 0 && count($notifDetails) > 0){ | ||
| $resultData = array_merge($setDetails, $notifDetails); | ||
| $resultArray = array( | ||
| 'privacy_policy'=>$resultData['privacy_policy'], | ||
| 'terms_and_conditions'=>$resultData['terms_and_conditions'], | ||
| ... | ... | @@ -1415,19 +1443,32 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| function get_last_booking($data) { | ||
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $cat_feild = ''; | ||
| $lang = $this->getUserLang($user_id); | ||
| if($lang == 'en'){ | ||
| $cat_field = 'events.event_name AS event_name'; | ||
| }else{ | ||
| $cat_field = 'events.event_name_ar AS event_name'; | ||
| } | ||
| $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(); | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $sql = "SELECT IF(review.event_id = '','false','true') AS is_last_booking_rated, | ||
| 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, | ||
| 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){ | ||
| $resultData = array( | ||
| 'is_last_booking_rated'=>$result['is_last_booking_rated'] === 'true'? true: false, | ||
| ... | ... | @@ -1438,7 +1479,6 @@ class Webservice_model extends CI_Model { |
| 'amount'=>$result['amount'], | ||
| 'date'=>$result['date'] | ||
| ); | ||
| $res = array('status'=>1,'data'=>$resultData); | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
| ... | ... | @@ -1456,52 +1496,31 @@ class Webservice_model extends CI_Model { |
| try { | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| if($user_id > 0) { | ||
| $lang = $this->db->select('language')->where('customer_id', $user_id)->get('customer')->row(); | ||
| if($lang->language == 'ar') { | ||
| $loc_field = 'locality.locality_ar AS city_name'; | ||
| $cat_field = 'event_category.category_ar AS category'; | ||
| $cat_field .= ',event_category.category_image_ar AS category_image'; | ||
| $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"]]; | ||
| } else { | ||
| $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'"; | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $sql = "SELECT LOC.id AS city_id,TLOC.locality_name AS city_name | ||
| FROM locality AS LOC | ||
| INNER JOIN customer AS CUST ON (CUST.city=LOC.region_id) | ||
| INNER JOIN translator_locality AS TLOC ON (TLOC.locality_id=LOC.id) | ||
| WHERE CUST.customer_id='$user_id' AND LOC.status='1' AND TLOC.language_code='$lang' | ||
| GROUP BY LOC.id"; | ||
| $locality = $this->db->query($sql)->result(); | ||
| $category = $this->db->query("SELECT cat_id AS category_id, $cat_field | ||
| FROM event_category | ||
| WHERE status = 1 | ||
| ORDER BY event_category.priority")->result(); | ||
| $sql = "SELECT ECAT.cat_id AS category_id,TCAT.category_name AS category, | ||
| TCAT.category_image AS category_image | ||
| FROM event_category AS ECAT | ||
| 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(); | ||
| if(!EMPTY($locality)) { | ||
| $locality = $locality; | ||
| }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); | ||
| $locality = (!empty($locality))?$locality:array(); | ||
| $category = (!empty($category))?$category:array(); | ||
| if(!empty($locality) && !empty($category)){ | ||
| $res = array('status'=>1,'data'=>array('cities'=>$locality,'categories'=>$category)); | ||
| } else { | ||
| $res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); | ||
| } | ||
| ... | ... | @@ -1563,26 +1582,29 @@ class Webservice_model extends CI_Model { |
| if($user_id > 0) { | ||
| $per_page = 10; | ||
| $str = urldecode(strtolower($data['query'])); | ||
| $countryData = $this->getCountryData($user_id); | ||
| $lang = $countryData['language_code']; | ||
| $this->db->query("SET SESSION group_concat_max_len = 20000"); | ||
| $sql = "SELECT GROUP_CONCAT(DISTINCT CONCAT_WS('#',EDATE.id,EDATE.date,EDATE.time)) | ||
| AS date_time | ||
| FROM events AS EVT | ||
| 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_gallery AS IMG ON | ||
| (IMG.event_id=EVT.event_id AND IMG.media_type=0) | ||
| WHERE (EVT.event_name LIKE '%$str%' OR | ||
| EVT.event_name_ar LIKE '%$str%') AND | ||
| EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | ||
| VEN.status='1' AND IMG.status='1' AND EDATE.status='1' | ||
| GROUP BY EVT.event_id"; | ||
| LEFT JOIN event_gallery AS IMG ON (IMG.event_id=EVT.event_id AND | ||
| IMG.media_type=0 AND IMG.status='1' ) | ||
| WHERE EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | ||
| VEN.status='1' AND EDATE.status='1' AND | ||
| EVT.event_id IN (SELECT event_id FROM translator_event | ||
| WHERE event_name LIKE '%$str%' OR | ||
| event_description LIKE '%$str%' | ||
| GROUP BY EVT.event_id)"; | ||
| $resCount = $this->db->query($sql)->result(); | ||
| if(empty($resCount)){ | ||
| return array('status'=>1,'data'=>array('events'=>[],'meta'=>$meta)); | ||
| } | ||
| foreach ($resCount AS $key => $rs) { | ||
| if(!empty($dates = explode(',',$rs->date_time))){ | ||
| $checkTime = 0; | ||
| ... | ... | @@ -1603,42 +1625,36 @@ class Webservice_model extends CI_Model { |
| } else { | ||
| unset($resCount[$key]); | ||
| } | ||
| } | ||
| $count = count($resCount); | ||
| $page = (isset($data['page']))?$data['page']:1; | ||
| $page_limit = ($page - 1) * $per_page; | ||
| $meta = array('total_pages'=>ceil($count/$per_page),'total'=>$count, | ||
| 'current_page'=>$page,'per_page'=>$per_page); | ||
| 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; | ||
| $this->db->query("SET SESSION group_concat_max_len = 20000"); | ||
| $sql = "SELECT EVT.event_id,EVT.event_name,VEN.location, | ||
| IMG.media_url AS event_image, | ||
| $sql = "SELECT EVT.event_id,VEN.location,IMG.media_url AS event_image, | ||
| GROUP_CONCAT(DISTINCT CONCAT_WS('#',EDATE.id,EDATE.date,EDATE.time)) | ||
| AS date_time | ||
| AS date_time,TEVT.event_name | ||
| FROM events AS EVT | ||
| 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_gallery AS IMG ON | ||
| (IMG.event_id=EVT.event_id AND IMG.media_type=0) | ||
| WHERE (EVT.event_name LIKE '%$str%' OR | ||
| EVT.event_name_ar LIKE '%$str%') AND | ||
| EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | ||
| VEN.status='1' AND IMG.status='1' AND EDATE.status='1' | ||
| INNER JOIN translator_event AS TEVT ON (TEVT.event_id=EVT.event_id) | ||
| LEFT JOIN event_gallery AS IMG ON (IMG.event_id=EVT.event_id AND | ||
| IMG.media_type=0 AND IMG.status='1') | ||
| WHERE EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND | ||
| VEN.status='1' AND EDATE.status='1' AND | ||
| 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 | ||
| ORDER BY EVT.event_id DESC | ||
| LIMIT $limit"; | ||
| $result = $this->db->query($sql)->result(); | ||
| $result = $this->db->query($sql)->result(); | ||
| foreach ($result AS $key => $rs) { | ||
| if(!empty($dates = explode(',',$rs->date_time)) && count($dates) > 0){ | ||
| $checkTime = 0; | ||
| ... | ... | @@ -1657,7 +1673,6 @@ class Webservice_model extends CI_Model { |
| } | ||
| unset($result[$key]->date_time); | ||
| } | ||
| $res = array('status'=>1,'data'=>array('events'=>$result,'meta'=>$meta)); | ||
| } else { | ||
| $res = array('status'=>1,'data'=>array('events'=>[],'meta'=>$meta)); | ||
| ... | ... | @@ -1671,12 +1686,10 @@ class Webservice_model extends CI_Model { |
| return $res; | ||
| } | ||
| public function checkSeatAvailability($data = ''){ | ||
| $user_id = $data['user_id']; | ||
| $event_id = $data['event_id']; | ||
| $evtTimeId = $data['time_id']; | ||
| $user_id = $data['user_id']; | ||
| $event_id = $data['event_id']; | ||
| $evtTimeId = $data['time_id']; | ||
| $lyCapacity = array(); | ||
| $capacity = $usrBooked = $maxBooking = 0; | ||
| $sql = "SELECT EDATE.date,EDATE.time,EVT.custom_seat_layout,EVT.seat_pricing, | ||
| ... | ... | @@ -1689,41 +1702,34 @@ class Webservice_model extends CI_Model { |
| EDATE.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; | ||
| $evtSql = $this->db->query($sql); | ||
| $evtData = $evtSql->row_array(); | ||
| if(!empty($user_id)){ | ||
| if(!empty($user_id)){ | ||
| $sql = "SELECT SUM(BOK.no_of_ticket) AS bookCount | ||
| FROM booking AS BOK | ||
| 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 | ||
| EDATE.id='$evtTimeId' AND BOK.status IN (1,2)"; | ||
| $result = $this->db->query($sql)->row_array(); | ||
| $usrBooked = (!empty($result))?$result['bookCount']:0; | ||
| } | ||
| $maxBooking = $evtData['max_booking']-$usrBooked; | ||
| if($evtData['show_layout'] == 0){ | ||
| $lyout = json_decode($evtData['seat_pricing'],true); | ||
| $lyCapacity['price'] = $lyout['price']; | ||
| $lyCapacity['capacity'] = $lyout['capacity']; | ||
| } else { | ||
| $lyout = (!empty($evtData['custom_seat_layout'])) | ||
| ?json_decode($evtData['custom_seat_layout'],true) | ||
| :json_decode($evtData['layout_details'],true); | ||
| foreach($lyout AS $custLy) { | ||
| $lyCapacity[$custLy['color']] = array('price'=>$custLy['price'], | ||
| 'capacity'=>$custLy['capacity'], | ||
| 'weekend_price'=>$custLy['weekend_price']); | ||
| } | ||
| } | ||
| $sql = "SELECT BOOK.no_of_ticket,BOOK.ticket_details | ||
| FROM booking AS BOOK | ||
| 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'"; | ||
| if(!empty($result = $this->db->query($sql)->result_array())){ | ||
| foreach($result AS $value) { | ||
| if($evtData['show_layout'] == 0){ | ||
| ... | ... | @@ -1736,7 +1742,6 @@ class Webservice_model extends CI_Model { |
| } | ||
| } | ||
| } | ||
| $event_layouts = array(); | ||
| if($evtData['show_layout'] == 0){ | ||
| $capacity = $lyCapacity['capacity']; | ||
| ... | ... | @@ -1748,7 +1753,6 @@ class Webservice_model extends CI_Model { |
| foreach($lyCapacity AS $block => $sData) { | ||
| $capacity = $sData['capacity']; | ||
| $lyCapacity[$block]['capacity'] = ($capacity < $maxBooking)? $capacity : $maxBooking; | ||
| $event_layouts[] = array('rate' => $lyCapacity[$block]['price'], | ||
| 'class_name' => $block, | ||
| 'max_ticket' => $lyCapacity[$block]['capacity']); | ||
| ... | ... | @@ -1759,32 +1763,41 @@ class Webservice_model extends CI_Model { |
| public function sync_contacts($data){ | ||
| $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)){ | ||
| return $respArr; | ||
| } | ||
| $phNumbers = ''; | ||
| foreach($data['contacts'] AS $key => $number) { | ||
| $number = preg_replace('/\D/', '', $number); | ||
| $eCond = ($key != count($data['contacts'])-1)?' OR ':''; | ||
| if(strlen($number) > 10){ | ||
| $phNumbers .= " phone LIKE '%".substr($number, strlen($number)-10)."' ".$eCond; | ||
| if(strlen($number) > 9){ | ||
| $phNumbers .= " phone LIKE '%".substr($number, strlen($number)-9)."' ".$eCond; | ||
| } else { | ||
| $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'))"); | ||
| if(!empty($result) && !empty($result = $result->result_array())){ | ||
| $respArr['status'] = 1; | ||
| $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) | ||
| 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; | ||
| if(!empty($result) && !empty($result = $result->result_array())){ | ||
| $respArr['data'] = $result; | ||
| }else{ | ||
| $respArr['message'] = 'No Data Found'; | ||
| } | ||
| return $respArr; | ||
| } | ||
| public function update_friend_request($data){ | ||
| $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; | ||
| } | ||
| ... | ... | @@ -1809,10 +1822,11 @@ class Webservice_model extends CI_Model { |
| public function get_friend_requests($data){ | ||
| $respArr = array('status'=>0,'code'=>'918','message'=>'No Request for you'); | ||
| $user_id = $this->auth_token_get($data['auth_token']); | ||
| $this->db->select("name,phone,profile_image"); | ||
| $this->db->join('customer','customer.customer_id = chats.to_user'); | ||
| $result=$this->db->get_where('chats',array('to_user'=>$user_id,'type'=>'0'))->result_array(); | ||
| if(!empty($result)){ | ||
| $result = $this->db->query("SELECT CUST.name,CUST.phone,CUST.profile_image,CUST.customer_id | ||
| FROM customer AS CUST | ||
| INNER JOIN chats AS CHT ON (CUST.customer_id = CHT.from_user) | ||
| WHERE type='0' AND to_user='".$user_id."'"); | ||
| if(!empty($result) && !empty($result = $result->result())){ | ||
| $respArr['status'] = 1; | ||
| $respArr['data'] = $result; | ||
| } | ||
| ... | ... | @@ -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(); | ||
| if(!empty($result)){ | ||
| foreach ($result as $key => $value) { | ||
| if($value['to_user'] == $user_id && $value['type'] == 0){ | ||
| if($value['type'] == 0){ | ||
| continue; | ||
| } | ||
| $this->db->select("name,phone,profile_image"); | ||
| $cust = $this->db->get_where('customer',array('customer_id'=>$value['to_user'])); | ||
| $fromUsrId = ''; | ||
| 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())){ | ||
| $custData[] = $cust; | ||
| } | ||
| ... | ... | @@ -1840,8 +1862,111 @@ class Webservice_model extends CI_Model { |
| 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