Subversion Repositories eFlore/Applications.cel

Rev

Rev 970 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 970 Rev 985
1
<?php
1
<?php
2
 
-
 
3
 
-
 
-
 
2
//TODO migrer cette classe lorsqu'elle deviendra utile à nouveau
4
Class InventoryImageExport extends DBAccessor {
3
Class InventoryImageExport extends DBAccessor {
5
 
4
 
6
	private $extendSpreadsheetProductor;
5
	private $extendSpreadsheetProductor;
7
 
6
 
8
	private $archive;
7
	private $archive;
9
	private $workbook;
8
	private $workbook;
10
	private $worksheet;
9
	private $worksheet;
11
	private $chemin_export_liste;
10
	private $chemin_export_liste;
12
 
11
 
13
    function InventoryImageExport($config) {
12
    function InventoryImageExport($config) {
14
 
13
 
15
    	parent::__construct($config);
14
    	parent::__construct($config);
16
 
15
 
17
        $this->config=$config;
16
        $this->config=$config;
18
        $this->extendSpreadsheetProductor = new SpreadsheetProductor();
17
        $this->extendSpreadsheetProductor = new SpreadsheetProductor();
19
		$this->extendSpreadsheetProductor->initSpreadsheet();
18
		$this->extendSpreadsheetProductor->initSpreadsheet();
20
    }
19
    }
21
 
20
 
22
    function getElement($uid){
21
    function getElement($uid){
23
    	
22
    	
24
      	$this->authentifier();
23
      	$this->authentifier();
25
 
24
 
26
      	$tableau = array();
25
      	$tableau = array();
27
        $tag = $uid[0];
26
        $tag = $uid[0];
28
 
27
 
29
        $limite = 0;
28
        $limite = 0;
30
        $pas = 0;
29
        $pas = 0;
31
 
30
 
32
        //ini_set('max_execution_time',120);
31
        //ini_set('max_execution_time',120);
33
 
32
 
34
        /*if(isset($uid[1]) && isset($uid[2])) {
33
        /*if(isset($uid[1]) && isset($uid[2])) {
35
			$limite = $uid[]
34
			$limite = $uid[]
36
        }*/
35
        }*/
37
 
36
 
38
       	$taille_archive_courante = 0;
37
       	$taille_archive_courante = 0;
39
		$index_archive_courante = 0;
38
		$index_archive_courante = 0;
40
		$taille_max_archive = $this->config['cel_db']['taille_max_archive'];
39
		$taille_max_archive = $this->config['cel_db']['taille_max_archive'];
41
		$liens_archives = array();
40
		$liens_archives = array();
42
 
41
 
43
        $DB=$this->connectDB($this->config,'cel_db');
42
        $DB=$this->connectDB($this->config,'cel_db');
44
 
43
 
45
        $query_id_id_img = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_images WHERE cmc_id_mot_cle_general = md5("'.$DB->escapeSimple($tag).'")' ;
44
        $query_id_id_img = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_images WHERE cmc_id_mot_cle_general = md5("'.$DB->escapeSimple($tag).'")' ;
46
 
45
 
47
        $res =& $DB->query($query_id_id_img);
46
        $res =& $DB->query($query_id_id_img);
48
 
47
 
49
        if (DB::isError($res)) {
48
        if (DB::isError($res)) {
50
			$this->logger("InventoryImageExport",'Erreur de requete '.$query_id_id_img);
49
			$this->logger("InventoryImageExport",'Erreur de requete '.$query_id_id_img);
51
            die($res->getMessage());
50
            die($res->getMessage());
52
        }
51
        }
53
 
52
 
54
 
53
 
55
        $query='SELECT * FROM cel_images';
54
        $query='SELECT * FROM cel_images';
56
 
55
 
57
        $premier_item = true ;
56
        $premier_item = true ;
58
        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
57
        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
59
 
58
 
60
        	$tableau['mots cles'] = array('utilisateur' => $row['cmc_id_proprietaire'], 'mot cle' => $row['cmc_id_mot_cle_utilisateur']);
59
        	$tableau['mots cles'] = array('utilisateur' => $row['cmc_id_proprietaire'], 'mot cle' => $row['cmc_id_mot_cle_utilisateur']);
61
 
60
 
62
            if($premier_item) {
61
            if($premier_item) {
63
                $query .= ' WHERE ';
62
                $query .= ' WHERE ';
64
                $premier_item = false ;
63
                $premier_item = false ;
65
            }
64
            }
66
            else{
65
            else{
67
                $query .= ' OR ';
66
                $query .= ' OR ';
68
            }
67
            }
69
 
68
 
70
            $query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ;
69
            $query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ;
71
        }
70
        }
72
 
71
 
73
        $query .= ' ORDER BY ci_meta_date_ajout' ;
72
        $query .= ' ORDER BY ci_meta_date_ajout' ;
74
 
73
 
75
        $res =& $DB->query($query);
74
        $res =& $DB->query($query);
76
 
75
 
77
        if (DB::isError($res)) {
76
        if (DB::isError($res)) {
78
            die($res->getMessage());
77
            die($res->getMessage());
79
        }
78
        }
80
 
79
 
81
        $this->logger('Requetes',$query);
80
        $this->logger('Requetes',$query);
82
 
81
 
83
        // création d'un objet 'zipfile'
82
        // création d'un objet 'zipfile'
84
		$this->archive = new zipfile();
83
		$this->archive = new zipfile();
85
 
84
 
86
		$i = 1;
85
		$i = 1;
87
 
86
 
88
		$this->initialiserWorkBook($index_archive_courante);
87
		$this->initialiserWorkBook($index_archive_courante);
89
 
88
 
90
        while ($image =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
89
        while ($image =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
91
 
90
 
92
           $image['ci_nom_original'] = htmlspecialchars($image['ci_nom_original']);
91
           $image['ci_nom_original'] = htmlspecialchars($image['ci_nom_original']);
93
           $image['ci_id_image'] = htmlspecialchars($image['ci_id_image']);
92
           $image['ci_id_image'] = htmlspecialchars($image['ci_id_image']);
94
           $image['ci_meta_date_ajout'] = htmlspecialchars($image['ci_meta_date_ajout']);
93
           $image['ci_meta_date_ajout'] = htmlspecialchars($image['ci_meta_date_ajout']);
95
           $image['ci_ce_utilisateur'] = htmlspecialchars($image['ci_ce_utilisateur']);
94
           $image['ci_ce_utilisateur'] = htmlspecialchars($image['ci_ce_utilisateur']);
96
           $image['ci_meta_user_comment'] = htmlspecialchars($image['ci_meta_user_comment']);
95
           $image['ci_meta_user_comment'] = htmlspecialchars($image['ci_meta_user_comment']);
97
           $image['ci_note_image'] = htmlspecialchars($image['ci_note_image']);
96
           $image['ci_note_image'] = htmlspecialchars($image['ci_note_image']);
98
 
97
 
99
           $id = $image['ci_id_image'];
98
           $id = $image['ci_id_image'];
100
 
99
 
101
           $tableau[$id]['image'] = $image;
100
           $tableau[$id]['image'] = $image;
102
                   
101
                   
103
           if($filename = $this->renvoyerCheminSurServeur($id,false)) {
102
           if($filename = $this->renvoyerCheminSurServeur($id,false)) {
104
 
103
 
105
				// appel de la classe
104
				// appel de la classe
106
			    // nom du fichier à ajouter dans l'archive
105
			    // nom du fichier à ajouter dans l'archive
107
			    // contenu du fichier
106
			    // contenu du fichier
108
			    $fp = fopen ($filename, 'r');
107
			    $fp = fopen ($filename, 'r');
109
			    $content = fread($fp, filesize($filename));
108
			    $content = fread($fp, filesize($filename));
110
			    fclose ($fp);
109
			    fclose ($fp);
111
 
110
 
112
			    // ajout du fichier dans cet objet
111
			    // ajout du fichier dans cet objet
113
			    if(preg_match('/\.(?:jpg|jpeg)$/i',$image['ci_nom_original'])) {
112
			    if(preg_match('/\.(?:jpg|jpeg)$/i',$image['ci_nom_original'])) {
114
			    	$nom_fichier_image = preg_replace('/\.(?:jpg|jpeg)$/i','_'.$id.'.jpg', $image['ci_nom_original']);
113
			    	$nom_fichier_image = preg_replace('/\.(?:jpg|jpeg)$/i','_'.$id.'.jpg', $image['ci_nom_original']);
115
			    } else {
114
			    } else {
116
			    	$nom_fichier_image = $image['ci_nom_original'].'_'.$id.'.jpg';
115
			    	$nom_fichier_image = $image['ci_nom_original'].'_'.$id.'.jpg';
117
			    }
116
			    }
118
			    
117
			    
119
			    $chemin_sur_serveur = $this->config['cel_db']['url_images'];
118
			    $chemin_sur_serveur = $this->config['cel_db']['url_images'];
120
			    
119
			    
121
			    $id = sprintf('%09s', $id) ;
120
			    $id = sprintf('%09s', $id) ;
122
            	$id = wordwrap($id, 3 , '_', true) ;
121
            	$id = wordwrap($id, 3 , '_', true) ;
123
			    $niveauDossier = split("_", $id) ;
122
			    $niveauDossier = split("_", $id) ;
124
 
123
 
125
	            $dossierNiveau1 = $niveauDossier[0] ;
124
	            $dossierNiveau1 = $niveauDossier[0] ;
126
	            $dossierNiveau2 = $niveauDossier[1] ;
125
	            $dossierNiveau2 = $niveauDossier[1] ;
127
	
126
	
128
	            $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
127
	            $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
129
	
128
	
130
	            $chemin_fichier = $chemin_sur_serveur_final.'/O/'.$id."_O.jpg" ;
129
	            $chemin_fichier = $chemin_sur_serveur_final.'/O/'.$id."_O.jpg" ;
131
			    
130
			    
132
			    $obs_liee['url_image_liee'] = $chemin_fichier;
131
			    $obs_liee['url_image_liee'] = $chemin_fichier;
133
 
132
 
134
			    $taille_fichier = filesize($filename);
133
			    $taille_fichier = filesize($filename);
135
 
134
 
136
            	$req_liaison = 'SELECT * FROM cel_inventory WHERE ordre IN (SELECT coi_ce_observation FROM cel_obs_images WHERE coi_ce_image = "'.$image['ci_id_image'].'") AND identifiant = "'.$image['ci_ce_utilisateur'].'"' ;
135
            	$req_liaison = 'SELECT * FROM cel_inventory WHERE ordre IN (SELECT coi_ce_observation FROM cel_obs_images WHERE coi_ce_image = "'.$image['ci_id_image'].'") AND identifiant = "'.$image['ci_ce_utilisateur'].'"' ;
137
            	$res_liaison =& $DB->query($req_liaison);
136
            	$res_liaison =& $DB->query($req_liaison);
138
 
137
 
139
	            if (DB::isError($res_liaison)) {
138
	            if (DB::isError($res_liaison)) {
140
	                die($res_liaison->getMessage());
139
	                die($res_liaison->getMessage());
141
	            }
140
	            }
142
 
141
 
143
	            if (DB::isError($res_liaison)) {
142
	            if (DB::isError($res_liaison)) {
144
	                die($res_liaison->getMessage());
143
	                die($res_liaison->getMessage());
145
	            }
144
	            }
146
 
145
 
147
	          while($obs_liee = & $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
146
	          while($obs_liee = & $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
148
 
147
 
149
          	  	$tableau[$id]['obs'] = $obs_liee;
148
          	  	$tableau[$id]['obs'] = $obs_liee;
150
          	  	$obs_liee['nom_image_liee'] = $nom_fichier_image;
149
          	  	$obs_liee['nom_image_liee'] = $nom_fichier_image;
151
          	  	$obs_liee['url_image_liee'] = $chemin_fichier;
150
          	  	$obs_liee['url_image_liee'] = $chemin_fichier;
152
 
151
 
153
			  	$this->ecrireLigneWorkBook($i,$obs_liee);
152
			  	$this->ecrireLigneWorkBook($i,$obs_liee);
154
 
153
 
155
		  		$i++;
154
		  		$i++;
156
	          }
155
	          }
157
 
156
 
158
	          //$this->archive->addfile($content, $nom_fichier_image);
157
	          //$this->archive->addfile($content, $nom_fichier_image);
159
			  //$taille_archive_courante += $taille_fichier;
158
			  //$taille_archive_courante += $taille_fichier;
160
 
159
 
161
	          if($taille_archive_courante <= $taille_max_archive) {
160
	          if($taille_archive_courante <= $taille_max_archive) {
162
 
161
 
163
 
162
 
164
				} else {
163
				} else {
165
 
164
 
166
					// fermeture du workbook
165
					// fermeture du workbook
167
					$this->workbook->close();
166
					$this->workbook->close();
168
					$i = 1;
167
					$i = 1;
169
 
168
 
170
					// ajout du fichier liste dans cet objet
169
					// ajout du fichier liste dans cet objet
171
					// contenu du fichier
170
					// contenu du fichier
172
				    $fp = fopen($this->chemin_export_liste, 'r');
171
				    $fp = fopen($this->chemin_export_liste, 'r');
173
				    $contenu = fread($fp, filesize($this->chemin_export_liste));
172
				    $contenu = fread($fp, filesize($this->chemin_export_liste));
174
				    fclose ($fp);
173
				    fclose ($fp);
175
 
174
 
176
					$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
175
					$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
177
					
176
					
178
					$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
177
					$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
179
					$index_archive_courante++;
178
					$index_archive_courante++;
180
					$taille_archive_courante = 0;
179
					$taille_archive_courante = 0;
181
 
180
 
182
					$this->archive = new zipfile();
181
					$this->archive = new zipfile();
183
					$this->initialiserWorkBook($index_archive_courante);
182
					$this->initialiserWorkBook($index_archive_courante);
184
				}
183
				}
185
	       }
184
	       }
186
 
185
 
187
      		//$this->verifierOuRelancerExecution();
186
      		//$this->verifierOuRelancerExecution();
188
      		//$this->logger('InventoryImageExport'," Temps d'éxécution à l'image ".$id." : ".$this->getTempsEcoule());
187
      		//$this->logger('InventoryImageExport'," Temps d'éxécution à l'image ".$id." : ".$this->getTempsEcoule());
189
        }
188
        }
190
        
189
        
191
        // fermeture du workbook
190
        // fermeture du workbook
192
		$this->workbook->close();
191
		$this->workbook->close();
193
		$i = 1;
192
		$i = 1;
194
 
193
 
195
		// ajout du fichier liste dans cet objet
194
		// ajout du fichier liste dans cet objet
196
		// contenu du fichier
195
		// contenu du fichier
197
	    $fp = fopen($this->chemin_export_liste, 'r');
196
	    $fp = fopen($this->chemin_export_liste, 'r');
198
	    $contenu = fread($fp, filesize($this->chemin_export_liste));
197
	    $contenu = fread($fp, filesize($this->chemin_export_liste));
199
	    fclose ($fp);
198
	    fclose ($fp);
200
 
199
 
201
		$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
200
		$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
202
		
201
		
203
		$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
202
		$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
204
		$index_archive_courante++;
203
		$index_archive_courante++;
205
 
204
 
206
		$j = 1;
205
		$j = 1;
207
		$sortie = '<div><ul>';
206
		$sortie = '<div><ul>';
208
		foreach($liens_archives as $lien) {
207
		foreach($liens_archives as $lien) {
209
			$sortie .= '<li> <a href = "'.$lien.'"> Partie '.$j.'</a></li>';
208
			$sortie .= '<li> <a href = "'.$lien.'"> Partie '.$j.'</a></li>';
210
			$j++;
209
			$j++;
211
		}
210
		}
212
 
211
 
213
		$sortie .= '</div></ul>';
212
		$sortie .= '</div></ul>';
214
 
213
 
215
		//$this->logger('InventoryImageExport',count($tableau));
214
		//$this->logger('InventoryImageExport',count($tableau));
216
 
215
 
217
		//$this->logger('InventoryImageExport',print_r($tableau,true));
216
		//$this->logger('InventoryImageExport',print_r($tableau,true));
218
 
217
 
219
		header('Content-Type: text/html');
218
		header('Content-Type: text/html');
220
		echo $sortie;
219
		echo $sortie;
221
 
220
 
222
    }
