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
5 years ago
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dc
parent
fb0d7781
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
19 deletions
+20
-19
Webservices.php
application/controllers/Webservices.php
+16
-17
Ride_model.php
application/models/Ride_model.php
+4
-2
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 {
public
function
nearest_ambulance
()
{
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'
]))
{
$auth
=
apache_request_headers
()[
'Auth'
];
$request
[
'auth'
]
=
$auth
;
$result
=
$this
->
Webservice_model
->
nearest_ambulance
(
$request
);
if
(
$result
)
{
print
json_encode
(
array
(
'status'
=>
'success'
,
'data'
=>
$result
));
}
else
{
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Something Went wrong'
,
'error'
=>
'503'
));
$postdata
=
$_GET
;
if
(
empty
(
$postdata
)
||
!
isset
(
$postdata
[
'latitude'
])
||
empty
(
$postdata
[
'latitude'
])
||
!
isset
(
$postdata
[
'longitude'
])
||
empty
(
$postdata
[
'longitude'
])){
print
json_encode
(
array
(
'status'
=>
'error'
,
'message'
=>
'Data missing'
,
'error'
=>
'504'
));
exit
;
}
$postdata
[
'auth'
]
=
$auth
;
$result
=
$this
->
Webservice_model
->
nearest_ambulance
(
$postdata
);
if
(
$result
)
{
print
json_encode
(
array
(
'status'
=>
'success'
,
'data'
=>
$result
));
exit
;
}
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 {
if
(
empty
(
$ride_data
)){
return
;
}
foreach
(
$ride_data
AS
$ride
)
{
if
(
empty
(
$ride
[
'pickup_lat'
])
||
empty
(
$ride
[
'pickup_lng'
])){
continue
;
}
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
;
}
$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
)){
continue
;
}
if
(
!
empty
(
$driver_data
)
&&
!
empty
(
$driver_data
[
'driver_id'
])
&&
!
empty
(
$driver_data
[
'distance'
])
&&
!
empty
(
$driver_data
[
'fcm_token'
])){
$fcm_data
=
array
(
'title'
=>
'Ride Request'
,
'message'
=>
'Emergency Ride Request'
,
...
...
@@ -535,5 +536,4 @@ class Webservices extends CI_Controller {
}
}
}
}
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
application/models/Ride_model.php
View file @
3eb294e0
...
...
@@ -199,9 +199,11 @@ class Ride_model extends CI_Model {
$driver_id
=
$nearByDriver
[
'driver_id'
];
$status
=
$this
->
db
->
update
(
'transport_details'
,
array
(
'driver_assign_status'
=>
'0'
,
'is_scheduled'
=>
'1'
,
'assigned_driver'
=>
$driver_id
,
'status'
=>
'3'
),
array
(
'driver_assign_status'
=>
'0'
,
'is_scheduled'
=>
'1'
,
'status'
=>
'3'
),
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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
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