Subversion Repositories eFlore/Applications.cel

Rev

Rev 1425 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
416 aurelien 1
<?php
904 aurelien 2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
416 aurelien 3
 
904 aurelien 4
/**
5
* PHP Version 5
6
*
7
* @category  PHP
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>
13
* @link      /doc/
14
*/
416 aurelien 15
 
904 aurelien 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
*
25
*/
26
class InventoryByDept extends Cel {
416 aurelien 27
 
28
	var $extendSpreadsheetProductor;
29
 
30
	function InventoryByDept($config) {
31
 
904 aurelien 32
		parent::__construct($config);
33
 
416 aurelien 34
		// Pas d'heritage multiple en php :(
35
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
904 aurelien 36
		$this->extendSpreadsheetProductor->initSpreadsheet();
416 aurelien 37
	}
38
 
905 aurelien 39
	//TODO : faire une fonction qui prend en paramètre un departement
416 aurelien 40
	function getRessource(){
41
 
904 aurelien 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);
416 aurelien 47
 
904 aurelien 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');
58
        $worksheet->write(0,5,'Numero taxonomique');
59
        $worksheet->write(0,6,'Famille');
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');
64
        $worksheet->write(0,11,'Milieu');
65
        $worksheet->write(0,12,'Commentaire');
66
        $worksheet->write(0,13,'Observateur');
67
 
68
		$i=1;
416 aurelien 69
 
904 aurelien 70
		$observations = array();
71
		$chercheur_infos_taxon = null;
72
		if (is_array($resultat_obs)) {
73
			$observations = &$resultat_obs;
1425 aurelien 74
			$chercheur_infos_taxon = new RechercheInfosTaxonBeta($this->config);
904 aurelien 75
		}
76
 
77
		foreach ($observations as $obs) {
416 aurelien 78
 
904 aurelien 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 {
89
						$obs[$k]=utf8_decode($v);
90
					}
91
				}
416 aurelien 92
 
904 aurelien 93
				if ($obs['date_observation']!="0000-00-00 00:00:00") {
996 aurelien 94
                	list($year,$month,$day)= explode('-',$obs['date_observation']);
95
    	            list($day)= explode(' ',$day);
904 aurelien 96
	                $obs['date_observation']=$day."/".$month."/".$year;
97
    	    	}
98
        		else {
99
            	    $obs['date_observation']="00/00/0000";
100
	        	}
416 aurelien 101
 
904 aurelien 102
				$worksheet->write($i,0,$code_departement);
103
				$worksheet->write($i,1,$obs['nom_sel']);
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']);
107
		        $worksheet->write($i,5,$obs['nt']);
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']);
112
		        $worksheet->write($i,10,$obs['station']);
113
		        $worksheet->write($i,11,$obs['milieu']);
114
        		$worksheet->write($i,12,$obs['commentaire']);
115
        		$worksheet->write($i,13,$obs['courriel_utilisateur']);
116
 
117
        		$i++;
118
			}
119
		}
120
 
121
		// sending HTTP headers
122
		$workbook->send('liste.xls');
123
		$workbook->close();
416 aurelien 124
 
904 aurelien 125
		exit();
126
	}
416 aurelien 127
}
128
 
129
/* +--Fin du code ---------------------------------------------------------------------------------------+
130
* $Log$
131
* Revision 1.1  2008-11-13 11:29:12  ddelon
132
* Reecriture gwt-ext
133
*
134
* Revision 1.2  2008-01-30 08:57:28  ddelon
135
* fin mise en place mygwt
136
*
137
* Revision 1.1  2007-06-06 13:31:16  ddelon
138
* v0.09
139
*
140
* Revision 1.3  2007-05-22 12:54:09  ddelon
141
* Securisation acces utilisateur
142
*
143
*
144
*
145
*/
904 aurelien 146
?>