Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TimeOutAdmin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TimeOut
TimeOutAdmin
Commits
9e63afa9
Commit
9e63afa9
authored
Jan 27, 2020
by
Jansa Jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in booked api for web and app
parent
fa4e0f32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
56 deletions
+109
-56
Api.php
application/controllers/Api.php
+2
-1
Webservice.php
application/controllers/Webservice.php
+2
-1
Api_model.php
application/models/Api_model.php
+0
-0
Webservice_model.php
application/models/Webservice_model.php
+105
-54
No files found.
application/controllers/Api.php
View file @
9e63afa9
...
...
@@ -156,7 +156,8 @@ class Api extends CI_Controller {
public
function
bookedlist
()
{
$data
=
(
array
)
json_decode
(
file_get_contents
(
'php://input'
));
$data
[
'auth_token'
]
=
$this
->
auth_token
;
$res
=
$this
->
Api_model
->
bookedlist
(
$data
);
$res_count
=
$this
->
Webservice_model
->
bookedlist
(
$data
,
0
,
0
);
$res
=
$this
->
Api_model
->
bookedlist
(
$data
,
10
,
''
,
$res_count
);
if
(
$res
[
'status'
]
!=
0
){
$this
->
response
(
$res
[
'data'
]);
}
...
...
application/controllers/Webservice.php
View file @
9e63afa9
...
...
@@ -311,7 +311,8 @@ class Webservice extends CI_Controller {
public
function
get_booking_list
()
{
$data
=
$_GET
;
$data
[
'auth_token'
]
=
$this
->
auth_token
;
$res
=
$this
->
Webservice_model
->
bookedlist
(
$data
);
$res_count
=
$this
->
Webservice_model
->
bookedlist
(
$data
,
0
,
0
);
$res
=
$this
->
Webservice_model
->
bookedlist
(
$data
,
10
,
''
,
$res_count
);
if
(
sizeof
(
$res
[
'data'
])
&&
$res
[
'status'
]
!=
0
){
$this
->
responseBookList
(
$res
[
'data'
]);
}
elseif
(
sizeof
(
$res
[
'data'
]
==
0
)
&&
$res
[
'status'
]
!=
0
){
...
...
application/models/Api_model.php
View file @
9e63afa9
This diff is collapsed.
Click to expand it.
application/models/Webservice_model.php
View file @
9e63afa9
...
...
@@ -1428,66 +1428,50 @@ class Webservice_model extends CI_Model {
return
$res
;
}
function
bookedlist
(
$data
)
{
function
bookedlist
(
$data
,
$per_page
=
''
,
$page
=
''
,
$count
=
''
)
{
try
{
$per_page
=
10
;
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
if
(
$user_id
>
0
)
{
$count
=
$this
->
db
->
query
(
"
SELECT ODR.order_id FROM orders AS ODR
INNER JOIN booking AS BOK ON
(ODR.booking_id=BOK.bookId AND BOK.status IN (0,1,2,3,5,6))
INNER JOIN flight_booking AS FBK ON
(ODR.booking_id=FBK.flight_book_id AND FBK.status IN (0,1,2,3,5))
INNER JOIN hotel_booking AS HBK ON
(ODR.booking_id=HBK.hotel_book_id AND HBK.status IN (0,1,2,3,5))
WHERE BOK.customer_id='
$user_id
' AND EVT.status='1'
GROUP BY ODR.order_id"
)
->
num_rows
();
if
(
$count
>
0
)
{
if
(
isset
(
$data
[
'page'
]))
{
$page
=
$data
[
'page'
];
}
else
{
$page
=
1
;
}
$page_limit
=
(
$page
-
1
)
*
$per_page
;
if
(
$page
==
0
&&
$per_page
==
0
){
$page
=
$page
;
}
else
{
$page
=
(
isset
(
$data
[
'page'
]))
?
$data
[
'page'
]
:
1
;
}
$page_limit
=
(
$page
-
1
)
*
$per_page
;
$cond
=
(
$per_page
==
0
&&
$page
==
0
)
?
''
:
"LIMIT
$page_limit
,
$per_page
"
;
$bookedData
=
$this
->
db
->
query
(
"
SELECT ODR.order_id,ODR.order_type,ODR.booking_id FROM orders AS ODR
LEFT JOIN booking AS BOK ON
(ODR.booking_id=BOK.bookId AND BOK.status IN (0,1,2,3,5,6) AND
BOK.customer_id='
$user_id
')
LEFT JOIN flight_booking AS FBK ON
(ODR.booking_id=FBK.flight_book_id AND FBK.status IN (0,1,2,3,5) AND
FBK.customer_id='
$user_id
')
LEFT JOIN hotel_booking AS HBK ON
(ODR.booking_id=HBK.hotel_book_id AND HBK.status IN (0,1,2,3,5) AND
HBK.customer_id='
$user_id
')
GROUP BY ODR.order_id
$cond
"
);
if
(
$per_page
==
0
&&
$page
==
0
){
return
$bookedData
->
num_rows
();
}
if
(
count
(
$bookedData
)
>
0
)
{
if
(
$count
>
$page_limit
)
{
$countryData
=
$this
->
getCountryData
(
$user_id
);
$lang
=
$countryData
[
'language_code'
];
$sql
=
"SELECT booking.bookId AS booking_id,event_date_time.date,
translator_event.event_name,booking.qrcode AS event_image,
venue.location,event_date_time.time,booking.event_id,
booking.no_of_ticket AS ticket_count,events.has_payment,
booking.status AS booking_status,transaction.status AS transaction_status
FROM booking
INNER JOIN events ON booking.event_id = events.event_id
INNER JOIN event_date_time ON booking.event_date_id = event_date_time.id
INNER JOIN venue ON venue.id = events.venue_id
INNER JOIN translator_event ON translator_event.event_id=events.event_id
LEFT JOIN transaction ON transaction.booking_id=booking.bookId
WHERE booking.customer_id = '
$user_id
' AND booking.status IN (0,1,2,6)
AND (translator_event.language_code='
$lang
' OR
translator_event.language_code='EN')
GROUP BY booking.id
ORDER BY booking.id DESC
LIMIT
$page_limit
,
$per_page
"
;
$result
=
$this
->
db
->
query
(
$sql
)
->
result_array
();
if
(
!
empty
(
$result
)){
foreach
(
$result
AS
$key
=>
$value
)
{
if
(
$value
[
'has_payment'
]
==
'1'
&&
$value
[
'transaction_status'
]
!=
'1'
){
unset
(
$result
[
$key
]);
}
$bookData
=
array
();
foreach
((
$bookedData
=
$bookedData
->
result_array
())
as
$key
=>
$value
)
{
switch
(
$value
[
'order_type'
]){
case
1
:
$resp
=
$this
->
getEventData
(
$value
[
'booking_id'
],
$user_id
);
break
;
case
2
:
$resp
=
$this
->
getHotelData
(
$value
[
'booking_id'
],
$user_id
);
break
;
case
3
:
$resp
=
$this
->
getFlightData
(
$value
[
'booking_id'
],
$user_id
);
break
;
}
if
(
!
empty
(
$resp
)){
$bookData
[]
=
$resp
;
}
$result
=
array_values
(
$result
);
}
$meta
=
array
(
'total_pages'
=>
ceil
(
$count
/
$per_page
),
'total'
=>
$count
,
'current_page'
=>
$page
,
'per_page'
=>
$per_page
);
$response
=
array
(
'bookings'
=>
$result
,
'meta'
=>
$meta
);
$res
=
array
(
'status'
=>
1
,
'data'
=>
$response
);
$meta
=
array
(
'total_pages'
=>
ceil
(
$count
/
$per_page
),
'total'
=>
$count
,
'current_page'
=>
$page
,
'per_page'
=>
$per_page
);
$res
=
array
(
'status'
=>
1
,
'data'
=>
array
(
'bookings'
=>
$bookData
,
'meta'
=>
$meta
));
}
else
{
$res
=
array
(
'status'
=>
1
,
'data'
=>
[]);
}
...
...
@@ -1503,6 +1487,73 @@ class Webservice_model extends CI_Model {
return
$res
;
}
function
getEventData
(
$booking_id
=
''
,
$user_id
=
''
){
$countryData
=
$this
->
getCountryData
(
$user_id
);
$lang
=
$countryData
[
'language_code'
];
$sql
=
"SELECT booking.bookId AS booking_id,event_date_time.date,
translator_event.event_name,booking.qrcode AS event_image,
venue.location,event_date_time.time,booking.event_id,
booking.no_of_ticket AS ticket_count,events.has_payment,
booking.status AS booking_status,transaction.status AS transaction_status
FROM booking
INNER JOIN events ON booking.event_id = events.event_id
INNER JOIN event_date_time ON booking.event_date_id = event_date_time.id
INNER JOIN venue ON venue.id = events.venue_id
INNER JOIN translator_event ON translator_event.event_id=events.event_id
LEFT JOIN transaction ON transaction.booking_id=booking.bookId
WHERE (translator_event.language_code='
$lang
' OR translator_event.language_code='EN').
AND booking.bookId='
$booking_id
' AND events.has_payment != '1'
AND transaction.status = '1'"
;
return
$this
->
db
->
query
(
$sql
)
->
row_array
();
}
function
getHotelData
(
$booking_id
=
''
,
$user_id
=
''
){
$sql
=
"SELECT HBK.hotel_book_id AS bookId,HBK.hotel_name AS event_name,
HBK.qrcode AS event_image,HBK.checkin AS date, HBK.id AS event_id,
HBK.status AS booking_status,TRS.status AS transaction_status,
HBK.traveller_details
FROM hotel_booking AS HBK
LEFT JOIN transaction AS TRS ON TRS.booking_id=HBK.hotel_book_id
WHERE HBK.hotel_book_id='
$booking_id
'"
;
$hotelData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
if
(
empty
(
$hotelData
)){
return
;
}
$trvlDtls
=
(
isset
(
$hotelData
[
'traveller_details'
])
&&
!
empty
(
$hotelData
[
'traveller_details'
]))
?
json_decode
(
$hotelData
[
'traveller_details'
])
:
''
;
$hotelData
[
'location'
]
=
(
!
empty
(
$trvlDtls
)
&&
isset
(
$trvlDtls
->
hotel_address
))
?
$trvlDtls
->
hotel_address
:
''
;
$hotelData
[
'ticket_count'
]
=
(
!
empty
(
$trvlDtls
)
&&
isset
(
$trvlDtls
->
roomDetails
->
room
))
?
$trvlDtls
->
roomDetails
->
room
.
' Room'
:
''
;
$hotelData
[
'time'
]
=
'11:00'
;
$hotelData
[
'has_payment'
]
=
1
;
unset
(
$hotelData
[
'traveller_details'
]);
return
$hotelData
;
}
function
getFlightData
(
$booking_id
=
''
,
$user_id
=
''
){
$sql
=
"SELECT FBK.flight_book_id AS bookId,FBK.flight_name AS event_name,FBK.id AS event_id,
FBK.qrcode AS event_image,FBK.departure_date AS date,
FBK.status AS booking_status,TRS.status AS transaction_status,
FBK.traveller_details
FROM flight_booking AS FBK
LEFT JOIN transaction AS TRS ON TRS.booking_id=FBK.flight_book_id
WHERE FBK.flight_book_id='
$booking_id
'"
;
$flightData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
if
(
empty
(
$flightData
)){
return
;
}
$trvlDtls
=
(
isset
(
$flightData
[
'traveller_details'
])
&&
!
empty
(
$flightData
[
'traveller_details'
]))
?
json_decode
(
$flightData
[
'traveller_details'
])
:
''
;
$flightData
[
'location'
]
=
(
!
empty
(
$trvlDtls
))
?
$trvlDtls
->
fromAirportCity
.
' - '
.
$trvlDtls
->
toAirportCity
:
''
;
$flightData
[
'ticket_count'
]
=
(
!
empty
(
$trvlDtls
))
?
(
int
)
$trvlDtls
->
passengerDetails
->
adult
+
(
int
)
$trvlDtls
->
passengerDetails
->
children
+
(
int
)
$trvlDtls
->
passengerDetails
->
infant
:
''
;
$fghtTme
=
explode
(
"T"
,
$flightData
[
'date'
]);
unset
(
$flightData
[
'traveller_details'
],
$flightData
[
'date'
]);
$flightData
[
'date'
]
=
(
isset
(
$fghtTme
[
0
])
&&
!
empty
(
$fghtTme
[
0
]))
?
$fghtTme
[
0
]
:
''
;
$flightData
[
'time'
]
=
(
isset
(
$fghtTme
[
1
])
&&
!
empty
(
$fghtTme
[
1
]))
?
$fghtTme
[
1
]
:
''
;
$flightData
[
'has_payment'
]
=
1
;
return
$flightData
;
}
function
get_settings
(
$data
)
{
try
{
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment