Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/06/2014, 16:15
MatiasFiermarin
 
Fecha de Ingreso: septiembre-2011
Mensajes: 35
Antigüedad: 13 años, 4 meses
Puntos: 0
Problema al ejecutar funciones

Tengo un problema, intente hacer un "buscar" de distintas formas para buscar datos y modificarlos. Aqui les dejo el codigo

Php Principal

Código:
<?php
	require_once("includes/FuncionesRegistro.php");

	$mensaje = "";
	if(isset($_POST['Modificar'])){
		$mensaje=Modificar_Registro();
		echo"<div id='nota-informativa'>".$mensaje."</div>";
	}
	if(isset($_POST['Eliminar'])){
		$mensaje=Eliminar_Registro();
		echo"<div id='nota-informativa'>".$mensaje."</div>";
	}
?>
<link rel="STYLESHEET" type="text/css" href="../css/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../css/dhtmlxform_dhx_skyblue.css">
<script  src="../script/datagrid/dhtmlxcommon.js"></script>
<script  src="../script/datagrid/dhtmlxgrid.js"></script>        
<script  src="../script/datagrid/dhtmlxgridcell.js"></script>  
<script src="../script/mensajes.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link href="css/estilos.css" rel="stylesheet" type="text/css">
<script src='../script/jquery.min.js'></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<body onLoad="IniciarGrid2()">
	<form id="form1" name="form1"method="post">
		<fieldset class="fieldset">
			<legend style="color: #999999; font-family: Tahoma;">
				<strong>
					Buscar
				</strong>
			</legend>
			<table width="402" border="0">
				<tr>
					<td width="215" height="146">
						<fieldset class="fieldset">
							<legend style="color: #999999; font-family: Tahoma;">
								<strong>
									Por Fecha
								</strong>
							</legend>
							<label for="fecha1" class="label">Fecha Inicio</label>
							<input type="date" name="fecha1" id="fecha1" class="textarea" size="20" maxlength="50" />
							<label for="fecha2" class="label">Fecha Fin</label>
							<input type="date" name="fecha2" id="fecha2" class="textarea" size="20" maxlength="50"/>
						</fieldset>
					</td>
					<td width="177">
						<fieldset class="fieldset">
							<legend style="color: #999999; font-family: Tahoma;">
								<strong>
									Por Letra
								</strong>
							</legend>
							<input type = "text" id = "coincidencia" />
						</fieldset>
						<fieldset class="fieldset">
							<legend style="color: #999999; font-family: Tahoma;">
								<strong>
									Por Sector	
								</strong>
							</legend>
							<select id = "categoriaB" >
								<option value = "Elegir...." >Elegir....</option>
								<option value = "Archivo&nbsp;PDF" >Archivo PDF</option>
								<option value = "Video" >Video</option>
								<option value = "Foto" >Foto</option>
								<option value = "Programa" >Programa ( .EXE )</option>
								<option value = "P&aacute;gina&nbsp;web" >P&aacute;gina web</option>
								<option value = "P&aacute;gina&nbsp;de&nbsp;peliculas" >P&aacute;gina de peliculas</option>
								<option value = "P&aacute;gina&nbsp;de&nbsp;videojuegos" >P&aacute;gina de videojuegos</option>
								<option value = "P&aacute;gina&nbsp;de&nbsp;musica" >P&aacute;gina de musica</option>
							</select>
						</fieldset>
					</td>
				</tr>
				<tr>
					<td height="146" colspan="2">
						<table>
							<td valign="top" width="350px" height="250px">
								<fieldset class="fieldset">
									<legend style="color: #999999; font-family: Tahoma;">
										<strong>
											Datos
										</strong>
									</legend>
									<input type="hidden" name="IdRegistro" id="IdRegistro"/>
									<div>
										<label for="cedula" class="label">
											<div align="left">Cedula </div>
										</label>
										<input type="text" name="cedula" id="cedula" class="textarea" readonly="readonly" required/>
									</div>
									<div>
										<label for="nombre" class="label">
											<div align="left">Nombre </div>
										</label>
										<input type="text" name="nombre" id="nombre" class="textarea" size="20" maxlength="50" readonly="readonly" required/>
									</div>
									<div>
										<label for="hora" class="label">
											<div align="left">Hora </div>
										</label>
										<input type="text" name="hora" id="hora" class="textarea" size="20" maxlength="25" readonly="readonly" required/>
									</div>
									<div>
										<label for="entrada" class="label">
											<div align="left">Entrada/Salida </div>
										</label>
										<input type="text" name="entrada" id="entrada" class="textarea" size="20" maxlength="25" required/>
									</div>
									<div>
										<label for="fecha" class="label">
											<div align="left">Fecha </div>
										</label>
										<input type="date" name="fecha" id="fecha" class="textarea" size="20" maxlength="50" readonly="readonly" required/>
									</div>
									<br>
									<div align="center">
										<div id="botones1" style="display:block;">
											<input name="Buscar" type="button" value="Buscar" onClick="Funcion()"/>
											<input name="Limpiar" type="button" value="Limpiar" onClick="window.location.reload()"/>
										</div>
										<div id="botones2" style="display:none;">
											<input name="Modificar" type="submit" value="Modificar"/>
											<input name="Eliminar" type="submit" value="Eliminar"/>
											<input name="Cancelar" type="submit" value="Cancelar" onClick="Ocultar()">
										</div>
									</div>	
								</fieldset>
							</td>
							<td valign="top" >
								<fieldset class="fieldset">
									<legend style="color: #999999; font-family: Tahoma;">
										<strong>
											Lista de Registros
										</strong>
									</legend>
									<div id="gridbox2" style="width:600px; height:250px; background-color:white;"></div>
								</fieldset>
							</td>
						</table>
					</td>
				</tr>
			</table>
	</fieldset>
	</form>
