<?php
session_start();
if(!isset($_SESSION['s_usuario'])) header('location: index.php');
require_once "../admin/class.ezpdf.php";
$pdf =& new Cezpdf('a4');
$pdf->selectFont('../fonts/Arial.afm');
//$pdf->ezSetCmMargins(1.5,1.5,1.5,1.5);
$conexion = mysql_connect("localhost", "root", "root");
mysql_select_db("bdcourier", $conexion);
//$dato= $_POST['dato'];
if($_POST['dato'] == "Contado"){  
$queEmp="select Rucdni,Numero,UPPER(cliente.Descripcion),UPPER(Area),UPPER(Tipopersona) from cliente inner join servicio where cliente.Idservicio=servicio.Idservicio and cliente.Tipocredito='CONTADO'";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
$ixx = 0;
while($datatmp = mysql_fetch_assoc($resEmp)) {
    $ixx = $ixx+1;
    $data[] = array_merge($datatmp, array('num'=>$ixx));
}
$titles = array(
                'num'=>' ITEM ',
                'Rucdni'=>' RUC-DNI ',
                'UPPER(cliente.Descripcion)'=>'  DESCRIPCION  ',
                'UPPER(Tipopersona)'=>' TIPO '
            );
$options = array(
               'shadeCol'=>array(0.9,0.9,0.9),
				'xOrientation'=>'center',
                'width'=>500
            );
$txttit = "::CTK-COURIER::\n";
$txttit.= "Lista de Clientes--Contado--\n";
$pdf->ezText($txttit, 14);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n\n\n", 9);
$pdf->ezText("Fecha:".date("d/m/Y"), 10);
$pdf->ezText("Hora:".date("H:i:s")."\n\n", 10);
$pdf->ezStream();
}
elseif($_POST['dato'] == "Credito") 
{ 
$queEmp="select Rucdni,Numero,UPPER(cliente.Descripcion),UPPER(Area),UPPER(Tipopersona) from cliente inner join servicio where cliente.Idservicio=servicio.Idservicio  and cliente.Tipocredito='CREDITO'";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
$ixx = 0;
while($datatmp = mysql_fetch_assoc($resEmp)) {
    $ixx = $ixx+1;
    $data[] = array_merge($datatmp, array('num'=>$ixx));
}
$titles = array(
                'num'=>' ITEM ',
                'Rucdni'=>' RUC-DNI ',
                'UPPER(cliente.Descripcion)'=>'  DESCRIPCION  ',
                'UPPER(Tipopersona)'=>' TIPO '
            );
$options = array(
               'shadeCol'=>array(0.9,0.9,0.9),
				'xOrientation'=>'center',
                'width'=>500
            );
$txttit = "::CTK-COURIER::\n";
$txttit.= "Lista de Clientes--Credito--\n";
$pdf->ezText($txttit, 14);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n\n\n", 9);
$pdf->ezText("Fecha:".date("d/m/Y"), 10);
$pdf->ezText("Hora:".date("H:i:s")."\n\n", 10);
$pdf->ezStream();
}
elseif($_POST['dato'] == "Otros") 
{ 
$queEmp="select Rucdni,Numero,UPPER(cliente.Descripcion),UPPER(Area),UPPER(Tipopersona) from cliente inner join servicio where cliente.Idservicio=servicio.Idservicio and  cliente.Tipocredito='INTERNO'";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
$ixx = 0;
while($datatmp = mysql_fetch_assoc($resEmp)) {
    $ixx = $ixx+1;
    $data[] = array_merge($datatmp, array('num'=>$ixx));
}
$titles = array(
                'num'=>' ITEM ',
                'Rucdni'=>' RUC-DNI ',
                'UPPER(cliente.Descripcion)'=>'  DESCRIPCION  ',
                'UPPER(Area)'=>' AREA ',
		'UPPER(Tipopersona)'=>' TIPO '
            );
$options = array(
               'shadeCol'=>array(0.9,0.9,0.9),
				'xOrientation'=>'center',
                'width'=>500
            );
$txttit = "::CTK-COURIER::\n";
$txttit.= "Lista de Clientes--Otros--\n";
$pdf->ezText($txttit, 14);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n\n\n", 9);
$pdf->ezText("Fecha:".date("d/m/Y"), 10);
$pdf->ezText("Hora:".date("H:i:s")."\n\n", 10);
$pdf->ezStream();

} 
elseif($_POST['dato'] == "Especial") 
{ 
$queEmp="select Rucdni,Numero,UPPER(cliente.Descripcion),UPPER(Area),UPPER(Tipopersona) from cliente inner join servicio where cliente.Idservicio=servicio.Idservicio and servicio.Descripcion='90'";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
$ixx = 0;
while($datatmp = mysql_fetch_assoc($resEmp)) {
    $ixx = $ixx+1;
    $data[] = array_merge($datatmp, array('num'=>$ixx));
}
$titles = array(
                'num'=>' ITEM ',
                'Rucdni'=>' RUC-DNI ',
                'UPPER(cliente.Descripcion)'=>'  DESCRIPCION  ',
		'UPPER(Tipopersona)'=>' TIPO '
            );
$options = array(
               'shadeCol'=>array(0.9,0.9,0.9),
				'xOrientation'=>'center',
                'width'=>500
            );
$txttit = "::CTK-COURIER::\n";
$txttit.= "Lista de Clientes--Especial--\n";
$pdf->ezText($txttit, 14);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n\n\n", 9);
$pdf->ezText("Fecha:".date("d/m/Y"), 10);
$pdf->ezText("Hora:".date("H:i:s")."\n\n", 10);
$pdf->ezStream();
} 
else
{
$queEmp="select Rucdni,Numero,UPPER(cliente.Descripcion),UPPER(Area),UPPER(Tipopersona) from cliente inner join servicio where cliente.Idservicio=servicio.Idservicio";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
$ixx = 0;
while($datatmp = mysql_fetch_assoc($resEmp)) {
    $ixx = $ixx+1;
    $data[] = array_merge($datatmp, array('num'=>$ixx));
}
$titles = array(
                'num'=>' ITEM ',
                'Rucdni'=>' RUC-DNI ',
                'UPPER(cliente.Descripcion)'=>'  DESCRIPCION  ',
                'UPPER(Tipopersona)'=>' TIPO '
            );
$options = array(
               'shadeCol'=>array(0.9,0.9,0.9),
				'xOrientation'=>'center',
                'width'=>500
            );
$txttit = "::CTK-COURIER::\n";
$txttit.= "Lista de Clientes--Otros--\n";
$pdf->ezText($txttit, 14);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n\n\n", 9);
$pdf->ezText("Fecha:".date("d/m/Y"), 10);
$pdf->ezText("Hora:".date("H:i:s")."\n\n", 10);
$pdf->ezStream();
}
?>




