<?php
if(phpversion()>4.2)parse_str(apache_getenv("QUERY_STRING"));
session_start();
require("config.php");
require($INCLUDEBASE."library.php");
$user = CheckUserLogin($_SESSION['login'], $_SESSION['password']);
$gpo = $user["groupid"];
$cli = $user["cliente"];
$operador = $user["operador"];
$operador_id = $user["codigo"];
$printer=$_SESSION['printers'];
$login=$_SESSION['login'];
$password=$_SESSION['password'];
$ip=getenv('REMOTE_ADDR');


switch($accion){


/*
if($fecha < "20-07-2005"){
select 	op_directo,
	nomusu(op_directo) as nombredirecto,
	op_indirecto,
	nomusu(op_indirecto) as nombreindirecto,
	op_tipoper,
	op_nrotaldir,
	op_compbte,
	op_comptrans,
	date(opv_fecha_ing) as fechaing,
	date(opv_fecha_egr) as fechaegr,
	opv_pat_tractor,
	opv_pat_chasis,
	opv_est_camion,
	opv_nro_doc,
	opv_chofer,
	opv_peso_ing,
	opv_peso_egr,
	opv_pesa,
	op_peso,
	opv_obs,
	opv_idoper
    from operaciones, opervehi 
	where date(opv_fecha_ing)='19-07-2005'
	    and op_id=opv_idoper
	    and op_tipoper in (1,5)
	    order by opv_fecha_ing;
	    ";
}else{
*/

/*
$Query="select opv_pat_tractor,
	opv_pat_chasis,
	opv_chofer,
	opv_nro_doc,
	op_compbte,
	op_comptrans,
	op_directo,
	nomusu(op_directo) as nombredirecto,
	op_indirecto,
	nomusu(op_indirecto) as nombreindirecto,
	marc_descrip,
	cont_nrocont,
	clac_nombre,
	clac_medida,
	cont_preori,
	cont_preana,
	cont_presatel,
	opv_pesa,	
	date(opv_fecha_ing) as fechaing,
	date(opv_fecha_egr) as fechaegr,
	opv_est_camion,
	opv_peso_ing,
	opv_peso_egr,
	op_peso,
	opv_obs,
	opv_idoper,
	op_tipoper,
	op_nrotaldir
    from operaciones, opervehi, contene, clacont, marcont
    	where date(opv_fecha_ing)='$fecha'
	    and op_id=opv_idoper
	    and op_id = cont_idoper
	    and opv_id = cont_idopv
	    and cont_clacont = clac_codigo
	    and cont_marcont = marc_codigo
	    and op_tipoper in (1,5)
	    order by opv_fecha_ing;
	    ";
*/




    case 'EXCEL'	:   
/*
    $fecha="19-07-2005";
    $Query="select op_directo,
	nomusu(op_directo) as nombredirecto,
	op_indirecto,
	nomusu(op_indirecto) as nombreindirecto,
	op_tipoper,
	op_nrotaldir,
	op_compbte,
	op_comptrans,
	date(opv_fecha_ing) as fechaing,
	date(opv_fecha_egr) as fechaegr,
	opv_pat_tractor,
	opv_pat_chasis,
	opv_est_camion,
	opv_nro_doc,
	opv_chofer,
	opv_peso_ing,
	opv_peso_egr,
	opv_pesa,
	op_peso,
	opv_obs,
	opv_idoper,
	marc_descrip,
	cont_nrocont,
	cont_preori,
	cont_preana,
	cont_presatel,
	clac_nombre,
	clac_medida
    from operaciones, opervehi, contene, clacont, marcont
    	where date(opv_fecha_ing)='$fecha'
	    and op_id=opv_idoper
	    and op_id = cont_idoper
	    and opv_id = cont_idopv
	    and cont_clacont = clac_codigo
	    and cont_marcont = marc_codigo
	    and op_tipoper in (1,5)
	    order by opv_fecha_ing;
	    ";

    $r=PgDoQuery($Query);
    $rows = pg_numrows($r);
    $cols = pg_numfields($r);
*/
// HTTP headers
    function HeaderingExcel($filename) {
      header("Content-type: application/vnd.ms-excel");
      header("Content-Disposition: attachment; filename=$filename" );
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
      header("Pragma: public");
      }

$filename = "Ingreso de Transportes ".$fecha .".xls";

  HeaderingExcel($filename);
// Creating a workbook
  $workbook = new Workbook("-");
// Creating the first worksheet
  $worksheet1 =& $workbook->add_worksheet('Ingresos Vehicular');
/*
  $formato1 =& $workbook->add_format();
  $formato1->set_size(8);
  $formato1->set_align('left');
  $formato1->set_color('black');
  $formato1->set_pattern();
  $formato1->set_fg_color('white');
  $formato1->set_bold();

  $formatot =& $workbook->add_format();
  $formatot->set_size(8);
  $formatot->set_align('center');
  $formatot->set_color('black');
  $formatot->set_pattern();
  $formatot->set_fg_color('silver');
  $formatot->set_bold();
  $formatot->set_border(2);
  $formatot->set_border_color('black');

  $formato2 =& $workbook->add_format();
  $formato2->set_size(8);
  $formato2->set_align('left');
  $formato2->set_pattern();
  $formato2->set_fg_color('silver');
  $formato2->set_border(7);
  $formato2->set_border_color('gray');

  $formato3 =& $workbook->add_format();
  $formato3->set_size(8);
  $formato3->set_align('left');
  $formato3->set_color('blue');
  $formato3->set_italic();
  $formato3->set_pattern();
  $formato3->set_fg_color('white');
  $formato3->set_border(7);
  $formato3->set_border_color('gray');
*/
/*
    $worksheet1->write_string(0,0, 'INGRESOS DEL DIA ' . $fecha,$formatot);
//	       $worksheet1->merge_cells(0,0,1,14);
// TITULOS
// Primera linea del Titulo
	       $worksheet1->write_string(2,1, 'N.',$formatot);
	       $worksheet1->write_string(2,2, 'TRACTOR',$formatot);
	       $worksheet1->write_string(2,3, 'SEMI',$formatot);
	       $worksheet1->write_string(2,4, 'CONDUCTOR',$formatot);
	       $worksheet1->write_string(2,5, 'D.N.I. / C.I.',$formatot);
	       $worksheet1->write_string(2,6, 'COMPROBANTE',$formatot);
	       $worksheet1->write_string(2,7, 'TRANSITO',$formatot);
	       $worksheet1->write_string(2,8, 'USUARIO DIRECTO',$formatot);
	       $worksheet1->write_string(2,9, 'USUARIO INDIRECTO',$formatot);
	       $worksheet1->write_string(2,10, 'CONTENEDOR',$formatot);
	       $worksheet1->write_string(2,11, 'TIPO',$formatot);
	       $worksheet1->write_string(2,12, 'PRECINTO ORIGEN',$formatot);
	       $worksheet1->write_string(2,13, 'PRECINTO ADUANA',$formatot);
	       $worksheet1->write_string(2,14, 'PRECINTO SATELITAL',$formatot);
	       $worksheet1->write_string(2,15, 'PESA?',$formatot);
// FIN TITULOS


    for($filmax=$i=0;$i < $rows;$i++){
	$filmax++;
	$worksheet1->write_number($filmax+4, 0, $filmax,$formato2);
        for($j=0;$j < $cols;$j++){
	    if(!strncmp(pg_fieldtype($r,$j),"numeric",5) || !strncmp(pg_fieldtype($r,$j),"int",3)){
		$worksheet1->write_number($filmax+4, $j+1, Resultado($r,$i,$j,1),$formato2);
		}else{
		$worksheet1->write_string($filmax+4,$j+1, Resultado($r,$i,$j,1),$formato2);
	    }
	}
    }

*/
$workbook->close();
break;


    case 'BUSCAR'	:   
	echo("<HTML>\n");
	echo("<HEAD>\n");
	echo("<TITLE>Consulta</TITLE>\n");
	echo("<style>\n");
	echo(" .input_text{font-size=8pt;\n");
	echo("             font:bold;\n");
	echo("             font:normal;\n");
	echo("             color:black;\n");
	echo("             border:2px groove #CCCCCC;\n");
	echo("             background-color: silver;\n");
	echo("             font-family:verdana;\n");
	echo("             height:20px;\n");
	echo("             }\n");
	echo(" .text{font-size=10pt;\n");
	echo("             font:bold;\n");
	echo(" 	          font:normal;\n");
	echo("             color:000000;\n");
	echo("             background-color: silver;\n");
	echo("             font-family:arial;\n");
	echo("             }\n");
	echo(" .textlow{font-size=8pt;\n");
	echo("             font:normal;\n");
	echo("             color:000000;\n");
	echo("             background-color: CCCCCC;\n");
	echo("             font-family:arial;\n");
	echo("             }\n");
	echo(" .textlown{font-size=8pt;\n");
	echo("             font:normal;\n");
	echo("             color:000000;\n");
	echo("             background-color: silver;\n");
	echo("             font-family:arial;\n");
	echo("             }\n");
	echo(" .textlowa{font-size=8pt;\n");
	echo("             font:normal;\n");
	echo("             color:0000FF;\n");
	echo("             background-color: silver;\n");
	echo("             font-family:arial;\n");
	echo("             }\n");
	echo(" .textlowv{font-size=8pt;\n");
	echo("             font:normal;\n");
	echo("             color:008000;\n");
	echo("             background-color: silver;\n");
	echo("             font-family:arial;\n");
	echo("             }\n");


// ESTAS LINEAS
	echo("/* Sortable tables */\n");
	echo("table.sortable a.sortheader {\n");
	echo("    background-color:#CCCCCC;\n");
	echo("    color:#000000;\n");
	echo("    font-weight: bold;\n");
	echo("    text-decoration: none;\n");
	echo("    display: block;\n");
	echo("}\n");
	echo("table.sortable span.sortarrow {\n");
	echo("    color: black;\n");
	echo("    text-decoration: none;\n");
	echo("}\n");





	echo("</style>\n");


// ESTA LINEA
echo("<script type=\"text/javascript\" src=\"sorttable.js\"></script>\n");



	echo("</HEAD>\n");

    if($camion==2)
	{

    $pase=0;
	if($fecha)
	    {
	    $pase=1;
	    $complet="date(opv_fecha_ing)='$fecha'";
	    }
	if($documento)
	    {
	    if($pase==1)
		$complet.=" and ";
	    $pase=1;
	    $complet.="op_compbte like '%$documento%'";
	    }
	if($patente)
	    {
	    if($pase==1)
		$complet.=" and ";
	    $pase=1;
	    $complet.="opv_pat_tractor='$patente'";
	    }
	if($op_directo)
	    {
	    if($pase==1)
		$complet.=" and ";
	    $pase=1;
	    $complet.="op_directo=$op_directo ";
	    }
	if($op_indirecto)
	    {
	    if($pase==1)
		$complet.=" and ";
	    $pase=1;
	    $complet.="op_indirecto=$op_indirecto ";
	    }
	if($op_tipoper)
	    {
	    if($pase==1)
		$complet.=" and ";
	    $pase=1;
	    $complet.="op_tipoper=$op_tipoper";
	    }

	$query="select op_id,op_tipoper,op_nrotaldir,op_directo,op_indirecto,op_compbte,
	    date(opv_fecha_ing) as fechaing,
	    date(opv_fecha_egr) as fechaegr,opv_pat_tractor,opv_pat_chasis,
	    opv_id,opv_est_camion,opv_peso_ing,opv_peso_egr,op_peso,opv_obs,
	    nomusu(op_directo) as nombredirecto,nomusu(op_indirecto) as nombreindirecto, opv_idoper  
	    from operaciones, opervehi where $complet and op_id=opv_idoper order by opv_fecha_ing;";
	}
    if($camion==1)
	{
	$pase=1;	
	$query="select op_id,op_tipoper,op_nrotaldir,op_directo,op_indirecto,op_compbte,
	    date(opv_fecha_ing) as fechaing,date(opv_fecha_egr) as fechaegr,opv_pat_tractor,opv_pat_chasis,
	    opv_id,opv_est_camion,opv_peso_ing,opv_peso_egr,op_peso,opv_obs,
	    nomusu(op_directo) as nombredirecto,nomusu(op_indirecto) as nombreindirecto, opv_idoper 
	    from operaciones, opervehi where opv_est_camion=0 and op_id=opv_idoper order by opv_fecha_reg;";
	}

    $r=PgDoQuery($query);
    $rows_oper=pg_NumRows($r);



	echo("<body bgcolor=\"#C0C0C0\" topmargin=\"20\" leftmargin=\"0\">");
    if($rows_oper){
    if($op_directo)
	{
	$d=PgDoQuery("select usu_nombre from usuarios where usu_codigo = $op_directo;");
	$op_nomdirecto=Resultado($d,0,"usu_nombre",1);
	}
    if($op_indirecto)
	{
	$i=PgDoQuery("select usu_nombre from usuarios where usu_codigo = $op_indirecto;");
	$op_nomindirecto=Resultado($i,0,"usu_nombre",1);
	}

// echo $query;

    echo("<CENTER><p class=\"text\">Movimiento vehicular  $fecha $patente $documento</p></CENTER>");

    echo("<TABLE id=\"t1\" class=\"sortable\" cellSpacing=0 cellPadding=1 border=1 bordercolor=\"CCCCCC\" ALIGN=\"CENTER\">");
//    echo("	<table width=\"100%\" border=\"1\" align=\"center\" bordercolor=\"#CCCCCC\" cellpadding=\"1\" cellspacing=\"0\"  bgcolor=\"#C0C0C0\">");
    echo("  <TBODY>");
    echo("  <TR>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Fecha In</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Fecha Out</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Directo</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Indirecto</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\" colspan=\"2\"> Operaci&oacute;n</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Comprobante</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Peso Docum.</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Patente</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Peso In</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Peso Out</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Neto</TD>");
    echo("<TD CLASS=\"textlow\" align=\"center\"> Estado</TD>");
    echo("</TR>");
    for($i=0; $i < $rows_oper ; $i++)
	{
	$opv_obs=Resultado($r,$i,"opv_obs",1);
	$op_id=Resultado($r,$i,"op_id",1);
	$opv_id=Resultado($r,$i,"opv_id",1);
        $op_tipoper=Resultado($r,$i,"op_tipoper",1);
	$op_nrotaldir=Resultado($r,$i,"op_nrotaldir",1);
	$op_directo=Resultado($r,$i,"op_directo",1);
	$op_indirecto=Resultado($r,$i,"op_indirecto",1);
        $op_compbte=Resultado($r,$i,"op_compbte",1);
        $opv_pat_tractor=Resultado($r,$i,"opv_pat_tractor",1);
        $opv_pat_chasis=Resultado($r,$i,"opv_pat_chasis",1);
        $fechaing=Resultado($r,$i,"fechaing",1);
        $fechaegr=Resultado($r,$i,"fechaegr",1);
        $opv_est_camion=Resultado($r,$i,"opv_est_camion",1);
        $opv_peso_ing=Resultado($r,$i,"opv_peso_ing",1);
        $opv_peso_egr=Resultado($r,$i,"opv_peso_egr",1);
        $op_peso=Resultado($r,$i,"op_peso",1);
        $nombredirecto=Resultado($r,$i,"nombredirecto",1);
        $nombreindirecto=Resultado($r,$i,"nombreindirecto",1);
        $opv_idoper=Resultado($r,$i,"opv_idoper",1);

	$t=PgDoQuery("select top_comprob from tipoper where top_codigo = $op_tipoper;");
        $op_nomtipoper=Resultado($t,0,"top_comprob",1);
	echo("<TR>");
	echo("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;$fechaing</TD>");
	echo("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;$fechaegr</TD>");
	echo("<TD CLASS=\"textlown\" align=\"center\"><A HREF=\"#\" style=\"text-decoration:none\" TITLE=\"$nombredirecto\"> $op_directo</A></TD>");

//	echo("<TD CLASS=\"textlown\" align=\"center\"> $nombredirecto </TD>");

	echo("<TD CLASS=\"textlown\" align=\"center\"><A HREF=\"#\" style=\"text-decoration:none\" TITLE=\"$nombreindirecto\"> $op_indirecto</A></TD>");

//	echo("<TD CLASS=\"textlown\" align=\"center\"> $nombreindirecto </TD>");

	echo("<TD CLASS=\"textlown\" align=\"center\">$op_nomtipoper</TD>");
	echo("<TD CLASS=\"textlown\" align=\"center\"> $op_nrotaldir</TD>");
	echo("<TD CLASS=\"textlown\" align=\"center\"> $op_compbte</TD>");
	printf("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;%10.2f</TD>",$op_peso);
	echo("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;$opv_pat_tractor - $opv_pat_chasis</TD>");
	printf("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;%d</TD>",$opv_peso_ing);
	printf("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;%d</TD>",$opv_peso_egr);

if($opv_est_camion == 50 || $opv_est_camion == 2)
    {
        if($opv_peso_ing > $opv_peso_egr){
	    $tara=$opv_peso_ing - $opv_peso_egr; 
	    }else{
	    $tara=$opv_peso_egr - $opv_peso_ing; 
	}
    printf("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;%d</TD>",$tara);
    }else{
    printf("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;</TD>");
}

if($opv_idoper != $operactual){
    $operactual = $opv_idoper;
    if( $op_tipoper < 10 ){
	$total_op_tipoper_in=$total_op_tipoper_in +1;
	}else{
	$total_op_tipoper_out=$total_op_tipoper_out +1;
    }
}

if($opv_est_camion == 1){
    $total_ingresados=$total_ingresados +1;
    echo("<TD CLASS=\"textlowa\" align=\"center\"> &nbsp;Ingresado");
    }
if($opv_est_camion == 2){
    $total_retirados=$total_retirados +1;
    echo("<TD CLASS=\"textlowv\" align=\"center\"> &nbsp;Retirado");
    }
if($opv_est_camion == 50)echo("<TD CLASS=\"textlown\" align=\"center\"> &nbsp;Publicado");
if($opv_est_camion == 100)
{
$total_anulados=$total_anulados + 1;
echo("<TD CLASS=\"textlowa\" align=\"center\"> &nbsp;Anulado");
}
	echo("</TD></TR>");
	}
	echo("  </TBODY>");
	echo("  </TABLE>");
    }
else
    {
	echo("<CENTER><h6 class=\"text\">No se Encuentran Operaciones Activas para los datos ingresados</h6></CENTER>");
	echo("<CENTER><A HREF=\"javascript:history.go(-1)\">Volver</A></CENTER>");
    }




echo("<TABLE cellSpacing=0 cellPadding=1 border=1 bordercolor=\"CCCCCC\" ALIGN=\"LEFT\">");
echo("<CAPTION CLASS=\"textlown\"> Operaciones de Ingreso: $total_op_tipoper_in - Operaciones de Egreso: $total_op_tipoper_out </CAPTION>");
echo("<TR><TD CLASS=\"textlown\" align=\"center\" ROWSPAN=\"4\"><IMG SRC=\"truck.gif\" width=80></TD></TR>");
//echo("<TR><TD CLASS=\"textlown\" align=\"center\">A Ingresar: </TD><TD CLASS=\"textlown\">$total_aingresar</TD></TR>");
echo("<TR><TD CLASS=\"textlown\" align=\"center\">Ingresados </TD><TD CLASS=\"textlown\">$total_ingresados</TD></TR>");
echo("<TR><TD CLASS=\"textlown\" align=\"center\">Retirados: </TD><TD CLASS=\"textlown\">$total_retirados</TD></TR>");
echo("<TR><TD CLASS=\"textlown\" align=\"center\">Anulados: </TD><TD CLASS=\"textlown\">$total_anulados</TD></TR>");
echo("</TABLE>");

	echo("</BODY>");
	echo("</HTML>");


	break;

default	:

	echo("<HTML>\n");
	echo("<HEAD>\n");
	echo("<TITLE>ABM de Transporte</TITLE>\n");
	echo("<STYLE type=text/css>\n");
	echo("	.boton {BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-WEIGHT: bold; BACKGROUND: #000099; BORDER-LEFT: 0px; WIDTH: 80px; COLOR: white; BORDER-BOTTOM: 0px; HEIGHT: 18px}\n");
	echo("	.input_text{font-size=8pt;font:bold;font:normal;color:black;border:2px groove #CCCCCC; background-color: silver;font-family:verdana;height:20px;}\n");
	echo("	.text{font-size=10pt;font:bold;font:normal;color:000000;background-color: silver;font-family:arial;}\n");
	echo("	H4{font-size=12pt;font:bold;color:black;border:0px groove #CCCCCC; background-color: silver;font-family:verdana;height:20px;}\n");
	echo("</STYLE>\n");
	echo("<SCRIPT language=\"JavaScript\" src=\"validate.js\"></SCRIPT>\n");
	echo("<SCRIPT language=\"JavaScript\">\n");
	echo("function Init(frm){\n");
	echo("frm.fecha.focus();\n");
	echo("}\n");
	echo("</SCRIPT>\n");
	echo("<script language=\"JavaScript\"><!--\n");
	echo("function Validate(frm,boton){\n");
	echo("switch(boton){\n");
	echo("case 0:\n");
	echo("    if(Blank(frm.fecha) && Blank(frm.documento) && Blank(frm.patente) && Blank(frm.op_directo) && Blank(frm.op_indirecto)){\n");
	echo("alert('Debe completar al menos uno de los campos para continuar');\n");
	echo("frm.fecha.focus();\n");
	echo("return(false);\n");
	echo("}\n");
	echo("break;\n");
	echo("}\n");
	echo("}\n");
	echo("//-->\n");
	echo("</script>\n");
	echo("<script language=\"JavaScript\" type=\"text/javascript\"><!--\n");
	echo("function newWindow(file,window) {\n");
	echo("    msgWindow=open(file,window,'resizable=no,width=400,height=200');\n");
	echo("    if (msgWindow.opener == null) msgWindow.opener = self;\n");
	echo("}\n");
	echo("//-->\n");
	echo("</script>\n");
	echo("<link rel=\"stylesheet\" href=\"../menu.css\"></link>\n");
	echo("</HEAD>\n");
	echo("<body bgcolor=\"#C0C0C0\" topmargin=\"20\" leftmargin=\"0\" onload=\"Init(document.reimpre)\">\n");
if($ip != "10.1.100.69")
	echo("    <script language=\"JavaScript1.2\" src=\"date.js\"></script>\n");
	echo("<script language='javascript' type=\"text/javascript\">\n");
	echo("function maskKeyPress(objEvent)\n");
	echo("{\n");
	echo("    var iKeyCode;\n");
	echo("    iKeyCode = objEvent.keyCode;\n");
	echo("    if(iKeyCode>=48 && iKeyCode<=57) return true;\n");
	echo("    return false;\n");
	echo("}\n");
	echo("</script>\n");
	echo("<FORM name=\"reimpre\" ACTION=\"consuxdespach.php\">\n");
	echo("<CENTER><H4>Consulta de Movimiento Vehicular</H4></CENTER>\n");
	echo("<TABLE cellSpacing=0 cellPadding=0 align=center border=0>\n");

	$fecha=date("d-m-Y");

	echo("  <tr> \n");
	echo("   <td class=\"text\">Fecha:</td>\n");
	echo("   <td>\n");
	echo("<input type=\"text\" name=\"fecha\" value=\"$fecha\" class=\"input_text\" size='10' maxlength=\"10\" onFocus=\"javascript:vDateType='3'\" onKeyUp=\"DateFormat(this,this.value,event,false,'3')\" onBlur=\"DateFormat(this,this.value,event,true,'3')\">\n");
	echo("   </td>\n");
	echo("  </tr>\n");

	echo("  <tr> \n");
	echo("   <td class=\"text\">Doc. Aduanero:</td>\n");
	echo("   <td>\n");
	echo(" <input type=\"text\" class=\"input_text\" name=\"documento\" size=\"18\" maxlength=\"16\">\n");
	echo("   </td>\n");
	echo("  </tr>\n");

	echo("  <tr> \n");
	echo("   <td class=\"text\">Patente:</td>\n");
	echo("   <td>\n");
	echo(" <input type=\"text\" class=\"input_text\" name=\"patente\" size=\"8\" maxlength=\"8\">\n");
	echo("   </td>\n");
	echo("  </tr>\n");

	echo("  <tr> \n");
	echo("   <td class=\"text\">Usuario Directo:</td>\n");
	echo("   <td>\n");
	echo("    <input type=\"text\" class=\"input_text\" name=\"op_directo\" size=\"4\" maxlength=\"6\" onChange='this.form.directo_nombre.value=\"\";' onkeypress=\"return maskKeyPress(event)\">\n");
$query_directo="select usu_codigo,usu_nombre from usuarios where usu_tipusu in (1,3) order by usu_nombre;";
	echo("    <input type=\"button\" class=\"input_text\" value=\"?\" onClick=\"newWindow('../auxiliar/search.php?formulario=reimpre&campo=op_directo&campo_nombre=directo_nombre&query=$query_directo','window2')\">\n");
	echo("    <input type=\"text\" class=\"input_text\" name=\"directo_nombre\" size=\"25\" maxlength=\"4\" >\n");
	echo("   </td>\n");
	echo("  </tr>\n");

	echo("  <tr> \n");
	echo("   <td class=\"text\">Usuario Indirecto:</td>\n");
	echo("   <td> \n");
	echo("    <input type=\"text\" class=\"input_text\" name=\"op_indirecto\" size=\"4\" maxlength=\"25\" onChange='this.form.indirecto_nombre.value=\"\";' onkeypress=\"return maskKeyPress(event)\">\n");
$query_indirecto="select usu_codigo,usu_nombre from usuarios where usu_tipusu = 2 order by usu_nombre;";
	echo("    <input type=\"button\" class=\"input_text\" value=\"?\" onClick=\"newWindow('../auxiliar/search.php?formulario=reimpre&campo=op_indirecto&campo_nombre=indirecto_nombre&query=$query_indirecto','window2')\">\n");
	echo("    <input type=\"text\" class=\"input_text\" name=\"indirecto_nombre\" size=\"25\" maxlength=\"4\">\n");
	echo("   </td>\n");
	echo("  </tr>\n");

	echo("  <tr>\n");
	echo("   <td>\n"); 
	echo("    <div align=\"left\" class=\"text\">Tipo de Operaci&oacute;n:</div>\n");
	echo("   </td>\n");
        echo("   <td width=\"57%\">\n");
ShowQueryAsCombo("select top_codigo,top_nombre from tipoper where  top_codigo in (1,5,101,105);","op_tipoper",1,0,1);
        echo("   </td>\n");
	echo(" </tr>\n");

	echo("  <tr> ");
	echo("   <td> ");
	echo("    <div align=\"left\" class=\"text\">Estado del Cami&oacute;n:</div>");
	echo("   </td>");
	echo("   <td width=\"57%\"> ");
	echo("    <SELECT  class=\"input_text\" name=\"camion\">");
	echo("<OPTION VALUE = 1>Pendientes de Ingresar</OPTION>");
	echo("<OPTION SELECTED VALUE = 2>Ingresados a Zona</OPTION>");
	echo("    </SELECT>");
	echo("   </td>");
	echo("  </tr>");

	echo("  </TBODY>\n");
	echo("</TABLE>\n");
	echo("</DIV>\n");
	echo("</TABLE>\n");
	echo("</DIV>\n");

	echo("<BR>\n");

	echo("<TABLE cellSpacing=0 cellPadding=2 align=center border=0 Align=center>\n");
	echo("  <TR>\n");
	echo("    <TD><INPUT class=boton type=\"SUBMIT\" value=\"BUSCAR\" name=\"accion\" onclick=\"return Validate(this.form,0);\"></TD>\n");
	echo("  </TR>\n");
	echo("</TABLE>\n");
	echo("</FORM>\n");
	echo("</BODY>\n");
	echo("</HTML>\n");
       break;
}

?>