</body>

<script>
	function pregunta(){ 
		document.form1.entrada.value="";
		if (confirm('¿Estas seguro de enviar este formulario?')){ 
			document.tuformulario.submit() 
		} 
	} 
	
	function IniciarGrid2(){
		mygrid2 = new dhtmlXGridObject('gridbox2');
		mygrid2.setImagePath("../images/datagrid/");
		mygrid2.setHeader("Id,Cedula,Nombre,Hora,Entrada/Salida,Fecha");
		mygrid2.setInitWidths("0,100,150,130,100,130");
		mygrid2.attachEvent("onRowSelect", doOnRowSelected2);
		mygrid2.setMultiselect('off');
		mygrid2.init();
		mygrid2.setSkin("sbdark");
		this.ListarRegistros();
	}
	
	function doOnRowSelected2(cellInd) {
		document.form1.IdRegistro.value=mygrid2.cells2(mygrid2.getRowIndex(mygrid2.getSelectedId()),0).getValue();
		document.form1.cedula.value=mygrid2.cells2(mygrid2.getRowIndex(mygrid2.getSelectedId()),1).getValue(); 
		document.form1.nombre.value=mygrid2.cells2(mygrid2.getRowIndex(mygrid2.getSelectedId()),2).getValue(); 
		document.form1.hora.value=mygrid2.cells2(mygrid2.getRowIndex(mygrid2.getSelectedId()),3).getValue(); 
		document.form1.entrada.value=mygrid2.cells2(mygrid2.getRowIndex(mygrid2.getSelectedId()),4).getValue();
		document.form1.fecha.value=mygrid2.cells2(mygrid2.getRowIndex(mygrid2.getSelectedId()),5).getValue();
		document.getElementById('botones2').style.display='block';
		document.getElementById('botones1').style.display='none';
	}
	
	function Funcion(){
		if (ValidoFechas()) {
			$("#mensaje").html("");
			mygrid2.clearAll()
			var parametros = {
				"accion" : "1",
				"fechainicio" : this.fecha1.value,
				"fechafinal" : this.fecha2.value
			};
			$.ajax({
				data:  parametros,
				url:   '../includes/FuncionesRegistroAjax.php',
				type:  'post',
				
				success:  function (response) {
					var ordenes = eval(response);
					for (var i = 0; i <= ordenes.length; i++) { 
						mygrid2.addRow(mygrid2.uid(),[ordenes[i].Id,ordenes[i].cedula,ordenes[i].nombre,ordenes[i].hora,ordenes[i].entrada,ordenes[i].fecha],1);
					}
				}
			});
		}
	}
	
	function ValidoFechas(){
		if (this.fecha1.value=="") {
			$("#mensaje").html("Seleccione la Fecha Inicio");
			return false;
		}
		if (this.fecha2.value=="") {
			$("#mensaje").html("Seleccione la Fecha Final");
			return false;
		}else{
			return true;
		}
	}
	
	function ListarRegistros(){
		<?php 
            $listan=Seleccionar('excel','*','cedula!= "" ORDER BY hora ASC ');
            while($row=mysql_fetch_array($listan)){
        ?>
				var id="<?php echo($row['Id']);?>";
				var cedula="<?php echo($row['cedula']);?>";
				var nombre="<?php echo($row['nombre']);?>";
				var hora="<?php echo($row['hora']);?>";
				var entrada="<?php echo($row['entrada']);?>";
				var fecha="<?php echo($row['fecha']);?>";
				mygrid2.addRow(mygrid2.uid(),[id,cedula,nombre,hora,entrada,fecha], 1);
        <?php
            }
        ?>
	}
	
	function cargarTabla(){
			mygrid2.clearAll()
			var parametros = {
				"accion" : "1",
				"texto" : this.coincidencia.value
			};
			$.ajax({
				data:  parametros,
				url:   '../includes/buscarEmpleado.php',
				type:  'post',
				
				success:  function (response) {
					var ordenlistado = eval(response);
					for (var i = 0; i <= ordenlistado.length; i++) { 
						mygrid2.addRow(mygrid2.uid(),[ordenlistado[i].Id,ordenlistado[i].cedula,ordenlistado[i].nombre,ordenlistado[i].hora,ordenlistado[i].entrada,ordenlistado[i].fecha],1);
					}
				}
			});
	}
	
	$( "#coincidencia" ).keyup(function(){	
		cargarTabla();
	});
	
	function Ocultar(){ 
		document.form1.IdRegistro.value="";
		document.form1.cedula.value="";
		document.form1.nombre.value="";
		document.form1.hora.value="";
		document.form1.entrada.value="";
		document.form1.fecha.value="";
		document.getElementById('botones2').style.display='none';
		document.getElementById('botones1').style.display='';
	}
</script>