<?php
include("seguranca.php"); // Inclui o arquivo com o sistema de segurança  
protegePagina(); // Chama a função que protege a página 
?>
<?php
include "conexao.php";

$sql_consult = $sqli->query("SELECT * FROM usuarios WHERE id='".$_SESSION['ID_ADMIN']."'");
$row_consult = $sql_consult->fetch_assoc();

if($row_consult['limite_assinatura'] == '') {
    $limite_assinatura = "--";
}
else {
    $limite_assinatura = date('d/m/Y', strtotime($row_consult['limite_assinatura']));
}

?>
<!doctype html>
<html>
	<head>

		<!-- Basic -->
		<meta charset="UTF-8">

		<title>Portal dos Patrocinadores</title>
		<meta name="keywords" content="HTML5 Admin Template" />
		<meta name="description" content="Porto Admin - Responsive HTML5 Template">
		<meta name="author" content="okler.net">

		<!-- Mobile Metas -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

		<!-- Web Fonts  -->
		<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">

        <!-- Vendor CSS -->
        <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
        <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
        <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
        <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/datepicker3.css" />

        <!-- Specific Page Vendor CSS -->
        <link rel="stylesheet" href="assets/vendor/pnotify/pnotify.custom.css" />

        <!-- Theme CSS -->
        <link rel="stylesheet" href="assets/stylesheets/theme.css" />

        <!-- Skin CSS -->
        <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />

        <!-- Theme Custom CSS -->
        <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">

		<!-- Head Libs -->
		<script src="assets/vendor/modernizr/modernizr.js"></script>

	</head>
	<body>
		<section class="body">

			<!-- start: header -->
