Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2459 Rev 2462
1
<?php
1
<?php
2
 
-
 
-
 
2
// declare(encoding='UTF-8');
3
/**
3
/**
-
 
4
 * Classe permettant de générer des PDFs.
-
 
5
 *
-
 
6
 * @internal   Mininum PHP version : 5.2
4
* @category  PHP
7
 * @category   CEL
5
* @package   jrest
8
 * @package    Services
-
 
9
 * @subpackage Bibliothèques
-
 
10
 * @version    0.1
-
 
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
6
* @author    Raphaël Droz <raphael@tela-botania.org>
12
 * @author     Raphaël Droz <raphael@tela-botania.org>
7
* @copyright 2013 Tela-Botanica
13
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
14
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
9
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
15
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
-
 
16
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
-
 
17
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
10
*/
18
 */
11
 
-
 
12
// Include the main TCPDF library (search for installation path).
19
// Include the main TCPDF library (search for installation path).
13
date_default_timezone_set("Europe/Paris");
20
date_default_timezone_set('Europe/Paris');
14
require_once('tcpdf_config.php');
21
require_once('tcpdf_config.php');
15
require_once('tcpdf/tcpdf.php');
22
require_once('tcpdf/tcpdf.php');
16
 
23
 
17
Class GenerateurPDF {
24
Class GenerateurPDF {
18
 
25
 
19
	public $pdf;
26
	public $pdf;
20
 
27
 
21
	function GenerateurPDF($utilisateur = NULL) {
28
	function GenerateurPDF($utilisateur = NULL) {
22
		// create new PDF document
29
		// create new PDF document
23
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
30
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
24
 
31
 
25
		// set document information
32
		// set document information
26
		$pdf->SetCreator(PDF_CREATOR);
33
		$pdf->SetCreator(PDF_CREATOR);
27
		$pdf->SetAuthor($utilisateur ? $utilisateur['prenom'] . ' ' . $utilisateur['nom'] : 'CEL - Tela Botanica');
34
		$pdf->SetAuthor($utilisateur ? $utilisateur['prenom'] . ' ' . $utilisateur['nom'] : 'CEL - Tela Botanica');
28
		$pdf->SetTitle('Observations en étiquettes');
35
		$pdf->SetTitle('Observations en étiquettes');
29
		$pdf->SetSubject('Étiquettes des observations');
36
		$pdf->SetSubject('Étiquettes des observations');
30
		$pdf->SetKeywords('botaniques, observations, étiquettes, cel, tela-botanica');
37
		$pdf->SetKeywords('botaniques, observations, étiquettes, cel, tela-botanica');
31
 
-
 
32
		// set default header data
-
 
33
		// $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 005', PDF_HEADER_STRING);
-
 
34
 
-
 
35
		// set header and footer fonts
-
 
36
		// $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
-
 
37
		// $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
-
 
38
 
-
 
39
		// set default monospaced font
38
 
40
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
39
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
41
 
40
 
42
		// set margins
41
		// set margins
43
		$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
42
		$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
44
		$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
43
		$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
45
		$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
44
		$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
46
 
-
 
47
		// set auto page breaks
-
 
48
		// $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
45
 
49
		$pdf->SetAutoPageBreak(FALSE, PDF_MARGIN_BOTTOM);
46
		$pdf->SetAutoPageBreak(FALSE, PDF_MARGIN_BOTTOM);
50
 
47
 
51
		$pdf->SetFont('times', '', 11);
48
		$pdf->SetFont('times', '', 11);
52
		$pdf->setCellPaddings(1, 1, 1, 1);
49
		$pdf->setCellPaddings(1, 1, 1, 1);
53
		$pdf->setCellMargins(1, 1, 1, 1);
50
		$pdf->setCellMargins(1, 1, 1, 1);
54
 
51
 
55
		$pdf->AddPage();
52
		$pdf->AddPage();
56
		$pdf->setEqualColumns(2);
53
		$pdf->setEqualColumns(2);
57
 
54
 
58
		$this->pdf = $pdf;
55
		$this->pdf = $pdf;
59
	}
56
	}
60
 
-
 
61
 
-
 
62
 
57
 
63
	function export($obs) {
58
	public function export($obs) {
64
		$pdf = &$this->pdf;
59
		$pdf = &$this->pdf;
65
 
60
 
66
		$i = 0;
61
		$i = 0;
67
		while($i < count($obs)) {
62
		while($i < count($obs)) {
68
			$pdf->selectColumn(0);
63
			$pdf->selectColumn(0);
69
			// Multicell test
64
			// Multicell test
70
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
65
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
71
			$pdf->Ln();
66
			$pdf->Ln();
72
			$this->doHTMLcell($obs[$i++]);  if(!isset($obs[$i])) break;
67
			$this->doHTMLcell($obs[$i++]);  if(!isset($obs[$i])) break;
73
			$pdf->Ln();
68
			$pdf->Ln();
74
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
69
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
75
			/*$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
70
			/*$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
76
			  $pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);*/
71
			  $pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);*/
77
 
72
 
78
			$pdf->selectColumn(1);
73
			$pdf->selectColumn(1);
79
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
74
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
80
			$pdf->Ln();
75
			$pdf->Ln();
81
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
76
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
82
			$pdf->Ln();
77
			$pdf->Ln();
83
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
78
			$this->doHTMLcell($obs[$i++]); if(!isset($obs[$i])) break;
84
			/*$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
79
			/*$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
85
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
80
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
86
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);*/
81
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);*/
87
 
82
 
88
			if(isset($obs[$i])) $pdf->AddPage();
83
			if(isset($obs[$i])) $pdf->AddPage();
89
		}
84
		}
90
	}
85
	}
