  <?php
    include_once('../inc/api_cred.php');
  
    $cargo = $_SESSION['LOGIN']['CARGONOMBRE'];
	if(empty($cargo)) { $cargo = "No Asignado"; }
  
	$departamento = "";	
	$longitud = $_SESSION['LOGIN']['DEPTONOMBRE'];

	

 
	$ch_acceso = curl_init($apiUrl . '/public/listarperfilespersona'); //create a new cURL resource
	$payload_acceso = json_encode(array('idpersona' => $_SESSION['LOGIN']['CODIGO']));
	curl_setopt($ch_acceso, CURLOPT_POSTFIELDS, $payload_acceso);//attach encoded JSON string to the POST fields
	curl_setopt($ch_acceso, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //set the content type to application/json
	curl_setopt($ch_acceso, CURLOPT_RETURNTRANSFER, true); //return response instead of outputting
	$result_acceso = curl_exec($ch_acceso); //execute the POST request
	$arrayPermisoAcceso = json_decode($result_acceso);
	
  curl_close($ch_acceso); 
	
  
  $ch4dpp = curl_init($apiUrl . '/public/obtenerdepartamentoprimarioasignado'); //create a new cURL resource
  $payload4dpp = json_encode(array('id_persona' => $_SESSION['LOGIN']['CODIGO']));
  curl_setopt($ch4dpp, CURLOPT_POSTFIELDS, $payload4dpp);//attach encoded JSON string to the POST fields
  curl_setopt($ch4dpp, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //set the content type to application/json
  curl_setopt($ch4dpp, CURLOPT_RETURNTRANSFER, true); //return response instead of outputting
  $result4dpp = curl_exec($ch4dpp); //execute the POST request
  $array4dpp = json_decode($result4dpp);
  error_log($result4dpp);



  curl_close($ch4dpp); 	
	
  ?>  
  
  <!-- Navbar -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
		  <div class="input-group mt-1 input-group-sm">
			<div class="input-group-prepend">
			  <div class="input-group-text bg-success">Usuario en Linea</div>
			</div>
			<input type="text" class="form-control control-text bg-success" style="width:400px;" value="<?php echo $_SESSION['LOGIN']['NOMBRE'] ?>" readonly>
		  </div>			
      </li>
    </ul>

 
    <ul class="navbar-nav ml-auto">
 
	
      <li class="nav-item dropdown ml-1">
        <a class="nav-link btn btn-outline-primary btn-sm" data-toggle="dropdown" href="#">
          <i class="fas fa-cog"></i>
          Herramientas
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
          <span class="dropdown-item dropdown-header">Herramientas</span>
        
  
          <div class="dropdown-divider"></div>
			  <span class="dropdown-item" style="font-size:11px;"><b>USUARIO :</b> <?php echo $_SESSION['LOGIN']['NOMBRE']; ?>	</span>  
          <div class="dropdown-divider"></div>
			  <span class="dropdown-item" style="font-size:11px;"><b>CARGO :</b> <?php echo $cargo; ?></span>		  
          <div class="dropdown-divider"></div>
			  <span class="dropdown-item" style="font-size:11px;"><b>CENTRO:</b> <?php echo $array4dpp[0][0]->departamento; ?></span>		  			  
        </div>
      </li>
	 
      <li class="nav-item dropdown ml-1">
        <a class="nav-link btn btn-danger btn-sm" style="color:#ffffff;" href="#"  data-toggle="modal" data-target="#exampleModal">
          <i class="fas fa-lock"></i>
        </a>
      </li>	 

    </ul>
  </nav>
  <!-- /.navbar -->
  
  
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">PowerTime</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body text-center">
        <p style="display:inline; font-size:11px;">
			Estimado(a) : <br /><?php echo substr($_SESSION['LOGIN']['NOMBRE'], 0, 15); ?> <br /> 		
			&iquest; Desea Cerrar Sesi&oacute;n ?
		</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Close</button>
        <a class="btn btn-danger btn-sm" style="color:#ffffff;cursor:pointer;" href="../cierre.sesion.php">Cerrar Sesi&oacute;n</a>
      </div>
    </div>
  </div>
</div>