<?php
include 'topo.php';
?>
				<!-- end: sidebar -->






            <section role="main" class="content-body">
					<header class="page-header">
						<h2>Meus Dados</h2>
                        <div class="right-wrapper pull-right">
                        </div>
					</header>


                <div class="row">

                    <form action="atualizar_dados.php" class="mb-lg formvalidacao form-bordered" enctype="multipart/form-data" method="post" target="_self">


                        <section class="panel panel-featured panel-featured-warning" id="w5">
                            <header class="panel-heading head_combtn">
                                <div class="row">
                                    <div class="col-md-6">
                                        <h2 class="panel-title">Meus Dados</h2>
                                    </div>
                                </div>
                            </header>
                            <div class="panel-body">

                                <div class="form-group">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="control-label">Nome</label>
                                            <input name="nome" class="form-control" placeholder="Nome" value="<?php echo $row_consult['nome'] ?>" require="required">
                                        </div>
                                    </div>
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="control-label">Sobrenome</label>
                                            <input name="sobrenome" class="form-control" placeholder="Sobrenome" value="<?php echo $row_consult['sobrenome'] ?>" require="required">
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="control-label">E-mail</label>
                                            <input name="email" class="form-control" placeholder="E-mail" value="<?php echo $row_consult['email'] ?>" disabled>
                                        </div>
                                    </div>
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="control-label">Data Limite</label>
                                            <input name="limite_assinatura" class="form-control data" placeholder="Data Limite" disabled value="<?php echo $limite_assinatura ?>">
                                        </div>
                                    </div>
                                </div>

                            </div>
                            <div class="panel-footer">
                                <div class="row">
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 text-right">
                                        <button type="submit" class="mb-xs mt-xs mr-xs btn btn-success" title="Salvar"><i class="fa fa-check"></i> Salvar</button>
                                    </div>
                                </div>
                            </div>
                        </section>

                    </form>


                </div>





                <!-- end: page -->
				</section>
			</div>

		</section>




        <div id="popup-empresa" class="zoom-anim-dialog modal-header-color modal-block-full modal-block modal-full-color modal-block-warning mfp-hide">
                <section class="panel" style="background: #efefef;">
                    <header class="panel-heading">
                        <h2 class="panel-title" id="titulo-empresa"></h2>
                    </header>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-12" id="visu-empresa">

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









        <!-- Vendor -->
        <script src="assets/vendor/jquery/jquery.js"></script>
        <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
        <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
        <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
        <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
        <script src="assets/vendor/magnific-popup/magnific-popup.js"></script>
        <script src="assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>

        <!-- Specific Page Vendor -->
        <script src="assets/vendor/pnotify/pnotify.custom.js"></script>

        <!-- Theme Base, Components and Settings -->
        <script src="assets/javascripts/theme.js"></script>

        <!-- Theme Custom -->
        <script src="assets/javascripts/theme.custom.js"></script>

        <!-- Theme Initialization Files -->
        <script src="assets/javascripts/theme.init.js"></script>



        <script>
            let bars = document.querySelectorAll('.load-bar');
            console.log(bars);

            for(let i = 0; i <bars.length; i++){
                bars[i].style.animationDelay = `${i/15}s`;
            }


            $(document).on('click','.bt-empresa',function() {

                $('#visu-empresa').empty();
                $('#titulo-empresa').text($(this).data('nome'));
                $('#visu-empresa').load('ficha_empresa.php?id='+$(this).data('id'));

                $.magnificPopup.open({
                    items: {
                        type: 'inline',

                        fixedContentPos: false,
                        fixedBgPos: true,

                        overflowY: 'auto',

                        closeBtnInside: true,
                        preloader: false,

                        midClick: true,
                        removalDelay: 300,
                        mainClass: 'my-mfp-zoom-in',
                        modal: true,
                        src: '#popup-empresa'
                    }
                });

                var PluginToggle = function($el, opts) {
                    return this.initialize($el, opts);
                };

                PluginToggle.defaults = {
                    duration: 350,
                    isAccordion: false,
                    addIcons: true
                };
            });


            $(document).ready(function () {
                $('#loader').hide();

                $('.sidebar-right-toggle').magnificPopup({
                    type: 'inline',

                    fixedContentPos: false,
                    fixedBgPos: true,

                    overflowY: 'auto',

                    closeBtnInside: true,
                    preloader: false,

                    midClick: true,
                    removalDelay: 300,
                    mainClass: 'my-mfp-zoom-in',
                    modal: true
                });

                $(document).on('click', '.modal-dismiss', function (e) {
                    e.preventDefault();
                    $.magnificPopup.close();
                });



                $(window).scroll(function(){
                    var position = $(window).scrollTop();
                    var bottom = $(document).height() - $(window).height();
                    if( position == bottom ){
                        var row = Number($('#row').val());
                        var allcount = Number($('#todas_empresas').val());
                        var rowperpage = 21;
                        row = row + rowperpage;
                        if(row <= allcount){
                            $('#loader').show();
                            var url = "list_empresa.php";
                            $('#row').val(row);
                            $.ajax({
                                url: url,
                                type: 'post',
                                data: {
                                    row: row,
                                    nome: '<?php echo $_POST['nome'] ?>',
                                    id_setor: '<?php echo $_POST['id_setor'] ?>',
                                    estado: '<?php echo $_POST['estado'] ?>',
                                    id_grupo: '<?php echo $_POST['id_grupo'] ?>',
                                    transparencia: '<?php echo $_POST['transparencia'] ?>',
                                    id_atividade: '<?php echo $_POST['id_atividade'] ?>',
                                    politica_patrocinio: '<?php echo $_POST['politica_patrocinio'] ?>',
                                    id_segmento: '<?php echo $_POST['id_segmento'] ?>',
                                    ordenacao: '<?php echo $_POST['ordenacao'] ?>'
                                },
                                success: function(response){
                                    $('#loader').hide();
                                    $(".empresas:last").after(response).show().fadeIn("slow");
                                }
                            });
                        }
                        else{
                            $('#loader').hide();
                        }
                    }
                });

            })

        </script>

		<!-- Examples -->


	</body>
</html>