2
0
forked from Wavyzz/dolibarr

Work on FPDF replacement by TCPDF

This commit is contained in:
Laurent Destailleur
2010-09-01 10:22:11 +00:00
parent d97c1054f1
commit f5a945cf74
24 changed files with 754 additions and 525 deletions

View File

@@ -30,28 +30,6 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/member/cards/modules_cards.php");
// liste des patterns remplacable dans le texte a imprimer
$patterns = array (
'/%PRENOM%/',
'/%NOM%/',
'/%LOGIN%/',
'/%SERVEUR%/',
'/%SOCIETE%/',
'/%ADRESSE%/',
'/%CP%/',
'/%VILLE%/',
'/%PAYS%/',
'/%EMAIL%/',
'/%NAISS%/',
'/%TYPE%/',
'/%ID%/',
'/%ANNEE%/', // For backward compatibility
'/%YEAR%/',
'/%MONTH%/',
'/%DAY%/'
);
// Choix de l'annee d'impression ou annee courante.
$now = dol_now();
$year=dol_print_date($now,'%Y');
@@ -83,30 +61,30 @@ if ($result)
if ($objp->pays == '-') $objp->pays='';
// List of values to scan for a replacement
$replace = array (
$objp->prenom,
$objp->nom,
$objp->login,
"http://".$_SERVER["SERVER_NAME"]."/",
$objp->societe,
$objp->adresse,
$objp->cp,
$objp->ville,
$objp->pays,
$objp->email,
$objp->naiss,
$objp->type,
$objp->rowid,
$year,
$year,
$month,
$day
$substitutionarray = array (
'%PRENOM%'=>$objp->prenom,
'%NOM%'=>$objp->nom,
'%LOGIN%'=>$objp->login,
'%SERVEUR%'=>"http://".$_SERVER["SERVER_NAME"]."/",
'%SOCIETE%'=>$objp->societe,
'%ADRESSE%'=>$objp->adresse,
'%CP%'=>$objp->cp,
'%VILLE%'=>$objp->ville,
'%PAYS%'=>$objp->pays,
'%EMAIL%'=>$objp->email,
'%NAISS%'=>$objp->naiss,
'%TYPE%'=>$objp->type,
'%ID%'=>$objp->rowid,
'%ANNEE%'=>$year, // For backward compatibility
'%YEAR%'=>$year,
'%MONTH%'=>$month,
'%DAY%'=>$day
);
$textleft=preg_replace ($patterns, $replace, $conf->global->ADHERENT_CARD_TEXT);
$textheader=preg_replace ($patterns, $replace, $conf->global->ADHERENT_CARD_HEADER_TEXT);
$textfooter=preg_replace ($patterns, $replace, $conf->global->ADHERENT_CARD_FOOTER_TEXT);
$textright=preg_replace ($patterns, $replace, $conf->global->ADHERENT_CARD_TEXT_RIGHT);
$textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray, $langs);
$textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray, $langs);
$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,

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,43 +21,28 @@
/**
* \file htdocs/adherents/cartes/etiquette.php
* \ingroup member
* \brief Page de creation d'etiquettes
* \brief Page to output members labels sheets
* \version $Id$
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/member/PDF_card.class.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/member/labels/modules_labels.php');
$dir = $conf->adherent->dir_temp;
$file = $dir . "/tmplabel.pdf";
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) $conf->global->ADHERENT_ETIQUETTE_TYPE='L7163';
$pdf = new PDF_card($conf->global->ADHERENT_ETIQUETTE_TYPE, 1, 1);
$pdf->Open();
$pdf->AddPage();
//if (empty($conf->global->ADHERENT_ETIQUETTE_TYPE)) $conf->global->ADHERENT_ETIQUETTE_TYPE='L7163';
//$pdf = new PDF_card($conf->global->ADHERENT_ETIQUETTE_TYPE, 1, 1);
// Choix de l'annee d'impression ou annee courante.
if (!isset($annee)){
$now = getdate();
$annee=$now['year'];
}
$now = dol_now();
$year=dol_print_date($now,'%Y');
$month=dol_print_date($now,'%m');
$day=dol_print_date($now,'%d');
$arrayofmembers=array();
// requete en prenant que les adherents a jour de cotisation
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.datefin,";
$sql = "SELECT d.rowid, d.prenom, d.nom, d.login, d.societe, d.datefin,";
$sql.= " d.adresse, d.cp, d.ville, d.naiss, d.email, d.photo,";
$sql.= " t.libelle as type,";
$sql.= " p.libelle as pays";
@@ -74,14 +59,59 @@ if ($result)
while ($i < $num)
{
$objp = $db->fetch_object($result);
// imprime le texte specifique sur la carte
$message=sprintf("%s\n%s\n%s %s\n%s", $objp->prenom." ".$objp->nom, $objp->adresse, $objp->cp, $objp->ville, $objp->pays);
$pdf->Add_PDF_card($message,'','',$langs);
if ($objp->pays == '-') $objp->pays='';
// List of values to scan for a replacement
$substitutionarray = array (
'%PRENOM%'=>$objp->prenom,
'%NOM%'=>$objp->nom,
'%LOGIN%'=>$objp->login,
'%SERVEUR%'=>"http://".$_SERVER["SERVER_NAME"]."/",
'%SOCIETE%'=>$objp->societe,
'%ADRESSE%'=>$objp->adresse,
'%CP%'=>$objp->cp,
'%VILLE%'=>$objp->ville,
'%PAYS%'=>$objp->pays,
'%EMAIL%'=>$objp->email,
'%NAISS%'=>$objp->naiss,
'%TYPE%'=>$objp->type,
'%ID%'=>$objp->rowid,
'%ANNEE%'=>$year, // For backward compatibility
'%YEAR%'=>$year,
'%MONTH%'=>$month,
'%DAY%'=>$day
);
$conf->global->ADHERENT_ETIQUETTE_TEXT="%PRENOM% %NOM%\n%ADRESSE%\n%CP% %VILLE%\n%PAYS%";
$textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray, $langs);
$textheader='';
$textfooter='';
$textright='';
$arrayofmembers[]=array('textleft'=>$textleft,
'textheader'=>$textheader,
'textfooter'=>$textfooter,
'textright'=>$textright,
'id'=>$objp->rowid,
'photo'=>$objp->photo);
$i++;
// $message=sprintf("%s\n%s\n%s %s\n%s", $objp->prenom." ".$objp->nom, $objp->adresse, $objp->cp, $objp->ville, $objp->pays);
// $pdf->Add_PDF_card($message,'','',$langs);
}
// Output to http strem
$pdf->Output($file);
// Build and output PDF
$result=members_label_pdf_create($db, $arrayofmembers, '', $outputlangs);
if ($result <= 0)
{
dol_print_error($db,$result);
exit;
}
/*
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -105,6 +135,7 @@ if ($result)
header('Pragma: public');
readfile($file);
*/
}
else
{

View File

@@ -101,7 +101,7 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire)
if ($pagecount)
{
$file=$diroutputpdf.'/'.$filename.'_'.dol_print_date(mktime(),'dayhourlog').'.pdf';
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
}

