<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
 
class PDF extends FPDF
{
	//Cabecera de Página
	function Header()
	{
	    //Logotipo
	         include("DYIM_VER.php");
	    //Arial Bold (14)
	    $this->SetFont('Arial','B',10);
	    //Espacio
		
	    //Título
	    $this->Cell(190,1,'REPORTE - LINEAS',0,1,'C');
	    //Salto de línea
	    $this->Ln(1);
		$this->SetFont('Times','',8);//establece tamaño de letra
		$this->SetFillColor(192,192, 192);
		$this->Cell(13,5,'',0,'C');//centra
		$this->Cell(10,5,'Clave',1,0,'C',1);
		$this->Cell(45,5,'Descripcion',1,0,'C',1);
		$this->Cell(20,5,'Cuenta Costo',1,0,'C',1);
		$this->Cell(20,5,'Cuenta Inventario',1,0,'C',1);
		$this->Cell(20,5,'Cuenta Venta',1,0,'C',1);
		$this->Cell(25,5,'Devolucion Venta',1,0,'C',1);
        $this->Cell(25,5,'Desc/Bonifica',1,1,'C',1);

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

if(isset($_POST['bot'])&&$_POST['bot']==""){
	if(isset($_POST['tip_bus'])&&$_POST['tip_bus']=="clave"){
		@$sql1 ="SELECT * FROM dglineasp WHERE linea = '".$_POST['txt_t1']."'";
	}elseif(isset($_POST['tip_bus'])&&$_POST['tip_bus']=="descripcion"){
		@$sql1 ="SELECT * FROM dglineasp WHERE des_linea LIKE '%".$_POST['txt_t1']."%'";
	}else{
		@$sql1 = "SELECT * FROM dglineasp";
	}
}else{
	$sql1 = "SELECT * FROM dglineasp WHERE linea = '".$_POST['bot']."'";
}
$sql = mysqli_query ($sql1); 
while (@$reg = mysqli_fetch_row($sql)) { 
    $data[] = $reg[0]; 
    $data1[] = $reg[1];
    $data2[] = $reg[2]; 
    $data3[] = $reg[3]; 
    $data4[] = $reg[4]; 
    $data5[] = $reg[5]; 
    $data6[] = $reg[6]; 
    $data7[] = $reg[7];

	}
$num_elementos=count($data);
$pdf=new PDF();
$pdf->AddPage();
//Titolo de la tabla
$pdf->SetFont('Times','',8);//establece tamaño de letra

for($i=0;$i<=$num_elementos-1;$i++)
{
	//$pdf->SetFillColor(49,120, 200);
	$pdf->Cell(13,5,'',0,'C');//centra
	$pdf->Cell(10,5, $data[$i],1,'','C');
	//$pdf->Cell(45,5, $data1[$i],1,'','L');
	$pdf->Cell(45,5, $data2[$i],1,'','L');	
	$pdf->Cell(20,5, $data3[$i],1,'','C');
	$pdf->Cell(20,5, $data4[$i],1,'','C');
	$pdf->Cell(20,5, $data5[$i],1,'','C');
	$pdf->Cell(25,5, $data6[$i],1,'','C');
        $pdf->Cell(25,5, $data7[$i],1,'','C');
	//$pdf->Cell(25,5, $data6[$i],1,1,'C');
} 
$pdf->Output("Lineas.pdf","D");
?> 
