Subversion Repositories eFlore/Applications.cel

Rev

Rev 416 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 416 Rev 904
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
Line 2... Line 3...
2
 
3
 
3
// In utf8
4
/**
4
// Out iso3859
5
* PHP Version 5
-
 
6
*
-
 
7
* @category  PHP
5
 
8
* @package   jrest
-
 
9
* @author    David Delon <delon@tela-botanica.org>
-
 
10
* @copyright 2010 Tela-Botanica
-
 
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
-
 
12
* @version   SVN: <svn_id>
6
// Liste des Nouvelles observations par departement
13
* @link      /doc/
7
 
-
 
8
 
-
 
Line -... Line 14...
-
 
14
*/
-
 
15
 
-
 
16
/**
-
 
17
* 
-
 
18
* in=utf8
-
 
19
* out=iso3859
-
 
20
* 
-
 
21
* Liste des Nouvelles observations par departement
-
 
22
* A voir avec David mais ne devrait plus ĂȘtre utilisĂ© 
-
 
23
* ou fait autrement
-
 
24
* 
Line 9... Line -...
9
Class InventoryByDept extends DBAccessor {
-
 
10
 
25
*/
Line 11... Line -...
11
 
-
 
12
	var $config;
26
class InventoryByDept extends Cel {
Line 13... Line 27...
13
	var $extendSpreadsheetProductor;
27
 
14
	
-
 
Line -... Line 28...
-
 
28
	var $extendSpreadsheetProductor;
15
	
29
	
16
	function InventoryByDept($config) {
30
	function InventoryByDept($config) {
17
 
-
 
18
		$this->config=$config;
31
 
Line 19... Line -...
19
		// Pas d'heritage multiple en php :(
-
 
-
 
32
		parent::__construct($config);
20
		
33
		
Line 21... Line -...
21
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
-
 
22
		$this->extendSpreadsheetProductor->initSpreadsheet();
-
 
23
	     
-
 
24
	}
34
		// Pas d'heritage multiple en php :(
25
	
35
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
26
 
36
		$this->extendSpreadsheetProductor->initSpreadsheet();   
27
	function getRessource(){
37
	}
28
		
38
	
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," .
-
 
Line 33... Line 39...
33
		           " lieudit, station, milieu, commentaire, transmission  FROM cel_inventory ". 
39
	//TODO : fonction qui prend en compte un departement
34
					"where id_location!='000null' and transmission=1 and num_taxon!=0 order by round(id_location), nom_ret";
40
	function getRessource(){
-
 
41
		
-
 
42
		$requete_obs = "SELECT ce_zone_geo, ce_utilisateur, courriel_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation," .
-
 
43
		    " lieudit, station, milieu, commentaire, transmission  FROM cel_obs ". 
-
 
44
			"WHERE ce_zone_geo != '000null' AND ce_zone_geo != '' AND transmission = 1 AND nt!=0 ORDER BY ce_zone_geo, nom_ret LIMIT 50";
-
 
45
 
-
 
46
		$resultat_obs = $this->executerRequete($requete_obs);
-
 
47
        	
-
 
48
    	// Creating a workbook
-
 
49
		$workbook = new Spreadsheet_Excel_Writer();
-
 
50
		// Creating a worksheet
-
 
51
		$worksheet = $workbook->addWorksheet('Liste');
-
 
52
 
-
 
53
        $worksheet->write(0,0,'Departement');
-
 
54
        $worksheet->write(0,1,'Nom saisi');
-
 
55
        $worksheet->write(0,2,'Numero nomenclatural');
-
 
56
        $worksheet->write(0,3,'Nom retenu');
-
 
57
        $worksheet->write(0,4,'Numero nomenclatural nom retenu');
35
					
58
        $worksheet->write(0,5,'Numero taxonomique');
-
 
59
        $worksheet->write(0,6,'Famille');
Line 36... Line 60...
36
   		    $res =& $DB->query($query);
60
        $worksheet->write(0,7,'Commune');
-
 
61
        $worksheet->write(0,8,'Date Observation');
-
 
62
        $worksheet->write(0,9,'Lieu dit');
-
 
63
        $worksheet->write(0,10,'Station');
37
    
64
        $worksheet->write(0,11,'Milieu');
-
 
65
        $worksheet->write(0,12,'Commentaire');
38
	        if (DB::isError($res)) {
66
        $worksheet->write(0,13,'Observateur');
-
 
67
 
Line 39... Line -...
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');
68
		$i=1;
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   
69
		
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']);
-
 
Line -... Line 70...
-
 
70
		$observations = array();
-
 
71
		$chercheur_infos_taxon = null;
-
 
72
		if (is_array($resultat_obs)) {
-
 
73
			$observations = &$resultat_obs;
-
 
74
			$chercheur_infos_taxon = new RechercheInfosTaxon($this->config);
-
 
75
		}
115
                		
76
		
-
 
77
		foreach ($observations as $obs) {
-
 
78
 
-
 
79
			$code_departement = $this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']);
-
 
80
			$taxon_deja_vu = $chercheur_infos_taxon->taxonEstPresentDansDepartement($obs['nt'], $code_departement);
-
 
81
			
-
 
82
			if (!$taxon_deja_vu) {								
-
 
83
			 	// Denullifiage   
-
 
84
				foreach($obs as $k=>$v) {
-
 
85
					if (($v=="null") || ($v=="000null")) {
-
 
86
						$obs[$k]="";
-
 
87
					}
-
 
88
					else {
116
                		$i++;		
89
						$obs[$k]=utf8_decode($v);
-
 
90
					}
-
 
91
				} 
-
 
92
 
-
 
93
				if ($obs['date_observation']!="0000-00-00 00:00:00") {
-
 
94
                	list($year,$month,$day)= split ('-',$obs['date_observation']);
-
 
95
    	            list($day)= split (' ',$day);
-
 
96
	                $obs['date_observation']=$day."/".$month."/".$year;
-
 
97
    	    	}
-
 
98
        		else {
-
 
99
            	    $obs['date_observation']="00/00/0000";
-
 
100
	        	}
-
 
101
 
-
 
102
				$worksheet->write($i,0,$code_departement);
-
 
103
				$worksheet->write($i,1,$obs['nom_sel']);
117
					}
104
                $worksheet->write($i,2,$obs['nom_sel_nn']);
-
 
105
		        $worksheet->write($i,3,$obs['nom_ret']);
-
 
106
                $worksheet->write($i,4,$obs['nom_ret_nn']);
118
					
107
		        $worksheet->write($i,5,$obs['nt']);
119
					
108
        		$worksheet->write($i,6,$obs['famille']);
-
 
109
                $worksheet->write($i,7,$obs['zone_geo']);
-
 
110
        		$worksheet->write($i,8,$obs['date_observation']);
-
 
111
                $worksheet->write($i,9,$obs['lieudit']);
Line -... Line 112...
-
 
112
		        $worksheet->write($i,10,$obs['station']);
-
 
113
		        $worksheet->write($i,11,$obs['milieu']);
120
			}
114
        		$worksheet->write($i,12,$obs['commentaire']);
Line 121... Line 115...
121
			
115
        		$worksheet->write($i,13,$obs['courriel_utilisateur']);
122
			
116
        		
123
			// sending HTTP headers
117
        		$i++;		
Line 147... Line 141...
147
* Securisation acces utilisateur
141
* Securisation acces utilisateur
148
*
142
*
149
*
143
*
150
* 
144
* 
151
*/
145
*/
152
 
-
 
153
?>
146
?>
154
147