Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nemt_backend
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
Tobin
nemt_backend
Commits
3eb294e0
Commit
3eb294e0
authored
Jul 03, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dc
parent
fb0d7781
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
21 deletions
+22
-21
Webservices.php
application/controllers/Webservices.php
+17
-18
Ride_model.php
application/models/Ride_model.php
+5
-3
Webservice_model.php
application/models/Webservice_model.php
+0
-0
No files found.
application/controllers/Webservices.php
View file @
3eb294e0
...
@@ -360,19 +360,23 @@ class Webservices extends CI_Controller {
...
@@ -360,19 +360,23 @@ class Webservices extends CI_Controller {
public
function
nearest_ambulance
()
{
public
function
nearest_ambulance
()
{
header
(
'Content-type: application/json'
);
header
(
'Content-type: application/json'
);
if
(
!
isset
(
apache_request_headers
()[
'Auth'
])
||
empty
(
$auth
=
apache_request_headers
()[
'Auth'
]))
{
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Auth Tocken Missing'
,
'error'
=>
'503'
));
exit
;
}
if
(
isset
(
apache_request_headers
()[
'Auth'
]))
{
$postdata
=
$_GET
;
$auth
=
apache_request_headers
()[
'Auth'
];
if
(
empty
(
$postdata
)
||
$request
[
'auth'
]
=
$auth
;
!
isset
(
$postdata
[
'latitude'
])
||
empty
(
$postdata
[
'latitude'
])
||
$result
=
$this
->
Webservice_model
->
nearest_ambulance
(
$request
);
!
isset
(
$postdata
[
'longitude'
])
||
empty
(
$postdata
[
'longitude'
])){
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Data missing'
,
'error'
=>
'504'
));
exit
;
if
(
$result
)
{
}
print
json_encode
(
array
(
'status'
=>
'success'
,
'data'
=>
$result
));
$postdata
[
'auth'
]
=
$auth
;
}
else
{
$result
=
$this
->
Webservice_model
->
nearest_ambulance
(
$postdata
);
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Something Went wrong'
,
'error'
=>
'503'
));
}
if
(
$result
)
{
print
json_encode
(
array
(
'status'
=>
'success'
,
'data'
=>
$result
));
exit
;
}
else
{
}
else
{
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Something Went wrong'
,
'error'
=>
'50
3'
))
;
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Something Went wrong'
,
'error'
=>
'50
5'
));
exit
;
}
}
}
}
...
@@ -512,21 +516,18 @@ class Webservices extends CI_Controller {
...
@@ -512,21 +516,18 @@ class Webservices extends CI_Controller {
if
(
empty
(
$ride_data
)){
if
(
empty
(
$ride_data
)){
return
;
return
;
}
}
foreach
(
$ride_data
AS
$ride
)
{
foreach
(
$ride_data
AS
$ride
)
{
if
(
empty
(
$ride
[
'pickup_lat'
])
||
empty
(
$ride
[
'pickup_lng'
])){
if
(
empty
(
$ride
[
'pickup_lat'
])
||
empty
(
$ride
[
'pickup_lng'
])){
continue
;
continue
;
}
}
if
(
$ride
[
'request_type'
]
==
3
&&
if
(
$ride
[
'request_type'
]
==
3
&&
(
empty
(
$ride
[
'appointment_time'
])
||
$ride
[
'appointment_time'
]
<
strtotime
(
date
(
'Y-m-d H:i:s'
)))){
(
empty
(
$ride
[
'appointment_time'
])
||
$ride
[
'appointment_time'
]
<
strtotime
(
date
(
'Y-m-d H:i:s'
)))){
continue
;
continue
;
}
}
$driver_data
=
$this
->
Webservice_model
->
getAvailableDrivers
(
$ride
[
'pickup_lat'
],
$ride
[
'pickup_lng'
]);
$driver_data
=
$this
->
Webservice_model
->
getAvailableDrivers
(
$ride
[
'pickup_lat'
],
$ride
[
'pickup_lng'
]);
if
(
empty
(
$driver_data
)){
if
(
empty
(
$driver_data
)){
continue
;
continue
;
}
}
if
(
!
empty
(
$driver_data
)
&&
!
empty
(
$driver_data
[
'driver_id'
])
&&
if
(
!
empty
(
$driver_data
)
&&
!
empty
(
$driver_data
[
'driver_id'
])
&&
!
empty
(
$driver_data
[
'distance'
])
&&
!
empty
(
$driver_data
[
'fcm_token'
])){
!
empty
(
$driver_data
[
'distance'
])
&&
!
empty
(
$driver_data
[
'fcm_token'
])){
$fcm_data
=
array
(
'title'
=>
'Ride Request'
,
'message'
=>
'Emergency Ride Request'
,
$fcm_data
=
array
(
'title'
=>
'Ride Request'
,
'message'
=>
'Emergency Ride Request'
,
...
@@ -535,5 +536,4 @@ class Webservices extends CI_Controller {
...
@@ -535,5 +536,4 @@ class Webservices extends CI_Controller {
}
}
}
}
}
}
}
?>
}
?>
\ No newline at end of file
application/models/Ride_model.php
View file @
3eb294e0
...
@@ -199,9 +199,11 @@ class Ride_model extends CI_Model {
...
@@ -199,9 +199,11 @@ class Ride_model extends CI_Model {
$driver_id
=
$nearByDriver
[
'driver_id'
];
$driver_id
=
$nearByDriver
[
'driver_id'
];
$status
=
$this
->
db
->
update
(
'transport_details'
,
$status
=
$this
->
db
->
update
(
'transport_details'
,
array
(
'driver_assign_status'
=>
'0'
,
'is_scheduled'
=>
'1'
,
array
(
'driver_assign_status'
=>
'0'
,
'is_scheduled'
=>
'1'
,
'status'
=>
'3'
),
'assigned_driver'
=>
$driver_id
,
'status'
=>
'3'
),
array
(
'transport_id'
=>
$ride_id
));
array
(
'transport_id'
=>
$ride_id
));
$this
->
db
->
insert
(
'driver_request'
,
array
(
'trip_id'
=>
$ride_id
,
'driver_id'
=>
$driver_id
,
'request_time'
=>
date
(
'Y-m-d H:i:s'
),
'status'
=>
'0'
));
return
$status
;
return
$status
;
}
}
}
}
...
...
application/models/Webservice_model.php
View file @
3eb294e0
This diff is collapsed.
Click to expand it.
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