<?php
$filename = 'c_leitura.php';

if (!file_exists($filename)) {
    header("Location: error.php");
    exit;
}
include 'c_leitura.php';
?>
<?php
session_start();
error_reporting(0);
?>

<!DOCTYPE html>
<html>

    <head>

        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>Gerenciamento de Tablet</title>

        <!-- Core CSS - Include with every page -->
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="font-awesome/css/font-awesome.css" rel="stylesheet">

        <!-- Page-Level Plugin CSS - Blank -->

        <!-- SB Admin CSS - Include with every page -->
        <link href="css/sb-admin.css" rel="stylesheet">

    </head>

    <body>

        <?php
        $nivel_necessario = 6;

// Verifica se não há a variável da sessão que identifica o usuário
        if (!isset($_SESSION['UsuarioID']) OR ( $_SESSION['UsuarioNivel'] > $nivel_necessario)) {
// Destrói a sessão por segurança
            session_destroy();
// Redireciona o visitante de volta pro login
            header("Location: index.php");
            exit;
        }

        require_once("db.php");
        ?>
        <div id="wrapper">

            <nav class="navbar navbar-default navbar-fixed-top" role="navigation" style="margin-bottom: 0">
                <?php include 'header.php'; ?>
                <?php include 'navbar.php'; ?>
            </nav>

            <div id="page-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">Alterar Senha</h1>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
                <?php
                if (!empty($_GET['msg'])) {
                  
                    if ($_GET['msg'] == 1) {
                    echo "<div class='alert alert-success alert-dismissable'>";
                    echo "<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>";
                    echo "Senha alterada com sucesso! </div>";
                    }

                    if ($_GET['msg'] == 2) {
                    echo "<div class='alert alert-danger alert-dismissable'>";
                    echo "<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>";
                    echo "Senha atual está incorreta! </div>";
                    }

                    if ($_GET['msg'] == 3) {
                    echo "<div class='alert alert-danger alert-dismissable'>";
                    echo "<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>";
                    echo "As senhas não conferem! </div>";
                    }
                }
                ?>

                    <div class="row">
                        <div class="col-lg-2 center-block">

                        </div>
                        <div class="col-lg-8 center-block">
                            <form role="form" action="newpassword.php" method="POST">
                                <div class="panel panel-default ">
                                    <div class="panel-heading">
                                        Preencha abaixo os campos para alteração de senha
                                    </div>

                                    <div class="panel-body">

                                     <div class="form-group input-group">
                                            <span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
                                            <input type="password" class="form-control" name="atual" placeholder="Senha Atual" required >
                                        </div>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
                                            <input type="password" class="form-control" name="pass" placeholder="Nova Senha" required >
                                        </div>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
                                            <input type="password" class="form-control"  name="pass2" placeholder="Confirmar Senha" required>
                                        </div>
                                        <div class="pull-right">

                                            <button type='submit' class='btn btn-primary'>Salvar</button>
                                            </form>

                                        </div>
                                    </div>

                                </div>



                        </div>
                    </div>
                </div>
            </div>

              
                <!-- Core Scripts - Include with every page -->
                <script src="js/jquery-1.10.2.js"></script>
                <script src="js/bootstrap.min.js"></script>
                <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>

                <!-- Page-Level Plugin Scripts - Blank -->
                <link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
                <script src="js/plugins/dataTables/jquery.dataTables.js"></script>
                <script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
                <!-- SB Admin Scripts - Include with every page -->
                <script src="js/sb-admin.js"></script>

                <!-- Page-Level Demo Scripts - Blank - Use for reference -->
                <script>
                    $(document).ready(function() {
                        $('#dataTables-example').dataTable();
                    });
                </script>
                </body>

                </html>
