From e26bac8231bd27f3c2d3e4102619af3ae39e28f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2010 10:43:52 +0000 Subject: [PATCH] Work on FPDF replacement by TCPDF --- htdocs/adherents/cartes/carte.php | 32 ++++++++++++++----- .../member/cards/pdf_standard.class.php | 18 +++++------ scripts/invoices/rebuild_merge_pdf.php | 2 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index d1e1d8a4b6d..9688522ed50 100755 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -35,7 +35,7 @@ $now = dol_now(); $year=dol_print_date($now,'%Y'); $month=dol_print_date($now,'%m'); $day=dol_print_date($now,'%d'); - +$foruserid=GETPOST('foruserid'); $arrayofmembers=array(); @@ -47,6 +47,7 @@ $sql.= " p.libelle as pays"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid"; $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; +if ($foruserid) $sql.=" AND d.rowid=".$foruserid; $sql.= " ORDER BY d.rowid ASC"; $result = $db->query($sql); @@ -86,14 +87,29 @@ if ($result) $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray, $langs); $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray, $langs); - $arrayofmembers[]=array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); + if ($foruserid) + { + for($j=0;$j<100;$j++) + { + $arrayofmembers[]=array('textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo); + } + } + else + { + $arrayofmembers[]=array('textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo); + } - $i++; + $i++; } // Build and output PDF diff --git a/htdocs/includes/modules/member/cards/pdf_standard.class.php b/htdocs/includes/modules/member/cards/pdf_standard.class.php index 7aff5e9ee73..f5d54b3fa9b 100644 --- a/htdocs/includes/modules/member/cards/pdf_standard.class.php +++ b/htdocs/includes/modules/member/cards/pdf_standard.class.php @@ -148,9 +148,9 @@ class pdf_standard { // Define photo $dir=$conf->adherent->dir_output; - $file=get_exdir($idmember,2).$photomember; + $file=get_exdir($idmember,2).'photos/'.$photomember; $photo=$dir.'/'.$file; - if (! is_readable($photo)) $photo=''; + if (empty($photomember) || ! is_readable($photo)) $photo=''; // Define background image $backgroundimage=''; @@ -194,7 +194,7 @@ class pdf_standard { else { $pdf->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height); - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft)); + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); } } else if ($textleft!='' && $textright!='') // @@ -211,12 +211,12 @@ class pdf_standard { if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); $pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); - $pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft)); + $pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); } else { $pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft)); + $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+3+$this->_Line_Height); $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); } @@ -277,16 +277,16 @@ class pdf_standard { for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { for($j=$i;$j<=($i+$Pointilles);$j++) { if($j<=($x2-1)) { - $pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point - $pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point + $pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point + $pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point } } } for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { for($j=$i;$j<=($i+$Pointilles);$j++) { if($j<=($y2-1)) { - $pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point - $pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point + $pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point + $pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point } } } diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index b9ae90c4fc2..b4e73ba4e14 100644 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -283,7 +283,7 @@ if ( $resql=$db->query($sql) ) if ($pagecount) { $file=$diroutputpdf.'/'.$filename.'.pdf'; - $pdf->Output($file); + $pdf->Output($file,'F'); if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); }