View File

@@ -131,7 +131,7 @@ class CommActionRapport
$pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -169,7 +169,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$pdf->Close();
$pdf->Output($_file);
$pdf->Output($_file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -293,7 +293,7 @@ class pdf_edison extends ModelePDFCommandes
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -382,7 +382,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -247,7 +247,9 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
return 1;
}

View File

@@ -366,7 +366,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -175,8 +175,13 @@ class pdf_crabe extends ModelePDFFactures
else
{
$pdf=new FPDI('P','mm',$this->format);
//$pdf=new TCPDF('P','mm','A4');
}
//$pdf->setPrintHeader(false);
//$pdf->setPrintFooter(false);
$pdf->SetFont('Helvetica');
$pdf->Open();
$pagenb=0;
$pdf->SetDrawColor(128,128,128);
@@ -204,7 +209,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $fac, 1, $outputlangs);
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0);
@@ -218,7 +223,7 @@ class pdf_crabe extends ModelePDFFactures
{
$tab_top = 88;
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
$pdf->SetXY ($this->posxdesc-1, $tab_top);
$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fac->note_public), 0, 'J');
$nexY = $pdf->GetY();
@@ -248,10 +253,10 @@ class pdf_crabe extends ModelePDFFactures
// Description of product line
$libelleproduitservice=pdf_getlinedesc($fac->lignes[$i],$outputlangs);
$pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
$pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page
$pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
$pdf->SetFont('','', 9); // On repositionne la police par defaut
$nexY = $pdf->GetY();
// TVA
@@ -347,7 +352,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $fac, 0, $outputlangs);
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0);
@@ -386,7 +391,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -423,13 +428,13 @@ class pdf_crabe extends ModelePDFFactures
$tab3_width = 80;
$tab3_height = 4;
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->SetXY ($tab3_posx, $tab3_top - 5);
$pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
$pdf->SetFont('Arial','',6);
$pdf->SetFont('','',6);
$pdf->SetXY ($tab3_posx, $tab3_top );
$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
$pdf->SetXY ($tab3_posx+21, $tab3_top );
@@ -441,7 +446,7 @@ class pdf_crabe extends ModelePDFFactures
$y=0;
$pdf->SetFont('Arial','',6);
$pdf->SetFont('','',6);
// Loop on each deposits and credit notes included
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
@@ -562,12 +567,12 @@ class pdf_crabe extends ModelePDFFactures
{
global $conf;
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
// If France, show VAT mention if not applicable
if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
{
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
@@ -577,12 +582,12 @@ class pdf_crabe extends ModelePDFFactures
// Show payments conditions
if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
{
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentConditions").':';
$pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->SetXY(50, $posy);
$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
@@ -601,7 +606,7 @@ class pdf_crabe extends ModelePDFFactures
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
$pdf->SetTextColor(0,0,0);
@@ -613,12 +618,12 @@ class pdf_crabe extends ModelePDFFactures
&& $object->mode_reglement_code != 'CHQ'
&& $object->mode_reglement_code != 'VIR')
{
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentMode").':';
$pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->SetXY(50, $posy);
$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
@@ -638,24 +643,24 @@ class pdf_crabe extends ModelePDFFactures
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0);
$posy=$pdf->GetY()+1;
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
$posy=$pdf->GetY()+2;
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('Arial','B',8);
$pdf->SetFont('','B',8);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0);
$posy=$pdf->GetY()+1;
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
$posy=$pdf->GetY()+2;
}
@@ -700,7 +705,7 @@ class pdf_crabe extends ModelePDFFactures
$tab2_top = $posy;
$tab2_hl = 5;
$tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
// Tableau total
$lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x;
@@ -894,7 +899,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
// Fin
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('','', 9);
$pdf->SetTextColor(0,0,0);
}
@@ -912,7 +917,7 @@ class pdf_crabe extends ModelePDFFactures
// Amount in (at tab_top - 1)
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie));
$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre);
@@ -920,10 +925,10 @@ class pdf_crabe extends ModelePDFFactures
// Rect prend une longueur en 3eme param et 4eme param
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
// line prend une position y en 3eme param et 4eme param
// line prend une position y en 2eme param et 4eme param
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
$pdf->SetFont('Arial','',9);
$pdf->SetFont('','',9);
$pdf->SetXY ($this->posxdesc-1, $tab_top+2);
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
@@ -984,10 +989,10 @@ class pdf_crabe extends ModelePDFFactures
$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->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*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
$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);
@@ -997,7 +1002,7 @@ class pdf_crabe extends ModelePDFFactures
//Print content
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13);
$pdf->SetFont('','B',13);
$posy=$this->marge_haute;
@@ -1014,7 +1019,7 @@ class pdf_crabe extends ModelePDFFactures
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("ErrorGoToGlobalSetup"), 0, 'L');
}
@@ -1025,7 +1030,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
$pdf->SetFont('Arial','B',13);
$pdf->SetFont('','B',13);
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
$title=$outputlangs->transnoentities("Invoice");
@@ -1035,7 +1040,7 @@ class pdf_crabe extends ModelePDFFactures
if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat");
$pdf->MultiCell(100, 4, $title, '' , 'R');
$pdf->SetFont('Arial','B',12);
$pdf->SetFont('','B',12);
$posy+=6;
$pdf->SetXY(100,$posy);
@@ -1043,7 +1048,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
$posy+=2;
$pdf->SetFont('Arial','',9);
$pdf->SetFont('','',9);
$facidnext=$object->getIdReplacingInvoice('validated');
if ($object->type == 0 && $facidnext)
@@ -1119,7 +1124,7 @@ class pdf_crabe extends ModelePDFFactures
{
$posy+=4;
$pdf->SetXY(100,$posy);
$pdf->SetFont('Arial','',9);
$pdf->SetFont('','',9);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R');
}
}
@@ -1145,7 +1150,7 @@ class pdf_crabe extends ModelePDFFactures
{
$posy+=4;
$pdf->SetXY(100,$posy);
$pdf->SetFont('Arial','',9);
$pdf->SetFont('','',9);
$text=$newobject->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
@@ -1168,9 +1173,9 @@ class pdf_crabe extends ModelePDFFactures
// Show sender frame
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->SetXY($posx,$posy-5);
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":");
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
@@ -1178,13 +1183,13 @@ class pdf_crabe extends ModelePDFFactures
// Show sender name
$pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('Arial','B',10);
$pdf->SetFont('','B',10);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->nom), 0, 'L');
// Show sender information
$pdf->SetXY($posx+2,$posy+8);
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(80, 4, $carac_emetteur);
$pdf->SetFont('','',9);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
@@ -1219,21 +1224,21 @@ class pdf_crabe extends ModelePDFFactures
// Show recipient frame
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetFont('','',8);
$pdf->SetXY($posx+2,$posy-5);
$pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":");
$pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":",0,'L');
$pdf->rect($posx, $posy, 100, $hautcadre);
// Show recipient name
$pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('Arial','B',10);
$pdf->SetFont('','B',10);
$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');
// Show recipient information
$pdf->SetFont('Arial','',9);
$pdf->SetFont('','',9);
$posy=$pdf->GetY()-9; //Auto Y coord readjust for multiline name
$pdf->SetXY($posx+2,$posy+6);
$pdf->MultiCell(86,4, $carac_client);
$pdf->MultiCell(86,4, $carac_client, 0, 'L');
}
}

