<?php
ViewResponse::getInstance()->setMethodAjax();

$o_Wf_trx_documento_cabFN =  new Wf_trx_documento_cabFN();
$o_Resource = $o_Wf_trx_documento_cabFN->getConnect();

$ob_sfUser = myUser::getUser();
$s_UserId = $ob_sfUser->getUserId();

$s_Sql = "SELECT * FROM mnu_user WHERE user_id='{$s_UserId}'; ";
$o_SQLResult = mssql_query( $s_Sql, $o_Resource );
$o_SQLRow = mssql_fetch_object( $o_SQLResult );

$user_password = $o_SQLRow->user_password;
if( isset( $_POST['b_Control'] ) )
{
    $md5_pass = md5( $passAnt );
    if( $user_password == $md5_pass )
    {
        $md5_passNvo1 = md5( $passNvo1 );
        $s_Sql = "UPDATE mnu_user SET user_password='{$md5_passNvo1}' WHERE user_id='{$s_UserId}'; ";
        $o_SQLResult = mssql_query( $s_Sql, $o_Resource );
        if( $o_SQLResult )
        {
            ?>
            <script>
            parent.objMainTab.windowsCloseAll();
            </script>
            <?php
        }
    }
}

?>
<script>
function validarDatos()
{
    var s_Value0 = document.getElementById( 'passAnt' ).value;
    var s_Value1 = document.getElementById( 'passNvo1' ).value;
    var s_Value2 = document.getElementById( 'passNvo2' ).value;
    
    if( s_Value0 == "" )
    {
        alert( "Por favor ingrese el Password anterior." ); return false;
    }
    
    if( s_Value1 == s_Value2 )
    {
        if( s_Value1.length > 5 && s_Value2.length > 5 ) 
        {
            document.getElementById( 'form1' ).submit();
        }
        else
        {
            alert( "Por favor ingrese el Password mayor a 5 caracteres." ); return false;
        }
    }
    else
    {
        alert( "El Password no es igual." ); return false;
    }
}
</script>


  <link rel="stylesheet" type="text/css" media="screen" href="/digitalizacion//web/css/main.css" />
  <link rel="stylesheet" type="text/css" media="screen" href="/digitalizacion//web/css/grid.css" />
  <link rel="stylesheet" type="text/css" media="screen" href="/digitalizacion//web/css/tab.css" />
  
  <link rel="stylesheet" href="/digitalizacion//web/css/jquery/themes/smoothness/jquery-ui.css">
  
  <link rel="stylesheet" href="/digitalizacion//web/css/jquery/autocomplete/jquery.autocomplete.css">
  
    <!--<script type="text/javascript" src="/web/js/jquery/jquery-1.7.2.js"></script>-->
    <!--<script type="text/javascript" src="/web/js/jquery/ui-1.8.18/jquery-ui-1.8.18.custom.js"></script>-->
    
    <script type="text/javascript" src="/digitalizacion//web/js/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="/digitalizacion//web/js/jquery/ui-1.10.3/jquery-ui.js"></script>
    
    <script type="text/javascript" src="/digitalizacion//web/js/jquery/autocomplete/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="/digitalizacion//web/js/jquery.validate.js"></script>
    
    <script type="text/javascript" src="/digitalizacion//web/js/jquery/ajax_upload/AjaxUpload.2.0.min.js"></script>
    
    <script type="text/javascript" src="/digitalizacion//web/js/index.js"></script>
    <script type="text/javascript" src="/digitalizacion//web/js/php.js"></script>

<form name="form1" id="form1" method="POST">
    <input type="hidden" name="b_Control" id="b_Control" value="ok"/>
    <table class="cuerpo" style="background: #E3E9E2" width="99%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td width="35%">&nbsp;</td>
            <td width="25%">
                <label>Contrase&ntilde;a Anerior</label>
            </td>
            <td><input type="password" name="passAnt" id="passAnt" class="text"></td>
        </tr>
        <tr><td colspan="3"><hr></td></tr>
        <tr>
            <td width="10%">&nbsp;</td>
            <td width="20%">
                <label>Nueva Contrase&ntilde;a</label>
            </td>
            <td><input type="password" name="passNvo1" id="passNvo1" class="text"></td>
        </tr>
        <tr>
            <td width="10%">&nbsp;</td>
            <td width="20%">
                <label>Respita la Contrase&ntilde;a</label>
            </td>
            <td><input type="password" name="passNvo2" id="passNvo2" class="text"></td>
        </tr>
        <tr><td colspan="3">&nbsp;</td></tr>
        <tr>
            <td colspan="3" align="center">
                <input type="button" value="Grabar" class="button" onclick="validarDatos()">
                <input type="button" value="Cancelar" class="button" onclick="parent.objMainTab.windowsCloseAll();">
            </td>
        </tr>
    </table>
</form>