<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php"); 
require_once("DF80000.php");
class PDF extends FPDF
{
	//Cabecera de página
	function Header()
	{
	    //Logo
	    include("DYIM_VER.php");
	    //Arial bold 14
	    $this->SetFont('Arial','B',10);
	    //Título
			$this->Cell(230,3,'PEDIDO SOBRE RECETAS',0,1,'C');
	    //Salto de línea
	    $this->Ln(3);
		$this->SetFont('Arial','',8);//establece tamaño de letra
		$this->SetFillColor(192,192, 192);
		$this->Cell(60,5,'',0,0,'C',0);
		$this->Cell(25,5,'CLAVE PEDIDO',10,'','C',1);
		$this->Cell(60,5,'DESCRIPCION',10,'','C',1);
		$this->Cell(18,5,'FECHA',10,'1','C',1);		
	}
	    //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, $this->PageNo().'/{nb}',0,0,'C');
	}
}
if($_POST['t1']=="clave") $sql ="SELECT * FROM cos_ped WHERE cos_ped.modulo='".$_SESSION['mod_sis']."' AND   n_reg = '".$_POST['b1']."' order by n_reg ";
elseif($_POST['t1']=="nombre") $sql="SELECT * FROM cos_ped WHERE cos_ped.modulo='".$_SESSION['mod_sis']."' AND   np_desc1 like '%".$_POST['b1']."%' order by n_reg";
else $sql = "SELECT * FROM cos_ped order by n_reg ";
$result = mysqli_query ($sql) or die (mysqli_error($GLOBALS['con'])); 
$num_elementos=count($data);
$pdf=new PDF('L','mm','A4');
$pdf->AddPage();
while ($data = mysqli_fetch_array($result)) { 
	$pdf->Cell(60,5, '',0,'','C');
	$pdf->Cell(25,5, $data['n_reg'],0,'','C');
	$pdf->Cell(60,5, $data['np_desc1'],0,'','C');
	$pdf-> Cell(18,5, chfecha($data['fecha'],'Y-m-d'),0,1,'C',0);
} 
$pdf->Output("PEDIDO_SOBRE_RECETAS.pdf","D");
?> 