<?php
/*
CRIADO POR: K88
DATA ULTIMA ALTERAÇÃO: 19/02/2018 10:30
OBS.: ATUALIZAÇÃO DE NOVA ESTRUTURA E REVISÃO
*/
include("configuracao.php");//confirma no banco de dados
include($DiretorioRaiz."seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página
header('Content-Type: text/html; charset=utf-8');
include($DiretorioRaiz."inclusos/funcoes.php");

//REDIRECIONA USUARIO CASO CAMPO ESTEJA VAZIO
if(isset($_SESSION['usuarioID']) == "" or isset($_SESSION['idfilial_usuario']) == "" or isset($_SESSION['cod_empresa']) == ""){
		echo"
		<script type=\"text/Javascript\">
		window.location = 'login.php';</script>";
		die;	
}

//echo $_SERVER[REQUEST_URI];

if($_SERVER['REQUEST_URI'] == "/listar_vendas.php"){
    $usascript = "nao";
}else{
    $usascript = "sim";
}

if($_SESSION['usuarioID'] == 49){
$CorTopo = "deeppink";
$CorTopoComplemento = "hotpink";    
}

if($_SESSION['usuarioID'] == 17){
$CorTopo = "deeppink";
$CorTopoComplemento = "hotpink";    
}


?>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>
            <?php echo $TituloSitema;?>
        </title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!--CSS PRINCIPAL-->
        
        <link href="<?php echo $DiretorioVirtual;?>bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>css/ionicons.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>css/jquery-ui.min.css" type="text/css" rel="stylesheet">
        <link href="<?php echo $DiretorioVirtual;?>dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>dist/css/skins/_all-skins.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>js/source/jquery.fancybox.css?v=2.1.5" media="screen" rel="stylesheet" type="text/css">
        <link href="<?php echo $DiretorioVirtual;?>js/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" rel="stylesheet" type="text/css">
        <link href="<?php echo $DiretorioVirtual;?>js/source/helpers/jquery.fancybox-thumbs.css?v=1.0.7" rel="stylesheet" type="text/css">
        <link href="<?php echo $DiretorioVirtual;?>css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>css/buttons.dataTables.min.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="<?php echo $DiretorioVirtual;?>css/bootstrap-select.min.css" />   
        <link href="<?php echo $DiretorioVirtual;?>inclusos/folhaestilo.css" rel="stylesheet">                                            
                       
        
        <link href="<?php echo $DiretorioVirtual;?>/antigo/inclusos/styles.css" rel="stylesheet">
        <link href="<?php echo $DiretorioVirtual;?>/antigo/inclusos/css_precopratico.css" rel="stylesheet" type="text/css">         
        <link href="<?php echo $DiretorioVirtual;?>plugins/morris/morris.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>plugins/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $DiretorioVirtual;?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="<?php echo $DiretorioVirtual;?>/js/chosen1.8/chosen.css">
        
       
        <style type="text/css">
            .fancybox-custom .fancybox-skin {
                box-shadow: 0 0 50px #222;
            }
            
            .fancybox-wrap {
                top: 80;
            }
            
            .fancybox-iframe{
            overflow: hidden;
            }              
            
            @media print {
                .header {
                    display: none;
                }
                .footer {
                    display: none;
                }
                .menu {
                    display: none;
                }
                .sidebar {
                    display: none;
                }
                .main-footer {
                    display: none;
                }
				
				.noprint { display:none; } 
                    body { background: #fff; }
            }
            
            body {
                overflow: hidden;
            }
            /* Preloader */
            
            #preloader {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-color: #fff;
                z-index: 99;
            }
            
            #status_preload {
                width: 200px;
                height: 200px;
                position: absolute;
                left: 50%;
                top: 50%;
                background-image: url('<?php echo $DiretorioVirtual;?>img/status.gif');
                /* path to your loading animation */
                background-repeat: no-repeat;
                background-position: center;
                margin: -100px 0 0 -100px;
            }
			
            /*MODIFICAÇÃO MENU TOPO*/
            
            .content-wrapper {
                margin-left: 0px;
                padding-top: 45px;
            }
            
            form {
                /*padding-top:45px;*/
            }
        </style>

<!--DESABILITADO -->
	