91
 
86
 
92
	function getlinenb4($txt) {
87
	function getlinenb4($txt) {
93
		// store current object
88
		// store current object
94
		$this->pdf->startTransaction();
89
		$this->pdf->startTransaction();
95
		// store starting values
90
		// store starting values
96
		$start_y = $this->pdf->GetY();
91
		$start_y = $this->pdf->GetY();
97
		$start_page = $this->pdf->getPage();
92
		$start_page = $this->pdf->getPage();
98
 
93
 
99
		$this->pdf->MultiCell($this->column_width, $h=0, $txt, $border=0, $align='L', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);
94
		$this->pdf->MultiCell($this->column_width, $h=0, $txt, $border=0, $align='L', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);
100
		$end_y = $this->pdf->GetY();
95
		$end_y = $this->pdf->GetY();
101
		$end_page = $this->pdf->getPage();
96
		$end_page = $this->pdf->getPage();
102
		// calculate height
97
		// calculate height
103
		$height = 0;
98
		$height = 0;
104
		if ($end_page == $start_page) {
99
		if ($end_page == $start_page) {
105
			$height = $end_y - $start_y;
100
			$height = $end_y - $start_y;
106
		} else {
101
		} else {
107
			for ($page=$start_page; $page <= $end_page; ++$page) {
102
			for ($page=$start_page; $page <= $end_page; ++$page) {
108
				$this->setPage($page);
103
				$this->setPage($page);
109
				if ($page == $start_page) {
104
				if ($page == $start_page) {
110
					// first page
105
					// first page
111
					$height = $this->pdf->h - $start_y - $this->pdf->bMargin;
106
					$height = $this->pdf->h - $start_y - $this->pdf->bMargin;
112
				} elseif ($page == $end_page) {
107
				} elseif ($page == $end_page) {
113
					// last page
108
					// last page
114
					$height = $end_y - $this->pdf->tMargin;
109
					$height = $end_y - $this->pdf->tMargin;
115
				} else {
110
				} else {
116
					$height = $this->pdf->h - $this->pdf->tMargin - $this->bMargin;
111
					$height = $this->pdf->h - $this->pdf->tMargin - $this->bMargin;
117
				}
112
				}
118
			}
113
			}
119
		}
114
		}
120
		// restore previous object
115
		// restore previous object
121
		$this->pdf = $this->pdf->rollbackTransaction();
116
		$this->pdf = $this->pdf->rollbackTransaction();
122
		return $height;
117
		return $height;
123
	}
118
	}
124
 
119
 
125
	function getlinenb3($txt) {
120
	function getlinenb3($txt) {
126
		return $this->pdf->getStringHeight($this->column_width, $txt);
121
		return $this->pdf->getStringHeight($this->column_width, $txt);
127
	}
122
	}
128
 
123
 
129
	function getlinenb2($txt) {
124
	function getlinenb2($txt) {
130
		//var_dump($line, $this->pdf->GetStringWidth($line));
125
		//var_dump($line, $this->pdf->GetStringWidth($line));
131
		return ceil($this->pdf->GetStringWidth($txt)  / $this->column_width);		
126
		return ceil($this->pdf->GetStringWidth($txt)  / $this->column_width);
132
	}
127
	}
133
 
128
 
134
	function getlinenb($txt) {
129
	function getlinenb($txt) {
135
		return $this->pdf->getStringHeight('', $txt) / ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio());
130
		return $this->pdf->getStringHeight('', $txt) / ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio());
136
	}
131
	}
137
 
132
 
138
	// singe la propriété CSS3 "text-overflow" : "ellipsis"
133
	// singe la propriété CSS3 "text-overflow" : "ellipsis"
139
	function elude($txt, $limite_lignes = 3) {
134
	function elude($txt, $limite_lignes = 3) {
140
		// echo strlen($txt) . ' '.  $this->getlinenb($txt) . ' ' . $limite_lignes . "\n";
135
		// echo strlen($txt) . ' '.  $this->getlinenb($txt) . ' ' . $limite_lignes . "\n";
141
 
136
 
142
		$cell_paddings = $this->pdf->getCellPaddings();
137
		$cell_paddings = $this->pdf->getCellPaddings();
143
		$marge = $cell_paddings['T'] + $cell_paddings['B'];
138
		$marge = $cell_paddings['T'] + $cell_paddings['B'];
144
		$line_height = $this->pdf->getStringHeight($this->column_width, "a") - $marge;
139
		$line_height = $this->pdf->getStringHeight($this->column_width, "a") - $marge;
145
		if($limite_lignes > 1) {
140
		if($limite_lignes > 1) {
146
			$lim = $line_height * $limite_lignes + $marge; // $line_height + ($line_height - $marge) * ($limite_lignes - 1);
141
			$lim = $line_height * $limite_lignes + $marge; // $line_height + ($line_height - $marge) * ($limite_lignes - 1);
147
		} else {
142
		} else {
148
			$lim = $line_height + $marge;
143
			$lim = $line_height + $marge;
149
		}
144
		}
150
 
145
 
151
		while(strlen($txt) > 4 && ($nb = $this->getlinenb3(strip_tags($txt))) > $lim) {
146
		while(strlen($txt) > 4 && ($nb = $this->getlinenb3(strip_tags($txt))) > $lim) {
152
			//echo "$nb / $line_height: $txt\n";
147
			//echo "$nb / $line_height: $txt\n";
153
			// TODO: mb_internal_encoding()
148
			// TODO: mb_internal_encoding()
154
			$txt = mb_substr($txt, 0, -4, 'UTF-8') . '…';
149
			$txt = mb_substr($txt, 0, -4, 'UTF-8') . '…';
155
		}
150
		}
156
		//echo "$txt: $nb / $limite_lignes \n";
151
		//echo "$txt: $nb / $limite_lignes \n";
157
		return $txt;
152
		return $txt;
158
	}
153
	}
