Work on FPDF replacement by TCPDF

This commit is contained in:
Laurent Destailleur 2010-09-01 14:13:51 +00:00
parent fc460abd17
commit 02206c3fa4
11 changed files with 71 additions and 164 deletions

View File

@ -706,33 +706,12 @@ class Fichinter extends CommonObject
{
global $user,$langs,$conf;
// Charge tableau des id de societe socids
$socids = array();
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE client IN (1, 3)";
$sql.= " AND entity = ".$conf->entity;
$sql.= " LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids
$prodids = array();
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " AND entity = ".$conf->entity;
$sql.= " WHERE tosell = 1";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " AND tosell = 1";
$resql = $this->db->query($sql);
if ($resql)
{
@ -745,13 +724,13 @@ class Fichinter extends CommonObject
$prodids[$i] = $row[0];
}
}
else dol_print_error($this->db);
// Initialise parametres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$socid = rand(1, $num_socs);
$this->socid = $socids[$socid];
$this->socid = 1;
$this->date = time();
$this->date_lim_reglement=$this->date+3600*24*30;
$this->cond_reglement_code = 'RECEP';

View File

@ -497,19 +497,7 @@ class pdf_edison extends ModelePDFCommandes
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
}

View File

@ -823,19 +823,7 @@ class pdf_einstein extends ModelePDFCommandes
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
}
//Print content

View File

@ -335,19 +335,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->SENDING_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
}
$Xoff = 90;

View File

@ -83,19 +83,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->SENDING_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
}
//Prepare la suite

View File

@ -982,24 +982,10 @@ class pdf_crabe extends ModelePDFFactures
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur;
$pdf->SetFont('','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$this->page_largeur,($this->page_hauteur-$watermark_y)*$this->page_largeur,-$watermark_x*$this->page_largeur,-($this->page_hauteur-$watermark_y)*$this->page_largeur));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
}
//Print content
if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
}
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('','B',13);

View File

@ -793,21 +793,8 @@ class pdf_oursin extends ModelePDFFactures
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-50;
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
}
//Print content
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13);

View File

@ -107,6 +107,8 @@ class pdf_soleil extends ModelePDFFicheinter
}
}
$fichinter->fetch_thirdparty();
$fichref = dol_sanitizeFileName($fichinter->ref);
$dir = $conf->ficheinter->dir_output;
if (! preg_match('/specimen/i',$fichref)) $dir.= "/" . $fichref;
@ -150,7 +152,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->AddPage();
$pagenb++;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
$pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 4
// Pagehead
@ -158,21 +160,8 @@ class pdf_soleil extends ModelePDFFicheinter
//Affiche le filigrane brouillon - Print Draft Watermark
if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-50;
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->FICHINTER_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
}
//Print content
$posy=$this->marge_haute;
@ -189,7 +178,7 @@ class pdf_soleil extends ModelePDFFicheinter
else
{
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
}
@ -199,7 +188,7 @@ class pdf_soleil extends ModelePDFFicheinter
$posy=40;
$hautcadre=40;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->SetXY($this->marge_gauche,$posy);
$pdf->SetFillColor(230,230,230);
@ -210,15 +199,15 @@ class pdf_soleil extends ModelePDFFicheinter
// Sender name
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',10);
$pdf->SetFont('','B',10);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->nom), 0, 'L');
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$pdf->SetFont('Arial','',9);
$pdf->SetFont('','',9);
$pdf->SetXY($this->marge_gauche+2,$posy+9);
$pdf->MultiCell(80, 4, $carac_emetteur);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
$object=$fichinter;
@ -239,23 +228,23 @@ class pdf_soleil extends ModelePDFFicheinter
// Client destinataire
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',10);
$pdf->SetFont('','B',10);
$fichinter->fetch_thirdparty();
$pdf->SetXY(102,42);
$pdf->MultiCell(86,5, $outputlangs->convToOutputCharset($carac_client_name));
$pdf->SetFont('Arial','B',9);
$pdf->MultiCell(86,4, $outputlangs->convToOutputCharset($carac_client_name), 0, 'L');
$pdf->SetFont('','',9);
$pdf->SetXY(102,$pdf->GetY());
$pdf->MultiCell(66,5, $outputlangs->convToOutputCharset($carac_client));
$pdf->MultiCell(66,4, $outputlangs->convToOutputCharset($carac_client), 0, 'L');
$pdf->rect(100, 40, 100, 40);
$pdf->SetTextColor(0,0,100);
$pdf->SetFont('Arial','B',14);
$pdf->SetFont('','B',14);
$pdf->Text(11, 94, $outputlangs->transnoentities("InterventionCard")." : ".$outputlangs->convToOutputCharset($fichinter->ref));
$pdf->SetFillColor(220,220,220);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10);
$pdf->SetFont('','',10);
$tab_top = 100;
@ -268,7 +257,7 @@ class pdf_soleil extends ModelePDFFicheinter
{
$tab_top = 98;
$pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
$pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page
$pdf->SetXY ($this->posxdesc-1, $tab_top);
$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fichinter->note_public), 0, 'J');
$nexY = $pdf->GetY();
@ -290,7 +279,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
$pdf->line(10, $tab_top + 8, 200, $tab_top + 8 );
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
$pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 3
$pdf->SetXY (10, $tab_top + 8 );
@ -349,7 +338,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->SetXY(110,225);
$pdf->MultiCell(80,30, '', 1);
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
$pdf->SetFont('','', 9); // On repositionne la police par defaut
$this->_pagefoot($pdf,$fichinter,$outputlangs);
$pdf->AliasNbPages();

View File

@ -856,19 +856,7 @@ class pdf_propale_azur extends ModelePDFPropales
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->PROPALE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
}
//Prepare la suite

View File

@ -490,19 +490,7 @@ class pdf_propale_jaune extends ModelePDFPropales
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && ! empty($conf->global->PROPALE_DRAFT_WATERMARK))
{
$watermark_angle=deg2rad(55);
$watermark_x=5;
$watermark_y=$this->page_hauteur-50;
$watermark_width=300;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($conf->global->PROPALE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
}
$posy=42;

View File

@ -124,8 +124,46 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
}
/**
* Add a draft watermark on PDF files
* @param pdf Object PDF
* @param outputlangs Object lang
* @param height Height of PDF
* @param width Width of PDF
* @param unit Unit of height (mmn, pt, ...)
* @param text Text to show
*/
function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
{
// Print Draft Watermark
if ($unit=='pt') $k=1;
elseif ($unit=='mm') $k=72/25.4;
elseif ($unit=='cm') $k=72/2.54;
elseif ($unit=='in') $k=72;
$watermark_angle=atan($h/$w);
$watermark_x=5;
$watermark_y=$h-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$h;
$pdf->SetFont('','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$k,($h-$watermark_y)*$k,-$watermark_x*$k,-($h-$watermark_y)*$k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,$outputlangs->convToOutputCharset($text),0,2,"C",0);
//antirotate
$pdf->_out('Q');
}
/**
* Show bank informations for PDF generation
* @param pdf Object PDF
* @param outputlangs Object lang
* @param curx X
* @param cury Y
* @param account Bank account object
*/
function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
{