Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
416 aurelien 1
<?php
2
 
3
// In utf8
4
// Out iso3859
5
 
6
// Liste des Nouvelles observations par departement
7
 
8
 
9
Class InventoryByDept extends DBAccessor {
10
 
11
 
12
	var $config;
13
	var $extendSpreadsheetProductor;
14
 
15
 
16
	function InventoryByDept($config) {
17
 
18
		$this->config=$config;
19
		// Pas d'heritage multiple en php :(
20
 
21
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
22
		$this->extendSpreadsheetProductor->initSpreadsheet();
23
 
24
	}
25
 
26
 
27
	function getRessource(){
28
 
29
			$DB=$this->connectDB($this->config,'database_cel');
30
 
31
 
32
			$query="SELECT id_location, identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, date_observation," .
33
		           " lieudit, station, milieu, commentaire, transmission  FROM cel_inventory ".
34
					"where id_location!='000null' and transmission=1 and num_taxon!=0 order by round(id_location), nom_ret";
35
 
36
   		    $res =& $DB->query($query);
37
 
38
	        if (DB::isError($res)) {
39
    	        die($res->getMessage());
40
        	}
41
 
42
        	// Creating a workbook
43
			$workbook = new Spreadsheet_Excel_Writer();
44
 
45
 
46
			// Creating a worksheet
47
			$worksheet = $workbook->addWorksheet('Liste');
48
 
49
 
50
            $worksheet->write(0,0,'Departement');
51
            $worksheet->write(0,1,'Nom saisi');
52
            $worksheet->write(0,2,'Numero nomenclatural');
53
            $worksheet->write(0,3,'Nom retenu');
54
            $worksheet->write(0,4,'Numero nomenclatural nom retenu');
55
            $worksheet->write(0,5,'Numero taxonomique');
56
            $worksheet->write(0,6,'Famille');
57
            $worksheet->write(0,7,'Commune');
58
            $worksheet->write(0,8,'Date Observation');
59
            $worksheet->write(0,9,'Lieu dit');
60
            $worksheet->write(0,10,'Station');
61
            $worksheet->write(0,11,'Milieu');
62
            $worksheet->write(0,12,'Commentaire');
63
            $worksheet->write(0,13,'Observateur');
64
 
65
 
66
    		$DB2=$this->connectDB($this->config);
67
 
68
    		$i=1;
69
			while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
70
 
71
					$query2="SELECT ecd_ce_taxon FROM eflore_zg, eflore_chorologie_donnee WHERE ecd_ce_taxon =".$row['num_taxon']." and ezg_code=".$row['id_location']." and ecd_ce_zone_geo=ezg_id_zone_geo and  ezg_id_projet_zg =ecd_ce_version_projet_zg and ecd_ce_version_projet_taxon=25";
72
 
73
					$res2 =& $DB2->query($query2);
74
 
75
 
76
			        if (DB::isError($res2)) {
77
    		        	die($res2->getMessage());
78
        			}
79
 
80
					if ($res2->numRows() == 0) {
81
 
82
					 	// Denullifiage
83
    					foreach($row as $k=>$v) {
84
    						if (($v=="null") || ($v=="000null")) {
85
    							$row[$k]="";
86
    						}
87
    						else {
88
    							$row[$k]=utf8_decode($v);
89
    						}
90
    					}
91
 
92
    					if ($row['date_observation']!="0000-00-00 00:00:00") {
93
    	                	list($year,$month,$day)= split ('-',$row['date_observation']);
94
    	    	            list($day)= split (' ',$day);
95
    		                $row['date_observation']=$day."/".$month."/".$year;
96
    	    	    	}
97
    	        		else {
98
    	            	    $row['date_observation']="00/00/0000";
99
    		        	}
100
 
101
    					$worksheet->write($i,0,$row['id_location']);
102
    					$worksheet->write($i,1,$row['nom_sel']);
103
		                $worksheet->write($i,2,$row['num_nom_sel']);
104
        		        $worksheet->write($i,3,$row['nom_ret']);
105
		                $worksheet->write($i,4,$row['num_nom_ret']);
106
        		        $worksheet->write($i,5,$row['num_taxon']);
107
                		$worksheet->write($i,6,$row['famille']);
108
		                $worksheet->write($i,7,$row['location']);
109
                		$worksheet->write($i,8,$row['date_observation']);
110
		                $worksheet->write($i,9,$row['lieudit']);
111
        		        $worksheet->write($i,10,$row['station']);
112
        		        $worksheet->write($i,11,$row['milieu']);
113
                		$worksheet->write($i,12,$row['commentaire']);
114
                		$worksheet->write($i,13,$row['identifiant']);
115
 
116
                		$i++;
117
					}
118
 
119
 
120
			}
121
 
122
 
123
			// sending HTTP headers
124
			$workbook->send('liste.xls');
125
			$workbook->close();
126
 
127
			exit();
128
 
129
 
130
	}
131
 
132
 
133
}
134
 
135
/* +--Fin du code ---------------------------------------------------------------------------------------+
136
* $Log$
137
* Revision 1.1  2008-11-13 11:29:12  ddelon
138
* Reecriture gwt-ext
139
*
140
* Revision 1.2  2008-01-30 08:57:28  ddelon
141
* fin mise en place mygwt
142
*
143
* Revision 1.1  2007-06-06 13:31:16  ddelon
144
* v0.09
145
*
146
* Revision 1.3  2007-05-22 12:54:09  ddelon
147
* Securisation acces utilisateur
148
*
149
*
150
*
151
*/
152
 
153
?>