159
 
154
 
160
 
155
 
161
	// TODO: affichage pays dans "localité"
156
	// TODO: affichage pays dans "localité"
162
	// ORDER BY id_observation
157
	// ORDER BY id_observation
163
	// italique pour nom d'espèce, mais pas auteur
158
	// italique pour nom d'espèce, mais pas auteur
164
	function doHTMLcell(&$obs) {
159
	function doHTMLcell(&$obs) {
165
		$this->pdf->setCellMargins(0,0,0,0);
160
		$this->pdf->setCellMargins(0,0,0,0);
166
		$width = $this->column_width = 98;
161
		$width = $this->column_width = 98;
167
 
162
 
168
		//echo "cell_padding['T']: " . $this->pdf->getCellPaddings()['T'] . ", cell_padding['B']: " . $this->pdf->getCellPaddings()['B'] . "\n";
163
		//echo "cell_padding['T']: " . $this->pdf->getCellPaddings()['T'] . ", cell_padding['B']: " . $this->pdf->getCellPaddings()['B'] . "\n";
169
 
164
 
170
		$lh = $this->pdf->getFontSize() * $this->pdf->getCellHeightRatio();
165
		$lh = $this->pdf->getFontSize() * $this->pdf->getCellHeightRatio();
171
		//$lh = $this->pdf->GetLineWidth();
166
		//$lh = $this->pdf->GetLineWidth();
172
 
167
 
173
		/*
168
		/*
174
		var_dump($this->pdf->GetLineWidth(),
169
		var_dump($this->pdf->GetLineWidth(),
175
				 $this->pdf->GetCharWidth("a"),
170
				 $this->pdf->GetCharWidth("a"),
176
				 $this->pdf->getStringHeight(60, "Ê"),
171
				 $this->pdf->getStringHeight(60, "Ê"),
177
				 $this->pdf->getHTMLFontUnits("plop"),
172
				 $this->pdf->getHTMLFontUnits("plop"),
178
				 $this->pdf->GetStringWidth("aa"),
173
				 $this->pdf->GetStringWidth("aa"),
179
				 $lh,
174
				 $lh,
180
 
175
 
181
				 5,
176
				 5,
182
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum..."),
177
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum..."),
183
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 5),
178
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 5),
184
 
179
 
185
				 4,
180
				 4,
186
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor"),
181
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor"),
187
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 4),
182
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 4),
188
 
183
 
189
				 3,
184
				 3,
190
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet"),
185
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet"),
191
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 3),
186
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 3),
192
 
187
 
193
				 2,
188
				 2,
194
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore"),
189
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore"),
195
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 2),
190
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 2),
196
 
191
 
197
				 1,
192
				 1,
198
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur"),
193
				 $this->getlinenb4("Observation : Lorem ipsum dolor sit amet, consectetur"),
199
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 1)
194
				 $this->elude("Observation : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum...", 1)
200
		);
195
		);
201
		die;
196
		die;
202
		*/
197
		*/
203
 
198
 
204
 
199
 
205
		/*		$str = '<strong>Observation</strong> : ' . $obs['commentaire'];
200
		/*		$str = '<strong>Observation</strong> : ' . $obs['commentaire'];
206
		echo $this->getlinenb(strip_tags($str)) . "\n";
201
		echo $this->getlinenb(strip_tags($str)) . "\n";
207
		echo $this->getlinenb2(strip_tags($str)) . "\n";
202
		echo $this->getlinenb2(strip_tags($str)) . "\n";
208
		echo $this->pdf->getStringHeight($width, strip_tags($str)) . "\n";
203
		echo $this->pdf->getStringHeight($width, strip_tags($str)) . "\n";
209
		echo $this->pdf->getStringHeight($width, "a") . "\n";
204
		echo $this->pdf->getStringHeight($width, "a") . "\n";
210
		echo ( $this->pdf->getStringHeight($width, strip_tags($str)) / $this->pdf->getStringHeight($width, "a")) . "\n";
205
		echo ( $this->pdf->getStringHeight($width, strip_tags($str)) / $this->pdf->getStringHeight($width, "a")) . "\n";
211
 
206
 
212
		die;*/
207
		die;*/
213
 
208
 
214
		// 3ème paramètre = '' equivalent à $this->pdf->getX()
209
		// 3ème paramètre = '' equivalent à $this->pdf->getX()
215
		// 4ème paramètre = '' equivalent à $this->pdf->getY()
210
		// 4ème paramètre = '' equivalent à $this->pdf->getY()
216
 
211
 
217
		// référentiel
212
		// référentiel
218
		/* $this->pdf->writeHTMLCell($w = $width, '', '', '',
213
		/* $this->pdf->writeHTMLCell($w = $width, '', '', '',
219
								  $html = '<strong>Référentiel</strong> : ' . $obs['nom_referentiel'],
214
								  $html = '<strong>Référentiel</strong> : ' . $obs['nom_referentiel'],
220
								  $border = 'LTR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true); */
215
								  $border = 'LTR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true); */
221
 
216
 
222
		// famille
217
		// famille
223
		$this->pdf->writeHTMLCell($w = $width, '', '', '',
218
		$this->pdf->writeHTMLCell($w = $width, '', '', '',
224
								  $html = '<strong>Famille</strong> : ' . strtoupper($obs['famille']),
219
								  $html = '<strong>Famille</strong> : ' . strtoupper($obs['famille']),
225
								  $border = 'LTR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
220
								  $border = 'LTR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
226
 
221
 
227
 
222
 
228
		/*
223
		/*
229
		// taxon
224
		// taxon
230
		// la taille maximum en bdtfx est 115 caractères UTF-8 (num_nom: 101483)
225
		// la taille maximum en bdtfx est 115 caractères UTF-8 (num_nom: 101483)
231
		// SELECT num_nom, CONCAT(nom_sci, ' ', auteur) AS a, CHAR_LENGTH(CONCAT(nom_sci, ' ', auteur)) FROM bdtfx_v1_01 ORDER BY CHAR_LENGTH(a) DESC limit 2;
226
		// SELECT num_nom, CONCAT(nom_sci, ' ', auteur) AS a, CHAR_LENGTH(CONCAT(nom_sci, ' ', auteur)) FROM bdtfx_v1_01 ORDER BY CHAR_LENGTH(a) DESC limit 2;
232
		$nom = '<em>' . $obs['nom_ret'] . '</em>';
227
		$nom = '<em>' . $obs['nom_ret'] . '</em>';
233
		if($obs['certitude'] && stripos($obs['certitude'], 'certain') === false) {
228
		if($obs['certitude'] && stripos($obs['certitude'], 'certain') === false) {
234
			$nom .= ' (' . $obs['certitude'] . ')';
229
			$nom .= ' (' . $obs['certitude'] . ')';
235
		}
230
		}
236
		$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '',  '',
231
		$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '',  '',
237
								  //$html = '<strong>Espèce</strong> : ' . self::elude('Espèce : ', $obs['nom_ret'], 2),
232
								  //$html = '<strong>Espèce</strong> : ' . self::elude('Espèce : ', $obs['nom_ret'], 2),
238
								  //$html = $this->elude('<strong>Taxon</strong> : ' . $nom, 3),
233
								  //$html = $this->elude('<strong>Taxon</strong> : ' . $nom, 3),
239
								  $html = '<strong>Taxon</strong> : ' . $nom, // on ne strip pas le nom de taxon, car pas plus de 3 lignes
234
								  $html = '<strong>Taxon</strong> : ' . $nom, // on ne strip pas le nom de taxon, car pas plus de 3 lignes
240
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
235
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
241
		*/
236
		*/
242
 
237
 
243
		// ou bien nom saisi...
238
		// ou bien nom saisi...
244
		// la taille maximum dans cel_obs au 12/07/2013 est 112 caractères UTF-8 (id_observation: 787762)
239
		// la taille maximum dans cel_obs au 12/07/2013 est 112 caractères UTF-8 (id_observation: 787762)
245
		// SELECT id_observation, TRIM(nom_sel), CHAR_LENGTH(TRIM(nom_sel)) FROM cel_obs ORDER BY CHAR_LENGTH(TRIM(nom_sel)) DESC LIMIT 2;
240
		// SELECT id_observation, TRIM(nom_sel), CHAR_LENGTH(TRIM(nom_sel)) FROM cel_obs ORDER BY CHAR_LENGTH(TRIM(nom_sel)) DESC LIMIT 2;
246
		$nom = '<em>' . $obs['nom_sel'] . '</em>';
241
		$nom = '<em>' . $obs['nom_sel'] . '</em>';
247
		if($obs['certitude'] && stripos($obs['certitude'], 'certain') === false) {
242
		if($obs['certitude'] && stripos($obs['certitude'], 'certain') === false) {
248
			$nom .= ' (' . $obs['certitude'] . ')';
243
			$nom .= ' (' . $obs['certitude'] . ')';
249
		}
244
		}
250
		$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '',  '',
245
		$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '',  '',
251
								  //$html = '<strong>Espèce</strong> : ' . self::elude('Espèce : ', $obs['nom_ret'], 2),
246
								  //$html = '<strong>Espèce</strong> : ' . self::elude('Espèce : ', $obs['nom_ret'], 2),
252
								  //$html = $this->elude('<strong>Taxon</strong> : ' . $nom, 3),
247
								  //$html = $this->elude('<strong>Taxon</strong> : ' . $nom, 3),
253
								  $html = '<strong>Taxon</strong> : ' . mb_substr(trim($nom), 0, 115, 'UTF-8'), // on ne strip pas le nom sélectionné, car pas plus de 3 lignes, mais on assure la mise en page
248
								  $html = '<strong>Taxon</strong> : ' . mb_substr(trim($nom), 0, 115, 'UTF-8'), // on ne strip pas le nom sélectionné, car pas plus de 3 lignes, mais on assure la mise en page
254
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
249
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
255
 
250
 
256
		// collecteur
251
		// collecteur
257
		// TODO: pseudo
252
		// TODO: pseudo
258
		$limite_nom = 26;
253
		$limite_nom = 26;
259
		$prenom = $obs['prenom_utilisateur'];
254
		$prenom = $obs['prenom_utilisateur'];
260
		if(mb_strlen($prenom . ' ' . $obs['nom_utilisateur'], 'UTF-8') > $limite_nom) {
255
		if(mb_strlen($prenom . ' ' . $obs['nom_utilisateur'], 'UTF-8') > $limite_nom) {
261
			$prenom = mb_substr($prenom, 0, 26 - mb_strlen($obs['nom_utilisateur'], 'UTF-8') - 1 /* espace */ - 1 /* … */, 'UTF-8') . '…';
256
			$prenom = mb_substr($prenom, 0, 26 - mb_strlen($obs['nom_utilisateur'], 'UTF-8') - 1 /* espace */ - 1 /* … */, 'UTF-8') . '…';
262
			//var_dump($prenom);die;
257
			//var_dump($prenom);die;
263
		}
258
		}
264
		$this->pdf->writeHTMLCell($w = $width - 25, '', '', '',
259
		$this->pdf->writeHTMLCell($w = $width - 25, '', '', '',
265
								  $html = '<strong>Collecteur</strong> : ' . $prenom . ' ' . $obs['nom_utilisateur'],
260
								  $html = '<strong>Collecteur</strong> : ' . $prenom . ' ' . $obs['nom_utilisateur'],
266
								  $border = 'L', $ln = 0, $fill = false, $reset = true, $align = 'L', $autopadding = true);
261
								  $border = 'L', $ln = 0, $fill = false, $reset = true, $align = 'L', $autopadding = true);
267
 
262
 
268
		// N°: TODO: writeHTMLCell() semble bugger
263
		// N°: TODO: writeHTMLCell() semble bugger
269
		$this->pdf->Cell($w = 25, '',
264
		$this->pdf->Cell($w = 25, '',
270
						 $txt = 'N° : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre'])
265
						 $txt = 'N° : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre'])
271
						 $border = 'R', $ln = 1, $align = 'R', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
266
						 $border = 'R', $ln = 1, $align = 'R', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
272
		/*$this->pdf->writeHTMLCell($w = 30, '', '', '',
267
		/*$this->pdf->writeHTMLCell($w = 30, '', '', '',
273
								  $html = '<strong>N°</strong> : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre']),
268
								  $html = '<strong>N°</strong> : ' . $obs['id_observation'], //. sprintf("%04d", $obs['ordre']),
274
								  $border = 'R', $ln = 1, $fill = true, $reset = true, $align = 'L', $autopadding = true);*/
269
								  $border = 'R', $ln = 1, $fill = true, $reset = true, $align = 'L', $autopadding = true);*/
275
 
270
 
276
		// localité
271
		// localité
277
		// TODO: département
272
		// TODO: département
278
		// TEST: Corse (2A, 2B)
273
		// TEST: Corse (2A, 2B)
279
		$info_dep = "<strong>Localité</strong> : %s";
274
		$info_dep = "<strong>Localité</strong> : %s";
280
		$donnees_dep = array($obs['zone_geo']);
275
		$donnees_dep = array($obs['zone_geo']);
281
		if($obs['ce_zone_geo']) {
276
		if($obs['ce_zone_geo']) {
282
			$info_dep .= " (%s)";
277
			$info_dep .= " (%s)";
283
			if(strpos($obs['ce_zone_geo'], 'INSEE') !== false) $donnees_dep[] = preg_replace('/^[^\d]*(\d\d).*/', '\1', $obs['ce_zone_geo']);
278
			if(strpos($obs['ce_zone_geo'], 'INSEE') !== false) $donnees_dep[] = preg_replace('/^[^\d]*(\d\d).*/', '\1', $obs['ce_zone_geo']);
284
			else $donnees_dep[] = $obs['ce_zone_geo'];
279
			else $donnees_dep[] = $obs['ce_zone_geo'];
285
		}
280
		}
286
 
281
 
287
		$info_loc = '';
282
		$info_loc = '';
288
		$donnees_loc = array();
283
		$donnees_loc = array();
289
		if($obs['lieudit']) {
284
		if($obs['lieudit']) {
290
			$info_loc = "%s";
285
			$info_loc = "%s";
291
			$donnees_loc[] = $obs['lieudit'];
286
			$donnees_loc[] = $obs['lieudit'];
292
		}
287
		}
293
		if($obs['station']) {
288
		if($obs['station']) {
294
			$info_loc .= ", %s";
289
			$info_loc .= ", %s";
295
			$donnees_loc[] = $obs['station'];
290
			$donnees_loc[] = $obs['station'];
296
		}
291
		}
297
		if($obs['milieu']) {
292
		if($obs['milieu']) {
298
			$info_loc .= " [%s]";
293
			$info_loc .= " [%s]";
299
			$donnees_loc[] = $obs['milieu'];
294
			$donnees_loc[] = $obs['milieu'];
300
		}
295
		}
301
		$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '', '',
296
		$this->pdf->writeHTMLCell($w = $width, $lh * 3.5, '', '',
302
								  //$html = "<strong>Localité</strong> : " .
297
								  //$html = "<strong>Localité</strong> : " .
303
								  //self::elude('Localité : ', sprintf("%s (%s)\n%s, %s [%s]", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station'], $obs['milieu'] ), 3),
298
								  //self::elude('Localité : ', sprintf("%s (%s)\n%s, %s [%s]", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station'], $obs['milieu'] ), 3),
304
								  // $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),
299
								  // $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),
305
								  $html = $this->elude(vsprintf($info_dep, $donnees_dep), 2) . "\n" .
300
								  $html = $this->elude(vsprintf($info_dep, $donnees_dep), 2) . "\n" .
306
								  $this->elude(vsprintf($info_loc, $donnees_loc), 2),
301
								  $this->elude(vsprintf($info_loc, $donnees_loc), 2),
307
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
302
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
308
 
303
 
309
		// lon/lat/alt
304
		// lon/lat/alt
310
		$info_geo = '';
305
		$info_geo = '';
311
		$donnees = array();
306
		$donnees = array();
312
		if($obs['latitude'] && $obs['longitude'] /* TODO: clean DB ! */ && $obs['latitude'] != 0.00000) {
307
		if($obs['latitude'] && $obs['longitude'] /* TODO: clean DB ! */ && $obs['latitude'] != 0.00000) {
313
			$info_geo .= "%.5f N  /  %.5f E";
308
			$info_geo .= "%.5f N  /  %.5f E";
314
			array_push($donnees, $obs['latitude'], $obs['longitude']);
309
			array_push($donnees, $obs['latitude'], $obs['longitude']);
315
		}
310
		}
316
		if($obs['altitude']) {
311
		if($obs['altitude']) {
317
			$info_geo .= ", %dm";
312
			$info_geo .= ", %dm";
318
			array_push($donnees, $obs['altitude']);
313
			array_push($donnees, $obs['altitude']);
319
		}
314
		}
320
		$this->pdf->writeHTMLCell($w = $width, '', '', '',
315
		$this->pdf->writeHTMLCell($w = $width, '', '', '',
321
								  $html = vsprintf("<strong>Lat. / Lon. , Alt.</strong> : " . $info_geo, $donnees),
316
								  $html = vsprintf("<strong>Lat. / Lon. , Alt.</strong> : " . $info_geo, $donnees),
322
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
317
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
323
 
318
 
324
		// commentaire
319
		// commentaire
325
		$this->pdf->writeHTMLCell($w = $width, $lh * 4.5, '', '',
320
		$this->pdf->writeHTMLCell($w = $width, $lh * 4.5, '', '',
326
								  //$html = '<strong>Observation</strong> : ' . self::elude('Observation : ', $obs['commentaire']),
321
								  //$html = '<strong>Observation</strong> : ' . self::elude('Observation : ', $obs['commentaire']),
327
								  $html = self::elude('<strong>Observations</strong> : ' . $obs['commentaire'], 4),
322
								  $html = self::elude('<strong>Observations</strong> : ' . $obs['commentaire'], 4),
328
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
323
								  $border = 'LR', $ln = 1, $fill = false, $reset = true, $align = 'L', $autopadding = true);
329
 
324
 
330
		// date, note: en 64 bits, strtotime() renvoi un entier négatif (!= FALSE) pour l'an 0
325
		// date, note: en 64 bits, strtotime() renvoi un entier négatif (!= FALSE) pour l'an 0
331
		if(strncmp("0000", $obs['date_observation'], 4) == 0) $temps = false;
326
		if(strncmp("0000", $obs['date_observation'], 4) == 0) $temps = false;
332
		else $temps = strtotime($obs['date_observation']);
327
		else $temps = strtotime($obs['date_observation']);
333
		$this->pdf->writeHTMLCell($w = $width, '', '', '',
328
		$this->pdf->writeHTMLCell($w = $width, '', '', '',
334
								  $html = '<strong>Date de récolte</strong> : ' . ($temps ? strftime("%d/%m/%Y", $temps) : '               '),
329
								  $html = '<strong>Date de récolte</strong> : ' . ($temps ? strftime("%d/%m/%Y", $temps) : '               '),
335
								  $border = 'LBR', $ln = 1, $fill = false, $reset = true, $align = 'R', $autopadding = true);
330
								  $border = 'LBR', $ln = 1, $fill = false, $reset = true, $align = 'R', $autopadding = true);
336
 
331
 
337
	}
332
	}
338
 
333
 
339
	function docell($obs) {
334
	function docell($obs) {
340
		$this->pdf->setCellMargins(0,0,0,0);
335
		$this->pdf->setCellMargins(0,0,0,0);
341
 
336
 
342
		$this->pdf->Cell($w = 60, '',
337
		$this->pdf->Cell($w = 60, '',
343
						 $txt = 'Famille : ' . $obs['famille'],
338
						 $txt = 'Famille : ' . $obs['famille'],
344
						 $border = 'LT', $ln = 0, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
339
						 $border = 'LT', $ln = 0, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
345
 
340
 
346
		$this->pdf->Cell($w = 20, '',
341
		$this->pdf->Cell($w = 20, '',
347
						 $txt = 'N° : ' . $obs['id_observation'] /*. sprintf("%04d", $obs['ordre']) */,
342
						 $txt = 'N° : ' . $obs['id_observation'] /*. sprintf("%04d", $obs['ordre']) */,
348
						 $border = 'TR', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
343
						 $border = 'TR', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
349
 
344
 
350
		$this->pdf->Cell($w = 80, '',
345
		$this->pdf->Cell($w = 80, '',
351
						 $txt = 'Espèce : ' . $obs['nom_ret'],
346
						 $txt = 'Espèce : ' . $obs['nom_ret'],
352
						 $border = 'RL', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
347
						 $border = 'RL', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
353
 
348
 
354
		$this->pdf->Cell($w = 80, '',
349
		$this->pdf->Cell($w = 80, '',
355
						 $txt = 'Collecteur : ' . $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
350
						 $txt = 'Collecteur : ' . $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
356
						 $border = 'RL', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
351
						 $border = 'RL', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
357
 
352
 
358
		$this->pdf->MultiCell(80, 20,
353
		$this->pdf->MultiCell(80, 20,
359
							  $txt = sprintf("Localité : %s (%s)\n%s, %s", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station']),
354
							  $txt = sprintf("Localité : %s (%s)\n%s, %s", $obs['zone_geo'], $obs['ce_zone_geo'], $obs['lieudit'], $obs['station']),
360
							  $border = 'RL', 'L', 0, 1, '', '', true);
355
							  $border = 'RL', 'L', 0, 1, '', '', true);
361
 
356
 
362
		$this->pdf->Cell($w = 80, '',
357
		$this->pdf->Cell($w = 80, '',
363
						 $txt = sprintf("Latitude, Longitude : %s  /  %s", $obs['latitude'], $obs['longitude']),
358
						 $txt = sprintf("Latitude, Longitude : %s  /  %s", $obs['latitude'], $obs['longitude']),
364
						 $border = 'RL', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
359
						 $border = 'RL', $ln = 1, $align = 'L', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
365
 
360
 
366
		$this->pdf->MultiCell(80, 20,
361
		$this->pdf->MultiCell(80, 20,
367
							  $txt = 'Observation : ' . self::elude('Observation : ', $obs['commentaire']),
362
							  $txt = 'Observation : ' . self::elude('Observation : ', $obs['commentaire']),
368
							  $border = 'RL', 'L', 0, 1, '', '', true); 
363
							  $border = 'RL', 'L', 0, 1, '', '', true);
369
 
364
 
370
		$this->pdf->Cell($w = 80, '',
365
		$this->pdf->Cell($w = 80, '',
371
						 $txt = 'Date : ' . strftime("%d/%m/%Y", strtotime($obs['date_observation'])),
366
						 $txt = 'Date : ' . strftime("%d/%m/%Y", strtotime($obs['date_observation'])),
372
						 $border = 'LBR', $ln = 1, $align = 'R', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
367
						 $border = 'LBR', $ln = 1, $align = 'R', $fill = false, $link = false, $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M');
373
	}
368
	}
374
 
369
 
375
 
370
 
376
	// singe la propriété CSS3 "text-overflow" : "ellipsis"
371
	// singe la propriété CSS3 "text-overflow" : "ellipsis"
377
	function elude_bis($intitule, $commentaire, $lignes = 3) {
372
	function elude_bis($intitule, $commentaire, $lignes = 3) {
378
		// TODO: GetLineWidth, GetCharWidth()
373
		// TODO: GetLineWidth, GetCharWidth()
379
		$limite = $lignes /* lignes */ * 43 /* caractères */ - strlen($intitule);
374
		$limite = $lignes /* lignes */ * 43 /* caractères */ - strlen($intitule);
380
		if(mb_strlen($commentaire, 'UTF-8') < $limite) return $commentaire;
375
		if(mb_strlen($commentaire, 'UTF-8') < $limite) return $commentaire;
381
		return mb_substr($commentaire, 0, $limite - 2) . '…';
376
		return mb_substr($commentaire, 0, $limite - 2) . '…';
382
	}
377
	}
383
 
378
 
384
 
379
 
385
	function export1($observations) {
380
	function export1($observations) {
386
		$pdf = &$this->pdf;
381
		$pdf = &$this->pdf;
387
		// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
382
		// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
388
 
383
 
389
		$pdf->setEqualColumns(2);
384
		$pdf->setEqualColumns(2);
390
 
385
 
391
		$i = 0;
386
		$i = 0;
392
		while($i < count($observations)) {
387
		while($i < count($observations)) {
393
			$obs = $observations[$i];
388
			$obs = $observations[$i];
394
 
389
 
395
			$pdf->selectColumn(0);
390
			$pdf->selectColumn(0);
396
			// Multicell test
391
			// Multicell test
397
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
392
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
398
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
393
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
399
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
394
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 1, 1, '', '', true);
400
			$pdf->Ln();
395
			$pdf->Ln();
401
 
396
 
402
			$pdf->selectColumn(1);
397
			$pdf->selectColumn(1);
403
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
398
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
404
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
399
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
405
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
400
			$pdf->MultiCell(0, 25, self::doTemplate($obs), 1, 'L', 0, 1, '', '', true);
406
 
401
 
407
			$i += 6;
402
			$i += 6;
408
			if(isset($observations[$i])) $pdf->AddPage();
403
			if(isset($observations[$i])) $pdf->AddPage();
409
		}
404
		}
410
	}
405
	}
411
 
406
 
412
	static function doTemplate($obs) {
407
	static function doTemplate($obs) {
413
		$pattern =
408
		$pattern =
414
<<<EOF
409
<<<EOF
415
Famille: %s (%d)
410
Famille: %s (%d)
416
Espèce: %s
411
Espèce: %s
417
Collecteur: %s
412
Collecteur: %s
418
Localité: %s
413
Localité: %s
419
Observation: %s	 Date: %s
414
Observation: %s	 Date: %s
420
EOF;
415
EOF;
421
		return sprintf($pattern,
416
		return sprintf($pattern,
422
 
417
 
423
					   $obs['famille'],
418
					   $obs['famille'],
424
					   $obs['ordre'],
419
					   $obs['ordre'],
425
					   $obs['nom_ret'],
420
					   $obs['nom_ret'],
426
					   $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
421
					   $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
427
					   $obs['zone_geo'],
422
					   $obs['zone_geo'],
428
					   $obs['commentaire'],
423
					   $obs['commentaire'],
429
					   strftime("%Y-%m-%d", strtotime($obs['date_observation']))
424
					   strftime("%Y-%m-%d", strtotime($obs['date_observation']))
430
		);
425
		);
431
					  
426
 
432
	}
427
	}
433
 
428
 
434
 
429
 
435
 
430
 
436
	function export2($observations) {
431
	function export2($observations) {
437
		$pdf = &$this->pdf;
432
		$pdf = &$this->pdf;
438
 
433
 
439
		$pdf->setEqualColumns(2);
434
		$pdf->setEqualColumns(2);
440
 
435
 
441
		$i = 0;
436
		$i = 0;
442
		$y = $pdf->getY();
437
		$y = $pdf->getY();
443
		$x = $pdf->getX();
438
		$x = $pdf->getX();
444
		while($i < count($observations)) {
439
		while($i < count($observations)) {
445
			$obs = $observations[$i++];
440
			$obs = $observations[$i++];
446
 
441
 
447
			$pdf->selectColumn(0);
442
			$pdf->selectColumn(0);
448
			// Multicell test
443
			// Multicell test
449
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 0, self::doHTMLTemplate($obs), 1, 0, 0, true);
444
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 0, self::doHTMLTemplate($obs), 1, 0, 0, true);
450
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 1, self::doHTMLTemplate($obs), 1, 0, 0, true);
445
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 1, self::doHTMLTemplate($obs), 1, 0, 0, true);
451
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 2, self::doHTMLTemplate($obs), 1, 0, 0, true);
446
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 2, self::doHTMLTemplate($obs), 1, 0, 0, true);
452
			//$pdf->Ln();
447
			//$pdf->Ln();
453
 
448
 
454
			$pdf->selectColumn(1);
449
			$pdf->selectColumn(1);
455
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 0, self::doHTMLTemplate($obs), 1, 1, 1, true);
450
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 0, self::doHTMLTemplate($obs), 1, 1, 1, true);
456
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 1, self::doHTMLTemplate($obs), 1, 1, 1, true);
451
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 1, self::doHTMLTemplate($obs), 1, 1, 1, true);
457
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 2, self::doHTMLTemplate($obs), 1, 1, 1, true);
452
			$pdf->writeHTMLCell(0, 25, $x, $y + 25 * 2, self::doHTMLTemplate($obs), 1, 1, 1, true);
458
 
453
 
459
			$i += 6;
454
			$i += 6;
460
			if(isset($observations[$i])) $pdf->AddPage();
455
			if(isset($observations[$i])) $pdf->AddPage();
461
		}
456
		}
462
	}
457
	}
463
 
458
 
464
	static function doHTMLTemplate($obs) {
459
	static function doHTMLTemplate($obs) {
465
		$pattern =
460
		$pattern =
466
<<<EOF
461
<<<EOF
467
<p>Famille: %s <span style="text-align: right">(%d)</span><br/>
462
<p>Famille: %s <span style="text-align: right">(%d)</span><br/>
468
Espèce: %s<br/>
463
Espèce: %s<br/>
469
Collecteur: %s<br/>
464
Collecteur: %s<br/>
470
Localité: %s<br/>
465
Localité: %s<br/>
471
Observation: %s	 Date: %s</p>
466
Observation: %s	 Date: %s</p>
472
EOF;
467
EOF;
473
		return sprintf($pattern,
468
		return sprintf($pattern,
474
 
469
 
475
					   $obs['famille'],
470
					   $obs['famille'],
476
					   $obs['ordre'],
471
					   $obs['ordre'],
477
					   $obs['nom_ret'],
472
					   $obs['nom_ret'],
478
					   $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
473
					   $obs['prenom_utilisateur'] . ' ' . $obs['nom_utilisateur'],
479
					   $obs['zone_geo'],
474
					   $obs['zone_geo'],
480
					   $obs['commentaire'],
475
					   $obs['commentaire'],
481
					   strftime("%Y-%m-%d", strtotime($obs['date_observation']))
476
					   strftime("%Y-%m-%d", strtotime($obs['date_observation']))
482
		);
477
		);
483
					  
478
 
484
	}
479
	}
485
 
480
 
486
}
481
}