<?PHP 
include_once('Modules/operadores_del_monitor/operadores_del_monitor.php');
include_once('Modules/operadores_moviles/operadores_moviles.php');
include_once('Modules/configuraciones/configuraciones.php');
$operador_monitor_id = trim($_SESSION['operador_sesion']['OperadorMonitorID']);

$operadores_del_monitor = new operador_monitor('');
$cantidad = $operadores_del_monitor->cantidadOperadores();

$operador_monitor_logueado = new operador_monitor('');
$operador_monitor = $operador_monitor_logueado->getOperadoresMonitorByID($_SESSION['operador_sesion']['OperadorMonitorID']);

$operadores_moviles_sin_lj = new operadores_moviles('');
$operadores_moviles_sin_lj_array = $operadores_moviles_sin_lj->GetOperadoresMovilesSinLJ(); 

$configuraciones = new configuraciones('');
//$configuraciones->checkBackUp();

$modulos_habilitados = new operador_monitor('');
$modulos_habilitados_array = $modulos_habilitados->getPermisosLectura($_SESSION['operador_sesion']['OperadorMonitorID']);

$configuraciones = new configuraciones('');
$razon_social = $configuraciones->GetConfiguraciones('RazonSocial');

if ($cantidad > 0)
{
	if (!isset($_SESSION['operador_sesion']['NombreUsuario']))
		header ('Location: login.php');
	
	//$configuraciones->checkBackUp();
}
else
{
	header ('Location: configuracion_inicial.php');
}	
?>
<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="shortcut icon" href="../Web_Tools/images/favicon.png" type="image/png">

  <title>Monitor Web 3.0</title>

  <link href="../Web_Tools/css/style.default.css" rel="stylesheet">
  <link href="../Web_Tools/css/jquery.datatables.css" rel="stylesheet">
  <link href="../Web_Tools/css/TableTools.css" rel="stylesheet">  
  <link href="../Web_Tools/css/jquery.gritter.css" rel="stylesheet">
   

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if
  
   lt IE 9]>
  <script src="js/html5shiv.js"></script>
  <script src="js/respond.min.js"></script>
  <![endif]-->
    <!--<script src="../Web_Tools/js/jquery-1.10.2.min.js"></script>-->
	<script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
	<script src="../Web_Tools/js/jquery-1.10.2.min.js"></script>
    <script src="../Web_Tools/js/jquery-migrate-1.2.1.min.js"></script>
    <script src="../Web_Tools/js/jquery-ui-1.10.3.min.js"></script>
    <script src="../Web_Tools/js/bootstrap.min.js"></script>
    <script src="../Web_Tools/js/bootbox.min.js"></script>
    <script src="../Web_Tools/js/modernizr.min.js"></script>
    <script src="../Web_Tools/js/jquery.sparkline.min.js"></script>
    <script src="../Web_Tools/js/toggles.min.js"></script>
    <script src="../Web_Tools/js/retina.min.js"></script>
    <script src="../Web_Tools/js/jquery.cookies.js"></script>
    
    <script src="../Web_Tools/js/bootstrap-timepicker.min.js"></script>
    <script src="../Web_Tools/js/jquery.validate.min.js"></script>
    <script src="../Web_Tools/js/jquery.datatables.min.js"></script>
	<script src="../Web_Tools/js/TableTools.min.js"></script>
    <script src="../Web_Tools/js/chosen.jquery.min.js"></script>

	<script src="../Web_Tools/js/jquery.gritter.min.js"></script>	
    <script src="http://maps.google.com/maps/api/js?sensor=true"></script>
    <script src="../Web_Tools/js/gmaps.js"></script>
    <script src="../Web_Tools/js/custom.js"></script>
    <script src="Modules/operadores_del_monitor/js_operadores_del_monitor.js"></script>
</head>

<body onLoad="simple_reloj();" onUnload="stop();">


<!-- Preloader -->
<div id="preloader">
    <div id="status"><i class="fa fa-spinner fa-spin"></i></div>
</div>

