Subversion Repositories eFlore/Applications.cel

Rev

Rev 423 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
423 aurelien 69
						$output = json_encode((integer)$value);
416 aurelien 70
						print($output);
71
 
72
						return true;
73
 
74
				}
75
			}
76
 
77
 
78
		    $res =& $DB->query($query);
79
 
80
	        if (DB::isError($res)) {
81
    	        die($res->getMessage());
82
        	}
83
	        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
84
	            $value[]=array($row['station']);
85
    	    }
86
 
423 aurelien 87
			$output = json_encode($value);
416 aurelien 88
			print($output);
89
 
90
			return true;
91
 
92
 
93
	}
94
 
95
 
96
 
97
}
98
 
99
 
100
/* +--Fin du code ---------------------------------------------------------------------------------------+
101
* $Log$
102
* Revision 1.3  2008-01-30 08:57:28  ddelon
103
* fin mise en place mygwt
104
*
105
* Revision 1.2  2007-05-22 12:54:09  ddelon
106
* Securisation acces utilisateur
107
*
108
*
109
*
110
*/
111
 
112
 
113
?>