From 24b39da556b19a5c6278b957842d9ea3dadf14c7 Mon Sep 17 00:00:00 2001 From: jlb Date: Wed, 27 Aug 2003 17:49:28 +0000 Subject: [PATCH] amelioration du design des cartes d'adherents (ajout de logo, header et footer) --- htdocs/adherents/cartes/PDF_card.class.php | 36 +++++++++++++++++----- htdocs/adherents/cartes/carte.php | 16 ++++++---- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/htdocs/adherents/cartes/PDF_card.class.php b/htdocs/adherents/cartes/PDF_card.class.php index c60f02e5e7a..bad1fe84884 100755 --- a/htdocs/adherents/cartes/PDF_card.class.php +++ b/htdocs/adherents/cartes/PDF_card.class.php @@ -77,7 +77,7 @@ class PDF_card extends FPDF { var $_COUNTX = 1; var $_COUNTY = 1; - + var $_First = 1; // Listing of labels size var $_Avery_Labels = array ( @@ -176,7 +176,9 @@ class PDF_card extends FPDF { 'SpaceY'=>0, 'width'=>85, 'height'=>54, - 'font-size'=>10) + 'font-size'=>10, + 'logo1'=>'logo1.jpg', + 'logo2'=>'logo2.png') ); // convert units (in to mm, mm to in) @@ -250,20 +252,40 @@ class PDF_card extends FPDF { } // On imprime une étiqette - function Add_PDF_card($texte) { + function Add_PDF_card($texte,$header='',$footer='') { // We are in a new page, then we must add a page - if (($this->_COUNTX ==0) and ($this->_COUNTY==0)) { + 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)); if ($this->_Avery_Name == "CARD") { + $Tformat=$this->_Avery_Labels["CARD"]; $this->_Pointille($_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,1,25); + 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); + } + //$this->image('logo1.jpg',$_PosX+$this->_Width-21,$_PosY+1,20); + if ($header!=''){ + $this->SetXY($_PosX, $_PosY+1); + $this->Cell($this->_Width, $this->_Line_Height,$header,0,1,'C'); + } + $this->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height); + $this->MultiCell($this->_Width, $this->_Line_Height, $texte); + if ($footer!=''){ + $this->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); + $this->Cell($this->_Width, $this->_Line_Height,$footer,0,1,'C'); + } + + }else{ + $this->SetXY($_PosX+3, $_PosY+3); + $this->MultiCell($this->_Width, $this->_Line_Height, $texte); } - $this->SetXY($_PosX+3, $_PosY+3); - $this->MultiCell($this->_Width, $this->_Line_Height, $texte); $this->_COUNTY++; if ($this->_COUNTY == $this->_Y_Number) { diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index f9aae80e952..9d18e960261 100755 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -41,17 +41,21 @@ Soit on donne le type d' // Dans cet exemple on va commencer l'impression des étiquettes à partir de la seconde colonne (cf les 2 derniers paramètres 1 et 2) //$pdf = new PDF_Label(array('name'=>'perso1', 'marginLeft'=>1, 'marginTop'=>1, 'NX'=>2, 'NY'=>7, 'SpaceX'=>0, 'SpaceY'=>0, 'width'=>99.1, 'height'=>'38.1', 'metric'=>'mm', 'font-size'=>14), 1, 2); //$pdf = new PDF_card('L7163', 1, 2); -$pdf = new PDF_card('CARD', 1, 2); +$pdf = new PDF_card('CARD', 1, 1); //$db = new Db(); $pdf->Open(); $pdf->AddPage(); -$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, ".$db->pdate("d.datefin")." as datefin, adresse,cp,ville,pays"; +if (!isset($annee)){ + $now = getdate(); + $annee=$now['year']; +} +$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, ".$db->pdate("d.datefin")." as datefin, adresse,cp,ville,pays, t.libelle as type"; $sql .= " , d.email"; -$sql .= " FROM llx_adherent as d"; -$sql .= " WHERE d.statut = 1"; -$sql .= " ORDER BY d.nom ASC "; +$sql .= " FROM llx_adherent as d, llx_adherent_type as t"; +$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; +$sql .= " ORDER BY d.rowid ASC "; $result = $db->query($sql); if ($result) @@ -61,7 +65,7 @@ if ($result) while ($i < $num) { $objp = $db->fetch_object( $i); - $pdf->Add_PDF_card(sprintf("%s\n%s\n%s\n%s\n%s, %s, %s", "N° :".$objp->rowid,$objp->prenom." ".$objp->nom,"<".$objp->email.">", $objp->adresse, $objp->cp, $objp->ville, $objp->pays)); + $pdf->Add_PDF_card(sprintf("%s\n%s\n%s\n%s\n%s, %s, %s", "Adhérent ".$objp->type." n°".$objp->rowid,$objp->prenom." ".$objp->nom,"<".$objp->email.">", $objp->adresse, $objp->cp, $objp->ville, $objp->pays),$annee,"Association FreeLUG http://www.freelug.org/"); $i++; } // On imprime les étiquettes