<!--<script src="<?php //echo $DiretorioVirtual;?>js/funcoes.js" type="text/javascript"></script>-->
<!--<script src="<?php //echo $DiretorioVirtual;?>js/bootstrap-select.min.js"></script>--	
        <!-- JS PRINCIPAL -->
		<script src="<?php echo $DiretorioVirtual;?>inclusos/script.js"></script>	
        <script src="<?php echo $DiretorioVirtual;?>plugins/jQuery/jQuery-2.1.3.min.js" type="text/javascript"></script>        
        <script src="<?php echo $DiretorioVirtual;?>js/jquery-ui.min.js" type="text/javascript"></script>        
        <script src="<?php echo $DiretorioVirtual;?>js/source/jquery.fancybox.js?v=2.1.5" type="text/javascript"></script>
        <script src="<?php echo $DiretorioVirtual;?>js/source/helpers/jquery.fancybox-buttons.js?v=1.0.5" type="text/javascript"></script>
		<script src="<?php echo $DiretorioVirtual;?>js/source/helpers/jquery.fancybox-thumbs.js?v=1.0.7" type="text/javascript"></script>
        <script src="<?php echo $DiretorioVirtual;?>js/source/helpers/jquery.fancybox-media.js?v=1.0.6" type="text/javascript"></script>        
        <script src="<?php echo $DiretorioVirtual;?>bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
		<script src="<?php echo $DiretorioVirtual;?>plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
		<script src="<?php echo $DiretorioVirtual;?>plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
		<script src="<?php echo $DiretorioVirtual;?>js/jquery.dataTables.min.js" type="text/javascript"></script>
        <script src="<?php echo $DiretorioVirtual;?>js/dataTables.buttons.min.js" type="text/javascript"></script>
		<script src="<?php echo $DiretorioVirtual;?>plugins/slimScroll/jquery.slimscroll.min.js" type="text/javascript"></script>
        <script src='<?php echo $DiretorioVirtual;?>plugins/fastclick/fastclick.min.js'></script>
        <script src="<?php echo $DiretorioVirtual;?>plugins/chartjs/Chart.min.js" type="text/javascript"></script>
		<script src="<?php echo $DiretorioVirtual;?>dist/js/app.min.js" type="text/javascript"></script>
        <script src="<?php echo $DiretorioVirtual;?>dist/js/demo.js" type="text/javascript"></script>  	
		<link rel="stylesheet" href="<?php echo $DiretorioVirtual;?>/js/chosen1.8/chosen.css">
		
		<!--
        
              
       
        <!-- JS OPCIONAIS -->
        <?php if($usascript == "sim"){ ?> 
        
        <script src="<?php //echo $DiretorioVirtual;?>js/buttons.flash.min.js" type="text/javascript"></script>
        <script src="<?php //echo $DiretorioVirtual;?>js/jszip.min.js" type="text/javascript"></script>
        <script src="<?php //echo $DiretorioVirtual;?>js/pdfmake.min.js" type="text/javascript"></script>
        <script src="<?php //echo $DiretorioVirtual;?>js/vfs_fonts.js" type="text/javascript"></script>
        <script src="<?php //echo $DiretorioVirtual;?>js/buttons.html5.min.js" type="text/javascript"></script>
        <script src="<?php //echo $DiretorioVirtual;?>js/buttons.print.min.js" type="text/javascript"></script>        
        <script src="<?php //echo $DiretorioVirtual;?>js/jquery.mascara.js"></script> 
        <script src="<?php //echo $DiretorioVirtual;?>js/jquery.maskMoney.js" type="text/javascript"></script> 
        
          
        <?php }?>
                
        <script type="text/javascript">
            //FANCYBOX
            $(document).ready(function() {

                $('.fancybox').fancybox({
					
                    width       : '90%',
                    height      : '90%',
					fitToView   : true,
					autoSize    : true,
					autoScale   : true,
					//closeClick  : true,
					openEffect  : 'fade',
					closeEffect : 'fade',
					scrolling   : 'no',
					padding     : 10,					
					
                    afterClose: function() {
                        window.location.reload();
                    }
										
					
                });
            });

            //PRELOAD
            $(window).on('load', function() { // makes sure the whole site is loaded 
                $('#status_preload').fadeOut(); // will first fade out the loading animation 
                $('#preloader').delay(350).fadeOut('slow'); // will fade out the white DIV that covers the website. 
                $('body').delay(350).css({
                    'overflow': 'visible'
                });
            })
        </script>

    </head>

    <body class="skin-red" style="margin-left: 0px">
        <!-- Preloader -->
        <div id="preloader">
            <div id="status_preload">&nbsp;</div>
        </div>
        <header class="main-header">
            <!-- Logo -->
            <a href="<?php echo $DiretorioVirtual;?>index.php" class="logo" style="background-color: <?php echo $CorTopo;?>"><b><?php echo $NomeEmpresa;?></b></a>
            <!-- Header Navbar: style can be found in header.less -->
            <nav class="navbar navbar-static-top" role="navigation" style="background-color: <?php echo $CorTopoComplemento;?>">
                <!-- Sidebar toggle button-->
                <!-- Navbar Right Menu -->
                <div class="navbar-custom-menu">
                    <ul class="nav navbar-nav">
                        <!-- Messages: style can be found in dropdown.less-->
                <?php
                //SELECIONA MENSAGENS
                $SelecionMensagens = Seleciona("mensagens", "WHERE destino='".$_SESSION['usuarioID']."' AND lida IS NULL AND idfilial='".$_SESSION['idfilial_usuario']."' AND cod_empresa='".$_SESSION['cod_empresa']."'", "ORDER BY data DESC");
                $TotalMensagem = mysql_num_rows($SelecionMensagens);
                ?>
                <li class="dropdown messages-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-envelope-o"></i>
                        <span class="label label-success"><?php echo $TotalMensagem;?></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">Você tem
                            <?php echo $TotalMensagem;?> mensagens</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <ul class="menu">
                                <?php
                while($linha_mensagens = mysql_fetch_array($SelecionMensagens)){
                ?>
                                    <li>
                                        <!-- start message -->
                                        <a class="fancybox fancybox.iframe" href="<?php //echo $DiretorioVirtual;?>detalhe_mensagem_lytebox.php?idmensagem=<?php echo $linha_mensagens['idmensagem'];?>&lida=nao">
                                            <div class="pull-left">
                                                <img src="<?php echo $DiretorioVirtual;?>img/icone_mensagem.png" class="img-circle" alt="Mensagem">
                                            </div>
                                            <h4>
                                                <?php echo LoginUsuario($linha_mensagens['origem']);?>
                                                <small><i class="fa fa-clock-o"></i> <?php echo InverteDataNovoSeparador($linha_mensagens['data'], "-", "/") . " às " . $linha_mensagens['hora'];?></small>
                                            </h4>
                                            <p>
                                                <?php echo $linha_mensagens['assunto'];?>
                                            </p>
                                        </a>
                                    </li>
                                    <?php }?>
                                    <!-- end message -->
                            </ul>
                        </li>
                        <li class="footer"><a href="<?php echo $DiretorioVirtual;?>listar_mensagens.php">Ver todas as mensagens</a></li>
                    </ul>
                </li>
                <?php
                //SELECIONA AVISOS
                $SelecionAvisos = Seleciona("avisos", "WHERE idusuario='".$_SESSION['usuarioID']."' AND status='Aberto' AND idfilial='".$_SESSION['idfilial_usuario']."'", "ORDER BY idaviso DESC");
                $TotalAvisos = mysql_num_rows($SelecionAvisos);
                ?>
                <li class="dropdown messages-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-bell" aria-hidden="true"></i>
                        <span class="label label-success"><?php echo $TotalAvisos;?></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">Você tem
                            <?php echo $TotalAvisos;?> avisos</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <ul class="menu">
                                <?php
                while($linha_avisos = mysql_fetch_array($SelecionAvisos)){
                ?>
                                    <li>
                                        <!-- start message -->
                                        <a class="fancybox fancybox.iframe" href="<?php echo $DiretorioVirtual;?>detalhe_aviso_lytebox.php?idaviso=<?php echo $linha_avisos['idaviso'];?>&lida=nao">
                                            <div class="pull-left">
                                                <img src="<?php echo $DiretorioVirtual;?>img/icone_avisos.png" class="img-circle" alt="Aviso">
                                            </div>
                                            <h4>
                                                <?php echo LoginUsuario($linha_avisos['usuario_cadastro']);?>
                                                <small><i class="fa fa-clock-o"></i> <?php echo $linha_avisos['datacadastro'];?></small>
                                            </h4>
                                            <p>
                                                <?php echo $linha_avisos['titulo'];?>
                                            </p>
                                        </a>
                                    </li>
                                    <?php }?>
                                    <!-- end message -->
                            </ul>
                        </li>
                        <li class="footer"><a href="<?php echo $DiretorioVirtual;?>listar_avisos.php">Ver todos os avisos</a></li>
                    </ul>
                </li>                            
                            
                            
					<?php
                    $img_cliente = "arquivos/uploads/".RetornaColaborador($_SESSION['usuarioID'], "imagem");
                    
                    if(RetornaColaborador($_SESSION['usuarioID'], "imagem") == ""){
                        $capa_usuario = "img/semimagem.jpg";
                    }else{
                        $capa_usuario = $img_cliente;
                    }
                    ?>                            
                            <li class="dropdown user user-menu">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                  <img src="<?php echo $DiretorioVirtual . $capa_usuario;?>" class="user-image"/>
                  <span class="hidden-xs"><?php echo LoginUsuario($_SESSION['usuarioID']);?></span>
                </a>
                                <ul class="dropdown-menu">
                                    <!-- User image -->
                                    <li class="user-header">
                                        <img src="<?php echo $DiretorioVirtual . $capa_usuario;?>" class="img-circle" alt="<?php echo LoginUsuario($_SESSION['usuarioID']);?>" />
                                        <p>
                                            <?php echo $_SESSION['usuarioNome'];?>
                                        </p>
                                    </li>
                                    <!-- Menu Footer-->
                                    <li class="user-footer">
                                        <div class="pull-left">
                                            <!--<a href="#" class="btn btn-default btn-flat">Meus Dados</a>-->
                                        </div>
                                        <div class="pull-right">
                                            <a href="<?php echo $DiretorioVirtual;?>login.php?logoff=sim" class="btn btn-default btn-flat">Sair</a>
                                        </div>
                                    </li>
                                </ul>
                            </li>
                    </ul>
                </div>
            </nav>
        </header>