Skip to content

Instantly share code, notes, and snippets.

@grekodev
Forked from evilnapsis/ticket-php1.php
Created November 6, 2019 16:37
Show Gist options
  • Save grekodev/a176a8120827b35a72eb8751aa62e30f to your computer and use it in GitHub Desktop.
Save grekodev/a176a8120827b35a72eb8751aa62e30f to your computer and use it in GitHub Desktop.

Revisions

  1. @evilnapsis evilnapsis revised this gist Apr 26, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ticket-php1.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    $pdf->setY(2);
    $pdf->setX(2);
    $pdf->Cell(5,$textypos,"NOMBRE DE LA EMPRESA");
    $pdf->SetFont('Arial','B',5); //Letra Arial, negrita (Bold), tam. 20
    $pdf->SetFont('Arial','',5); //Letra Arial, negrita (Bold), tam. 20
    $textypos+=6;
    $pdf->setX(2);
    $pdf->Cell(5,$textypos,'-------------------------------------------------------------------');
  2. @evilnapsis evilnapsis created this gist Apr 26, 2018.
    50 changes: 50 additions & 0 deletions ticket-php1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    <?php
    include "fpdf/fpdf.php";

    $pdf = new FPDF($orientation='P',$unit='mm', array(45,350));
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',8); //Letra Arial, negrita (Bold), tam. 20
    $textypos = 5;
    $pdf->setY(2);
    $pdf->setX(2);
    $pdf->Cell(5,$textypos,"NOMBRE DE LA EMPRESA");
    $pdf->SetFont('Arial','B',5); //Letra Arial, negrita (Bold), tam. 20
    $textypos+=6;
    $pdf->setX(2);
    $pdf->Cell(5,$textypos,'-------------------------------------------------------------------');
    $textypos+=6;
    $pdf->setX(2);
    $pdf->Cell(5,$textypos,'CANT. ARTICULO PRECIO TOTAL');

    $total =0;
    $off = $textypos+6;
    $producto = array(
    "q"=>1,
    "name"=>"Computadora Lenovo i5",
    "price"=>100
    );
    $productos = array($producto, $producto, $producto, $producto, $producto );
    foreach($productos as $pro){
    $pdf->setX(2);
    $pdf->Cell(5,$off,$pro["q"]);
    $pdf->setX(6);
    $pdf->Cell(35,$off, strtoupper(substr($pro["name"], 0,12)) );
    $pdf->setX(20);
    $pdf->Cell(11,$off, "$".number_format($pro["price"],2,".",",") ,0,0,"R");
    $pdf->setX(32);
    $pdf->Cell(11,$off, "$ ".number_format($pro["q"]*$pro["price"],2,".",",") ,0,0,"R");

    $total += $pro["q"]*$pro["price"];
    $off+=6;
    }
    $textypos=$off+6;

    $pdf->setX(2);
    $pdf->Cell(5,$textypos,"TOTAL: " );
    $pdf->setX(38);
    $pdf->Cell(5,$textypos,"$ ".number_format($total,2,".",","),0,0,"R");

    $pdf->setX(2);
    $pdf->Cell(5,$textypos+6,'GRACIAS POR TU COMPRA ');

    $pdf->output();