221
    }
223
 
222
 
224
 
223
 
225
    function getRessource(){
224
    function getRessource(){
226
		//$this->getElement();
225
		//$this->getElement();
227
    }
226
    }
228
 
227
 
229
    public function authentifier() {
228
    public function authentifier() {
230
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
229
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
231
        header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
230
        header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
232
        header('HTTP/1.0 401 Unauthorized');
231
        header('HTTP/1.0 401 Unauthorized');
233
        header('Content-type: text/html; charset=UTF-8');
232
        header('Content-type: text/html; charset=UTF-8');
234
        echo 'Accès interdit';
233
        echo 'Accès interdit';
235
        exit;
234
        exit;
236
        } else {
235
        } else {
237
            if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
236
            if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
238
                return ;
237
                return ;
239
            }
238
            }
240
            else
239
            else
241
            {
240
            {
242
                header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
241
                header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
243
                header('HTTP/1.0 401 Unauthorized');
242
                header('HTTP/1.0 401 Unauthorized');
244
                header('Content-type: text/html; charset=UTF-8');
243
                header('Content-type: text/html; charset=UTF-8');
245
                echo 'Accès interdit';
244
                echo 'Accès interdit';
246
                exit ;
245
                exit ;
247
            }
246
            }
248
        }
247
        }
249
    }
248
    }
250
 
249
 
251
    public function verifierAcces($id) {
250
    public function verifierAcces($id) {
252
 
251
 
253
        $DB=$this->connectDB($this->config,'database_ident');
252
        $DB=$this->connectDB($this->config,'database_ident');
254
        $query="SELECT ".$this->config['database_ident']['ann_id']." as name FROM ".$this->config['database_ident']['annuaire']." WHERE ".$this->config['database_ident']['ann_id']." ='".$DB->escapeSimple($id)
253
        $query="SELECT ".$this->config['database_ident']['ann_id']." as name FROM ".$this->config['database_ident']['annuaire']." WHERE ".$this->config['database_ident']['ann_id']." ='".$DB->escapeSimple($id)
255
        ."' AND ".$this->config['database_ident']['ann_pwd']." = ".$this->config['database_ident']['pass_crypt_funct']."('".$DB->escapeSimple($_SERVER['PHP_AUTH_PW'])."')" ;
254
        ."' AND ".$this->config['database_ident']['ann_pwd']." = ".$this->config['database_ident']['pass_crypt_funct']."('".$DB->escapeSimple($_SERVER['PHP_AUTH_PW'])."')" ;
256
 
255
 
257
        $res =& $DB->getOne($query);
256
        $res =& $DB->getOne($query);
258
 
257
 
259
        if($res == "") {
258
        if($res == "") {
260
            return false ;
259
            return false ;
261
        }
260
        }
262
 
261
 
263
        if (DB::isError($res)) {
262
        if (DB::isError($res)) {
264
            die($res->getMessage());
263
            die($res->getMessage());
265
        }
264
        }
266
 
265
 
267
        return $this->isAdmin($id) ;
266
        return $this->isAdmin($id) ;
268
 
267
 
269
    }
268
    }
