Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 905 Rev 996
1
<?php
1
<?php
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
3
 
3
 
4
/**
4
/**
5
* PHP Version 5
5
* PHP Version 5
6
*
6
*
7
* @category  PHP
7
* @category  PHP
8
* @package   jrest
8
* @package   jrest
9
* @author    David Delon <delon@tela-botanica.org>
9
* @author    David Delon <delon@tela-botanica.org>
10
* @copyright 2010 Tela-Botanica
10
* @copyright 2010 Tela-Botanica
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
* @version   SVN: <svn_id>
12
* @version   SVN: <svn_id>
13
* @link      /doc/
13
* @link      /doc/
14
*/
14
*/
15
 
15
 
16
/**
16
/**
17
* 
17
* 
18
* in=utf8
18
* in=utf8
19
* out=iso3859
19
* out=iso3859
20
* 
20
* 
21
* Liste des Nouvelles observations par departement
21
* Liste des Nouvelles observations par departement
22
* A voir avec David mais ne devrait plus être utilisé 
22
* A voir avec David mais ne devrait plus être utilisé 
23
* ou fait autrement
23
* ou fait autrement
24
* 
24
* 
25
*/
25
*/
26
class InventoryByDept extends Cel {
26
class InventoryByDept extends Cel {
27
 
27
 
28
	var $extendSpreadsheetProductor;
28
	var $extendSpreadsheetProductor;
29
	
29
	
30
	function InventoryByDept($config) {
30
	function InventoryByDept($config) {
31
 
31
 
32
		parent::__construct($config);
32
		parent::__construct($config);
33
		
33
		
34
		// Pas d'heritage multiple en php :(
34
		// Pas d'heritage multiple en php :(
35
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
35
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
36
		$this->extendSpreadsheetProductor->initSpreadsheet();   
36
		$this->extendSpreadsheetProductor->initSpreadsheet();   
37
	}
37
	}
38
	
38
	
39
	//TODO : faire une fonction qui prend en paramètre un departement
39
	//TODO : faire une fonction qui prend en paramètre un departement
40
	function getRessource(){
40
	function getRessource(){
41
		
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," .
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 ". 
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";
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
 
45
 
46
		$resultat_obs = $this->executerRequete($requete_obs);
46
		$resultat_obs = $this->executerRequete($requete_obs);
47
        	
47
        	
48
    	// Creating a workbook
48
    	// Creating a workbook
49
		$workbook = new Spreadsheet_Excel_Writer();
49
		$workbook = new Spreadsheet_Excel_Writer();
50
		// Creating a worksheet
50
		// Creating a worksheet
51
		$worksheet = $workbook->addWorksheet('Liste');
51
		$worksheet = $workbook->addWorksheet('Liste');
52
 
52
 
53
        $worksheet->write(0,0,'Departement');
53
        $worksheet->write(0,0,'Departement');
54
        $worksheet->write(0,1,'Nom saisi');
54
        $worksheet->write(0,1,'Nom saisi');
55
        $worksheet->write(0,2,'Numero nomenclatural');
55
        $worksheet->write(0,2,'Numero nomenclatural');
56
        $worksheet->write(0,3,'Nom retenu');
56
        $worksheet->write(0,3,'Nom retenu');
57
        $worksheet->write(0,4,'Numero nomenclatural nom retenu');
57
        $worksheet->write(0,4,'Numero nomenclatural nom retenu');
58
        $worksheet->write(0,5,'Numero taxonomique');
58
        $worksheet->write(0,5,'Numero taxonomique');
59
        $worksheet->write(0,6,'Famille');
59
        $worksheet->write(0,6,'Famille');
60
        $worksheet->write(0,7,'Commune');
60
        $worksheet->write(0,7,'Commune');
61
        $worksheet->write(0,8,'Date Observation');
61
        $worksheet->write(0,8,'Date Observation');
62
        $worksheet->write(0,9,'Lieu dit');
62
        $worksheet->write(0,9,'Lieu dit');
63
        $worksheet->write(0,10,'Station');
63
        $worksheet->write(0,10,'Station');
64
        $worksheet->write(0,11,'Milieu');
64
        $worksheet->write(0,11,'Milieu');
65
        $worksheet->write(0,12,'Commentaire');
65
        $worksheet->write(0,12,'Commentaire');
66
        $worksheet->write(0,13,'Observateur');
66
        $worksheet->write(0,13,'Observateur');
67
 
67
 
68
		$i=1;
68
		$i=1;
69
		
69
		
70
		$observations = array();
70
		$observations = array();
71
		$chercheur_infos_taxon = null;
71
		$chercheur_infos_taxon = null;
72
		if (is_array($resultat_obs)) {
72
		if (is_array($resultat_obs)) {
73
			$observations = &$resultat_obs;
73
			$observations = &$resultat_obs;
74
			$chercheur_infos_taxon = new RechercheInfosTaxon($this->config);
74
			$chercheur_infos_taxon = new RechercheInfosTaxon($this->config);
75
		}
75
		}
76
		
76
		
77
		foreach ($observations as $obs) {
77
		foreach ($observations as $obs) {
78
 
78
 
79
			$code_departement = $this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']);
79
			$code_departement = $this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']);
80
			$taxon_deja_vu = $chercheur_infos_taxon->taxonEstPresentDansDepartement($obs['nt'], $code_departement);
80
			$taxon_deja_vu = $chercheur_infos_taxon->taxonEstPresentDansDepartement($obs['nt'], $code_departement);
81
			
81
			
82
			if (!$taxon_deja_vu) {								
82
			if (!$taxon_deja_vu) {								
83
			 	// Denullifiage   
83
			 	// Denullifiage   
84
				foreach($obs as $k=>$v) {
84
				foreach($obs as $k=>$v) {
85
					if (($v=="null") || ($v=="000null")) {
85
					if (($v=="null") || ($v=="000null")) {
86
						$obs[$k]="";
86
						$obs[$k]="";
87
					}
87
					}
88
					else {
88
					else {
89
						$obs[$k]=utf8_decode($v);
89
						$obs[$k]=utf8_decode($v);
90
					}
90
					}
91
				} 
91
				} 
92
 
92
 
93
				if ($obs['date_observation']!="0000-00-00 00:00:00") {
93
				if ($obs['date_observation']!="0000-00-00 00:00:00") {
94
                	list($year,$month,$day)= split ('-',$obs['date_observation']);
94
                	list($year,$month,$day)= explode('-',$obs['date_observation']);
95
    	            list($day)= split (' ',$day);
95
    	            list($day)= explode(' ',$day);
96
	                $obs['date_observation']=$day."/".$month."/".$year;
96
	                $obs['date_observation']=$day."/".$month."/".$year;
97
    	    	}
97
    	    	}
98
        		else {
98
        		else {
99
            	    $obs['date_observation']="00/00/0000";
99
            	    $obs['date_observation']="00/00/0000";
100
	        	}
100
	        	}
101
 
101
 
102
				$worksheet->write($i,0,$code_departement);
102
				$worksheet->write($i,0,$code_departement);
103
				$worksheet->write($i,1,$obs['nom_sel']);
103
				$worksheet->write($i,1,$obs['nom_sel']);
104
                $worksheet->write($i,2,$obs['nom_sel_nn']);
104
                $worksheet->write($i,2,$obs['nom_sel_nn']);
105
		        $worksheet->write($i,3,$obs['nom_ret']);
105
		        $worksheet->write($i,3,$obs['nom_ret']);
106
                $worksheet->write($i,4,$obs['nom_ret_nn']);
106
                $worksheet->write($i,4,$obs['nom_ret_nn']);
107
		        $worksheet->write($i,5,$obs['nt']);
107
		        $worksheet->write($i,5,$obs['nt']);
108
        		$worksheet->write($i,6,$obs['famille']);
108
        		$worksheet->write($i,6,$obs['famille']);
109
                $worksheet->write($i,7,$obs['zone_geo']);
109
                $worksheet->write($i,7,$obs['zone_geo']);
110
        		$worksheet->write($i,8,$obs['date_observation']);
110
        		$worksheet->write($i,8,$obs['date_observation']);
111
                $worksheet->write($i,9,$obs['lieudit']);
111
                $worksheet->write($i,9,$obs['lieudit']);
112
		        $worksheet->write($i,10,$obs['station']);
112
		        $worksheet->write($i,10,$obs['station']);
113
		        $worksheet->write($i,11,$obs['milieu']);
113
		        $worksheet->write($i,11,$obs['milieu']);
114
        		$worksheet->write($i,12,$obs['commentaire']);
114
        		$worksheet->write($i,12,$obs['commentaire']);
115
        		$worksheet->write($i,13,$obs['courriel_utilisateur']);
115
        		$worksheet->write($i,13,$obs['courriel_utilisateur']);
116
        		
116
        		
117
        		$i++;		
117
        		$i++;		
118
			}			
118
			}			
119
		}
119
		}
120
				
120
				
121
		// sending HTTP headers
121
		// sending HTTP headers
122
		$workbook->send('liste.xls');
122
		$workbook->send('liste.xls');
123
		$workbook->close();
123
		$workbook->close();
124
		
124
		
125
		exit();					
125
		exit();					
126
	}	
126
	}	
127
}
127
}
128
 
128
 
129
/* +--Fin du code ---------------------------------------------------------------------------------------+
129
/* +--Fin du code ---------------------------------------------------------------------------------------+
130
* $Log$
130
* $Log$
131
* Revision 1.1  2008-11-13 11:29:12  ddelon
131
* Revision 1.1  2008-11-13 11:29:12  ddelon
132
* Reecriture gwt-ext
132
* Reecriture gwt-ext
133
*
133
*
134
* Revision 1.2  2008-01-30 08:57:28  ddelon
134
* Revision 1.2  2008-01-30 08:57:28  ddelon
135
* fin mise en place mygwt
135
* fin mise en place mygwt
136
*
136
*
137
* Revision 1.1  2007-06-06 13:31:16  ddelon
137
* Revision 1.1  2007-06-06 13:31:16  ddelon
138
* v0.09
138
* v0.09
139
*
139
*
140
* Revision 1.3  2007-05-22 12:54:09  ddelon
140
* Revision 1.3  2007-05-22 12:54:09  ddelon
141
* Securisation acces utilisateur
141
* Securisation acces utilisateur
142
*
142
*
143
*
143
*
144
* 
144
* 
145
*/
145
*/
146
?>
146
?>