Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dcarfixers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
dcarfixers
Commits
f88ec774
Commit
f88ec774
authored
Jan 11, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d cmmit
parent
9dc8f7e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
4 deletions
+57
-4
Webservices.php
application/controllers/Webservices.php
+8
-4
Vehicle_model.php
application/models/Vehicle_model.php
+49
-0
No files found.
application/controllers/Webservices.php
View file @
f88ec774
...
...
@@ -224,13 +224,17 @@ class Webservices extends CI_Controller {
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
$respArr
=
array
(
'status'
=>
'0'
,
'message'
=>
'Something went wrong.'
);
$respArr
=
array
(
'status'
=>
'0'
,
'message'
=>
'Something went wrong.'
);
if
(
empty
(
$postData
)){
echo
json_encode
(
$respArr
);
exit
;
}
$this
->
load
->
model
(
'Vehicle_model'
);
$status
=
$this
->
Vehicle_model
->
scheduleBooking
(
$postData
);
if
(
$status
){
$respArr
[
'status'
]
=
'1'
;
$respArr
[
'message'
]
=
'Success'
;
}
echo
json_encode
(
$respArr
);
exit
;
}
}
...
...
application/models/Vehicle_model.php
View file @
f88ec774
...
...
@@ -25,5 +25,53 @@ class Vehicle_model extends CI_Model {
}
return
$status
;
}
public
function
scheduleBooking
(
$postData
=
array
()){
if
(
empty
(
$postData
)){
return
0
;
}
$vehData
=
$postData
[
'vechile_info'
];
$car_name
=
$vehData
[
'modelYear'
]
.
' '
.
$vehData
[
'maker'
]
.
' '
.
$vehData
[
'modelName'
];
$vehJson
=
array
(
'vehicle'
=>
$car_name
,
'attributes'
=>
array
(
'Year'
=>
$vehData
[
'modelYear'
],
'Make'
=>
$vehData
[
'maker'
],
'Trim'
=>
$vehData
[
'trim'
],
'Model'
=>
$vehData
[
'modelName'
],
'Engine'
=>
$vehData
[
'emgine'
]
));
$insert_array
=
array
(
'customer_id'
=>
$postData
[
'customer_id'
],
'car_name'
=>
$car_name
,
'car_model'
=>
$vehData
[
'modelName'
],
'car_maker'
=>
$vehData
[
'maker'
],
'car_loc_lat'
=>
$postData
[
'pickup_data'
][
'pickup_lat'
],
'car_loc_lng'
=>
$postData
[
'pickup_data'
][
'pickup_lng'
],
'car_location'
=>
$postData
[
'pickup_data'
][
'pickup_loc'
],
'vehicle_data'
=>
json_encode
(
$vehJson
),
'car_model_year'
=>
$vehData
[
'modelYear'
],
'status'
=>
'3'
);
if
(
$this
->
db
->
insert
(
'customer_vehicle'
,
$insert_array
)){
$last_id
=
$this
->
db
->
insert_id
();
$book_data
=
array
(
'customer_veh_id'
=>
$last_id
,
'customer_id'
=>
$postData
[
'customer_id'
],
'mechanic_id'
=>
$postData
[
'mechanic_id'
],
'scheduled_date'
=>
$postData
[
'schedule_date'
][
'date'
],
'scheduled_time'
=>
$postData
[
'schedule_date'
][
'time'
],
'mileage'
=>
$vehData
[
'milage'
],
'status'
=>
'0'
);
if
(
$this
->
db
->
insert
(
'bookings'
,
$book_data
)){
return
1
;
}
}
return
0
;
}
}
?>
\ No newline at end of file
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