1 |
<?php |
2 |
/** |
3 |
* Ce script permet de g�n�rer un fichier pdf repr�sentant une �dition |
4 |
* "Etat" en fonction de param�tres dans la table om_etat |
5 |
* |
6 |
* @package openmairie_exemple |
7 |
* @version SVN : $Id: pdfetat.php 1811 2012-09-28 10:09:12Z nhaye $ |
8 |
*/ |
9 |
|
10 |
require_once "../obj/utils.class.php"; |
11 |
$f = new utils("nohtml"); |
12 |
$f->disableLog(); |
13 |
|
14 |
/** |
15 |
* |
16 |
*/ |
17 |
// Identifiant de l'�dition � g�n�rer (champ id de la table om_etat) |
18 |
(isset($_POST['obj']) ? $obj = $_POST['obj'] : $obj = ""); |
19 |
// Identifiant de l'�l�ment concern� par l'�dition |
20 |
(isset($_POST['idxConsultations']) ? $idxConsultations = $_POST['idxConsultations'] : $idxConsultations = ""); |
21 |
// L'attribut collectivite de la classe utils est un tableau de param�tres |
22 |
$collectivite = $f->collectivite; |
23 |
// Variable permettant de stocker l'identifiant de la collectivit� de niveau 2 |
24 |
$niveau = ""; |
25 |
/** |
26 |
* Gestion de la s�lection des param�tres de l'�dition � g�n�rer |
27 |
* en fonction du param�tre actif et/ou du niveau de la collectivit� |
28 |
*/ |
29 |
// On r�cup�re l'enregistrement 'om_etat' de la collectivit� en cours dans |
30 |
// l'�tat 'actif' |
31 |
$sql = " select * from ".DB_PREFIXE."om_etat "; |
32 |
$sql .= " where id='".$obj."' "; |
33 |
$sql .= " and actif IS TRUE "; |
34 |
$sql .= " and om_collectivite='".$_SESSION['collectivite']."' "; |
35 |
$res1 = $f->db->query($sql); |
36 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
37 |
$f->isDatabaseError($res1); |
38 |
// Si on obtient aucun r�sultat |
39 |
if ($res1->numrows() == 0) { |
40 |
// On lib�re le r�sultat de la requ�te pr�c�dente |
41 |
$res1->free(); |
42 |
// On r�cup�re l'identifiant de la collectivit� de niveau 2 |
43 |
$sql = " select om_collectivite from ".DB_PREFIXE."om_collectivite "; |
44 |
$sql .= " where niveau='2' "; |
45 |
$niveau = $f->db->getone($sql); |
46 |
$f->addToLog("pdfetat.php: db->getone(\"".$sql."\");", VERBOSE_MODE); |
47 |
$f->isDatabaseError($niveau); |
48 |
// On r�cup�re l'enregistrement 'om_etat' de la collectivit� de niveau |
49 |
// 2 dans l'�tat 'actif' |
50 |
$sql = " select * from ".DB_PREFIXE."om_etat "; |
51 |
$sql .= " where id='".$obj."' "; |
52 |
$sql .= " and actif IS TRUE "; |
53 |
$sql .= " and om_collectivite='".$niveau."' "; |
54 |
$res1 = $f->db->query($sql); |
55 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
56 |
$f->isDatabaseError($res1); |
57 |
// Si on obtient aucun r�sultat |
58 |
if ($res1->numrows() == 0) { |
59 |
// On lib�re le r�sultat de la requ�te pr�c�dente |
60 |
$res1->free(); |
61 |
// On r�cup�re l'enregistrement 'om_etat' de la collectivit� de |
62 |
// niveau 2 dans n'importe quel �tat |
63 |
$sql = " select * from ".DB_PREFIXE."om_etat "; |
64 |
$sql .= " where id='".$obj."' "; |
65 |
$sql .= " and om_collectivite='".$niveau."' "; |
66 |
$res1 = $f->db->query($sql); |
67 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
68 |
$f->isDatabaseError($res1); |
69 |
} |
70 |
} |
71 |
|
72 |
/** |
73 |
* |
74 |
*/ |
75 |
// |
76 |
set_time_limit(180); |
77 |
// |
78 |
require_once PATH_OPENMAIRIE."fpdf_etat.php"; |
79 |
class somePDF extends PDF { |
80 |
|
81 |
function Footer() { |
82 |
// surcharge fpdf |
83 |
//Pied de page |
84 |
//Positionnement a 1,5 cm du bas |
85 |
$this->SetY(-15); |
86 |
//Police Arial italique 8 |
87 |
$this->SetFont('Arial', 'I', 8); |
88 |
} |
89 |
} |
90 |
/** |
91 |
* |
92 |
*/ |
93 |
// |
94 |
while ($edition =& $res1->fetchRow(DB_FETCHMODE_ASSOC)) { |
95 |
|
96 |
/** |
97 |
* |
98 |
*/ |
99 |
// |
100 |
$pdf = new somePDF($edition["orientation"], "mm", $edition["format"]); |
101 |
// |
102 |
$pdf->footerfont=$edition["footerfont"]; |
103 |
$pdf->footertaille=$edition["footertaille"]; |
104 |
$pdf->footerattribut=$edition["footerattribut"]; |
105 |
// |
106 |
$pdf->SetMargins($edition['se_margeleft'],$edition['se_margetop'],$edition['se_margeright']); //marge gauche,haut,droite par defaut 10mm |
107 |
// |
108 |
$pdf->SetDisplayMode('real', 'single'); |
109 |
// D�finit un alias pour le nombre total de pages |
110 |
$pdf->AliasNbPages(); |
111 |
|
112 |
foreach ($idxConsultations as $idx) { |
113 |
|
114 |
// Ajoute une nouvelle page � l'�dition |
115 |
$pdf->AddPage(); |
116 |
|
117 |
/** |
118 |
* Affichage du logo |
119 |
*/ |
120 |
// R�cup�ration du path du logo � afficher |
121 |
$path_logo = $f->getPathFolderTrs().$edition['logo']; |
122 |
// Placement d'une image - aucune dimension explicite, auquel cas l'image |
123 |
// est dimensionn�e en 96 dpi |
124 |
if(file_exists($path_logo)) { |
125 |
$pdf->Image($path_logo, $edition["logoleft"], $edition["logotop"], 0, 0); |
126 |
} |
127 |
|
128 |
/** |
129 |
* |
130 |
*/ |
131 |
// Variables statiques contenant des param�tres � remplacer |
132 |
$sql = $edition['om_sql']; |
133 |
if (DBCHARSET == "UTF8") { |
134 |
$titre = utf8_decode($edition["titre"]); |
135 |
$corps = utf8_decode($edition["corps"]); |
136 |
} else { |
137 |
$titre = $edition["titre"]; |
138 |
$corps = $edition["corps"]; |
139 |
} |
140 |
|
141 |
// Remplacement des param�tres dans le fichier ../dyn/varetatpdf.inc |
142 |
if (file_exists("../dyn/varetatpdf.inc")) { |
143 |
include "../dyn/varetatpdf.inc"; |
144 |
} |
145 |
|
146 |
// Ex�cution de la requ�te SQL de l'�dition |
147 |
$res = $f->db->query($sql); |
148 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
149 |
$f->isDatabaseError($res); |
150 |
|
151 |
// |
152 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
153 |
|
154 |
////// |
155 |
// TITRE |
156 |
////// |
157 |
|
158 |
// Explosion des champs � r�cup�rer depuis la requ�te |
159 |
$temp = explode("[", $titre); |
160 |
// |
161 |
for ($i = 1; $i < sizeof($temp); $i++) { |
162 |
// |
163 |
$temp1 = explode("]", $temp[$i]); |
164 |
// |
165 |
if (DBCHARSET == "UTF8") { |
166 |
$titre = str_replace("[".$temp1[0]."]", utf8_decode($row[$temp1[0]]), $titre); |
167 |
} else { |
168 |
$titre = str_replace("[".$temp1[0]."]", $row[$temp1[0]], $titre); |
169 |
} |
170 |
// |
171 |
$temp1[0] = ""; |
172 |
} |
173 |
|
174 |
// |
175 |
$element = $titre; |
176 |
// On teste si une balise <b> est pr�sente dans l'�l�ment |
177 |
if (strpos($element, "<b>") === false) { |
178 |
// => Aucune balise <b> n'est pr�sente dans l'�l�ment |
179 |
// |
180 |
if (trim($element) != "") { |
181 |
// |
182 |
$pdf->SetFont($edition["titrefont"], $edition["titreattribut"], $edition["titretaille"]); |
183 |
$pdf->SetXY($edition["titreleft"], $edition["titretop"]); |
184 |
$pdf->MultiCell($edition["titrelargeur"], $edition["titrehauteur"], $element, $edition["titrebordure"], $edition["titrealign"], 0); |
185 |
} |
186 |
} else { |
187 |
// => Une balise <b> est pr�sente dans l'�l�ment |
188 |
// |
189 |
$pdf->SetY($edition["titretop"]); |
190 |
// |
191 |
$element_part1 = ""; |
192 |
$element_part1 = explode("<b>", $element); |
193 |
// |
194 |
for ($x = 0; $x < sizeof($element_part1); $x++) { |
195 |
// |
196 |
if (strpos($element_part1[$x], "</b>") === false) { |
197 |
// => |
198 |
// |
199 |
if (trim($element_part1[$x]) != "") { |
200 |
// |
201 |
$pdf->SetFont($edition["titrefont"], $edition["titreattribut"], $edition["titretaille"]); |
202 |
$pdf->SetX($edition["titreleft"]); |
203 |
$pdf->MultiCell($edition["titrelargeur"], $edition["titrehauteur"], $element_part1[$x], $edition["titrebordure"], $edition["titrealign"], 0); |
204 |
} |
205 |
} else { |
206 |
// => |
207 |
// |
208 |
$ctrl_fin_b = 0; |
209 |
$ctrl_fin_b = substr_count($element_part1[$x], "</b>"); |
210 |
// |
211 |
$edition["titreattribut"] = str_replace("B", "", $edition["titreattribut"]); |
212 |
$edition["titreattribut"] = str_replace("b", "", $edition["titreattribut"]); |
213 |
// |
214 |
if ($ctrl_fin_b > 1) { |
215 |
// => nbr </b> superieur a 1 |
216 |
// |
217 |
if (trim($element_part1[$x]) != "") { |
218 |
// |
219 |
$pdf->SetFont($edition["titrefont"], "B".$edition["titreattribut"], $edition["titretaille"]); |
220 |
$pdf->SetX($edition["titreleft"]); |
221 |
$pdf->MultiCell($edition["titrelargeur"], $edition["titrehauteur"], $element_part1[$x], $edition["titrebordure"], $edition["titrealign"], 0); |
222 |
} |
223 |
} else { |
224 |
// => |
225 |
// |
226 |
$element_part2 = explode("</b>", $element_part1[$x]); |
227 |
// |
228 |
if (trim($element_part2[0]) != "") { |
229 |
// |
230 |
$pdf->SetFont($edition["titrefont"], "B".$edition["titreattribut"], $edition["titretaille"]); |
231 |
$pdf->SetX($edition["titreleft"]); |
232 |
$pdf->MultiCell($edition["titrelargeur"], $edition["titrehauteur"], $element_part2[0], $edition["titrebordure"], $edition["titrealign"], 0); |
233 |
} |
234 |
// |
235 |
if (trim($element_part2[1]) != "") { |
236 |
// |
237 |
$pdf->SetFont($edition["titrefont"], $edition["titreattribut"], $edition["titretaille"]); |
238 |
$pdf->SetX($edition["titreleft"]); |
239 |
$pdf->MultiCell($edition["titrelargeur"], $edition["titrehauteur"], $element_part2[1], $edition["titrebordure"], $edition["titrealign"], 0); |
240 |
} |
241 |
} |
242 |
} |
243 |
} |
244 |
} |
245 |
|
246 |
////// |
247 |
// CORPS |
248 |
////// |
249 |
|
250 |
// Explosion des champs � r�cup�rer depuis la requ�te |
251 |
$temp = explode("[", $edition["corps"]); |
252 |
// |
253 |
for ($i = 1; $i < sizeof($temp); $i++) { |
254 |
// |
255 |
$temp1 = explode("]", $temp[$i]); |
256 |
// |
257 |
if (DBCHARSET == "UTF8") { |
258 |
$corps = str_replace("[".$temp1[0]."]", utf8_decode($row[$temp1[0]]), $corps); |
259 |
} else { |
260 |
$corps = str_replace("[".$temp1[0]."]", $row[$temp1[0]], $corps); |
261 |
} |
262 |
// |
263 |
$temp1[0] = ""; |
264 |
} |
265 |
// |
266 |
if (strstr($corps, "\p")) { |
267 |
// |
268 |
$temp = ""; |
269 |
$temp = explode("\p", $corps); |
270 |
|
271 |
// |
272 |
$element = $temp[0]; |
273 |
// On teste si une balise <b> est pr�sente dans l'�l�ment |
274 |
if (strpos($element, "<b>") === false) { |
275 |
// => Aucune balise <b> n'est pr�sente dans l'�l�ment |
276 |
// |
277 |
if (trim($element) != "") { |
278 |
// |
279 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
280 |
$pdf->SetXY($edition["corpsleft"], $edition["corpstop"]); |
281 |
$pdf->MultiCell($edition["corpslargeur"], $edition["corpshauteur"], $element, $edition["corpsbordure"], $edition["corpsalign"], 0); |
282 |
} |
283 |
} else { |
284 |
// => Une balise <b> est pr�sente dans l'�l�ment |
285 |
// |
286 |
$pdf->SetXY($edition["corpsleft"], $edition["corpstop"]); |
287 |
// |
288 |
$element_part1 = ""; |
289 |
$element_part1 = explode("<b>", $element); |
290 |
// |
291 |
for ($x = 0; $x < sizeof($element_part1); $x++) { |
292 |
// |
293 |
if (strpos($element_part1[$x], "</b>") === false) { |
294 |
// => |
295 |
// |
296 |
if (trim($element_part1[$x]) != "") { |
297 |
// |
298 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
299 |
$pdf->write($edition["corpshauteur"], $element_part1[$x]); |
300 |
} |
301 |
} else { |
302 |
// => |
303 |
// |
304 |
$ctrl_fin_b = 0; |
305 |
$ctrl_fin_b = substr_count($element_part1[$x], "</b>"); |
306 |
// |
307 |
$edition["corpsattribut"] = str_replace("B", "", $edition["corpsattribut"]); |
308 |
$edition["corpsattribut"] = str_replace("b", "", $edition["corpsattribut"]); |
309 |
// |
310 |
if ($ctrl_fin_b > 1) { |
311 |
// => nbr </b> superieur a 1 |
312 |
// |
313 |
if (trim($element_part1[$x]) != "") { |
314 |
// |
315 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
316 |
$pdf->write($edition["corpshauteur"], $element_part1[$x]); |
317 |
} |
318 |
} else { |
319 |
// => |
320 |
// |
321 |
$element_part2 = explode("</b>", $element_part1[$x]); |
322 |
// |
323 |
if (trim($element_part2[0]) != "") { |
324 |
// |
325 |
$nbcar = 0; |
326 |
$nbcar = $element_part2[0]; |
327 |
// |
328 |
if (strlen($nbcar) == 1) { |
329 |
// ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs |
330 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
331 |
$pdf->write($edition["corpshauteur"], " ".$element_part2[0]." "); |
332 |
} else { |
333 |
// |
334 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
335 |
$pdf->write($edition["corpshauteur"], $element_part2[0]); |
336 |
} |
337 |
} |
338 |
// |
339 |
if (trim($element_part2[1]) != "") { |
340 |
// |
341 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
342 |
$pdf->write($edition["corpshauteur"], $element_part2[1]); |
343 |
} |
344 |
} |
345 |
} |
346 |
} |
347 |
} |
348 |
// |
349 |
for ($i = 1; $i < sizeof($temp); $i++) { |
350 |
// |
351 |
$pdf->AddPage(); |
352 |
// |
353 |
$element = $temp[$i]; |
354 |
// On teste si une balise <b> est pr�sente dans l'�l�ment |
355 |
if (strpos($element, "<b>") === false) { |
356 |
// => Aucune balise <b> n'est pr�sente dans l'�l�ment |
357 |
// |
358 |
if (trim($element) != "") { |
359 |
// |
360 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
361 |
$pdf->SetXY($edition["corpsleft"], $edition["se_margetop"]); |
362 |
$pdf->MultiCell($edition["corpslargeur"], $edition["corpshauteur"], $element, $edition["corpsbordure"], $edition["corpsalign"], 0); |
363 |
} |
364 |
} else { |
365 |
// => Une balise <b> est pr�sente dans l'�l�ment |
366 |
// |
367 |
$pdf->SetXY($edition["corpsleft"], $edition["se_margetop"]); |
368 |
// |
369 |
$element_part1 = ""; |
370 |
$element_part1 = explode("<b>", $element); |
371 |
// |
372 |
for ($x = 0; $x < sizeof($element_part1); $x++) { |
373 |
// |
374 |
if (strpos($element_part1[$x], "</b>") === false) { |
375 |
// => |
376 |
// |
377 |
if (trim($element_part1[$x]) != "") { |
378 |
// |
379 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
380 |
$pdf->write($edition["corpshauteur"], $element_part1[$x]); |
381 |
} |
382 |
} else { |
383 |
// => |
384 |
// |
385 |
$ctrl_fin_b = 0; |
386 |
$ctrl_fin_b = substr_count($element_part1[$x], "</b>"); |
387 |
// |
388 |
$edition["corpsattribut"] = str_replace("B", "", $edition["corpsattribut"]); |
389 |
$edition["corpsattribut"] = str_replace("b", "", $edition["corpsattribut"]); |
390 |
// |
391 |
if ($ctrl_fin_b > 1) { |
392 |
// => nbr </b> superieur a 1 |
393 |
// |
394 |
if (trim($element_part1[$x]) != "") { |
395 |
// |
396 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
397 |
$pdf->write($edition["corpshauteur"], $element_part1[$x]); |
398 |
} |
399 |
} else { |
400 |
// => |
401 |
// |
402 |
$element_part2 = explode("</b>", $element_part1[$x]); |
403 |
// |
404 |
if (trim($element_part2[0]) != "") { |
405 |
// |
406 |
$nbcar = 0; |
407 |
$nbcar = $element_part2[0]; |
408 |
// |
409 |
if (strlen($nbcar) == 1) { |
410 |
// ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs |
411 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
412 |
$pdf->write($edition["corpshauteur"], " ".$element_part2[0]." "); |
413 |
} else { |
414 |
// |
415 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
416 |
$pdf->write($edition["corpshauteur"], $element_part2[0]); |
417 |
} |
418 |
} |
419 |
// |
420 |
if (trim($element_part2[1]) != "") { |
421 |
// |
422 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
423 |
$pdf->write($edition["corpshauteur"], $element_part2[1]); |
424 |
} |
425 |
} |
426 |
} |
427 |
} |
428 |
} |
429 |
} |
430 |
} else { |
431 |
// |
432 |
$element = $corps; |
433 |
// On teste si une balise <b> est pr�sente dans l'�l�ment |
434 |
if (strpos($element, "<b>") === false) { |
435 |
// => Aucune balise <b> n'est pr�sente dans l'�l�ment |
436 |
// |
437 |
if (trim($element) != "") { |
438 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
439 |
$pdf->SetXY($edition["corpsleft"], $edition["corpstop"]); |
440 |
$pdf->MultiCell($edition["corpslargeur"], $edition["corpshauteur"], $element, $edition["corpsbordure"], $edition["corpsalign"], 0); |
441 |
} |
442 |
} else { |
443 |
// => Une balise <b> est pr�sente dans l'�l�ment |
444 |
// |
445 |
$pdf->SetXY($edition["corpsleft"], $edition["corpstop"]); |
446 |
// |
447 |
$element_part1 = ""; |
448 |
$element_part1 = explode("<b>", $element); |
449 |
// |
450 |
for ($x = 0; $x < sizeof($element_part1); $x++) { |
451 |
// |
452 |
if (strpos($element_part1[$x], "</b>") === false) { |
453 |
// |
454 |
if (trim($element_part1[$x]) != "") { |
455 |
// |
456 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
457 |
$pdf->write($edition["corpshauteur"], $element_part1[$x]); |
458 |
} |
459 |
} else { |
460 |
// |
461 |
$ctrl_fin_b = 0; |
462 |
$ctrl_fin_b = substr_count($element_part1[$x], "</b>"); |
463 |
// |
464 |
$edition["corpsattribut"] = str_replace("B", "", $edition["corpsattribut"]); |
465 |
$edition["corpsattribut"] = str_replace("b", "", $edition["corpsattribut"]); |
466 |
// |
467 |
if ($ctrl_fin_b > 1) { |
468 |
// => nbr </b> superieur a 1 |
469 |
// |
470 |
if (trim($element_part1[$x]) != "") { |
471 |
// |
472 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
473 |
$pdf->write($edition["corpshauteur"], $element_part1[$x]); |
474 |
} |
475 |
} else { |
476 |
// => |
477 |
// |
478 |
$element_part2 = explode("</b>", $element_part1[$x]); |
479 |
// |
480 |
if (trim($element_part2[0]) != "") { |
481 |
// |
482 |
$nbcar = 0; |
483 |
$nbcar = $element_part2[0]; |
484 |
// |
485 |
if (strlen($nbcar) == 1) { |
486 |
// ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs |
487 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
488 |
$pdf->write($edition["corpshauteur"], " ".$element_part2[0]." "); |
489 |
} else { |
490 |
// |
491 |
$pdf->SetFont($edition["corpsfont"], "B".$edition["corpsattribut"], $edition["corpstaille"]); |
492 |
$pdf->write($edition["corpshauteur"], $element_part2[0]); |
493 |
} |
494 |
} |
495 |
// |
496 |
if (trim($element_part2[1]) != "") { |
497 |
// |
498 |
$pdf->SetFont($edition["corpsfont"], $edition["corpsattribut"], $edition["corpstaille"]); |
499 |
$pdf->write($edition["corpshauteur"], $element_part2[1]); |
500 |
} |
501 |
} |
502 |
} |
503 |
} |
504 |
} |
505 |
} |
506 |
} |
507 |
|
508 |
////// |
509 |
// SOUS-ETATS |
510 |
////// |
511 |
// D�s�rialisation du param�tre couleur |
512 |
if ( is_array($edition) && count($edition) == 1 ) |
513 |
$edition["se_couleurtexte"] = explode("-", $edition["se_couleurtexte"]); |
514 |
// R�cup�ration de la liste des sous-�tats |
515 |
if (trim($edition['sousetat']) != "") { |
516 |
// Transformation de la valeur r�cup�r�e en liste |
517 |
// [chr(13) = retour charriot][chr(10) = retour a la ligne] |
518 |
// en sauvegarde pgsql, il n y a que le chr(10) |
519 |
// $sousetatliste = explode(chr(13).chr(10), $edition['sousetat']); |
520 |
$sousetatliste = explode(chr(10), $edition['sousetat']); |
521 |
} else { |
522 |
// |
523 |
$sousetatliste = array(); |
524 |
} |
525 |
// |
526 |
foreach ($sousetatliste as $elem) { |
527 |
// On r�cup�re l'enregistrement 'om_sousetat' de la collectivit� en cours dans |
528 |
// l'�tat 'actif' |
529 |
$sql = " select * from ".DB_PREFIXE."om_sousetat "; |
530 |
$sql .= " where id='".trim($elem)."' "; |
531 |
$sql .= " and actif IS TRUE "; |
532 |
$sql .= " and om_collectivite='".$_SESSION['collectivite']."' "; |
533 |
$res2 = $f->db->query($sql); |
534 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
535 |
$f->isDatabaseError($res2); |
536 |
// Si on obtient aucun r�sultat |
537 |
if ($res2->numrows() == 0) { |
538 |
// On lib�re le r�sultat de la requ�te pr�c�dente |
539 |
$res2->free(); |
540 |
// |
541 |
if ($niveau == "") { |
542 |
// On r�cup�re l'identifiant de la collectivit� de niveau 2 |
543 |
$sql = "select om_collectivite from ".DB_PREFIXE."om_collectivite "; |
544 |
$sql .= " where niveau='2' "; |
545 |
$niveau = $f->db->getone($sql); |
546 |
$f->addToLog("pdfetat.php: db->getone(\"".$sql."\");", VERBOSE_MODE); |
547 |
$f->isDatabaseError($niveau); |
548 |
} |
549 |
// On r�cup�re l'enregistrement 'om_sousetat' de la collectivit� de niveau |
550 |
// 2 dans l'�tat 'actif' |
551 |
$sql = " select * from ".DB_PREFIXE."om_sousetat "; |
552 |
$sql .= " where id='".trim($elem)."'"; |
553 |
$sql .= " and actif IS TRUE "; |
554 |
$sql .= " and om_collectivite='".$niveau."' "; |
555 |
$res2 = $f->db->query($sql); |
556 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
557 |
$f->isDatabaseError($res2); |
558 |
// Si on obtient aucun r�sultat |
559 |
if ($res2->numrows() == 0) { |
560 |
// On lib�re le r�sultat de la requ�te pr�c�dente |
561 |
$res2->free(); |
562 |
// On r�cup�re l'enregistrement 'om_sousetat' de la collectivit� de |
563 |
// niveau 2 dans n'importe quel �tat |
564 |
$sql = " select * from ".DB_PREFIXE."om_sousetat "; |
565 |
$sql .= " where id='".trim($elem)."' "; |
566 |
$sql .= " and om_collectivite='".$niveau."' "; |
567 |
$res2 = $f->db->query($sql); |
568 |
$f->addToLog("pdfetat.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
569 |
$f->isDatabaseError($res2); |
570 |
} |
571 |
} |
572 |
// |
573 |
while ($sousetat =& $res2->fetchRow(DB_FETCHMODE_ASSOC)) { |
574 |
// |
575 |
$sql = ''; |
576 |
$titre = ''; |
577 |
// Variables statiques contenant des param�tres � remplacer |
578 |
$sql = $sousetat['om_sql']; |
579 |
$titre = $sousetat['titre']; |
580 |
// Remplacement des param�tres dans le fichier ../dyn/varetatpdf.inc |
581 |
if (file_exists("../dyn/varetatpdf.inc")) { |
582 |
include "../dyn/varetatpdf.inc"; |
583 |
} |
584 |
// |
585 |
$sousetat['om_sql'] = $sql; |
586 |
$sousetat['titre'] = $titre; |
587 |
// imprime les colonnes de la requete |
588 |
$pdf->sousetatdb($f->db, $edition, $sousetat); |
589 |
} |
590 |
} |
591 |
} |
592 |
|
593 |
/** |
594 |
* Sortie du fichier PDF |
595 |
*/ |
596 |
// |
597 |
$pdf->Output("etat.pdf", "D"); |
598 |
|
599 |
} |
600 |
?> |