Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/07/2006, 10:38
Avatar de seik!
seik!
 
Fecha de Ingreso: mayo-2006
Mensajes: 492
Antigüedad: 17 años, 10 meses
Puntos: 6
segunda parte

Código PHP:

<?php                                 
                        
                $strsql 
"SELECT num_oficio FROM oficio";
                
$result select_data($strsql, &$fil, &$col);
                
$row=mysql_fetch_array($result);
                
$consulta $row["num_oficio"];
?>
<html>
<head>
    <script language="JavaScript">
        function esDigito(sChr){
            var sCod = sChr.charCodeAt(0);
            return ((sCod > 47) && (sCod < 58));
        }

        function valSep(oTxt){
            var bOk = false;
            bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
            bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
            return bOk;
        }
        
        function finMes(oTxt){
            var nMes = parseInt(oTxt.value.substr(3, 2), 10);
            var nRes = 0;
            
            switch (nMes){
                case 1: nRes = 31; break;
                case 2: nRes = 29; break;
                case 3: nRes = 31; break;
                case 4: nRes = 30; break;
                case 5: nRes = 31; break;
                case 6: nRes = 30; break;
                case 7: nRes = 31; break;
                case 8: nRes = 31; break;
                case 9: nRes = 30; break;
                case 10: nRes = 31; break;
                case 11: nRes = 30; break;
                case 12: nRes = 31; break;
            }
            
            return nRes;
        }
        
        
        function valDia(oTxt){
            var bOk = false;
            var nDia = parseInt(oTxt.value.substr(0, 2), 10);
            bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
            return bOk;    
        }


        function valMes(oTxt){
            var bOk = false;
            var nMes = parseInt(oTxt.value.substr(3, 2), 10);
            bOk = bOk || ((nMes >= 1) && (nMes <= 12));
        return bOk;
        }
        
        function valAno(oTxt){
            var bOk = true;
            var nAno = oTxt.value.substr(6);
            bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
                if (bOk){
                    for (var i = 0; i < nAno.length; i++){
                        bOk = bOk && esDigito(nAno.charAt(i));
                    }
                }    
        
        return bOk;
        }    

        function valFecha(oTxt){
            var bOk = true;
            if (oTxt.value != ""){
            bOk = bOk && (valAno(oTxt));
            bOk = bOk && (valMes(oTxt));
            bOk = bOk && (valDia(oTxt));
            bOk = bOk && (valSep(oTxt));
                if (!bOk){
                    alert("Fecha inválida");
                    oTxt.value = "";
                    oTxt.focus();
                }
            }
        }
    </script>

    <!--valida espacios vacios-->
    <script languaje="javascript">
        function validar(form)
        {
            var error = "Por favor, antes de enviar el formulario,\ncomplete los siguientes campos:\n\n";
            var a = ""
            var plata2=document.form.num_oficio.value;
            var plata3=parseInt(plata2);
            var fecha_recepcion, fecha_oficio;
            
            if (form.num_oficio.value == "") { a += " - Nº de documento\n"; }
            if (form.nom_oficio.value == "") { a += " - Nombre de documento\n"; }
            if (form.ant_oficio.value == "") { a += " - Descrip documento ANT.\n"; }
            if (form.mat_oficio.value == "") { a += " - Descrip. documento MAT.\n"; }
            if (form.fecha_oficio.value == "") { a += " - Fecha del documento.\n"; }
            if (form.fecha_recepcion_oficio.value == "") { a += " - Fecha de Recepción.\n"; }
            if (form.selorganismo.value == "") { a += " - Organismo Regulador\n"; }
            if (form.seltipo_oficio.value == "") { a += " - Tipo documento.\n"; }
            if (form.archivo.value == "") { a += " - Adjuntar documento.\n"; }
            
            if (a != "") { alert(error + a); return true; }
            
            // VALIDACION DE FECHA MAYOR
            fecha_oficio = form.fecha_oficio.value;
            fecha_oficio = fecha_oficio.substring(6, 10) + fecha_oficio.substring(3, 5) + fecha_oficio.substring(0, 2);
            fecha_recepcion = form.fecha_recepcion_oficio.value;
            fecha_recepcion = fecha_recepcion.substring(6, 10) + fecha_recepcion.substring(3, 5) + fecha_recepcion.substring(0, 2);
            
            if (fecha_recepcion < fecha_oficio){
                alert('La fecha de recepción no puede ser mayor a la fecha de creacion del documento.');
                form.fecha_recepcion_oficio.focus();
                return;
            }
            // ***********
            
            if(isNaN(plata3)){
                alert('" Nº de Oficio " debe ser un dato númerico');
                document.form.num_oficio.focus();return;
            }
            document.form.selestado_oficio.disabled=false;                
            document.form.cmdEnviar.disabled=true;
            document.form.cmdCancelar.disabled=true;
            document.form.cmdBorrar.disabled=true;                        
            form.submit()
        }
    </script>
    
