-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample.js
More file actions
80 lines (70 loc) · 1.27 KB
/
Copy pathexample.js
File metadata and controls
80 lines (70 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function getUriParams(obj)
{
return uriparams;
}
function checkClientId(obj)
{
try{
return ((obj.clientID) && (obj.clientID!=""));
} catch(e){
return false;
}
}
function responseError(obj)
{
var resp={};
resp.success=false;
resp.error = "Authenticate fails due to invalid credentials!";
return resp;
}
//This function returns a JSON Object for fastest results use sql2jsonstr
function sql2json(sql)
{
var ds = X.GETSQLDATASET(sql, null);
if (ds.RECORDCOUNT>0){
return '{"success":true, "data":'+ds.JSON+'}';
}else{
return '{"success":false, "error":"No data"}';
}
}
/*
Old method delays and wasting memory
function sql2json(sql)
{
var resp={};
var ds = X.GETSQLDATASET(sql, null);
if (ds.RECORDCOUNT>0){
resp.success=true;
resp.data = eval(ds.JSON);
return resp;
}else{
resp.success=false;
resp.error = "No data";
return resp;
}
}
*/
//This function returns a JSON data as string
function sql2jsonstr(sql)
{
var ds = X.GETSQLDATASET(sql, null);
if (ds){
return ds.JSON;
}else{
return "";
}
}
function getVat(obj)
{
if (checkClientId(obj)){
return sql2json('SELECT VAT,NAME,PERCNT,VATS1 FROM VAT WHERE ISACTIVE=1 ORDER BY VAT');
} else {
return responseError(obj);
}
}
function test(obj)
{
...
...
...
}