View File

@@ -285,7 +285,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -354,7 +354,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -297,7 +297,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -419,7 +419,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -1,376 +0,0 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Inspire de PDF_Label
* PDF_Label - PDF label editing
* @package PDF_Label
* @author Laurent PASSEBECQ <lpasseb@numericable.fr>
* @copyright 2003 Laurent PASSEBECQ
* disponible ici : http://www.fpdf.org/fr/script/script29.php
*/
////////////////////////////////////////////////////
// PDF_Label
//
// Classe afin d'editer au format PDF des etiquettes
// au format Avery ou personnalis<69>
//
//
// Copyright (C) 2003 Laurent PASSEBECQ (LPA)
// Bas<61> sur les fonctions de Steve Dillon : steved@mad.scientist.com
//
//-------------------------------------------------------------------
// VERSIONS :
// 1.0 : Initial release
// 1.1 : + : Added unit in the constructor
// + : Now Positions start @ (1,1).. then the first image @top-left of a page is (1,1)
// + : Added in the description of a label :
// font-size : defaut char size (can be changed by calling Set_Char_Size(xx);
// paper-size : Size of the paper for this sheet (thanx to Al Canton)
// metric : type of unit used in this description
// You can define your label properties in inches by setting metric to 'in'
// and printing in millimiter by setting unit to 'mm' in constructor.
// Added some labels :
// 5160, 5161, 5162, 5163,5164 : thanx to Al Canton : acanton@adams-blake.com
// 8600 : thanx to Kunal Walia : kunal@u.washington.edu
// + : Added 3mm to the position of labels to avoid errors
////////////////////////////////////////////////////
/**
* \file htdocs/includes/modules/member/PDF_card.class.php
* \ingroup member
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
* \author Steve Dillon
* \author Laurent Passebecq
* \author Rodolphe Quiedville
* \author Jean Louis Bergamo.
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php');
/**
* \class PDF_card
* \brief Classe afin d'editer au format PDF des etiquettes au format Avery ou personnalise
*/
class PDF_card extends FPDF {
var $code; // Code of format
var $format; // Array with informations
// Proprietes privees
var $_Avery_Name = ''; // Nom du format de l'etiquette
var $_Margin_Left = 0; // Marge de gauche de l'etiquette
var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette
var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes
var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes
var $_X_Number = 0; // Nombre d'etiquettes sur la largeur de la page
var $_Y_Number = 0; // Nombre d'etiquettes sur la hauteur de la page
var $_Width = 0; // Largeur de chaque etiquette
var $_Height = 0; // Hauteur de chaque etiquette
var $_Char_Size = 10; // Hauteur des caracteres
var $_Line_Height = 10; // Hauteur par defaut d'une ligne
var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values
var $_Metric_Doc = 'mm'; // Type of metric for the doc..
var $_COUNTX = 1;
var $_COUNTY = 1;
var $_First = 1;
/**
* Constructor
*
* @param $format Avery format of label paper. For example 5160, 5161, 5162, 5163, 5164, 8600, L7163
* @param $posX
* @param $posY
* @param $unit
* @return PDF_card
*/
function PDF_card ($format, $posX=1, $posY=1, $unit='mm')
{
global $conf,$langs,$mysoc,$_Avery_Labels;
if (is_array($format)) {
// Si c'est un format personnel alors on maj les valeurs
$Tformat = $format;
} else {
// If it's an Avery format, we get array that describe it from key and we store it in Tformat.
$Tformat = $_Avery_Labels[$format];
if (empty($Tformat))
{
dol_print_error('','Format value "'.$format.'" is not supported.');
exit;
}
}
parent::FPDF('P', $unit, $Tformat['paper-size']);
$this->SetMargins(0,0);
$this->SetAutoPageBreak(false);
$this->_Metric_Doc = $unit;
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
if ($posX > 0) $posX--; else $posX=0;
if ($posY > 0) $posY--; else $posY=0;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($Tformat);
}
//Methode qui permet de modifier la taille des caracteres
// Cela modiera aussi l'espace entre chaque ligne
function Set_Char_Size($pt) {
if ($pt > 3) {
$this->_Char_Size = $pt;
$this->_Line_Height = $this->_Get_Height_Chars($pt);
$this->SetFont('Arial','',$pt);
}
}
// On imprime une etiquette
function Add_PDF_card($textleft,$header='',$footer='',$outputlangs,$textright='')
{
global $mysoc,$conf,$langs;
if (! is_object($outputlangs)) $outputlangs=$langs;
// Force output charset to ISO, because, FPDF expects text to be encoded in ISO
$outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("members");
// We are in a new page, then we must add a page
if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) {
$this->AddPage();
}
$this->_First=0;
$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
if (is_readable($logo))
{
if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
{
$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
}
elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
{
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
}
}
if ($this->_Avery_Name == "CARD")
{
$Tformat=$this->_Avery_Labels["CARD"];
//$this->_Pointille($_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
$this->_Croix($_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,10);
if($Tformat['fond'] != '' and file_exists($Tformat['fond'])){
$this->image($Tformat['fond'],$_PosX,$_PosY,$this->_Width,$this->_Height);
}
if($Tformat['logo1'] != '' and file_exists($Tformat['logo1'])){
$this->image($Tformat['logo1'],$_PosX+$this->_Width-21,$_PosY+1,20,20);
}
if($Tformat['logo2'] != '' and file_exists($Tformat['logo2'])){
$this->image($Tformat['logo2'],$_PosX+$this->_Width-21,$_PosY+25,20,20);
}
// Top
if ($header!=''){
$this->SetXY($_PosX, $_PosY+1);
$this->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
}
// Center
if ($textright=='') // Only a left part
{
if ($textleft == '%LOGO%') $this->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20);
else
{
$this->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height);
$this->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft));
}
}
else if ($textleft!='' && $textright!='') //
{
if ($textleft == '%LOGO%')
{
$this->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20);
$this->SetXY($_PosX+22, $_PosY+3+$this->_Line_Height);
$this->MultiCell($this->_Width-20, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
else if ($textright == '%LOGO%')
{
$this->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20);
$this->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height);
$this->MultiCell($this->_Width-20, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft));
}
else
{
$this->SetXY($_PosX+round($this->_Width/2), $_PosY+3+$this->_Line_Height);
$this->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
$this->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height);
$this->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft));
}
}
else // Only a right part
{
if ($textright == '%LOGO%') $this->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20);
else
{
$this->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height);
$this->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
}
// Bottom
if ($footer!='')
{
$this->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
$this->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
}
}
else
{
$this->SetXY($_PosX+3, $_PosY+3);
$this->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft));
}
$this->_COUNTY++;
if ($this->_COUNTY == $this->_Y_Number) {
// Si on est en bas de page, on remonte le 'curseur' de position
$this->_COUNTX++;
$this->_COUNTY=0;
}
if ($this->_COUNTX == $this->_X_Number) {
// Si on est en bout de page, alors on repart sur une nouvelle page
$this->_COUNTX=0;
$this->_COUNTY=0;
}
}
function _Pointille($x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15)
{
$this->SetLineWidth($epaisseur);
$longueur=abs($x1-$x2);
$hauteur=abs($y1-$y2);
if($longueur>$hauteur) {
$Pointilles=($longueur/$nbPointilles)/2; // taille des pointilles
}
else {
$Pointilles=($hauteur/$nbPointilles)/2;
}
for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) {
for($j=$i;$j<=($i+$Pointilles);$j++) {
if($j<=($x2-1)) {
$this->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point
$this->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)) {
$this->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point
$this->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point
}
}
}
}
/*
* Fonction realisant une croix aux 4 coins des cartes
*/
function _Croix($x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=5)
{
//$this->Color('#888888');
$this->SetLineWidth($epaisseur);
$lg=$taille/2;
// croix haut gauche
$this->Line($x1,$y1-$lg,$x1,$y1+$lg);
$this->Line($x1-$lg,$y1,$x1+$lg,$y1);
// croix bas gauche
$this->Line($x1,$y2-$lg,$x1,$y2+$lg);
$this->Line($x1-$lg,$y2,$x1+$lg,$y2);
// croix haut droit
$this->Line($x2,$y1-$lg,$x2,$y1+$lg);
$this->Line($x2-$lg,$y1,$x2+$lg,$y1);
// croix bas droit
$this->Line($x2,$y2-$lg,$x2,$y2+$lg);
$this->Line($x2-$lg,$y2,$x2+$lg,$y2);
//$this->Color('#000000');
}
// convert units (in to mm, mm to in)
// $src and $dest must be 'in' or 'mm'
function _Convert_Metric ($value, $src, $dest) {
if ($src != $dest) {
$tab['in'] = 39.37008;
$tab['mm'] = 1000;
return $value * $tab[$dest] / $tab[$src];
} else {
return $value;
}
}
// Give the height for a char size given.
function _Get_Height_Chars($pt) {
// Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes
$_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10);
if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
return $_Table_Hauteur_Chars[$pt];
} else {
return 100; // There is a prob..
}
}
function _Set_Format($format) {
$this->_Metric = $format['metric'];
$this->_Avery_Name = $format['name'];
$this->_Avery_Code = $format['code'];
$this->_Margin_Left = $this->_Convert_Metric ($format['marginLeft'], $this->_Metric, $this->_Metric_Doc);
$this->_Margin_Top = $this->_Convert_Metric ($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
$this->_X_Space = $this->_Convert_Metric ($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
$this->_Y_Space = $this->_Convert_Metric ($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
$this->_X_Number = $format['NX'];
$this->_Y_Number = $format['NY'];
$this->_Width = $this->_Convert_Metric ($format['width'], $this->_Metric, $this->_Metric_Doc);
$this->_Height = $this->_Convert_Metric ($format['height'], $this->_Metric, $this->_Metric_Doc);
$this->Set_Char_Size( $format['font-size']);
}
}
?>

View File

@@ -71,7 +71,7 @@ require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php');
/**
* \class pdf_standard
* \brief Classe afin d'editer au format PDF des etiquettes au format Avery ou personnalise
* \brief Classe afin d'editer au format PDF des cartes de visite au format Avery ou personnalise
*/
class pdf_standard {
@@ -386,7 +386,7 @@ class pdf_standard {
$dir = $conf->adherent->dir_temp;
$file = $dir . "/tmpcard.pdf";
$file = $dir . "/tmpcards.pdf";
if (! file_exists($dir))
{
@@ -449,7 +449,7 @@ class pdf_standard {
// Output to file
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -0,0 +1,129 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/includes/modules/member/labels/modules_labels.php
* \ingroup member
* \brief File of parent class of document generator for members labels sheets.
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
/**
* \class ModelePDFLabels
* \brief Parent class of document generator for members cards.
*/
class ModelePDFLabels
{
var $error='';
/**
* \brief Return list of active generation modules
* \param $db Database handler
*/
function liste_modeles($db)
{
global $conf;
$type='members_labels';
$liste=array();
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
$liste=getListOfModels($db,$type,'');
return $liste;
}
}
/**
* \brief Cree un fichier de cartes de visites en fonction du modele de ADHERENT_CARDS_ADDON_PDF
* \param db objet base de donnee
* \param id id de la facture a creer
* \param message message
* \param modele force le modele a utiliser ('' to not force)
* \param outputlangs objet lang a utiliser pour traduction
* \return int <0 if KO, >0 if OK
*/
function members_label_pdf_create($db, $arrayofmembers, $modele, $outputlangs)
{
global $conf,$langs;
$langs->load("members");
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/member/labels/";
// Positionne modele sur le nom du modele a utiliser
if (! dol_strlen($modele))
{
if ($conf->global->ADHERENT_ETIQUETTE_TYPE)
{
$modele = $conf->global->ADHERENT_ETIQUETTE_TYPE;
$code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
}
else
{
$modele = 'L7163';
$code = 'L7163';
}
}
$modele='standardlabel';
// Charge le modele
$file = "pdf_".$modele.".class.php";
if (file_exists($dir.$file))
{
$classname = "pdf_".$modele;
require_once($dir.$file);
$obj = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output;
if ($obj->write_file($arrayofmembers, $outputlangs) > 0)
{
$outputlangs->charset_output=$sav_charset_output;
return 1;
}
else
{
$outputlangs->charset_output=$sav_charset_output;
dol_print_error($db,"members_card_pdf_create Error: ".$obj->error);
return -1;
}
}
else
{
dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file));
return -1;
}
}
?>

View File

@@ -0,0 +1,460 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Inspire de PDF_Label
* PDF_Label - PDF label editing
* @package PDF_Label
* @author Laurent PASSEBECQ <lpasseb@numericable.fr>
* @copyright 2003 Laurent PASSEBECQ
* disponible ici : http://www.fpdf.org/fr/script/script29.php
*/
////////////////////////////////////////////////////
// PDF_Label
//
// Classe afin d'editer au format PDF des etiquettes
// au format Avery ou personnalise
//
//
// Copyright (C) 2003 Laurent PASSEBECQ (LPA)
// Base sur les fonctions de Steve Dillon : steved@mad.scientist.com
//
//-------------------------------------------------------------------
// VERSIONS :
// 1.0 : Initial release
// 1.1 : + : Added unit in the constructor
// + : Now Positions start @ (1,1).. then the first image @top-left of a page is (1,1)
// + : Added in the description of a label :
// font-size : defaut char size (can be changed by calling Set_Char_Size(xx);
// paper-size : Size of the paper for this sheet (thanx to Al Canton)
// metric : type of unit used in this description
// You can define your label properties in inches by setting metric to 'in'
// and printing in millimiter by setting unit to 'mm' in constructor.
// Added some labels :
// 5160, 5161, 5162, 5163,5164 : thanx to Al Canton : acanton@adams-blake.com
// 8600 : thanx to Kunal Walia : kunal@u.washington.edu
// + : Added 3mm to the position of labels to avoid errors
////////////////////////////////////////////////////
/**
* \file htdocs/includes/modules/member/pdf_standardlabel.class.php
* \ingroup member
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
* \author Steve Dillon
* \author Laurent Passebecq
* \author Rodolphe Quiedville
* \author Jean Louis Bergamo.
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php');
/**
* \class pdf_standardlabel
* \brief Classe afin d'editer au format PDF des pages d'etiquette adresse au format Avery ou personnalise
*/
class pdf_standardlabel {
var $code; // Code of format
var $format; // Array with informations
// Proprietes privees
var $_Avery_Name = ''; // Nom du format de l'etiquette
var $_Margin_Left = 0; // Marge de gauche de l'etiquette
var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette
var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes
var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes
var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page
var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page
var $_Width = 0; // Largeur de chaque etiquette
var $_Height = 0; // Hauteur de chaque etiquette
var $_Char_Size = 10; // Hauteur des caracteres
var $_Line_Height = 10; // Hauteur par defaut d'une ligne
var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values
var $_Metric_Doc = 'mm'; // Type of metric for the doc..
var $_COUNTX = 1;
var $_COUNTY = 1;
var $_First = 1;
/**
* Constructor
*/
function pdf_standard($db)
{
$this->db = $db;
}
//Methode qui permet de modifier la taille des caracteres
// Cela modiera aussi l'espace entre chaque ligne
function Set_Char_Size(&$pdf,$pt) {
if ($pt > 3) {
$this->_Char_Size = $pt;
$this->_Line_Height = $this->_Get_Height_Chars($pt);
$pdf->SetFont('Arial','',$pt);
}
}
// On imprime une etiquette
function Add_PDF_card(&$pdf,$textleft,$header='',$footer='',$outputlangs,$textright='')
{
global $mysoc,$conf,$langs;
// We are in a new page, then we must add a page
if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) {
$pdf->AddPage();
}
$this->_First=0;
$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
// Define logo
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
if (! is_readable($logo))
{
$logo='';
if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
{
$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
}
elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
{
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
}
}
// Print lines
if ($this->code == "CARD")
{
$this->Tformat=$this->_Avery_Labels["CARD"];
//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
$this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
}
// Top
if ($header!='')
{
if ($this->code == "CARD")
{
$pdf->SetDrawColor(128,128,128);
$pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1);
$pdf->SetDrawColor(0,0,0);
}
$pdf->SetXY($_PosX, $_PosY+1);
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
}
// Center
if ($textright=='') // Only a left part
{
if ($textleft == '%LOGO%' && $logo) $this->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20);
else if ($textleft == '%PHOTO%' && $photo) $this->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20);
else
{
$pdf->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft));
}
}
else if ($textleft!='' && $textright!='') //
{
if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
{
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20);
$pdf->SetXY($_PosX+21, $_PosY+3+$this->_Line_Height);
$pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
{
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));
}
else
{
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height);
$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft));
$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');
}
}
else // Only a right part
{
if ($textright == '%LOGO%' && $logo) $this->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20);
else if ($textright == '%PHOTO%' && $photo) $this->Image($photo,$_PosX+$this->_Width-21,$_PosY+1,20);
else
{
$pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
}
// Bottom
if ($footer!='')
{
if ($this->code == "CARD")
{
$pdf->SetDrawColor(128,128,128);
$pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
$pdf->SetDrawColor(0,0,0);
}
$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
}
//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
$this->_COUNTY++;
if ($this->_COUNTY == $this->_Y_Number) {
// Si on est en bas de page, on remonte le 'curseur' de position
$this->_COUNTX++;
$this->_COUNTY=0;
}
if ($this->_COUNTX == $this->_X_Number) {
// Si on est en bout de page, alors on repart sur une nouvelle page
$this->_COUNTX=0;
$this->_COUNTY=0;
}
}
function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15)
{
$pdf->SetLineWidth($epaisseur);
$longueur=abs($x1-$x2);
$hauteur=abs($y1-$y2);
if($longueur>$hauteur) {
$Pointilles=($longueur/$nbPointilles)/2; // taille des pointilles
}
else {
$Pointilles=($hauteur/$nbPointilles)/2;
}
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
}
}
}
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
}
}
}
}
/*
* Fonction realisant une croix aux 4 coins des cartes
*/
function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4)
{
$pdf->SetDrawColor(192,192,192);
$pdf->SetLineWidth($epaisseur);
$lg=$taille/2;
// croix haut gauche
$pdf->Line($x1,$y1-$lg,$x1,$y1+$lg);
$pdf->Line($x1-$lg,$y1,$x1+$lg,$y1);
// croix bas gauche
$pdf->Line($x1,$y2-$lg,$x1,$y2+$lg);
$pdf->Line($x1-$lg,$y2,$x1+$lg,$y2);
// croix haut droit
$pdf->Line($x2,$y1-$lg,$x2,$y1+$lg);
$pdf->Line($x2-$lg,$y1,$x2+$lg,$y1);
// croix bas droit
$pdf->Line($x2,$y2-$lg,$x2,$y2+$lg);
$pdf->Line($x2-$lg,$y2,$x2+$lg,$y2);
$pdf->SetDrawColor(0,0,0);
}
// convert units (in to mm, mm to in)
// $src and $dest must be 'in' or 'mm'
function _Convert_Metric ($value, $src, $dest) {
if ($src != $dest) {
$tab['in'] = 39.37008;
$tab['mm'] = 1000;
return $value * $tab[$dest] / $tab[$src];
} else {
return $value;
}
}
// Give the height for a char size given.
function _Get_Height_Chars($pt) {
// Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes
$_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10);
if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
return $_Table_Hauteur_Chars[$pt];
} else {
return 100; // There is a prob..
}
}
function _Set_Format(&$pdf, $format) {
$this->_Metric = $format['metric'];
$this->_Avery_Name = $format['name'];
$this->_Avery_Code = $format['code'];
$this->_Margin_Left = $this->_Convert_Metric ($format['marginLeft'], $this->_Metric, $this->_Metric_Doc);
$this->_Margin_Top = $this->_Convert_Metric ($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
$this->_X_Space = $this->_Convert_Metric ($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
$this->_Y_Space = $this->_Convert_Metric ($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
$this->_X_Number = $format['NX'];
$this->_Y_Number = $format['NY'];
$this->_Width = $this->_Convert_Metric ($format['width'], $this->_Metric, $this->_Metric_Doc);
$this->_Height = $this->_Convert_Metric ($format['height'], $this->_Metric, $this->_Metric_Doc);
$this->Set_Char_Size($pdf, $format['font-size']);
}
/**
* \brief Function to build PDF on disk, then output on HTTP strem.
* \param arrayofmembers Array of members informations
* \param outputlangs Lang object for output language
* \return int 1=ok, 0=ko
*/
function write_file($arrayofmembers,$outputlangs)
{
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
// Choose type (L7163 by default)
$this->code=empty($conf->global->ADHERENT_ETIQUETTE_TYPE)?'L7163':$conf->global->ADHERENT_ETIQUETTE_TYPE;
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
if (! is_object($outputlangs)) $outputlangs=$langs;
// Force output charset to ISO, because, FPDF expect text encoded in ISO
$outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("members");
$outputlangs->load("admin");
$dir = $conf->adherent->dir_temp;
$file = $dir . "/tmplabels.pdf";
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
// Protection et encryption du pdf
if ($conf->global->PDF_SECURITY_ENCRYPTION)
{
$pdf=new FPDI_Protection('P',$this->Tformat['metric'],$this->format);
$pdfrights = array('print'); // Ne permet que l'impression du document
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final
$pdfownerpass = NULL; // Mot de passe du proprietaire, cree aleatoirement si pas defini
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
}
else
{
$pdf=new FPDI('P',$this->Tformat['metric'],$this->format);
}
$pdf->SetTitle($outputlangs->transnoentities('MembersLabels'));
$pdf->SetSubject($outputlangs->transnoentities("MembersLabels"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->transnoentities('MembersLabels')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->nom));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$this->_Metric_Doc = $this->Tformat['metric'];
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
$posX=1;
$posY=1;
if ($posX > 0) $posX--; else $posX=0;
if ($posY > 0) $posY--; else $posY=0;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($pdf, $this->Tformat);
$pdf->Open();
$pdf->AddPage();
// Add each record
foreach($arrayofmembers as $val)
{
// imprime le texte specifique sur la carte
$this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']);
}
//$pdf->SetXY(10, 295);
//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
// Output to file
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
// Output to http stream
clearstatcache();
$attachment=true;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
$filename='tmplabels.pdf';
$type=dol_mimetype($filename);
if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($file);
return 1;
}
}
?>

View File

@@ -287,7 +287,7 @@ class pdf_baleine extends ModelePDFProjects
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -390,7 +390,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -399,7 +399,7 @@ class pdf_propale_azur extends ModelePDFPropales
//$pdfConcat->setFiles(array($file, DOL_DOCUMENT_ROOT."/includes/modules/propale/morefile.pdf"));
//$pdfConcat->concat();
//$pdf->AliasNbPages();
//$pdfConcat->Output($file);
//$pdfConcat->Output($file,'F');
$outputlangs->charset_output=$sav_charset_output;
return 1; // Pas d'erreur

View File

@@ -291,7 +291,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -203,7 +203,7 @@ class pdf_paiement
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -353,7 +353,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->Close();
$pdf->Output($file);
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@@ -3094,7 +3094,7 @@ function dol_textishtml($msg,$option=0)
}
/**
* Add substitution required by external modules then make substitutions.
* Make substition into a string
* There is two type of substitions:
* - From $substitutionarray (oldval=>newval)
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules