<?php
if(!isset($_SESSION)) session_start();
include('clases/clase.conexion.php');
include('funciones/variables.php');
include('funciones/funciones.php');
$var = VarServer("MYSQLI");
$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
?>
<HTML>
<HEAD>
<TITLE>LISTADO DE DOCUMENTOS DE VENTA</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
td {
	font-family:Tahoma;
	font-size:11px;
	color:#727272;
}
a {
	text-decoration: underline;
	color:#727272;
}
a.1 {
	text-decoration: none;
	color: 000000;
}
.t11 {
	font-family: Tahoma;
	font-size: 11px;
	font-style: normal;
}
body  {margin:0px;padding:0px}
.style3 {font-size: 9px}
-->
</style>
<link rel="stylesheet" type="text/css" href="css/ajax_registro.css">
<link rel="stylesheet" type="text/css" href="forms/paginate1.css">
<link rel="stylesheet" type="text/css" href="css/paginate.css" />
<script language='javascript'>
function seleccionar(varIde, varDoc, varCli, varDir, varRut, varVen, varMon, varIde1, varDoc1, varCli1, varDir1, varRut1, varVen1, varMon1) {
	var varIde2 = opener.document.getElementById(varIde1);
	var varDoc2 = opener.document.getElementById(varDoc1); 
	var varCli2 = opener.document.getElementById(varCli1);
	var varDir2 = opener.document.getElementById(varDir1);
	var varRut2 = opener.document.getElementById(varRut1); 
	var varVen2 = opener.document.getElementById(varVen1);
	var varMon2 = opener.document.getElementById(varMon1);
	var existe="NO";
	var form = opener.document.getElementById('formAsignacion');
	for (i=0;i<form.elements.length;i++) {
		var Campo = form.elements[i].name;	
		if(Campo.indexOf("ide")==0 && form.elements[i].value==varIde) {
			existe="SI";	
			}		
		}
	if (existe=="SI") {
		varText = "\nIde Venta :\t"+varIde;
		varText = varText + "\nDocumento :\t"+varDoc;
		varText = varText + "\nCliente :\t\t"+varCli;
		varText = varText + "\nDireccion :\t"+varDir;
		varText = varText + "\nRuta :\t\t"+varRut;
		varText = varText + "\nVendedor :\t"+varVen;
		alert("LA VENTA YA ESTA AGREGADA, SELECCIONE OTRO POR FAVOR"+varText);
		}
	else {
		varIde2.value = varIde;
		varDoc2.value = varDoc; 
		varCli2.value = varCli;
		varDir2.value = varDir;
		varRut2.value = varRut; 
		varVen2.value = varVen;
		varMon2.value = varMon;
		window.close();
		}
  	}
