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
36cd8466
Commit
36cd8466
authored
Jan 22, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dc
parent
66ad8d20
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
388 additions
and
2 deletions
+388
-2
Bookings.php
application/controllers/Bookings.php
+81
-0
Booking_model.php
application/models/Booking_model.php
+41
-0
list-booking.php
application/views/Bookings/list-booking.php
+131
-0
left-menu.php
application/views/Templates/left-menu.php
+6
-0
custom-script.js
assets/js/custom-script.js
+129
-2
No files found.
application/controllers/Bookings.php
0 → 100644
View file @
36cd8466
<?php
defined
(
'BASEPATH'
)
OR
exit
(
'No direct script access allowed'
);
class
Bookings
extends
CI_Controller
{
public
function
__construct
()
{
parent
::
__construct
();
date_default_timezone_set
(
"Asia/Kolkata"
);
$this
->
load
->
model
(
'Booking_model'
);
if
(
!
$this
->
session
->
userdata
(
'logged_in'
))
{
redirect
(
base_url
(
'Login'
));
}
if
(
$this
->
session
->
userdata
[
'user_type'
]
!=
1
){
redirect
(
base_url
());
}
}
public
function
listBookings
(
$mechanic_id
=
''
){
if
(
!
empty
(
$mechanic_id
)){
$mechanic_id
=
(
!
is_numeric
(
$mechanic_id
))
?
decode_param
(
$mechanic_id
)
:
$mechanic_id
;
}
$mechanic_data
=
''
;
if
(
$this
->
session
->
userdata
(
'user_type'
)
==
1
){
$this
->
load
->
model
(
'Mechanic_model'
);
$mechanic_data
=
$this
->
Mechanic_model
->
getMechanic
(
''
,
0
);
if
(
isset
(
$_POST
[
'mechanic_id'
])
&&
!
empty
(
$_POST
[
'mechanic_id'
])){
$mechanic_id
=
$_POST
[
'mechanic_id'
];
$mechanic_id
=
(
!
is_numeric
(
$mechanic_id
))
?
decode_param
(
$mechanic_id
)
:
$mechanic_id
;
}
}
else
{
$mechanic_id
=
$this
->
session
->
userdata
(
'id'
);
}
$template
[
'page'
]
=
'Bookings/list-booking'
;
$template
[
'pTitle'
]
=
"View Bookings"
;
$template
[
'pDescription'
]
=
"View and Manage Bookings"
;
$template
[
'menu'
]
=
"Bookings Management"
;
$template
[
'smenu'
]
=
"View Bookings"
;
$template
[
'mechanic_id'
]
=
$mechanic_id
;
$template
[
'mechanic_data'
]
=
$mechanic_data
;
$template
[
'bookingData'
]
=
$this
->
Booking_model
->
getMechBookings
(
$mechanic_id
,
''
,
'0,1,3,4'
);
$this
->
load
->
view
(
'template'
,
$template
);
}
public
function
changeBookingStatus
(
$booking_id
=
''
,
$status
=
''
,
$mechanic_id
=
''
){
$flashMsg
=
array
(
'message'
=>
'Something went wrong, please try again..!'
,
'class'
=>
'error'
);
if
(
empty
(
$booking_id
)
||
$status
==
''
){
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
redirect
(
base_url
(
'Bookings/listBookings'
));
}
$booking_id
=
decode_param
(
$booking_id
);
$status
=
$this
->
Booking_model
->
changeStatus
(
$booking_id
,
$status
);
if
(
!
$status
){
$this
->
session
->
set_flashdata
(
'message'
,
$flashMsg
);
}
redirect
(
base_url
(
'Bookings/listBookings/'
.
$mechanic_id
));
}
public
function
getBooking
(){
$return_arr
=
array
(
'status'
=>
'0'
);
if
(
!
isset
(
$_POST
)
||
empty
(
$_POST
)
||
!
isset
(
$_POST
[
'booking_id'
])
||
empty
(
$_POST
[
'booking_id'
])
||
empty
(
decode_param
(
$_POST
[
'booking_id'
]))){
echo
json_encode
(
$return_arr
);
exit
;
}
$booking_id
=
decode_param
(
$_POST
[
'booking_id'
]);
$bookingData
=
$this
->
Booking_model
->
getMechBookings
(
''
,
$booking_id
,
'0,1,3,4'
);
if
(
!
empty
(
$bookingData
)){
$return_arr
[
'status'
]
=
1
;
$return_arr
[
'data'
]
=
$bookingData
;
echo
json_encode
(
$return_arr
);
exit
;
}
}
}
?>
\ No newline at end of file
application/models/Booking_model.php
View file @
36cd8466
...
...
@@ -100,5 +100,45 @@ class Booking_model extends CI_Model {
return
$status
;
}
function
getMechBookings
(
$mechanic_id
=
''
,
$booking_id
=
''
,
$status
=
'1'
){
if
(
empty
(
$mechanic_id
)
&&
empty
(
$booking_id
)){
return
0
;
}
$cond
=
" BK.status IN ("
.
$status
.
") "
;
$cond
.=
(
!
empty
(
$booking_id
))
?
" AND BK.booking_id='"
.
$booking_id
.
"' "
:
""
;
$cond
.=
(
!
empty
(
$mechanic_id
))
?
" AND BK.mechanic_id='"
.
$mechanic_id
.
"' "
:
""
;
$sql
=
"SELECT BK.booking_id,BK.customer_id,BK.mechanic_id,BK.customer_veh_id,BK.scheduled_date,
BK.scheduled_time,BK.cost,BK.status,BK.mileage,BK.issues_selected,VEH.car_name,
BK.custom_issue_data,MECH.first_name AS mechFirstName,VEH.car_model,
MECH.last_name AS mechLastName,VEH.car_maker,VEH.car_model_year,VEH.car_vin,
VEH.vehicle_data,VEH.car_location,VEH.car_loc_lat,VEH.car_loc_lng,
CUST.first_name AS custFirstName,CUST.last_name AS custLastName,CUST.phone,
CUST.email,CUST.address,CUST.profile_image,CUST.date_of_birth
FROM bookings AS BK
INNER JOIN mechanic AS MECH ON (MECH.mechanic_id AND BK.mechanic_id)
INNER JOIN customers AS CUST ON (CUST.customer_id AND BK.customer_id)
INNER JOIN admin_users AS ADM ON (ADM.id AND BK.mechanic_id)
INNER JOIN customer_vehicle AS VEH ON (VEH.customer_veh_id AND BK.customer_veh_id)
WHERE
$cond
AND ADM.status='1' AND CUST.status='1' AND VEH.status='1'
GROUP BY BK.booking_id"
;
$bookData
=
$this
->
db
->
query
(
$sql
);
if
(
!
empty
(
$bookData
)){
$bookData
=
(
!
empty
(
$booking_id
))
?
$bookData
->
row
()
:
$bookData
->
result
();
return
$bookData
;
}
return
0
;
}
function
changeStatus
(
$booking_id
=
''
,
$status
=
'0'
){
if
(
empty
(
$booking_id
)){
return
0
;
}
$status
=
$this
->
db
->
update
(
'bookings'
,
array
(
'status'
=>
$status
),
array
(
'booking_id'
=>
$booking_id
));
return
$status
;
}
}
?>
\ No newline at end of file
application/views/Bookings/list-booking.php
0 → 100644
View file @
36cd8466
<div
class=
"content-wrapper"
>
<section
class=
"content-header"
>
<h1>
<?=
$pTitle
?>
<small>
<?=
$pDescription
?>
</small>
</h1>
<ol
class=
"breadcrumb"
>
<li><a
href=
"
<?=
base_url
()
?>
"
><i
class=
"fa fa-star-o"
aria-hidden=
"true"
></i>
Home
</a></li>
<li>
<?=
$menu
?>
</li>
<li
class=
"active"
>
<?=
$smenu
?>
</li>
</ol>
</section>
<section
class=
"content"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<?php
if
(
$this
->
session
->
flashdata
(
'message'
))
{
$flashdata
=
$this
->
session
->
flashdata
(
'message'
);
?>
<div
class=
"alert alert-
<?=
$flashdata
[
'class'
]
?>
"
>
<button
class=
"close"
data-dismiss=
"alert"
type=
"button"
>
×
</button>
<?=
$flashdata
[
'message'
]
?>
</div>
<?php
}
?>
</div>
<?php
if
(
$this
->
session
->
userdata
[
'user_type'
]
==
1
&&
!
empty
(
$mechanic_data
)){
?>
<div
class=
"col-sm-12"
>
<div
class=
"box box-warning"
>
<div
class=
"box-header with-border"
>
<div
class=
"col-md-6"
>
<h3
class=
"box-title"
>
Booking Management
</h3>
</div>
</div>
<div
class=
"box-body"
>
<form
id=
"chooseMechForm"
role=
"form"
action=
"
<?=
base_url
(
'Bookings/listBookings'
)
?>
"
method=
"post"
class=
"validate"
data-parsley-validate=
""
enctype=
"multipart/form-data"
>
<div
class=
"col-sm-12"
>
<div
class=
"form-group"
>
<label>
Choose a Mechanic
</label>
<select
name=
"mechanic_id"
class=
"form-control required"
data-parsley-trigger=
"change"
onchange=
"changeMechanic()"
dmClick=
"0"
required
>
<option
selected
disabled
>
Select Mechanic
</option>
<?php
if
(
!
empty
(
$mechanic_data
)){
foreach
(
$mechanic_data
as
$mechanic
)
{
$chkFlg
=
(
$mechanic_id
==
$mechanic
->
mechanic_id
)
?
'selected'
:
''
;
echo
'<option value="'
.
encode_param
(
$mechanic
->
mechanic_id
)
.
'" '
.
$chkFlg
.
'>
'
.
$mechanic
->
first_name
.
' '
.
$mechanic
->
last_name
.
'</option>'
;
}
}
?>
</select>
</div>
</div>
</form>
</div>
</div>
</div>
<?php
}
if
(
$this
->
session
->
userdata
[
'user_type'
]
!=
1
||
(
$this
->
session
->
userdata
[
'user_type'
]
==
1
&&
!
empty
(
$mechanic_id
))){
?>
<div
class=
"col-xs-12"
>
<div
class=
"box box-warning"
>
<div
class=
"box-body"
>
<table
id=
"mechanicUsers"
class=
"table table-bordered table-striped datatable "
>
<thead>
<tr>
<th
class=
"hidden"
>
ID
</th>
<th
width=
"18%;"
>
Car Name
</th>
<th
width=
"12%;"
>
Mechanic
</th>
<th
width=
"12%;"
>
Customer
</th>
<th
width=
"15%;"
>
Scheduled Date
</th>
<th
width=
"11%;"
>
Service Fee
</th>
<th
width=
"7%;"
>
Status
</th>
<th
width=
"26%;"
>
Action
</th>
</tr>
</thead>
<tbody>
<?php
if
(
!
empty
(
$bookingData
)){
$mapIssueData
=
$bookingData
;
foreach
(
$bookingData
as
$bookData
)
{
?>
<tr>
<th
class=
"hidden"
>
<?=
$bookData
->
booking_id
?>
</th>
<th
class=
"center"
>
<?=
$bookData
->
car_name
?>
</th>
<th
class=
"center"
>
<?=
$bookData
->
mechFirstName
.
' '
.
$bookData
->
mechLastName
?>
</th>
<th
class=
"center"
>
<?=
$bookData
->
custFirstName
.
' '
.
$bookData
->
custLastName
?>
</th>
<th
class=
"center"
>
<?=
$bookData
->
scheduled_date
.
' '
.
$bookData
->
scheduled_time
?>
</th>
<th
class=
"center"
>
<?=
$bookData
->
cost
?>
</th>
<th
class=
"center"
>
<?php
switch
(
$bookData
->
status
){
case
0
:
echo
'Pending'
;
break
;
case
1
:
echo
'Accepted'
;
break
;
case
3
:
echo
'Completed'
;
break
;
case
4
:
echo
'Cancelled'
;
break
;
}
?>
</th>
<td
class=
"center float-right"
>
<button
class=
"btn btn-sm btn-primary"
booking_id=
"
<?=
encode_param
(
$bookData
->
booking_id
)
?>
"
id=
"showBookinDetails"
>
<i
class=
"fa fa-fw fa-edit"
></i>
View Quote
</button>
<?php
if
(
$bookData
->
status
==
1
){
?>
<a
class=
"btn btn-sm btn-success"
style=
"background-color:#ac2925"
href=
"
<?=
base_url
(
"Bookings/changeBookingStatus/"
.
encode_param
(
$bookData
->
booking_id
)
.
"/3/"
.
encode_param
(
$mechanic_id
))
?>
"
>
<i
class=
"fa fa-cog"
></i>
Cancel
</a>
<?php
}
?>
<?php
if
(
$bookData
->
status
==
0
||
$bookData
->
status
==
3
){
?>
<a
class=
"btn btn-sm btn-success"
href=
"
<?=
base_url
(
"Bookings/changeBookingStatus/"
.
encode_param
(
$bookData
->
booking_id
)
.
"/1/"
.
encode_param
(
$mechanic_id
))
?>
"
>
<i
class=
"fa fa-cog"
></i>
Accept
</a>
<?php
}
?>
<a
class=
"btn btn-sm btn-danger"
href=
"
<?=
base_url
(
"Bookings/changeBookingStatus/"
.
encode_param
(
$bookData
->
booking_id
)
.
"/2/"
.
encode_param
(
$mechanic_id
))
?>
"
onClick=
"return doconfirm()"
>
<i
class=
"fa fa-fw fa-trash"
></i>
Delete
</a>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
}
?>
</div>
</section>
</div>
\ No newline at end of file
application/views/Templates/left-menu.php
View file @
36cd8466
...
...
@@ -118,6 +118,12 @@
</li>
</ul>
</li>
<?php
}
?>
<li>
<a
href=
"
<?=
base_url
(
'Bookings/listBookings'
)
?>
"
><i
class=
"fa fa-book"
aria-hidden=
"true"
>
</i><span>
Request Management
</span></a>
</li>
<?php
if
(
$this
->
session
->
userdata
[
'user_type'
]
==
1
){
?>
<li><a
href=
"
<?=
base_url
(
'Settings'
)
?>
"
>
<i
class=
"fa fa-wrench"
aria-hidden=
"true"
>
</i><span>
Settings
</span></a>
...
...
assets/js/custom-script.js
View file @
36cd8466
...
...
@@ -754,4 +754,131 @@ function viewMapIssueDetails(issue_id) {
jQuery
(
'[id="modal_content"]'
).
html
(
'<div class="subIssueCntr">'
+
head
+
body
+
'</div>'
);
remModalLoader
();
return
false
;
}
\ No newline at end of file
}
jQuery
(
'[id="showBookinDetails"]'
).
on
(
'click'
,
function
()
{
var
booking_id
=
jQuery
(
this
).
attr
(
'booking_id'
);
if
(
booking_id
==
''
||
booking_id
==
undefined
||
booking_id
==
'undefined'
||
booking_id
==
null
||
booking_id
==
'null'
){
return
true
;
}
modalTrigger
(
'Booking Details'
,
''
);
addModalLoader
();
jQuery
.
ajax
({
url
:
base_url
+
"Bookings/getBooking"
,
type
:
'POST'
,
data
:
{
'booking_id'
:
booking_id
,
'view_all'
:
'1'
},
success
:
function
(
resp
){
if
(
resp
==
''
||
resp
==
undefined
||
resp
==
'undefined'
||
resp
==
null
||
resp
==
'null'
){
remModalLoader
();
jQuery
(
'[id="modal_content"]'
).
html
(
'Something went wrong, please try again later...!'
);
return
false
;
}
var
resp_data
=
jQuery
.
parseJSON
(
resp
);
if
(
resp_data
[
'status'
]
==
'0'
){
remModalLoader
();
jQuery
(
'[id="modal_content"]'
).
html
(
'Something went wrong, please try again later...!'
);
return
false
;
}
var
booking_data
=
resp_data
[
'data'
];
jQuery
.
each
(
booking_data
,
function
(
index
,
value
)
{
if
(
value
==
''
||
value
==
null
||
value
==
undefined
||
value
==
'null'
||
value
==
'undefined'
){
booking_data
[
index
]
=
' -- '
;
}
});
var
html
=
''
,
issueHtml
=
''
,
issues_selected
=
jQuery
.
parseJSON
(
booking_data
[
'issues_selected'
]);
if
(
issues_selected
!=
''
){
var
comma
=
''
;
issueHtml
=
'<div class="row"><label>Selected Issue</label></div>'
;
issueHtml
+=
'<div class="row">'
+
'<div class="col-md-1"></div>'
+
'<div class="col-md-11">'
;
jQuery
.
each
(
issues_selected
,
function
(
index
,
value
)
{
issueHtml
+=
comma
+
' '
+
value
[
'issue_category'
]
+
' '
;
comma
=
','
;
});
issueHtml
+=
'</div></div>'
;
}
html
=
'<div class="col-xs-12">'
+
'<div class="col-md-6">'
+
'<div class="row"><label>Basic Details</label></div>'
+
'<div class="row">'
+
'<div class="col-md-4">Customer</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'custFirstName'
]
+
' '
+
booking_data
[
'custLastName'
]
+
'</label></div>'
+
'</div> '
+
'<div class="row">'
+
'<div class="col-md-4">Mechanic</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'mechFirstName'
]
+
' '
+
booking_data
[
'mechLastName'
]
+
'</label></div>'
+
'</div> '
+
'<div class="row">'
+
'<div class="col-md-4">Current Milage</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'mileage'
]
+
'</label></div>'
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Service Free</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'cost'
]
+
'</label></div>'
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Scheduled Date</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'scheduled_date'
]
+
' '
+
booking_data
[
'scheduled_time'
]
+
'</label></div> '
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Customer Phone</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'phone'
]
+
'</label></div> '
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Customer Mail</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'email'
]
+
'</label></div> '
+
'</div> '
+
'</div> '
+
'<div class="col-md-6"> '
+
issueHtml
+
'<div class="row"><label>Customer Vehicle Details</label></div>'
+
'<div class="row"> '
+
'<div class="col-md-4">Car Name</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'car_name'
]
+
' </label></div>'
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Car Model</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'car_model'
]
+
'</label></div>'
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Car Model Year</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'car_model_year'
]
+
'</label></div>'
+
'</div> '
+
'<div class="row"> '
+
'<div class="col-md-4">Car Location</div>'
+
'<div class="col-md-1">:</div>'
+
'<div class="col-md-6"><label>'
+
booking_data
[
'car_location'
]
+
'</label></div>'
+
'</div> '
+
'</div> '
+
'</div>'
;
remModalLoader
();
jQuery
(
'[id="modal_content"]'
).
html
(
html
);
},
fail
:
function
(
xhr
,
textStatus
,
errorThrown
){
remModalLoader
();
jQuery
(
'[id="modal_content"]'
).
html
(
'Something went wrong, please try again later...!'
);
},
error
:
function
(
ajaxContext
)
{
remModalLoader
();
jQuery
(
'[id="modal_content"]'
).
html
(
'Something went wrong, please try again later...!'
);
}
});
});
\ 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