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
 
3
// in : utf8
4
// out : utf8
5
 
6
// Liste les date de releves par utilisateur
7
 
8
 
9
Class InventoryDateList extends DBAccessor {
10
 
11
 
12
	var $config;
13
 
14
	function InventoryDateList($config) {
15
 
16
		$this->config=$config;
17
	}
18
 
19
 
20
	function getElement($uid){
21
 
22
 
23
			// uid[0] : utilisateur obligatoire
24
			// uid[1] : si absent : valeur 'all' (annee)
25
			// uid[2] : si absent : valeur 'all' (mois)
26
			// uid[3] : si absent : valeur 'all' (jour)
27
 
28
		   // Controle detournement utilisateur
29
		    session_start();
30
 
31
		 	$this->controleUtilisateur($uid[0]);
32
 
33
			$DB=$this->connectDB($this->config,'database_cel');
34
 
35
			$select = "date_observation" ;
36
 
37
			if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
38
				$uid[1]="all";
39
				if ($select=="") $select="year(date_observation) ";
40
			}
41
			else {
42
				$query_year=" AND year(date_observation)='".$DB->escapeSimple($uid[1])."' ";
43
			}
44
 
45
 
46
			if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all" ) {
47
				$uid[2]="all";
48
				if ($select=="") $select="month(date_observation) ";
49
			}
50
			else {
51
				$query_month=" AND month(date_observation)='".$DB->escapeSimple($uid[2])."' ";
52
			}
53
 
54
			if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all" ) {
55
				$uid[3]="all";
56
				if ($select=="") $select="day(date_observation) ";
57
			}
58
			else {
59
				$query_day=" AND day(date_observation)='".$DB->escapeSimple($uid[3])."' ";
60
			}
61
 
62
 
63
			$value=array();
64
 
65
 
66
 
67
		   	$query="SELECT DISTINCT ".
68
	    			$select. " AS id" .
69
	           		" FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
70
	            	$query_year.
71
	            	$query_month.
72
	            	$query_day.
73
	           		" ORDER BY ".$select;
74
 
75
 
76
		    $res =& $DB->query($query);
77
 
78
	        if (DB::isError($res)) {
79
    	        die($res->getMessage());
80
        	}
81
	        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
82
	        	 $value[]=array($row['id']);
83
    	    }
84
 
423 aurelien 85
			$output = json_encode($value);
416 aurelien 86
			print($output);
87
 
88
			return true;
89
 
90
 
91
	}
92
 
93
 
94
 
95
}
96
 
97
 
98
/* +--Fin du code ---------------------------------------------------------------------------------------+
99
* $Log$
100
* Revision 1.4  2008-01-30 08:57:28  ddelon
101
* fin mise en place mygwt
102
*
103
* Revision 1.3  2007-05-22 12:54:09  ddelon
104
* Securisation acces utilisateur
105
*
106
*
107
*
108
*/
109
 
110
 
111
 
112
?>