<link href="../config.inc.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" leftmargin="0" class="ti_9_plomo">
<form method="POST" enctype="multipart/form-data" name="form" action="oficio_ag.php" ALIGN="top">
    <input type="hidden" name="evento_user" value="<?php print($_SESSION['user_sec'])?>">    
            <table width="510" border="0" cellpadding="0" cellspacing="2">
                <tr><td height="40" colspan="3" class="ti_14_blanco" style="font-size:20;" align="center" bgcolor="#333399">DETALLE NUEVO DOCUMENTO</td></tr>
                
                <tr><td height="20"></td>
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#ccffff">&nbsp;Nº de documento</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_12_negro"><input type="text" name="num_oficio" style="width:120;" class="text110"  maxlength="15"  size="10" ></td>
                </tr>
                <tr><td height="7"></td></tr>
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#ccffff">&nbsp;Nombre de documento</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_12_negro"><input type="text" name="nom_oficio" style="width:320;" size="20" class="text110"  maxlength="20" onChange="javascript:this.value=this.value.toLowerCase();"></td>
                </tr>
                <tr><td height="7"></td></tr>
                <tr>
                    <td height="25" width="180" class="ti_12_negro" valign="top" bgcolor="#ccffff">&nbsp;Descrip. documento ANT.</td>
                    <td width="10" class="ti_12_negro" align="center" valign="top">:</td>
                    <td width="320" class="ti_12_negro"><textarea name="ant_oficio" class="text110" style="width:320;" rows="3" onChange="javascript:this.value=this.value.toLowerCase();"></textarea></td>
                </tr>
                <tr><td height="7"></td></tr>
                <tr>
                    <td height="25" width="180" class="ti_12_negro" valign="top" bgcolor="#ccffff">&nbsp;Descrip. documento MAT.</td>
                    <td width="10" class="ti_12_negro" align="center" valign="top">:</td>
                    <td width="320" class="ti_12_negro"><textarea name="mat_oficio" class="text110" style="width:320;" rows="3" onChange="javascript:this.value=this.value.toLowerCase();"></textarea></td>
                </tr>
                <tr><td height="7"></td></tr>
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#ccffff">&nbsp;Fecha del documento</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_9_plomo"><input type="text" name="fecha_oficio" class="text110" maxlength="10" onblur="valFecha(this)"><font color="#C0C0C0">&nbsp;Ej: 31/12/2006</font></td>
                </tr>
                <tr><td height="7"></td></tr>
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#ccffff">&nbsp;Fecha de Recepción</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_9_plomo"><input type="text" name="fecha_recepcion_oficio" class="text110" maxlength="10" onblur="valFecha(this)"><font  color="#C0C0C0">&nbsp;Ej: 31/12/2006</font></td>
                </tr>
                <tr><td height="7"></td></tr>
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#ccffff">&nbsp;Estado documento</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_12_negro">
                        <select name="selestado_oficio" disabled>
                               <option value="Ingresado" selected>Ingresado</option> 
                           </select>
                    </td>
                </tr>                
                <tr><td height="7"></td></tr>                
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#CCFFFF">&nbsp;Organismo Regulador</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_12_negro">
                        <select name="selorganismo" >
                               <option value="sec">SEC</option> 
                               <option value="cne">CNE</option> 
                               <option value="cdec">CDEC</option> 
                        </select>
                        <input type="hidden" name="hidorganismo" value="<?php print($row["organismo"]);?>">
                        <script language="vbscript">
                            document.forms.form.selorganismo.value=document.forms.form.hidorganismo.value
                        </script>
                    </td>
                </tr>                
                <tr><td height="7"></td></tr>                
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#CCFFFF">&nbsp;Tipo Documento</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_12_negro">
                        <select name="seltipo_oficio">
                               <option value="Oficio Circular">Oficio Circular</option>
                            <option value="Resolución Exenta">Resolución Exenta</option>   
                               <option value="Cartas">Cartas</option>
                            <option value="Respuesta de Facturación">Respuesta de Facturación</option>
                        </select>
                        <input type="hidden" name="hidtipo_oficio" value="<?php print($row["tipo_oficio"]);?>">
                        <script language="vbscript">
                            document.forms.form.seltipo_oficio.value=document.forms.form.hidtipo_oficio.value
                        </script>
                    </td>
                </tr>
                <tr><td height="7"></td></tr>                        
                <tr>
                    <td height="25" width="150" class="ti_12_negro" bgcolor="#ccffff">Adjuntar documento&nbsp;</td>
                    <td width="10" class="ti_12_negro" align="center">:</td>
                    <td width="320" class="ti_12_negro"><input type="file"  name="archivo" size="20" ></td>
                </tr>                
                <tr><td height="25"></td></tr>    
                </table>
                <center>
                <input type="button" name="cmdEnviar" value="Enviar" class="button" onClick="validar(this.form)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" class="button" name="cmdCancelar" value="Cancelar" onclick="javascript:window.close();">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="reset" value="Borrar" class="button" name="cmdBorrar" >
                </center>
             </form>    

</center>
</body>
</html>
__________________
sEIK! -Chile-
Analista Programador.