Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1029 | Rev 1031 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1029 Rev 1030
Line 111... Line 111...
111
 
111
 
112
	private function capturerParametresFormulaire() {
112
	private function capturerParametresFormulaire() {
113
		if (!empty($_POST['bloc'])) {
113
		if (!empty($_POST['bloc'])) {
114
			$this->blocs = $_POST['bloc'];
114
			$this->blocs = $_POST['bloc'];
115
		} else {
115
		} else {
116
			$this->blocs = array('description', 'ecologie', 'ethnobotanique',
-
 
117
								 'statuts', 'illustrations', 'bibliographie',
116
			$this->blocs = array('description', 'ecologie', 'ethnobotanique', 'statuts', 'illustrations',
118
								 'repartition', 'nomenclature');
117
				'bibliographie', 'repartition', 'nomenclature');
119
		}
118
		}
Line 120... Line 119...
120
	}
119
	}
121
 
120
 
122
	public function executerActionParDefaut() {
121
	public function executerActionParDefaut() {
Line 123... Line 122...
123
		$this->executerPdfExport();
122
		$this->executerPdfExport();
-
 
123
	}
-
 
124
 
-
 
125
	public function executerPdfExport(){
-
 
126
		$nom_fichier = $this->getNomFichierValide();
-
 
127
		$this->fichier_html = $this->chemin_pdf.''.$nom_fichier.'.html';
124
	}
128
		$this->fichier_pdf = $this->chemin_pdf.''.$nom_fichier.'.pdf';
125
 
129
 
126
	public function executerPdfExport(){
130
		if (file_exists($this->fichier_pdf) == false) {
127
		$this->capturerParametresFormulaire();
131
			$this->capturerParametresFormulaire();
128
		$donnees = $this->obtenirDonnees();
-
 
129
		$this->construireHtml($donnees);
-
 
130
		if ($this->transformerHtmlEnPdf()) {
132
			$donnees = $this->obtenirDonnees();
-
 
133
			$this->construireHtml($donnees);
131
			$this->envoyerPdfAuNavigateur();
134
			if ($this->transformerHtmlEnPdf() == false) {
132
		} else {
135
				die('Erreur de generation du fichier PDF');
133
			die('Erreur de generation du fichier PDF');
136
			}
134
		}
137
		}
135
		// important, autrement l'exécution de papyrus continue
138
		$this->envoyerPdfAuNavigateur();
Line 136... Line 139...
136
		// et du HTML inutile est ajouté à la fin du fichier PDF
139
		// ATTENTION : on doit stopper l'exécution de Papyrus sinon du HTML inutile est ajouté à la fin du fichier PDF
137
		exit;
140
		exit;
Line 201... Line 204...
201
		}
204
		}
202
	}
205
	}
Line 203... Line 206...
203
 
206
 
204
	//version WKHTMLtoPDF en ligne de commande
207
	//version WKHTMLtoPDF en ligne de commande
205
	private function transformerHtmlEnPdf() {
-
 
206
		$nom_fichier = $this->getNomFichierValide();
-
 
207
		$time = $_SERVER['REQUEST_TIME'] ;
-
 
208
		$this->fichier_html = $this->chemin_pdf.''.$nom_fichier.'-'.$time.'.html';
-
 
209
		$this->fichier_pdf = $this->chemin_pdf.''.$nom_fichier.'-'.$time.'.pdf';
208
	private function transformerHtmlEnPdf() {
210
		$nom = $this->getNomRetenu();
209
		$nom = $this->getNomRetenu();
211
		file_put_contents($this->fichier_html, $this->html);
210
		file_put_contents($this->fichier_html, $this->html);
212
		$commande =	"{$this->wkhtml}  --replace 'nom' '$nom' --encoding utf-8  --footer-html {$this->piedepage} {$this->fichier_html} {$this->fichier_pdf}";
211
		$commande =	"{$this->wkhtml}  --replace 'nom' '$nom' --encoding utf-8  --footer-html {$this->piedepage} {$this->fichier_html} {$this->fichier_pdf}";
213
		$ret = -1;
212
		$ret = -1;
214
		$debug = array();
213
		$debug = array();
215
		exec($commande, $debug, $ret);
214
		exec($commande, $debug, $ret);
216
		//print_r( $debug ); echo $ret;
215
		//print_r( $debug ); echo $ret;
-
 
216
		$ok = ($ret == 0 || $ret == 2) ? true : false;
217
		return ( $ret == 0 || $ret == 2 );
217
		return $ok;
218
	}
218
	}
219
}
219
}
220
?>
220
?>