270
 
269
 
271
    private function renvoyerCheminSurServeur($id,$url = true) {
270
    private function renvoyerCheminSurServeur($id,$url = true) {
272
 
271
 
273
		if($url) {
272
		if($url) {
274
			$chemin_sur_serveur = $this->config['cel_db']['url_images'];
273
			$chemin_sur_serveur = $this->config['cel_db']['url_images'];
275
		} else {
274
		} else {
276
			$chemin_sur_serveur = $this->config['cel_db']['chemin_images'];
275
			$chemin_sur_serveur = $this->config['cel_db']['chemin_images'];
277
		}
276
		}
278
 
277
 
279
		$id = sprintf('%09s', $id) ;
278
		$id = sprintf('%09s', $id) ;
280
        $id = wordwrap($id, 3 , '_', true) ;
279
        $id = wordwrap($id, 3 , '_', true) ;
281
 
280
 
282
        $id_fichier = $id.".jpg" ;
281
        $id_fichier = $id.".jpg" ;
283
 
282
 
284
        $niveauDossier = split("_", $id) ;
283
        $niveauDossier = split("_", $id) ;
285
 
284
 
286
        $dossierNiveau1 = $niveauDossier[0] ;
285
        $dossierNiveau1 = $niveauDossier[0] ;
287
        $dossierNiveau2 = $niveauDossier[1] ;
286
        $dossierNiveau2 = $niveauDossier[1] ;
288
 
287
 
289
        $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
288
        $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
290
 
289
 
291
        $chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
290
        $chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
292
 
291
 
293
        return $chemin_fichier;
292
        return $chemin_fichier;
294
    }
293
    }
295
 
294
 
296
    private function renvoyerCheminExport($url = true) {
295
    private function renvoyerCheminExport($url = true) {
297
    	if($url) {
296
    	if($url) {
298
    		return $this->config['cel_db']['url_export'];
297
    		return $this->config['cel_db']['url_export'];
299
    	} else {
298
    	} else {
300
			return $this->config['cel_db']['chemin_export'];
299
			return $this->config['cel_db']['chemin_export'];
301
    	}
300
    	}
302
    }
301
    }
303
 
302
 
304
    private function enregistrerArchive($zip,$index,$tag) {
303
    private function enregistrerArchive($zip,$index,$tag) {
305
 
304
 
306
		// production de l'archive' Zip
305
		// production de l'archive' Zip
307
	    $this->archive = $zip->file();
306
	    $this->archive = $zip->file();
308
		$chemin_export = $this->renvoyerCheminExport(false);
307
		$chemin_export = $this->renvoyerCheminExport(false);
309
		$url_export = $this->renvoyerCheminExport(true);
308
		$url_export = $this->renvoyerCheminExport(true);
310
 
309
 
311
		$chemin_archive = $chemin_export.'/'.md5($tag).'_'.$index.'.zip';
310
		$chemin_archive = $chemin_export.'/'.md5($tag).'_'.$index.'.zip';
312
		$url_archive = $url_export.'/'.md5($tag).'_'.$index.'.zip';
311
		$url_archive = $url_export.'/'.md5($tag).'_'.$index.'.zip';
313
 
312
 
314
		$fp = fopen($chemin_archive,'w+');
313
		$fp = fopen($chemin_archive,'w+');
315
	    $ecriture = fwrite($fp,$this->archive);
314
	    $ecriture = fwrite($fp,$this->archive);
316
	    fclose($fp);
315
	    fclose($fp);
317
 
316
 
318
	    if($ecriture) {
317
	    if($ecriture) {
319
			return $url_archive;
318
			return $url_archive;
320
	    } else {
319
	    } else {
321
	    	return false;
320
	    	return false;
322
	    }
321
	    }
323
 
322
 
324
    }
323
    }
