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
4869bf3e
Commit
4869bf3e
authored
Jul 05, 2019
by
Jansa Jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mechanic app apis
parent
0c001580
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
163 additions
and
82 deletions
+163
-82
Webservices_mechanic.php
application/controllers/Webservices_mechanic.php
+94
-67
Webservice_mechanic_model.php
application/models/Webservice_mechanic_model.php
+69
-14
Webservice_model.php
application/models/Webservice_model.php
+0
-1
No files found.
application/controllers/Webservices_mechanic.php
View file @
4869bf3e
...
@@ -156,73 +156,6 @@
...
@@ -156,73 +156,6 @@
echo
json_encode
(
$respArr
);
exit
;
echo
json_encode
(
$respArr
);
exit
;
}
}
// public function get_pending_services(){
// header('Content-type: application/json');
// $headers = apache_request_headers();
// if(!isset($headers['Auth']) || empty($headers['Auth'])){
// $respArr['status'] = 'error';
// $respArr['message'] = 'Authtoken is Required';
// echo json_encode($respArr);exit;
// }
// $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
// if($authRes['status'] == 'error'){
// echo json_encode($authRes);exit;
// }
// $per_page = 10;
// $page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
// $start = ($page - 1) * $per_page;
// $post = file_get_contents("php://input");
// $postData = json_decode($post, true);
// $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
// $bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,2);
// $bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,2);
// $total = 0;
// if($bookDataCount['status'] == 'success'){
// $total = count($bookDataCount['data']);
// }
// if($total >= $per_page){
// $totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
// }
// else{
// $totalPages = 1;
// }
// if($bookDataResult['status'] == 'success'){
// $respArr = array(
// 'status' => 'success',
// 'message'=>'success',
// 'data' => $bookDataResult['data'],
// 'meta' => array(
// 'total_pages' => $totalPages,
// 'total' => $total,
// 'current_page' => ($page == 0)?1:$page,
// 'per_page' => $per_page
// )
// );
// }else{
// $respArr = array(
// 'status' => 'error',
// 'message'=>'No data',
// 'data' => [],
// 'meta' => array(
// 'total_pages' => $totalPages,
// 'total' => $total,
// 'current_page' => ($page == 0)?1:$page,
// 'per_page' => $per_page
// )
// );
// }
// echo json_encode($respArr);exit;
// }
public
function
get_service_history
(){
public
function
get_service_history
(){
header
(
'Content-type: application/json'
);
header
(
'Content-type: application/json'
);
$headers
=
apache_request_headers
();
$headers
=
apache_request_headers
();
...
@@ -289,5 +222,99 @@
...
@@ -289,5 +222,99 @@
}
}
echo
json_encode
(
$respArr
);
exit
;
echo
json_encode
(
$respArr
);
exit
;
}
}
public
function
logout
(){
header
(
'Content-type: application/json'
);
$headers
=
apache_request_headers
();
if
(
!
isset
(
$headers
[
'Auth'
])
||
empty
(
$headers
[
'Auth'
])){
$respArr
[
'status'
]
=
'error'
;
$respArr
[
'message'
]
=
'Authtoken is Required'
;
echo
json_encode
(
$respArr
);
exit
;
}
$authRes
=
$this
->
Webservice_mechanic_model
->
get_mechanic_authtoken
(
$headers
[
'Auth'
]);
if
(
$authRes
[
'status'
]
==
'error'
){
echo
json_encode
(
$authRes
);
exit
;
}
$respArr
=
$this
->
Webservice_mechanic_model
->
mechanic_logout
(
$authRes
[
'data'
][
'mechanic_id'
]);
echo
json_encode
(
$respArr
);
exit
;
}
public
function
forgot_password
(){
header
(
'Content-type: application/json'
);
$headers
=
apache_request_headers
();
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
if
(
!
isset
(
$postData
[
'user_name'
])
||
empty
(
$postData
[
'user_name'
])){
$respArr
[
'message'
]
=
"Username is Required"
;
echo
json_encode
(
$respArr
);
exit
;
}
$respArr
=
$this
->
Webservice_mechanic_model
->
forgot_password
(
$postData
[
'user_name'
]);
echo
json_encode
(
$respArr
);
exit
;
}
public
function
change_password
(){
header
(
'Content-type: application/json'
);
$headers
=
apache_request_headers
();
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
$respArr
=
array
(
"status"
=>
"error"
);
if
(
!
isset
(
$postData
[
'user_name'
])
||
empty
(
$postData
[
'user_name'
])){
$respArr
[
'message'
]
=
"Username is Required"
;
echo
json_encode
(
$respArr
);
exit
;
}
else
if
(
!
isset
(
$postData
[
'password'
])
||
empty
(
$postData
[
'password'
])){
$respArr
[
'message'
]
=
"Password is Required"
;
echo
json_encode
(
$respArr
);
exit
;
}
$respArr
=
$this
->
Webservice_mechanic_model
->
change_password
(
$postData
);
echo
json_encode
(
$respArr
);
exit
;
}
public
function
start_service
(){
header
(
'Content-type: application/json'
);
$headers
=
apache_request_headers
();
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
$respArr
=
array
(
"status"
=>
"error"
);
if
(
!
isset
(
$postData
[
'service_id'
])
||
empty
(
$postData
[
'service_id'
])){
$respArr
[
'message'
]
=
"Booking Id is Required"
;
echo
json_encode
(
$respArr
);
exit
;
}
if
(
!
isset
(
$postData
[
'emergency'
])){
$respArr
[
'message'
]
=
"Emergency Field is Required"
;
echo
json_encode
(
$respArr
);
exit
;
}
$respArr
=
$this
->
Webservice_mechanic_model
->
start_service
(
$postData
);
echo
json_encode
(
$respArr
);
exit
;
}
public
function
stop_service
(){
header
(
'Content-type: application/json'
);
$headers
=
apache_request_headers
();
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
if
(
!
isset
(
$postData
[
'service_id'
])
||
empty
(
$postData
[
'service_id'
])){
$respArr
[
'message'
]
=
"Booking Id is Required"
;
return
$respArr
;
}
else
if
(
!
isset
(
$postData
[
'emergency'
])
||
empty
(
$postData
[
'emergency'
])){
$respArr
[
'message'
]
=
"Emergency Field is Required"
;
return
$respArr
;
}
$respArr
=
$this
->
Webservice_mechanic_model
->
start_service
(
$postData
,
1
);
echo
json_encode
(
$respArr
);
exit
;
}
}
}
?>
?>
application/models/Webservice_mechanic_model.php
View file @
4869bf3e
<?php
<?php
class
Webservice_mechanic_model
extends
CI_Model
{
class
Webservice_mechanic_model
extends
CI_Model
{
function
__construct
()
{
function
__construct
()
{
parent
::
__construct
();
parent
::
__construct
();
date_default_timezone_set
(
'Asia/Kolkata'
);
date_default_timezone_set
(
'Asia/Kolkata'
);
}
}
/***************************************************************************************/
/***************************************************************************************/
/****************************************Mobile API's***********************************/
/****************************************Mobile API's***********************************/
function
checkMechanicLogin
(
$userLogData
){
function
checkMechanicLogin
(
$userLogData
){
$respArr
=
array
(
'status'
=>
'error'
);
$respArr
=
array
(
'status'
=>
'error'
);
if
(
empty
(
$userLogData
)){
if
(
empty
(
$userLogData
)){
return
$respArr
;
return
$respArr
;
...
@@ -32,9 +32,9 @@ class Webservice_mechanic_model extends CI_Model {
...
@@ -32,9 +32,9 @@ class Webservice_mechanic_model extends CI_Model {
$respArr
[
'status'
]
=
'success'
;
$respArr
[
'status'
]
=
'success'
;
}
}
return
$respArr
;
return
$respArr
;
}
}
public
function
insert_auth
(
$id
){
public
function
insert_auth
(
$id
){
$static_string
=
time
();
$static_string
=
time
();
$authToken
=
'Dcarfixs'
.
sha1
(
$static_string
);
$authToken
=
'Dcarfixs'
.
sha1
(
$static_string
);
$mechData
=
$this
->
db
->
get_where
(
'authtable_mechanic'
,
array
(
'mechanic_id'
=>
$id
));
$mechData
=
$this
->
db
->
get_where
(
'authtable_mechanic'
,
array
(
'mechanic_id'
=>
$id
));
...
@@ -46,9 +46,9 @@ class Webservice_mechanic_model extends CI_Model {
...
@@ -46,9 +46,9 @@ class Webservice_mechanic_model extends CI_Model {
}
}
return
$authToken
;
return
$authToken
;
}
}
public
function
get_mechanic_authtoken
(
$auth
=
''
){
public
function
get_mechanic_authtoken
(
$auth
=
''
){
$respArr
=
array
(
'status'
=>
0
,
'error'
=>
'901'
,
'message'
=>
'Something Went Wrong.'
);
$respArr
=
array
(
'status'
=>
0
,
'error'
=>
'901'
,
'message'
=>
'Something Went Wrong.'
);
if
(
empty
(
$auth
)){
if
(
empty
(
$auth
)){
return
$respArr
;
return
$respArr
;
...
@@ -63,9 +63,9 @@ class Webservice_mechanic_model extends CI_Model {
...
@@ -63,9 +63,9 @@ class Webservice_mechanic_model extends CI_Model {
$respArr
[
'message'
]
=
'Authtoken is not Valid'
;
$respArr
[
'message'
]
=
'Authtoken is not Valid'
;
}
}
return
$respArr
;
return
$respArr
;
}
}
public
function
getBookedService
(
$postData
=
array
(),
$start
=
''
,
$per_page
=
''
,
$type
=
0
,
$status
=
1
){
public
function
getBookedService
(
$postData
=
array
(),
$start
=
''
,
$per_page
=
''
,
$type
=
0
,
$status
=
1
){
$respArr
=
array
(
'status'
=>
'error'
,
'message'
=>
'Something Went Wrong.. Try Again Later'
);
$respArr
=
array
(
'status'
=>
'error'
,
'message'
=>
'Something Went Wrong.. Try Again Later'
);
if
(
empty
(
$postData
)){
if
(
empty
(
$postData
)){
$respArr
[
'message'
]
=
"All Field is Required"
;
$respArr
[
'message'
]
=
"All Field is Required"
;
...
@@ -127,15 +127,70 @@ class Webservice_mechanic_model extends CI_Model {
...
@@ -127,15 +127,70 @@ class Webservice_mechanic_model extends CI_Model {
$bookData
[
$key
][
'service_name'
]
=
$new
;
$bookData
[
$key
][
'service_name'
]
=
$new
;
}
}
}
$respArr
[
'status'
]
=
'success'
;
$respArr
[
'message'
]
=
'success'
;
$respArr
[
'data'
]
=
$bookData
;
}
return
$respArr
;
}
public
function
mechanic_logout
(
$mechanic_id
){
$respArr
=
array
(
'status'
=>
'error'
);
$status
=
$this
->
db
->
delete
(
'authtable_mechanic'
,
array
(
'mechanic_id'
=>
$mechanic_id
));
if
(
$status
){
$respArr
[
'status'
]
=
"success"
;
$respArr
[
'message'
]
=
"Logged Out Successfully"
;
}
}
$respArr
[
'status'
]
=
'success'
;
return
$status
;
$respArr
[
'message'
]
=
'success'
;
}
$respArr
[
'data'
]
=
$bookData
;
public
function
forgot_password
(
$username
){
$respArr
=
array
(
'status'
=>
'error'
);
$result
=
$this
->
db
->
query
(
"SELECT MCH.phone as phone_number,AU.username as user_name FROM admin_users AS AU INNER JOIN mechanic AS MCH ON MCH.mechanic_id = AU.id WHERE AU.username LIKE '
$username
'"
);
if
(
empty
(
$result
)
||
$result
->
num_rows
()
<
0
||
empty
(
$result
=
$result
->
row
())){
$respArr
[
'message'
]
=
"Username Doesnot Exist"
;
return
$respArr
;
}
}
$respArr
[
'status'
]
=
"success"
;
$respArr
[
'message'
]
=
"success"
;
$respArr
[
'data'
]
=
$result
;
return
$respArr
;
return
$respArr
;
}
public
function
change_password
(
$postData
=
array
())
{
$respArr
=
array
(
'status'
=>
'error'
);
$result
=
$this
->
db
->
query
(
"SELECT * FROM admin_users WHERE username LIKE '"
.
$postData
[
'user_name'
]
.
"'"
);
if
(
empty
(
$result
)
||
$result
->
num_rows
()
<
0
||
empty
(
$result
=
$result
->
row
())){
$respArr
[
'message'
]
=
"Username doesnot Exist"
;
return
$respArr
;
}
if
(
$this
->
db
->
update
(
'admin_users'
,
array
(
'password'
=>
md5
(
$postData
[
'password'
])),
array
(
'id'
=>
$result
->
id
))){
$respArr
[
'status'
]
=
"success"
;
$respArr
[
'message'
]
=
"Password Updated Successfully"
;
}
}
return
$respArr
;
}
public
function
start_service
(
$postData
=
array
(),
$type
=
0
){
$respArr
=
array
(
'status'
=>
'error'
);
if
(
empty
(
$postData
)){
return
$respArr
;
}
$status
=
(
$type
==
'1'
)
?
3
:
1
;
$cost
=
(
$postData
[
'emergency'
]
==
'2'
)
?
$postData
[
'amount'
]
:
''
;
if
(
$this
->
db
->
update
(
'bookings'
,
array
(
'service_type'
=>
$postData
[
'emergency'
],
'cost'
=>
$cost
,
'status'
=>
$status
),
array
(
'booking_id'
=>
$postData
[
'service_id'
]))){
$respArr
[
'status'
]
=
"success"
;
$respArr
[
'message'
]
=
(
$type
==
'1'
)
?
"Service Completed Successfully"
:
"Service Started Successfully"
;
}
return
$respArr
;
}
}
}
?>
?>
application/models/Webservice_model.php
View file @
4869bf3e
...
@@ -179,7 +179,6 @@ class Webservice_model extends CI_Model {
...
@@ -179,7 +179,6 @@ class Webservice_model extends CI_Model {
}
}
$this
->
db
->
where
(
'scheduled_date >'
,
date
(
'Y-m-d h:i'
));
$this
->
db
->
where
(
'scheduled_date >'
,
date
(
'Y-m-d h:i'
));
$bookData
=
$this
->
db
->
get_where
(
'bookings'
,
$where
)
->
result_array
();
$bookData
=
$this
->
db
->
get_where
(
'bookings'
,
$where
)
->
result_array
();
//pr($this->db->last_query());
$respArr
[
'status'
]
=
'success'
;
$respArr
[
'status'
]
=
'success'
;
$respArr
[
'message'
]
=
'success'
;
$respArr
[
'message'
]
=
'success'
;
if
(
!
empty
(
$bookData
)
&&
(
count
(
$bookData
)
>
0
)){
if
(
!
empty
(
$bookData
)
&&
(
count
(
$bookData
)
>
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