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
c1aa0b14
Commit
c1aa0b14
authored
Sep 10, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'production'
dc See merge request
!36
parents
c17641af
a66cc5d2
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
74 additions
and
66 deletions
+74
-66
Broker.php
application/controllers/Broker.php
+2
-0
Driver.php
application/controllers/Driver.php
+4
-4
Ride.php
application/controllers/Ride.php
+14
-6
generals_helper.php
application/helpers/generals_helper.php
+4
-3
Ride_model.php
application/models/Ride_model.php
+6
-39
add_broker.php
application/views/Broker/add_broker.php
+7
-1
edit.php
application/views/Broker/edit.php
+8
-2
add_company.php
application/views/Company/add_company.php
+1
-1
edit.php
application/views/Company/edit.php
+1
-1
scheduled_rides.php
application/views/Ride/scheduled_rides.php
+25
-8
view_rides.php
application/views/Ride/view_rides.php
+2
-1
No files found.
application/controllers/Broker.php
View file @
c1aa0b14
...
...
@@ -88,6 +88,7 @@ class Broker extends CI_Controller {
$err
=
1
;
$errMsg
=
'Choose a Company'
;
}
$_POST
[
'accept_trip_status'
]
=
(
isset
(
$_POST
[
'accept_trip_status'
])
&&
!
empty
(
$_POST
[
'accept_trip_status'
]))
?
$_POST
[
'accept_trip_status'
]
:
'S1'
;
if
(
$err
==
1
){
$flashMsg
[
'message'
]
=
$errMsg
;
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
...
...
@@ -192,6 +193,7 @@ class Broker extends CI_Controller {
$err
=
1
;
$errMsg
=
'Provide a State Name'
;
}
$_POST
[
'accept_trip_status'
]
=
(
isset
(
$_POST
[
'accept_trip_status'
])
&&
!
empty
(
$_POST
[
'accept_trip_status'
]))
?
$_POST
[
'accept_trip_status'
]
:
'S1'
;
if
(
$err
==
1
){
$flashMsg
[
'message'
]
=
$errMsg
;
...
...
application/controllers/Driver.php
View file @
c1aa0b14
...
...
@@ -139,8 +139,8 @@ class Driver extends CI_Controller {
$err
=
1
;
$errMsg
=
'Provide a valid Active Location'
;
}
else
{
$_POST
[
'
lat_driver
'
]
=
$acLatLng
[
'lat'
];
$_POST
[
'
lng_driver
'
]
=
$acLatLng
[
'lng'
];
$_POST
[
'
active_lat
'
]
=
$acLatLng
[
'lat'
];
$_POST
[
'
active_lng
'
]
=
$acLatLng
[
'lng'
];
}
}
...
...
@@ -318,8 +318,8 @@ class Driver extends CI_Controller {
$err
=
1
;
$errMsg
=
'Provide a valid Active Location'
;
}
else
{
$_POST
[
'
lat_driver
'
]
=
$acLatLng
[
'lat'
];
$_POST
[
'
lng_driver
'
]
=
$acLatLng
[
'lng'
];
$_POST
[
'
active_lat
'
]
=
$acLatLng
[
'lat'
];
$_POST
[
'
active_lng
'
]
=
$acLatLng
[
'lng'
];
}
if
(
$err
==
1
){
...
...
application/controllers/Ride.php
View file @
c1aa0b14
...
...
@@ -883,6 +883,11 @@ class Ride extends CI_Controller {
$succArr
=
array
();
if
(
is_array
(
$ride_ids
)){
if
(
!
empty
(
$drivers
)){
$this
->
db
->
query
(
"UPDATE drivers SET virtual_lat=active_lat,virtual_lng=active_lng,
expected_arrival_time=CONCAT('"
.
date
(
'Y-m-d '
)
.
"',online_start_time)
WHERE status='1'"
);
}
foreach
(
$ride_ids
AS
$ride_id
)
{
$status
=
$this
->
changeScheduler
(
$ride_id
,
$is_scheduled
,
$drivers
,
$no_driver
);
if
(
$status
==
1
){
...
...
@@ -1010,11 +1015,11 @@ class Ride extends CI_Controller {
if
(
!
empty
(
$value
[
'search'
]))
{
$where
=
array
();
if
(
strtolower
(
$value
[
'search'
])
==
'ss0'
){
$where_data
[]
=
"TD.is_scheduled='0' AND
TD.trip_status='S1'
"
;
$where_data
[]
=
"TD.is_scheduled='0' AND
(TD.trip_status=BK.accept_trip_status OR TD.broker_id=0)
"
;
}
else
if
(
strtolower
(
$value
[
'search'
])
==
'ss1'
){
$where_data
[]
=
"TD.is_scheduled='1'"
;
}
else
if
(
strtolower
(
$value
[
'search'
])
==
'err'
){
$where_data
[]
=
"
TD.trip_status!='S1'
"
;
$where_data
[]
=
"
(TD.trip_status!=BK.accept_trip_status OR TD.broker_id!=0)
"
;
}
else
{
foreach
(
$headerArr
as
$key
=>
$c
)
{
if
(
$c
==
'Medicaid_Number'
||
$c
==
'Members_First_Name'
||
...
...
@@ -1036,9 +1041,9 @@ class Ride extends CI_Controller {
if
(
empty
(
$json_ride
)){
continue
;
}
if
(
$json_ride
[
'Trip_Status'
]
==
'S1'
&&
!
empty
(
$ride
->
appointment_time
)
&&
$this
->
session
->
userdata
[
'user_type'
]
!=
1
&&
!
empty
(
$ride
->
appointment_time
)
&&
$ride
->
is_scheduled
!=
3
){
if
(
(
empty
(
$ride
->
trip_status
)
||
$ride
->
trip_status
==
$ride
->
accept_trip_status
)
&&
!
empty
(
$ride
->
appointment_time
)
&&
$this
->
session
->
userdata
[
'user_type'
]
!=
1
&&
!
empty
(
$ride
->
appointment_time
)
&&
$ride
->
is_scheduled
!=
3
){
$style
=
'style="color:red;";'
;
$ride
->
is_scheduled
=
(
isset
(
$ride
->
is_scheduled
))
?
$ride
->
is_scheduled
:
0
;
if
(
$ride
->
is_scheduled
==
1
){
...
...
@@ -1067,7 +1072,10 @@ class Ride extends CI_Controller {
}
$data
=
(
$key
==
'Appointment_Time'
&&
$ride
->
is_scheduled
==
3
)
?
'--'
:
$data
;
if
(
$key
==
'Is_Scheduled'
){
if
(
$json_ride
[
'Trip_Status'
]
==
'S1'
){
if
(
empty
(
$ride
->
drop_lat
)
||
empty
(
$ride
->
drop_lng
)
||
empty
(
$ride
->
pickup_lat
)
||
empty
(
$ride
->
pickup_lng
)){
$data
=
'ADD_ERR'
;
}
else
if
((
empty
(
$ride
->
trip_status
)
||
$ride
->
trip_status
==
$ride
->
accept_trip_status
)){
$data
=
(
$ride
->
is_scheduled
==
'1'
)
?
'SS1'
:
'SS0'
;
}
else
{
$data
=
'ERR'
;
...
...
application/helpers/generals_helper.php
View file @
c1aa0b14
...
...
@@ -135,11 +135,12 @@ function getLatLngFromLocation($location = ''){
}
function
getDistance
(
$lat1
,
$lng1
,
$lat2
,
$lng2
)
{
if
(
empty
(
$lat1
)
||
empty
(
$lat2
)
||
empty
(
$lng1
)
||
empty
(
$lng2
)){
$settings
=
getSettings
();
$thisObj
=
&
get_instance
();
if
(
empty
(
$lat1
)
||
empty
(
$lat2
)
||
empty
(
$lng1
)
||
empty
(
$lng2
)
||
empty
(
$settings
)){
return
;
}
$thisObj
=
&
get_instance
();
$url
=
"https://maps.googleapis.com/maps/api/distancematrix/json?origins="
.
$lat1
.
","
.
$lng1
.
"&destinations="
.
$lat2
.
","
.
$lng2
.
"&mode=driving"
.
"&key="
.
$thisObj
->
session
->
userdata
[
'settings'
][
'google_api_key'
];
$url
=
"https://maps.googleapis.com/maps/api/distancematrix/json?origins="
.
$lat1
.
","
.
$lng1
.
"&destinations="
.
$lat2
.
","
.
$lng2
.
"&mode=driving"
.
"&key="
.
$settings
[
'google_api_key'
];
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
...
...
application/models/Ride_model.php
View file @
c1aa0b14
...
...
@@ -66,8 +66,8 @@ class Ride_model extends CI_Model {
$cond
.=
implode
(
' '
,
$condArr
);
}
$sql
=
"SELECT TD.*,BK.broker_name,
AR.reason,VH.vehicle_id,VH.vehicle_type,TT.trip_type
,
TS.trip_status
$sql
=
"SELECT TD.*,BK.broker_name,
BK.accept_trip_status,AR.reason,VH.vehicle_id
,
VH.vehicle_type,TT.trip_type,TS.trip_status AS trip_status_code
FROM transport_details AS TD
LEFT JOIN brokers AS BK ON (TD.broker_id = BK.broker_id)
LEFT JOIN trip_type AS TT ON (TT.trip_id = TD.trip_type)
...
...
@@ -115,9 +115,11 @@ class Ride_model extends CI_Model {
$field
=
'count(TD.transport_id) AS count'
;
if
(
$scheduleCnt
==
1
){
$field
=
" TD.transport_id "
;
$cond
.=
" AND TD.is_scheduled='0' AND
TD.trip_status='S1'
"
;
$cond
.=
" AND TD.is_scheduled='0' AND
(TD.trip_status=BK.accept_trip_status OR TD.broker_id=0)
"
;
}
$sql
=
"SELECT
$field
FROM transport_details TD WHERE TD.status!='2' "
.
$cond
;
$sql
=
"SELECT
$field
FROM transport_details TD
LEFT JOIN brokers AS BK ON (TD.broker_id = BK.broker_id)
WHERE TD.status!='2' "
.
$cond
;
if
(
$scheduleCnt
==
1
){
$rideIds
=
array
();
...
...
@@ -239,41 +241,6 @@ class Ride_model extends CI_Model {
LIMIT 0,1"
;
$driverData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
if
(
empty
(
$driverData
)){
$sql
=
"SELECT GROUP_CONCAT(REQ.driver_id) AS assigned_drivers
FROM transport_details AS TD
INNER JOIN driver_request AS REQ ON (REQ.trip_id = TD.transport_id)
WHERE TD.driver_assign_status='0' AND TD.is_scheduled='1' AND
TD.appointment_time>"
.
strtotime
(
$arrTime
)
.
" AND TD.status IN (3) AND
TD.appointment_time<"
.
strtotime
(
$appDate
)
.
" AND REQ.status IN (0,1) AND
REQ.driver_id IN ("
.
implode
(
","
,
$drivers
)
.
")"
;
$prvDrivers
=
$this
->
db
->
query
(
$sql
);
$driverCond
=
''
;
if
(
!
empty
(
$prvDrivers
)
&&
$prvDrivers
->
num_rows
()
>
0
&&
!
empty
(
$prvDrivers
=
$prvDrivers
->
row_array
())
&&
isset
(
$prvDrivers
[
'assigned_drivers'
])
&&
!
empty
(
$prvDrivers
[
'assigned_drivers'
])){
$prvDrivers
=
explode
(
','
,
$prvDrivers
[
'assigned_drivers'
]);
$drivers
=
array_diff
(
$drivers
,
$prvDrivers
);
}
$sql
=
"SELECT DRV.driver_id,DRV.fcm_token,
3956*2*ASIN(SQRT(POWER(SIN(("
.
$locData
[
'plat'
]
.
"-DRV.lat_driver)*
pi()/180/2),2)+COS("
.
$locData
[
'plat'
]
.
"*pi()/180)*COS(DRV.lat_driver*
pi()/180)*POWER(SIN(("
.
$locData
[
'plng'
]
.
"-DRV.lng_driver)*
pi()/180/2),2))) AS distance
FROM drivers AS DRV
WHERE DRV.status = 1 AND DRV.driver_id IN (
$drv_ids
) AND
DRV.online_start_time<'
$appTime
' AND DRV.online_end_time>'
$appTime
' AND
DRV.fcm_token IS NOT NULL AND DRV.fcm_token!='' AND
(DRV.virtual_lat IS NULL OR DRV.virtual_lat='0' OR DRV.virtual_lat='' OR
DRV.virtual_lng IS NULL AND DRV.virtual_lng='0' AND DRV.virtual_lng='')
ORDER BY distance
LIMIT 0,1"
;
$driverData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
}
if
(
!
empty
(
$driverData
)
&&
!
empty
(
$driver_id
=
$driverData
[
'driver_id'
])){
$status
=
$this
->
db
->
update
(
'transport_details'
,
array
(
'driver_assign_status'
=>
0
,
'is_scheduled'
=>
'1'
,
'status'
=>
'3'
),
...
...
application/views/Broker/add_broker.php
View file @
c1aa0b14
...
...
@@ -33,7 +33,7 @@
<div
class=
"form-group has-feedback"
>
<label>
Broker Name
</label>
<input
type=
"text"
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
data-parsley-pattern=
"^[a-zA-Z\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"broker_name"
placeholder=
"Enter Broker Company Name"
>
data-parsley-minlength=
"2"
data-parsley-pattern=
"^[a-zA-Z
0-9
\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"broker_name"
placeholder=
"Enter Broker Company Name"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
<?php
if
(
$this
->
session
->
userdata
[
'user_type'
]
==
1
){
?>
...
...
@@ -68,6 +68,12 @@
<input
type=
"number"
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
required=
""
name=
"broker_phone"
placeholder=
"Enter Broker Phone"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
<div
class=
"form-group has-feedback"
>
<label>
Acceptable Trip Status
</label>
<input
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
required
name=
"accept_trip_status"
placeholder=
"Provide Schedulable Trip Status"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
</div>
...
...
application/views/Broker/edit.php
View file @
c1aa0b14
...
...
@@ -33,7 +33,7 @@
<div
class=
"form-group has-feedback"
>
<label>
Broker Name
</label>
<input
type=
"text"
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
value=
"
<?=
$broker_data
->
broker_name
?>
"
data-parsley-pattern=
"^[a-zA-Z\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"broker_name"
placeholder=
"Enter Company Name"
>
data-parsley-minlength=
"2"
value=
"
<?=
$broker_data
->
broker_name
?>
"
data-parsley-pattern=
"^[a-zA-Z
0-9
\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"broker_name"
placeholder=
"Enter Company Name"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
<?php
if
(
$this
->
session
->
userdata
[
'user_type'
]
==
1
){
?>
...
...
@@ -41,7 +41,7 @@
<label>
Select Company
</label>
<select
name=
"company_id"
class=
"form-control"
>
<option
selected
value=
""
>
All Company
</option>
<?php
<?php
if
(
!
empty
(
$company_data
)){
foreach
(
$company_data
as
$company
)
{
$chkFlg
=
(
$broker_data
->
company_id
==
$company
->
company_id
)
?
'selected'
:
''
;
...
...
@@ -69,6 +69,12 @@
data-parsley-minlength=
"2"
value=
"
<?=
$broker_data
->
broker_phone
?>
"
required=
""
name=
"broker_phone"
placeholder=
"Broker Phone"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
<div
class=
"form-group has-feedback"
>
<label>
Acceptable Trip Status
</label>
<input
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
required
name=
"accept_trip_status"
placeholder=
"Provide Schedulable Trip Status"
value=
"
<?=
$broker_data
->
accept_trip_status
?>
"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
</div>
<div
class=
"col-md-6"
>
...
...
application/views/Company/add_company.php
View file @
c1aa0b14
...
...
@@ -33,7 +33,7 @@
<div
class=
"form-group has-feedback"
>
<label
for=
"exampleInputEmail1"
>
Company Name
</label>
<input
type=
"text"
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
data-parsley-pattern=
"^[a-zA-Z\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"company_name"
placeholder=
"Enter Company Name"
>
data-parsley-minlength=
"2"
data-parsley-pattern=
"^[a-zA-Z
0-9
\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"company_name"
placeholder=
"Enter Company Name"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
<div
class=
"form-group has-feedback"
>
...
...
application/views/Company/edit.php
View file @
c1aa0b14
...
...
@@ -33,7 +33,7 @@
<div
class=
"form-group has-feedback"
>
<label
for=
"exampleInputEmail1"
>
Company Name
</label>
<input
type=
"text"
class=
"form-control required"
data-parsley-trigger=
"change"
data-parsley-minlength=
"2"
data-parsley-pattern=
"^[a-zA-Z\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"company_name"
value=
"
<?=
$company_data
->
company_name
?>
"
placeholder=
"Enter Company Name"
>
data-parsley-minlength=
"2"
data-parsley-pattern=
"^[a-zA-Z
0-9
\ . ! @ # $ % ^ & * () + = , \/]+$"
required=
""
name=
"company_name"
value=
"
<?=
$company_data
->
company_name
?>
"
placeholder=
"Enter Company Name"
>
<span
class=
"glyphicon form-control-feedback"
></span>
</div>
<div
class=
"form-group has-feedback"
>
...
...
application/views/Ride/scheduled_rides.php
View file @
c1aa0b14
...
...
@@ -58,13 +58,14 @@
<thead>
<tr>
<th
class=
"hidden"
>
ID
</th>
<th
width=
"100px"
>
Scheduled Time
</th>
<th
width=
"70px"
>
Arrival Time
</th>
<th
width=
"100px"
>
Coustomer Name
</th>
<th
width=
"100px"
>
Appointment
</th>
<th
width=
"70px"
>
Arrival
</th>
<th
width=
"100px"
>
Name
</th>
<th
width=
"100px"
>
Phone
</th>
<th
width=
"30px"
>
Mobility
</th>
<th
width=
"
90px"
>
Pick Up Address
</th>
<th
width=
"
90px"
>
Drop Address
</th>
<th
width=
"1
5
5px"
>
Rider Status
</th>
<th
width=
"
150px"
>
Pick Up
</th>
<th
width=
"
150px"
>
Drop
</th>
<th
width=
"1
0
5px"
>
Rider Status
</th>
<th
width=
"30px"
></th>
</tr>
</thead>
...
...
@@ -84,9 +85,25 @@
</th>
<th
class=
"center"
>
<?=
date
(
"d-M-y G:i"
,
$ride
->
appointment_time
)
?>
</th>
<th
class=
"center"
>
<?=
$ride
->
patient_name
?>
</th>
<th
class=
"center"
>
<?=
$ride
->
phone
?>
</th>
<th
class=
"center"
>
Med
</th>
<th
class=
"center"
>
<?=
$ride
->
pickup_location
?>
</th>
<th
class=
"center"
>
<?=
$ride
->
drop_location
?>
</th>
<th
class=
"center"
>
<?php
echo
$json_ride
[
'Pickup_Address'
]
.
' <br>'
.
'<small>City : </small>'
.
$json_ride
[
'Pickup_City'
]
.
' <br>'
.
'<small>State : </small>'
.
$json_ride
[
'Pickup_State'
]
.
' <br>'
.
'<small>Zip : </small>'
.
$json_ride
[
'Pickup_Zip_Code'
];
?>
</th>
<th
class=
"center"
>
<?php
echo
$json_ride
[
'Delivery_Name'
]
.
' <br>'
.
$json_ride
[
'Delivery_Address'
]
.
' <br>'
.
'<small>City : </small>'
.
$json_ride
[
'Delivery_City'
]
.
' <br>'
.
'<small>State : </small>'
.
$json_ride
[
'Delivery_State'
]
.
' <br>'
.
'<small>Zip : </small>'
.
$json_ride
[
'Delivery_Zip_Code'
]
.
' <br>'
.
'<small>Ph : </small>'
.
$json_ride
[
'Delivery_Phone_Number'
];
?>
</th>
<th
class=
"center"
>
<?php
if
(
!
empty
(
$ride
->
assigned_driver
)
||
$ride
->
driver_status
==
'3'
){
...
...
application/views/Ride/view_rides.php
View file @
c1aa0b14
...
...
@@ -134,7 +134,8 @@
</div>
</div>
<div
class=
"col-xs-12 driver-list-blk"
>
<?php
foreach
(
$drivers_data
AS
$driver
){
?>
<?php
foreach
(
$drivers_data
AS
$driver
){
if
(
empty
(
$driver
->
fcm_token
)){
continue
;
}
?>
<div
class=
"col-xs-3"
>
<div
class=
"col-xs-2"
>
<input
type=
"checkbox"
id=
"avlDriver_
<?=
$driver
->
driver_id
?>
"
class=
"Cards"
...
...
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