325
 
324
 
326
    private function initialiserWorkBook($index) {
325
    private function initialiserWorkBook($index) {
327
 
326
 
328
    	// Creating a workbook
327
    	// Creating a workbook
329
        $this->chemin_export_liste = $this->renvoyerCheminExport(false).'/liste'.$index.'.xls';
328
        $this->chemin_export_liste = $this->renvoyerCheminExport(false).'/liste'.$index.'.xls';
330
		$this->workbook = new Spreadsheet_Excel_Writer($this->chemin_export_liste);
329
		$this->workbook = new Spreadsheet_Excel_Writer($this->chemin_export_liste);
331
 
330
 
332
		// Creating a worksheet
331
		// Creating a worksheet
333
		$this->worksheet = $this->workbook->addWorksheet('Liste');
332
		$this->worksheet = $this->workbook->addWorksheet('Liste');
334
 
333
 
335
		$this->worksheet->write(0,0,'url de l\'image');
334
		$this->worksheet->write(0,0,'url de l\'image');
336
		$this->worksheet->write(0,1,'Nom original de l\'image');
335
		$this->worksheet->write(0,1,'Nom original de l\'image');
337
        //$this->worksheet->write(0,1,'Nom saisi');
336
        //$this->worksheet->write(0,1,'Nom saisi');
338
        //$this->worksheet->write(0,2,'Numero nomenclatural');
337
        //$this->worksheet->write(0,2,'Numero nomenclatural');
339
        $this->worksheet->write(0,2,'Nom retenu');
338
        $this->worksheet->write(0,2,'Nom retenu');
340
        $this->worksheet->write(0,3,'Numero nomenclatural nom retenu');
339
        $this->worksheet->write(0,3,'Numero nomenclatural nom retenu');
341
        $this->worksheet->write(0,4,'Numero taxonomique');
340
        $this->worksheet->write(0,4,'Numero taxonomique');
342
        $this->worksheet->write(0,5,'Famille');
341
        $this->worksheet->write(0,5,'Famille');
343
        //$this->worksheet->write(0,7,'Commune');
342
        //$this->worksheet->write(0,7,'Commune');
344
        //$this->worksheet->write(0,8,'Identifiant Commune');
343
        //$this->worksheet->write(0,8,'Identifiant Commune');
345
        $this->worksheet->write(0,6,'Date Observation');
344
        $this->worksheet->write(0,6,'Date Observation');
346
       // $this->worksheet->write(0,10,'Lieu dit');
345
       // $this->worksheet->write(0,10,'Lieu dit');
347
        //$this->worksheet->write(0,11,'Station');
346
        //$this->worksheet->write(0,11,'Station');
348
        //$this->worksheet->write(0,12,'Milieu');
347
        //$this->worksheet->write(0,12,'Milieu');
349
        $this->worksheet->write(0,7,'Contributeur');
348
        $this->worksheet->write(0,7,'Contributeur');
350
        $this->worksheet->write(0,8,'Commentaire');
349
        $this->worksheet->write(0,8,'Commentaire');
351
    }
350
    }
