Commit 7018f12a by Tobin

daily commit

parent fdf33bd6
...@@ -252,7 +252,7 @@ class Api extends CI_Controller { ...@@ -252,7 +252,7 @@ class Api extends CI_Controller {
public function discover() { public function discover() {
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; //$data['auth_token'] = $this->auth_token;
$res = $this->Api_model->discover($data); $res = $this->Api_model->discover($data);
if($res['status']!=0){ if($res['status']!=0){
$this->response($res['data']); $this->response($res['data']);
...@@ -264,7 +264,7 @@ class Api extends CI_Controller { ...@@ -264,7 +264,7 @@ class Api extends CI_Controller {
public function event() { public function event() {
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; //$data['auth_token'] = $this->auth_token;
$res = $this->Api_model->event($data); $res = $this->Api_model->event($data);
if($res['status']!=0){ if($res['status']!=0){
$this->response($res['data']); $this->response($res['data']);
...@@ -276,7 +276,7 @@ class Api extends CI_Controller { ...@@ -276,7 +276,7 @@ class Api extends CI_Controller {
public function search() { public function search() {
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; //$data['auth_token'] = $this->auth_token;
$res = $this->Api_model->search($data); $res = $this->Api_model->search($data);
if($res['status']!=0){ if($res['status']!=0){
...@@ -298,45 +298,127 @@ class Api extends CI_Controller { ...@@ -298,45 +298,127 @@ class Api extends CI_Controller {
} }
} }
public function payNow($auth_token='',$amount=0,$booking_id='',$event_id=''){
if(empty($auth_token) || empty($amount) || empty($booking_id)){
redirect('http://localhost:4200/failure');
}
$payData = array('auth_token'=>$auth_token,'amount'=>$amount,'booking_id'=>$booking_id);
$res = $this->Api_model->payNow($payData);
if($res['status']==1){
$this->paymentGateway($amount,$res['transaction_id'],$event_id,$booking_id);
}
else{
redirect('http://localhost:4200/failure?event_id='.$eventid);
}
}
public function paymentSuccessUrl(){
$response = '';
$transaction_id = '';
BayanPayPayment();
$BayanPayArray = $this->bayanPayArray('0','0','0','0');
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray);
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){
$response = $BayanPayOnlineObject->decryptData($_REQUEST['responseParameter'],$BayanPayOnlineObject->merchantKey,$BayanPayOnlineObject->iv);
$ref_id = explode('|',$response['Transaction_related_information']);
$transaction_id = $ref_id[1];
$last_id = explode('|',$response['Merchant_Information']);
$lastid = $last_id[1];
$eventid = $last_id[2];
$booking_id = $last_id[3];
$this->Api_model->update_payment($response,$transaction_id,$lastid,'1') ;
redirect('http://localhost:4200/bookingdetails?booking_id='.$booking_id);
}
}
public function paymentFailureUrl(){
$lastid = '';
$response = '';
$transaction_id = '';
BayanPayPayment();
$BayanPayArray = $this->bayanPayArray('0','0','0','0');
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray);
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){
$response = $BayanPayOnlineObject->decryptData($_REQUEST['responseParameter'],$BayanPayOnlineObject->merchantKey,$BayanPayOnlineObject->iv);
$ref_id = explode('|',$response['Transaction_related_information']);
$transaction_id = $ref_id[1];
$last_id = explode('|',$response['Merchant_Information']);
$lastid = $last_id[1];
$eventid = $last_id[2];
$booking_id = $last_id[3];
$this->Api_model->update_payment($response,$transaction_id,$lastid,'0');
redirect('http://localhost:4200/failure?event_id='.$eventid);
}
}
public function paymentGateway(){ public function paymentGateway($amount='0',$lastid='0',$event_id='0',$booking_id='0'){
BayanPayPayment(); BayanPayPayment();
$BayanPayArray = $this->bayanPayArray($amount,$lastid,$event_id,$booking_id);
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray);
$requestParameter = $BayanPayOnlineObject->BayanPostData;
if($BayanPayOnlineObject->url){
$requestUrl = 'https://payments.bayanpay.sa/direcpay/secure/PaymentTxnServlet';
}
else{
$requestUrl = 'https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet';
}
$this->load->view('payment/payment',array('requestUrl'=>$requestUrl,
'requestParameter'=>$requestParameter));
}
$networkOnlineArray = function baseurl(){
array('Network_Online_setting' => if(isset($_SERVER['HTTPS']))
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
else
$protocol = 'http';
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
function bayanPayArray($amount = '0',$lastid='',$event_id='',$booking_id=''){
$BayanPayArray =
array( array(
'BayanPay_Online_setting' => array(
'merchantKey' => "+Hu4bL6iVk943JmFAvGtWEYMODFry4fad2I+iM0X2m0=", 'merchantKey' => "+Hu4bL6iVk943JmFAvGtWEYMODFry4fad2I+iM0X2m0=",
'merchantId' => '201901291000002', 'merchantId' => '201901291000002',
'collaboratorId' => 'NI', 'collaboratorId' => 'BAYANPAY',
'iv' => '0123456789abcdef', 'iv' => '0123456789abcdef',
'url' => false 'url' => false// Set to false if you are using testing environment , set to true if you are using live environment
), ),
'Block_Existence_Indicator' => array( 'Block_Existence_Indicator' => array(
'transactionDataBlock' => true, 'transactionDataBlock' => true,
'billingDataBlock' => true, 'billingDataBlock' => true,
'shippingDataBlock' => true, 'shippingDataBlock' => true,
'paymentDataBlock' => false, 'paymentDataBlock' => false,
'merchantDataBlock' => false, 'merchantDataBlock' => true,
'otherDataBlock' => false, 'otherDataBlock' => false,
'DCCDataBlock' => false 'DCCDataBlock' => false
), ),
'Field_Existence_Indicator_Transaction' => array( 'Field_Existence_Indicator_Transaction' => array(
'merchantOrderNumber' => time(), 'merchantOrderNumber' => time(),
'amount' => '100.00', 'amount' => $amount,
'successUrl' => $this->baseurl(), 'successUrl' => base_url('Api/paymentSuccessUrl'),
'failureUrl' => $this->baseurl(), 'failureUrl' => base_url('Api/paymentFailureUrl'),
'transactionMode' => 'INTERNET', 'transactionMode' => 'INTERNET',
'payModeType' => 'CC', 'payModeType' => 'CC',
'transactionType' => '01', 'transactionType' => '01',
'currency' => 'AED' 'currency' => 'SAR'
), ),
'Field_Existence_Indicator_Billing' => array( 'Field_Existence_Indicator_Billing' => array(
'billToFirstName' => 'Soloman', 'billToFirstName' => 'Soloman',
'billToLastName' => 'Vandy', 'billToLastName' => 'Vandy',
'billToStreet1' => '123,ParkStreet', 'billToStreet1' => '123,ParkStreet',
'billToStreet2' => 'Park Street', 'billToStreet2' => 'Park Street',
'billToCity' => 'Mumbai', 'billToCity' => 'Riyadh',
'billToState' => 'Maharashtra', 'billToState' => 'Riyadh',
'billtoPostalCode' => '400081', 'billtoPostalCode' => '400081',
'billToCountry' => 'IN', 'billToCountry' => 'IN',
'billToEmail' => '[email protected]', 'billToEmail' => '[email protected]',
...@@ -350,8 +432,8 @@ class Api extends CI_Controller { ...@@ -350,8 +432,8 @@ class Api extends CI_Controller {
'shipToLastName' => 'Vandy', 'shipToLastName' => 'Vandy',
'shipToStreet1' => '123ParkStreet', 'shipToStreet1' => '123ParkStreet',
'shipToStreet2' => 'parkstreet', 'shipToStreet2' => 'parkstreet',
'shipToCity' => 'Mumbai', 'shipToCity' => 'Riyadh',
'shipToState' => 'Maharashtra', 'shipToState' => 'Riyadh',
'shipToPostalCode' => '400081', 'shipToPostalCode' => '400081',
'shipToCountry' => 'IN', 'shipToCountry' => 'IN',
'shipToPhoneNumber1' => '', 'shipToPhoneNumber1' => '',
...@@ -366,73 +448,33 @@ class Api extends CI_Controller { ...@@ -366,73 +448,33 @@ class Api extends CI_Controller {
'CVV' => '123', // 4. CVV 'CVV' => '123', // 4. CVV
'cardHolderName' => 'Soloman', // 5. Card Holder Name 'cardHolderName' => 'Soloman', // 5. Card Holder Name
'cardType' => 'Visa', // 6. Card Type 'cardType' => 'Visa', // 6. Card Type
'custMobileNumber'=> '9820998209', // 7. Customer Mobile Number 'custMobileNumber' => '9820998209', // 7. Customer Mobile Number
'paymentID' => '123456', // 8. Payment ID 'paymentID' => '123456', // 8. Payment ID
'OTP' => '123456', // 9. OTP field 'OTP' => '123456', // 9. OTP field
'gatewayID' => '1026', // 10.Gateway ID 'gatewayID' => '1026', // 10.Gateway ID
'cardToken' => '1202' // 11.Card Token 'cardToken' => '1202' // 11.Card Token
), ),
'Field_Existence_Indicator_Merchant' => 'Field_Existence_Indicator_Merchant' => array(
array( 'UDF1' => $lastid,
'UDF1' => '115.121.181.112', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. 'UDF2' => $event_id,
'UDF2' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction. 'UDF3' => $booking_id
'UDF3' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF4' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF5' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF6' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF7' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF8' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF9' => 'abc', // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
'UDF10' => 'abc' // This is a ‘user-defined field’ that can be used to send additional information about the transaction.
), ),
'Field_Existence_Indicator_OtherData' => 'Field_Existence_Indicator_OtherData' => array(
array(
'custID' => '12345', 'custID' => '12345',
'transactionSource' => 'IVR', 'transactionSource' => 'IVR',
'productInfo' => 'Book', 'productInfo' => 'Book',
'isUserLoggedIn' => 'Y', 'isUserLoggedIn' => 'Y',
'itemTotal' => '500.00, 1000.00', 'itemTotal' => '500.00, 1000.00',
'itemCategory' => 'CD, Book', 'itemCategory' => 'CD, Book',
'ignoreValidationResult' => 'FALSE' 'ignoreValidationResult'=> 'FALSE'
), ),
'Field_Existence_Indicator_DCC' => 'Field_Existence_Indicator_DCC' => array(
array(
'DCCReferenceNumber' => '09898787', // DCC Reference Number 'DCCReferenceNumber' => '09898787', // DCC Reference Number
'foreignAmount' => '240.00', // Foreign Amount 'foreignAmount' => '240.00', // Foreign Amount
'ForeignCurrency' => 'USD' // Foreign Currency 'ForeignCurrency' => 'USD' // Foreign Currency
) )
); );
return $BayanPayArray;
$networkOnlineObject = new NetworkonlieBitmapPaymentIntegration($networkOnlineArray);
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){
$response = $networkOnlineObject->decryptData($_REQUEST['responseParameter'],$networkOnlineObject->merchantKey,$networkOnlineObject->iv);
$networkOnlineObject->AddLog('Network Online Response : '.print_r($response, TRUE),'16');
} }
$requestParameter = $networkOnlineObject->NeoPostData;
// if($networkOnlineObject->url)
// $requestUrl = 'https://www.timesofmoney.com/direcpay/secure/PaymentTxnServlet';
// else
$requestUrl = 'https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet';
echo '<form action="'.$requestUrl.'" method="post" name="network_online_payment"
id="network_online_payment">
<input type="hidden" name="requestParameter" value='.$requestParameter.'>
<input type="submit" value="Submit">
</form>';
}
function baseurl(){
if(isset($_SERVER['HTTPS']))
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
else
$protocol = 'http';
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
} }
?>
\ No newline at end of file
...@@ -370,7 +370,8 @@ class Api_model extends CI_Model { ...@@ -370,7 +370,8 @@ class Api_model extends CI_Model {
if($res_count > 0) { if($res_count > 0) {
$rs = $this->db->where('bookId',$data['bookingCode'])->update('booking',array('status'=>1)); $rs = $this->db->where('bookId',$data['bookingCode'])->update('booking',array('status'=>1));
if($rs) { if($rs) {
$result = $this->db->select('booking.id AS book_id,booking.event_id,booking.bookId AS bookingCode,booking.qrcode,booking.no_of_ticket,booking.amount,booking.status AS book_status,events.event_name,events.event_discription,event_gallery.media_url,venue.location,customer.name AS customer_name,customer.profile_image,venue.venue_name,venue.location_lat AS lat,venue.location_lng AS lng, booking.ticket_details')->where('booking.bookId',$data['bookingCode'])->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')->join('customer','customer.customer_id = booking.customer_id')->get()->row(); $result = $this->db->select('booking.id AS book_id,booking.event_id,booking.bookId AS bookingCode,booking.qrcode,booking.no_of_ticket,booking.amount,booking.status AS book_status,events.event_name,events.event_discription,event_gallery.media_url,venue.location,customer.name AS customer_name,customer.profile_image,venue.venue_name,venue.location_lat AS lat,venue.location_lng AS lng, booking.ticket_details,event_date_time.date,event_date_time.time')->where('booking.bookId',$data['bookingCode'])->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')->join('customer','customer.customer_id = booking.customer_id')->get()->row();
if(count($result)>0){ if(count($result)>0){
$res = array('status'=>1,'data'=>$result); $res = array('status'=>1,'data'=>$result);
} else { } else {
...@@ -484,16 +485,19 @@ class Api_model extends CI_Model { ...@@ -484,16 +485,19 @@ class Api_model extends CI_Model {
unset($post_data['auth_token']); unset($post_data['auth_token']);
$post_data['customer_id'] = $user_id; $post_data['customer_id'] = $user_id;
$post_data['ticket_details'] = json_encode($post_data['ticket_details']); $post_data['ticket_details'] = json_encode($post_data['ticket_details']);
$post_data['qrcode'] = $this->generateQR($post_data);
$post_data['status'] = 3; $post_data['status'] = 3;
$code = 'TO'; $code = 'TO';
$ymd = date('ymd'); $ymd = date('ymd');
$squence = rand(1111,9999); $squence = rand(1111,9999);
$squence = str_pad($squence,4,0,STR_PAD_LEFT); $squence = str_pad($squence,4,0,STR_PAD_LEFT);
$post_data['bookId'] = $code.$ymd.$squence; $post_data['bookId'] = $code.$ymd.$squence;
$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); $rs = $this->db->insert('booking', $post_data);
if($rs){ if($rs){
$res = array('status'=>1,'data'=>array('bookingCode'=>$post_data['bookId'])); $res = array('status'=>1,
'data'=>array('user_id'=>$user_id,
'bookingCode'=>$post_data['bookId']));
} else { } else {
$res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37'); $res = array('status'=>0,'message'=>'Seat booking failed','code'=>'ER37');
} }
...@@ -590,8 +594,8 @@ class Api_model extends CI_Model { ...@@ -590,8 +594,8 @@ class Api_model extends CI_Model {
function discover($data) { function discover($data) {
try { try {
$user_id = $this->auth_token_get($data['auth_token']); //$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0) { //if($user_id > 0) {
$cat_id = $data['cat_id']; $cat_id = $data['cat_id'];
$city_id = $data['city']; $city_id = $data['city'];
$category = $this->db->where('cat_id',$cat_id)->get('event_category')->row(); $category = $this->db->where('cat_id',$cat_id)->get('event_category')->row();
...@@ -625,9 +629,9 @@ class Api_model extends CI_Model { ...@@ -625,9 +629,9 @@ class Api_model extends CI_Model {
} else { } else {
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); $res = array('status'=>0,'message'=>'No records found','code'=>'ER13');
} }
} else { //} else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); //$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} //}
} catch(Exception $e) { } catch(Exception $e) {
...@@ -640,11 +644,11 @@ class Api_model extends CI_Model { ...@@ -640,11 +644,11 @@ class Api_model extends CI_Model {
function event($data) { function event($data) {
try { try {
$user_id = $this->auth_token_get($data['auth_token']); $user_id = (!isset($data['auth_token']) || empty($data['auth_token']))?'':$this->auth_token_get($data['auth_token']);
if($user_id > 0) { //if($user_id > 0) {
$event_id = $data['event_id']; $event_id = $data['event_id'];
$this->db->query("SET SESSION group_concat_max_len = 20000"); $this->db->query("SET SESSION group_concat_max_len = 20000");
$result = $this->db->query("SELECT events.has_payment,events.event_id, AVG(review.rate) AS rate, MAX(booking.id) AS attendees, events.event_name,events.event_discription AS event_description,events.seat_pricing, events.custom_seat_layout, events.seat_pricing, venue.layout, venue.layout_details,venue.venue_name,venue.venue_details,venue.location,venue.location_lat AS lat,venue.location_lng AS lng, GROUP_CONCAT(DISTINCT `event_gallery`.`media_url`) AS media_url,favourite.status AS fav_status, events.max_booking, host_categories.show_layout, GROUP_CONCAT(DISTINCT tags.tag_name) AS tag, GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date,event_date_time.time)) AS date_time 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 events.event_id = ".$event_id." GROUP BY events.event_id, event_date_time.event_id")->result(); $result = $this->db->query("SELECT events.has_payment,events.event_id, AVG(review.rate) AS rate, MAX(booking.id) AS attendees, events.event_name,events.event_discription AS event_description,events.seat_pricing, events.custom_seat_layout, events.seat_pricing, venue.layout, venue.layout_details,venue.venue_name,venue.venue_details,venue.location,venue.location_lat AS lat,venue.location_lng AS lng, GROUP_CONCAT(DISTINCT `event_gallery`.`media_url`) AS media_url,favourite.status AS fav_status, events.max_booking, host_categories.show_layout, GROUP_CONCAT(DISTINCT tags.tag_name) AS tag, GROUP_CONCAT(DISTINCT CONCAT_WS('#',event_date_time.id,event_date_time.date,event_date_time.time)) AS date_time 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 events.event_id = ".$event_id." GROUP BY events.event_id, event_date_time.event_id")->result();
if(count($result)>0){ if(count($result)>0){
$resultData = array(); $resultData = array();
$event_layout = ''; $event_layout = '';
...@@ -705,9 +709,9 @@ class Api_model extends CI_Model { ...@@ -705,9 +709,9 @@ class Api_model extends CI_Model {
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); $res = array('status'=>0,'message'=>'No records found','code'=>'ER13');
} }
} else { /*} else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }*/
} catch(Exception $e) { } catch(Exception $e) {
...@@ -719,20 +723,17 @@ class Api_model extends CI_Model { ...@@ -719,20 +723,17 @@ class Api_model extends CI_Model {
function search($data) { function search($data) {
try { try {
$per_page = 10; $per_page = 10;
$user_id = $this->auth_token_get($data['auth_token']); $user_id = (!isset($data['auth_token']) || empty($data['auth_token']))?'':$this->auth_token_get($data['auth_token']);
if($user_id > 0) { //if($user_id > 0) {
$where = ''; $where = '';
if(isset($data['venue_id'])) {
$where = ' AND events.venue_id='.$data['venue_id'];
}
if(isset($data['cat_id'])) { if(isset($data['cat_id']) && !empty($data['cat_id'])) {
$where = ' AND events.category_id='.$data['cat_id']; $where = ' AND events.category_id='.$data['cat_id'];
} }
$case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; $case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')";
if(isset($data['choose_date'])) { if(isset($data['choose_date']) && !empty($data['choose_date'])) {
switch ($data['choose_date']) { switch ($data['choose_date']) {
case '1': case '1':
$case = ""; $case = "";
...@@ -768,13 +769,15 @@ class Api_model extends CI_Model { ...@@ -768,13 +769,15 @@ class Api_model extends CI_Model {
$case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')"; $case = "AND event_date_time.date >= DATE_FORMAT(NOW(),'%Y-%m-%d')";
break; break;
} }
$where = ' AND events.venue_id='.$data['venue_id']; // $where = ' AND events.venue_id='.$data['venue_id'];
} }
$count = $this->db->query("SELECT events.event_id FROM events INNER JOIN event_date_time ON events.event_id = event_date_time.event_id $case WHERE events.status = 1 $where GROUP BY events.event_id")->num_rows();
if(isset($data['venue_id']) && !empty($data['venue_id'])) {
$where = ' AND locality.id ='.$data['venue_id'];
}
$count = $this->db->query("SELECT events.event_id FROM events INNER JOIN event_date_time ON events.event_id = event_date_time.event_id $case WHERE events.status = 1 $where GROUP BY events.event_id")->num_rows();
if($count > 0) { if($count > 0) {
if(isset($data['page'])) { if(isset($data['page'])) {
...@@ -786,7 +789,25 @@ class Api_model extends CI_Model { ...@@ -786,7 +789,25 @@ class Api_model extends CI_Model {
$page_limit = ($page - 1) * $per_page; $page_limit = ($page - 1) * $per_page;
if($count > $page_limit) { if($count > $page_limit) {
$result = $this->db->query("SELECT events.event_id, AVG(review.rate) AS rate, MAX(booking.id) AS attendees, events.event_name,events.event_discription AS event_description,events.seat_pricing, events.custom_seat_layout, venue.layout, venue.layout_details,`event_gallery`.`media_url`,favourite.status AS fav_status, GROUP_CONCAT(DISTINCT tags.tag_name) AS tag FROM events INNER JOIN event_date_time ON events.event_id = event_date_time.event_id $case INNER JOIN venue ON venue.id = events.venue_id 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 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 WHERE events.status = 1 $where GROUP BY events.event_id ORDER BY attendees DESC LIMIT ". $page_limit.", ".$per_page)->result(); $result = $this->db->query("
SELECT events.event_id, AVG(review.rate) AS rate,
MAX(booking.id) AS attendees, events.event_name,
events.event_discription AS event_description,events.seat_pricing,
events.custom_seat_layout, venue.layout, venue.layout_details,
`event_gallery`.`media_url`,favourite.status AS fav_status,
GROUP_CONCAT(DISTINCT tags.tag_name) AS tag
FROM events
INNER JOIN event_date_time ON events.event_id = event_date_time.event_id $case
INNER JOIN venue ON venue.id = events.venue_id
LEFT JOIN locality ON locality.id = venue.locality_id
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
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
WHERE events.status = 1 $where GROUP BY events.event_id ORDER BY attendees DESC LIMIT ". $page_limit.", ".$per_page)->result();
if(count($result)>0){ if(count($result)>0){
$resultData = array(); $resultData = array();
foreach ($result as $rs) { foreach ($result as $rs) {
...@@ -834,9 +855,9 @@ class Api_model extends CI_Model { ...@@ -834,9 +855,9 @@ class Api_model extends CI_Model {
} else { } else {
$res = array('status'=>0,'message'=>'No records found','code'=>'ER13'); $res = array('status'=>0,'message'=>'No records found','code'=>'ER13');
} }
} else { /*} else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }*/
} catch(Exception $e) { } catch(Exception $e) {
...@@ -855,5 +876,31 @@ class Api_model extends CI_Model { ...@@ -855,5 +876,31 @@ class Api_model extends CI_Model {
return $res; return $res;
} }
function payNow($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0) {
$this->db->insert('transaction',array('customer_id'=>$user_id,'booking_id'=>$data['booking_id'],'datetime'=>date('Y-m-d h:i:s'),'amount'=>$data['amount']));
$last_id = $this->db->insert_id();
$res = array('status'=>1,'transaction_id'=>$last_id);
}else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
}
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06');
}
return $res;
}
function update_payment($response,$transactionid,$last_id,$status){
try{
$this->db->update('transaction',array('transaction_id'=>$transactionid,'transaction_response'=>json_encode($response),'status'=>$status),array('id'=>$last_id));
$res = array('status'=>1);
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06');
}
return $res;
}
} }
?> ?>
\ No newline at end of file
...@@ -3,101 +3,270 @@ ...@@ -3,101 +3,270 @@
class Validation_model extends CI_Model { class Validation_model extends CI_Model {
public $validation_array = array( public $validation_array = array(
'login'=> array('email_id'=>array('required'=>array('code'=>'ER02', 'message'=>'Email id is null or empty'), 'login' => array(
'email'=>array('code'=>'ER03', 'message'=>'Invalid Email id') 'email_id' => array(
), 'required' => array(
'password'=>array('required'=>array('code'=>'ER04', 'message'=>'Password is null or empty'), 'code' => 'ER02',
) 'message' => 'Email id is null or empty'
), ) ,
'register'=> array('email_id'=>array('required'=>array('code'=>'ER02', 'message'=>'Email id is null or empty'), 'email' => array(
'email'=>array('code'=>'ER03', 'message'=>'Invalid Email id') 'code' => 'ER03',
), 'message' => 'Invalid Email id'
'phone'=>array('required'=>array('code'=>'ER07', 'message'=>'Phone no is null or empty'), )
'phone'=>array('code'=>'ER08', 'message'=>'Invalid Phone no'), ) ,
), 'password' => array(
'password'=>array('required'=>array('code'=>'ER04', 'message'=>'Password is null or empty'), 'required' => array(
) 'code' => 'ER04',
), 'message' => 'Password is null or empty'
'forgot'=> array('email_id'=>array('required'=>array('code'=>'ER02', 'message'=>'Email id is null or empty'), ) ,
'email'=>array('code'=>'ER03', 'message'=>'Invalid Email id') )
) ) ,
), 'register' => array(
'popular'=>array(), 'email_id' => array(
'category'=>array(), 'required' => array(
'locality'=>array(), 'code' => 'ER02',
'favourite'=>array('event_id'=>array('required'=>array('code'=>'ER16', 'message'=>'Event id is null or empty') 'message' => 'Email id is null or empty'
), ) ,
'auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'email' => array(
), 'code' => 'ER03',
'status'=>array('required'=>array('code'=>'ER18', 'message'=>'Favourite status is missing'), 'message' => 'Invalid Email id'
), )
), ) ,
'favouritelist'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'phone' => array(
), 'required' => array(
), 'code' => 'ER07',
'bookedlist'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'message' => 'Phone no is null or empty'
), ) ,
), 'phone' => array(
'bookingdetails'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'code' => 'ER08',
), 'message' => 'Invalid Phone no'
'bookingCode'=>array('required'=>array('code'=>'ER23', 'message'=>'Booking code is null or empty'), ) ,
), ) ,
), 'password' => array(
'cancel'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'required' => array(
), 'code' => 'ER04',
'bookingCode'=>array('required'=>array('code'=>'ER23', 'message'=>'Booking code is null or empty'), 'message' => 'Password is null or empty'
), ) ,
), )
'confirm'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), ) ,
), 'forgot' => array(
'bookingCode'=>array('required'=>array('code'=>'ER23', 'message'=>'Booking code is null or empty'), 'email_id' => array(
), 'required' => array(
), 'code' => 'ER02',
'userinfo'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'message' => 'Email id is null or empty'
), ) ,
), 'email' => array(
'profile'=>array('name'=>array('required'=>array('code'=>'ER27', 'message'=>'Name is null or empty') 'code' => 'ER03',
), 'message' => 'Invalid Email id'
'gender'=>array('required'=>array('code'=>'ER28', 'message'=>'Gender is null or empty') )
), )
'dob'=>array('required'=>array('code'=>'ER29', 'message'=>'Date of birth is null or empty') ) ,
), 'popular' => array() ,
'city'=>array('required'=>array('code'=>'ER30', 'message'=>'City no is null or empty') 'category' => array() ,
), 'locality' => array() ,
'auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'paymentResponse' => array() ,
), 'paymentFailureUrl' => array() ,
), 'paymentSuccessUrl' => array() ,
'tempbooking'=>array('event_id'=>array('required'=>array('code'=>'ER16', 'message'=>'Event id is null or empty') 'favourite' => array(
), 'event_id' => array(
'event_date_id'=>array('required'=>array('code'=>'ER33', 'message'=>'Event date and time is null or empty') 'required' => array(
), 'code' => 'ER16',
'amount'=>array('required'=>array('code'=>'ER35', 'message'=>'Amount is null or empty') 'message' => 'Event id is null or empty'
), )
'no_of_ticket'=>array('required'=>array('code'=>'ER36', 'message'=>'no of ticket is null or empty') ) ,
), 'auth_token' => array(
'auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'required' => array(
), 'code' => 'ER17',
), 'message' => 'User Id is null or empty'
'recommend'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), ) ,
), ) ,
), 'status' => array(
'search'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'required' => array(
), 'code' => 'ER18',
), 'message' => 'Favourite status is missing'
'discover'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), ) ,
), ) ,
'cat_id'=>array('required'=>array('code'=>'ER38', 'message'=>'Category id null or empty') ) ,
), 'favouritelist' => array(
), 'auth_token' => array(
'event'=>array('auth_token'=>array('required'=>array('code'=>'ER17', 'message'=>'User Id is null or empty'), 'required' => array(
), 'code' => 'ER17',
'event_id'=>array('required'=>array('code'=>'ER16', 'message'=>'Event id is null or empty') 'message' => 'User Id is null or empty'
), ) ,
), ) ,
'searchEvent'=>array() ) ,
'bookedlist' => array(
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
) ,
'bookingdetails' => array(
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
'bookingCode' => array(
'required' => array(
'code' => 'ER23',
'message' => 'Booking code is null or empty'
) ,
) ,
) ,
'cancel' => array(
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
'bookingCode' => array(
'required' => array(
'code' => 'ER23',
'message' => 'Booking code is null or empty'
) ,
) ,
) ,
'confirm' => array(
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
'bookingCode' => array(
'required' => array(
'code' => 'ER23',
'message' => 'Booking code is null or empty'
) ,
) ,
) ,
'userinfo' => array(
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
) ,
'profile' => array(
'name' => array(
'required' => array(
'code' => 'ER27',
'message' => 'Name is null or empty'
)
) ,
'gender' => array(
'required' => array(
'code' => 'ER28',
'message' => 'Gender is null or empty'
)
) ,
'dob' => array(
'required' => array(
'code' => 'ER29',
'message' => 'Date of birth is null or empty'
)
) ,
'city' => array(
'required' => array(
'code' => 'ER30',
'message' => 'City no is null or empty'
)
) ,
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
) ,
'tempbooking' => array(
'event_id' => array(
'required' => array(
'code' => 'ER16',
'message' => 'Event id is null or empty'
)
) ,
'event_date_id' => array(
'required' => array(
'code' => 'ER33',
'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(
'required' => array(
'code' => 'ER36',
'message' => 'no of ticket is null or empty'
)
) ,
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
) ,
'recommend' => array(
'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,
) ,
'search' => array(
/*'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,*/
) ,
'discover' => array(
// 'auth_token' => array(
// 'required' => array(
// 'code' => 'ER17',
// 'message' => 'User Id is null or empty'
// ) ,
// ) ,
'cat_id' => array(
'required' => array(
'code' => 'ER38',
'message' => 'Category id null or empty'
)
) ,
) ,
'event' => array(
/*'auth_token' => array(
'required' => array(
'code' => 'ER17',
'message' => 'User Id is null or empty'
) ,
) ,*/
'event_id' => array(
'required' => array(
'code' => 'ER16',
'message' => 'Event id is null or empty'
)
) ,
) ,
'payNow' => array(),
'searchEvent' => array()
); );
public function _consruct(){ public function _consruct(){
parent::_construct(); parent::_construct();
......
<html>
<head>
<title>Merchant Checkout Page</title>
</head>
<body>
<center><h1 style="margin-top: 20%">Please do not refresh this page...</h1></center>
<form action="<?= $requestUrl ?>" method="post" id="BayanPay_online_payment">
<input type="hidden" name="requestParameter" value="<?= $requestParameter ?>">
</form>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("BayanPay_online_payment").submit();
});
</script>
</body>
</html>
\ No newline at end of file
<form action="<?php echo $requestUrl; ?>" method="post" name="network_online_payment"
id="network_online_payment">
<?php echo '<input type="hidden" name="requestParameter" value='.$requestParameter.'>'; ?>
<input type="submit" value="Submit">
</form>
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