diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 7953e278d41..cdf67bd254f 100755 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2006-2008 Laurent Destailleur + * Copyright (C) 2006-2010 Laurent Destailleur * * 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 @@ -24,7 +24,6 @@ * \brief Page to output members business cards * \version $Id$ */ - require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); diff --git a/htdocs/adherents/cartes/etiquette.php b/htdocs/adherents/cartes/etiquette.php index 0865d1fff7e..24ff5ca248d 100755 --- a/htdocs/adherents/cartes/etiquette.php +++ b/htdocs/adherents/cartes/etiquette.php @@ -44,13 +44,8 @@ if (! file_exists($dir)) } - -//$pdf = new PDF_card('CARD', 1, 1); -if (defined("ADHERENT_ETIQUETTE_TYPE") && ADHERENT_ETIQUETTE_TYPE !=''){ - $pdf = new PDF_card(ADHERENT_ETIQUETTE_TYPE, 1, 1); -}else{ - $pdf = new PDF_card('L7163', 1, 1); -} +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(); diff --git a/htdocs/admin/adherent.php b/htdocs/admin/adherent.php index 7eeb5b3b849..7af2ed6914f 100644 --- a/htdocs/admin/adherent.php +++ b/htdocs/admin/adherent.php @@ -43,6 +43,8 @@ $typeconst=array('yesno','texte','chaine'); // Action mise a jour ou ajout d'une constante if ($_POST["action"] == 'update' || $_POST["action"] == 'add') { + if (($_POST["constname"]=='ADHERENT_CARD_TYPE' || $_POST["constname"]=='ADHERENT_ETIQUETTE_TYPE') + && $_POST["constvalue"] == -1) $_POST["constvalue"]=''; $result=dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:'',$conf->entity); if ($result < 0) { @@ -71,6 +73,7 @@ if ($_GET["action"] == 'unset') } + /* * View */ @@ -219,7 +222,8 @@ $constantes=array( 'ADHERENT_CARD_HEADER_TEXT', 'ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT_RIGHT', - 'ADHERENT_CARD_FOOTER_TEXT' + 'ADHERENT_CARD_FOOTER_TEXT', + 'ADHERENT_CARD_TYPE' ); print_fiche_titre($langs->trans("MembersCards"),'',''); @@ -271,7 +275,7 @@ llxFooter('$Date$ - $Revision$'); function form_constantes($tableau) { - global $db,$bc,$langs,$conf; + global $db,$bc,$langs,$conf,$_Avery_Labels; $form = new Form($db); @@ -319,16 +323,17 @@ function form_constantes($tableau) print $langs->trans("Desc".$const) != ("Desc".$const) ? $langs->trans("Desc".$const) : ($obj->note?$obj->note:$const); print "\n"; - if ($const == 'ADHERENT_ETIQUETTE_TYPE') + if ($const == 'ADHERENT_CARD_TYPE' || $const == 'ADHERENT_ETIQUETTE_TYPE') { print ''; - // List of possible labels. Values must exists in - // file htdocs/adherents/PDF_Card.class.php - require_once(DOL_DOCUMENT_ROOT.'/includes/modules/member/PDF_card.class.php'); - $pdfcardstatic=new PDF_card('5160',1,1,'mm'); - $arrayoflabels=array_keys($pdfcardstatic->_Avery_Labels); - - $form->select_array('constvalue',$arrayoflabels,$obj->value,1,0,1); + // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php) + require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php'); + $arrayoflabels=array(); + foreach(array_keys($_Avery_Labels) as $codecards) + { + $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; + } + $form->select_array('constvalue',$arrayoflabels,($obj->value?$obj->value:'CARD'),1,0,0); print ''; $form->select_array('consttype',array('yesno','texte','chaine'),1); } diff --git a/htdocs/includes/modules/member/PDF_card.class.php b/htdocs/includes/modules/member/PDF_card.class.php index 457c434dba9..63a9c12a31a 100644 --- a/htdocs/includes/modules/member/PDF_card.class.php +++ b/htdocs/includes/modules/member/PDF_card.class.php @@ -65,6 +65,7 @@ */ 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'); @@ -74,6 +75,9 @@ require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php'); */ 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 @@ -93,106 +97,6 @@ class PDF_card extends FPDF { var $_COUNTY = 1; var $_First = 1; - // Listing of labels size - var $_Avery_Labels = array ( - '5160'=>array('name'=>'5160', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>1.762, - 'marginTop'=>10.7, - 'NX'=>3, - 'NY'=>10, - 'SpaceX'=>3.175, - 'SpaceY'=>0, - 'width'=>66.675, - 'height'=>25.4, - 'font-size'=>8), - '5161'=>array('name'=>'5161', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>0.967, - 'marginTop'=>10.7, - 'NX'=>2, - 'NY'=>10, - 'SpaceX'=>3.967, - 'SpaceY'=>0, - 'width'=>101.6, - 'height'=>25.4, - 'font-size'=>8), - '5162'=>array('name'=>'5162', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>0.97, - 'marginTop'=>20.224, - 'NX'=>2, - 'NY'=>7, - 'SpaceX'=>4.762, - 'SpaceY'=>0, - 'width'=>100.807, - 'height'=>35.72, - 'font-size'=>8), - '5163'=>array('name'=>'5163', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>1.762, - 'marginTop'=>10.7, - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>3.175, - 'SpaceY'=>0, - 'width'=>101.6, - 'height'=>50.8, - 'font-size'=>8), - '5164'=>array('name'=>'5164', - 'paper-size'=>'letter', - 'metric'=>'in', - 'marginLeft'=>0.148, - 'marginTop'=>0.5, - 'NX'=>2, - 'NY'=>3, - 'SpaceX'=>0.2031, - 'SpaceY'=>0, - 'width'=>4.0, - 'height'=>3.33, - 'font-size'=>12), - '8600'=>array('name'=>'8600', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>7.1, - 'marginTop'=>19, - 'NX'=>3, - 'NY'=>10, - 'SpaceX'=>9.5, - 'SpaceY'=>3.1, - 'width'=>66.6, - 'height'=>25.4, - 'font-size'=>8), - 'L7163'=>array('name'=>'L7163', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>5, - 'marginTop'=>15, - 'NX'=>2, - 'NY'=>7, - 'SpaceX'=>25, - 'SpaceY'=>0, - 'width'=>99.1, - 'height'=>38.1, - 'font-size'=>10), - 'CARD'=>array('name'=>'CARD', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>15, - 'marginTop'=>15, - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>0, - 'SpaceY'=>0, - 'width'=>85, - 'height'=>54, - 'font-size'=>10) - ); - /** @@ -206,14 +110,14 @@ class PDF_card extends FPDF { */ function PDF_card ($format, $posX=1, $posY=1, $unit='mm') { - global $conf,$mysoc; + 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 = $this->_Avery_Labels[$format]; + $Tformat = $_Avery_Labels[$format]; if (empty($Tformat)) { dol_print_error('','Format value "'.$format.'" is not supported.'); @@ -456,6 +360,7 @@ class PDF_card extends FPDF { 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); diff --git a/htdocs/includes/modules/member/cards/pdf_standard.class.php b/htdocs/includes/modules/member/cards/pdf_standard.class.php index 911f3d01f78..b7cc8279a07 100644 --- a/htdocs/includes/modules/member/cards/pdf_standard.class.php +++ b/htdocs/includes/modules/member/cards/pdf_standard.class.php @@ -65,6 +65,7 @@ */ 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'); @@ -74,14 +75,17 @@ require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php'); */ class pdf_standard { + 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 $_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 @@ -93,129 +97,13 @@ class pdf_standard { var $_COUNTY = 1; var $_First = 1; - // Listing of labels size - var $_Avery_Labels = array ( - '5160'=>array('name'=>'5160', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>1.762, - 'marginTop'=>10.7, - 'NX'=>3, - 'NY'=>10, - 'SpaceX'=>3.175, - 'SpaceY'=>0, - 'width'=>66.675, - 'height'=>25.4, - 'font-size'=>8), - '5161'=>array('name'=>'5161', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>0.967, - 'marginTop'=>10.7, - 'NX'=>2, - 'NY'=>10, - 'SpaceX'=>3.967, - 'SpaceY'=>0, - 'width'=>101.6, - 'height'=>25.4, - 'font-size'=>8), - '5162'=>array('name'=>'5162', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>0.97, - 'marginTop'=>20.224, - 'NX'=>2, - 'NY'=>7, - 'SpaceX'=>4.762, - 'SpaceY'=>0, - 'width'=>100.807, - 'height'=>35.72, - 'font-size'=>8), - '5163'=>array('name'=>'5163', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>1.762, - 'marginTop'=>10.7, - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>3.175, - 'SpaceY'=>0, - 'width'=>101.6, - 'height'=>50.8, - 'font-size'=>8), - '5164'=>array('name'=>'5164', - 'paper-size'=>'letter', - 'metric'=>'in', - 'marginLeft'=>0.148, - 'marginTop'=>0.5, - 'NX'=>2, - 'NY'=>3, - 'SpaceX'=>0.2031, - 'SpaceY'=>0, - 'width'=>4.0, - 'height'=>3.33, - 'font-size'=>12), - '8600'=>array('name'=>'8600', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>7.1, - 'marginTop'=>19, - 'NX'=>3, - 'NY'=>10, - 'SpaceX'=>9.5, - 'SpaceY'=>3.1, - 'width'=>66.6, - 'height'=>25.4, - 'font-size'=>8), - 'L7163'=>array('name'=>'L7163', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>5, - 'marginTop'=>15, - 'NX'=>2, - 'NY'=>7, - 'SpaceX'=>25, - 'SpaceY'=>0, - 'width'=>99.1, - 'height'=>38.1, - 'font-size'=>10), - 'CARD'=>array('name'=>'CARD', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>15, - 'marginTop'=>15, - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>0, - 'SpaceY'=>0, - 'width'=>85, - 'height'=>54, - 'font-size'=>10) - ); - - /** * Constructor - * - * @param unknown_type $format Avery format of label paper. For example 5160, 5161, 5162, 5163, 5164, 8600, L7163, CARD - * @param unknown_type $posX - * @param unknown_type $posY - * @param unknown_type $unit - * @return PDF_card */ - function pdf_standard($db, $format='CARD', $posX=1, $posY=1, $unit='mm') + function pdf_standard($db) { - global $conf,$langs,$mysoc; - $this->db = $db; - - $this->Tformat = $this->_Avery_Labels[$format]; - - // Dimension page pour format A4 - $this->type = 'pdf'; - $this->format = $this->Tformat['paper-size']; - } @@ -264,84 +152,88 @@ class pdf_standard { $photo=$dir.'/'.$file; if (! is_readable($photo)) $photo=''; - if ($this->_Avery_Name == "CARD") + // 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!=''){ + // 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'); + } + $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'); } - // Center - if ($textright=='') // Only a left part + } + 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 { - 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)); - } + $pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); } - 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!='') + // 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'); } + $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
\n"; - } - else - { - $pdf->SetXY($_PosX+3, $_PosY+3); - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft)); - } $this->_COUNTY++; if ($this->_COUNTY == $this->_Y_Number) { @@ -439,6 +331,7 @@ class pdf_standard { $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); @@ -459,7 +352,14 @@ class pdf_standard { */ function write_file($arrayofmembers,$outputlangs) { - global $user,$langs,$conf; + global $user,$conf,$langs,$mysoc,$_Avery_Labels; + + // Choose type (CARD by default) + $this->code=empty($conf->global->ADHERENT_CARD_TYPE)?'CARD':$conf->global->ADHERENT_CARD_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 @@ -487,7 +387,7 @@ class pdf_standard { // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) { - $pdf=new FPDI_Protection('P','mm',$this->format); + $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 @@ -495,15 +395,17 @@ class pdf_standard { } else { - $pdf=new FPDI('P','mm',$this->format); + $pdf=new FPDI('P',$this->Tformat['metric'],$this->format); } $pdf->SetMargins(0,0); $pdf->SetAutoPageBreak(false); - $this->_Metric_Doc = 'mm'; + $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; @@ -522,6 +424,9 @@ class pdf_standard { $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id']); } + //$pdf->SetXY(10, 295); + //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C'); + // Output to file $pdf->Output($file); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 188bf3c4ede..53d813448b0 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -138,7 +138,8 @@ DescADHERENT_MAIL_COTIS=EMail for subscription DescADHERENT_MAIL_RESIL_SUBJECT=EMail subject for member resiliation DescADHERENT_MAIL_RESIL=EMail for member resiliation DescADHERENT_MAIL_FROM=Sender EMail for automatic emails -DescADHERENT_ETIQUETTE_TYPE=Labels format +DescADHERENT_ETIQUETTE_TYPE=Format of labels page +DescADHERENT_CARD_TYPE=Format of cards page DescADHERENT_CARD_HEADER_TEXT=Text printed on top of member cards DescADHERENT_CARD_TEXT=Text printed on member cards (align on left) DescADHERENT_CARD_TEXT_RIGHT=Text printed on member cards (align on right) diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 5b9b006b457..b705af93449 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -138,7 +138,8 @@ DescADHERENT_MAIL_COTIS=Mail de validation d'une adhésion DescADHERENT_MAIL_RESIL_SUBJECT=Sujet du mail de résiliation DescADHERENT_MAIL_RESIL=Mail de résiliation DescADHERENT_MAIL_FROM=Mail émetteur pour les mails automatique -DescADHERENT_ETIQUETTE_TYPE=Format étiquettes +DescADHERENT_ETIQUETTE_TYPE=Format pages étiquettes +DescADHERENT_CARD_TYPE=Format pages cartes visites DescADHERENT_CARD_HEADER_TEXT=Texte imprimé sur le haut des cartes adhérents DescADHERENT_CARD_TEXT=Texte imprimé sur les cartes adhérents (Aligné à gauche) DescADHERENT_CARD_TEXT_RIGHT=Texte imprimé sur les cartes adhérents (Aligné à droite) diff --git a/htdocs/lib/format_cards.lib.php b/htdocs/lib/format_cards.lib.php new file mode 100644 index 00000000000..6754416659e --- /dev/null +++ b/htdocs/lib/format_cards.lib.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007 Patrick Raguin + * + * 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/lib/format_cards.lib.php + * \brief Set of functions used for cards generation + * \ingroup core + * \version $Id$ + */ + + + +global $_Avery_Labels; + + +$_Avery_Labels = array ( + '5160'=>array('name'=>'5160', + 'paper-size'=>'letter', + 'metric'=>'mm', + 'marginLeft'=>1.762, + 'marginTop'=>10.7, + 'NX'=>3, + 'NY'=>10, + 'SpaceX'=>3.175, + 'SpaceY'=>0, + 'width'=>66.675, + 'height'=>25.4, + 'font-size'=>8), + '5161'=>array('name'=>'5161', + 'paper-size'=>'letter', + 'metric'=>'mm', + 'marginLeft'=>0.967, + 'marginTop'=>10.7, + 'NX'=>2, + 'NY'=>10, + 'SpaceX'=>3.967, + 'SpaceY'=>0, + 'width'=>101.6, + 'height'=>25.4, + 'font-size'=>8), + '5162'=>array('name'=>'5162', + 'paper-size'=>'letter', + 'metric'=>'mm', + 'marginLeft'=>0.97, + 'marginTop'=>20.224, + 'NX'=>2, + 'NY'=>7, + 'SpaceX'=>4.762, + 'SpaceY'=>0, + 'width'=>100.807, + 'height'=>35.72, + 'font-size'=>8), + '5163'=>array('name'=>'5163', + 'paper-size'=>'letter', + 'metric'=>'mm', + 'marginLeft'=>1.762, + 'marginTop'=>10.7, + 'NX'=>2, + 'NY'=>5, + 'SpaceX'=>3.175, + 'SpaceY'=>0, + 'width'=>101.6, + 'height'=>50.8, + 'font-size'=>8), + '5164'=>array('name'=>'5164', + 'paper-size'=>'letter', + 'metric'=>'in', + 'marginLeft'=>0.148, + 'marginTop'=>0.5, + 'NX'=>2, + 'NY'=>3, + 'SpaceX'=>0.2031, + 'SpaceY'=>0, + 'width'=>4.0, + 'height'=>3.33, + 'font-size'=>12), + '8600'=>array('name'=>'8600', + 'paper-size'=>'letter', + 'metric'=>'mm', + 'marginLeft'=>7.1, + 'marginTop'=>19, + 'NX'=>3, + 'NY'=>10, + 'SpaceX'=>9.5, + 'SpaceY'=>3.1, + 'width'=>66.6, + 'height'=>25.4, + 'font-size'=>8), + 'L7163'=>array('name'=>'L7163', + 'paper-size'=>'A4', + 'metric'=>'mm', + 'marginLeft'=>5, + 'marginTop'=>15, + 'NX'=>2, + 'NY'=>7, + 'SpaceX'=>25, + 'SpaceY'=>0, + 'width'=>99.1, + 'height'=>38.1, + 'font-size'=>10), + 'AVERYC32010'=>array('name'=>'AVERY-C32010', + 'paper-size'=>'A4', + 'metric'=>'mm', + 'marginLeft'=>15, + 'marginTop'=>13, + 'NX'=>2, + 'NY'=>5, + 'SpaceX'=>10, + 'SpaceY'=>0, + 'width'=>85, + 'height'=>54, + 'font-size'=>10), + 'CARD'=>array('name'=>'Dolibarr cards', + 'paper-size'=>'A4', + 'metric'=>'mm', + 'marginLeft'=>15, + 'marginTop'=>15, + 'NX'=>2, + 'NY'=>5, + 'SpaceX'=>0, + 'SpaceY'=>0, + 'width'=>85, + 'height'=>54, + 'font-size'=>10) + ); + + +?> \ No newline at end of file