352
 
351
 
353
    private function ecrireLigneWorkBook($index, $observation) {
352
    private function ecrireLigneWorkBook($index, $observation) {
354
 
353
 
355
    	$this->worksheet->write($index,0,$observation['url_image_liee']);
354
    	$this->worksheet->write($index,0,$observation['url_image_liee']);
356
    	$this->worksheet->write($index,1,$observation['nom_image_liee']);
355
    	$this->worksheet->write($index,1,$observation['nom_image_liee']);
357
	  	//$this->worksheet->write($index,1,$observation['nom_sel']);
356
	  	//$this->worksheet->write($index,1,$observation['nom_sel']);
358
		//$this->worksheet->write($index,2,$observation['num_nom_sel']);
357
		//$this->worksheet->write($index,2,$observation['num_nom_sel']);
359
		$this->worksheet->write($index,2,$observation['nom_ret']);
358
		$this->worksheet->write($index,2,$observation['nom_ret']);
360
		$this->worksheet->write($index,3,$observation['num_nom_ret']);
359
		$this->worksheet->write($index,3,$observation['num_nom_ret']);
361
		$this->worksheet->write($index,4,$observation['num_taxon']);
360
		$this->worksheet->write($index,4,$observation['num_taxon']);
362
		$this->worksheet->write($index,5,$observation['famille']);
361
		$this->worksheet->write($index,5,$observation['famille']);
363
		//$this->worksheet->write($index,7,$observation['location']);
362
		//$this->worksheet->write($index,7,$observation['location']);
364
		//$this->worksheet->write($index,8,$observation['id_location']);
363
		//$this->worksheet->write($index,8,$observation['id_location']);
365
		$this->worksheet->write($index,6,$observation['date_observation']);
364
		$this->worksheet->write($index,6,$observation['date_observation']);
366
		//$this->worksheet->write($index,10,$observation['lieudit']);
365
		//$this->worksheet->write($index,10,$observation['lieudit']);
367
		//$this->worksheet->write($index,11,$observation['station']);
366
		//$this->worksheet->write($index,11,$observation['station']);
368
	 	//$this->worksheet->write($index,12,$observation['milieu']);
367
	 	//$this->worksheet->write($index,12,$observation['milieu']);
369
	 	$this->worksheet->write($index,7,$observation['identifiant']);
368
	 	$this->worksheet->write($index,7,$observation['identifiant']);
370
		$this->worksheet->write($index,8,$observation['commentaire']);
369
		$this->worksheet->write($index,8,$observation['commentaire']);
371
    }
370
    }
372
}
371
}
373
 
372
 
374
 
373
 
375
/* +--Fin du code ---------------------------------------------------------------------------------------+
374
/* +--Fin du code ---------------------------------------------------------------------------------------+
376
* $Log$
375
* $Log$
377
* Revision 1.5  2008-11-13 11:29:12  ddelon
376
* Revision 1.5  2008-11-13 11:29:12  ddelon
378
* Reecriture gwt-ext
377
* Reecriture gwt-ext
379
*
378
*
380
* Revision 1.4  2007-06-06 13:31:16  ddelon
379
* Revision 1.4  2007-06-06 13:31:16  ddelon
381
* v0.09
380
* v0.09
382
*
381
*
383
* Revision 1.3  2007-05-22 12:54:09  ddelon
382
* Revision 1.3  2007-05-22 12:54:09  ddelon
384
* Securisation acces utilisateur
383
* Securisation acces utilisateur
385
*
384
*
386
*
385
*
387
*
386
*
388
*/
387
*/
389
 
388
 
390
?>
389
?>