Código PHP:
<?
include_once("conexion.php");
mysql_select_db("seniat", $db) or die ("Fallo la seleccion de la Base de Datos");
function limpiarcampos(){
global $numfianza;
global $tipofianza;
global $rifaux;
global $rifaseg;
global $fecha;
global $fecharec;
global $fechae;
global $fechaexp;
global $fechav;
global $fechaven;
global $monto;
global $obs;
global $tipoaux;
global $nombreseg;
global $operacion;
$numfianza="";
$tipofianza="";
$rifaux="";
$rifaseg="";
$fecha="";
$fecharec="";
$fechae="";
$fechaexp="";
$fechav="";
$fechaven="";
$monto="";
$obs="";
$tipoaux="";
$nombreseg="";
$operacion="";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="js1/jscal2.js"> </script>
<script src="js1/lang/es.js"></script>
<link rel="stylesheet" type="text/css" href="css/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="css/steel/steel.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Control de Fianzas</title>
<script language="javascript" type="text/javascript">
function validarcampos()
{
var form=document.fianza;
if (form.nfianza.value=="")
{
alert("Debe llenar el numero de Fianza");
form.nfianza.focus()
return false;
}
var opc = form.tipofianza.selectedIndex;
if (opc == 0)
{
alert("Debe elegir un tipo de Fianza");
return false;
}
var opcionSeleccionada = form.tipoa.selectedIndex;
if (opcionSeleccionada == 0)
{
alert("Por favor, seleccione un tipo de auxiliar");
return false;
}
var opcion = form.rif_auxiliar.selectedIndex;
if (opcion== 0)
{
alert("Por favor, seleccione un auxiliar");
return false;
}
if(form.rifaseguradora.value=="")
{
alert("Falta Rif Aseguradora");
form.rifaseguradora.focus();
return false;
}
if(form.nombreseguro.value=="")
{
alert("Falta Nombre de Seguro");
form.nombreseguro.focus();
return false;
}
if(form.fechaexp.value=="")
{
alert("Falta Fecha de expedicion");
form.fechaexp.focus();
return false;
}
if(form.fecharecep.value=="")
{
alert("Falta Fecha de Recepcion");
form.fecharecep.focus();
return false;
}
if(form.fechavenc.value=="")
{
alert("Falta Fecha de Vencimiento");
form.fechavenc.focus();
return false;
}
if(form.monto.value=="")
{
alert("Falta el Monto de la Fianza");
form.monto.focus();
return false;
}
form.submit();
}
</script>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:854px;
height:433px;
z-index:1;
left: 208px;
top: 36px;
}
.Estilo1 {color: #000000}
-->
</style>
</head>
<body>
<?
$btnregistrar="disabled";
$btnactualizar="disabled";
$operacion="";
if(isset($_POST["txtoperacion"])){
$numfianza=$_POST["nfianza"];
$tipofianza=$_POST["tipofianza"];
$rifaux=$_POST["rif_auxiliar"];
$rifaseg=$_POST["rifaseguradora"];
$fechar=explode("/",$_POST["fecharecep"]);
$fecharec= $fechar[2]."-".$fechar[1]."-".$fechar[0];
$fechae=explode("/",$_POST["fechaexp"]);
$fechaexp= $fechae[2]."-".$fechae[1]."-".$fechae[0];
$fechav=explode("/",$_POST["fechavenc"]);
$fechaven= $fechav[2]."-".$fechav[1]."-".$fechav[0];
$monto=$_POST["monto"];
$obs=$_POST["obs"];
$tipoaux=$_POST["tipoa"];
$nombreseg=$_POST["nombreseguro"];
$operacion=$_POST["txtoperacion"];
if($operacion=="registrar"){
$query2="INSERT INTO
fianza(n_fianza,rif_auxiliar,rif_seguro,
fecha_recepcion,fecha_expedicion,fecha_vencimiento,
monto,observacion,
tipoauxiliar,nombreseguro)";
$query2.="values('$numfianza','$rifaux','$rifaseg',
'$fecharec','$fechaexp','$fechaven','$monto','$obs',
'$tipoaux','$nombreseg')";
$result= mysql_query($query2,$db) or die(mysql_error());
echo "<script type='text/javascript'>
alert('La Fianza ".$_POST["nfianza"]." Esta Registrada');
</script>";
limpiarcampos();
}
}
?>
<div id="Layer1">
<form action="fianza1.php" method="post" enctype="multipart/form-data" name="fianza" id="fianza">
<div>
<div align="center">
<p><strong>FIANZA</strong></p>
<p> </p>
</div>
</div>
<table width="815" border="0" align="center">
<tr>
<td width="153"><label></label>
<label><strong>Numero de Fianza</strong></label></td>
<td width="153">
<input type="text" name="nfianza" id="nfianza">
</td>
<td colspan="2"><strong>Tipo de Fianza</strong></td>
<td><label for="tipofianza"></label>
<select name="tipofianza" id="tipofianza">
<option> Seleccione tipo</option>
<?
$quer= mysql_query("Select * from tipofianza",$db);
while ($datos1=mysql_fetch_assoc($quer)){
echo '<option value="'.$datos1['idtipofianza'].'">'.$datos1['descripcion'].'</option>';
}
?>
</select></td>
</tr>
<tr>
<td><strong>Tipo de Contribuyente</strong> </td>
<td colspan="4"><label>
<select name="tipoa" id="tipoa" >
<option> Seleccione el Tipo </option>
<?
$query1= mysql_query("Select * from tipoauxiliar",$db);
while ($datos1=mysql_fetch_assoc($query1)){
echo '<option value="'.$datos1['idtipo'].'">'.$datos1['nombre'].'</option>';
}
?>
</select>
</label></td>
</tr>
<tr>
<td><strong>Contribuyente </strong></td>
<td colspan="4">
<select name="rif_auxiliar" id="rif_auxiliar">
<option> Seleccione un Contribuyente </option>
<?
$query = mysql_query("SELECT * FROM auxiliares",$db);
if (!query){
$message = "Invalido query".mysql_error();
$message .= "Query".$query;
die(message);
}
while ($datos = mysql_fetch_assoc($query)){
echo '<option value="'.$datos['rif_auxiliar'].'">'.$datos['nombre'].'</option>';
$combo= $_POST['rif_auxiliar'];
echo $combo;
}
?>
</select> </td>
</tr>
<tr>
<td><strong>Rif Aseguradora</strong></td>
<td colspan="2"><label>
<input name="rifaseguradora" type="text" id="rifaseguradora" size="20" />
</label>
<td><strong>Razón Social de Aseguradora</strong>
<td><label>
<input name="nombreseguro" id="nombreseguro" type="text" size="40" />
</label>
</tr>
<tr>
<td><strong>Fecha de Expedicion </strong></td>
<td colspan="2"><input name="fechaexp" type="text" id="fechaexp" size="15" readonly="readonly"/>
<input name="btnexp" type="button" value="..." id="btnexp" /> </td>
<script type="text/javascript">//<![CDATA[
var cal = Calendar.setup({
onClick: function(cal) { cal.hide() },
showTime: true
});
cal.manageFields("btnexp", "fechaexp", "%d/%m/%Y");
//]]></script>
<td width="122"><strong>Fecha de Vencimiento</strong> </td>
<td width="359">
<input name="fechavenc" type="text" id="fechavenc" size="15" readonly="readonly" />
<input name="btnven" type="button" id="btnven" value="..." />
<script type="text/javascript">//<![CDATA[
var cal = Calendar.setup({
onClick: function(cal) { cal.hide() },
showTime: true
});
cal.manageFields("btnven", "fechavenc", "%d/%m/%Y");
//]]></script>
</label></td>
</tr>
<tr>
<td><strong>Fecha de Recepcion </strong></td>
<td colspan="4">
<input name="fecharecep" type="text" id="fecharecep" size="15" readonly="readonly" />
<input type="button" name="btnrecep" value="..." id="btnrecep" />
<script type="text/javascript">//<![CDATA[
var cal = Calendar.setup({
onClick: function(cal) { cal.hide() },
showTime: true
});
cal.manageFields("btnrecep", "fecharecep", "%d/%m/%Y");
//]]></script>
</label></td>
</tr>
<tr>
<td><strong>Monto</strong></td>
<td colspan="4"><label>
<input type="text" name="monto" id="monto" />
</label></td>
</tr>
<tr>
<td><strong>Observacion</strong></td>
<td colspan="4"><label>
<input name="obs" type="text" id="obs" size="80" />
</label></td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<label>
<input name="registrar" type="button" value="Registrar" onclick="registrar()"/>
</label></td>
<td><label>
<input type="button" name="Actualizar" value="Actualizar"/>
</label></td>
<td><label>
<input type="reset" name="Submit3" value="Cancelar" />
</label></td>
</tr>
</table>
<p>
<input name="txtoperacion" type="hidden" id="txtoperacion" />
<br />
</p>
</form>
</div>
</body>
<script language="javascript">
function registrar()
{
form=document.fianza;
if (validarcampos())
{
form.txtoperacion.value="registrar";
form.submit();
}
}
</script>
</html>
[HIGHLIGHT="PHP"][/HIGHLIGHT]