416 |
aurelien |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
// In : utf8
|
|
|
5 |
// Out : utf8
|
|
|
6 |
|
|
|
7 |
Class InventoryItemList extends DBAccessor {
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
var $config;
|
|
|
11 |
|
|
|
12 |
function InventoryItemList($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' (departement)
|
|
|
26 |
// uid[2] : si absent : valeur 'all' (commune)
|
|
|
27 |
// uid[3] : si absent : valeur 'all' (annee)
|
|
|
28 |
// uid[4] : si absent : valeur 'all' (mois)
|
|
|
29 |
// uid[5] : si absent : valeur 'all' (jour)
|
|
|
30 |
// uid[6] : si absent : valeur 'all' (recherche libre)
|
|
|
31 |
// uid[7] : si absent : valeur 'all' (lieudit)
|
|
|
32 |
// uid[8] et uid[9] : selection intervalle
|
|
|
33 |
|
|
|
34 |
$DB=$this->connectDB($this->config,'database_cel');
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
|
|
|
38 |
$uid[1]="all";
|
|
|
39 |
$query_id_location="";
|
|
|
40 |
}
|
|
|
41 |
else {
|
|
|
42 |
$query_id_location=" AND id_location='".$DB->escapeSimple($uid[1])."' ";
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all" ) {
|
|
|
47 |
$uid[2]="all";
|
|
|
48 |
$query_location="";
|
|
|
49 |
}
|
|
|
50 |
else {
|
|
|
51 |
$query_location=" AND location='".$DB->escapeSimple($uid[2])."' ";
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all") {
|
|
|
55 |
$uid[3]="all";
|
|
|
56 |
$query_year="";
|
|
|
57 |
}
|
|
|
58 |
else {
|
|
|
59 |
$query_year=" AND year(date_observation)='".$DB->escapeSimple($uid[3])."' ";
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
if (!isset($uid[4]) || $uid[4]=="" || $uid[4]=="all") {
|
|
|
64 |
$uid[4]="all";
|
|
|
65 |
$query_month="";
|
|
|
66 |
}
|
|
|
67 |
else {
|
|
|
68 |
$query_month=" AND month(date_observation)='".$DB->escapeSimple($uid[4])."' ";
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
if (!isset($uid[5]) || $uid[5]=="" || $uid[5]=="all") {
|
|
|
72 |
$uid[5]="all";
|
|
|
73 |
$query_day="";
|
|
|
74 |
}
|
|
|
75 |
else {
|
|
|
76 |
$query_day=" AND day(date_observation)='".$DB->escapeSimple($uid[5])."' ";
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
if (!isset($uid[6]) || $uid[6]=="" || $uid[6]=="all") {
|
|
|
81 |
$uid[6]="all";
|
|
|
82 |
$query_libre="";
|
|
|
83 |
}
|
|
|
84 |
else {
|
|
|
85 |
$query_libre=" AND (nom_sel like '%".$DB->escapeSimple($uid[6])."%' OR nom_ret like '%".$DB->escapeSimple($uid[6])."%' OR station like '%".$DB->escapeSimple($uid[6])."%' OR milieu like '%".$DB->escapeSimple($uid[6])."%' OR commentaire like '%".$DB->escapeSimple($uid[6])."%') ";
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
if (!isset($uid[7]) || $uid[7]=="" || $uid[7]=="all") {
|
|
|
89 |
$uid[7]="all";
|
|
|
90 |
$query_lieudit="";
|
|
|
91 |
}
|
|
|
92 |
else {
|
|
|
93 |
$query_lieudit=" AND lieudit='".$DB->escapeSimple($uid[7])."' ";
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
$value=array();
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
if (isset($uid[8]) && isset($uid[9])) {
|
|
|
101 |
$query="SELECT identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, date_observation," .
|
|
|
102 |
" lieudit, station, milieu, commentaire, transmission FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
|
|
|
103 |
$query_id_location.
|
|
|
104 |
$query_location.
|
|
|
105 |
$query_year.
|
|
|
106 |
$query_month.
|
|
|
107 |
$query_day.
|
|
|
108 |
$query_libre.
|
|
|
109 |
$query_lieudit.
|
|
|
110 |
" ORDER BY ordre LIMIT ".$uid[8].",".$uid[9];
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
else {
|
|
|
114 |
if (isset($uid[8])) {
|
|
|
115 |
// les n derniers
|
|
|
116 |
$query="SELECT identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, date_observation," .
|
|
|
117 |
" lieudit, station, milieu, commentaire, transmission FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
|
|
|
118 |
$query_id_location.
|
|
|
119 |
$query_location.
|
|
|
120 |
$query_year.
|
|
|
121 |
$query_month.
|
|
|
122 |
$query_day.
|
|
|
123 |
$query_libre.
|
|
|
124 |
$query_lieudit.
|
|
|
125 |
" ORDER BY ordre LIMIT ".$uid[8].",18446744073709551615";
|
|
|
126 |
}
|
|
|
127 |
else {
|
|
|
128 |
$query="SELECT count(*) as count FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."'" .
|
|
|
129 |
$query_id_location.
|
|
|
130 |
$query_location.
|
|
|
131 |
$query_year.
|
|
|
132 |
$query_month.
|
|
|
133 |
$query_day.
|
|
|
134 |
$query_libre.
|
|
|
135 |
$query_lieudit;
|
|
|
136 |
|
|
|
137 |
$res =& $DB->query($query);
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
if (DB::isError($res)) {
|
|
|
141 |
die($res->getMessage());
|
|
|
142 |
}
|
|
|
143 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
144 |
$value=$row['count'];
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
$json = new Services_JSON();
|
|
|
148 |
$output = $json->encode((integer)$value);
|
|
|
149 |
print($output);
|
|
|
150 |
|
|
|
151 |
return true;
|
|
|
152 |
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
$res =& $DB->query($query);
|
|
|
158 |
|
|
|
159 |
if (DB::isError($res)) {
|
|
|
160 |
die($res->getMessage());
|
|
|
161 |
}
|
|
|
162 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
163 |
if ($row['date_observation']!="0000-00-00 00:00:00") {
|
|
|
164 |
list($year,$month,$day)= split ('-',$row['date_observation']);
|
|
|
165 |
list($day)= split (' ',$day);
|
|
|
166 |
$row['date_observation']=$day."/".$month."/".$year;
|
|
|
167 |
}
|
|
|
168 |
$value[]=array($row['nom_sel'], $row['num_nom_sel'],$row['nom_ret'],$row['num_nom_ret'],$row['num_taxon'],$row['famille'], $row['location'], $row['ordre'], $row['date_observation'], $row['lieudit'], $row['station'], $row['milieu'], $row['commentaire'], $row['transmission']);
|
|
|
169 |
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
$json = new Services_JSON();
|
|
|
173 |
$output = $json->encode($value);
|
|
|
174 |
print($output);
|
|
|
175 |
|
|
|
176 |
return true;
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
186 |
* $Log$
|
|
|
187 |
* Revision 1.7 2008-11-13 11:29:12 ddelon
|
|
|
188 |
* Reecriture gwt-ext
|
|
|
189 |
*
|
|
|
190 |
* Revision 1.6 2008-01-30 08:57:28 ddelon
|
|
|
191 |
* fin mise en place mygwt
|
|
|
192 |
*
|
|
|
193 |
* Revision 1.5 2007-05-22 12:54:08 ddelon
|
|
|
194 |
* Securisation acces utilisateur
|
|
|
195 |
*
|
|
|
196 |
*
|
|
|
197 |
*
|
|
|
198 |
*/
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
?>
|