| 416 |
aurelien |
1 |
<?php
|
|
|
2 |
// in utf8
|
|
|
3 |
// out utf8
|
|
|
4 |
|
|
|
5 |
// List des stations par utilisateur et par commune
|
|
|
6 |
|
|
|
7 |
Class InventoryStationList extends DBAccessor {
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
var $config;
|
|
|
11 |
|
|
|
12 |
function InventoryStationList($config) {
|
|
|
13 |
|
|
|
14 |
$this->config=$config;
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
function getElement($uid){
|
|
|
19 |
|
|
|
20 |
// Controle detournement utilisateur
|
|
|
21 |
session_start();
|
|
|
22 |
$this->controleUtilisateur($uid[0]);
|
|
|
23 |
|
|
|
24 |
// uid[0] : utilisateur obligatoire
|
|
|
25 |
// uid[1] : si absent : valeur 'all' (commune)
|
|
|
26 |
// uid[2] et uid[3] : selection intervalle
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
$DB=$this->connectDB($this->config,'database_cel');
|
|
|
30 |
|
|
|
31 |
if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
|
|
|
32 |
$uid[1]="all";
|
|
|
33 |
$query_location="";
|
|
|
34 |
}
|
|
|
35 |
else {
|
|
|
36 |
$query_location=" AND location='".$DB->escapeSimple($uid[1])."' ";
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
$value=array();
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
if (isset($uid[3]) && isset($uid[2])) {
|
|
|
44 |
// les n � partir de x
|
|
|
45 |
$query="SELECT DISTINCT station FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."'" .
|
|
|
46 |
$query_location.
|
|
|
47 |
" ORDER BY station LIMIT ".$uid[2].",".$uid[3];
|
|
|
48 |
}
|
|
|
49 |
else {
|
|
|
50 |
if (isset($uid[2])) {
|
|
|
51 |
$query="SELECT DISTINCT station FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
|
|
|
52 |
$query_location.
|
|
|
53 |
"ORDER BY station LIMIT ".$uid[2].",18446744073709551615";
|
|
|
54 |
}
|
|
|
55 |
else {
|
|
|
56 |
// le nombre total
|
|
|
57 |
$query="SELECT count(DISTINCT station) as count FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
|
|
|
58 |
$query_location;
|
|
|
59 |
|
|
|
60 |
$res =& $DB->query($query);
|
|
|
61 |
|
|
|
62 |
if (DB::isError($res)) {
|
|
|
63 |
die($res->getMessage());
|
|
|
64 |
}
|
|
|
65 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
66 |
$value=$row['count'];
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
$json = new Services_JSON();
|
|
|
70 |
$output = $json->encode((integer)$value);
|
|
|
71 |
print($output);
|
|
|
72 |
|
|
|
73 |
return true;
|
|
|
74 |
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
$res =& $DB->query($query);
|
|
|
80 |
|
|
|
81 |
if (DB::isError($res)) {
|
|
|
82 |
die($res->getMessage());
|
|
|
83 |
}
|
|
|
84 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
85 |
$value[]=array($row['station']);
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
$json = new Services_JSON();
|
|
|
89 |
$output = $json->encode($value);
|
|
|
90 |
print($output);
|
|
|
91 |
|
|
|
92 |
return true;
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
103 |
* $Log$
|
|
|
104 |
* Revision 1.3 2008-01-30 08:57:28 ddelon
|
|
|
105 |
* fin mise en place mygwt
|
|
|
106 |
*
|
|
|
107 |
* Revision 1.2 2007-05-22 12:54:09 ddelon
|
|
|
108 |
* Securisation acces utilisateur
|
|
|
109 |
*
|
|
|
110 |
*
|
|
|
111 |
*
|
|
|
112 |
*/
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
?>
|