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
4bec71e0
Commit
4bec71e0
authored
Dec 18, 2018
by
Tobin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'production'
daily commit See merge request
!11
parents
400fa2a1
f79e840d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
37 deletions
+56
-37
Ride.php
application/controllers/Ride.php
+9
-10
Ride_model.php
application/models/Ride_model.php
+40
-24
edit.php
application/views/Driver/edit.php
+2
-2
view.php
application/views/Driver/view.php
+1
-1
nemt_custom.js
assets/js/nemt_custom.js
+4
-0
No files found.
application/controllers/Ride.php
View file @
4bec71e0
...
...
@@ -733,15 +733,16 @@ class Ride extends CI_Controller {
if
(
$status
==
1
){
$succArr
[]
=
$ride_id
;
}
$result
[
'status'
]
=
'1'
;
$result
[
'succArr'
]
=
$succArr
;
}
}
else
{
$status
=
$this
->
changeScheduler
(
$ride_ids
,
$is_scheduled
,
$drivers
,
$no_driver
);
if
(
$status
==
1
){
$
result
[
'status'
]
=
'1'
;
$result
[
'succArr'
]
=
array
(
$ride_ids
);
$
succArr
[]
=
$ride_ids
;
}
}
if
(
!
empty
(
$succArr
)){
$result
[
'status'
]
=
1
;
$result
[
'succArr'
]
=
$succArr
;
}
echo
json_encode
(
$result
);
exit
;
}
...
...
@@ -753,9 +754,9 @@ class Ride extends CI_Controller {
}
if
(
$is_scheduled
==
1
){
$ride_data
=
$this
->
Ride_model
->
getRideData
(
$ride_id
);
if
(
empty
(
$ride_data
))
if
(
empty
(
$ride_data
)
||
(
isset
(
$ride_data
->
is_scheduled
)
&&
$ride_data
->
is_scheduled
!=
'0'
))
return
$status
;
$pickup_location
=
$ride_data
->
pickup_location
;
$appointment_time
=
$ride_data
->
appointment_time
;
...
...
@@ -768,11 +769,9 @@ class Ride extends CI_Controller {
$status
=
$this
->
Ride_model
->
autoAssignDriver
(
$ride_id
,
$appointment_time
,
array
(
'lat'
=>
$pickupLocData
[
'lat'
],
'lng'
=>
$pickupLocData
[
'lng'
]),
$drivers
,
$no_driver
);
if
(
!
$status
){
return
$status
;
}
}
}
else
{
$status
=
$this
->
Ride_model
->
changeSchuduleStatus
(
$ride_id
,
$is_scheduled
);
}
return
$status
;
}
...
...
application/models/Ride_model.php
View file @
4bec71e0
...
...
@@ -10,7 +10,7 @@ class Ride_model extends CI_Model {
if
(
!
empty
(
$reason
)){
return
$reason
->
result
();
}
return
;
return
0
;
}
function
getTripType
(){
...
...
@@ -18,7 +18,7 @@ class Ride_model extends CI_Model {
if
(
!
empty
(
$tripType
)){
return
$tripType
->
result
();
}
return
;
return
0
;
}
function
uploadRides
(
$insertArr
=
array
(),
$custInsrData
=
array
()){
...
...
@@ -68,7 +68,7 @@ class Ride_model extends CI_Model {
ORDER BY TD.transport_id DESC"
;
$ride_data
=
$this
->
db
->
query
(
$sql
);
if
(
empty
(
$ride_data
)){
return
;
return
0
;
}
return
(
!
empty
(
$ride_id
))
?
$ride_data
->
row
()
:
$ride_data
->
result
();
}
...
...
@@ -124,12 +124,12 @@ class Ride_model extends CI_Model {
function
changeSchuduleStatus
(
$ride_id
=
''
,
$is_scheduled
=
'0'
){
if
(
empty
(
$ride_id
)){
return
;
return
0
;
}
$upArr
=
array
(
'is_scheduled'
=>
$is_scheduled
);
if
(
$is_scheduled
==
0
){
$upArr
[
'status'
]
=
'
0
'
;
$upArr
[
'status'
]
=
'
1
'
;
$upArr
[
'assigned_driver'
]
=
'0'
;
$upArr
[
'driver_assign_status'
]
=
NULL
;
...
...
@@ -142,34 +142,32 @@ class Ride_model extends CI_Model {
function
deleteAssignedRider
(
$ride_id
=
''
){
if
(
empty
(
$ride_id
)){
return
;
return
0
;
}
$this
->
db
->
delete
(
'ride_status'
,
array
(
'ride_id'
=>
$ride_id
));
}
function
autoAssignDriver
(
$ride_id
=
''
,
$appointment_time
=
''
,
$pickupLoc
=
array
(),
$drivers
=
array
(),
$no_driver
=
'0'
){
if
(
empty
(
$ride_id
)){
return
;
if
(
empty
(
$ride_id
)
||
empty
(
$appointment_time
)
||
empty
(
$pickupLoc
)
||
!
isset
(
$pickupLoc
[
'lat'
])
||
$pickupLoc
[
'lat'
]
==
''
||
!
isset
(
$pickupLoc
[
'lng'
])
||
$pickupLoc
[
'lng'
]
==
''
){
return
0
;
}
if
(
!
empty
(
$drivers
)
&&
!
empty
(
$appointment_time
)
&&
!
empty
(
$pickupLoc
)
&&
isset
(
$pickupLoc
[
'lat'
])
&&
!
$pickupLoc
[
'lat'
]
==
''
&&
isset
(
$pickupLoc
[
'lng'
])
&&
!
$pickupLoc
[
'lng'
]
==
''
){
$time
=
date
(
"G:i"
,
$appointment_time
);
$date
=
date
(
"d-m-Y"
,
$appointment_time
);
$appTime
=
date
(
"H:i"
,
$appointment_time
);
$arrTime
=
date
(
"H:i"
,
$appointment_time
-
3600
);
$endTime
=
date
(
"G:i"
,
strtotime
(
$time
)
+
60
*
60
)
;
$startTime
=
date
(
"G:i"
,
strtotime
(
$time
)
-
90
*
60
)
;
$endDateTime
=
$appointment_time
+
1200
;
$startDateTime
=
$appointment_time
-
4800
;
$endDateTime
=
strtotime
(
$date
.
' '
.
$endTime
);
$startDateTime
=
strtotime
(
$date
.
' '
.
$startTime
);
if
(
!
empty
(
$drivers
)){
$sql
=
"SELECT GROUP_CONCAT(TD.assigned_driver) AS assigned_drivers
FROM transport_details AS TD
INNER JOIN drivers AS DRV ON (DRV.driver_id = TD.assigned_driver)
WHERE TD.driver_assign_status='0' AND TD.assigned_driver<>'0' AND TD.is_scheduled='1' AND
WHERE TD.driver_assign_status='0' AND TD.assigned_driver<>'0' AND
TD.is_scheduled='1' AND
TD.appointment_time>
$startDateTime
AND TD.appointment_time<
$endDateTime
AND
TD.status IN (4,5,8) AND TD.assigned_driver IN ("
.
implode
(
","
,
$drivers
)
.
")"
;
...
...
@@ -185,11 +183,13 @@ class Ride_model extends CI_Model {
}
if
(
!
empty
(
$drivers
)){
$sql
=
"SELECT DRV.driver_id,3956*2*ASIN(SQRT(POWER(SIN(("
.
$pickupLoc
[
'lat'
]
.
"-DRV.active_loc_lat)*
$sql
=
"SELECT DRV.driver_id,3956*2*ASIN(SQRT(POWER(SIN(("
.
$pickupLoc
[
'lat'
]
.
"
-DRV.active_loc_lat)*
pi()/180/2),2)+COS("
.
$pickupLoc
[
'lat'
]
.
"*pi()/180)*COS(DRV.active_loc_lat*pi()/180)*
POWER(SIN(("
.
$pickupLoc
[
'lng'
]
.
"-DRV.active_loc_lng)*pi()/180/2),2))) AS distance
FROM drivers AS DRV
WHERE DRV.status = 1 AND DRV.driver_id IN ("
.
implode
(
","
,
$drivers
)
.
")
WHERE DRV.status = 1 AND DRV.driver_id IN ("
.
implode
(
","
,
$drivers
)
.
") AND
DRV.online_start_time<'
$arrTime
' AND DRV.online_end_time>'
$appTime
'
ORDER BY distance
LIMIT 0,1"
;
$driverData
=
$this
->
db
->
query
(
$sql
);
...
...
@@ -199,16 +199,32 @@ class Ride_model extends CI_Model {
$driver_id
=
$nearByDriver
[
'driver_id'
];
$status
=
$this
->
db
->
update
(
'transport_details'
,
array
(
'driver_assign_status'
=>
'0'
,
array
(
'driver_assign_status'
=>
'0'
,
'is_scheduled'
=>
'1'
,
'assigned_driver'
=>
$driver_id
,
'status'
=>
'3'
),
array
(
'transport_id'
=>
$ride_id
));
return
$status
;
}
}
}
$assignStatus
=
(
$no_driver
==
'1'
)
?
'2'
:
'1'
;
if
(
$no_driver
==
'1'
){
$company_id
=
$this
->
session
->
userdata
[
'id'
];
$sql
=
"SELECT transport_id
FROM transport_details
WHERE company_id='
$company_id
' AND driver_assign_status='2' AND
appointment_time>=
$startDateTime
AND appointment_time<=
$endDateTime
AND
status IN (4,5,8)"
;
$noDrvAvl
=
$this
->
db
->
query
(
$sql
);
if
(
!
empty
(
$noDrvAvl
)
&&
$noDrvAvl
->
num_rows
()
<=
0
){
$status
=
$this
->
db
->
update
(
'transport_details'
,
array
(
'driver_assign_status'
=>
'2'
,
'status'
=>
'4'
,
'is_scheduled'
=>
'1'
),
array
(
'transport_id'
=>
$ride_id
));
return
$status
;
}
}
$status
=
$this
->
db
->
update
(
'transport_details'
,
array
(
'driver_assign_status'
=>
$assignStatus
,
'status'
=>
'3
'
),
array
(
'driver_assign_status'
=>
'1'
,
'status'
=>
'3'
,
'is_scheduled'
=>
'1
'
),
array
(
'transport_id'
=>
$ride_id
));
return
$status
;
}
...
...
application/views/Driver/edit.php
View file @
4bec71e0
...
...
@@ -79,7 +79,7 @@
data-autoclose=
"true"
style=
"padding-right: 5px;width: 50%;"
>
<div
class=
"input-group date"
id=
'online_start_time'
>
<input
type=
"text"
class=
"form-control required"
data-parsley-trigger=
"change"
name=
"online_start_time"
value=
"
<?=
date
(
'G:i'
,
$driver_data
->
online_start_time
)
?>
"
name=
"online_start_time"
value=
"
<?=
$driver_data
->
online_start_time
?>
"
data-parsley-minlength=
"2"
required=
""
placeholder=
"Pick Online Check In Time"
autocomplete=
"off"
>
<div
class=
"input-group-addon"
>
<i
class=
"fa fa-clock-o"
></i>
...
...
@@ -90,7 +90,7 @@
data-autoclose=
"true"
style=
"padding-left: 5px;width: 50%;"
>
<div
class=
"input-group date"
id=
'online_end_time'
>
<input
type=
"text"
class=
"form-control required"
data-parsley-trigger=
"change"
value=
"
<?=
date
(
'G:i'
,
$driver_data
->
online_end_time
)
?>
"
data-parsley-minlength=
"2"
required=
""
value=
"
<?=
$driver_data
->
online_end_time
?>
"
data-parsley-minlength=
"2"
required=
""
name=
"online_end_time"
placeholder=
"Pick Online Check Out Time"
autocomplete=
"off"
>
<div
class=
"input-group-addon"
>
<i
class=
"fa fa-clock-o"
></i>
...
...
application/views/Driver/view.php
View file @
4bec71e0
...
...
@@ -119,7 +119,7 @@
<?php
$online_time
=
' -- '
;
if
(
!
empty
(
$driver_data
->
online_start_time
)
&&
!
empty
(
$driver_data
->
online_end_time
)){
$online_time
=
date
(
'G:i'
,
$driver_data
->
online_start_time
)
.
' - '
.
date
(
'G:i'
,
$driver_data
->
online_end_time
)
;
$online_time
=
$driver_data
->
online_start_time
.
' - '
.
$driver_data
->
online_end_time
;
}
?>
<div
class=
"form-group has-feedback"
>
<div
class=
"col-md-5"
>
...
...
assets/js/nemt_custom.js
View file @
4bec71e0
...
...
@@ -243,6 +243,10 @@ jQuery('[id="scheduleAll"]').click(function(){
if
(
ride_ids
==
undefined
||
ride_ids
==
'undefined'
||
ride_ids
==
null
||
ride_ids
==
'null'
||
ride_ids
==
''
){
return
false
;
}
if
(
!
jQuery
(
"[is_scheduled='0']"
).
length
){
setErrModal
(
'Ride Schedule Status'
,
'Currently there is no unscheduled ride available..!'
);
return
false
;
}
markAsScheduled
(
ride_ids
,
'0'
);
});
...
...
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