Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | 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();
1609 raphael 50
		$workbook->setVersion(8);
904 aurelien 51
		// Creating a worksheet
52
		$worksheet = $workbook->addWorksheet('Liste');
1609 raphael 53
		$worksheet->setInputEncoding('utf-8');
904 aurelien 54
 
55
        $worksheet->write(0,0,'Departement');
56
        $worksheet->write(0,1,'Nom saisi');
57
        $worksheet->write(0,2,'Numero nomenclatural');
58
        $worksheet->write(0,3,'Nom retenu');
59
        $worksheet->write(0,4,'Numero nomenclatural nom retenu');
60
        $worksheet->write(0,5,'Numero taxonomique');
61
        $worksheet->write(0,6,'Famille');
62
        $worksheet->write(0,7,'Commune');
63
        $worksheet->write(0,8,'Date Observation');
64
        $worksheet->write(0,9,'Lieu dit');
65
        $worksheet->write(0,10,'Station');
66
        $worksheet->write(0,11,'Milieu');
67
        $worksheet->write(0,12,'Commentaire');
68
        $worksheet->write(0,13,'Observateur');
69
 
70
		$i=1;
416 aurelien 71
 
904 aurelien 72
		$observations = array();
73
		$chercheur_infos_taxon = null;
74
		if (is_array($resultat_obs)) {
75
			$observations = &$resultat_obs;
1425 aurelien 76
			$chercheur_infos_taxon = new RechercheInfosTaxonBeta($this->config);
904 aurelien 77
		}
78
 
79
		foreach ($observations as $obs) {
416 aurelien 80
 
904 aurelien 81
			$code_departement = $this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']);
82
			$taxon_deja_vu = $chercheur_infos_taxon->taxonEstPresentDansDepartement($obs['nt'], $code_departement);
83
 
84
			if (!$taxon_deja_vu) {
85
			 	// Denullifiage
86
				foreach($obs as $k=>$v) {
87
					if (($v=="null") || ($v=="000null")) {
88
						$obs[$k]="";
89
					}
90
					else {
91
						$obs[$k]=utf8_decode($v);
92
					}
93
				}
416 aurelien 94
 
904 aurelien 95
				if ($obs['date_observation']!="0000-00-00 00:00:00") {
996 aurelien 96
                	list($year,$month,$day)= explode('-',$obs['date_observation']);
97
    	            list($day)= explode(' ',$day);
904 aurelien 98
	                $obs['date_observation']=$day."/".$month."/".$year;
99
    	    	}
100
        		else {
101
            	    $obs['date_observation']="00/00/0000";
102
	        	}
416 aurelien 103
 
904 aurelien 104
				$worksheet->write($i,0,$code_departement);
105
				$worksheet->write($i,1,$obs['nom_sel']);
106
                $worksheet->write($i,2,$obs['nom_sel_nn']);
107
		        $worksheet->write($i,3,$obs['nom_ret']);
108
                $worksheet->write($i,4,$obs['nom_ret_nn']);
109
		        $worksheet->write($i,5,$obs['nt']);
110
        		$worksheet->write($i,6,$obs['famille']);
111
                $worksheet->write($i,7,$obs['zone_geo']);
112
        		$worksheet->write($i,8,$obs['date_observation']);
113
                $worksheet->write($i,9,$obs['lieudit']);
114
		        $worksheet->write($i,10,$obs['station']);
115
		        $worksheet->write($i,11,$obs['milieu']);
116
        		$worksheet->write($i,12,$obs['commentaire']);
117
        		$worksheet->write($i,13,$obs['courriel_utilisateur']);
118
 
119
        		$i++;
120
			}
121
		}
122
 
123
		// sending HTTP headers
124
		$workbook->send('liste.xls');
125
		$workbook->close();
416 aurelien 126
 
904 aurelien 127
		exit();
128
	}
416 aurelien 129
}
130
 
131
/* +--Fin du code ---------------------------------------------------------------------------------------+
132
* $Log$
133
* Revision 1.1  2008-11-13 11:29:12  ddelon
134
* Reecriture gwt-ext
135
*
136
* Revision 1.2  2008-01-30 08:57:28  ddelon
137
* fin mise en place mygwt
138
*
139
* Revision 1.1  2007-06-06 13:31:16  ddelon
140
* v0.09
141
*
142
* Revision 1.3  2007-05-22 12:54:09  ddelon
143
* Securisation acces utilisateur
144
*
145
*
146
*
147
*/
904 aurelien 148
?>