|
Directory : /home/zjabogados/public_html/genericas/ |
<?php
session_start();
$motorBD = $_SESSION['motorBD'];
$idusuario = $_SESSION['idusuario'];
require_once("../../Connections/$motorBD.php");
require_once("../Libs/classdata$motorBD.php");
require_once("../Libs/functionsquerys.php");
?>
<?php
//CARGO LAS VARIABLES QUE VIENEN DEL FORMULARIO
$tb = $_POST['tb'];
if ($tb == '') {
$tb = $_GET['tb'];
}
$nombre_real_campo = $_POST['nombre_real_campo'];
if ($nombre_real_campo == '') {
$nombre_real_campo = $_GET['nombre_real_campo'];
}
$nombrecampo = $_POST['nombrecampo'];
if ($nombrecampo == '') {
$nombrecampo = $_GET['nombrecampo'];
}
$origen = $_POST['origen'];
if ($origen == '') {
$origen = $_GET['origen'];
}
$form_paso = $_POST['form_paso'];
if ($form_paso == '') {
$form_paso = $_GET['form_paso'];
}
$form_idpermiso = $_POST['form_idpermiso'];
if ($form_idpermiso == '') {
$form_idpermiso = $_GET['form_idpermiso'];
}
$tb_origen_permiso = $_POST['tb_origen_permiso'];
if ($tb_origen_permiso == '') {
$tb_origen_permiso = $_GET['tb_origen_permiso'];
}
$restriccion_listar_where = $_POST['restriccion_listar_where'];
if ($tb == '') {
$tb = $_GET['tb'];
}
$MGMData_Restricciones_abm = RSrestriccionesABM($idusuario, $form_idpermiso, $tb_origen_permiso);
$restriccion_abm = '';
$restriccion_where = '';
if ($MGMData_Restricciones_abm->cant_rows > 0) {
$MGMData_Restricciones_abm->First();
$MGMData_Restricciones_abm->Next();
$ind_cant_restricciones_abm = 1;
while ($ind_cant_restricciones_abm <= $MGMData_Restricciones_abm->cant_rows) {
if (strtolower($MGMData_Restricciones_abm->row[0]) == strtolower($nombre_real_campo)) {
if ($MGMData_Restricciones_abm->row[1] <> '') {
$restriccion_abm = $MGMData_Restricciones_abm->row[1];
$restriccion_abm = "$restriccion_abm $idusuario";
}
if ($MGMData_Restricciones_abm->row[2] <> '') {
$restriccion_where = $MGMData_Restricciones_abm->row[2];
}
}
$MGMData_Restricciones_abm->Next();
$ind_cant_restricciones_abm++;
}
}
$MGMData_Restricciones_abm->Close();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Busqueda de<?php echo $nombrecampo; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function resultado_onclick(origen) {
//var list = document.window.form1.textfield;
//var valor = objeto.options[objeto.selectedIndex].value
//var list = window.forms[0].selectList
var valor_id = window.document.form1.pasar_id.value;
var valor_detalle = window.document.form1.pasar_detalle.value;
if (!opener.parent.document.form) {
if (opener.parent.document.form1) {
opener.parent.document.form1.<?php echo $nombre_real_campo; ?>.value = valor_id;
opener.parent.document.form1.detalle_<?php echo $nombre_real_campo; ?>.value = valor_detalle;
}
else {
opener.parent.rightFrame.document.form1.<?php echo $nombre_real_campo; ?>.value = valor_id;
opener.parent.rightFrame.document.form1.detalle_<?php echo $nombre_real_campo; ?>.value = valor_detalle;
}
}
else {
opener.parent.document.form.<?php echo $nombre_real_campo; ?>.value = valor_id;
opener.parent.document.form.detalle_<?php echo $nombre_real_campo; ?>.value = valor_detalle;
}
window.close();
}
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
var obj = MM_findObj(objName);
if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
if (theValue == true || theValue == false)
eval("obj."+theProp+"="+theValue);
else eval("obj."+theProp+"='"+theValue+"'");
}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function EnviarForm_fk(urldestino, target, tb, nombrecampo, nombre_real_campo, origen, form_idpermiso, tb_origen_permiso, seleccion) {
window.open(target+'.php','seleccion'+nombre_real_campo,'scrollbars=yes,resizable=yes,width=400,height=350');
eval("document.form_fk.action = '"+urldestino+"'");
eval("document.form_fk.target = 'seleccion"+nombre_real_campo+"'");
eval("document.form_fk.tb.value = '"+tb+"'");
eval("document.form_fk.nombrecampo.value = '"+nombrecampo+"'");
eval("document.form_fk.nombre_real_campo.value = '"+nombre_real_campo+"'");
eval("document.form_fk.origen.value = '"+origen+"'");
eval("document.form_fk.form_idpermiso.value = '"+form_idpermiso+"'");
eval("document.form_fk.tb_origen_permiso.value = '"+tb_origen_permiso+"'");
eval("document.form_fk.submit()");
}
</script>
<link href="../css/contenido.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="" method="post" name="form" id="form">
<table width="360" border="0" cellpadding="2" cellspacing="0">
<tr>
<td class="ColorEncabezadoGenerica">INGRESE CRITERIO DE BUSQUEDA</td>
</tr>
<?php
$MGMData_Indextb = RSIndexes($_SESSION['nombreBD'], $motorBD, $tb);
for ($ind_cant_camposIndex==1; $ind_cant_camposIndex<$MGMData_Indextb->cant_rows; $ind_cant_camposIndex++)
{
$MGMData_Indextb->Next();
$var_nombre = "";
?>
<tr>
<td class="ColorFondoTablaGenerica">
<?php
$etiquetadecampo = etiquetadecampo($MGMData_Indextb->row[0]);
echo "$etiquetadecampo: ";
$NombreCampo = explode("_",$MGMData_Indextb->row[0]);
if (($NombreCampo[0] == "tb" and ($motorBD == 'mysql' or $motorBD == 'postgresql')) or ($MGMData_Indextb->row[1] <> '' and $motorBD == 'mssql'))
{
CampoFK($motorBD, $MGMData_Indextb, $_SESSION['nombreBD'], $MGMData_Indextb->row[0], '', 0, '', 'busca', '', '', $restriccion_abm, $idusuario, $form_idpermiso, $tb, '');
}
else
{
?>
<input name="<?php echo $MGMData_Indextb->row[0]; ?>" type="text" id="criterio">
<?php } ?>
</td>
</tr>
<?php
}
?>
<tr>
<td class="ColorFondoTablaGenerica">
<input type="submit" name="Submit" value="Buscar" usemap="">
<input name="form_paso" type="hidden" id="form_paso" value="1">
<input name="tb_origen_permiso" type="hidden" id="tb_origen_permiso" value="<?php echo $tb_origen_permiso ?>">
<input name="form_idpermiso" type="hidden" id="form_idpermiso" value="<?php echo $form_idpermiso ?>">
<input name="restriccion_abm" type="hidden" id="restriccion_abm" value="<?php echo $restriccion_abm ?>">
<input name="restriccion_where" type="hidden" id="restriccion_where" value="<?php echo $restriccion_where ?>">
<input name="restriccion_listar_where" type="hidden" id="restriccion_listar_where" value="<?php echo $restriccion_listar_where ?>">
<input name="tb" type="hidden" value="<?php echo $tb ?>">
<input name="nombrecampo" type="hidden" value="<?php echo $nombrecampo ?>">
<input name="nombre_real_campo" type="hidden" value="<?php echo $nombre_real_campo ?>">
<input name="origen" type="hidden" value="<?php echo $origen ?>"></td>
</tr>
</table>
</form>
<form action="" method="post" name="form_fk" id="form_fk">
<input name="tb" type="hidden" value="">
<input name="nombrecampo" type="hidden" value="">
<input name="nombre_real_campo" type="hidden" value="">
<input name="origen" type="hidden" value="">
<input name="form_idpermiso" type="hidden" value="">
<input name="tb_origen_permiso" type="hidden" value="">
</form>
<?php
if ($form_paso == 1)
{
//CONSTRUYO LA SENTENCIA SQL
$MGMData_datostb = RSDatos($_SESSION['nombreBD'], $motorBD, $tb, 'index', 'buscar', 0, '', '', '', 0, 0, 0, '', '', $restriccion_abm, $id_usuario, $restriccion_where, $restriccion_listar_where, 'reducido');
?>
<form action="" method="post" name="form1" id="form1">
<table width="360" border="0" cellpadding="0" cellspacing="2">
<tr>
<td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="ColorEncabezadoGenerica"> </td>
<td class="ColorEncabezadoGenerica"> RESULTADO</td>
<td class="ColorEncabezadoGenerica"> </td>
<td> </td>
</tr>
</table> </td>
</tr>
<tr>
<td width="20" class="ColorEncabezadoGenerica"> </td>
<?php
$MGMData_Indextb->First();
for ($ind_cant_campotbIndex2=0; $ind_cant_campotbIndex2<$MGMData_Indextb->cant_rows; $ind_cant_campotbIndex2++)
{
$MGMData_Indextb->Next();
$var_nombre = "";
$NombreCampo=explode("_",$MGMData_Indextb->row[0]);
//INICIO MUESTRA EL CAMPO
?><td align="center" class="ColorEncabezadoGenerica"><b>
<?php
$etiquetadecampo = etiquetadecampo($MGMData_Indextb->row[0]);
echo $etiquetadecampo;
?>
</b></td>
<?php
// FIN MUESTRA EL CAMPO
}
?>
</tr>
<?php
for ($ind_cant_datostbIndex=0; $ind_cant_datostbIndex<$MGMData_datostb->cant_rows; $ind_cant_datostbIndex++) {
$MGMData_datostb->Next();
//VUELVO A CERO EL RESULT DE CAMPOS PARA TOMAR EL NOMBRE DEL ID
$MGMData_Indextb->First();
$MGMData_Indextb->Next();
?>
<tr>
<td width="20" class="ColorFondoTablaGenerica"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="radio" type="radio" id="radio3" onClick="MM_changeProp('pasar_detalle','','value',document.form1.detalle<?php echo $ind_cant_datostbIndex; ?>.value,'INPUT/TEXT');MM_changeProp('pasar_id','','value',document.form1.id<?php echo $ind_cant_datostbIndex; ?>.value,'INPUT/TEXT')">
<input name="id<?php echo $ind_cant_datostbIndex; ?>" type="hidden" id="id<?php echo $ind_cant_datostbIndex; ?>" value="<?php echo $MGMData_datostb->row[$MGMData_Indextb->row[0]]; ?>">
</font></td>
<?php
//VUELVO A CERO EL RESULT DE CAMPOS PARA MOSTRAR LOS VALORES EN LA TABLA
$valor_detalle_campo_id = "";
$MGMData_Indextb->First();
for ($ind_cant_campostbIndex3=0; $ind_cant_campostbIndex3<$MGMData_Indextb->cant_rows; $ind_cant_campostbIndex3++)
{
$MGMData_Indextb->Next();
if ($ind_cant_campostbIndex3 > 0) {
if ($ind_cant_campostbIndex3 == 1) {
$valor_detalle_campo_id = $MGMData_datostb->row[$MGMData_Indextb->row[0]];
}
else {
$valor_detalle_campo_id = $valor_detalle_campo_id.' - '.$MGMData_datostb->row[$MGMData_Indextb->row[0]];
}
}
//INICIO MUESTRA EL CAMPO
?>
<td class="ColorFondoTablaGenerica">
<?php
if ($MGMData_Indextb->row[3] == "date" or $MGMData_Indextb->row[3] == "datetime")
{
$val_fecha = $MGMData_datostb->row[$MGMData_Indextb->row[0]];
$fecha=explode("-",$val_fecha);
if ($tipodecampo == "datetime") {
$anio=explode(" ",$fecha[2]);
echo "$fecha[0]/$fecha[1]/$anio[0]";
}
else {
echo "$fecha[2]/$fecha[1]/$fecha[0]";
}
}
else
{
echo $MGMData_datostb->row[$MGMData_Indextb->row[0]];
}
if ($ind_cant_campostbIndex3 == $MGMData_Indextb->cant_rows-1) {
?>
<input name="detalle<?php echo $ind_cant_datostbIndex; ?>" type="hidden" id="detalle<?php echo $ind_cant_datostbIndex; ?>" value="<?php echo $valor_detalle_campo_id; ?>">
<?php
}
?>
</td>
<?php
// FIN MUESTRA EL CAMPO
}
?>
</tr>
<?php
}
?>
</table>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
</font></font>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="Submit2" type="button" onClick="resultado_onclick()" value="Seleccionar">
</font></font> <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="pasar_detalle" type="hidden" id="pasar_detalle" size="10">
<input name="pasar_id" type="hidden" id="pasar_id" size="10">
</font>
</form>
<?php
$MGMData_datostb->Close();
}
$MGMData_Indextb->Close();
?>
</body>
</html>