ZoomMode="real"; // $this->SetCreator("Eric DIENOT, www.123ventes.com"); $this->SetCreator($contactMsg[10], $_SESSION['nomSiteAff']); } // ----------------------------------------------------- // En-tete de la facture // ----------------------------------------------------- // gestionnaire raison soc $add $ville $cp $pays $tel idcde date mp ml civ fact nomcli prenom cli adressecli fact addr2 fact cp villecli idpaysfact civliv nomliv prenomLiv adrliv adr2liv cp liv vile liv pays liv tx remise adreouinon // ----------------------------------------------------- function hautDePage($raisonSoc, $add, $villeAdm, $cp, $pays, $tel, $idCde, $dateCdeCrea, $descriptionMP, $civ, $nom, $prenom, $adresseCli, $adresseCli2, $codePostCli, $ville, $libPaysFact, $civLiv, $nomLiv, $prenomLiv, $adrLiv, $adrLiv2, $codePostLiv, $villeLiv, $libellepaysliv, $txRemiseCli, $adresseLivOui, $telCli, $libDateEmission) { global $includePath; global $includePathDesign; global $includePathConf; if (empty($adresseCli2)) $adresseCli2="-"; if (empty($adrLiv2)) $adrLiv2="-"; $position=0; date_default_timezone_set( 'Europe/Paris' ) ; if (empty($lg)) $lg='FRA'; if ($lg=='ENG') { setlocale (LC_TIME, 'en_US.utf8', 'ang'); } else setlocale (LC_TIME, 'fr_FR.utf8', 'fra'); $dateTimeObj = new DateTime('now', new DateTimeZone('Europe/Paris')); $today = IntlDateFormatter::formatObject( $dateTimeObj, "y-MM-dd HH:mm", 'fr' ); $today= mb_convert_encoding($today, 'ISO-8859-1', 'UTF-8'); $posVertical0 = 10; // les messages finalement pas besoin de les passer en param on peut mettre un include ici include ($includePath. "/dataBaseConnect.php"); $refresh='Oui'; include ($includePath. "/req/09-init.enteteMsgList.php"); include ($includePath. "/req/06-init.cliMsgList.php"); include ($includePath. "/req/07-init.cdeMsgList.php"); $refresh='N'; // logo if (isset($titreImgPt[4])) { $test=substr(strtolower($titreImgPt[4]),-3); // cas html if ($test=='tml') { // $lire = file_get_contents($titreImgPt[4]); // $this->WriteHTML($titreImgPt[4]); // $pdf->SetFont('Arial','',12); // $pdf->AddPage(); // $pdf->WriteHTML($titreImgPt[4]); // $this->Cell(150, 5, "\n".ltrim(strip_tags($lire)), 0, 2, '', false); } else { $logoAffF=str_replace("./Design","",$titreImgPt[4]); // Image(string file [, float x [, float y [, float w [, float h [, string type [, mixed link]]]]]]) $this->Image($includePathDesign .$logoAffF, 10, $posVertical0, 30); } } // posX posY longueur // raison sociale $posVertical1 = $posVertical0 + 40; $this->SetFont('helvetica', 'B', 12); $this->SetTextColor(0, 0, 200); $this->SetXY(9, $posVertical1); $this->Cell(150, 5, "\n".ltrim(strip_tags($raisonSoc)), 0, 2, '', false); // adresse business $posVertical2 = $posVertical1 + 8; $this->SetFont('helvetica', '', 10); $this->SetTextColor(0, 0, 200); $this->SetXY(10, $posVertical2 ); $this->SetFont('helvetica', '', 10); $this->SetTextColor(0, 0, 0); $this->MultiCell(200, 5, strip_tags($add). "\n".strip_tags($cp). " ".strip_tags($villeAdm). "\n".strip_tags($pays). "\n", 0, 'L', false); // date emission $posVertical3 = $posVertical2 + 15; $this->SetFont('helvetica', '', 10); $this->SetXY(10, $posVertical3 ); $this->SetTextColor(0, 0, 0); $this->MultiCell(200, 5, "\n".($libDateEmission). ' '.($today). "\n".mb_convert_encoding($cdeMsg[17], 'ISO-8859-1', 'UTF-8'). " : ".($descriptionMP). "\n", 0, 'L', false); // ----------------------------------------------------- // Informations Facture // ----------------------------------------------------- $posVertical4 = $posVertical3 + 20; $this->SetXY(10, $posVertical4); $this->SetFillColor(200, 200, 200); $this->SetFont('helvetica', 'B', 15); $this->SetTextColor(0, 0, 0); $this->SetFont('helvetica', 'B', 12); $this->Cell(190, 10, mb_convert_encoding(strtoupper($cdeMsg[86]). " n° : " ,'ISO-8859-1', 'UTF-8') .$idCde , 1, 2, 'C', true); // deux blocs infos client fact et liv $posVertical5=$posVertical4 + 15; if ($adresseLivOui==1) { // Adresse de Facturation $this->SetXY(10, $posVertical5); $this->SetFillColor(200, 200, 200); $this->SetTextColor(0, 0, 0); $this->SetFont('helvetica', 'B', 11); $this->Cell(90, 8, $clientMsg[2], 1, 2, 'C', true); $this->SetFont('helvetica', '', 11); $this->MultiCell(90, 5, "\n".mb_convert_encoding($cdeMsg[87], 'ISO-8859-1', 'UTF-8'). "\n\n", 'LRB', 'L', false); } else { // Adresse de Facturation $this->SetXY(10, $posVertical5); $this->SetFillColor(200, 200, 200); $this->SetTextColor(0, 0, 0); $this->SetFont('helvetica', 'B', 11); $this->Cell(90, 8, mb_convert_encoding( strip_tags ( $clientMsg[1] ), 'ISO-8859-1', 'UTF-8' ), 1, 2, 'C', true); $this->SetFont('helvetica', '', 11); $prenom=$prenom. ' '; if (!empty($adresseCli2) && $adresseCli2!="-" ) $this->MultiCell(90, 5, "\n" .$civ. " " .$prenom. " " .$nom. "\n" .$adresseCli. " - " .$adresseCli2. "\n" .$codePostCli. " " .$ville. "\n" .$libPaysFact. "\n\n", 'LRB', 'L', false); else { $this->MultiCell(90, 5, "\n" .$civ. " " .$prenom. " " .$nom. "\n" .$adresseCli. "\n" .$codePostCli. " " .$ville. "\n" .$libPaysFact. "\n\n", 'LRB', 'L', false); } } $position=$this->getY(); // Adresse de livraison $this->SetXY(110, $posVertical5); $this->SetFillColor(200, 200, 200); $this->SetFont('helvetica', 'B', 11); $this->Cell(90, 6, mb_convert_encoding( strip_tags ( $clientMsg[2]) ,'ISO-8859-1', 'UTF-8') , 1, 2, 'C', true); $this->SetFont('helvetica', '', 12); if (!empty($adrLiv2) && $adrLiv2!='-') {$this->MultiCell(90, 5, "\n" .$civLiv. " " .$prenomLiv. " " .$nomLiv. "\n" .$adrLiv. " - " .$adrLiv2. "\n" .$codePostLiv. " " .$villeLiv. "\n" .$libellepaysliv. "\n\n", 'LRB', 'L', false);} else { $this->MultiCell(90, 5, "\n" .$civLiv. " " .$prenomLiv. " " .$nomLiv. "\n" .$adrLiv. "\n" .$codePostLiv. " " .$villeLiv. "\n" .$libellepaysliv. "\n\n", 'LRB', 'L', false); } // tel client liv $this->SetXY(110, $posVertical5+38); $this->SetFont('helvetica', '', 11); $this->SetTextColor(200, 100, 30); $this->Cell(90, 5, $telCli. "\n\n", 1, 2, 'L', false); if ($this->getY()>$position) { $position=$this->getY(); } $this->SetXY(10, $position+5); } // ----------------------------------------------------- // Préparation de la génération de la table // ----------------------------------------------------- function tableArticles($idPrd, $nomPrd, $prixUnitRemiseHt, $qteLigne, $nbLignes, $montantTvaLigne, $ttcLignes, $totalCde, $modeLiv, $fpCdeHt, $fpCdeTVA, $fpCdeTTC, $libRef, $libDesignation, $libPrixUHt, $libQte, $libTotLigneTTC, $libModeLiv, $libFpHt, $libFpTva, $libFpTTC, $libTotTTC, $libTraduit, $quantiteOption, $prixTotTTC, $prixTotHT, $tvaMontant, $lg) { $position = 0; $prixTotal = 0; $libRef = str_replace(":","",$libRef); // Tableau des titres des colonnes panier $header = array( mb_convert_encoding($libRef, 'ISO-8859-1', 'UTF-8'), mb_convert_encoding($libDesignation, 'ISO-8859-1', 'UTF-8'), $libPrixUHt, mb_convert_encoding($libQte, 'ISO-8859-1', 'UTF-8'), mb_convert_encoding($libFpTva, 'ISO-8859-1', 'UTF-8'), mb_convert_encoding($libTotLigneTTC, 'ISO-8859-1', 'UTF-8') ); // Tableau des données options $datasOpt = array(); if (!empty($libTraduit)) { for($ij=0; $ij<$nbLignes; $ij++) { if (!empty($libTraduit[$ij])) { for($o=0; $otablePrd($header, $w, $al, $datas, $datasOpt); // $this->table($header, $w, $al, $datasOpt); // ----------------------------------------------------- // Tableau frais de livaison // ----------------------------------------------------- $this->SetY($this->GetY()+10); // Tableau contenant les titres des colonnes $header=array(mb_convert_encoding($libModeLiv ,'ISO-8859-1', 'UTF-8'), mb_convert_encoding($libFpHt ,'ISO-8859-1', 'UTF-8'), mb_convert_encoding($libFpTva ,'ISO-8859-1', 'UTF-8'), mb_convert_encoding($libFpTTC ,'ISO-8859-1', 'UTF-8')); // Creation des donnees qui seront contenues la table $datas = array(); $datas[] = array(mb_convert_encoding($modeLiv ,'ISO-8859-1', 'UTF-8'), $fpCdeHt. ' '.chr(128), $fpCdeTVA.chr(128), $fpCdeTTC. ' '.chr(128)); // Tableau contenant la largeur des colonnes $w=array(90, 50, 25, 25); // Tableau contenant le centrage des colonnes $al=array('C', 'C', 'C', 'C'); $this->tableLivr($header, $w, $al, $datas, ""); // ----------------------------------------------------- // Tableau de synthese // ----------------------------------------------------- $this->SetY($this->GetY()+10); $this->SetFillColor(200, 200, 200); $this->SetTextColor(0); $this->SetDrawColor(0, 0, 0); $this->SetFont('helvetica', 'B', 9); $this->setX(150); $this->Cell(30, 6, $libTotTTC, 1, 0, 'C'); $this->SetFillColor(245, 245, 245); $this->SetTextColor(0); $this->SetFont('helvetica'); $totalCde=(float)$totalCde; $totalCde=number_format($totalCde, 2, ', ', ' '); $this->Cell(20, 6, $totalCde. ' '.chr(128), 1, 2, 'C'); } // ----------------------------------------------------- // Pied de page // ----------------------------------------------------- function Footer() { // Positionnement 1, 5 cm du bas $this->SetY(-15); // Police helvetica italique 8 $this->SetFont('helvetica', 'I', 8); // Numéro de page $this->Cell(0, 4, 'Page ' .$this->PageNo(). '/{nb}', 0, 2, 'C'); $this->MultiCell(0, 4, mb_convert_encoding($_SESSION['nomSiteAff'], 'ISO-8859-1', 'UTF-8'). " - " .$_SESSION['siretAff']. "\n", 0, 'C', false); } // ----------------------------------------------------- // Impression de l'entree du tableau // ----------------------------------------------------- function printTableHeader($header, $w) { // Couleurs, epaisseur du trait et police grasse $this->SetFillColor(200, 200, 200); $this->SetTextColor(0); $this->SetDrawColor(0, 0, 0); $this->SetFont('helvetica', 'B', 9); for($i=0;$iCell($w[$i], 7, $header[$i], 1, 0, 'C', 1); $this->Ln(); // Restauration des couleurs et de la police pour les données du tableau $this->SetFillColor(245, 245, 245); $this->SetTextColor(0); $this->SetFont('helvetica'); } // ----------------------------------------------------- // Impression des options // ----------------------------------------------------- function affOpt($header, $w, $al, $opt, $posStartX, $posAfterY) { foreach($opt as $row2) { $this->MultiCell($w[$j], 6, strip_tags($row2[$j]), '', $al[$j], false); } } // ----------------------------------------------------- // Generation du tableau produit // table(données de l'entete tableau, largeur des colonnes, alignement des colonnes, donnees) // ----------------------------------------------------- function tablePrd($header, $w, $al, $datas, $opt) { // Impression de l'entete tableau $this->SetLineWidth(.3); $this->printTableHeader($header, $w); $posStartX=$this->getX(); $posBeforeX=$posStartX; $posBeforeY=$this->getY(); $posAfterY=$posBeforeY; $posStartY=$posBeforeY; // On parcours le tableau des données $a=0; foreach($datas as $row) { $posBeforeX=$posStartX; $posBeforeY=$posAfterY; // On vérifie qu'il n'y a pas débordement de page. $nb=0; for($i=0;$iNbLines($w[$i], $row[$i])); } $h=6*$nb; // Effectue un saut de page si il y a debordement $resultat = $this->CheckPageBreak($h, $w, $header, $posStartX, $posStartY, $posAfterY); if ($resultat>0) { $posAfterY=$resultat; $posBeforeY=$resultat; $posStartY=$resultat; } // Impression de la ligne for($i=0;$iMultiCell($w[$i], 6, strip_tags($row[$i]), '', $al[$i], false); // On enregistre la plus grande hauteur de cellule if ($posAfterY<$this->getY()) { $posAfterY=$this->getY(); } $posBeforeX+=$w[$i]; $this->setXY($posBeforeX, $posBeforeY); } // -- otions // Trace de la ligne du dessous // var_dump($opt); $this->Line($posStartX, $posAfterY, $posBeforeX, $posAfterY); $this->setXY($posStartX, $posAfterY); // Impression des lignes options $b=0; if (!empty($opt[$a])) { $opt2=$opt[$a]; // var_dump($opt2); foreach($opt2 as $row2) { // echo '
a = ' .$a. ' row2 = '.var_dump($row2). ' $row2[0]' .$row2[0]; $posBeforeX=$posStartX; $posBeforeY=$posAfterY; // On vérifie qu'il n'y a pas débordement de page. $nb=0; for($i=0;$iNbLines($w[$i], $row[$i])); } $h=6*$nb; // Effectue un saut de page si il y a debordement $resultat = $this->CheckPageBreak($h, $w, $header, $posStartX, $posStartY, $posAfterY); if ($resultat>0) { $posAfterY=$resultat; $posBeforeY=$resultat; $posStartY=$resultat; } for($i=0; $iMultiCell($w[$i], 6, strip_tags($row2[$i]), '', $al[$i], false); // On enregistre la plus grande hauteur de cellule if ($posAfterY<$this->getY()) { $posAfterY=$this->getY(); } $posBeforeX+=$w[$i]; $this->setXY($posBeforeX, $posBeforeY); } $this->Line($posStartX, $posAfterY, $posBeforeX, $posAfterY); $this->setXY($posStartX, $posAfterY); $b++; } } $a++; // Trace de la ligne du dessous $this->Line($posStartX, $posAfterY, $posBeforeX, $posAfterY); $this->setXY($posStartX, $posAfterY); } // Trace des colonnes $this->PrintCols($w, $posStartX, $posStartY, $posAfterY); } // ----------------------------------------------------- // Generation du tableau livraison // table(données de l'entete tableau, largeur des colonnes, alignement des colonnes, donnees) // ----------------------------------------------------- function tableLivr($header, $w, $al, $datas, $opt) { // Impression de l'entete tableau $this->SetLineWidth(.3); $this->printTableHeader($header, $w); $posStartX=$this->getX(); $posBeforeX=$posStartX; $posBeforeY=$this->getY(); $posAfterY=$posBeforeY; $posStartY=$posBeforeY; // On parcours le tableau des données foreach($datas as $row) { $posBeforeX=$posStartX; $posBeforeY=$posAfterY; // On vérifie qu'il n'y a pas débordement de page. $nb=0; for($i=0;$iNbLines($w[$i], $row[$i])); } $h=6*$nb; // Effectue un saut de page si il y a debordement $resultat = $this->CheckPageBreak($h, $w, $header, $posStartX, $posStartY, $posAfterY); if ($resultat>0) { $posAfterY=$resultat; $posBeforeY=$resultat; $posStartY=$resultat; } // Impression de la ligne for($i=0;$iMultiCell($w[$i], 6, strip_tags($row[$i]), '', $al[$i], false); // On enregistre la plus grande hauteur de cellule if ($posAfterY<$this->getY()) { $posAfterY=$this->getY(); } $posBeforeX+=$w[$i]; $this->setXY($posBeforeX, $posBeforeY); } // Trace de la ligne du dessous $this->Line($posStartX, $posAfterY, $posBeforeX, $posAfterY); $this->setXY($posStartX, $posAfterY); } // Trace des colonnes $this->PrintCols($w, $posStartX, $posStartY, $posAfterY); } // ----------------------------------------------------- // Tracé des colonnes // ----------------------------------------------------- function PrintCols($w, $posStartX, $posStartY, $posAfterY) { $this->Line($posStartX, $posStartY, $posStartX, $posAfterY); $colX=$posStartX; // On trace la ligne pour chaque colonne foreach($w as $row) { $colX+=$row; $this->Line($colX, $posStartY, $colX, $posAfterY); } } // ----------------------------------------------------- // Verification du debordement de page // ----------------------------------------------------- function CheckPageBreak($h, $w, $header, $posStartX, $posStartY, $posAfterY) { // Si la hauteur h provoque un debordement, saut de page manuel if ($this->GetY()+$h>$this->PageBreakTrigger) { // On imprime les colonnes de la page actuelle $this->PrintCols($w, $posStartX, $posStartY, $posAfterY); // On ajoute une page $this->AddPage(); // On reimprime l'enttte du tableau $this->printTableHeader($header, $w); // On renvoi la position courante sur la nouvelle page return $this->GetY(); } // On a pas effectue de saut on revoie 0 return 0; } // ----------------------------------------------------- // Calcule le nombre de lignes qu'occupe un MultiCell de largeur w // ----------------------------------------------------- function NbLines($w, $txt) { $cw=&$this->CurrentFont['cw']; if ($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r", '', $txt); $nb=strlen($s); if ($nb>0 and $s[$nb-1]=="\n") $nb--; $sep=-1; $i=0; $j=0; $l=0; $nl=1; while($i<$nb) { $c=$s[$i]; if ($c=="\n") { $i++;$sep=-1;$j=$i;$l=0;$nl++; continue; } if ($c==' ') $sep=$i; $l+=$cw[$c]; if ($l>$wmax) { if ($sep==-1) { if ($i==$j) $i++; } else $i=$sep+1; $sep=-1; $j=$i; $l=0; $nl++; } else $i++; } return $nl; } } ?>