<section>
  
  <div class="leftpanel">
    
    <div class="logopanel">
        <img src="../Web_Tools/images/logo_small.png" width="220" alt="logo">
    </div><!-- logopanel -->
        
    <div class="leftpanelinner">    
        
        <!-- This is only visible to small devices -->
        <div class="visible-xs hidden-sm hidden-md hidden-lg">   
            <div class="media userlogged">
                <div class="media-body">
                    <h4><?PHP echo $operador_monitor["NombreUsuario"]; ?></h4>
                </div>
            </div>
          
            <h5 class="sidebartitle actitle">Cuenta Usuario</h5>
            <ul class="nav nav-pills nav-stacked nav-bracket mb30">
            <?php if($_SESSION['operador_sesion']['rol']!=1){ ?>
              <li><a data-toggle="modal" data-target="#perfil_modal"><i class="fa fa-user"></i> <span>Perfil</span></a></li>
            <?php } ?>
            <li><a href="/dimartsky/Docs/ManualDIMARTSKY.pdf" data-target="#perfil_modal" style="cursor:pointer"><i class="glyphicon glyphicon-file"></i>Manual de usuario</a></li>
               <li><a href="http://gritec.com.ar" target="_blank"data-target="#perfil_modal" style="cursor:pointer"><i class="glyphicon glyphicon-info-sign"></i>Acerca de</a></li>
              <li><a href="../signout.html"><i class="fa fa-sign-out"></i> <span>Cerrar Sesión</span></a></li>
            </ul>
        </div>
      
      <h5 class="sidebartitle">Módulos</h5>
      <ul class="nav nav-pills nav-stacked nav-bracket">
      <?php if(in_array("14", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=estado_de_dispositivos_moviles"><i class="glyphicon glyphicon-phone"></i> <span>Estado de Dispositivos Móviles</span></a></li>
      <?php } ?>
      <?php if(in_array("17", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=operadores_moviles"><i class="fa fa-user"></i> <span>Operadores Móviles</span></a></li>
	  <?php } ?>
      <?php if(in_array("8", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=operadores_del_monitor"><i class="glyphicon glyphicon-eye-open"></i> <span>Operadores del Monitor</span></a></li>
	  <?php } ?>
      <?php if(in_array("2", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=eventos"><i class="glyphicon glyphicon-flash"></i> <span>Eventos</span></a></li>
	  <?php } ?>
      <?php if(in_array("9", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=localizaciones_jerarquicas"><i class="glyphicon glyphicon-home"></i> <span>Localizaciones Jerárquicas</span></a></li>
	  <?php } ?>
      <?php if(in_array("1", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=pedidos"><i class="glyphicon glyphicon-shopping-cart"></i> <span>Pedidos</span></a></li>
 	  <?php } ?>
      <?php if(in_array("10", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=controles_de_visitas"><i class="glyphicon glyphicon-check"></i> <span>Controles de Visitas</span></a></li>
 	  <?php } ?>
      <?php if(in_array("4", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=eficiencias"><i class="glyphicon glyphicon-stats"></i> <span>Eficiencias</span></a></li>
	  <?php } ?>
      <?php if(in_array("3", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=eficacias"><i class="fa fa-bar-chart-o"></i> <span>Eficacias</span></a></li>
	  <?php } ?>
      <?php if(in_array("7", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=productividades"><i class="fa fa-flag"></i> <span>Productividades</span></a></li>
 	  <?php } ?>
      <?php if(in_array("11", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=resumen_por_localizaciones_jerarquicas"><i class="fa fa-home"></i> <span>Resumen por Localizaciónes Jerárquicas</span></a></li>
	  <?php } ?>
      <?php if(in_array("18", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=ver_clientes_mapa"><i class="fa fa-map-marker"></i> <span>Ver Clientes en mapa</span></a></li>
    <?php } ?>
          <?php if(in_array("20", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=clientes_por_hora"><i class="glyphicon glyphicon-time"></i> <span>Clientes por hora</span></a></li>
    <?php } ?>
      <?php if(in_array("12", $modulos_habilitados_array)){ ?>
               <li class=""><a href="index.php?tabla=informes_por_localizaciones_jerarquicas"><i class="fa fa-info"></i> <span>Informes por Localizaciones Jerárquicas</span></a></li>
	  <?php } ?>
      <?php if(in_array("13", $modulos_habilitados_array)){ ?>    
               <li class=""><a href="index.php?tabla=configuraciones"><i class="glyphicon glyphicon-wrench"></i> <span>Configuraciones</span></a></li>
	  <?php } ?>
       </ul>
      <script> var tick; 
        function stop() {clearTimeout(tick);}
        function simple_reloj() {var ut=new Date(); var h,m,s; var time="        "; h=ut.getHours(); m=ut.getMinutes(); s=ut.getSeconds(); if(s<=9) s="0"+s; if(m<=9) m="0"+m; if(h<=9) h="0"+h; time+=h+":"+m+":"+s; document.getElementById('reloj').innerHTML=time; tick=setTimeout("simple_reloj()",1000);}
      </script>
        <div>          
          <div class="mb20"></div>
          <div class="row">
            <div>
              <div class="panel panel-warning panel-alt widget-today">
                <div class="panel-heading text-center">
                  <i class="fa fa-calendar-o"></i>
                </div>
                <div class="panel-body text-center">
                  <h3 class="today">
                    <?php setlocale(LC_TIME,"es_ES");
                      echo date("d") . "  " . date("M") . " de " . date("Y");
                    ?>
                  </h3>
                </div><!-- panel-body -->
              </div><!-- panel -->
            </div>

            <div>
              <div class="panel panel-danger panel-alt widget-time">
                <div class="panel-heading text-center">
                  <i class="glyphicon glyphicon-time"></i>
                </div>
                <div class="panel-body text-center">
                  <h3 class="today" id="reloj">
                  </h3>
                </div><!-- panel-body -->
              </div><!-- panel -->
            </div>
          </div>
        </div>
    </div><!-- leftpanelinner -->

  </div><!-- leftpanel -->
  <?php if(count($operadores_moviles_sin_lj_array) > 0) ?>
  <div class="mainpanel">
    
    <div class="headerbar">
      
      <a class="menutoggle"><i class="fa fa-bars"></i></a>
      
      <div class="header-right">
        <ul class="headermenu">
		<?php if($_SESSION['operador_sesion']['rol']==1){ ?>
        <li>
            <div class="btn-group">
              <button class="btn btn-default dropdown-toggle tp-icon" data-toggle="dropdown">
                <i class="glyphicon glyphicon-user"></i>
                <?php if(count($operadores_moviles_sin_lj_array) > 0){ ?>
                	<span id="cantidad_operadores_moviles_sin_lj" class="badge"><?php echo count($operadores_moviles_sin_lj_array); ?></span>
                <?php } ?>
              </button>
              <?php if(count($operadores_moviles_sin_lj_array) > 0){ ?>
              <div class="dropdown-menu dropdown-menu-head pull-right">
                <h5 class="title"><span id="operadores_moviles_sin_lj" class="badge badge-success"><?php echo count($operadores_moviles_sin_lj_array); ?></span> operadores móviles sin localización jerárquica.</h5>
                <ul id="lista_operadores_moviles_sin_lj" class="dropdown-list user-list">
                <?php  foreach ($operadores_moviles_sin_lj_array as &$v_operadores_moviles) {?>
                  <li class="new">
                    <div class="desc">
                      <h5><a href="index.php?tabla=operadores_moviles">Operador móvil <?php echo $v_operadores_moviles["NombreApellido"]; ?> sin Localización Jerárquica</a></h5>
                    </div>
                  </li>
                <?php  }?>
                </ul>
              </div>
              <?php } ?>
            </div>
          </li>
		  <?php } ?>
          <li>
            <div class="btn-group">
              <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                <?PHP echo $operador_monitor["NombreUsuario"];?>
                <span class="caret"></span>
              </button>
              <ul class="dropdown-menu dropdown-menu-usermenu pull-right">
               <?php if($operador_monitor["RolID"]!=1){ ?>
                <li><a data-toggle="modal" data-target="#perfil_modal"><i class="glyphicon glyphicon-user"></i> Perfil de usuario</a></li>
               <?php } ?>
               <li><a href="/dimartsky/Docs/ManualDIMARTSKY.pdf" data-target="#perfil_modal" style="cursor:pointer"><i class="glyphicon glyphicon-file"></i>Manual de usuario</a></li>
               <li><a href="http://gritec.com.ar" target="_blank"data-target="#perfil_modal" style="cursor:pointer"><i class="glyphicon glyphicon-info-sign"></i>Acerca de</a></li>
                <li onClick="logout();"><a> <i class="glyphicon glyphicon-log-out"></i> Cerrar sesión</a></li>
              </ul>
            </div>
          </li>
        </ul>
      </div><!-- header-right -->
      
    </div><!-- headerbar -->
    
	<!-- INICIO: DENTRO DE CADA FORMULARIO DEBE IR LOS TAGS "PAGEHEADER" Y "CONTENTPANEL" -->
	<?php
		if(isset($_GET['tabla']))
    		include('Modules/'.$_GET['tabla'].'/grid_'.$_GET['tabla'].'.php');	
	?>
    <!-- FIN: DENTRO DE CADA FORMULARIO DEBE IR LOS TAGS "PAGEHEADER" Y "CONTENTPANEL" -->
 
 	<?php 
		if($_SESSION['operador_sesion']['rol']!=1)
			include('Modules/operadores_del_monitor/frm_perfil_operadores_monitor.php');  
	?>
  </div><!-- mainpanel -->  
</section>

<script>
  jQuery(document).ready(function() {

	function verificarOperadoresMoviles(){

		$.getJSON('Modules/operadores_moviles/libreria_general.php?case=5', function(data){
	 	  $("#lista_operadores_moviles_sin_lj").html('');	
		  
		  $.each(data, function(key, val){ 
			$("#lista_operadores_moviles_sin_lj").append('<li class="new">'+
															'<div class="desc">'+
															  '<h5>'+
																'<a href="index.php?tabla=operadores_moviles">'+
																	'Operador móvil '+val.NombreApellido+' sin Localización Jerárquica'+
																'</a>'+
															   '</h5>'+
															'</div>'+
														  '</li>');
		  })
		  
		  if(data.length > 0){
		  	$('#cantidad_operadores_moviles_sin_lj').html(data.length);
			$('#operadores_moviles_sin_lj').html(data.length);
		  }
		});
    }

    //setInterval(verificarOperadoresMoviles, 10000);

    // Show aciton upon row hover
    jQuery('.table-hidaction tbody tr').hover(function(){
      jQuery(this).find('.table-action-hide a').animate({opacity: 1});
    },function(){
      jQuery(this).find('.table-action-hide a').animate({opacity: 0});
    });
  
 /* jQuery('#fecha_desde').datepicker();
  jQuery('#fecha_hasta').datepicker();*/
  
	$( "#fecha_desde" ).datepicker({
	  defaultDate: "+1w",
	  changeMonth: true,
	  changeYear: true,
	  dateFormat: "dd-mm-yy",
	  altField: "#fecha_desde_hidden",
      altFormat: "yymmdd"+'000000',
	  numberOfMonths: 1,
	  onClose: function( selectedDate ) {
		$( "#fecha_hasta" ).datepicker( "option", "minDate", selectedDate );
	  }
	});
	
	$( "#fecha_hasta" ).datepicker({
	  defaultDate: "+1w",
	  dateFormat: "dd-mm-yy",
	  changeMonth: true,
      changeYear: true,
	  altField: "#fecha_hasta_hidden",
      altFormat: "yymmdd"+'000000',
	  numberOfMonths: 1,
	  onClose: function( selectedDate ) {
		$( "#fecha_desde" ).datepicker( "option", "maxDate", selectedDate );
	  }
	});
	
  $( "#fecha_desde" ).datepicker({dateFormat:"dd-mm-yy"}).datepicker("setDate",new Date());
  $( "#fecha_hasta" ).datepicker({dateFormat:"dd-mm-yy"}).datepicker("setDate",new Date());
  $( "#fecha_hasta_hidden" ).datepicker({dateFormat:"yymmdd"+'000000'}).datepicker("setDate",new Date());		
  $( "#fecha_desde_hidden" ).datepicker({dateFormat:"yymmdd"+'000000'}).datepicker("setDate",new Date());		
		
  
    // Chosen Select
  jQuery(".chosen-select").chosen({'width':'100%','white-space':'nowrap'});

  });
  var spinner = jQuery('#spinner').spinner();
  spinner.spinner('value', 1);
</script>


</body>
</html>