Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

<?

php
require('fpdf/fpdf.php');

class PDF extends FPDF


{
// Cabecera de página
function Header()
{
// Logo
// $this->Image('logo.png',10,8,33);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Movernos a la derecha
$this->Cell(80);
// Título
$this->Cell(100,10,'Control de Pedidos',1,0,'C');
// Salto de línea5
$this->Ln(10);

$this->SetFont('Arial','B',10);
date_default_timezone_set('America/Lima');
$this->Cell(0,10,utf8_decode('Fecha: ').date('Y-m-d'),0,0,'C');
$this->Ln(20);

$this->Cell(18,10,'Fecha',1,0,'C',0);
$this->Cell(50,10,'Agencia',1,0,'C',0);
$this->Cell(50,10,'Cliente',1,0,'C',0);
$this->Cell(10,10,'Ped.',1,0,'C',0);
$this->Cell(12,10,'Mes',1,0,'C',0);
$this->Cell(8,10,'Bod.',1,0,'C',0);
$this->Cell(25,10,'Cod.',1,0,'C',0);
$this->Cell(60,10,utf8_decode('Artículo'),1,0,'C',0);
$this->Cell(17,10,'Cant.',1,0,'C',0);
$this->Cell(10,10,'Hoj.',1,1,'C',0);
}

// Pie de página
function Footer()
{
// Posición: a 1,5 cm del final
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Número de página
$this->Cell(0,10,utf8_decode('Página ').$this->PageNo().'/{nb}',0,0,'C');
}
}

session_start();
include("conexion.php");

$cod = $_GET['id1'];
$cli = $_GET['id2'];
$feci = $_GET['id3'];
$fecf = $_GET['id4'];

$movimientos = "SELECT k.fecha fec, ag.nom_age nomagen, c.nom_cli nomclie, k.ped


nped,
k.per_ped perped, k.cod_bod bode, a.cod_art codart,
concat(a.Descrip_art,' ',l.descrip_color,'
',s.descrip_calibre) descrip,
k.cant canti, k.hojas hoj
from movimientos k, articulos a, agencias ag, clientes c, colores
l, calibres s
where k.fecha>= '$feci' and fecha <= '$fecf' and
k.cod_art = if('$cod' =
'T',k.cod_art,'$cod') and
k.id_clie = if('$cli' =
'T',k.id_clie,'$cli') and
k.cod_age = ag.cod_age and k.id_clie
= c.id_cliente and
k.cod_art = a.cod_art and
a.cod_color = l.cod_color and
a.cod_calibre = s.cod_calibre
order by 1,2,3,5,4,8";

$resultado = mysqli_query($conexion, $movimientos);

$pdf = new PDF('L','mm','Letter');


$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','',7);

while ($row = mysqli_fetch_assoc($resultado)) {


$pdf->Cell(18,10,$row['fec'],1,0,'C',0);
$pdf->Cell(50,10,$row['nomagen'],1,0,'C',0);
$pdf->Cell(50,10,$row['nomclie'],1,0,'C',0);
$pdf->Cell(10,10,$row['nped'],1,0,'C',0);
$pdf->Cell(12,10,$row['perped'],1,0,'C',0);
$pdf->Cell(8,10,$row['bode'],1,0,'C',0);
$pdf->Cell(25,10,$row['codart'],1,0,'C',0);
$pdf->Cell(60,10,$row['descrip'],1,0,'C',0);
$pdf->Cell(17,10,$row['canti'],1,0,'C',0);
$pdf->Cell(10,10,$row['hoj'],1,1,'C',0);
}

$nomarch = 'pedidos'.date('Y-m-d').'_'.date('Hms');

$pdf->Output('D',$nomarch.'.pdf','true');
?>

You might also like