Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
Line -... |
Line 2... |
- |
|
2 |
|
- |
|
3 |
/**
|
- |
|
4 |
* @category PHP
|
- |
|
5 |
* @package jrest
|
- |
|
6 |
* @author Raphaël Droz <raphael@tela-botania.org>
|
- |
|
7 |
* @copyright 2013 Tela-Botanica
|
- |
|
8 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
- |
|
9 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
- |
|
10 |
*/
|
2 |
|
11 |
|
3 |
// Include the main TCPDF library (search for installation path).
|
12 |
// Include the main TCPDF library (search for installation path).
|
4 |
date_default_timezone_set("Europe/Paris");
|
13 |
date_default_timezone_set("Europe/Paris");
|
5 |
require_once('tcpdf_config.php');
|
14 |
require_once('tcpdf_config.php');
|
Line 6... |
Line -... |
6 |
require_once('tcpdf/tcpdf.php');
|
- |
|
7 |
|
15 |
require_once('tcpdf/tcpdf.php');
|
Line 8... |
Line 16... |
8 |
//set_time_limit(6);
|
16 |
|
Line 9... |
Line 17... |
9 |
Class GenerateurPDF {
|
17 |
Class GenerateurPDF {
|
Line 203... |
Line 211... |
203 |
|
211 |
|
Line 204... |
Line 212... |
204 |
die;*/
|
212 |
die;*/
|
205 |
|
213 |
|
- |
|
214 |
// 3ème paramètre = '' equivalent à $this->pdf->getX()
|
- |
|
215 |
// 4ème paramètre = '' equivalent à $this->pdf->getY()
|
- |
|
216 |
|
- |
|
217 |
// référentiel
|
- |
|
218 |
$this->pdf->writeHTMLCell($w = $width, '', '', '',
|
- |
|
219 |
$html = '<strong>Référentiel</strong> : ' . $obs['nom_referentiel'],
|
206 |
// 3ème paramètre = '' equivalent à $this->pdf->getX()
|
220 |
$border = 'LTR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
207 |
// 4ème paramètre = '' equivalent à $this->pdf->getY()
|
221 |
|
208 |
// famille
|
222 |
// famille
|
209 |
$this->pdf->writeHTMLCell($w = $width - 20, '', '', '',
|
223 |
$this->pdf->writeHTMLCell($w = $width, '', '', '',
|
210 |
$html = '<strong>Famille</strong> : ' . $obs['famille'],
|
- |
|
Line 211... |
Line -... |
211 |
$border = 'LT', $ln = 0, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
- |
|
212 |
|
- |
|
213 |
|
- |
|
214 |
// N°: TODO: writeHTMLCell() semble bugger
|
- |
|
215 |
$this->pdf->Cell($w = 20, '',
|
- |
|
216 |
$txt = 'N° : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre'])
|
- |
|
217 |
$border = 'TR', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
|
- |
|
Line 218... |
Line 224... |
218 |
/*$this->pdf->writeHTMLCell($w = 20, '', '', '',
|
224 |
$html = '<strong>Famille</strong> : ' . $obs['famille'],
|
- |
|
225 |
$border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
- |
|
226 |
|
- |
|
227 |
|
- |
|
228 |
// taxon
|
219 |
$html = '<strong>N°</strong> : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre']),
|
229 |
$nom = $obs['nom_ret'];
|
220 |
$border = 'TR', $ln = 1, $fill = true, $reset = true, $align = 'R', $autopadding = true);*/
|
230 |
if($obs['certitude'] && stripos($obs['certitude'], 'certain') === false) {
|
221 |
|
231 |
$nom .= ' ' . $obs['certitude'];
|
222 |
// espece
|
232 |
}
|
Line 223... |
Line 233... |
223 |
$this->pdf->writeHTMLCell($w = $width, $lh * 2.5, '', '',
|
233 |
$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '', '',
|
- |
|
234 |
//$html = '<strong>Espèce</strong> : ' . self::elude('Espèce : ', $obs['nom_ret'], 2),
|
- |
|
235 |
$html = $this->elude('<strong>Taxon</strong> : ' . $nom, 3),
|
- |
|
236 |
$border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
- |
|
237 |
|
- |
|
238 |
// collecteur
|
- |
|
239 |
// TODO: pseudo
|
- |
|
240 |
$limite_nom = 26;
|
224 |
//$html = '<strong>Espèce</strong> : ' . self::elude('Espèce : ', $obs['nom_ret'], 2),
|
241 |
$prenom = $obs['prenom_utilisateur'];
|
225 |
$html = $this->elude('<strong>Espèce</strong> : ' . $obs['nom_ret'], 2),
|
242 |
if(mb_strlen($prenom . ' ' . $obs['nom_utilisateur'], 'UTF-8') > $limite_nom) {
|
226 |
$border = 'RL', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
243 |
$prenom = mb_substr($prenom, 0, 26 - mb_strlen($obs['nom_utilisateur'], 'UTF-8') - 1 /* espace */ - 1 /* … */, 'UTF-8') . '…';
|
- |
|
244 |
//var_dump($prenom);die;
|
- |
|
245 |
}
|
- |
|
246 |
$this->pdf->writeHTMLCell($w = $width - 25, '', '', '',
|
- |
|
247 |
$html = '<strong>Collecteur</strong> : ' . $prenom . ' ' . $obs['nom_utilisateur'],
|
- |
|
248 |
$border = 'L', $ln = 0, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
- |
|
249 |
|
- |
|
250 |
// N°: TODO: writeHTMLCell() semble bugger
|
- |
|
251 |
$this->pdf->Cell($w = 25, '',
|
Line 227... |
Line 252... |
227 |
|
252 |
$txt = 'N° : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre'])
|
- |
|
253 |
$border = 'R', $ln = 1, $align = 'R', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
|
- |
|
254 |
/*$this->pdf->writeHTMLCell($w = 30, '', '', '',
|
- |
|
255 |
$html = '<strong>N°</strong> : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre']),
|
- |
|
256 |
$border = 'R', $ln = 1, $fill = true, $reset = true, $align = 'L', $autopadding = true);*/
|
- |
|
257 |
|
- |
|
258 |
// localité
|
- |
|
259 |
// TODO: département
|
- |
|
260 |
// TEST: Corse (2A, 2B)
|
- |
|
261 |
$info_dep = "<strong>Localité</strong> : %s";
|
- |
|
262 |
$donnees_dep = array($obs['zone_geo']);
|
- |
|
263 |
if($obs['ce_zone_geo']) {
|
- |
|
264 |
$info_dep .= " (%s)";
|
- |
|
265 |
if(strpos($obs['ce_zone_geo'], 'INSEE') !== false) $donnees_dep[] = preg_replace('/^[^\d]*(\d\d).*/', '\1', $obs['ce_zone_geo']);
|
- |
|
266 |
else $donnees_dep[] = $obs['ce_zone_geo'];
|
- |
|
267 |
}
|
- |
|
268 |
|
228 |
// collecteur
|
269 |
$info_loc = "%s, %s";
|
229 |
$this->pdf->writeHTMLCell($w = $width, '', '', '',
|
270 |
$donnees_loc = array($obs['lieudit'], $obs['station']);
|
230 |
$html = '<strong>Collecteur</strong> : ' . $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
|
271 |
if($obs['milieu']) {
|
231 |
$border = 'RL', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
272 |
$info_loc .= " [%s]";
|
232 |
|
273 |
$donnees_loc[] = $obs['milieu'];
|
233 |
// localité
|
274 |
}
|
234 |
$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '', '',
|
275 |
$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '', '',
|
235 |
//$html = "<strong>Localité</strong> : " .
|
276 |
//$html = "<strong>Localité</strong> : " .
|
236 |
//self::elude('Localité : ', sprintf("%s (%s)\n%s, %s [%s]", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station'], $obs['milieu'] ), 3),
|
277 |
//self::elude('Localité : ', sprintf("%s (%s)\n%s, %s [%s]", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station'], $obs['milieu'] ), 3),
|
- |
|
278 |
// $html = self::elude(sprintf("<strong>Localité</strong> : %s (%s)\n%s, %s [%s]", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station'], $obs['milieu']), 3),
|
- |
|
279 |
$html = $this->elude(vsprintf($info_dep, $donnees_dep), 2) . "\n" .
|
- |
|
280 |
$this->elude(vsprintf($info_loc, $donnees_loc), 2),
|
- |
|
281 |
$border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
- |
|
282 |
|
- |
|
283 |
// lon/lat/alt
|
- |
|
284 |
$info_geo = '';
|
- |
|
285 |
$donnees = array();
|
- |
|
286 |
if($obs['latitude'] && $obs['longitude']) {
|
- |
|
287 |
$info_geo .= "%.5f N / %.5f E";
|
237 |
// $html = self::elude(sprintf("<strong>Localité</strong> : %s (%s)\n%s, %s [%s]", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station'], $obs['milieu']), 3),
|
288 |
array_push($donnees, $obs['latitude'], $obs['longitude']);
|
238 |
$html = $this->elude(sprintf("<strong>Localité</strong> : %s (%s)", $obs['zone_geo'], $obs['ce_zone_geo']), 2) . "\n" .
|
289 |
}
|
239 |
$this->elude(sprintf("%s, %s [%s]", $obs['lieudit'], $obs['station'], $obs['milieu']), 2),
|
290 |
if($obs['altitude']) {
|
Line 240... |
Line 291... |
240 |
$border = 'RL', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
291 |
$info_geo .= ", %dm";
|
241 |
|
292 |
array_push($donnees, $obs['altitude']);
|
242 |
// lon/lat
|
293 |
}
|
243 |
$this->pdf->writeHTMLCell($w = $width, '', '', '',
|
294 |
$this->pdf->writeHTMLCell($w = $width, '', '', '',
|
244 |
$html = sprintf("<strong>Latitude / Longitude</strong> : %s / %s", $obs['latitude'], $obs['longitude']),
|
295 |
$html = vsprintf("<strong>Lat. / Lon. , Alt.</strong> : " . $info_geo, $donnees),
|
Line 245... |
Line 296... |
245 |
$border = 'RL', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
296 |
$border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
|
246 |
|
297 |
|
247 |
// commentaire
|
298 |
// commentaire
|
248 |
$this->pdf->writeHTMLCell($w = $width, $lh * 4.5, '', '',
|
299 |
$this->pdf->writeHTMLCell($w = $width, $lh * 4.5, '', '',
|
Line 249... |
Line 300... |
249 |
//$html = '<strong>Observation</strong> : ' . self::elude('Observation : ', $obs['commentaire']),
|
300 |
//$html = '<strong>Observation</strong> : ' . self::elude('Observation : ', $obs['commentaire']),
|
Line 250... |
Line 301... |
250 |
$html = self::elude('<strong>Observation</strong> : ' . $obs['commentaire'], 4),
|
301 |
$html = self::elude('<strong>Observation</strong> : ' . $obs['commentaire'], 4),
|
Line 296... |
Line 347... |
296 |
|
347 |
|
297 |
// singe la propriété CSS3 "text-overflow" : "ellipsis"
|
348 |
// singe la propriété CSS3 "text-overflow" : "ellipsis"
|
298 |
function elude_bis($intitule, $commentaire, $lignes = 3) {
|
349 |
function elude_bis($intitule, $commentaire, $lignes = 3) {
|
299 |
// TODO: GetLineWidth, GetCharWidth()
|
350 |
// TODO: GetLineWidth, GetCharWidth()
|
300 |
$limite = $lignes /* lignes */ * 43 /* caractères */ - strlen($intitule);
|
351 |
$limite = $lignes /* lignes */ * 43 /* caractères */ - strlen($intitule);
|
301 |
if(mb_strlen($commentaire) < $limite) return $commentaire;
|
352 |
if(mb_strlen($commentaire, 'UTF-8') < $limite) return $commentaire;
|
302 |
return mb_substr($commentaire, 0, $limite - 2) . '…';
|
353 |
return mb_substr($commentaire, 0, $limite - 2) . '…';
|
Line 303... |
Line 354... |
303 |
}
|
354 |
}
|