Subversion Repositories eFlore/Applications.cel

Rev

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

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