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
105ec3e7
Commit
105ec3e7
authored
Jun 13, 2019
by
Jansa Jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apis and product filter in web
parent
7d3596ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
8 deletions
+133
-8
Webservices.php
application/controllers/Webservices.php
+93
-0
Webservice_model.php
application/models/Webservice_model.php
+40
-8
No files found.
application/controllers/Webservices.php
View file @
105ec3e7
...
...
@@ -2171,6 +2171,14 @@
$postData
[
'customer_id'
]
=
$authRes
[
'data'
][
'customer_id'
];
$prd_data
=
$this
->
Webservice_model
->
SingleProductSearch
(
$postData
);
if
(
$prd_data
[
'status'
]
==
'error'
){
$respArr
[
'status'
]
=
'error'
;
$respArr
[
'message'
]
=
'Amount is Required'
;
echo
json_encode
(
$respArr
);
exit
;
}
$postData
[
'amount'
]
=
$prd_data
[
'data'
]
->
amount
*
$postData
[
'quantity'
];
$result
=
$this
->
Webservice_model
->
addToCart
(
$postData
);
echo
json_encode
(
$result
);
exit
;
}
...
...
@@ -2499,6 +2507,25 @@
echo
json_encode
(
$result
);
exit
;
}
public
function
get_vehicle_brand
(){
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_model
->
get_customer_authtoken
(
$headers
[
'Auth'
]);
if
(
$authRes
[
'status'
]
==
'error'
){
echo
json_encode
(
$authRes
);
exit
;
}
$result
=
$this
->
Webservice_model
->
getVehicleBrand
();
echo
json_encode
(
$result
);
exit
;
}
public
function
getVehicleModel
(){
header
(
'Content-type:application/json'
);
$headers
=
apache_request_headers
();
...
...
@@ -2509,6 +2536,72 @@
$result
=
$this
->
Webservice_model
->
getVehicleModel
(
$postData
);
echo
json_encode
(
$result
);
exit
;
}
public
function
get_vehicle_model
(){
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_model
->
get_customer_authtoken
(
$headers
[
'Auth'
]);
if
(
$authRes
[
'status'
]
==
'error'
){
echo
json_encode
(
$authRes
);
exit
;
}
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
$result
=
$this
->
Webservice_model
->
getVehicleModel
(
$postData
);
echo
json_encode
(
$result
);
exit
;
}
public
function
get_userAddress_by_id
(){
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_model
->
get_customer_authtoken
(
$headers
[
'Auth'
]);
if
(
$authRes
[
'status'
]
==
'error'
){
echo
json_encode
(
$authRes
);
exit
;
}
$postData
=
$_GET
;
$postData
[
'customer_id'
]
=
$authRes
[
'data'
][
'customer_id'
];
$result
=
$this
->
Webservice_model
->
getUserAddressById
(
$postData
);
echo
json_encode
(
$result
);
exit
;
}
public
function
update_address
(){
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_model
->
get_customer_authtoken
(
$headers
[
'Auth'
]);
if
(
$authRes
[
'status'
]
==
'error'
){
echo
json_encode
(
$authRes
);
exit
;
}
$post
=
file_get_contents
(
"php://input"
);
$postData
=
json_decode
(
$post
,
true
);
$result
=
$this
->
Webservice_model
->
update_user_address
(
$postData
);
echo
json_encode
(
$result
);
exit
;
}
}
...
...
application/models/Webservice_model.php
View file @
105ec3e7
...
...
@@ -621,18 +621,31 @@ class Webservice_model extends CI_Model {
$where
.=
" PRD.amount < "
.
$postData
[
'maxPrice'
]
.
" AND "
;
}
if
(
isset
(
$postData
[
'year'
])
&&
$postData
[
'year'
]
!=
''
){
$where
.=
" CRD.year = "
.
$postData
[
'year'
]
.
" AND "
;
}
if
(
isset
(
$postData
[
'maker'
])
&&
$postData
[
'maker'
]
!=
''
){
$where
.=
" VEHM.veh_brand_id = "
.
$postData
[
'maker'
]
.
" AND "
;
}
if
(
isset
(
$postData
[
'model'
])
&&
$postData
[
'model'
]
!=
''
){
$where
.=
" VEHM.veh_modal_id = "
.
$postData
[
'model'
]
.
" AND "
;
}
$result
=
$this
->
db
->
query
(
"SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS count,PRD.*,PI.image
FROM products AS PRD
LEFT JOIN
product_images AS PI ON
(PI.id=(SELECT MIN(id)
FROM product_images
WHERE product_id= PRD.product_id AND
PRD.status='1'))
LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id
LEFT JOIN
cardetails AS CRD ON (PRD.cardetail_id=CRD.id)
LEFT JOIN product_rating AS REV ON (REV.product_id=PRD.product_id)
LEFT JOIN vehicles_model AS VEHM ON (VEHM.veh_modal_id=CRD.veh_modal_id)
LEFT JOIN product_images AS PI ON (PI.id=
(SELECT MIN(id) FROM product_images
WHERE product_id=PRD.product_id AND PRD.status='1'))
WHERE
$where
PRD.status='1'
GROUP BY PRD.product_id,PI.product_id
$lmt
"
);
GROUP BY PRD.product_id,PI.product_id
$lmt
"
);
if
(
!
empty
(
$result
)
&&
$result
->
num_rows
()
>
0
){
$result
=
$result
->
result_array
();
foreach
(
$result
as
$key
=>
$value
)
{
...
...
@@ -809,6 +822,25 @@ class Webservice_model extends CI_Model {
return
$respArr
;
}
public
function
update_user_address
(
$postData
){
$respArr
=
array
(
'status'
=>
'error'
);
if
(
empty
(
$postData
)){
$respArr
[
'message'
]
=
'All Field is required'
;
return
$respArr
;
}
if
(
empty
(
$postData
[
'id'
])){
$respArr
[
'message'
]
=
'Address Id is required'
;
return
$respArr
;
}
if
(
$this
->
db
->
update
(
'customer_address'
,
$postData
,
array
(
'id'
=>
$postData
[
'id'
]))){
$respArr
[
'status'
]
=
'success'
;
$respArr
[
'message'
]
=
'Address Updated Successfully'
;
}
return
$respArr
;
}
public
function
initOrderBooking
(
$postData
=
array
()){
$respArr
=
array
(
'status'
=>
'error'
);
if
(
empty
(
$postData
[
'data'
])){
...
...
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