Commit 48b12131 by Tobin

dc

parent b61980c6
...@@ -20,7 +20,9 @@ if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { ...@@ -20,7 +20,9 @@ if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
class Api extends CI_Controller { class Api extends CI_Controller {
var $auth_token; var $auth_token;
private $cipher = "AES-256-CBC"; private $cipher = "aes-256-cbc";
private $local_iv = "9H77F2KL7KRF4W51";
private $local_key = "af5b2a1h6947gt8fd045k78s2ah5609f";
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
date_default_timezone_set("Asia/Riyadh"); date_default_timezone_set("Asia/Riyadh");
...@@ -31,8 +33,8 @@ class Api extends CI_Controller { ...@@ -31,8 +33,8 @@ class Api extends CI_Controller {
if($method == 'profile') { if($method == 'profile') {
$data = $_POST; $data = $_POST;
} }
if (isset(apache_request_headers()['Auth'])) { if (isset(apache_request_headers()['Auth']) || isset(apache_request_headers()['auth'])) {
$this->auth_token = apache_request_headers()['Auth']; $this->auth_token = (isset(apache_request_headers()['Auth']))?apache_request_headers()['Auth']:apache_request_headers()['auth'];
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
} }
$res = $this->Validation_model->validation_check($method, $data); $res = $this->Validation_model->validation_check($method, $data);
...@@ -47,12 +49,11 @@ class Api extends CI_Controller { ...@@ -47,12 +49,11 @@ class Api extends CI_Controller {
$res = $this->Validation_model->validation_check('login',array('email_id'=>'adarsh')); $res = $this->Validation_model->validation_check('login',array('email_id'=>'adarsh'));
} }
public function response($data) { public function response($data='') {
$result = array( $result = array('code'=>1,'message'=>'Success');
'code' => 1, if(!empty($data)){
'message' => 'Success', $result['responseResult'] = $data;
'responseResult' =>$data }
);
print json_encode($result);exit; print json_encode($result);exit;
} }
...@@ -394,10 +395,7 @@ class Api extends CI_Controller { ...@@ -394,10 +395,7 @@ class Api extends CI_Controller {
if($noCard == 0){ if($noCard == 0){
$pText .= '11111100000|'.$cardNo.'|'.$expMonth.'|'.$expYear.'|'.$cvv.'|'.$holder.'|'.$cardType.'||'; $pText .= '11111100000|'.$cardNo.'|'.$expMonth.'|'.$expYear.'|'.$cvv.'|'.$holder.'|'.$cardType.'||';
} else { } else {
// No Card Payment Method Logic. // Provide Card Details Manually in Bayanpay Payment gateway.
// $holder = 'Basanta Mahunta'; $cardType = 'MasterCard'; $cardNo = '5111111111111118';
// $cvv = '100'; $expMonth = '06'; $expYear = '2022';
} }
} }
$pText .= '1110000|'.$last_id.'|'.$event_id.'|'.$booking_id.'||'; $pText .= '1110000|'.$last_id.'|'.$event_id.'|'.$booking_id.'||';
...@@ -468,7 +466,7 @@ class Api extends CI_Controller { ...@@ -468,7 +466,7 @@ class Api extends CI_Controller {
} }
if(!empty($transaction_id) && !empty($last_id)){ if(!empty($transaction_id) && !empty($last_id)){
$this->Api_model->update_payment($response,$transaction_id,$last_id,'1') ; $this->Api_model->update_payment($response,$transaction_id,$last_id,'1');
} }
if(!empty($booking_id)){ if(!empty($booking_id)){
...@@ -606,7 +604,10 @@ class Api extends CI_Controller { ...@@ -606,7 +604,10 @@ class Api extends CI_Controller {
empty($resp->txnCardDetails) || count($resp->txnCardDetails) <= 0){ empty($resp->txnCardDetails) || count($resp->txnCardDetails) <= 0){
$this->errorResponse('893','No Data Found'); $this->errorResponse('893','No Data Found');
} }
$this->response(array('saved_cards'=>$resp->txnCardDetails));
$cardData = json_encode(json_decode(json_encode($resp->txnCardDetails),true));
$resp = $this->encrypt($cardData,$this->local_key,$this->local_iv);
$this->response(array('saved_cards'=>$resp));
} }
function encryptePayData($merchant_iv='',$merchant_key='',$plainText='') { function encryptePayData($merchant_iv='',$merchant_key='',$plainText='') {
...@@ -644,21 +645,46 @@ class Api extends CI_Controller { ...@@ -644,21 +645,46 @@ class Api extends CI_Controller {
return ''; return '';
} }
if (in_array($this->cipher, openssl_get_cipher_methods())) { if (in_array($this->cipher, openssl_get_cipher_methods())) {
$ciphertext = openssl_encrypt($plainText, $this->cipher, $this->key, $options=0, $this->iv); $ciphertext = openssl_encrypt($plainText,$this->cipher,$mKey,$options=0,$mIv);
return $ciphertext; return $ciphertext;
} }
} }
public function decrypt($encText='',$mKey='',$mIv='') { public function decrypt($encText='',$mKey='',$mIv='') {
if(empty($plainText) || empty($mKey) || empty($mIv)){ if(empty($encText) || empty($mKey) || empty($mIv)){
return ''; return '';
} }
if (in_array($this->cipher, openssl_get_cipher_methods())) { if (in_array($this->cipher, openssl_get_cipher_methods())) {
$original_plaintext = openssl_decrypt($encText, $this->cipher, $this->key, $options=0, $this->iv); $original_plaintext = openssl_decrypt($encText,$this->cipher,$mKey,$options=0,$mIv);
return $original_plaintext; return $original_plaintext;
} }
} }
public function addCard(){
$data = (array) json_decode(file_get_contents('php://input'));
// $dmyData = '{"auth_token":"cc731b6bd572eb452d85c96aaec77898","cardNumber":"5111111111111118",
// "expMonthYear":"0622","cardHolderName":"John","cvv":"100","cardType":"MasterCard"}';
// $data['requestData'] = $this->encrypt($dmyData,$this->local_key,$this->local_iv);
$settings = getSettings();
$merchant_iv = $settings['merchant_iv'];
$merchant_key = $settings['merchant_key'];
$reqData = $this->decrypt($data['requestData'],$this->local_key,$this->local_iv);
if(empty($reqData) || empty($reqData=json_decode($reqData,true))){
redirect($redUrl.'failure');
}
$payData = array('auth_token'=>$reqData['auth_token'],'amount'=>'1','booking_id'=>'ADD_CARD');
$res = $this->Api_model->payNow($payData);
if($res['status']==1){
unset($reqData['auth_token']);
$this->paymentGateway(1,$res['transaction_id'],'test','ADD_CARD',$res['custData'],$reqData);
}else{
redirect($redUrl.'failure');
}
}
/*================ START : Checker API ================*/ /*================ START : Checker API ================*/
public function checker_bookingDetails(){ public function checker_bookingDetails(){
......
...@@ -22,7 +22,7 @@ class Booking extends CI_Controller { ...@@ -22,7 +22,7 @@ class Booking extends CI_Controller {
$template['page_head'] = "Booking Management"; $template['page_head'] = "Booking Management";
$provider_id = ($this->session->userdata('user_type')==2)?$this->session->userdata('id'):''; $provider_id = ($this->session->userdata('user_type')==2)?$this->session->userdata('id'):'';
$template['booking_data'] = $this->Booking_model->getBookingData('',$provider_id,'0,1,2,3,5'); $template['booking_data'] = $this->Booking_model->getBookingData('',$provider_id,'0,1,2,3,5,6');
$this->load->view('template',$template); $this->load->view('template',$template);
} }
...@@ -35,7 +35,7 @@ class Booking extends CI_Controller { ...@@ -35,7 +35,7 @@ class Booking extends CI_Controller {
$booking_id = (!is_numeric($_POST['booking_id']))? $booking_id = (!is_numeric($_POST['booking_id']))?
decode_param($_POST['booking_id']):$_POST['booking_id']; decode_param($_POST['booking_id']):$_POST['booking_id'];
$view_all = (isset($_POST['view_all'])&&$_POST['view_all'] != '')?$_POST['view_all']:'0,1,2,3,5'; $view_all = (isset($_POST['view_all'])&&$_POST['view_all'] != '')?$_POST['view_all']:'0,1,2,3,5,6';
$provider_id = ($this->session->userdata('user_type')==2)?$this->session->userdata('id'):''; $provider_id = ($this->session->userdata('user_type')==2)?$this->session->userdata('id'):'';
$bookData['bookData'] = $this->Booking_model->getBookingData($booking_id,$provider_id,$view_all); $bookData['bookData'] = $this->Booking_model->getBookingData($booking_id,$provider_id,$view_all);
...@@ -48,10 +48,11 @@ class Booking extends CI_Controller { ...@@ -48,10 +48,11 @@ class Booking extends CI_Controller {
if(!isset($_POST) || !isset($_POST['booking_id']) || empty($_POST['booking_id'])){ if(!isset($_POST) || !isset($_POST['booking_id']) || empty($_POST['booking_id'])){
echo json_encode(array('status'=>'0'));exit; echo json_encode(array('status'=>'0'));exit;
} }
$status = (isset($_POST['status']) && $_POST['status'] != '')?$_POST['status']:'1';
$booking_id = decode_param($_POST['booking_id']); $booking_id = decode_param($_POST['booking_id']);
$resp = $this->Booking_model->changeStatus($booking_id,'4'); $resp = $this->Booking_model->changeStatus($booking_id,$status);
if($resp){ if($resp){
echo json_encode(array('status'=>'1'));exit; echo json_encode(array('status'=>'1','data'=>array('booking_id'=>$_POST['booking_id'])));exit;
} }
echo json_encode(array('status'=>'0'));exit; echo json_encode(array('status'=>'0'));exit;
} }
......
...@@ -95,6 +95,7 @@ class Event extends CI_Controller { ...@@ -95,6 +95,7 @@ class Event extends CI_Controller {
} }
$_POST['has_payment'] = (isset($_POST['has_payment']) && $_POST['has_payment'] == 1)?'1':'0'; $_POST['has_payment'] = (isset($_POST['has_payment']) && $_POST['has_payment'] == 1)?'1':'0';
$_POST['approve_booking'] = (isset($_POST['approve_booking']) && $_POST['approve_booking']==1)?'1':'0';
$_POST['seat_pricing'] = $_POST['custom_seat_layout'] = ''; $_POST['seat_pricing'] = $_POST['custom_seat_layout'] = '';
if(isset($_POST['fare_type']) && $_POST['fare_type'] == 1){ if(isset($_POST['fare_type']) && $_POST['fare_type'] == 1){
...@@ -109,7 +110,7 @@ class Event extends CI_Controller { ...@@ -109,7 +110,7 @@ class Event extends CI_Controller {
'weekend_price'=>$_POST['weekend_price'][$i]); 'weekend_price'=>$_POST['weekend_price'][$i]);
} }
$_POST['custom_seat_layout'] = json_encode($cstmSeatLayout); $_POST['custom_seat_layout'] = json_encode($cstmSeatLayout);
} else if (isset($_POST['price']) && !empty($_POST['price']) && } else if (isset($_POST['price']) && $_POST['price'] != '' &&
isset($_POST['capacity']) && !empty($_POST['capacity'])){ isset($_POST['capacity']) && !empty($_POST['capacity'])){
$seatPriceArr = array('price'=>$_POST['price'],'capacity'=>$_POST['capacity']); $seatPriceArr = array('price'=>$_POST['price'],'capacity'=>$_POST['capacity']);
foreach($language AS $lang) { foreach($language AS $lang) {
...@@ -129,6 +130,7 @@ class Event extends CI_Controller { ...@@ -129,6 +130,7 @@ class Event extends CI_Controller {
'category_id'=>$_POST['category_id'], 'category_id'=>$_POST['category_id'],
'provider_id'=>$provider, 'provider_id'=>$provider,
'max_booking'=>$_POST['max_booking'], 'max_booking'=>$_POST['max_booking'],
'approve_booking'=>$_POST['approve_booking'],
'has_payment'=>$_POST['has_payment'], 'has_payment'=>$_POST['has_payment'],
'seat_pricing'=>$_POST['seat_pricing'], 'seat_pricing'=>$_POST['seat_pricing'],
'custom_seat_layout'=>$_POST['custom_seat_layout']); 'custom_seat_layout'=>$_POST['custom_seat_layout']);
...@@ -276,7 +278,9 @@ class Event extends CI_Controller { ...@@ -276,7 +278,9 @@ class Event extends CI_Controller {
$errMsg = 'Provide Proper Layout details'; $errMsg = 'Provide Proper Layout details';
} }
$_POST['has_payment'] = (isset($_POST['has_payment']) && $_POST['has_payment'] == 1)?'1':'0'; $_POST['has_payment'] = (isset($_POST['has_payment']) && $_POST['has_payment']==1)?'1':'0';
$_POST['approve_booking'] = (isset($_POST['approve_booking']) && $_POST['approve_booking']==1)?'1':'0';
$_POST['seat_pricing'] = $_POST['custom_seat_layout'] = ''; $_POST['seat_pricing'] = $_POST['custom_seat_layout'] = '';
if(isset($_POST['fare_type']) && $_POST['fare_type'] == 1){ if(isset($_POST['fare_type']) && $_POST['fare_type'] == 1){
$cstmSeatLayout = array(); $cstmSeatLayout = array();
...@@ -290,7 +294,7 @@ class Event extends CI_Controller { ...@@ -290,7 +294,7 @@ class Event extends CI_Controller {
'weekend_price'=>$_POST['weekend_price'][$i]); 'weekend_price'=>$_POST['weekend_price'][$i]);
} }
$_POST['custom_seat_layout'] = json_encode($cstmSeatLayout); $_POST['custom_seat_layout'] = json_encode($cstmSeatLayout);
} else if(isset($_POST['price']) && !empty($_POST['price']) && } else if(isset($_POST['price']) && $_POST['price'] != '' &&
isset($_POST['capacity']) && !empty($_POST['capacity'])){ isset($_POST['capacity']) && !empty($_POST['capacity'])){
$seatPriceArr = array('price'=>$_POST['price'],'capacity'=>$_POST['capacity']); $seatPriceArr = array('price'=>$_POST['price'],'capacity'=>$_POST['capacity']);
foreach($language AS $lang) { foreach($language AS $lang) {
...@@ -312,6 +316,7 @@ class Event extends CI_Controller { ...@@ -312,6 +316,7 @@ class Event extends CI_Controller {
'max_booking'=>$_POST['max_booking'], 'max_booking'=>$_POST['max_booking'],
'has_payment'=>$_POST['has_payment'], 'has_payment'=>$_POST['has_payment'],
'seat_pricing'=>$_POST['seat_pricing'], 'seat_pricing'=>$_POST['seat_pricing'],
'approve_booking'=>$_POST['approve_booking'],
'custom_seat_layout'=>$_POST['custom_seat_layout']); 'custom_seat_layout'=>$_POST['custom_seat_layout']);
$languageArr = array(); $languageArr = array();
foreach($language AS $lang) { foreach($language AS $lang) {
......
...@@ -132,7 +132,7 @@ class Webservice extends CI_Controller { ...@@ -132,7 +132,7 @@ class Webservice extends CI_Controller {
print json_encode($result); print json_encode($result);
} }
public function successResponse($data) { public function successResponse($data='') {
$result = array( $result = array(
'status' => 'success', 'status' => 'success',
); );
...@@ -580,5 +580,17 @@ class Webservice extends CI_Controller { ...@@ -580,5 +580,17 @@ class Webservice extends CI_Controller {
$this->errorResponse($res['code'],$res['message']); $this->errorResponse($res['code'],$res['message']);
} }
} }
public function update_user_visibility(){
$data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->update_user_visibility($data);
if($res['status'] != 0){
$this->successResponse();
} else {
$this->errorResponse($res['code'],$res['message']);
}
}
} }
?> ?>
...@@ -8,6 +8,7 @@ class Api_model extends CI_Model { ...@@ -8,6 +8,7 @@ class Api_model extends CI_Model {
public function login($data){ public function login($data){
try{ try{
$res = array('status'=>0,'message'=>'Something went wrong','code'=>'ER07');
$this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.profile_image $this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.profile_image
AS image,customer.gender,users.id AS userId,customer.profile_city AS city,customer.dob,customer.email_verified'); AS image,customer.gender,users.id AS userId,customer.profile_city AS city,customer.dob,customer.email_verified');
$this->db->where('users.status',1); $this->db->where('users.status',1);
...@@ -43,19 +44,23 @@ class Api_model extends CI_Model { ...@@ -43,19 +44,23 @@ class Api_model extends CI_Model {
try{ try{
$email = $data['email_id']; $email = $data['email_id'];
$phone = preg_replace('/\D/', '', $data['phone']); $phone = preg_replace('/\D/', '', $data['phone']);
$res_count = $phone_code = preg_replace('/\D/', '', $data['phone_code']);
$this->db->query("SELECT * FROM customer
$sql = "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 (customer.email = '$email' OR
(customer.email = '$email' OR customer.phone LIKE '%$phone')")->row(); (customer.phone_code='$phone_code' AND customer.phone LIKE '%$phone'))";
$res_count = $this->db->query($sql)->row();
if(count($res_count) > 0) { if(count($res_count) > 0) {
if($res_count->email == $data['email_id'] && $res_count->phone == $data['phone']){ if($res_count->email == $data['email_id'] && $res_count->phone == $data['phone']){
$res = array('status'=>0,'message'=>'Already have an account with email id and phone no. Please login','code'=>'ER12'); return array('status'=>0,'message'=>'Already have an account with email id and phone no. Please login','code'=>'ER12');
} else if($res_count->email == $data['email_id']){ } else if($res_count->email == $data['email_id']){
$res = array('status'=>0,'message'=>'Email id already exists','code'=>'ER09'); return array('status'=>0,'message'=>'Email id already exists','code'=>'ER09');
} else if(strpos($res_count->phone,$data['phone']) !== false) { } else if(strpos($res_count->phone,$data['phone'])!==false||$res_count->phone==$data['phone']){
$res = array('status'=>0,'message'=>'Phone no already exists','code'=>'ER10'); return array('status'=>0,'message'=>'Phone no already exists','code'=>'ER10');
}else{
return array('status'=>0,'message'=>'Something went wrong','code'=>'ER07');
} }
} else { } else {
$unique_id = uniqid().time(); $unique_id = uniqid().time();
...@@ -67,14 +72,8 @@ class Api_model extends CI_Model { ...@@ -67,14 +72,8 @@ class Api_model extends CI_Model {
$id = $this->db->insert_id(); $id = $this->db->insert_id();
if($id) { if($id) {
if(strpos($data['phone'],'+') === true){
$data['phone'] = str_replace('+','',$data['phone']);
}
if(strpos($data['phone'],'966') !== true){
$data['phone'] = '966'.$data['phone'];
}
$customer_data = array('customer_id'=>$id,'phone'=>$data['phone'], $customer_data = array('customer_id'=>$id,'phone'=>$data['phone'],
'phone_code'=>$data['phone_code'],
'email_verified'=>'0','email'=>$data['email_id'], 'email_verified'=>'0','email'=>$data['email_id'],
'name'=>$data['name'],'confirm_link'=>$unique_id); 'name'=>$data['name'],'confirm_link'=>$unique_id);
...@@ -97,7 +96,7 @@ class Api_model extends CI_Model { ...@@ -97,7 +96,7 @@ class Api_model extends CI_Model {
$this->send_mail($subject,$email_id,$message); $this->send_mail($subject,$email_id,$message);
$res = array('status'=>1,'data'=>''); return array('status'=>1,'data'=>'');
// $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',$id); // $this->db->where('users.id',$id);
...@@ -113,13 +112,12 @@ class Api_model extends CI_Model { ...@@ -113,13 +112,12 @@ class Api_model extends CI_Model {
// $res = array('status'=>0,'message'=>'No record found','code'=>'ER13'); // $res = array('status'=>0,'message'=>'No record found','code'=>'ER13');
// } // }
} else { } else {
$res = array('status'=>0,'message'=>'Registration failed please try again','code'=>'ER11'); return array('status'=>0,'message'=>'Registration failed please try again','code'=>'ER11');
} }
} }
} catch(Exception $e) { } catch(Exception $e) {
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06'); return array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06');
} }
return $res;
} }
function send_mail($subject,$email,$message,$attach=null) { function send_mail($subject,$email,$message,$attach=null) {
...@@ -148,13 +146,16 @@ class Api_model extends CI_Model { ...@@ -148,13 +146,16 @@ class Api_model extends CI_Model {
function forgot($data) { function forgot($data) {
try{ try{
$settings = getSettings();
$redUrl = $settings['web_base_url'];
$res_count = $this->db->where('email',$data['email_id'])->get('customer')->num_rows(); $res_count = $this->db->where('email',$data['email_id'])->get('customer')->num_rows();
if($res_count > 0) { if($res_count > 0) {
$unique_id = uniqid().time(); $unique_id = uniqid().time();
$this->db->where('email',$data['email_id'])->update('customer',array('reset_key'=>$unique_id)); $this->db->where('email',$data['email_id'])->update('customer',array('reset_key'=>$unique_id));
$subject = "TimeOut: Forgot Password"; $subject = "TimeOut: Forgot Password";
$url = 'https://timeout.sa/staging/forgot/?reset_key='.$unique_id; $url = $redUrl.'forgot?reset_key='.$unique_id;
$msgContent = "Hi, Welcome to TimeOut. Please use this link $msgContent = "Hi, Welcome to TimeOut. Please use this link
for reset your password: ".$url; for reset your password: ".$url;
$message = "<html><body><p>".$msgContent."</p></body></html>"; $message = "<html><body><p>".$msgContent."</p></body></html>";
...@@ -227,11 +228,12 @@ class Api_model extends CI_Model { ...@@ -227,11 +228,12 @@ class Api_model extends CI_Model {
function getCountry() { function getCountry() {
try { try {
$rs = $this->db->query("SELECT language_code,country_id,country_name,country_code, $rs = $this->db->query("SELECT CTRY.language_code,CTRY.country_id,CTRY.country_name,
language,currency,currency_symbol,conversion_rate CTRY.country_code,CTRY.language,CTRY.currency,CTRY.currency_symbol,
FROM country CTRY.conversion_rate,CTRY.phone_code
WHERE status = 1 FROM country AS CTRY
ORDER BY country_name")->result(); WHERE CTRY.status = 1
ORDER BY CTRY.country_name")->result();
if(count($rs) > 0) { if(count($rs) > 0) {
$res = array('status'=>1,'data'=>$rs); $res = array('status'=>1,'data'=>$rs);
} else { } else {
...@@ -393,7 +395,7 @@ class Api_model extends CI_Model { ...@@ -393,7 +395,7 @@ class Api_model extends CI_Model {
JOIN venue ON venue.id=events.venue_id JOIN venue ON venue.id=events.venue_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.media_type=0 event_gallery.media_type=0
WHERE customer_id='$user_id' AND booking.status IN(0,1,2) WHERE customer_id='$user_id' AND booking.status IN(0,1,2,6)
GROUP BY booking.id ORDER BY booking.id DESC LIMIT 10"; GROUP BY booking.id ORDER BY booking.id DESC LIMIT 10";
$result = $this->db->query($sql)->result_array(); $result = $this->db->query($sql)->result_array();
...@@ -450,8 +452,6 @@ class Api_model extends CI_Model { ...@@ -450,8 +452,6 @@ class Api_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) {
$res_count = $this->db->where('bookId',$data['bookingCode'])->where('status',1)->get('booking')->num_rows();
if($res_count > 0) {
$rs = $this->db->where('bookId',$data['bookingCode'])->update('booking',array('status'=>0)); $rs = $this->db->where('bookId',$data['bookingCode'])->update('booking',array('status'=>0));
if($rs) { if($rs) {
$res = array('status'=>1,'data'=>null); $res = array('status'=>1,'data'=>null);
...@@ -459,9 +459,6 @@ class Api_model extends CI_Model { ...@@ -459,9 +459,6 @@ class Api_model extends CI_Model {
$res = array('status'=>0,'message'=>'Cancel submission failed','code'=>'ER25'); $res = array('status'=>0,'message'=>'Cancel submission failed','code'=>'ER25');
} }
} else { } else {
$res = array('status'=>0,'message'=>'Invalid booking code','code'=>'ER24');
}
} else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }
...@@ -598,7 +595,6 @@ class Api_model extends CI_Model { ...@@ -598,7 +595,6 @@ class Api_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) {
$post_data = $data; $post_data = $data;
$status = (isset($post_data['has_payment']) && $post_data['has_payment'] == 0)?'1':'3'; $status = (isset($post_data['has_payment']) && $post_data['has_payment'] == 0)?'1':'3';
...@@ -609,15 +605,25 @@ class Api_model extends CI_Model { ...@@ -609,15 +605,25 @@ class Api_model extends CI_Model {
$post_data['booking_date'] = date('Y-m-d H:i:s'); $post_data['booking_date'] = date('Y-m-d H:i:s');
$post_data['ticket_details'] = json_encode($post_data['ticket_details']); $post_data['ticket_details'] = json_encode($post_data['ticket_details']);
if(!isset($post_data['amount']) || $post_data['amount'] == ''){
$post_data['amount'] = 0;
}
$evtData = $this->db->get_where('events',array('event_id'=>$post_data['event_id']));
$evtData = $evtData->row_array();
if(!empty($evtData) && isset($evtData['approve_booking']) && $evtData['approve_booking']=='1'){
$post_data['status'] = '6';
}
$promocodeData = array(); $promocodeData = array();
if(isset($post_data['promocode_id']) && !empty($post_data['promocode_id']) && if(isset($post_data['promocode_id']) && !empty($post_data['promocode_id']) &&
isset($post_data['redeem_amount']) && !empty($post_data['redeem_amount'])){ isset($post_data['redeem_amount']) && !empty($post_data['redeem_amount'])){
$status = ($post_data['status'] == '1')?1:0; $promoStatus = ($post_data['status'] == '1')?1:0;
$promocodeData = array('user_id'=>$user_id,'booking_id'=>$post_data['bookId'], $promocodeData = array('user_id'=>$user_id,'booking_id'=>$post_data['bookId'],
'promocode_id'=>$post_data['promocode_id'], 'promocode_id'=>$post_data['promocode_id'],
'redeem_amount'=>$post_data['redeem_amount'], 'redeem_amount'=>$post_data['redeem_amount'],
'created_date'=>date('Y-m-d H:i:s'),'status'=>$status); 'created_date'=>date('Y-m-d H:i:s'),'status'=>$promoStatus);
} }
unset($post_data['auth_token'],$post_data['has_payment'], unset($post_data['auth_token'],$post_data['has_payment'],
$post_data['promocode_id'],$post_data['redeem_amount']); $post_data['promocode_id'],$post_data['redeem_amount']);
...@@ -1100,7 +1106,7 @@ class Api_model extends CI_Model { ...@@ -1100,7 +1106,7 @@ class Api_model extends CI_Model {
INNER JOIN event_date_time ON events.event_id=event_date_time.event_id $case INNER JOIN event_date_time ON events.event_id=event_date_time.event_id $case
WHERE events.status = 1 AND event_date_time.status='1' $where WHERE events.status = 1 AND event_date_time.status='1' $where
GROUP BY events.event_id"; GROUP BY events.event_id";
$count = $this->db->query()->num_rows($sql); $count = $this->db->query($sql)->num_rows();
if(isset($data['venue_id']) && !empty($data['venue_id'])) { if(isset($data['venue_id']) && !empty($data['venue_id'])) {
$where .= " AND locality.id ='".$data['venue_id']."'"; $where .= " AND locality.id ='".$data['venue_id']."'";
...@@ -1332,8 +1338,7 @@ class Api_model extends CI_Model { ...@@ -1332,8 +1338,7 @@ class Api_model extends CI_Model {
if(empty($last_id)){ if(empty($last_id)){
return; return;
} }
$this->db->update('transaction', $this->db->update('transaction',array('transaction_id'=>$transactionid,
array('transaction_id'=>$transactionid,
'transaction_response'=>json_encode($response), 'transaction_response'=>json_encode($response),
'status'=>$status), 'status'=>$status),
array('id'=>$last_id)); array('id'=>$last_id));
...@@ -1341,22 +1346,21 @@ class Api_model extends CI_Model { ...@@ -1341,22 +1346,21 @@ class Api_model extends CI_Model {
$trBook = $this->db->get_where('transaction',array('id'=>$last_id))->row_array(); $trBook = $this->db->get_where('transaction',array('id'=>$last_id))->row_array();
$book_id = $trBook['booking_id']; $book_id = $trBook['booking_id'];
$this->db->update('booking',array('status'=>'1'),array('bookId'=>$book_id)); $sql = "SELECT TEVT.event_name,CONCAT(EDATE.date,' ',EDATE.time) AS show_time,
$this->db->update('event_invites',array('status'=>'1'),array('book_id'=>$book_id)); CUST.name,CUST.email,CUST.phone,EVT.approve_booking
$this->db->update('promocode_used',array('status'=>'1'),array('booking_id'=>$book_id));
$bkData = $this->db->query("
SELECT TEVT.event_name,CONCAT(EDATE.date,' ',EDATE.time) AS show_time,
CUST.name,CUST.email,CUST.phone
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 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='".$trBook['booking_id']."' AND EVT.status='1' AND WHERE BK.bookId='".$trBook['booking_id']."' AND EVT.status='1' AND
BK.status='1' AND EDATE.status='1' AND TEVT.language_code='EN'")->row_array(); BK.status='3' AND EDATE.status='1' AND TEVT.language_code='EN'";
$bkData = $this->db->query($sql)->row_array();
$bokStatus = '1';
if(!empty($bkData)){ if(!empty($bkData)){
$bokStatus = (isset($bkData['approve_booking'])&&$bkData['approve_booking']=='1')?'6':'1';
$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 '".$bkData['event_name']. $msgContent = "Hi, Your booking is confirmed for the event '".$bkData['event_name'].
...@@ -1373,13 +1377,15 @@ class Api_model extends CI_Model { ...@@ -1373,13 +1377,15 @@ class Api_model extends CI_Model {
$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}'),
array($bkData['event_name'],$trBook['booking_id'],$showTime), array($bkData['event_name'],$trBook['booking_id'],$showTime),
$template['booking_sms']); $template['booking_sms']);
} }
$this->sendSMS($bkData['phone'],$msgContent); $this->sendSMS($bkData['phone'],$msgContent);
} }
$this->db->update('booking',array('status'=>$bokStatus),array('bookId'=>$book_id));
$this->db->update('event_invites',array('status'=>'1'),array('book_id'=>$book_id));
$this->db->update('promocode_used',array('status'=>'1'),array('booking_id'=>$book_id));
} }
$res = array('status'=>1); $res = array('status'=>1);
}catch(Exception $e){ }catch(Exception $e){
...@@ -1476,6 +1482,8 @@ class Api_model extends CI_Model { ...@@ -1476,6 +1482,8 @@ class Api_model extends CI_Model {
} }
public function verifyMail($data = ''){ public function verifyMail($data = ''){
$settings = getSettings();
$redUrl = $settings['web_base_url'];
try{ try{
$cust = $this->db->query("SELECT CUST.customer_id,CUST.email,CUST.phone $cust = $this->db->query("SELECT CUST.customer_id,CUST.email,CUST.phone
FROM customer AS CUST FROM customer AS CUST
...@@ -1500,11 +1508,11 @@ class Api_model extends CI_Model { ...@@ -1500,11 +1508,11 @@ class Api_model extends CI_Model {
if($this->db->update('customer',array('confirm_link'=>'','email_verified'=>'1'), if($this->db->update('customer',array('confirm_link'=>'','email_verified'=>'1'),
array('customer_id'=>$cust['customer_id']))){ array('customer_id'=>$cust['customer_id']))){
header('Location:https://timeout.sa/staging/location?login=1'); header('Location:'.$redUrl.'location?login=1');
} }
} }
}catch(Exception $e){} }catch(Exception $e){}
header('Location:https://timeout.sa/staging/location'); header('Location:'.$redUrl.'location');
} }
public function checkSeatAvailability($data = ''){ public function checkSeatAvailability($data = ''){
...@@ -1726,7 +1734,7 @@ class Api_model extends CI_Model { ...@@ -1726,7 +1734,7 @@ class Api_model extends CI_Model {
->select('booking.id AS book_id,booking.bookId,customer.name AS customer_name, ->select('booking.id AS book_id,booking.bookId,customer.name AS customer_name,
booking.status,booking.no_of_ticket,booking.qrcode, booking.status,booking.no_of_ticket,booking.qrcode,
booking.ticket_details,event_date_time.date AS booking_date') booking.ticket_details,event_date_time.date AS booking_date')
->where('booking.bookId',$data['qr_pin']) ->where(array('booking.bookId'=>$data['qr_pin'],'status'=>'1'))
->from('booking') ->from('booking')
->join('events','booking.event_id = events.event_id') ->join('events','booking.event_id = events.event_id')
->join('event_date_time','booking.event_date_id = event_date_time.id') ->join('event_date_time','booking.event_date_id = event_date_time.id')
...@@ -1815,4 +1823,5 @@ class Api_model extends CI_Model { ...@@ -1815,4 +1823,5 @@ class Api_model extends CI_Model {
} }
return $res; return $res;
} }
} ?> }
?>
\ No newline at end of file
...@@ -5,7 +5,7 @@ class Booking_model extends CI_Model { ...@@ -5,7 +5,7 @@ class Booking_model extends CI_Model {
parent::_construct(); parent::_construct();
} }
public function getBookingData($booking_id='',$provider_id='',$view='0,1,2,3,5'){ public function getBookingData($booking_id='',$provider_id='',$view='0,1,2,3,5,6'){
$cond = (!empty($view))?" BOK.status IN ($view) ":" BOK.status != '4' "; $cond = (!empty($view))?" BOK.status IN ($view) ":" BOK.status != '4' ";
$cond .= (!empty($booking_id))?" AND BOK.id='$booking_id' ":""; $cond .= (!empty($booking_id))?" AND BOK.id='$booking_id' ":"";
$cond .= (!empty($provider_id))?" AND EVT.provider_id='$provider_id' ":""; $cond .= (!empty($provider_id))?" AND EVT.provider_id='$provider_id' ":"";
...@@ -95,7 +95,7 @@ class Booking_model extends CI_Model { ...@@ -95,7 +95,7 @@ class Booking_model extends CI_Model {
$end_date = date('Y-m-d',strtotime(trim($where_cond['end_date']).' 23:59')); $end_date = date('Y-m-d',strtotime(trim($where_cond['end_date']).' 23:59'));
$where_clause .= " BOK.booking_date <= '".$end_date."' "; $where_clause .= " BOK.booking_date <= '".$end_date."' ";
} }
if(!empty($where_cond['status'])){ if($where_cond['status'] != ''){
$where_clause .= (empty($where_clause))?' WHERE ':' AND '; $where_clause .= (empty($where_clause))?' WHERE ':' AND ';
$where_clause .= " BOK.status = '".$where_cond['status']."' "; $where_clause .= " BOK.status = '".$where_cond['status']."' ";
......
...@@ -5,10 +5,11 @@ class Country_model extends CI_Model { ...@@ -5,10 +5,11 @@ class Country_model extends CI_Model {
} }
public function getCountryData($country_id='',$view=''){ public function getCountryData($country_id='',$view=''){
$cond = (!empty($view))?" status IN ($view) ":" status != '2' "; $cond = (!empty($view))?" CTRY.status IN ($view) ":" CTRY.status != '2' ";
$cond .= (!empty($country_id))?" AND country_id='$country_id' ":""; $cond .= (!empty($country_id))?" AND CTRY.country_id='$country_id' ":"";
$countryData = $this->db->query("SELECT * FROM country WHERE $cond"); $sql = "SELECT CTRY.* FROM country AS CTRY WHERE $cond";
$countryData = $this->db->query($sql);
if(!empty($countryData)){ if(!empty($countryData)){
return (empty($country_id))?$countryData->result():$countryData->row(); return (empty($country_id))?$countryData->result():$countryData->row();
} }
...@@ -35,8 +36,7 @@ class Country_model extends CI_Model { ...@@ -35,8 +36,7 @@ class Country_model extends CI_Model {
if(empty($country_id)){ if(empty($country_id)){
return 0; return 0;
} }
$status = $this->db->update('country',array('status'=>$status), $status = $this->db->update('country',array('status'=>$status),array('country_id'=>$country_id));
array('country_id'=>$country_id));
return $status; return $status;
} }
......
...@@ -209,7 +209,7 @@ class Event_model extends CI_Model { ...@@ -209,7 +209,7 @@ class Event_model extends CI_Model {
if(empty($event_id) || empty($eventData)){ if(empty($event_id) || empty($eventData)){
return 0; return 0;
} }
$this->db->update('event_date_time',array('status'=>'0'),array('event_id'=>$event_id)); $this->db->update('event_date_time',array('status'=>'0'),array('event_id'=>$event_id,'status'=>'1'));
$status = $this->db->insert_batch('event_date_time',$eventData); $status = $this->db->insert_batch('event_date_time',$eventData);
return $status; return $status;
} }
......
...@@ -169,7 +169,15 @@ class Validation_app_model extends CI_Model { ...@@ -169,7 +169,15 @@ class Validation_app_model extends CI_Model {
) )
) )
), ),
'create_guest_user' => array() 'create_guest_user' => array(),
'update_user_visibility' => array(
'visible' => array(
'required' => array(
'code' => 'ER18',
'message' => 'Required field is null or empty'
)
)
)
); );
public function validation_check($method_name, $parms) { public function validation_check($method_name, $parms) {
......
...@@ -47,6 +47,12 @@ class Validation_model extends CI_Model { ...@@ -47,6 +47,12 @@ class Validation_model extends CI_Model {
'code' => 'ER04', 'code' => 'ER04',
'message' => 'Password is null or empty' 'message' => 'Password is null or empty'
) , ) ,
) ,
'phone_code' => array(
'required' => array(
'code' => 'ER05',
'message' => 'ISD Code is null or empty'
) ,
) )
) , ) ,
'forgot' => array( 'forgot' => array(
...@@ -213,13 +219,7 @@ class Validation_model extends CI_Model { ...@@ -213,13 +219,7 @@ class Validation_model extends CI_Model {
'code' => 'ER33', 'code' => 'ER33',
'message' => 'Event date and time is null or empty' 'message' => 'Event date and time is null or empty'
) )
) , ),
'amount' => array(
'required' => array(
'code' => 'ER35',
'message' => 'Amount is null or empty'
)
) ,
'no_of_ticket' => array( 'no_of_ticket' => array(
'required' => array( 'required' => array(
'code' => 'ER36', 'code' => 'ER36',
...@@ -692,6 +692,14 @@ class Validation_model extends CI_Model { ...@@ -692,6 +692,14 @@ class Validation_model extends CI_Model {
) )
) )
), ),
'addCard' => array(
'requestData' => array(
'required' => array(
'code' => 'ER18',
'message' => 'Request Data is null or empty'
)
)
)
); );
public function _consruct(){ public function _consruct(){
......
...@@ -1061,7 +1061,7 @@ class Webservice_model extends CI_Model { ...@@ -1061,7 +1061,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) {
$post_data = $data; $post_data = $data;
$status = '3';
$book_id = 'TO'.date('ymd').str_pad(rand(1111,9999),4,0,STR_PAD_LEFT); $book_id = 'TO'.date('ymd').str_pad(rand(1111,9999),4,0,STR_PAD_LEFT);
$post_data['bookId'] = $book_id; $post_data['bookId'] = $book_id;
$post_data['qrcode'] = genQRcode($post_data['bookId']); $post_data['qrcode'] = genQRcode($post_data['bookId']);
...@@ -1073,9 +1073,14 @@ class Webservice_model extends CI_Model { ...@@ -1073,9 +1073,14 @@ class Webservice_model extends CI_Model {
if(!isset($post_data['amount']) || empty($post_data['amount'])){ if(!isset($post_data['amount']) || empty($post_data['amount'])){
$post_data['amount'] = 0; $post_data['amount'] = 0;
} }
if(isset($post_data['has_payment']) && $post_data['has_payment'] == 0){ if(isset($post_data['has_payment']) && $post_data['has_payment'] == 0){
$post_data['status'] = '1'; $status = $post_data['status'] = '1';
}
$evtData = $this->db->get_where('events',array('event_id'=>$post_data['event_id']));
$evtData = $evtData->row_array();
if(!empty($evtData) && isset($evtData['approve_booking']) && $evtData['approve_booking']=='1'){
$post_data['status'] = '6';
} }
$promocodeData = array(); $promocodeData = array();
...@@ -1089,10 +1094,10 @@ class Webservice_model extends CI_Model { ...@@ -1089,10 +1094,10 @@ class Webservice_model extends CI_Model {
$post_data['amount'] = $post_data['discounted_price']; $post_data['amount'] = $post_data['discounted_price'];
$redeem_amount = $post_data['amount']-$post_data['discounted_price']; $redeem_amount = $post_data['amount']-$post_data['discounted_price'];
$status = ($post_data['status'] == '1')? 1 : 0; $promoStatus = ($post_data['status'] == '1')? 1 : 0;
$promocodeData = array('user_id'=>$user_id,'booking_id'=>$book_id, $promocodeData = array('user_id'=>$user_id,'booking_id'=>$book_id,
'promocode_id'=>$promo_id,'redeem_amount'=>$redeem_amount, 'promocode_id'=>$promo_id,'redeem_amount'=>$redeem_amount,
'created_date'=>date('Y-m-d H:i:s'),'status'=>$status); 'created_date'=>date('Y-m-d H:i:s'),'status'=>$promoStatus);
} }
$invite_ids = (isset($post_data['friends_ids']))?$post_data['friends_ids']:''; $invite_ids = (isset($post_data['friends_ids']))?$post_data['friends_ids']:'';
$invite_phone = (isset($post_data['invite_list']))?$post_data['invite_list']:''; $invite_phone = (isset($post_data['invite_list']))?$post_data['invite_list']:'';
...@@ -1127,7 +1132,7 @@ class Webservice_model extends CI_Model { ...@@ -1127,7 +1132,7 @@ class Webservice_model extends CI_Model {
$this->db->insert_batch('event_invites',$insertArr); $this->db->insert_batch('event_invites',$insertArr);
} }
if($post_data['status'] == 1){ if($status == 1){
$countryData = $this->getCountryData($user_id); $countryData = $this->getCountryData($user_id);
$lang = $countryData['language_code']; $lang = $countryData['language_code'];
...@@ -1197,8 +1202,6 @@ class Webservice_model extends CI_Model { ...@@ -1197,8 +1202,6 @@ 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) {
$res_count = $this->db->where('bookId',$data['booking_id'])->where('status',1)->get('booking')->num_rows();
if($res_count > 0) {
$rs = $this->db->where('bookId',$data['booking_id'])->update('booking',array('status'=>0)); $rs = $this->db->where('bookId',$data['booking_id'])->update('booking',array('status'=>0));
if($rs) { if($rs) {
$res = array('status'=>1,'data'=>null); $res = array('status'=>1,'data'=>null);
...@@ -1206,9 +1209,6 @@ class Webservice_model extends CI_Model { ...@@ -1206,9 +1209,6 @@ class Webservice_model extends CI_Model {
$res = array('status'=>0,'message'=>'Cancel submission failed','code'=>'ER25'); $res = array('status'=>0,'message'=>'Cancel submission failed','code'=>'ER25');
} }
} else { } else {
$res = array('status'=>0,'message'=>'Invalid booking code','code'=>'ER24');
}
} 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) {
...@@ -1374,7 +1374,7 @@ class Webservice_model extends CI_Model { ...@@ -1374,7 +1374,7 @@ class Webservice_model extends CI_Model {
SELECT BOK.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)
INNER JOIN event_date_time AS EDT ON (EVT.event_id=EVT.event_id) 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' WHERE BOK.customer_id='$user_id' AND BOK.status IN (0,1,2,6) AND EVT.status='1'
GROUP BY BOK.id")->num_rows(); GROUP BY BOK.id")->num_rows();
if($count > 0) { if($count > 0) {
...@@ -1399,8 +1399,8 @@ class Webservice_model extends CI_Model { ...@@ -1399,8 +1399,8 @@ class Webservice_model extends CI_Model {
INNER JOIN event_date_time ON booking.event_date_id = event_date_time.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 venue ON venue.id = events.venue_id
INNER JOIN translator_event ON translator_event.event_id = events.event_id INNER JOIN translator_event ON translator_event.event_id = events.event_id
WHERE booking.customer_id = '$user_id' AND booking.status IN(0, 1, 2) AND WHERE booking.customer_id = '$user_id' AND booking.status IN(0,1,2,6) AND
translator_event.language_code = '$lang' (translator_event.language_code='$lang' OR translator_event.language_code='EN')
GROUP BY booking.id GROUP BY booking.id
ORDER BY booking.id DESC ORDER BY booking.id DESC
LIMIT $page_limit, $per_page"; LIMIT $page_limit, $per_page";
...@@ -1511,7 +1511,7 @@ class Webservice_model extends CI_Model { ...@@ -1511,7 +1511,7 @@ class Webservice_model extends CI_Model {
LEFT JOIN customer ON customer.customer_id = booking.customer_id LEFT JOIN customer ON customer.customer_id = booking.customer_id
LEFT JOIN review ON review.event_id = booking.event_id LEFT JOIN review ON review.event_id = booking.event_id
WHERE booking.customer_id = '$user_id' AND booking.status='2' AND WHERE booking.customer_id = '$user_id' AND booking.status='2' AND
translator_event.language_code='$lang' (translator_event.language_code='$lang' OR translator_event.language_code='EN')
ORDER BY booking.id DESC LIMIT 1"; ORDER BY booking.id DESC LIMIT 1";
$result = $this->db->query($sql)->row_array(); $result = $this->db->query($sql)->row_array();
...@@ -1831,10 +1831,10 @@ class Webservice_model extends CI_Model { ...@@ -1831,10 +1831,10 @@ class Webservice_model extends CI_Model {
CUST.profile_image_qr,CHT.type AS friend_status CUST.profile_image_qr,CHT.type AS friend_status
FROM customer AS CUST 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) 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 CUST.enable_chat='1' AND
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 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'))"); 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'))
GROUP BY CUST.customer_id");
$respArr['status'] = 1; $respArr['status'] = 1;
$respArr['data'] = (!empty($result) && !empty($result=$result->result_array()))?$result:[]; $respArr['data'] = (!empty($result) && !empty($result=$result->result_array()))?$result:[];
...@@ -1873,7 +1873,8 @@ class Webservice_model extends CI_Model { ...@@ -1873,7 +1873,8 @@ class Webservice_model extends CI_Model {
CUST.customer_id CUST.customer_id
FROM customer AS CUST FROM customer AS CUST
INNER JOIN chats AS CHT ON (CUST.customer_id = CHT.from_user) INNER JOIN chats AS CHT ON (CUST.customer_id = CHT.from_user)
WHERE type='0' AND to_user='".$user_id."'"); WHERE type='0' AND to_user='$user_id'
GROUP BY CUST.customer_id");
if(!empty($result) && !empty($result = $result->result())){ if(!empty($result) && !empty($result = $result->result())){
$respArr['status'] = 1; $respArr['status'] = 1;
$respArr['data'] = $result; $respArr['data'] = $result;
...@@ -1892,9 +1893,9 @@ class Webservice_model extends CI_Model { ...@@ -1892,9 +1893,9 @@ class Webservice_model extends CI_Model {
continue; continue;
} }
$fromUsrId = ''; $fromUsrId = '';
if($value['to_user']==$user_id){ if($value['to_user'] == $user_id) {
$fromUsrId = $value['from_user']; $fromUsrId = $value['from_user'];
} else if ($value['from_user'] == $user_id){ } else if ($value['from_user'] == $user_id) {
$fromUsrId = $value['to_user']; $fromUsrId = $value['to_user'];
} else { } else {
continue; continue;
...@@ -1902,7 +1903,8 @@ class Webservice_model extends CI_Model { ...@@ -1902,7 +1903,8 @@ class Webservice_model extends CI_Model {
$sql = "SELECT CUST.name,CUST.phone,CUST.profile_image,CUST.profile_image_qr, $sql = "SELECT CUST.name,CUST.phone,CUST.profile_image,CUST.profile_image_qr,
CUST.customer_id,CUST.fcm_token CUST.customer_id,CUST.fcm_token
FROM customer AS CUST FROM customer AS CUST
WHERE CUST.customer_id='$fromUsrId'"; WHERE CUST.customer_id='$fromUsrId' AND CUST.enable_chat='1'
GROUP BY CUST.customer_id";
$cust = $this->db->query($sql); $cust = $this->db->query($sql);
if(!empty($cust) && !empty($cust = $cust->row_array())){ if(!empty($cust) && !empty($cust = $cust->row_array())){
$custData[] = $cust; $custData[] = $cust;
...@@ -2056,5 +2058,24 @@ class Webservice_model extends CI_Model { ...@@ -2056,5 +2058,24 @@ class Webservice_model extends CI_Model {
return array('status'=>'success','data'=>array('auth_token'=>$auth_token)); return array('status'=>'success','data'=>array('auth_token'=>$auth_token));
} }
public function update_user_visibility($data){
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06');
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0) {
$status = $this->db->update('customer',array('enable_chat'=>$data['visible']),
array('customer_id'=>$user_id));
$res = array('status'=>1);
} 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;
}
} }
?> ?>
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<option selected disabled>Select Booking Status</option> <option selected disabled>Select Booking Status</option>
<option value="">All Bookings</option> <option value="">All Bookings</option>
<?php <?php
$status = array('2'=>'Completed','1'=>'Bookings','3'=>'Pending','0'=>'Cancelled','4'=>'Deleted'); $status = array('2'=>'Completed','1'=>'Bookings','3'=>'Pending','0'=>'Cancelled','4'=>'Deleted','5'=>'Payment Failed');
foreach ($status as $key => $stat) { foreach ($status as $key => $stat) {
echo '<option value="'.$key.'">'.$stat.'</option>'; echo '<option value="'.$key.'">'.$stat.'</option>';
} }
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<th class="center"><?= $booking->customer_name ?></th> <th class="center"><?= $booking->customer_name ?></th>
<th class="center"><?= $booking->date.' '.$booking->time ?></th> <th class="center"><?= $booking->date.' '.$booking->time ?></th>
<th class="center"><?= $booking->amount ?></th> <th class="center"><?= $booking->amount ?></th>
<th class="center"> <th class="center" id="bookingStatus_<?= encode_param($booking->booking_id) ?>">
<?php <?php
switch($booking->book_status){ switch($booking->book_status){
case 0: echo 'Cancelled'; break; case 0: echo 'Cancelled'; break;
...@@ -68,16 +68,28 @@ ...@@ -68,16 +68,28 @@
case 3: echo 'Pending'; break; case 3: echo 'Pending'; break;
case 4: echo 'Deleted'; break; case 4: echo 'Deleted'; break;
case 5: echo 'Payment Failed'; break; case 5: echo 'Payment Failed'; break;
case 6: echo 'Waiting for Aproval'; break;
} }
?> ?>
</th> </th>
<td class="center"> <td class="center">
<a class="btn btn-sm btn-info" id="viewBooking" booking_id="<?= encode_param($booking->booking_id) ?>"> <a class="cpoint text-primary" id="viewBooking"
booking_id="<?= encode_param($booking->booking_id) ?>">
<i class="fa fa-fw fa-eye"></i>View <i class="fa fa-fw fa-eye"></i>View
</a> <br>
<?php
if($this->session->userdata('user_type')==2 && $booking->book_status == '6'){
$msg = "Are you sure to Aprove this booking ?";
$bookId = encode_param($booking->booking_id);
$param = "{'booking_id':'$bookId','alertMsg':'$msg'}"; ?>
<a id="approveBooking_<?= encode_param($booking->booking_id) ?>"
class="cpoint text-success" status="1" call_back="updateBokApproved"
status_id="<?= encode_param($booking->booking_id) ?>"
onclick="confirmDelete(jQuery(this),'Booking/changeStatus',<?= $param ?>)">
<i class="fa fa-fw fa-check"></i>Approve
</a> </a>
<!-- <a class="btn btn-sm btn-danger" status="2" onclick="confirmDelete(jQuery(this),'Booking/changeStatus',{'booking_id':'<?= encode_param($booking->booking_id) ?>'})"> <?php } ?>
<i class="fa fa-fw fa-trash"></i>Delete
</a> -->
<?php } ?> <?php } ?>
</td> </td>
</tr> </tr>
......
...@@ -101,6 +101,17 @@ ...@@ -101,6 +101,17 @@
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="col-md-5">
<div class="form-group">
<label>Phone Code</label>
<input type="text" class="form-control required" data-parsley-trigger="change"
data-parsley-minlength="2" data-parsley-pattern="^[0-9]+$"
name="phone_code" required="" value="<?= (isset($countryData->phone_code))?$countryData->phone_code:'' ?>"placeholder="Phone Code">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
</div>
<div class="col-md-12">
<div class="box-footer textCenterAlign"> <div class="box-footer textCenterAlign">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
<a href="<?= base_url('Country/listCountry') ?>" class="btn btn-primary">Cancel</a> <a href="<?= base_url('Country/listCountry') ?>" class="btn btn-primary">Cancel</a>
......
...@@ -228,11 +228,22 @@ ...@@ -228,11 +228,22 @@
data-parsley-minlength="2" name="max_booking" value="14" data-parsley-minlength="2" name="max_booking" value="14"
placeholder="Maximum Seat Can Book Per Transaction (Default 14)"> placeholder="Maximum Seat Can Book Per Transaction (Default 14)">
</div> </div>
<div class="row">
<div class="col-md-5">
<div class="form-group"> <div class="form-group">
<label>Payment Mode</label><br> <label>Payment Mode</label><br>
<input type="checkbox" name="has_payment" value="1" checked> <input type="checkbox" name="has_payment" value="1" checked>
<p style="display:-webkit-inline-box;padding-left: 15px;">Enable Payment</p> <p style="display:-webkit-inline-box;padding-left: 15px;">Enable Payment</p>
</div> </div>
</div>
<div class="col-md-7">
<div class="form-group">
<label>Booking Approval</label><br>
<input type="checkbox" name="approve_booking" value="1">
<p style="display:-webkit-inline-box;padding-left: 15px;">Enable Booking Approval</p>
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Event Images</label> <label>Event Images</label>
<div id="multipleImageInputCntr"> <div id="multipleImageInputCntr">
......
...@@ -229,15 +229,26 @@ ...@@ -229,15 +229,26 @@
<div class="form-group"> <div class="form-group">
<label>Maximum Seat Booking</label> <label>Maximum Seat Booking</label>
<input type="text" class="form-control" data-parsley-trigger="change" <input type="text" class="form-control" data-parsley-trigger="change"
data-parsley-minlength="2" name="max_booking" value="14" data-parsley-minlength="2" name="max_booking" placeholder="Maximum Seat Can Book Per Transaction (Default 14)" value="<?= $event_data->max_booking ?>">
placeholder="Maximum Seat Can Book Per Transaction (Default 14)"
value="<?= $event_data->max_booking ?>">
</div> </div>
<div class="row">
<div class="col-md-5">
<div class="form-group"> <div class="form-group">
<label>Payment Mode</label><br> <label>Payment Mode</label><br>
<input type="checkbox" name="has_payment" value="1" <?= ($event_data->has_payment == 1)?'checked':'' ?>> <input type="checkbox" <?= ($event_data->has_payment == 1)?'checked':'' ?>
name="has_payment" value="1" >
<p style="display:-webkit-inline-box;padding-left: 15px;">Enable Payment</p> <p style="display:-webkit-inline-box;padding-left: 15px;">Enable Payment</p>
</div> </div>
</div>
<div class="col-md-7">
<div class="form-group">
<label>Booking Approval</label><br>
<input type="checkbox" <?= ($event_data->approve_booking==1)?'checked':'' ?>
name="approve_booking" value="1" >
<p style="display:-webkit-inline-box;padding-left: 15px;">Enable Booking Approval</p>
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Event Images</label> <label>Event Images</label>
<div id="multipleImageInputCntr"> <div id="multipleImageInputCntr">
......
...@@ -63,6 +63,32 @@ ...@@ -63,6 +63,32 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6">
<div class="form-group">
<label>Country</label>
<div class="row">
<div class="col-md-12">
<input type="text" class="form-control" name="country"
data-parsley-trigger="change" data-parsley-minlength="2"
placeholder="Country Name" value="<?= (isset($hotelCityData->country))?$hotelCityData->country:'' ?>">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Country Code</label>
<div class="row">
<div class="col-md-12">
<input type="text" class="form-control" name="country_code"
data-parsley-trigger="change" data-parsley-minlength="2"
placeholder="Country Code" value="<?= (isset($hotelCityData->country_code))?$hotelCityData->country_code:'' ?>">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
</div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="box-footer textCenterAlign"> <div class="box-footer textCenterAlign">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
<th class="hidden">ID</th> <th class="hidden">ID</th>
<th width="50px;">Icon</th> <th width="50px;">Icon</th>
<th width="125px;">Hotel City (English)</th> <th width="125px;">Hotel City (English)</th>
<th width="125px;">Country</th>
<th width="100px;">Status</th> <th width="100px;">Status</th>
<?php if(in_array('2',$pAccess)||in_array('3',$pAccess)||in_array('4',$pAccess)){?> <?php if(in_array('2',$pAccess)||in_array('3',$pAccess)||in_array('4',$pAccess)){?>
<th width="200px;">Action</th> <th width="200px;">Action</th>
...@@ -66,6 +67,12 @@ ...@@ -66,6 +67,12 @@
height="50" width="50" /> height="50" width="50" />
</th> </th>
<th class="center"><?= (isset($hotelCity->hotel_city_name_EN))?$hotelCity->hotel_city_name_EN:'' ?></th> <th class="center"><?= (isset($hotelCity->hotel_city_name_EN))?$hotelCity->hotel_city_name_EN:'' ?></th>
<th class="center">
<?php
echo (isset($hotelCity->country))?$hotelCity->country:'';
echo (isset($hotelCity->country_code))?' ('.$hotelCity->country_code.')':'';
?>
</th>
<th class="center" id="statusFlag_<?= $hotelCity->hotel_city_id ?>"> <th class="center" id="statusFlag_<?= $hotelCity->hotel_city_id ?>">
<?= ($hotelCity->status == 1)?'Active':'De-activate' ?> <?= ($hotelCity->status == 1)?'Active':'De-activate' ?>
</th> </th>
......
...@@ -62,6 +62,11 @@ ...@@ -62,6 +62,11 @@
<label>Admin Email-ID</label> <label>Admin Email-ID</label>
<input type="email" name="admin_mail_id" class="form-control required" placeholder="Admin Email-ID" value="<?= $data['admin_mail_id'] ?>"> <input type="email" name="admin_mail_id" class="form-control required" placeholder="Admin Email-ID" value="<?= $data['admin_mail_id'] ?>">
</div> </div>
<div class="form-group col-xs-6">
<label>Web Base URL</label>
<input type="text" name="web_base_url" class="form-control required"
placeholder="Web Base URL" value="<?= $data['web_base_url'] ?>">
</div>
</div> </div>
<div class="form-group col-xs-5"> <div class="form-group col-xs-5">
<div class="form-group"> <div class="form-group">
......
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
<span>Dashboard</span> <span>Dashboard</span>
</a> </a>
</li> </li>
<?php }if(array_key_exists('Customer_Booking',$menus)){ ?>
<li>
<a href="<?= base_url('Customer_Booking') ?>">
<img src="<?=base_url("assets/images/m5.png") ?>">
<span>Care Home</span>
</a>
</li>
<?php } if(array_key_exists('Tag',$menus)){ ?> <?php } if(array_key_exists('Tag',$menus)){ ?>
<li> <li>
<a href="<?= base_url('Tag/listTags') ?>"> <a href="<?= base_url('Tag/listTags') ?>">
...@@ -168,16 +175,10 @@ ...@@ -168,16 +175,10 @@
</li> </li>
</ul> </ul>
</li> </li>
<?php } if(array_key_exists('Booking',$menus)){ ?>
<li>
<a href="<?= base_url('Booking/viewBookings') ?>">
<img src="<?=base_url("assets/images/m8.png") ?>">
<span>Booking Details</span></a>
</li>
<?php } if(array_key_exists('Promocode',$menus)){ ?> <?php } if(array_key_exists('Promocode',$menus)){ ?>
<li class="treeview"> <li class="treeview">
<a href="#"> <a href="#">
<img src="<?=base_url("assets/images/m8.png") ?>"> <img src="<?=base_url("assets/images/m2.png") ?>">
<span>Promocode Management</span> <span>Promocode Management</span>
<i class="fa fa-angle-left pull-right"></i> <i class="fa fa-angle-left pull-right"></i>
</a> </a>
...@@ -196,6 +197,18 @@ ...@@ -196,6 +197,18 @@
</li> </li>
</ul> </ul>
</li> </li>
<?php } if(array_key_exists('Booking',$menus)){ ?>
<li>
<a href="<?= base_url('Booking/viewBookings') ?>">
<img src="<?=base_url("assets/images/m8.png") ?>">
<span>Booking Details</span></a>
</li>
<?php } if(array_key_exists('HotelCity',$menus)){ ?>
<li>
<a href="<?= base_url('HotelCity/listHotelCity') ?>">
<img src="<?=base_url("assets/images/m4.png") ?>">
<span>Hotel Cities</span></a>
</li>
<?php } if(array_key_exists('',$menus)){ ?> <?php } if(array_key_exists('',$menus)){ ?>
<li><a href="<?= base_url('Provider/getProviderPayDetails') ?>"> <li><a href="<?= base_url('Provider/getProviderPayDetails') ?>">
<img src="<?=base_url("assets/images/m2.png") ?>"> <img src="<?=base_url("assets/images/m2.png") ?>">
......
...@@ -603,7 +603,7 @@ function viewBooking(booking_id){ ...@@ -603,7 +603,7 @@ function viewBooking(booking_id){
jQuery.ajax({ jQuery.ajax({
url : base_url+"Booking/getBookingData", url : base_url+"Booking/getBookingData",
type : 'POST', type : 'POST',
data : {'booking_id':booking_id,'view_all':'0,1,2,3,4,5'}, data : {'booking_id':booking_id,'view_all':'0,1,2,3,4,5,6'},
success: function(resp){ success: function(resp){
if(resp == '' || resp == undefined || resp == 'undefined' || resp == null || resp == 'null'){ if(resp == '' || resp == undefined || resp == 'undefined' || resp == null || resp == 'null'){
remModalLoader(); remModalLoader();
...@@ -933,8 +933,22 @@ function setPromoStatus(elmId,data){ ...@@ -933,8 +933,22 @@ function setPromoStatus(elmId,data){
jQuery('[id="statusFlag_'+elmId+'"]').html(data['c_status']); jQuery('[id="statusFlag_'+elmId+'"]').html(data['c_status']);
} }
function updateBokApproved(elmId,data){
if(data==undefined || data=='undefined' || data==null || data=='null' || data=='' ||
elmId==undefined || elmId=='undefined' || elmId==null || elmId=='null' || elmId==''){
return false;
}
jQuery('[id="bookingStatus_'+elmId+'"]').html('Booked');
console.log('[id="bookingStatus_'+elmId+'"]');
jQuery('[id="approveBooking_'+elmId+'"]').remove();
}
function confirmDelete(thisObj,fnName,params){ function confirmDelete(thisObj,fnName,params){
if(confirm("Are you sure to delete permanently?")){ var msg = "Are you sure to delete permanently ?";
if(params.alertMsg){
msg = params.alertMsg;
}
if(confirm(msg)){
updateStatus(thisObj,fnName,params,status); updateStatus(thisObj,fnName,params,status);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment