/[openfoncier]/trunk/app/pdf_instruction.php
ViewVC logotype

Diff of /trunk/app/pdf_instruction.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 88 by fraynaud, Thu Aug 25 09:59:07 2011 UTC revision 1184 by fmichon, Wed Jan 9 09:34:50 2013 UTC
# Line 3  Line 3 
3   *   *
4   *   *
5   * @package openmairie_exemple   * @package openmairie_exemple
6   * @version SVN : $Id: pdflettretype.php 278 2010-11-30 07:12:41Z fmichon $   * @version SVN : $Id$
7   */   */
8  // fpdf ne traite pas UTF8  // fpdf ne traite pas UTF8
9  // donc il faut utiliser decode  // donc il faut utiliser decode
# Line 31  $f = new utils("nohtml"); Line 31  $f = new utils("nohtml");
31   */   */
32    
33    
34  $sql_courrier="select * from instruction where instruction=".$idx;  $sql_courrier="select * from ".DB_PREFIXE."instruction where instruction=".$idx;
35  $res = $f->db->query($sql_courrier);  $res = $f->db->query($sql_courrier);
36  $f->isDatabaseError($res);  $f->isDatabaseError($res);
37  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
38      $obj=$row['lettretype'];      $obj=$row['lettretype'];
39      //if(CHARSET=='UTF8'){      //if(DBCHARSET=='UTF8'){
40      //    $titre= utf8_decode($lettretype["titre"]);      //    $titre= utf8_decode($lettretype["titre"]);
41      $destinataire=$row['destinataire'];  // ***      $destinataire=$row['destinataire'];  // ***
42      $datecourrier=$row['datecourrier'];      $date_evenement=$row['date_evenement'];
43      $complement=$row['complement'];      $complement=$row['complement'];
44      $complement2=$row['complement2'];      $complement2=$row['complement2'];
45      $complement3=$row['complement3'];      $complement3=$row['complement3'];
# Line 59  while ($row=& $res->fetchRow(DB_FETCHMOD Line 59  while ($row=& $res->fetchRow(DB_FETCHMOD
59    
60  // ligne a desactiver ==========================================================================  // ligne a desactiver ==========================================================================
61  //$destinataire ="";  //$destinataire ="";
62  //$datecourrier=date('d/m/Y');  //$date_evenement=date('d/m/Y');
63  //$complement="<-Ici le complement->";  //$complement="<-Ici le complement->";
64  // =============================================================================================  // =============================================================================================
65    
66  /* format a voir  // format date courrier en francais
67  if ($f->formatDate=="AAAA-MM-JJ"){  if ($f->formatdate=="AAAA-MM-JJ"){
68      $valTemp=explode("-",$datecourrier);      $valTemp=explode("-",$date_evenement);
69      $datecourrier = $valTemp[2]."/".$valTemp[1]."/".$valTemp[0];      $date_evenement = $valTemp[2]."/".$valTemp[1]."/".$valTemp[0];
70  }  }
71  */  
72    
73  /**  /**
74   *  acces table om_lettretype   *  acces table om_lettretype
# Line 76  if ($f->formatDate=="AAAA-MM-JJ"){ Line 76  if ($f->formatDate=="AAAA-MM-JJ"){
76  $niveau='';  $niveau='';
77  // requete SQL  // requete SQL
78  $sql= "select * from ".DB_PREFIXE."om_lettretype where id='".$obj."'"; // select obj  $sql= "select * from ".DB_PREFIXE."om_lettretype where id='".$obj."'"; // select obj
79  $sql.= " and actif ='Oui'";  $sql.= " and actif IS TRUE";
80  $sql.= " and om_collectivite ='".$_SESSION['collectivite']."'";  $sql.= " and om_collectivite ='".$_SESSION['collectivite']."'";
81  $res1 = $f->db->query($sql);  $res1 = $f->db->query($sql);
82  $f->isDatabaseError($res1);  $f->isDatabaseError($res1);
# Line 85  if ($res1->numrows()==0){ Line 85  if ($res1->numrows()==0){
85      $niveau=$f->db->getOne($sql);      $niveau=$f->db->getOne($sql);
86      //$res1->free();      //$res1->free();
87      $sql= "select * from ".DB_PREFIXE."om_lettretype where id='".$obj."'"; // select obj      $sql= "select * from ".DB_PREFIXE."om_lettretype where id='".$obj."'"; // select obj
88      $sql.= " and actif ='Oui'";      $sql.= " and actif IS TRUE";
89      $sql.= " and om_collectivite ='".$niveau."'";      $sql.= " and om_collectivite ='".$niveau."'";
90      $res1 = $f->db->query($sql);      $res1 = $f->db->query($sql);
91      $f->isDatabaseError($res1);      $f->isDatabaseError($res1);
# Line 111  class PDF extends FPDF { Line 111  class PDF extends FPDF {
111       */       */
112      function Footer() {      function Footer() {
113          // NUMERO DE PAGE          // NUMERO DE PAGE
114          //Positionnement � 1,5 cm du bas          //Positionnement � 1,5 cm du bas
115          $this->SetY(-15);          $this->SetY(-15);
116          // Police Arial italique 8          // Police Arial italique 8
117          $this->SetFont('Arial','I',8);          $this->SetFont('Arial','I',8);
# Line 156  while ($lettretype =& $res1->fetchRow(DB Line 156  while ($lettretype =& $res1->fetchRow(DB
156      //           3 = bordure (0 ou 1)      //           3 = bordure (0 ou 1)
157      //           4 = align (L C R J)      //           4 = align (L C R J)
158      //           5 =     0 fd transparent      //           5 =     0 fd transparent
159      //                   1 couleur (parametre � rajouter)      //                   1 couleur (parametre � rajouter)
160      // ==============================================================      // ==============================================================
161      $pdf->Image($f->getPathFolderTrs().$lettretype["logo"],      if(file_exists($f->getPathFolderTrs().$lettretype["logo"])) {
162                  $lettretype["logoleft"],        $pdf->Image($f->getPathFolderTrs().$lettretype["logo"],
163                  $lettretype["logotop"],                    $lettretype["logoleft"],
164                  0,                    $lettretype["logotop"],
165                  0,                    0,
166                  '',                    0,
167                  '');                    '',
168                      '');
169        }
170      // variables statiques      // variables statiques
171      $sql = $lettretype['om_sql'];      $sql = $lettretype['om_sql'];
172      $titre= $lettretype["titre"];      $titre= $lettretype["titre"];
# Line 190  while ($lettretype =& $res1->fetchRow(DB Line 192  while ($lettretype =& $res1->fetchRow(DB
192         //************************************************         //************************************************
193         $pos_t="";         $pos_t="";
194         $pos_t = strpos($titre, "<b>");         $pos_t = strpos($titre, "<b>");
195          if(CHARSET=='UTF8')          if(DBCHARSET=='UTF8')
196              $titre= utf8_decode($titre);              $titre= utf8_decode($titre);
197         if ($pos_t === false) {         if ($pos_t === false) {
198         // compatibilite :aucun attribut affichage <b> dans corps         // compatibilite :aucun attribut affichage <b> dans corps
# Line 260  while ($lettretype =& $res1->fetchRow(DB Line 262  while ($lettretype =& $res1->fetchRow(DB
262         $temp = explode("[",$lettretype["corps"]);         $temp = explode("[",$lettretype["corps"]);
263         for($i=1;$i<sizeof($temp);$i++){         for($i=1;$i<sizeof($temp);$i++){
264             $temp1 = explode("]",$temp[$i]);             $temp1 = explode("]",$temp[$i]);
265             $corps=str_replace("[".$temp1[0]."]",$row[$temp1[0]],$corps);             $corps=str_replace("[".$temp1[0]."]",$row[$temp1[0]],$corps);
266               //18//11/2011 +
267               $temp1[0]="";
268               //FIN +
269         }         }
270         //************************************************         //18//11/2011++
271         // traitement attribut affichage <b> dans corps  *          $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
272         //              aout 2008                        *          $pdf->SetXY($lettretype["corpsleft"],$lettretype["corpstop"]);
273         //************************************************          //FIN++
274         $pos="";          //18//11/2011 AJOUT \p
275         $pos = strpos($corps, "<b>");          if (strstr($corps,'\p')){
276          if(CHARSET=='UTF8')              $temp="";
277                  $corps= utf8_decode($corps);              $temp = explode("\p",$corps);
278         if ($pos === false) {              ////////////////////////
279         // compatibilite :aucun attribut affichage dans corps              // image en fond de page
280         //***************************************************************************              if (file_exists("../trs/bg_".$obj."1.png")) {
281            if(trim($corps)!="") {                   $pdf->Image("../trs/bg_".$obj."1.png", 0, 0, 210, 0, '', '');
282              $pdf->SetFont($lettretype["corpsfont"],              }
283                         $lettretype["corpsattribut"],              ////////////////////////
284                         $lettretype["corpstaille"]);              //************************************************
285              $pdf->SetXY($lettretype["corpsleft"],              //traitement attribut affichage <b> dans $temp[0]*
286                       $lettretype["corpstop"]);              //              aout 2008                        *
287              $pdf->MultiCell($lettretype["corpslargeur"],              //************************************************
288                           $lettretype["corpshauteur"] ,              $pos="";
289                           $corps."vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv",              $pos = strpos($temp[0], "<b>");
290                           $lettretype["corpsbordure"],               if ($pos === false) {
291                           $lettretype["corpsalign"],                 // compatibilite :aucun attribut affichage dans corps
292                           0);                 //***************************************************************************
293            }                 $pdf->MultiCell($lettretype["corpslargeur"],$lettretype["corpshauteur"],$temp[0],$lettretype["corpsbordure"],$lettretype["corpsalign"],0);
294           //****************************************************************************              }else{
295           // attribut affichage <b> present  dans corps                        $tmp="";
296          }else{                        $tmp=explode('<b>', $temp[0]);
297            $pdf->SetXY($lettretype["corpsleft"],$lettretype["corpstop"]);                        //
298            $tmp="";                         for($x=0;$x<sizeof($tmp);$x++){
299            $tmp=explode('<b>', $corps);                             $pos1="";
300            //                             $pos1 = strpos($tmp[$x], "</b>");
301             for($x=0;$x<sizeof($tmp);$x++){                             //
302                 $pos1="";                             if ($pos1 === false) {
303                 $pos1 = strpos($tmp[$x], "</b>");                                if(trim($tmp[$x])!=""){
304                                   $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
305                                   $pdf->write($lettretype["corpshauteur"],$tmp[$x]);
306                                  }
307                               }else{
308                                   $ctrl_fin_b=0;
309                                   $ctrl_fin_b=substr_count($tmp[$x],"</b>");
310                                   $lettretype["corpsattribut"] = str_replace("B","",$lettretype["corpsattribut"]);
311                                   $lettretype["corpsattribut"] = str_replace("b","",$lettretype["corpsattribut"]);
312                                    if ($ctrl_fin_b>1){
313                                       // nbr </b> superieur a 1
314                                       if(trim($tmp[$x])!=""){
315                                          $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
316                                          $pdf->write($lettretype["corpshauteur"],$tmp[$x]);
317                                       }
318                                    }else{
319                                       $tmp1 = explode("</b>",$tmp[$x]);
320                                       //
321                                       if(trim($tmp1[0])!=""){
322                                          //
323                                          $nbcar=0;
324                                          $nbcar=$tmp1[0];
325                                          if( strlen($nbcar)==1) {
326                                            // ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs
327                                            $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
328                                            $pdf->write($lettretype["corpshauteur"],"  ".$tmp1[0]."  ");
329                                          }else{
330                                             $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
331                                             $pdf->write($lettretype["corpshauteur"],$tmp1[0]);
332                                          }
333                                       }
334                                       if(trim($tmp1[1])!=""){
335                                          $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
336                                          $pdf->write($lettretype["corpshauteur"],$tmp1[1]);
337                                       }
338                                    }
339                                  //
340                               }
341                             }
342                }
343                for($i=1;$i<sizeof($temp);$i++){      
344                   $pdf->AddPage();
345                   $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
346                   $pdf->SetXY($lettretype["corpsleft"],$lettretype["titretop"]);
347                   ////////////////////////
348                   // image en fond de page
349                   if (file_exists("../trs/bg_".$obj.($i+1).".png")) {
350                        $pdf->Image("../trs/bg_".$obj.($i+1).".png", 0, 0, 210, 0, '', '');
351                   }
352                   //************************************************
353                   //traitement attribut affichage <b> dans $temp[$i]*
354                   //              aout 2008                        *
355                   //************************************************
356                   $pos="";
357                   $pos = strpos($temp[$i], "<b>");
358                    if ($pos === false) {
359                        // compatibilite :aucun attribut affichage dans corps
360                        //***************************************************************************
361                        $pdf->MultiCell($lettretype["corpslargeur"],$lettretype["corpshauteur"],$temp[$i],$lettretype["corpsbordure"],$lettretype["corpsalign"],0);
362                    }else{
363                          $tmp="";
364                          $tmp=explode('<b>', $temp[$i]);
365                          //
366                           for($x=0;$x<sizeof($tmp);$x++){
367                               $pos1="";
368                               $pos1 = strpos($tmp[$x], "</b>");
369                               //
370                               if ($pos1 === false) {
371                                  if(trim($tmp[$x])!=""){
372                                   $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
373                                   $pdf->write($lettretype["corpshauteur"],$tmp[$x]);
374                                  }
375                               }else{
376                                   $ctrl_fin_b=0;
377                                   $ctrl_fin_b=substr_count($tmp[$x],"</b>");
378                                   $lettretype["corpsattribut"] = str_replace("B","",$lettretype["corpsattribut"]);
379                                   $lettretype["corpsattribut"] = str_replace("b","",$lettretype["corpsattribut"]);
380                                    if ($ctrl_fin_b>1){
381                                       // nbr </b> superieur a 1
382                                       if(trim($tmp[$x])!=""){
383                                          $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
384                                          $pdf->write($lettretype["corpshauteur"],$tmp[$x]);
385                                       }
386                                    }else{
387                                       $tmp1 = explode("</b>",$tmp[$x]);
388                                       //
389                                       if(trim($tmp1[0])!=""){
390                                          //
391                                          $nbcar=0;
392                                          $nbcar=$tmp1[0];
393                                          if( strlen($nbcar)==1) {
394                                            // ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs
395                                            $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
396                                            $pdf->write($lettretype["corpshauteur"],"  ".$tmp1[0]."  ");
397                                          }else{
398                                             $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
399                                             $pdf->write($lettretype["corpshauteur"],$tmp1[0]);
400                                          }
401                                       }
402                                       if(trim($tmp1[1])!=""){
403                                          $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
404                                          $pdf->write($lettretype["corpshauteur"],$tmp1[1]);
405                                       }
406                                    }
407                                  //
408                               }
409                             }
410                    }
411                }
412            }else{ //18/11/2011 fin ajout \p
413                //************************************************
414                // traitement attribut affichage <b> dans corps  *
415                //              aout 2008                        *
416                //************************************************
417                $pos="";
418                $pos = strpos($corps, "<b>");
419                 if(DBCHARSET=='UTF8')
420                         $corps= utf8_decode($corps);
421                if ($pos === false) {
422                // compatibilite :aucun attribut affichage dans corps
423                //***************************************************************************
424                   if(trim($corps)!="") {
425                     $pdf->SetFont($lettretype["corpsfont"],
426                                $lettretype["corpsattribut"],
427                                $lettretype["corpstaille"]);
428                     $pdf->SetXY($lettretype["corpsleft"],
429                              $lettretype["corpstop"]);
430                     $pdf->MultiCell($lettretype["corpslargeur"],
431                                  $lettretype["corpshauteur"] ,
432                                  $corps,
433                                  $lettretype["corpsbordure"],
434                                  $lettretype["corpsalign"],
435                                  0);
436                   }
437                  //****************************************************************************
438                  // attribut affichage <b> present  dans corps
439                 }else{
440                   $pdf->SetXY($lettretype["corpsleft"],$lettretype["corpstop"]);
441                   $tmp="";
442                   $tmp=explode('<b>', $corps);
443                 //                 //
444                 if ($pos1 === false) {                  for($x=0;$x<sizeof($tmp);$x++){
445                    if(trim($tmp[$x])!=""){                      $pos1="";
446                     $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);                      $pos1 = strpos($tmp[$x], "</b>");
447                     $pdf->write($lettretype["corpshauteur"],$tmp[$x]);                      //
448                    }                      if ($pos1 === false) {
                }else{  
                    $ctrl_fin_b=0;  
                    $ctrl_fin_b=substr_count($tmp[$x],"</b>");  
                    $lettretype["corpsattribut"] = str_replace("B","",$lettretype["corpsattribut"]);  
                    $lettretype["corpsattribut"] = str_replace("b","",$lettretype["corpsattribut"]);  
                     if ($ctrl_fin_b>1){  
                        // nbr </b> superieur a 1  
449                         if(trim($tmp[$x])!=""){                         if(trim($tmp[$x])!=""){
450                            $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);                          $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
451                            $pdf->write($lettretype["corpshauteur"],$tmp[$x]);                          $pdf->write($lettretype["corpshauteur"],$tmp[$x]);
452                         }                         }
453                      }else{                      }else{
454                         $tmp1 = explode("</b>",$tmp[$x]);                          $ctrl_fin_b=0;
455                         //                          $ctrl_fin_b=substr_count($tmp[$x],"</b>");
456                         if(trim($tmp1[0])!=""){                          $lettretype["corpsattribut"] = str_replace("B","",$lettretype["corpsattribut"]);
457                              //                          $lettretype["corpsattribut"] = str_replace("b","",$lettretype["corpsattribut"]);
458                              $nbcar=0;                           if ($ctrl_fin_b>1){
459                              $nbcar=$tmp1[0];                              // nbr </b> superieur a 1
460                              if( strlen($nbcar)==1) {                              if(trim($tmp[$x])!=""){
                               // ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs  
                               $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);  
                               $pdf->write($lettretype["corpshauteur"],"  ".$tmp1[0]."  ");  
                             }else{  
461                                 $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);                                 $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
462                                 $pdf->write($lettretype["corpshauteur"],$tmp1[0]);                                 $pdf->write($lettretype["corpshauteur"],$tmp[$x]);
463                                }
464                             }else{
465                                $tmp1 = explode("</b>",$tmp[$x]);
466                                //
467                                if(trim($tmp1[0])!=""){
468                                     //
469                                     $nbcar=0;
470                                     $nbcar=$tmp1[0];
471                                     if( strlen($nbcar)==1) {
472                                       // ??????bug fpdf write si affichage 1 seul caractere -> ajout 2 blancs
473                                       $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
474                                       $pdf->write($lettretype["corpshauteur"],"  ".$tmp1[0]."  ");
475                                     }else{
476                                        $pdf->SetFont($lettretype["corpsfont"],"B".$lettretype["corpsattribut"],$lettretype["corpstaille"]);
477                                        $pdf->write($lettretype["corpshauteur"],$tmp1[0]);
478                                     }
479                                  }
480                                if(trim($tmp1[1])!=""){
481                                   $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);
482                                   $pdf->write($lettretype["corpshauteur"],$tmp1[1]);
483                              }                              }
484                           }                           }
485                         if(trim($tmp1[1])!=""){                         //
                           $pdf->SetFont($lettretype["corpsfont"],$lettretype["corpsattribut"],$lettretype["corpstaille"]);  
                           $pdf->write($lettretype["corpshauteur"],$tmp1[1]);  
                        }  
486                      }                      }
487                    //                  }
488                 }               }
489             }          } //18/11/2011 fin de 'pas de \p'
         }  
490         // fermeture pdf         // fermeture pdf
491         $pdf->Output();         $pdf->Output($obj.date("dmY").".pdf","D");
492      }      }
493  }  }
494  ?>  ?>

Legend:
Removed from v.88  
changed lines
  Added in v.1184

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26