</script>
<script type="text/javascript" src="js/tablesort.js"></script>
<script type="text/javascript" src="js/paginate.js"></script>
<script type="text/javascript" src="js/popcalendar.js"> </script>
<script type="text/javascript" src="js/funciones.js"></script>
<script type="text/javascript" src="js/wz_tooltip.js"></script>
<script type="text/javascript" src="js/tip_balloon.js"></script>
<!--[if IE]>
<style type="text/css">
ul.fdtablePaginater {display:inline-block;}
ul.fdtablePaginater {display:inline;}
ul.fdtablePaginater li {float:left;}
ul.fdtablePaginater {text-align:center;}
table { border-bottom:1px solid #C1DAD7; }
</style>
<![endif]-->
<script type="text/javascript" src="stmenu.js"></script>
<meta http-equiv="msthemecompatible" content="no" />
<link href="images/logo_siscomges_32x32.png" rel="shortcut icon" type="image/x-icon" />
<meta http-equiv="msthemecompatible" content="no" />
<link href="images/logo_siscomges_32x32.png" rel="shortcut icon" type="image/x-icon" />
</HEAD>
<meta http-equiv="msthemecompatible" content="no" />
<link href="images/logo_siscomges_32x32.png" rel="shortcut icon" type="image/x-icon" />
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<table cellpadding="0" cellspacing="0" border="0" style="height:100%; width:100% ">
                            <!--DWLayoutTable-->
                            <tr>
                              
<td width="750" align="center" valign="top">
<?php 
	$varEst = array("AC"=>"ACTIVO", "PP"=>"PAGADO PARCIAL","CA"=>"CANCELADO","AN"=>"ANULADO");
	$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"450", "clase"=>"FormTitulo", "titulo"=>"BUSCAR DOCUMENTO DE VENTA",
					"formu"=>array("id"=>"form", "name"=>"form", "metodo"=>"POST"),						
					"ocult"=>array(array("tipo"=>"oculto", "id"=>"ide", "name"=>"ide", "valor"=>$_GET["ide"]),
								   array("tipo"=>"oculto", "id"=>"doc", "name"=>"doc", "valor"=>$_GET["doc"]),
								   array("tipo"=>"oculto", "id"=>"cli", "name"=>"cli", "valor"=>$_GET["cli"]),
								   array("tipo"=>"oculto", "id"=>"dir", "name"=>"dir", "valor"=>$_GET["dir"]),
								   array("tipo"=>"oculto", "id"=>"rut", "name"=>"rut", "valor"=>$_GET["rut"]),
								   array("tipo"=>"oculto", "id"=>"ven", "name"=>"ven", "valor"=>$_GET["ven"]),
								   array("tipo"=>"oculto", "id"=>"mon", "name"=>"mon", "valor"=>$_GET["mon"])
								  ),
					"conte"=>array(array("titulo"=>"Cliente :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"text", "id"=>"ccod", "name"=>"ccod", "valor"=>$_POST["ccod"],
																				 "ancho"=>"50", "alinear"=>"center", 
																				 "keypress"=>"return SoloEnteros(event)",
																				 "blur"=>"xajax_seleccionar_cliente(this.value)", 
																				 "dclick"=>"fn_cargar_listado_cliente('ccod', 'cnom')"),
																		   array("tipo"=>"text", "id"=>"cnom", "name"=>"cnom", "valor"=>$_POST["cnom"], 
																				 "ancho"=>"250", "clase"=>"inputDisable", "locked"=>"SI")
																		   )
														)
										 ),
								   array("titulo"=>"Vendedor :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"text", "id"=>"vcod", "name"=>"vcod", "valor"=>$_POST["vcod"],
																				 "ancho"=>"50", "alinear"=>"center", 
																				 "keypress"=>"return SoloEnteros(event)",
																				 "blur"=>"xajax_seleccionar_vendedor(this.value)", 
																				 "dclick"=>"fn_cargar_listado_vendedor('vcod', 'vnom')"),
																		   array("tipo"=>"text", "id"=>"vnom", "name"=>"vnom", "valor"=>$_POST["vnom"], 
																				 "ancho"=>"250", "clase"=>"inputDisable", "locked"=>"SI")
																		   )
														)
										 ),
								   array("titulo"=>"Ruta :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"text", "id"=>"rcod", "name"=>"rcod", "valor"=>$_POST["rcod"],
																				 "ancho"=>"50", "alinear"=>"center", 
																				 "keypress"=>"return SoloEnteros(event)",
																				 "blur"=>"xajax_seleccionar_ruta(this.value)", 
																				 "dclick"=>"fn_cargar_listado_ruta('rcod', 'rnom')"),
																		   array("tipo"=>"text", "id"=>"rnom", "name"=>"rnom", "valor"=>$_POST["rnom"], 
																				 "ancho"=>"250", "clase"=>"inputDisable", "locked"=>"SI")
																		   )
														)
										 ),
								   array("titulo"=>"Fecha Incial :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"fecha", "id"=>"fini", "name"=>"fini", "alinear"=>"center", 
																				 "valor"=>$_POST["fini"]))
														)
										 ),								  							  
								   array("titulo"=>"Fecha Final :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"fecha", "id"=>"ffin", "name"=>"ffin", "alinear"=>"center"))
														)
										 )
								   ),
				  "boton"=>array(array("tipo"=>"submit", "id"=>"bcon", "name"=>"bcon", "ancho"=>"100", "texto"=>"Buscar",
									   "clase"=>"boton_buscar", "click"=>"javascript:xBuscarJS()")
								 )
				);
	echo $obj->setTablaForm($varTabla);
	
	if (isset($_POST["bcon"])) {
		$varCli = (isset($_POST["ccod"]) && $_POST["ccod"]<>"")?$_POST["ccod"]:"NULL";
		$varVen = (isset($_POST["vcod"]) && $_POST["vcod"]<>"")?$_POST["vcod"]:"NULL";
		$varRut = (isset($_POST["rcod"]) && $_POST["rcod"]<>"")?"'".$_POST["rcod"]."'":"NULL";
		$varIni = (isset($_POST["fini"]) && $_POST["fini"]<>"")?"'".FechaMySql($_POST["fini"])."'":"NULL";
		$varFin = (isset($_POST["ffin"]) && $_POST["ffin"]<>"")?"'".FechaMySql($_POST["ffin"])."'":"NULL";
		$varIni = ($_POST["fini"]=="" && $_POST["ffin"]=="")?"'".date('Y-m-d')."'":$varIni;
		$sql = "call spQuery_Asignacion_Venta_Agregar($varCli, $varVen, $varRut, $varIni, $varFin, NULL, NULL);";
		$varTabla=array("id"=>"theTable", "name"=>"theTable", "tamano"=>"98%", "sql_cab"=>$sql,	"pages"=>20,
							"conte"=>array(array("titulo"=>"IDE",      "ancho"=>"40" , "alinear"=>"center"),
										   array("titulo"=>"FEMI",      "ancho"=>"40" , "alinear"=>"center"), 
										   array("titulo"=>"NDOC",      "ancho"=>"60" , "alinear"=>"center"),
										   array("titulo"=>"CLIENTE", "ancho"=>"300", "fijo"=>"SI"),
										   array("titulo"=>"DIRECCION", "ancho"=>"300", "fijo"=>"SI"),
										   array("titulo"=>"RUTA", "ancho"=>"300", "fijo"=>"SI"),
										   array("titulo"=>"VENDEDOR", "ancho"=>"300", "fijo"=>"SI"),
										   array("titulo"=>"MONTO",      "ancho"=>"40" , "alinear"=>"right")
										   ),
							"boton"=>array(array("tipo"=>"img", "id"=>"bbus", "name"=>"bbus", "img"=>"images/b_table_add.png", 
												 "toltip"=>array(array("valor"=>"HAGA CLICK PARA <b>SELECCIONAR</b> EL REGISTRO<br><b>"),
																	 array("valor"=>0, "tipo"=>"INDEX"),
																	 array("valor"=>" - "),
																	 array("valor"=>1, "tipo"=>"INDEX"),
																	 array("valor"=>"</b>")
																	),
												 "click"=>array("funcion"=>"seleccionar",
																"param"=>array(array("valor"=>0, "tipo"=>"INDEX"),
																			   array("valor"=>2, "tipo"=>"INDEX"),
																			   array("valor"=>3, "tipo"=>"INDEX"),														   
																			   array("valor"=>4, "tipo"=>"INDEX"),
																			   array("valor"=>5, "tipo"=>"INDEX"),
																			   array("valor"=>6, "tipo"=>"INDEX"),														   
																			   array("valor"=>7, "tipo"=>"INDEX"),
																			   array("valor"=>$_GET["ide"], "tipo"=>"TEXTO"),
																			   array("valor"=>$_GET["doc"], "tipo"=>"TEXTO"),
																			   array("valor"=>$_GET["cli"], "tipo"=>"TEXTO"),
																			   array("valor"=>$_GET["dir"], "tipo"=>"TEXTO"),
																			   array("valor"=>$_GET["rut"], "tipo"=>"TEXTO"),
																			   array("valor"=>$_GET["ven"], "tipo"=>"TEXTO"),
																			   array("valor"=>$_GET["mon"], "tipo"=>"TEXTO")
																			  )
																)
												 
												)
										)
							);
			echo $obj->SetGridTabla($varTabla);
		}
?>
</td>
	</tr>
  </table>


<!--  PopCalendar(tag name and id must match) Tags should not be enclosed in tags other than the html body tag. -->
<iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="HelloWorld/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;"> </iframe>
</body>
</html>
<frameset rows="100,*" border=0 frameborder="0">
<frameset rows="100,*" border=0 frameborder="0">