Skip to content
Snippets Groups Projects
Commit 6845e01b authored by Eduardo L. Buratti's avatar Eduardo L. Buratti
Browse files

web: Fix location filter

parent 0248d779
No related branches found
No related tags found
No related merge requests found
...@@ -82,9 +82,10 @@ angular.module('datasid.attendance.search', []). ...@@ -82,9 +82,10 @@ angular.module('datasid.attendance.search', []).
key: 'location', key: 'location',
title: 'Localização', title: 'Localização',
options: [ options: [
{ key: 'Maceio, AL', title: 'Maceio, AL', value: false }, { key: 3106200, title: 'Belo Horizonte, MG', value: false },
{ key: 'Salvador, BA', title: 'Salvador, BA', value: false }, { key: 2927408, title: 'Salvador, BA', value: false },
{ key: 'Manaus, AM', title: 'Manaus, AM', value: false } { key: 1501402, title: 'Belém, PA', value: false },
{ key: 5300108, title: 'Brasília, DF' , value: false }
], ],
more: true more: true
} }
......
...@@ -18,17 +18,28 @@ exports.list = function(req, res) { ...@@ -18,17 +18,28 @@ exports.list = function(req, res) {
for (var key in filters) { for (var key in filters) {
switch (key) { switch (key) {
case "project": case "project":
var l = [];
for (var i = 0; i < filters[key].length; i++) { for (var i = 0; i < filters[key].length; i++) {
conditions.push("project = $"+(c++)); l.push("pt.project = $"+(c++));
parameters.push(filters[key][i]); parameters.push(filters[key][i]);
} }
if (l.length > 0)
conditions.push(l.join(' OR '));
break;
case "location":
var l = [];
for (var i = 0; i < filters[key].length; i++) {
l.push("pt.id_city = $"+(c++));
parameters.push(filters[key][i]);
}
if (l.length > 0)
conditions.push(l.join(' OR '));
break; break;
} }
} }
if (conditions.length > 0) if (conditions.length > 0)
where = " AND (" + conditions.join(' OR ') + ")"; where = " AND (" + conditions.join(') AND (') + ")";
var query = "\ var query = "\
SELECT \ SELECT \
...@@ -58,6 +69,8 @@ exports.list = function(req, res) { ...@@ -58,6 +69,8 @@ exports.list = function(req, res) {
LIMIT 50 \ LIMIT 50 \
OFFSET " + offset; OFFSET " + offset;
// console.log(query);
req.db.query(query, parameters, function(result) { req.db.query(query, parameters, function(result) {
req.db.done(); req.db.done();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment