103, "B"=>104, "C"=>105); // Caractères de changement de jeu var $JSwap = array("A"=>101, "B"=>100, "C"=>99); function Footer() { // surcharge fpdf //Pied de page //Positionnement a 1,5 cm du bas $this->SetY(-15); //Police Arial italique 8 $this->SetFont('Arial', 'I', 8); //Numero de page $this->Cell(0, 10, 'Page '.$this->PageNo().'/{nb}', 0, 0, 'C'); } /** * */ function TextWithRotation($xr, $yr, $txtr, $txtr_angle, $font_angle = 0) { //nouvelle fonction : ROTATION texte 90 45 ..... $txtr=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txtr))); // $font_angle+=90+$txtr_angle; $txtr_angle*=M_PI/180; $font_angle*=M_PI/180; // $txtr_dx=cos($txtr_angle); $txtr_dy=sin($txtr_angle); $font_dx=cos($font_angle); $font_dy=sin($font_angle); // $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET', $txtr_dx,$txtr_dy,$font_dx,$font_dy, $xr*$this->k,($this->h-$yr)*$this->k,$txtr); if ($this->ColorFlag) $s='q '.$this->TextColor.' '.$s.' Q'; $this->_out($s); } /** * DEPRECATED 4.0.0 */ function sousetat(&$db, $etat, $sousetat) { $GLOBALS['entete_flag']=$sousetat['entete_flag']; // $res =& $db->query($sousetat['sql']); if (database::isError($res)) { $this->erreur_db($res->getDebugInfo(),$res->getMessage(),''); } else { $info=$res->tableInfo(); } $this->SetDrawColor($sousetat['bordure_couleur'][0],$sousetat['bordure_couleur'][1],$sousetat['bordure_couleur'][2]);////couleur du trace //intervalle $this->ln($sousetat['intervalle_debut']); //titre $this->SetFillColor($sousetat['titrefondcouleur'][0],$sousetat['titrefondcouleur'][1],$sousetat['titrefondcouleur'][2]); $this->SetTextColor($sousetat['titretextecouleur'][0],$sousetat['titretextecouleur'][1],$sousetat['titretextecouleur'][2]); $this->SetFont($sousetat["titrefont"],$sousetat["titreattribut"],$sousetat["titretaille"]); $this->MultiCell($sousetat['tableau_largeur'],$sousetat["titrehauteur"],$sousetat["titre"],$sousetat["titrebordure"],$sousetat["titrealign"],$sousetat["titrefond"]); // $nbchamp=count($info); // $this->SetFont($etat['se_font'],'',$sousetat['tableau_fontaille']); // ENTETE if ($sousetat['entete_flag']==1) { $this->SetFillColor($sousetat['entete_fondcouleur'][0],$sousetat['entete_fondcouleur'][1],$sousetat['entete_fondcouleur'][2]); $this->SetTextColor($sousetat['entete_textecouleur'][0],$sousetat['entete_textecouleur'][1],$sousetat['entete_textecouleur'][2]); //texte horizontal if (!isset($sousetat['entete_orientation'])) { //------------------------------------------- for($k=0;$k<$nbchamp;$k++) { $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],mb_strtoupper($info[$k]['name']),$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); } //------------------------------------------- } else { //texte avec angle for ($k=0;$k<$nbchamp;$k++) { //mo 27 mars 2008------------------------------------------- //texte horizontal si entete_orientation =0 if ($sousetat['entete_orientation'][$k]==0) { $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],mb_strtoupper($info[$k]['name']),$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); } else { //mo 27 mars 2008--------------------------------------- if ($sousetat['entete_orientation'][$k]>0) { $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],'',$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); $xd=$this->Getx(); $yd=$this->Gety(); $xd=$xd-(floor($sousetat['cellule_largeur'][$k]/2)); if ($sousetat['entete_orientation'][$k]<91) { $yd=($yd+$sousetat['entete_hauteur'])-1; } else { $yd=($yd+$sousetat['entete_hauteur'])-5; } $this->TextWithRotation($xd,$yd,mb_strtoupper($info[$k]['name']),$sousetat['entete_orientation'][$k],0); } else { //$this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],strtoupper($info[$k]['name']),$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],'',$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); $xd=$this->Getx(); $yd=$this->Gety(); $xd = $xd - floor((($sousetat['cellule_largeur'][$k]/2))) - floor(strlen ($info[$k]['name'])); $yd=($yd+$sousetat['entete_hauteur'])-3; $this->TextWithRotation($xd,$yd,mb_strtoupper($info[$k]['name']),$sousetat['entete_orientation'][$k],0); } }//mo 27 mars 2008 fin else entete_orientation'][$k]different de zero }//fin for } // $this->ln(); } // $couleur=1; $this->SetTextColor($etat['se_couleurtexte'][0],$etat['se_couleurtexte'][1],$etat['se_couleurtexte'][2]); // initialisation for($j=0;$j<$nbchamp;$j++) $total[$j]=0; $cptenr=0; $flagtotal=0; $flagmoyenne=0; $flagcompteur=0; // while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { // if ($couleur==1){ $this->SetFillColor($sousetat['se_fond1'][0],$sousetat['se_fond1'][1],$sousetat['se_fond1'][2]); $couleur=0; } else { $this->SetFillColor($sousetat['se_fond2'][0],$sousetat['se_fond2'][1],$sousetat['se_fond2'][2]); $couleur=1; } // //preparer multiligne $max_ln=1; $multi_height=$sousetat['cellule_hauteur']; //Etablir nb lignes necessaires et preparer chaines avec \n for ($j=0;$j<$nbchamp;$j++) { // A ajouter eventuellement dans .sousetat.inc // //a 1 texte organise en multiligne, avec autre valeur texte compresse // $sousetat['cellule_multiligne']=array("0","0","1","1","1","0","0","1","1","0"); // //pourcentage de hauteur utilisee pour 1 ligne d'une cellule multiligne // $sousetat['cellule_hautmulti']=1/2; if (isset($sousetat['cellule_multiligne'])) { //si variable definie, valeur a 1 => multiligne if ($sousetat['cellule_multiligne'][$j]==1) { $t_ln=$this->PrepareMultiCell($sousetat['cellule_largeur'][$j],$row[$info[$j]['name']]); if ($t_ln>$max_ln) $max_ln=$t_ln; } // sinon compression } else { //si variable non definie, multiligne par defaut $t_ln=$this->PrepareMultiCell($sousetat['cellule_largeur'][$j],$row[$info[$j]['name']]); if ($t_ln>$max_ln) $max_ln=$t_ln; } } //fixation de la nouvelle hauteur si plus d'1 ligne selon quota hauteur/nblignesmulti ou pas if ($max_ln>1) if (isset($sousetat['cellule_hautmulti'])) //si valeur cellule_hautmulti existe $multi_height=$max_ln*$sousetat['cellule_hauteur']*$sousetat['cellule_hautmulti']; else //sinon valeur par defaut 1/2 $multi_height=$max_ln*$sousetat['cellule_hauteur']*1/2; for ($j=0;$j<$nbchamp;$j++) { if (isset($sousetat['cellule_numerique'][$j]) AND TRIM($sousetat['cellule_numerique'][$j])!=""){ //champs non numerique = 999 , numerique if ($sousetat['cellule_numerique'][$j]==999) { // non numerique if ($cptenr==0) { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,$row[$info[$j]['name']],$sousetat['cellule_bordure_un'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } else { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,$row[$info[$j]['name']],$sousetat['cellule_bordure'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } } else { // numerique if ($cptenr==0) { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,number_format($row[$info[$j]['name']], $sousetat['cellule_numerique'][$j], ',', ' '),$sousetat['cellule_bordure_un'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } else { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,number_format($row[$info[$j]['name']], $sousetat['cellule_numerique'][$j], ',', ' '),$sousetat['cellule_bordure'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } // si total = calcul variable total if ($sousetat['cellule_total'][$j]==1) { $total[$j] = $total[$j]+$row[$info[$j]['name']]; $flagtotal=1; } if ($sousetat['cellule_moyenne'][$j]==1) { if ($flagtotal==0) $total[$j] = $total[$j]+$row[$info[$j]['name']]; $flagmoyenne=1; } } } if ($sousetat['cellule_compteur'][$j]==1) { $flagcompteur=1; } } // fin for $cptenr=$cptenr+1; $this->ln(); } //fin while // // apres derniere ligne if ($sousetat['tableau_bordure']=="1") { $this->Cell($sousetat['tableau_largeur'],0,'',"T",1,'L',0); } //affichage total---------------------------------------------------- if ($flagtotal==1) { for ($k=0;$k<$nbchamp;$k++) { if ($sousetat['cellule_total'][$k]==1) { $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_total']); $this->SetFillColor($sousetat['cellule_fondcouleur_total'][0],$sousetat['cellule_fondcouleur_total'][1],$sousetat['cellule_fondcouleur_total'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_total'],number_format($total[$k], $sousetat['cellule_numerique'][$k], ',', ' '),$sousetat['cellule_bordure_total'][$k],0,$sousetat['cellule_align_total'][$k],$sousetat['cellule_fond_total']); } else {// affichage sur la colone correspondante if ($k==0) { // 1ere colone $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_total']); $this->SetFillColor($sousetat['cellule_fondcouleur_total'][0],$sousetat['cellule_fondcouleur_total'][1],$sousetat['cellule_fondcouleur_total'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_total'],'TOTAL',$sousetat['cellule_bordure_total'][$k],0,$sousetat['cellule_align_total'][$k],$sousetat['cellule_fond_total']); } else { // colones suivante $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_total']); $this->SetFillColor($sousetat['cellule_fondcouleur_total'][0],$sousetat['cellule_fondcouleur_total'][1],$sousetat['cellule_fondcouleur_total'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_total'],'',$sousetat['cellule_bordure_total'][$k],0,$sousetat['cellule_align_total'][$k],$sousetat['cellule_fond_total']); } } } //fin for k $this->ln(); } //$k=0; //affichage moyenne---------------------------------------------------- if ($flagmoyenne==1) { for ($k=0;$k<$nbchamp;$k++) { if ($sousetat['cellule_moyenne'][$k]==1) { $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_moyenne']); $this->SetFillColor($sousetat['cellule_fondcouleur_moyenne'][0],$sousetat['cellule_fondcouleur_moyenne'][1],$sousetat['cellule_fondcouleur_moyenne'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_moyenne'],number_format($total[$k]/$cptenr, $sousetat['cellule_numerique'][$k], ',', ' '),$sousetat['cellule_bordure_moyenne'][$k],0,$sousetat['cellule_align_moyenne'][$k],$sousetat['cellule_fond_moyenne']); } else { // affichage sur la colone correspondante if ($k==0) { // 1ere colone $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_moyenne']); $this->SetFillColor($sousetat['cellule_fondcouleur_moyenne'][0],$sousetat['cellule_fondcouleur_moyenne'][1],$sousetat['cellule_fondcouleur_moyenne'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_moyenne'],'MOYENNE',$sousetat['cellule_bordure_moyenne'][$k],0,$sousetat['cellule_align_moyenne'][$k],$sousetat['cellule_fond_moyenne']); } else { // colones suivante $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_moyenne']); $this->SetFillColor($sousetat['cellule_fondcouleur_moyenne'][0],$sousetat['cellule_fondcouleur_moyenne'][1],$sousetat['cellule_fondcouleur_moyenne'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_moyenne'],'',$sousetat['cellule_bordure_moyenne'][$k],0,$sousetat['cellule_align_moyenne'][$k],$sousetat['cellule_fond_moyenne']); } } } //fin for k $this->ln(); } //affichage compteur---------------------------------------------------- if ($flagcompteur==1) { for ($k=0;$k<$nbchamp;$k++) { if ($sousetat['cellule_compteur'][$k]==1) { $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_nbr']); $this->SetFillColor($sousetat['cellule_fondcouleur_nbr'][0],$sousetat['cellule_fondcouleur_nbr'][1],$sousetat['cellule_fondcouleur_nbr'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_nbr'],number_format($cptenr, 0, ',', ' '),$sousetat['cellule_bordure_nbr'][$k],0,$sousetat['cellule_align_nbr'][$k],$sousetat['cellule_fond_nbr']); } else { // affichage sur la colone correspondante if ($k==0) { // 1ere colone $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_nbr']); $this->SetFillColor($sousetat['cellule_fondcouleur_nbr'][0],$sousetat['cellule_fondcouleur_nbr'][1],$sousetat['cellule_fondcouleur_nbr'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_nbr'],'NOMBRE',$sousetat['cellule_bordure_nbr'][$k],0,$sousetat['cellule_align_nbr'][$k],$sousetat['cellule_fond_nbr']); } else { // colones suivante $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_nbr']); $this->SetFillColor($sousetat['cellule_fondcouleur_nbr'][0],$sousetat['cellule_fondcouleur_nbr'][1],$sousetat['cellule_fondcouleur_nbr'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_nbr'],'',$sousetat['cellule_bordure_nbr'][$k],0,$sousetat['cellule_align_nbr'][$k],$sousetat['cellule_fond_nbr']); } } } //fin for k $this->ln(); } if ($cptenr>0) { $this->ln($sousetat['intervalle_fin']); } } /** * fonction 4.0.0 */ function sousetatdb(&$db, $etat, $sousetat) { $GLOBALS['entete_flag']=$sousetat['entete_flag']; // $res =& $db->query($sousetat['om_sql']); $this->addToLog("fpdf_etat.php: db->query(\"".$sousetat['om_sql']."\");", VERBOSE_MODE); // if (database::isError($res)) { $this->erreur_db($res->getDebugInfo(),$res->getMessage(),''); } elseif ( DBCHARSET == 'UTF8' ) { $info=$res->tableInfo(); $sousetat["titre"] = $this->convertToCP1252($sousetat["titre"]); } else { $info=$res->tableInfo(); } //*** transformer les valeurs de la base en tableau *** $sousetat['titrefondcouleur']=explode("-", $sousetat['titrefondcouleur']); $sousetat['titretextecouleur']=explode("-", $sousetat['titretextecouleur']); $sousetat['entete_orientation']=explode("|", $sousetat['entete_orientation']); $sousetat['entetecolone_bordure']=explode("|", $sousetat['entetecolone_bordure']); $sousetat['entetecolone_align']=explode("|", $sousetat['entetecolone_align']); $sousetat['entete_fondcouleur']=explode("-", $sousetat['entete_fondcouleur']); $sousetat['entete_textecouleur']=explode("-", $sousetat['entete_textecouleur']); $sousetat['bordure_couleur']=explode("-", $sousetat['bordure_couleur']); $sousetat['se_fond1']=explode("-", $sousetat['se_fond1']); $sousetat['se_fond2']=explode("-", $sousetat['se_fond2']); $sousetat['cellule_largeur']=explode("|", $sousetat['cellule_largeur']); $sousetat['cellule_bordure_un']=explode("|", $sousetat['cellule_bordure_un']); $sousetat['cellule_bordure']=explode("|", $sousetat['cellule_bordure']); $sousetat['cellule_align']=explode("|", $sousetat['cellule_align']); $sousetat['cellule_fondcouleur_total']=explode("-", $sousetat['cellule_fondcouleur_total']); $sousetat['cellule_bordure_total']=explode("|", $sousetat['cellule_bordure_total']); $sousetat['cellule_align_total']=explode("|", $sousetat['cellule_align_total']); $sousetat['cellule_fondcouleur_moyenne']=explode("-", $sousetat['cellule_fondcouleur_moyenne']); $sousetat['cellule_bordure_moyenne']=explode("|", $sousetat['cellule_bordure_moyenne']); $sousetat['cellule_align_moyenne']=explode("|", $sousetat['cellule_align_moyenne']); $sousetat['cellule_fondcouleur_nbr']=explode("-", $sousetat['cellule_fondcouleur_nbr']); $sousetat['cellule_bordure_nbr']=explode("|", $sousetat['cellule_bordure_nbr']); $sousetat['cellule_align_nbr']=explode("|", $sousetat['cellule_align_nbr']); $sousetat['cellule_numerique']=explode("|", $sousetat['cellule_numerique']); $sousetat['cellule_total']=explode("|", $sousetat['cellule_total']); $sousetat['cellule_moyenne']=explode("|", $sousetat['cellule_moyenne']); $sousetat['cellule_compteur']=explode("|", $sousetat['cellule_compteur']); // *** $this->SetDrawColor($sousetat['bordure_couleur'][0],$sousetat['bordure_couleur'][1],$sousetat['bordure_couleur'][2]);////couleur du trace //intervalle $this->ln($sousetat['intervalle_debut']); //titre $this->SetFillColor($sousetat['titrefondcouleur'][0],$sousetat['titrefondcouleur'][1],$sousetat['titrefondcouleur'][2]); $this->SetTextColor($sousetat['titretextecouleur'][0],$sousetat['titretextecouleur'][1],$sousetat['titretextecouleur'][2]); $this->SetFont($sousetat["titrefont"],$sousetat["titreattribut"],$sousetat["titretaille"]); $this->MultiCell($sousetat['tableau_largeur'],$sousetat["titrehauteur"],$sousetat["titre"],$sousetat["titrebordure"],$sousetat["titrealign"],$sousetat["titrefond"]); // $nbchamp=count($info); // $this->SetFont($etat['se_font'],'',$sousetat['tableau_fontaille']); // ENTETE if ($sousetat['entete_flag']==1) { $this->SetFillColor($sousetat['entete_fondcouleur'][0],$sousetat['entete_fondcouleur'][1],$sousetat['entete_fondcouleur'][2]); $this->SetTextColor($sousetat['entete_textecouleur'][0],$sousetat['entete_textecouleur'][1],$sousetat['entete_textecouleur'][2]); //texte horizontal if (!isset($sousetat['entete_orientation'])) { //------------------------------------------- for($k=0;$k<$nbchamp;$k++) { $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],mb_strtoupper($this->convertToCP1252(_($info[$k]['name']))),$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); } //------------------------------------------- } else { //texte avec angle for ($k=0;$k<$nbchamp;$k++) { //mo 27 mars 2008------------------------------------------- //texte horizontal si entete_orientation =0 if ($sousetat['entete_orientation'][$k]==0) { $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],mb_strtoupper($this->convertToCP1252(_($info[$k]['name']))),$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); } else { //mo 27 mars 2008--------------------------------------- if ($sousetat['entete_orientation'][$k]>0) { $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],'',$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); $xd=$this->Getx(); $yd=$this->Gety(); $xd=$xd-(floor($sousetat['cellule_largeur'][$k]/2)); if ($sousetat['entete_orientation'][$k]<91) { $yd=($yd+$sousetat['entete_hauteur'])-1; } else { $yd=($yd+$sousetat['entete_hauteur'])-5; } $this->TextWithRotation($xd,$yd,mb_strtoupper($this->convertToCP1252(_($info[$k]['name']))),$sousetat['entete_orientation'][$k],0); } else { //$this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],strtoupper($info[$k]['name']),$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['entete_hauteur'],'',$sousetat['entetecolone_bordure'][$k],0,$sousetat['entetecolone_align'][$k],$sousetat['entete_fond']); $xd=$this->Getx(); $yd=$this->Gety(); $xd = $xd - floor((($sousetat['cellule_largeur'][$k]/2))) - floor(strlen ($this->convertToCP1252(_($info[$k]['name'])))); $yd=($yd+$sousetat['entete_hauteur'])-3; $this->TextWithRotation($xd,$yd,mb_strtoupper($this->convertToCP1252(_($info[$k]['name']))),$sousetat['entete_orientation'][$k],0); } }//mo 27 mars 2008 fin else entete_orientation'][$k]different de zero }//fin for } // $this->ln(); } // $couleur=1; $this->SetTextColor($etat['se_couleurtexte'][0],$etat['se_couleurtexte'][1],$etat['se_couleurtexte'][2]); // initialisation for($j=0;$j<$nbchamp;$j++) $total[$j]=0; $cptenr=0; $flagtotal=0; $flagmoyenne=0; $flagcompteur=0; // while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { // if ($couleur==1){ $this->SetFillColor($sousetat['se_fond1'][0],$sousetat['se_fond1'][1],$sousetat['se_fond1'][2]); $couleur=0; } else { $this->SetFillColor($sousetat['se_fond2'][0],$sousetat['se_fond2'][1],$sousetat['se_fond2'][2]); $couleur=1; } // //preparer multiligne $max_ln=1; $multi_height=$sousetat['cellule_hauteur']; //Etablir nb lignes necessaires et preparer chaines avec \n for ($j=0;$j<$nbchamp;$j++) { // A ajouter eventuellement dans .sousetat.inc // //a 1 texte organise en multiligne, avec autre valeur texte compresse // $sousetat['cellule_multiligne']=array("0","0","1","1","1","0","0","1","1","0"); // //pourcentage de hauteur utilisee pour 1 ligne d'une cellule multiligne // $sousetat['cellule_hautmulti']=1/2; if (isset($sousetat['cellule_multiligne'])) { //si variable definie, valeur a 1 => multiligne if ($sousetat['cellule_multiligne'][$j]==1) { $t_ln=$this->PrepareMultiCell($sousetat['cellule_largeur'][$j],$row[$info[$j]['name']]); if ($t_ln>$max_ln) $max_ln=$t_ln; } // sinon compression } else { //si variable non definie, multiligne par defaut $t_ln=$this->PrepareMultiCell($sousetat['cellule_largeur'][$j],$row[$info[$j]['name']]); if ($t_ln>$max_ln) $max_ln=$t_ln; } } //fixation de la nouvelle hauteur si plus d'1 ligne selon quota hauteur/nblignesmulti ou pas if ($max_ln>1) if (isset($sousetat['cellule_hautmulti'])) //si valeur cellule_hautmulti existe $multi_height=$max_ln*$sousetat['cellule_hauteur']*$sousetat['cellule_hautmulti']; else //sinon valeur par defaut 1/2 $multi_height=$max_ln*$sousetat['cellule_hauteur']*1/2; for ($j=0;$j<$nbchamp;$j++) { if (isset($sousetat['cellule_numerique'][$j]) AND TRIM($sousetat['cellule_numerique'][$j])!=""){ //champs non numerique = 999 , numerique if ($sousetat['cellule_numerique'][$j]==999) { // non numerique // transcodage pour les bases UTF8 (fpdf ne supporte pas UTF8) if (DBCHARSET == 'UTF8') { $value = utf8_decode($row[$info[$j]['name']]); } else { $value = $row[$info[$j]['name']]; } // if ($cptenr==0) { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,$value,$sousetat['cellule_bordure_un'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } else { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,$value,$sousetat['cellule_bordure'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } } else { // numerique if ($cptenr==0) { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,number_format($row[$info[$j]['name']], $sousetat['cellule_numerique'][$j], ',', ' '),$sousetat['cellule_bordure_un'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } else { $this->Cell($sousetat['cellule_largeur'][$j],$multi_height,number_format($row[$info[$j]['name']], $sousetat['cellule_numerique'][$j], ',', ' '),$sousetat['cellule_bordure'][$j],0,$sousetat['cellule_align'][$j],$sousetat['cellule_fond']); } // si total = calcul variable total if ($sousetat['cellule_total'][$j]==1) { $total[$j] = $total[$j]+$row[$info[$j]['name']]; $flagtotal=1; } if ($sousetat['cellule_moyenne'][$j]==1) { if ($flagtotal==0) $total[$j] = $total[$j]+$row[$info[$j]['name']]; $flagmoyenne=1; } } } if ($sousetat['cellule_compteur'][$j]==1) { $flagcompteur=1; } } // fin for $cptenr=$cptenr+1; $this->ln(); } //fin while // // apres derniere ligne if ($sousetat['tableau_bordure']=="1") { $this->Cell($sousetat['tableau_largeur'],0,'',"T",1,'L',0); } //affichage total---------------------------------------------------- if ($flagtotal==1) { for ($k=0;$k<$nbchamp;$k++) { if ($sousetat['cellule_total'][$k]==1) { $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_total']); $this->SetFillColor($sousetat['cellule_fondcouleur_total'][0],$sousetat['cellule_fondcouleur_total'][1],$sousetat['cellule_fondcouleur_total'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_total'],number_format($total[$k], $sousetat['cellule_numerique'][$k], ',', ' '),$sousetat['cellule_bordure_total'][$k],0,$sousetat['cellule_align_total'][$k],$sousetat['cellule_fond_total']); } else {// affichage sur la colone correspondante if ($k==0) { // 1ere colone $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_total']); $this->SetFillColor($sousetat['cellule_fondcouleur_total'][0],$sousetat['cellule_fondcouleur_total'][1],$sousetat['cellule_fondcouleur_total'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_total'],'TOTAL',$sousetat['cellule_bordure_total'][$k],0,$sousetat['cellule_align_total'][$k],$sousetat['cellule_fond_total']); } else { // colones suivante $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_total']); $this->SetFillColor($sousetat['cellule_fondcouleur_total'][0],$sousetat['cellule_fondcouleur_total'][1],$sousetat['cellule_fondcouleur_total'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_total'],'',$sousetat['cellule_bordure_total'][$k],0,$sousetat['cellule_align_total'][$k],$sousetat['cellule_fond_total']); } } } //fin for k $this->ln(); } //$k=0; //affichage moyenne---------------------------------------------------- if ($flagmoyenne==1) { for ($k=0;$k<$nbchamp;$k++) { if ($sousetat['cellule_moyenne'][$k]==1) { $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_moyenne']); $this->SetFillColor($sousetat['cellule_fondcouleur_moyenne'][0],$sousetat['cellule_fondcouleur_moyenne'][1],$sousetat['cellule_fondcouleur_moyenne'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_moyenne'],number_format($total[$k]/$cptenr, $sousetat['cellule_numerique'][$k], ',', ' '),$sousetat['cellule_bordure_moyenne'][$k],0,$sousetat['cellule_align_moyenne'][$k],$sousetat['cellule_fond_moyenne']); } else { // affichage sur la colone correspondante if ($k==0) { // 1ere colone $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_moyenne']); $this->SetFillColor($sousetat['cellule_fondcouleur_moyenne'][0],$sousetat['cellule_fondcouleur_moyenne'][1],$sousetat['cellule_fondcouleur_moyenne'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_moyenne'],'MOYENNE',$sousetat['cellule_bordure_moyenne'][$k],0,$sousetat['cellule_align_moyenne'][$k],$sousetat['cellule_fond_moyenne']); } else { // colones suivante $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_moyenne']); $this->SetFillColor($sousetat['cellule_fondcouleur_moyenne'][0],$sousetat['cellule_fondcouleur_moyenne'][1],$sousetat['cellule_fondcouleur_moyenne'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_moyenne'],'',$sousetat['cellule_bordure_moyenne'][$k],0,$sousetat['cellule_align_moyenne'][$k],$sousetat['cellule_fond_moyenne']); } } } //fin for k $this->ln(); } //affichage compteur---------------------------------------------------- if ($flagcompteur==1) { for ($k=0;$k<$nbchamp;$k++) { if ($sousetat['cellule_compteur'][$k]==1) { $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_nbr']); $this->SetFillColor($sousetat['cellule_fondcouleur_nbr'][0],$sousetat['cellule_fondcouleur_nbr'][1],$sousetat['cellule_fondcouleur_nbr'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_nbr'],number_format($cptenr, 0, ',', ' '),$sousetat['cellule_bordure_nbr'][$k],0,$sousetat['cellule_align_nbr'][$k],$sousetat['cellule_fond_nbr']); } else { // affichage sur la colone correspondante if ($k==0) { // 1ere colone $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_nbr']); $this->SetFillColor($sousetat['cellule_fondcouleur_nbr'][0],$sousetat['cellule_fondcouleur_nbr'][1],$sousetat['cellule_fondcouleur_nbr'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_nbr'],'NOMBRE',$sousetat['cellule_bordure_nbr'][$k],0,$sousetat['cellule_align_nbr'][$k],$sousetat['cellule_fond_nbr']); } else { // colones suivante $this->SetFont($etat['se_font'],'',$sousetat['cellule_fontaille_nbr']); $this->SetFillColor($sousetat['cellule_fondcouleur_nbr'][0],$sousetat['cellule_fondcouleur_nbr'][1],$sousetat['cellule_fondcouleur_nbr'][2]); $this->Cell($sousetat['cellule_largeur'][$k],$sousetat['cellule_hauteur_nbr'],'',$sousetat['cellule_bordure_nbr'][$k],0,$sousetat['cellule_align_nbr'][$k],$sousetat['cellule_fond_nbr']); } } } //fin for k $this->ln(); } if ($cptenr>0) { $this->ln($sousetat['intervalle_fin']); } } /** * */ function PrepareMultiCell($w, &$txt) { //prepare un texte passe par reference (en le modifiant) avec ajout \n pour traitement par Cell modifie //et retourne nb ligne necessaire //base sur code MultiCell mais pas d'affichage $cw=&$this->CurrentFont['cw']; //largeur caractere if ($w==0) //si largeur=0, largeur=largeurcourante-margegauche-positionx $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r",'',$txt); $nb=strlen($s); //longueur texte sans retour chariot if ($nb>0 && $s[$nb-1]=="\n") $nb--; //supp. dernier retour ligne si existe $sep=-1; //espace $i=0; //index boucle $j=0; $l=0; $ns=0; $nl=1; $nbrc=0; //nb retourcharriot while ($i<$nb) { //boucle sur texte //Get next character $c=$s{$i}; //caractere courant if ($c=="\n") { //retour ligne //Explicit line break $i++; // $sep=-1; //raz espace $j=$i; //debut de ligne $l=0; $ns=0; $nl++; //nb ligne +1 continue; // prochain caractere } if ($c==' ') { //si espace $sep=$i; //position espace $ls=$l; $ns++; } $l+=$cw[$c]; if ($l>$wmax) { //si ligne depasse largeur //Automatic line break if($sep==-1) { //si aucun espace detecte if($i==$j) $i++; } else { //espace detecte $i=$sep+1; //prochain car = car suivant dernier espace } //insertion retour charriot dans texte $txt=substr($txt,0,$i+$nbrc)."\n".substr($txt,$i+$nbrc); $nbrc++; $sep=-1; $j=$i; $l=0; $ns=0; $nl++; //nb ligne +1 } else //ligne < largeur colonne $i++; } //fin de texte return $nl; } /** * */ function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') { //surcharge pour retour ligne sur detection \n sinon compression //changement //border: indicates if borders must be drawn around the cell. The value can be either a number: //0: no border //>0: frame of the corresponding width //or a string containing some or all of the following characters (in any order): //L: left //T: top //R: right //B: bottom //or for bold border: //l: left //t: top //r: right //b: bottom //Default value: 0. //Output a cell $k=$this->k; // !$this->InHeader commenter pour compatibilite avec fpdf 1.53 semble ne pas etre necessaire pour // la version fpdf 1.6 if($this->y+$h>$this->PageBreakTrigger /*&& !$this->InHeader*/ && !$this->InFooter && $this->AcceptPageBreak()) { //Automatic page break $x=$this->x; $ws=$this->ws; if($ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->AddPage($this->CurOrientation,$this->CurPageFormat); $this->x=$x; if($ws>0) { $this->ws=$ws; $this->_out(sprintf('%.3F Tw', $ws*$k)); } } if($w==0) $w=$this->w-$this->rMargin-$this->x; $s=''; // begin change Cell function 12.08.2003 if($fill==1 or $border>0) { if($fill==1) $op=($border>0) ? 'B' : 'f'; else $op='S'; if ($border>1) { $s=sprintf(' q %.2F w %.2F %.2F %.2F %.2F re %s Q ', $border, $this->x*$k, ($this->h-$this->y)*$k, $w*$k, -$h*$k, $op); } else $s=sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x*$k, ($this->h-$this->y)*$k, $w*$k, -$h*$k, $op); } if(is_string($border)) { $x=$this->x; $y=$this->y; if(is_int(strpos($border, 'L'))) $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-$y)*$k, $x*$k, ($this->h-($y+$h))*$k); else if(is_int(strpos($border, 'l'))) $s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ', $x*$k, ($this->h-$y)*$k, $x*$k, ($this->h-($y+$h))*$k); if(is_int(strpos($border, 'T'))) $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-$y)*$k); else if(is_int(strpos($border, 't'))) $s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ', $x*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-$y)*$k); if(is_int(strpos($border, 'R'))) $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', ($x+$w)*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k); else if(is_int(strpos($border, 'r'))) $s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ', ($x+$w)*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k); if(is_int(strpos($border, 'B'))) $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-($y+$h))*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k); else if(is_int(strpos($border, 'b'))) $s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ', $x*$k, ($this->h-($y+$h))*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k); } if (trim($txt)!='') { $cr=substr_count($txt, "\n"); if ($cr>0) { // Multi line $txts = explode("\n", $txt); $lines = count($txts); //$dy=($h-2*$this->cMargin)/$lines; for ($l=0;$l<$lines;$l++) { $txt=$txts[$l]; $w_txt=$this->GetStringWidth($txt); if ($align=='R') $dx=$w-$w_txt-$this->cMargin; elseif($align=='C') $dx=($w-$w_txt)/2; else $dx=$this->cMargin; // $txt=str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))); if ($this->ColorFlag) $s.='q '.$this->TextColor.' '; $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET ', ($this->x+$dx)*$k, ($this->h-($this->y+.5*$h+(.7+$l-$lines/2)*$this->FontSize))*$k, $txt); if ($this->underline) $s.=' '.$this->_dounderline($this->x+$dx, $this->y+.5*$h+.3*$this->FontSize, $txt); if ($this->ColorFlag) $s.='Q '; if ($link) $this->Link($this->x+$dx, $this->y+.5*$h-.5*$this->FontSize, $w_txt, $this->FontSize, $link); } } else { // Single line $w_txt=$this->GetStringWidth($txt); $Tz=100; if ($w_txt>$w-2*$this->cMargin) { // Need compression $Tz=($w-2*$this->cMargin)/$w_txt*100; $w_txt=$w-2*$this->cMargin; } if ($align=='R') $dx=$w-$w_txt-$this->cMargin; elseif($align=='C') $dx=($w-$w_txt)/2; else $dx=$this->cMargin; $txt=str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))); if ($this->ColorFlag) $s.='q '.$this->TextColor.' '; $s.=sprintf('q BT %.2F %.2F Td %.2F Tz (%s) Tj ET Q ', ($this->x+$dx)*$k, ($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k, $Tz, $txt); if ($this->underline) $s.=' '.$this->_dounderline($this->x+$dx, $this->y+.5*$h+.3*$this->FontSize, $txt); if ($this->ColorFlag) $s.='Q '; if ($link) $this->Link($this->x+$dx, $this->y+.5*$h-.5*$this->FontSize, $w_txt, $this->FontSize, $link); } } // end change Cell function 12.08.2003 if ($s) $this->_out($s); $this->lasth=$h; if ($ln>0) { //Go to next line $this->y+=$h; if ($ln==1) $this->x=$this->lMargin; } else $this->x+=$w; } // {{{ Gestion des messages de debug /** * */ function addToLog($message, $type = DEBUG_MODE) { // logger::instance()->log("class ".get_class($this)." - ".$message, $type); } // }}} /** * Cette methode ne doit plus etre appelee, c'est 'message::isError($res)' * qui s'occupe d'afficher le message d'erreur et de faire le 'die()'. * * @deprecated */ function erreur_db($debuginfo, $messageDB, $table) { die(_("Erreur de base de donnees. Contactez votre administrateur.")); } /* * Initialisation des variables pour la création d'un code barre de type code 128 * */ function init_Code128(){ // Composition des caractères $this->T128[] = array(2, 1, 2, 2, 2, 2); //0 : [ ] $this->T128[] = array(2, 2, 2, 1, 2, 2); //1 : [!] $this->T128[] = array(2, 2, 2, 2, 2, 1); //2 : ["] $this->T128[] = array(1, 2, 1, 2, 2, 3); //3 : [#] $this->T128[] = array(1, 2, 1, 3, 2, 2); //4 : [$] $this->T128[] = array(1, 3, 1, 2, 2, 2); //5 : [%] $this->T128[] = array(1, 2, 2, 2, 1, 3); //6 : [&] $this->T128[] = array(1, 2, 2, 3, 1, 2); //7 : ['] $this->T128[] = array(1, 3, 2, 2, 1, 2); //8 : [(] $this->T128[] = array(2, 2, 1, 2, 1, 3); //9 : [)] $this->T128[] = array(2, 2, 1, 3, 1, 2); //10 : [*] $this->T128[] = array(2, 3, 1, 2, 1, 2); //11 : [+] $this->T128[] = array(1, 1, 2, 2, 3, 2); //12 : [,] $this->T128[] = array(1, 2, 2, 1, 3, 2); //13 : [-] $this->T128[] = array(1, 2, 2, 2, 3, 1); //14 : [.] $this->T128[] = array(1, 1, 3, 2, 2, 2); //15 : [/] $this->T128[] = array(1, 2, 3, 1, 2, 2); //16 : [0] $this->T128[] = array(1, 2, 3, 2, 2, 1); //17 : [1] $this->T128[] = array(2, 2, 3, 2, 1, 1); //18 : [2] $this->T128[] = array(2, 2, 1, 1, 3, 2); //19 : [3] $this->T128[] = array(2, 2, 1, 2, 3, 1); //20 : [4] $this->T128[] = array(2, 1, 3, 2, 1, 2); //21 : [5] $this->T128[] = array(2, 2, 3, 1, 1, 2); //22 : [6] $this->T128[] = array(3, 1, 2, 1, 3, 1); //23 : [7] $this->T128[] = array(3, 1, 1, 2, 2, 2); //24 : [8] $this->T128[] = array(3, 2, 1, 1, 2, 2); //25 : [9] $this->T128[] = array(3, 2, 1, 2, 2, 1); //26 : [:] $this->T128[] = array(3, 1, 2, 2, 1, 2); //27 : [;] $this->T128[] = array(3, 2, 2, 1, 1, 2); //28 : [<] $this->T128[] = array(3, 2, 2, 2, 1, 1); //29 : [=] $this->T128[] = array(2, 1, 2, 1, 2, 3); //30 : [>] $this->T128[] = array(2, 1, 2, 3, 2, 1); //31 : [?] $this->T128[] = array(2, 3, 2, 1, 2, 1); //32 : [@] $this->T128[] = array(1, 1, 1, 3, 2, 3); //33 : [A] $this->T128[] = array(1, 3, 1, 1, 2, 3); //34 : [B] $this->T128[] = array(1, 3, 1, 3, 2, 1); //35 : [C] $this->T128[] = array(1, 1, 2, 3, 1, 3); //36 : [D] $this->T128[] = array(1, 3, 2, 1, 1, 3); //37 : [E] $this->T128[] = array(1, 3, 2, 3, 1, 1); //38 : [F] $this->T128[] = array(2, 1, 1, 3, 1, 3); //39 : [G] $this->T128[] = array(2, 3, 1, 1, 1, 3); //40 : [H] $this->T128[] = array(2, 3, 1, 3, 1, 1); //41 : [I] $this->T128[] = array(1, 1, 2, 1, 3, 3); //42 : [J] $this->T128[] = array(1, 1, 2, 3, 3, 1); //43 : [K] $this->T128[] = array(1, 3, 2, 1, 3, 1); //44 : [L] $this->T128[] = array(1, 1, 3, 1, 2, 3); //45 : [M] $this->T128[] = array(1, 1, 3, 3, 2, 1); //46 : [N] $this->T128[] = array(1, 3, 3, 1, 2, 1); //47 : [O] $this->T128[] = array(3, 1, 3, 1, 2, 1); //48 : [P] $this->T128[] = array(2, 1, 1, 3, 3, 1); //49 : [Q] $this->T128[] = array(2, 3, 1, 1, 3, 1); //50 : [R] $this->T128[] = array(2, 1, 3, 1, 1, 3); //51 : [S] $this->T128[] = array(2, 1, 3, 3, 1, 1); //52 : [T] $this->T128[] = array(2, 1, 3, 1, 3, 1); //53 : [U] $this->T128[] = array(3, 1, 1, 1, 2, 3); //54 : [V] $this->T128[] = array(3, 1, 1, 3, 2, 1); //55 : [W] $this->T128[] = array(3, 3, 1, 1, 2, 1); //56 : [X] $this->T128[] = array(3, 1, 2, 1, 1, 3); //57 : [Y] $this->T128[] = array(3, 1, 2, 3, 1, 1); //58 : [Z] $this->T128[] = array(3, 3, 2, 1, 1, 1); //59 : [[] $this->T128[] = array(3, 1, 4, 1, 1, 1); //60 : [\] $this->T128[] = array(2, 2, 1, 4, 1, 1); //61 : []] $this->T128[] = array(4, 3, 1, 1, 1, 1); //62 : [^] $this->T128[] = array(1, 1, 1, 2, 2, 4); //63 : [_] $this->T128[] = array(1, 1, 1, 4, 2, 2); //64 : [`] $this->T128[] = array(1, 2, 1, 1, 2, 4); //65 : [a] $this->T128[] = array(1, 2, 1, 4, 2, 1); //66 : [b] $this->T128[] = array(1, 4, 1, 1, 2, 2); //67 : [c] $this->T128[] = array(1, 4, 1, 2, 2, 1); //68 : [d] $this->T128[] = array(1, 1, 2, 2, 1, 4); //69 : [e] $this->T128[] = array(1, 1, 2, 4, 1, 2); //70 : [f] $this->T128[] = array(1, 2, 2, 1, 1, 4); //71 : [g] $this->T128[] = array(1, 2, 2, 4, 1, 1); //72 : [h] $this->T128[] = array(1, 4, 2, 1, 1, 2); //73 : [i] $this->T128[] = array(1, 4, 2, 2, 1, 1); //74 : [j] $this->T128[] = array(2, 4, 1, 2, 1, 1); //75 : [k] $this->T128[] = array(2, 2, 1, 1, 1, 4); //76 : [l] $this->T128[] = array(4, 1, 3, 1, 1, 1); //77 : [m] $this->T128[] = array(2, 4, 1, 1, 1, 2); //78 : [n] $this->T128[] = array(1, 3, 4, 1, 1, 1); //79 : [o] $this->T128[] = array(1, 1, 1, 2, 4, 2); //80 : [p] $this->T128[] = array(1, 2, 1, 1, 4, 2); //81 : [q] $this->T128[] = array(1, 2, 1, 2, 4, 1); //82 : [r] $this->T128[] = array(1, 1, 4, 2, 1, 2); //83 : [s] $this->T128[] = array(1, 2, 4, 1, 1, 2); //84 : [t] $this->T128[] = array(1, 2, 4, 2, 1, 1); //85 : [u] $this->T128[] = array(4, 1, 1, 2, 1, 2); //86 : [v] $this->T128[] = array(4, 2, 1, 1, 1, 2); //87 : [w] $this->T128[] = array(4, 2, 1, 2, 1, 1); //88 : [x] $this->T128[] = array(2, 1, 2, 1, 4, 1); //89 : [y] $this->T128[] = array(2, 1, 4, 1, 2, 1); //90 : [z] $this->T128[] = array(4, 1, 2, 1, 2, 1); //91 : [{] $this->T128[] = array(1, 1, 1, 1, 4, 3); //92 : [|] $this->T128[] = array(1, 1, 1, 3, 4, 1); //93 : [}] $this->T128[] = array(1, 3, 1, 1, 4, 1); //94 : [~] $this->T128[] = array(1, 1, 4, 1, 1, 3); //95 : [DEL] $this->T128[] = array(1, 1, 4, 3, 1, 1); //96 : [FNC3] $this->T128[] = array(4, 1, 1, 1, 1, 3); //97 : [FNC2] $this->T128[] = array(4, 1, 1, 3, 1, 1); //98 : [SHIFT] $this->T128[] = array(1, 1, 3, 1, 4, 1); //99 : [Cswap] $this->T128[] = array(1, 1, 4, 1, 3, 1); //100 : [Bswap] $this->T128[] = array(3, 1, 1, 1, 4, 1); //101 : [Aswap] $this->T128[] = array(4, 1, 1, 1, 3, 1); //102 : [FNC1] $this->T128[] = array(2, 1, 1, 4, 1, 2); //103 : [Astart] $this->T128[] = array(2, 1, 1, 2, 1, 4); //104 : [Bstart] $this->T128[] = array(2, 1, 1, 2, 3, 2); //105 : [Cstart] $this->T128[] = array(2, 3, 3, 1, 1, 1); //106 : [STOP] $this->T128[] = array(2, 1); //107 : [END BAR] //J eux de caractères for ($i = 32; $i <= 95; $i++) { $this->ABCset .= chr($i); } $this->Aset = $this->ABCset; $this->Bset = $this->ABCset; for ($i = 0; $i <= 31; $i++) { $this->ABCset .= chr($i); $this->Aset .= chr($i); } for ($i = 96; $i <= 126; $i++) { $this->ABCset .= chr($i); $this->Bset .= chr($i); } $this->Cset="0123456789"; //Convertisseurs des jeux A & B for ($i=0; $i<96; $i++) { @$this->SetFrom["A"] .= chr($i); @$this->SetFrom["B"] .= chr($i + 32); @$this->SetTo["A"] .= chr(($i < 32) ? $i+64 : $i-32); @$this->SetTo["B"] .= chr($i); } } /* * Génération d'un code barre de type code 128 * Script original : http://www.fpdf.org/fr/script/script88.php * @param $x, $y angle supérieur code du code barres * @param $code le code à créer * @param $w largeur du code * @param $h hauteur du code * */ function Code128($x, $y, $code, $w, $h) { // Initialisation des données if( $this->T128 == "" || $this->ABCset == "" || $this->Aset == "" || $this->Bset == "" || $this->Cset == "" || $this->SetFrom == "" || $this->SetTo == "" ){ $this->init_Code128(); } $this->SetFont('Arial', '', 10); // Affiche le numéro sous le code barres $this->Text($x, $y+$h+4, $code); // Création des guides de choix ABC $Aguid = ""; $Bguid = ""; $Cguid = ""; for ($i=0; $i < strlen($code); $i++) { $needle = substr($code,$i,1); $Aguid .= ((strpos($this->Aset,$needle)===false) ? "N" : "O"); $Bguid .= ((strpos($this->Bset,$needle)===false) ? "N" : "O"); $Cguid .= ((strpos($this->Cset,$needle)===false) ? "N" : "O"); } $SminiC = "OOOO"; $IminiC = 4; $crypt = ""; while ($code > "") { $i = strpos($Cguid,$SminiC); // Force le jeu C, si possible if ($i!==false) { $Aguid [$i] = "N"; $Bguid [$i] = "N"; } // Jeu C if (substr($Cguid,0,$IminiC) == $SminiC) { // Début Cstart, sinon Cswap $crypt .= chr(($crypt > "") ? $this->JSwap["C"] : $this->JStart["C"]); // Étendu du set C $made = strpos($Cguid,"N"); if ($made === false) { $made = strlen($Cguid); } // Seulement un nombre pair if (fmod($made,2)==1) { $made--; } for ($i=0; $i < $made; $i += 2) { // Conversion 2 par 2 $crypt .= chr(strval(substr($code,$i,2))); } $jeu = "C"; } else { // Étendu du set A $madeA = strpos($Aguid,"N"); if ($madeA === false) { $madeA = strlen($Aguid); } // Étendu du set B $madeB = strpos($Bguid,"N"); if ($madeB === false) { $madeB = strlen($Bguid); } // Étendu traité $made = (($madeA < $madeB) ? $madeB : $madeA ); // Jeu en cours $jeu = (($madeA < $madeB) ? "B" : "A" ); // Début start, sinon swap $crypt .= chr(($crypt > "") ? $this->JSwap[$jeu] : $this->JStart[$jeu]); // Conversion selon jeu $crypt .= strtr(substr($code, 0,$made), $this->SetFrom[$jeu], $this->SetTo[$jeu]); } // Raccourcir légende et guides de la zone traitée $code = substr($code,$made); $Aguid = substr($Aguid,$made); $Bguid = substr($Bguid,$made); $Cguid = substr($Cguid,$made); } // Calcul de la somme de contrôle $check = ord($crypt[0]); for ($i=0; $iT128[ord($crypt[$i])]; for ($j=0; $jRect($x,$y,$c[$j]*$modul,$h,"F"); $x += ($c[$j++]+$c[$j])*$modul; } } } /** * Affiche des code barres en les positionnant correctement grâce à des marqueurs * @param string $texte le texte à traiter * @param integer $largeur la largeur du bloc * @param integer $taillePolice Taille de la police du bloc * @param integer $x abscisse du bloc * @param integr $y ordonnée du bloc * @return null */ function code_barres($texte, $largeur, $taillePolice, $x, $y){ $depart = 0; //Pour chaque code barre while( is_numeric($pos = strpos($texte, "|||||", $depart))) { //Récupération du code $code = ""; for ( $i = $pos + 5 ; $i < strpos($texte, "|||||", $pos +1 ) ; $i++ ){ $code .= substr($texte, $i, 1); } //Chaine entre le début et le code barres $chaine = ""; for ( $i = 0 ; $i < $pos ; $i++ ){ $chaine .= substr($texte, $i, 1); } //Longueur de la chaine $longueurChaine = $this->GetStringWidth($chaine); /* * Calcul de l'abscisse du positionnement du code barres */ //Calcul du nombre de ligne, nombre de saut de ligne \n et à de retour à la //ligne à cause de la longueur $nbligne = substr_count($chaine, "\n"); $chaineTemp = explode("\r", $chaine); foreach($chaineTemp as $souschaine){ $longueurSousChaine = $this->GetStringWidth($souschaine); //Si la sous chaine est de taille supérieure à la taille maximal du cadre //une ligne va être sautée if ( $longueurChaine > $largeur ){ $nbligne += (int)($longueurSousChaine/$largeur); } } //Calcul de la taille d'une ligne $pointToMm = 25.4; $pointToMm = $pointToMm/72; $tailleLigne = $pointToMm * $taillePolice * 1.63; /* * Calcul de l'ordonné du positionnement du code barres */ //Nombre de caractère dans la chaine se trouvant avant le code $nbCharChaine = strlen($chaine); //Taille moyenne d'une caractère de la chaine se trouvant avant le code $tailleUnChar = ($nbCharChaine==0)? 0 : $longueurChaine / $nbCharChaine; //Nombre de caractères sur ligne du code barres $nbCharLigneCodeBarres = $this->GetStringWidth($chaineTemp[count($chaineTemp)-1]); if ( $nbCharLigneCodeBarres > $largeur ){ $nbligne += ceil($nbCharLigneCodeBarres/$largeur); $tailleCharLigneCodeBarres = $this->GetStringWidth(substr($chaineTemp[count($chaineTemp)-1], 0, (int)($nbligne*$tailleUnChar))); } else{ $tailleCharLigneCodeBarres = $nbCharLigneCodeBarres; } //Affichage du code barres $this->Code128($tailleCharLigneCodeBarres + $x , $y + $tailleLigne * $nbligne , $code, 50, 8); // Avance au prochain code barres $pos = strpos($texte, "|||||", $pos + 1); $depart = $pos + 1; } } /** * Passe les données entre balises en minuscule et en * majuscule. * @param string $data les données à traiter * @param string $tagName le nom de la balise * * @return string */ function transformMinMaj($data, $tagName){ //le tag doit être min ou MAJ if ( strcasecmp($tagName, "min") === 0 || strcasecmp($tagName, "MAJ") === 0 ) { $temp = explode("<".$tagName.">", $data); //Si des balises ouvrantes sont trouvées for ($i = 1; $i < sizeof($temp); $i++) { // $temp1 = explode("", $temp[$i]); //Si une balise fermante est trouvé if ( sizeof($temp1[0]) > 0 ) { $texteTransforme = ""; //Selon le tag, on transforme les données ( strcasecmp($tagName, "min") == 0 ) ? $texteTransforme = mb_strtolower($temp1[0], 'UTF-8') : $texteTransforme = mb_strtoupper($temp1[0], 'UTF-8'); //On supprime les balises et on ajoute les données transformées $data = str_replace("<".$tagName.">".$temp1[0]."", $texteTransforme, $data); } // $temp1[0] = ""; } } return $data; } /** * Méthodes permettant de convertir n'importe quel encodage vers CP1252 * @param string $value chaîne à encoder */ function convertToCP1252($value) { $encodage = array("UTF-8", "ASCII", "Windows-1252", "ISO-8859-15", "ISO-8859-1"); return iconv(mb_detect_encoding($value, $encodage), "CP1252", $value); } } ?>