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
65b69a7a
Commit
65b69a7a
authored
Apr 10, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dc
parent
678c927e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
188 additions
and
58 deletions
+188
-58
Ride.php
application/controllers/Ride.php
+155
-46
excel_reader_helper.txt
application/helpers/excel_reader_helper.txt
+9
-0
Ride_model.php
application/models/Ride_model.php
+11
-9
add_transport.php
application/views/Ride/add_transport.php
+7
-1
view_rides.php
application/views/Ride/view_rides.php
+6
-2
No files found.
application/controllers/Ride.php
View file @
65b69a7a
...
@@ -45,13 +45,15 @@ class Ride extends CI_Controller {
...
@@ -45,13 +45,15 @@ class Ride extends CI_Controller {
function
excelMapping
(){
function
excelMapping
(){
$flashMsg
=
array
(
'message'
=>
'Something went wrong, please try again..!'
,
'class'
=>
'error'
);
$flashMsg
=
array
(
'message'
=>
'Something went wrong, please try again..!'
,
'class'
=>
'error'
);
if
(
!
isset
(
$_FILES
)
||
empty
(
$_FILES
)
||
!
isset
(
$_FILES
[
'import_file'
])
||
if
(
!
isset
(
$_FILES
)
||
empty
(
$_FILES
)
||
!
isset
(
$_FILES
[
'import_file'
])
||
empty
(
$_FILES
[
'import_file'
])
||
!
isset
(
$_POST
)
||
empty
(
$_POST
)
||
!
isset
(
$_POST
[
'broker_id'
])
||
empty
(
$_FILES
[
'import_file'
])
||
!
isset
(
$_POST
)
||
empty
(
$_POST
)
||
empty
(
$_POST
[
'broker_id'
])
||
!
isset
(
$_POST
[
'company_id'
])
||
empty
(
$_POST
[
'company_id'
])){
!
isset
(
$_POST
[
'broker_id'
])
||
empty
(
$_POST
[
'broker_id'
])
||
!
isset
(
$_POST
[
'company_id'
])
||
empty
(
$_POST
[
'company_id'
])){
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
redirect
(
base_url
(
'Ride/import_ride'
));
redirect
(
base_url
(
'Ride/import_ride'
));
}
}
$fileType
=
''
;
$fileType
=
''
;
$skipMapping
=
(
isset
(
$_POST
[
'skipMapping'
]))
?
true
:
false
;
$importedFile
=
''
;
$importedFile
=
''
;
$this
->
load
->
library
(
'upload'
);
$this
->
load
->
library
(
'upload'
);
...
@@ -82,7 +84,7 @@ class Ride extends CI_Controller {
...
@@ -82,7 +84,7 @@ class Ride extends CI_Controller {
break
;
break
;
}
}
if
(
empty
(
$importData
)
||
!
isset
(
$importData
[
'status'
])
||
$importData
[
'status'
]
==
3
||
if
(
empty
(
$importData
)
||
!
isset
(
$importData
[
'status'
])
||
$importData
[
'status'
]
==
3
||
$importData
[
'status'
]
==
4
||
(
$importData
[
'status'
]
==
1
&&
empty
(
$importData
[
'headerArr'
]))){
$importData
[
'status'
]
==
4
||
(
$importData
[
'status'
]
==
1
&&
empty
(
$importData
[
'headerArr'
]))){
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
redirect
(
base_url
(
'Ride/import_ride'
));
redirect
(
base_url
(
'Ride/import_ride'
));
...
@@ -93,6 +95,26 @@ class Ride extends CI_Controller {
...
@@ -93,6 +95,26 @@ class Ride extends CI_Controller {
redirect
(
base_url
(
'Ride/import_ride'
));
redirect
(
base_url
(
'Ride/import_ride'
));
}
}
$this
->
load
->
model
(
'Broker_model'
);
$broker_data
=
$this
->
Broker_model
->
getBroker
(
$_POST
[
'broker_id'
]);
if
(
$skipMapping
&&
!
empty
(
$broker_data
)
&&
isset
(
$broker_data
->
export_header
)
&&
!
empty
(
$broker_data
->
export_header
)
&&
isset
(
$broker_data
->
mapped_header
)
&&
!
empty
(
$broker_data
->
mapped_header
)
&&
!
empty
(
$broker_data
->
export_header
=
json_decode
(
$broker_data
->
export_header
,
true
))
&&
$broker_data
->
export_header
===
$importData
[
'headerArr'
]
){
$params
=
array
(
'broker_id'
=>
$_POST
[
'broker_id'
],
'company_id'
=>
$_POST
[
'company_id'
],
'file_type'
=>
$fileType
,
'import_file'
=>
$importedFile
,
'header_order'
=>
$broker_data
->
mapped_header
);
$this
->
session
->
set_flashdata
(
'params'
,
$params
);
redirect
(
base_url
(
'Ride/import'
));
}
else
{
$this
->
db
->
update
(
'brokers'
,
array
(
'export_header'
=>
json_encode
(
$importData
[
'headerArr'
])),
array
(
'broker_id'
=>
$_POST
[
'broker_id'
]));
}
$template
[
'fileType'
]
=
$fileType
;
$template
[
'fileType'
]
=
$fileType
;
$template
[
'headerArr'
]
=
$importData
[
'headerArr'
];
$template
[
'headerArr'
]
=
$importData
[
'headerArr'
];
$template
[
'broker_id'
]
=
$_POST
[
'broker_id'
];
$template
[
'broker_id'
]
=
$_POST
[
'broker_id'
];
...
@@ -110,8 +132,7 @@ class Ride extends CI_Controller {
...
@@ -110,8 +132,7 @@ class Ride extends CI_Controller {
$this
->
load
->
view
(
'template'
,
$template
);
$this
->
load
->
view
(
'template'
,
$template
);
}
}
function
getImportDataCSV
(
$importedFile
=
''
,
$headerRetFlag
=
0
,
$headerOrder
=
array
(),
$data
=
array
()){
function
getImportDataCSV
(
$importedFile
=
''
,
$headerRetFlag
=
0
,
$headerOrder
=
array
(),
$data
=
array
()){
$header
=
0
;
$header
=
0
;
$insertArr
=
array
();
$insertArr
=
array
();
$headerArr
=
array
();
$headerArr
=
array
();
...
@@ -210,6 +231,25 @@ class Ride extends CI_Controller {
...
@@ -210,6 +231,25 @@ class Ride extends CI_Controller {
$tripBidStatus
=
(
isset
(
$headerOrder
[
'37'
])
&&
isset
(
$row
[
$headerOrder
[
'37'
]]))
?
$tripBidStatus
=
(
isset
(
$headerOrder
[
'37'
])
&&
isset
(
$row
[
$headerOrder
[
'37'
]]))
?
$row
[
$headerOrder
[
'37'
]]
:
''
;
$row
[
$headerOrder
[
'37'
]]
:
''
;
$locData
=
array
(
'pLat'
=>
'0'
,
'pLng'
=>
'0'
,
'dLat'
=>
'0'
,
'dLng'
=>
'0'
);
if
(
isset
(
$row
[
$headerOrder
[
'23'
]])
&&
!
empty
(
$row
[
$headerOrder
[
'23'
]])){
$locData
=
getLatLngFromLocation
(
$row
[
$headerOrder
[
'23'
]]);
if
(
!
empty
(
$locData
)){
$locData
[
'pLat'
]
=
$locData
[
'lat'
];
$locData
[
'pLng'
]
=
$locData
[
'lng'
];
}
}
if
(
isset
(
$row
[
$headerOrder
[
'28'
]])
&&
!
empty
(
$row
[
$headerOrder
[
'28'
]])){
$locData
=
getLatLngFromLocation
(
$row
[
$headerOrder
[
'28'
]]);
if
(
!
empty
(
$locData
)){
$locData
[
'dLat'
]
=
$locData
[
'lat'
];
$locData
[
'dLng'
]
=
$locData
[
'lng'
];
}
}
$insertData
=
array
(
$insertData
=
array
(
'broker_id'
=>
$data
[
'broker_id'
],
'broker_id'
=>
$data
[
'broker_id'
],
'company_id'
=>
$data
[
'company_id'
],
'company_id'
=>
$data
[
'company_id'
],
...
@@ -225,6 +265,10 @@ class Ride extends CI_Controller {
...
@@ -225,6 +265,10 @@ class Ride extends CI_Controller {
'trip_status'
=>
$row
[
$headerOrder
[
'12'
]],
'trip_status'
=>
$row
[
$headerOrder
[
'12'
]],
'vehicle_type'
=>
$row
[
$headerOrder
[
'13'
]],
'vehicle_type'
=>
$row
[
$headerOrder
[
'13'
]],
'patient_name'
=>
$row
[
$headerOrder
[
'2'
]]
.
' '
.
$row
[
$headerOrder
[
'1'
]],
'patient_name'
=>
$row
[
$headerOrder
[
'2'
]]
.
' '
.
$row
[
$headerOrder
[
'1'
]],
'drop_lat'
=>
$locData
[
'dLat'
],
'drop_lng'
=>
$locData
[
'dLng'
],
'pickup_lat'
=>
$locData
[
'pLat'
],
'pickup_lng'
=>
$locData
[
'pLng'
],
'drop_location'
=>
$row
[
$headerOrder
[
'28'
]],
'drop_location'
=>
$row
[
$headerOrder
[
'28'
]],
'pickup_location'
=>
$row
[
$headerOrder
[
'23'
]],
'pickup_location'
=>
$row
[
$headerOrder
[
'23'
]],
'trip_bid_status'
=>
$tripBidStatus
,
'trip_bid_status'
=>
$tripBidStatus
,
...
@@ -353,25 +397,47 @@ class Ride extends CI_Controller {
...
@@ -353,25 +397,47 @@ class Ride extends CI_Controller {
$tripBidStatus
=
(
isset
(
$headerOrder
[
'37'
])
&&
isset
(
$row
[
$headerOrder
[
'37'
]]))
?
$tripBidStatus
=
(
isset
(
$headerOrder
[
'37'
])
&&
isset
(
$row
[
$headerOrder
[
'37'
]]))
?
$row
[
$headerOrder
[
'37'
]]
:
''
;
$row
[
$headerOrder
[
'37'
]]
:
''
;
$insertData
=
array
(
$locData
=
array
(
'pLat'
=>
'0'
,
'pLng'
=>
'0'
,
'dLat'
=>
'0'
,
'dLng'
=>
'0'
);
'broker_id'
=>
$data
[
'broker_id'
],
if
(
isset
(
$row
[
$headerOrder
[
'23'
]])
&&
!
empty
(
$row
[
$headerOrder
[
'23'
]])){
'company_id'
=>
$data
[
'company_id'
],
$plocData
=
getLatLngFromLocation
(
$row
[
$headerOrder
[
'23'
]]);
'customer_id'
=>
$customerId
,
if
(
!
empty
(
$plocData
)){
'age'
=>
$row
[
$headerOrder
[
'4'
]],
$locData
[
'pLat'
]
=
$plocData
[
'lat'
];
'phone'
=>
$row
[
$headerOrder
[
'5'
]],
$locData
[
'pLng'
]
=
$plocData
[
'lng'
];
'trip_no'
=>
$row
[
$headerOrder
[
'7'
]],
}
'trip_cost'
=>
$row
[
$headerOrder
[
'22'
]],
}
'trip_type'
=>
$row
[
$headerOrder
[
'14'
]],
'medical_no'
=>
$row
[
$headerOrder
[
'0'
]],
if
(
isset
(
$row
[
$headerOrder
[
'28'
]])
&&
!
empty
(
$row
[
$headerOrder
[
'28'
]])){
'reason_code'
=>
$row
[
$headerOrder
[
'11'
]],
$dlocData
=
getLatLngFromLocation
(
$row
[
$headerOrder
[
'28'
]]);
'trip_status'
=>
$row
[
$headerOrder
[
'12'
]],
'vehicle_type'
=>
$row
[
$headerOrder
[
'13'
]],
if
(
!
empty
(
$dlocData
)){
'patient_name'
=>
$row
[
$headerOrder
[
'2'
]]
.
' '
.
$row
[
$headerOrder
[
'1'
]],
$locData
[
'dLat'
]
=
$dlocData
[
'lat'
];
'drop_location'
=>
$row
[
$headerOrder
[
'28'
]],
$locData
[
'dLng'
]
=
$dlocData
[
'lng'
];
'pickup_location'
=>
$row
[
$headerOrder
[
'23'
]],
}
'trip_bid_status'
=>
$tripBidStatus
,
}
'data'
=>
json_encode
(
$rowArr
)
$insertData
=
array
(
'broker_id'
=>
$data
[
'broker_id'
],
'company_id'
=>
$data
[
'company_id'
],
'customer_id'
=>
$customerId
,
'age'
=>
$row
[
$headerOrder
[
'4'
]],
'phone'
=>
$row
[
$headerOrder
[
'5'
]],
'trip_no'
=>
$row
[
$headerOrder
[
'7'
]],
'trip_cost'
=>
$row
[
$headerOrder
[
'22'
]],
'trip_type'
=>
$row
[
$headerOrder
[
'14'
]],
'medical_no'
=>
$row
[
$headerOrder
[
'0'
]],
'reason_code'
=>
$row
[
$headerOrder
[
'11'
]],
'trip_status'
=>
$row
[
$headerOrder
[
'12'
]],
'vehicle_type'
=>
$row
[
$headerOrder
[
'13'
]],
'patient_name'
=>
$row
[
$headerOrder
[
'2'
]]
.
' '
.
$row
[
$headerOrder
[
'1'
]],
'drop_lat'
=>
$locData
[
'dLat'
],
'drop_lng'
=>
$locData
[
'dLng'
],
'pickup_lat'
=>
$locData
[
'pLat'
],
'pickup_lng'
=>
$locData
[
'pLng'
],
'drop_location'
=>
$row
[
$headerOrder
[
'28'
]],
'pickup_location'
=>
$row
[
$headerOrder
[
'23'
]],
'trip_bid_status'
=>
$tripBidStatus
,
'data'
=>
json_encode
(
$rowArr
)
);
);
$insertData
[
'appointment_time'
]
=
strtotime
(
$date_time
);
$insertData
[
'appointment_time'
]
=
strtotime
(
$date_time
);
$insertArr
[]
=
$insertData
;
$insertArr
[]
=
$insertData
;
...
@@ -390,25 +456,49 @@ class Ride extends CI_Controller {
...
@@ -390,25 +456,49 @@ class Ride extends CI_Controller {
}
}
function
import
(){
function
import
(){
$redirectFlag
=
0
;
$flashMsg
=
array
(
'message'
=>
'Something went wrong, please try again..!'
,
'class'
=>
'error'
);
$flashMsg
=
array
(
'message'
=>
'Something went wrong, please try again..!'
,
'class'
=>
'error'
);
if
(
!
isset
(
$_POST
)
||
empty
(
$_POST
)
||
!
isset
(
$_POST
[
'broker_id'
])
||
empty
(
$_POST
[
'broker_id'
])
||
if
(
isset
(
$_POST
)
&&
!
empty
(
$_POST
)){
!
isset
(
$_POST
[
'file_type'
])
||
empty
(
$_POST
[
'file_type'
])
||
if
(
!
isset
(
$_POST
[
'broker_id'
])
||
empty
(
$_POST
[
'broker_id'
])
||
!
isset
(
$_POST
[
'company_id'
])
||
empty
(
$_POST
[
'company_id'
])
||
!
isset
(
$_POST
[
'file_type'
])
||
empty
(
$_POST
[
'file_type'
])
||
!
isset
(
$_POST
[
'import_file'
])
||
empty
(
$_POST
[
'import_file'
])
||
!
isset
(
$_POST
[
'company_id'
])
||
empty
(
$_POST
[
'company_id'
])
||
!
isset
(
$_POST
[
'header_order'
])
||
empty
(
$_POST
[
'header_order'
])){
!
isset
(
$_POST
[
'import_file'
])
||
empty
(
$_POST
[
'import_file'
])
||
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
!
isset
(
$_POST
[
'header_order'
])
||
empty
(
$_POST
[
'header_order'
])){
redirect
(
base_url
(
'Ride/import_ride'
));
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
redirect
(
base_url
(
'Ride/import_ride'
));
}
$this
->
db
->
update
(
'brokers'
,
array
(
'mapped_header'
=>
json_encode
(
$_POST
[
'header_order'
])),
array
(
'broker_id'
=>
$_POST
[
'broker_id'
]));
}
else
{
if
(
empty
(
$params
=
$this
->
session
->
flashdata
(
'params'
))
||
!
isset
(
$params
[
'broker_id'
])
||
empty
(
$params
[
'broker_id'
])
||
!
isset
(
$params
[
'file_type'
])
||
empty
(
$params
[
'file_type'
])
||
!
isset
(
$params
[
'company_id'
])
||
empty
(
$params
[
'company_id'
])
||
!
isset
(
$params
[
'import_file'
])
||
empty
(
$params
[
'import_file'
])
||
!
isset
(
$params
[
'header_order'
])
||
empty
(
$params
[
'header_order'
])){
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
redirect
(
base_url
(
'Ride/import_ride'
));
}
$redirectFlag
=
1
;
$_POST
[
'file_type'
]
=
$params
[
'file_type'
];
$_POST
[
'broker_id'
]
=
$params
[
'broker_id'
];
$_POST
[
'company_id'
]
=
$params
[
'company_id'
];
$_POST
[
'import_file'
]
=
$params
[
'import_file'
];
$_POST
[
'header_order'
]
=
json_decode
(
$params
[
'header_order'
],
true
);
}
}
$data
=
array
(
'broker_id'
=>
$_POST
[
'broker_id'
],
'company_id'
=>
$_POST
[
'company_id'
]);
$data
=
array
(
'broker_id'
=>
$_POST
[
'broker_id'
],
'company_id'
=>
$_POST
[
'company_id'
]);
switch
(
$_POST
[
'file_type'
]){
switch
(
$_POST
[
'file_type'
]){
case
'csv'
:
case
'csv'
:
$respStatus
=
$this
->
getImportDataCSV
(
$_POST
[
'import_file'
],
1
,
$_POST
[
'header_order'
],
$data
);
$respStatus
=
$this
->
getImportDataCSV
(
$_POST
[
'import_file'
],
1
,
$_POST
[
'header_order'
],
$data
);
break
;
break
;
case
'xls'
:
case
'xls'
:
case
'xlsx'
:
case
'xlsx'
:
$respStatus
=
$this
->
getImportDataExcel
(
$_POST
[
'import_file'
],
1
,
$_POST
[
'header_order'
],
$data
);
$respStatus
=
$this
->
getImportDataExcel
(
$_POST
[
'import_file'
],
1
,
$_POST
[
'header_order'
],
$data
);
break
;
break
;
}
}
if
(
!
empty
(
$respStatus
)
&&
isset
(
$respStatus
[
'status'
])
&&
$respStatus
[
'status'
]
!=
''
){
if
(
!
empty
(
$respStatus
)
&&
isset
(
$respStatus
[
'status'
])
&&
$respStatus
[
'status'
]
!=
''
){
...
@@ -428,6 +518,24 @@ class Ride extends CI_Controller {
...
@@ -428,6 +518,24 @@ class Ride extends CI_Controller {
}
else
{
}
else
{
$respStatus
[
'status'
]
=
'0'
;
$respStatus
[
'status'
]
=
'0'
;
}
}
if
(
$redirectFlag
==
1
){
if
(
$respStatus
[
'status'
]
==
0
)
{
$flashMsg
[
'class'
]
=
'error'
;
$flashMsg
[
'message'
]
=
'Something went wrong, please try again..!'
;
}
else
if
(
$respStatus
[
'status'
]
==
2
)
{
$flashMsg
[
'class'
]
=
'error'
;
$flashMsg
[
'message'
]
=
'Invalid File given, please try again later..!'
;
}
else
if
(
$respStatus
[
'status'
]
==
3
)
{
$flashMsg
[
'class'
]
=
'error'
;
$flashMsg
[
'message'
]
=
'No data found, please try again later..!'
;
}
else
if
(
$respStatus
[
'status'
]
==
4
)
{
$flashMsg
[
'class'
]
=
'error'
;
$flashMsg
[
'message'
]
=
'Invalid header given, please try again later..!'
;
}
redirect
(
base_url
(
'Ride/view_rides'
));
}
echo
json_encode
(
$respStatus
);
exit
;
echo
json_encode
(
$respStatus
);
exit
;
}
}
...
@@ -757,18 +865,19 @@ class Ride extends CI_Controller {
...
@@ -757,18 +865,19 @@ class Ride extends CI_Controller {
if
(
empty
(
$ride_data
)
||
(
isset
(
$ride_data
->
is_scheduled
)
&&
$ride_data
->
is_scheduled
!=
'0'
))
if
(
empty
(
$ride_data
)
||
(
isset
(
$ride_data
->
is_scheduled
)
&&
$ride_data
->
is_scheduled
!=
'0'
))
return
$status
;
return
$status
;
$pickup_location
=
$ride_data
->
pickup_location
;
$appointment_time
=
$ride_data
->
appointment_time
;
$appointment_time
=
$ride_data
->
appointment_time
;
if
(
empty
(
$pickup_location
)
||
empty
(
$appointment_time
))
if
(
!
isset
(
$ride_data
->
drop_lat
)
||
empty
(
$ride_data
->
drop_lat
)
||
return
$status
;
!
isset
(
$ride_data
->
drop_lng
)
||
empty
(
$ride_data
->
drop_lng
)
||
$pickupLocData
=
getLatLngFromLocation
(
$pickup_location
);
!
isset
(
$ride_data
->
pickup_lat
)
||
empty
(
$ride_data
->
pickup_lat
)
||
!
isset
(
$ride_data
->
pickup_lng
)
||
empty
(
$ride_data
->
pickup_lng
)){
if
(
empty
(
$pickupLocData
))
return
$status
;
return
$status
;
}
$status
=
$this
->
Ride_model
->
autoAssignDriver
(
$ride_id
,
$appointment_time
,
$locData
=
array
(
'dlat'
=>
$ride_data
->
drop_lat
,
'dlng'
=>
$ride_data
->
drop_lng
,
array
(
'lat'
=>
$pickupLocData
[
'lat'
],
'lng'
=>
$pickupLocData
[
'lng'
]),
'plat'
=>
$ride_data
->
pickup_lat
,
'plng'
=>
$ride_data
->
pickup_lng
);
$drivers
,
$no_driver
);
$status
=
$this
->
Ride_model
->
autoAssignDriver
(
$ride_id
,
$appointment_time
,
$locData
,
$drivers
,
$no_driver
);
}
else
{
}
else
{
$status
=
$this
->
Ride_model
->
changeSchuduleStatus
(
$ride_id
,
$is_scheduled
);
$status
=
$this
->
Ride_model
->
changeSchuduleStatus
(
$ride_id
,
$is_scheduled
);
}
}
...
...
application/helpers/excel_reader_helper.txt
0 → 100644
View file @
65b69a7a
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
include('excelReaderLibrary/SpreadsheetReader.php');
include('excelReaderLibrary/php-excel-reader/excel_reader.php');
?>
\ No newline at end of file
application/models/Ride_model.php
View file @
65b69a7a
...
@@ -42,8 +42,8 @@ class Ride_model extends CI_Model {
...
@@ -42,8 +42,8 @@ class Ride_model extends CI_Model {
return
(
$status
)
?
1
:
0
;
return
(
$status
)
?
1
:
0
;
}
}
function
getRideData
(
$ride_id
=
''
,
$company_id
=
''
,
$broker_id
=
''
,
$scheduled
=
''
,
$condArr
=
array
()){
function
getRideData
(
$ride_id
=
''
,
$company_id
=
''
,
$broker_id
=
''
,
$scheduled
=
''
,
$condArr
=
array
()){
$cond
=
(
!
empty
(
$ride_id
))
?
" AND TD.transport_id = '
$ride_id
'"
:
""
;
$cond
=
(
!
empty
(
$ride_id
))
?
" AND TD.transport_id = '
$ride_id
'"
:
""
;
$cond
.=
(
$broker_id
!=
''
)
?
" AND TD.broker_id = '
$broker_id
'"
:
""
;
$cond
.=
(
$broker_id
!=
''
)
?
" AND TD.broker_id = '
$broker_id
'"
:
""
;
$cond
.=
(
!
empty
(
$company_id
))
?
" AND TD.company_id = '
$company_id
'"
:
""
;
$cond
.=
(
!
empty
(
$company_id
))
?
" AND TD.company_id = '
$company_id
'"
:
""
;
...
@@ -147,11 +147,13 @@ class Ride_model extends CI_Model {
...
@@ -147,11 +147,13 @@ class Ride_model extends CI_Model {
$this
->
db
->
delete
(
'ride_status'
,
array
(
'ride_id'
=>
$ride_id
));
$this
->
db
->
delete
(
'ride_status'
,
array
(
'ride_id'
=>
$ride_id
));
}
}
function
autoAssignDriver
(
$ride_id
=
''
,
$appointment_time
=
''
,
$
pickupLoc
=
array
(),
function
autoAssignDriver
(
$ride_id
=
''
,
$appointment_time
=
''
,
$
locData
=
array
(),
$drivers
=
array
(),
$no_driver
=
'0'
){
$drivers
=
array
(),
$no_driver
=
'0'
){
if
(
empty
(
$ride_id
)
||
empty
(
$appointment_time
)
||
empty
(
$pickupLoc
)
||
if
(
empty
(
$ride_id
)
||
empty
(
$appointment_time
)
||
empty
(
$locData
)
||
!
isset
(
$pickupLoc
[
'lat'
])
||
$pickupLoc
[
'lat'
]
==
''
||
!
isset
(
$locData
[
'plat'
])
||
$locData
[
'plat'
]
==
''
||
!
isset
(
$pickupLoc
[
'lng'
])
||
$pickupLoc
[
'lng'
]
==
''
){
!
isset
(
$locData
[
'plng'
])
||
$locData
[
'plng'
]
==
''
||
!
isset
(
$locData
[
'dlat'
])
||
$locData
[
'dlat'
]
==
''
||
!
isset
(
$locData
[
'dlng'
])
||
$locData
[
'dlng'
]
==
''
){
return
0
;
return
0
;
}
}
...
@@ -180,9 +182,9 @@ class Ride_model extends CI_Model {
...
@@ -180,9 +182,9 @@ class Ride_model extends CI_Model {
}
}
if
(
!
empty
(
$drivers
)){
if
(
!
empty
(
$drivers
)){
$sql
=
"SELECT DRV.driver_id,
$sql
=
"SELECT DRV.driver_id,
3956*2*ASIN(SQRT(POWER(SIN(("
.
$
pickupLoc
[
'
lat'
]
.
"-DRV.active_loc_lat)*
3956*2*ASIN(SQRT(POWER(SIN(("
.
$
locData
[
'p
lat'
]
.
"-DRV.active_loc_lat)*
pi()/180/2),2)+COS("
.
$
pickupLoc
[
'
lat'
]
.
"*pi()/180)*COS(DRV.active_loc_lat*
pi()/180/2),2)+COS("
.
$
locData
[
'p
lat'
]
.
"*pi()/180)*COS(DRV.active_loc_lat*
pi()/180)*POWER(SIN(("
.
$
pickupLoc
[
'
lng'
]
.
"-DRV.active_loc_lng)*
pi()/180)*POWER(SIN(("
.
$
locData
[
'p
lng'
]
.
"-DRV.active_loc_lng)*
pi()/180/2),2))) AS distance
pi()/180/2),2))) AS distance
FROM drivers AS DRV
FROM drivers AS DRV
WHERE DRV.status = 1 AND DRV.driver_id IN ("
.
implode
(
","
,
$drivers
)
.
") AND
WHERE DRV.status = 1 AND DRV.driver_id IN ("
.
implode
(
","
,
$drivers
)
.
") AND
...
...
application/views/Ride/add_transport.php
View file @
65b69a7a
...
@@ -281,10 +281,16 @@
...
@@ -281,10 +281,16 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-md-12"
style=
"padding-left:30px;padding-bottom:10px;"
>
<input
type=
"checkbox"
name=
"skipMapping"
checked
>
<p
style=
"display:inline;padding-left:10px;"
>
Auto skip Mapping Page (If mapping data is available)
</p>
</div>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<div
class=
"box-footer"
>
<div
class=
"box-footer"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Upload
</button>
<button
type=
"submit"
class=
"btn btn-primary"
>
Upload
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
...
...
application/views/Ride/view_rides.php
View file @
65b69a7a
...
@@ -168,16 +168,20 @@
...
@@ -168,16 +168,20 @@
$report_data
=
array
();
$report_data
=
array
();
if
(
!
empty
(
$ride_data
)){
if
(
!
empty
(
$ride_data
)){
foreach
(
$ride_data
as
$ride
)
{
foreach
(
$ride_data
as
$ride
)
{
$
ride_ids
[]
=
$ride
->
transport_id
;
$
schedFlag
=
0
;
$json_ride
=
json_decode
(
$ride
->
data
,
true
);
$json_ride
=
json_decode
(
$ride
->
data
,
true
);
if
(
empty
(
$json_ride
)){
if
(
empty
(
$json_ride
)){
continue
;
continue
;
}
}
if
(
$json_ride
[
'Trip_Status'
]
==
'S1'
){
$schedFlag
=
1
;
$ride_ids
[]
=
$ride
->
transport_id
;
}
?>
?>
<tr>
<tr>
<th
class=
"hidden"
>
<?=
$ride
->
transport_id
?>
</th>
<th
class=
"hidden"
>
<?=
$ride
->
transport_id
?>
</th>
<th
class=
"center"
>
<th
class=
"center"
>
<?php
if
(
$this
->
session
->
userdata
[
'user_type'
]
!=
1
&&
!
empty
(
$drivers_data
)){
<?php
if
(
$
schedFlag
&&
$
this
->
session
->
userdata
[
'user_type'
]
!=
1
&&
!
empty
(
$drivers_data
)){
$style
=
'style="color:red;";'
;
$style
=
'style="color:red;";'
;
$ride
->
is_scheduled
=
(
isset
(
$ride
->
is_scheduled
))
?
$ride
->
is_scheduled
:
0
;
$ride
->
is_scheduled
=
(
isset
(
$ride
->
is_scheduled
))
?
$ride
->
is_scheduled
:
0
;
if
(
$ride
->
is_scheduled
==
1
){
if
(
$ride
->
is_scheduled
==
1
){
...
...
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