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