Subversion Repositories ALCASAR

Rev

Rev 584 | Rev 921 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

<?php
// ticket d'impression (thank's to Geoffroy MUSITELLI)
//--recupération des variables provenant du formulaire 
// Etiquettes
$l_login_imp=utf8_decode($_POST["l_login_imp"]);
$l_password_imp=utf8_decode($_POST["l_password_imp"]);
$l_max_all_session_imp=utf8_decode($_POST["l_max_all_session_imp"]);
$l_session_timeout_imp=utf8_decode($_POST["l_session_timeout_imp"]);
$l_max_daily_session_imp=utf8_decode($_POST["l_max_daily_session_imp"]);
$l_max_monthly_session_imp=utf8_decode($_POST["l_max_monthly_session_imp"]);
$l_expiration_imp=utf8_decode($_POST["l_expiration_imp"]);
// Valeurs 
$log_imp=utf8_decode($_POST["log_imp"]);
$passwd_imp=utf8_decode($_POST["passwd_imp"]);
$exp_imp=utf8_decode($_POST["exp_imp"]);
$sto_imp=utf8_decode($_POST["sto_imp"]);
$mas_imp=utf8_decode($_POST["mas_imp"]);
$mds_imp=utf8_decode($_POST["mds_imp"]);
$mms_imp=utf8_decode($_POST["mms_imp"]);

//--initialisation des classes FPDF
require('../../lib/fpdf16/fpdf.php');

//création de la classe PDF pour faire l'entête et pieds de page
class PDF extends FPDF
{
        //Entête
        function Header()
        {
                $l_title_imp=utf8_decode($_POST["l_title_imp"]);
                //Logo coordonnées x , y, largeur de l'image ---Attention fpdf ne supporte pas le png avec fond transparent----
//              $this->Image('../../../images/organisme.jpg',25,5,25);
                //Police Arial gras 15
                $this->SetFont('Arial','B',18);
                //couleur de l'écriture en rouge
                $this->SetTextColor(250,1,10);
                //Titre largeur cellule x , hauteur y, texte, bordure 0 , Indique où déplace la prochaine position courante 0 droite, centré C
                $this->Cell(190,10,$l_title_imp,0,0,'C');
                //Saut de ligne
                $this->Ln(25);
        }
        //Pied de page
        function Footer()
        {
                //Positionnement à 1,5 cm du bas
                $this->SetY(-15);
                //Police Arial italique 8
                $this->SetFont('Arial','I',8);
                //Produit par est volontairement resté en français
                $this->Cell(200,20,'Produit par : ALCASAR',0,0,'C');
        }
        //fonction rectangle
        //Rectangle : 
        //x, y : coin supérieur gauche du rectangle.w, h : largeur et hauteur. r : rayon des coins arrondis.
    //style : comme celui de Rect() : F, D (défaut), FD ou DF. 
        function RoundedRect($x, $y, $w, $h, $r, $style = '')
        {
                $k = $this->k;
                $hp = $this->h;
                if($style=='F')
                        $op='f';
                elseif($style=='FD' or $style=='DF')
                        $op='B';
                else
                        $op='S';
                $MyArc = 4/3 * (sqrt(2) - 1);
                $this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k ));
                $xc = $x+$w-$r ;
                $yc = $y+$r;
                $this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k ));

                $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
                $xc = $x+$w-$r ;
                $yc = $y+$h-$r;
                $this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k));
                $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
                $xc = $x+$r ;
                $yc = $y+$h-$r;
                $this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k));
                $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
                $xc = $x+$r ;
                $yc = $y+$r;
                $this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k ));
                $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
                $this->_out($op);
        }
    //fonction arc de cercle
        function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
        {
                $h = $this->h;
                $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1*$this->k, ($h-$y1)*$this->k,
                        $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
        }
}

//création du constructeur pdf avec fpdf : portrait P sinon paysage L, unite  mm, page A4
$pdf = new PDF('L','mm','A5'); 
$pdf->AliasNbPages();
//creation de la page
$pdf->Addpage();
//Couleur du texte en noir
$pdf->SetTextColor(0);

//création du cadre arrondi qui entoure le ticket d'impression
//x, y : coin supérieur gauche du rectangle.w, h : largeur et hauteur. r : rayon des coins arrondis.
//style : comme celui de Rect() : F, D (défaut), FD ou DF. 
$pdf->RoundedRect(40, 32, 130, 80, 3.5, 'D');
//création utilisateur et mot de passe coordonnées x , y hauteur et largeur , texte
$pdf->Ln(5); 
$pdf->SetFont('Arial','',12);
$pdf->cell(50);
$pdf->Cell(45,10,$l_login_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$log_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_password_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$passwd_imp,0,1,'L');
//saut de ligne 
$pdf->Ln(7); 
//création des attributs utilisateurs coordonnées x , y hauteur et largeur , texte
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_max_all_session_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$mas_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_session_timeout_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$sto_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_max_daily_session_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$mds_imp,0,1,'L');
//$pdf->SetFont('Arial','',12);
//$pdf->cell(50);
//$pdf->Cell(45,10,$l_max_monthly_session_imp,0,0,'R');
//$pdf->SetFont('Arial','B',12);
//$pdf->Cell(45,10,$mms_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_expiration_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$exp_imp,0,1,'L');

//renvoie au navigateur du document 
$pdf->Output('ticket.pdf','I');

?>