<?php 

    include_once(__DIR__."/../config.php"); 

    $cs = new cs;
    if(!$cs->checkLog_unf()) { exit("<script>location='../login';</script>"); }
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" type="image/png" sizes="16x16" href="<?= SITE_PAINEL; ?>/plugins/images/favicon.png">
    <title>Elite Admin Template - The Ultimate Multipurpose admin template</title>
    <!-- Bootstrap Core CSS -->
    <link href="../public/assets/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="../plugins/bower_components/bootstrap-extension/css/bootstrap-extension.css" rel="stylesheet">
    <!-- Menu CSS -->
    <link href="../plugins/bower_components/sidebar-nav/dist/sidebar-nav.min.css" rel="stylesheet">
    <!-- toast CSS -->
    <link href="../plugins/bower_components/toast-master/css/jquery.toast.css" rel="stylesheet">
    <!-- morris CSS -->
    <link href="../plugins/bower_components/morrisjs/morris.css" rel="stylesheet">
    <!-- animation CSS -->
    <link href="../public/assets/css/animate.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="../public/assets/css/style.css" rel="stylesheet">
    <!-- color CSS -->
    <link href="../public/assets/css/colors/default-dark.css" id="theme" rel="stylesheet">
    <!-- dataTable CSS -->
    <!--  <link rel="stylesheet" href="<//?= BASE_URL; ?>/painel/plugins/bower_components/datatables/jquery.dataTables.min.css"> -->

    <!-- Editable CSS -->
    <link rel="stylesheet" href="../plugins/bower_components/jquery-datatables-editable/datatables.css">
    
    <!-- SELECT 2 --> 
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
    <!-- DATAPICKER --> 
    <link href="../plugins/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet">
    <!-- SWEETALERT --> 
    <link href="../plugins/bower_components/sweetalert/sweetalert.css">
    

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
    <!-- <script>
    (function(i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function() {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o), m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
    ga('create', 'UA-19175540-9', 'auto');
    ga('send', 'pageview');
    </script> -->
    
</head>
<?php    
    include_once(__DIR__."/../layout/header.php");
    include_once(__DIR__."/../layout/left-sidebar.php"); 
    include_once(__DIR__."/../layout/breadcrumbs.php");
?>
   
	    <!-- Page Content -->
	    <div id="page-wrapper">
	        <div class="container-fluid">
	            <div class="row bg-title">
	                <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
	                    <h4 class="page-title">Perfil</h4></div>
	                <div class="col-lg-9 col-sm-8 col-md-8 col-xs-12"> 
	                    <?php echo breadcrumbs(); ?>
	                </div>
	                <!-- /.col-lg-12 -->
	            </div>

				<div class="row">
				    <div class="col-md-12">
	                    <div class="white-box">	                        
	                        <div class="row">
                                   
	                            <div class="col-sm-12 col-xs-12">
                                    <h3 class="box-title">Alterar senha</h3>
	                                <form class="stdform" method="post" id="edit">
	                                	<input type="hidden" value="<?= $_SESSION['info_unf']['id']; ?>" name="id"> 
	                                	<div class="form-group">
	                                        <label for="senha_atual">Senha atual</label>
	                                        <div class="input-group">
	                                            <div class="input-group-addon"><i class="ti-lock"></i></div>
	                                            <input type="text" class="form-control"  id="senha_atual" name="senha_atual"> 
	                                        </div>
	                                    </div>

	                                    <div class="form-group">
	                                        <label for="nova_senha">Nova senha</label>
	                                        <div class="input-group">
	                                            <div class="input-group-addon"><i class="ti-lock"></i></div>
	                                            <input type="text" class="form-control"  id="nova_senha" name="nova_senha"> 
	                                        </div>
	                                    </div>

	                                    <div class="form-group">
	                                        <label for="senha_confirmacao">Confirme sua nova senha</label>
	                                        <div class="input-group">
	                                            <div class="input-group-addon"><i class="ti-lock"></i></div>
	                                            <input type="text" class="form-control"  id="senha_confirmacao" name="senha_confirmacao"> 
	                                        </div>
	                                    </div>

	                                    <div class="col-sm-6 col-xs-6 mx-auto alertmsg" >
				                            
		                                </div>
	                                    
	                                    <button type="submit" class="btn btn-success waves-effect waves-light m-r-10">Alterar senha</button>            
	                                </form>
	                            </div>
	                        </div>
	                    </div>
	                </div>
				</div>
	        <?php include_once(__DIR__.'/../layout/right-sidebar.php');?>
            </div>
            <!-- /.container-fluid -->
            <?php include_once(__DIR__.'/../layout/footer.php');?>
	    </div>
	    <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
    <!-- jQuery -->
    <script src="../plugins/bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="../public/assets/bootstrap/dist/js/tether.min.js"></script>
    <script src="../public/assets/bootstrap/dist/js/bootstrap.min.js"></script>
    
    <script src="../plugins/bower_components/bootstrap-extension/js/bootstrap-extension.min.js"></script>
    <!-- Menu Plugin JavaScript -->
    <script src="../plugins/bower_components/sidebar-nav/dist/sidebar-nav.min.js"></script>
    <!--slimscroll JavaScript -->
    <script src="../public/assets/js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="../public/assets/js/waves.js"></script>
    <!-- Custom Theme JavaScript -->
    <script src="../public/assets/js/custom.min.js"></script>

    <!-- jQuery Mask -->
    <script src="../plugins/bower_components/jquery-mask/dist/jquery.mask.min.js"></script>
    <!--Style Switcher -->
    <script src="../plugins/bower_components/styleswitcher/jQuery.style.switcher.js"></script>
    <!--Sweet Alert -->
    <script src="../plugins/bower_components/sweetalert/sweetalert.min.js"></script>
      
    <!--Functions Js -->
    <script src="../public/assets/js/functions.js"></script>
    
    <script>
    	jQuery.browser = {};
	        (function () {
	            jQuery.browser.msie = false
	            jQuery.browser.version = 0
	            if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
	                jQuery.browser.msie = true
	                jQuery.browser.version = RegExp.$1
	            }
	        })()

		$(document).ready(function () {
            
            //$(".alert").alert('close')
            
            $('#edit').submit( function(e) {
	            e.preventDefault()

	            let form   = $(this).serialize()
	            let action = 'ajax_edit.php'
	            $('.alertmsg').html('')
                updateUser(form, action)  
	            
	        }) // End Form Submit

	        function updateUser(form, action) {
           	    
                $('#alertMessage p').html('')
           	    $.post(action, form)
                    .done( (data) => {
                    
                    data = JSON.parse(data)
                  
                    $('.alertmsg')
                        .html(`<div id="alertMessage" class="alert ${data.class} alert-dismissable text-center">
                                <button type="button " class="close" data-dismiss="alert" aria-hidden="true">×</button><p>${data.text}</p> 
                            </div>`)

                })
	        }

	        
		})
		
    </script>

    
</body>

</html>