Subversion Repositories eFlore/Applications.cel

Rev

Rev 798 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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