Subversion Repositories eFlore/Applications.cel

Rev

Rev 624 | Rev 984 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
416 aurelien 1
<?php
907 aurelien 2
/**
3
* PHP Version 5
4
*
5
* @category  PHP
6
* @package   jrest
7
* @author    David Delon <david@tela-botania.org>
8
* @author    Aurélien Peronnet <aurelien@tela-botania.org>
9
* @copyright 2010 Tela-Botanica
10
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
* @version   SVN: <svn_id>
12
* @link      /doc/jrest/
13
*/
416 aurelien 14
 
907 aurelien 15
/**
16
* in:utf8
17
* out:iso8859
18
*
19
* Export vers feuille de calcul d'une selection de releves
20
*
21
*/
22
class InventoryExport extends Cel  {
416 aurelien 23
 
907 aurelien 24
	private $extendSpreadsheetProductor;
416 aurelien 25
 
26
	function InventoryExport($config) {
27
 
907 aurelien 28
		parent::__construct($config);
416 aurelien 29
 
30
		$this->extendSpreadsheetProductor = new SpreadsheetProductor();
31
		$this->extendSpreadsheetProductor->initSpreadsheet();
32
	}
33
 
34
	function getElement($uid){
35
 
36
		   // Controle detournement utilisateur
37
		    session_start();
624 aurelien 38
		 	$this->controleUtilisateur($uid[0]);
416 aurelien 39
 
907 aurelien 40
			$criteres = array();
41
 
42
			$chercheur_observations = new RechercheObservation($this->config);
416 aurelien 43
 
44
			if(isset($uid[1]))
45
			{
907 aurelien 46
				$criteres = $chercheur_observations->parserRequeteCriteres($uid[1]);
416 aurelien 47
			}
48
 
49
    	    // Creating a workbook
50
			$workbook = new Spreadsheet_Excel_Writer();
51
 
540 david 52
			$workbook->send('liste.xls');
53
 
416 aurelien 54
			// Creating a worksheet
55
			$worksheet = $workbook->addWorksheet('Liste');
624 aurelien 56
 
57
            $worksheet->write(0,0,'Espece');
416 aurelien 58
            $worksheet->write(0,1,'Numero nomenclatural');
59
            $worksheet->write(0,2,'Nom retenu');
60
            $worksheet->write(0,3,'Numero nomenclatural nom retenu');
61
            $worksheet->write(0,4,'Numero taxonomique');
62
            $worksheet->write(0,5,'Famille');
63
            $worksheet->write(0,6,'Commune');
64
            $worksheet->write(0,7,'Identifiant Commune');
624 aurelien 65
            $worksheet->write(0,8,'Date');
66
            $worksheet->write(0,9,'Lieu-dit');
416 aurelien 67
            $worksheet->write(0,10,'Station');
68
            $worksheet->write(0,11,'Milieu');
624 aurelien 69
            $worksheet->write(0,12,'Notes');
70
            $worksheet->write(0,13,'Latitude');
71
            $worksheet->write(0,14,'Longitude');
416 aurelien 72
            $worksheet->write(0,15,'Referentiel Geographique');
907 aurelien 73
 
74
            $numero_page = isset($criteres['numero_page']) ? $criteres['numero_page'] : 0;
75
            $limite = isset($criteres['limite']) ? $criteres['limite'] : 50;
416 aurelien 76
 
907 aurelien 77
			$observations = $chercheur_observations->rechercherObservations($uid[0], $criteres, $numero_page, $limite);
416 aurelien 78
 
79
			$i=1;
907 aurelien 80
			foreach ($observations as $obs) {
416 aurelien 81
 
907 aurelien 82
				$obs = $this->denullifierTableauValeurCel(&$obs);
416 aurelien 83
 
907 aurelien 84
			  	if ($obs['date_observation'] != "0000-00-00 00:00:00") {
85
	                $obs['date_observation'] = $this->formaterDate($obs['date_observation']);
416 aurelien 86
	        	}
87
	        	else {
907 aurelien 88
	                $obs['date_observation']="00/00/0000";
416 aurelien 89
	        	}
90
 
907 aurelien 91
                $worksheet->write($i,0,$obs['nom_sel']);
92
                $worksheet->write($i,1,$obs['nom_sel_nn']);
93
                $worksheet->write($i,2,$obs['nom_ret']);
94
                $worksheet->write($i,3,$obs['nom_ret_nn']);
95
                $worksheet->write($i,4,$obs['nt']);
96
                $worksheet->write($i,5,$obs['famille']);
97
                $worksheet->write($i,6,$obs['zone_geo']);
98
                $worksheet->write($i,7,$this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']));
99
                $worksheet->write($i,8,$obs['date_observation']);
100
                $worksheet->write($i,9,$obs['lieudit']);
101
                $worksheet->write($i,10,$obs['station']);
102
                $worksheet->write($i,11,$obs['milieu']);
103
                $worksheet->write($i,12,$obs['commentaire']);
104
                $worksheet->write($i,13,$obs['latitude']);
105
                $worksheet->write($i,14,$obs['longitude']);
106
                $worksheet->write($i,15,$obs['geodatum']);
416 aurelien 107
                $i++;
108
    	    }
109
 
110
			$workbook->close();
111
 
112
			exit();
113
	}
114
}
115
/* +--Fin du code ---------------------------------------------------------------------------------------+
116
* $Log$
117
* Revision 1.7  2008-11-13 11:29:12  ddelon
118
* Reecriture gwt-ext
119
*
120
* Revision 1.6  2008-01-30 08:57:28  ddelon
121
* fin mise en place mygwt
122
*
123
* Revision 1.5  2007-06-06 13:31:16  ddelon
124
* v0.09
125
*
126
* Revision 1.4  2007-05-22 12:54:09  ddelon
127
* Securisation acces utilisateur
128
*/
907 aurelien 129
?>