<?php
@session_start();
   $vg_login=$_SESSION["usuario"];
  $empresa=$_SESSION["empresa"];
 if($vg_login<>""){}
 else
  {echo "<script>";
   echo "window.location='index.php';";
   echo "</script>";
  }	


require_once ('Mobile_Detect.php');
$detect = new Mobile_Detect(); 
if ($detect->isMobile()==false)   {   $tipodispo=2;  }
else   {  $tipodispo=1;}  
include "parametros.php" ;
include "conexion.php" ;

$sql_datos =mysqli_query($conexion,"select id FROM empresa where nit='".$vg_login."'");
while($datos= mysqli_fetch_row($sql_datos))	{ $idempresa=$datos[0]; $codigoempresa=$datos[0]; }
				   
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?php  echo $nombreprograma." - ".$version; ?></title>
  
  <link rel="icon" href="icono.ico" type="image/x-icon"/>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Tempusdominus Bootstrap 4 -->
  <link rel="stylesheet" href="plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- JQVMap -->
  <link rel="stylesheet" href="plugins/jqvmap/jqvmap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
  <!-- summernote -->
  <link rel="stylesheet" href="plugins/summernote/summernote-bs4.min.css">
  
</head>
<body class="hold-transition sidebar-mini layout-fixed">
    
    
    
<div class="wrapper">

  <!-- Preloader -->
  <div class="preloader flex-column justify-content-center align-items-center">
    <img class="animation__shake" src="imagenes/logo.png" alt="Garanty Seguros" >
    
   <div class="progress" style="height: 20px;">
  <div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>

  </div>



  <!-- 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="#" role="button"><i class="fas fa-bars"></i></a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a href="sg-sst.php" class="nav-link">Inicio</a>
      </li>
     
    </ul>

    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <!-- Navbar Search -->
      <li class="nav-item">
       
        <div class="navbar-search-block">
          <form class="form-inline">
            <div class="input-group input-group-sm">
              <input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
              <div class="input-group-append">
                <button class="btn btn-navbar" type="submit">
                  <i class="fas fa-search"></i>
                </button>
                <button class="btn btn-navbar" type="button" data-widget="navbar-search">
                  <i class="fas fa-times"></i>
                </button>
              </div>
            </div>
          </form>
        </div>
      </li>

     <?php
       if($nperfil=='Administrador')
        {
     ?>
        <li class="nav-item dropdown">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="fa fa-bell"></i>
          <span class="badge badge-danger navbar-badge">
              <div id="feedback-bg-chat" >  </div>	
          </span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
          <a href="#" class="dropdown-item">
            <!-- Message Start -->
            <div class="media">
             
              <div class="media-body">
                
                <div id="feedback-bg-chatdetalle">  </div>	
                
              </div>
            </div>
            <!-- Message End -->
          </a>
         
          <div class="dropdown-divider"></div>          
        </div>
      </li>
      
      <?php
        }
     ?>
     
     

      <!-- Notifications Dropdown Menu -->
      <?php
      /*
      <li class="nav-item dropdown">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="far fa-bell"></i>
          <span class="badge badge-warning navbar-badge">15</span>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
          <span class="dropdown-item dropdown-header">Notifications</span>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <i class="fas fa-envelope mr-2"></i> 4 Mensajes Nuevos
          </a>
          <div class="dropdown-divider"></div>
          <a href="#" class="dropdown-item">
            <i class="fas fa-file mr-2"></i> 3 Reportes Nuevos            
          </a>
          <div class="dropdown-divider"></div>
         
        </div>
      </li>
      */
      ?>
  
      <li class="nav-item">
        <a class="nav-link" data-widget="fullscreen" href="#" role="button">
          <i class="fas fa-expand-arrows-alt"></i>
        </a>
      </li>

      <li class="nav-item">
       <a href="exit.php" class="btn btn-outline-white border-0 p-2 mr-1" title="Cerrar Session">
                       <i class="fa fa-sign-out-alt text-150"></i>
       </a>
      </li>
     
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <center>
    <a href="sg-sst.php" class="brand-link">   
       <img src="imagenes/logo.png" alt="GARANTY SEGUROS" width='50%' >         
    </a>  
</center>
        <center>
            <?php
        //<a href="#" data-toggle="modal" data-target="#fotoperfil-lg" class="d-block"><img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image" width='50px' height='50px'></a>
        ?>
          <font color='#ffffff'><strong> 
            <?php echo $nombreusuario; ?><br>
            <?php echo $nperfil; ?></strong>
            </font>
        </center>
    

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar user panel (optional) -->
      

      <!-- SidebarSearch Form -->
      

      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
         </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    
  <section class="content">
    <?php
    if($nperfil=='Administrador')
          {
    ?>          
    

       <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
        <div class="row">
          

          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-primary">
               
              <div class="inner">
                   <a href="#" data-target="#estadisticaempresas" data-toggle="modal" >
                <font color='#ffffff'>
                <h4> EMPRESA</h4>
                <p>
                  <?php
                      $sql_datosrs=mysqli_query($conexion,"SELECT count(*) from empresa where estado='A'");
                      while($datos= mysqli_fetch_row($sql_datosrs))	{ $totalempresa=$datos[0]; }
                      echo "TOTAL:  $totalempresa";
                  ?>
                </p>
                </font>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              <a href="#" class="small-box-footer"> <i class="fas fa-arrow-circle-right"></i></a>
               </a>
            </div>
           
          </div>
          
          
          
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-success">
               
              <div class="inner">
                   <a href="#" data-target="#estadisticaempresasaportes" data-toggle="modal" >
                <font color='#ffffff'>
                <h4> APORTES</h4>
                <p>
                 Estadistica
                </p>
                </font>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              <a href="#" class="small-box-footer"> <i class="fas fa-arrow-circle-right"></i></a>
               </a>
            </div>
           
          </div>
          
         
          
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-warning">
              <div class="inner">
                <h4>PLAN CAPACITACION</h4>
                <p>
                      <?php
                      $totalpC=0;
                      $sql_datosrs=mysqli_query($conexion,"SELECT count(*) from curso_programa where year(fecha)='".date("Y")."'");
                      while($datos= mysqli_fetch_row($sql_datosrs))	{ $totalpC=$datos[0]; }
                      echo "TOTAL POR AÑO:  $totalpC";
                    ?>
                </p>
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a href="#" class="small-box-footer"> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-danger">
              <div class="inner">
              <h4>PLAN TRABAJO</h4>
                <p>
                     <?php
                      $totalpt=0;
                      $sql_datosrs=mysqli_query($conexion,"SELECT count(*) from empresa_plantrabajo where year(fecha)='".date("Y")."'");
                      while($datos= mysqli_fetch_row($sql_datosrs))	{ $totalpt=$datos[0]; }
                      echo "TOTAL POR AÑO  $totalpt";
                      
                  ?>
                    
                    
                </p>
              </div>
              <div class="icon">
                <i class="ion ion-pie-graph"></i>
              </div>
              <a href="#" class="small-box-footer"> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
        </div>
        <!-- /.row -->

        <!-- Main row -->
        <div class="row">
          <!-- Left col -->
          <section class="col-lg-6 connectedSortable">
            <!-- Custom tabs (Charts with tabs)-->
            <div class="card">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="fas fa-chart-pie mr-1"></i>
                  SOLICITUD DE SERVCIOS
                </h3>
                <div class="card-tools">
                </div>
              </div><!-- /.card-header -->

              <div class="card-body">
                <div class="tab-content p-0" style="font-size:18px">
                  <!-- Morris chart - Sales -->
                  <?php
       //estadisticas de la empresa
       	         $sql_datosrs=mysqli_query($conexion,"SELECT count(*) from empresa_solicitud where estado<>'I'");
				         while($datos= mysqli_fetch_row($sql_datosrs))	{ $totalsolicitud=$datos[0]; }
                 
                 $sumat=0;$sumaiva=0;$totals=0;
                $sql_datosi=mysqli_query($conexion,"select id,descripcion,duracion,cantidad,valor_unitario,iva
													FROM empresa_solicitud_items
													 where consecutivo in (select solicitud from empresa_solicitud where estado<>'I')");
							while($datoslogi= mysqli_fetch_row($sql_datosi))//01
							{
								$id=$datoslogi[0];
								$descripcion11=$datoslogi[1];
								$duracion=$datoslogi[2];
								$cantidad=$datoslogi[3];
								$valorunitario=$datoslogi[4];
								$iva=$datoslogi[5];
								$vrtotal=$cantidad*$valorunitario;								
								if($iva=='S')
								{
    								$vriva=$vrtotal*0.19;
    								$sumaiva=$sumaiva+$vriva;
								}
								$totals=$totals+$vrtotal;
							}
							$sumat=$totals+$sumaiva;
                     $cp=0; 
                    $sql_datosrs=mysqli_query($conexion,"SELECT count(*),proveedor from empresa_solicitud where estado<>'I' group by proveedor");
                    while($datos= mysqli_fetch_row($sql_datosrs))	
                      { $cp++;                      
                      }
                echo "Total Solicitudes Asignadas:  $totalsolicitud<br>";
                echo "Valor Total Solicitudes:  ".number_format($sumat)."<br>";
                echo "Total Proveedores Asignados:  ".number_format($cp)."<br>";
                echo "<table width='100%' >";
                echo "<tr><th width='100%' class='btn-primary' align='center' colspan='2'>SOLICITUDES SERVICIO POR USUARIO</th></tr>";
                $nuser="";
                $sql_datosrs=mysqli_query($conexion,"SELECT count(*),usuario from empresa_solicitud where estado='P' group by usuario");
                while($datos= mysqli_fetch_row($sql_datosrs))	
                  { $cantidad=$datos[0];
                    $usuario=$datos[1];   
                        
                    $sql_datosuser=mysqli_query($conexion,"SELECT nombre,apellido from usuario where login='".$usuario."'");
                    while($datosuser= mysqli_fetch_row($sql_datosuser))	
                      { $nuser=$datosuser[0]." ". $datosuser[1];                      
                      }
                      echo "<tr><td width='80%'>".strtoupper($nuser)."</td><td>".number_format($cantidad)."</td></tr>";
                  }
            echo "</table>";
       ?>
                 
                </div>
              </div><!-- /.card-body -->
            </div>
            <!-- /.card -->

          
            <!-- TO DO List -->
           <?php
           /*
            <div class="card">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="ion ion-clipboard mr-1"></i>
                  OTRAS ESTADISTICAS
                </h3>

               
              </div>
              <!-- /.card-header -->
              <div class="card-body">
               ACA LOS LINK
              </div>
            </div>
            */
            ?>
            <!-- /.card -->
          </section>


          <!-- /.Left col -->
          <!-- right col (We are only adding the ID to make the widgets sortable)-->
          <section class="col-lg-6 connectedSortable">

            <!-- Map card -->
            <div class="card">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="fas fa-chart-pie mr-1"></i>
                  ESTADISTICA ARL
                </h3>
                <div class="card-tools">
                </div>
              </div><!-- /.card-header -->

              <div class="card-body">
                <div class="tab-content p-0" style="font-size:18px">
                  <!-- Morris chart - Sales -->
                  <?php
                  echo "<a href='PHPExcel/Examples/arl.php' target='otro'><img src='imagenes/imprimir.png' width='30px' height='30px'></a>";
                echo "<table width='100%' >";
                echo "<tr><th width='100%' class='btn-primary' align='center' colspan='2'>CANTIDAD EMPRESAS POR ARL</th></tr>";
                $sql_datosrs=mysqli_query($conexion,"SELECT count(*),arl from empresa group by arl");
                while($datos= mysqli_fetch_row($sql_datosrs))	
                  { $cantidad=$datos[0];
                    $arl=$datos[1];   
                        
                    $sql_datosuser=mysqli_query($conexion,"SELECT nombre from riesgoslaborales where id='".$arl."'");
                    while($datosuser= mysqli_fetch_row($sql_datosuser))	
                      { $narl=$datosuser[0];                      
                      }
                      echo "<tr><td width='80%'>".strtoupper($narl)."</td><td>".number_format($cantidad)."</td></tr>";
                  }
                echo "</table>";
       ?>
                 
                </div>
              </div><!-- /.card-body -->
            </div>
            <!-- /.card -->

          
        
          </section>
          
          
           <section class="col-lg-6 connectedSortable">

            <!-- Map card -->
            <div class="card">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="fas fa-chart-pie mr-1"></i>
                  HSE
                </h3>
                <div class="card-tools">
                </div>
              </div><!-- /.card-header -->

              <div class="card-body">
                <div class="tab-content p-0" style="font-size:18px">
                  <!-- Morris chart - Sales -->
                   <a href="#" data-target="#calendariohse-xl" data-toggle="modal" >Calendario Plan Trabajo</a>
                 
                </div>
              </div><!-- /.card-body -->
            </div>
            <!-- /.card -->

          
        
          </section>
          <!-- right col -->
        </div>
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->

    <?php
          }
    ?>
        
      
      <?php
      //verificamos perfil de empresa para mostrarle la informacion correspondiente
          if($nperfil=='empresa')
          {
            ?>
           <!-- /.inicio -->
                  <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
        <div class="row">
          <div class="col-lg-3 col-6">
            <a href='#' data-toggle="modal" data-target="#calendarioaactividades-xl" >
            <!-- small box -->
            <div class="small-box bg-info">
              <div class="inner">
                <h4 align='center'>CALENDARIO</h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-bag"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver<i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>    
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <a href='#' data-toggle="modal" data-target="#comunicados-xl" >
            <div class="small-box bg-success">
              <div class="inner">
                <h4 align='center'>COMUNICADOS</h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver<i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <a href='#' data-toggle="modal" data-target="#actividades-xl" >
            <div class="small-box bg-warning">
              <div class="inner">
                <h4 align='center'>ACTIVIDADES</h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver <i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
           <!-- small box -->
            <a href='#' data-toggle="modal" data-target="#empestadistica-xl" >
            <div class="small-box bg-danger">
              <div class="inner">
              <h4 align='center'>ESTADISTICA</h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-pie-graph"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver <i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>
          </div>
          <!-- ./col -->
        </div>
        <!-- /.row -->

 
   <center> <table id="example1" class="table table-bordered table-striped" style="font-size:12px;" border='1' bordercolor='#cccccc' cellpadding='0' cellspacing='0'>
                  <thead>
                  <tr>
                    <th  class="btn-primary" ALIGN='center' colspan='5'>PLAN DE CAPACITACION</th>
                    
                  </tr>
                  <tr>
                    <th width="10%" class="btn-primary" align='center'>FECHA/HORA</th>
                    <th width="15%" class="btn-primary" align='center'>PROVEEDOR</th>
                    <th width="10%" class="btn-primary" align='center'>RESPONSABLE</th>
                    <th width="20%" class="btn-primary" align='center'>OBSERVACION</th>
                    <th width="20%" class="btn-primary" align='center'>INGRESAR PERSONAL</th>
                  </tr>
                  </thead>                 
                  <tbody>
						  <?php
						 
                          $c=0;
								$sql_datos=mysqli_query($conexion,"select  id,fecha,hora,curso,proveedor,responsable,observacion,estado,usuario,fecsis,horasis,empresa,link
																	FROM curso_programa
																	where id in (select idprograma from curso_empresa where empresa='".$codigoempresa."')
																	and estado='1'
																	order by fecha asc");
								while($datos=mysqli_fetch_row($sql_datos))//01
								{   
                                    $id=$datos[0]; 						
                                    $fecha=$datos[1]; 	
                                    $hora=$datos[2]; 	
                                    $curso=$datos[3]; 
									$proveedor=$datos[4]; 
									$responsable=$datos[5]; 
									$observacion=$datos[6]; 	
									$estado=$datos[7]; 	
									$usuario=$datos[8]; 	
									$rsfecsis=$datos[9]; 	
									$rshorasis=$datos[10]; 
									$rsempresa=$datos[11]; 
									$link=$datos[12]; 
									
									if($estado=='A'){$nestado='Activo';} else {$nestado='Inactivo';}
                    
									$rs_tipo=mysqli_query($conexion,"SELECT nombre FROM estado where id='".$estado."'");
                                    while($datostipo=mysqli_fetch_row($rs_tipo))  { $nestado=$datostipo[0]; 		}
									
									$rs_tipo=mysqli_query($conexion,"SELECT nombre FROM empresa where id='".$rsempresa."'");
                                    while($datostipo=mysqli_fetch_row($rs_tipo))  { $nempresa=$datostipo[0]; 		}
									
                    
                                    echo " <tr>";
                                             echo "<td>$fecha<br>$hora</td>";
                                             echo "<td>".$proveedor."</td>";
											 echo "<td>".$responsable."</td>";
											 echo "<td>".$observacion."</td>";
											 echo "<td align='center'>";
											 ?>
											 <input name='crear' type='button'  id='crear' value='Cargar Empleados'   class="btn btn-primary"   
                                            onClick="javascript:window.open('hse/frm_empleado.php?cu=<?php echo $id; ?>&em=<?php echo $codigoempresa; ?>','creaempleados','menubar=1,toolbar=0,location=0,directories=0,status=1,scrollbars=1,width=500,height=300');"  >
										<?php	 
											echo "</td>";											 
                                             echo "</tr>";
                                        $c=$c+1;
                                    }
                          ?>  
			      </tbody>
            </table></center>

        <!-- Main row -->
      
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->
  
            <!-- /.fin -->
            <?php  
          }
          
          
          if($nperfil=='proveedor')
          {
            ?>
           <!-- /.inicio -->
                 <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
        <div class="row">
          <div class="col-lg-3 col-6">
            <a href='#' data-toggle="modal" data-target="#radicar-xl" >
            <!-- small box -->
            <div class="small-box bg-info">
              <div class="inner">
                <h4 align='center'>RADICAR </h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-bag"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver<i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>    
          </div>
          
          
            <div class="col-lg-3 col-6">
            <!-- small box -->
            <a href='#' data-toggle="modal" data-target="#radicarp-xl" >
            <div class="small-box bg-warning">
              <div class="inner">
                <h4 align='center'>EN APROBACION</h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver<i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>
          </div>
          
          
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <a href='#' data-toggle="modal" data-target="#radicara-xl" >
            <div class="small-box bg-success">
              <div class="inner">
                <h4 align='center'>APROBADAS</h4>
                <p>&nbsp;</p>
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a href="#" class="small-box-footer">Clic Para ver <i class="fas fa-arrow-circle-right"></i></a>
            </div>
            </a>
          </div>
         
        </div>
        <!-- /.row -->

        
      </div><!-- /.container-fluid -->
            <!-- /.fin -->
            <?php  
          }
          
          if($nperfil=='empresa')
          {
               $sql_contar=mysqli_query($conexion,"SELECT id FROM empresa where nit='".$vg_login."'");
               while($datoscontar= mysqli_fetch_row($sql_contar)){ $idempresa=$datoscontar[0];}
              $contar=0;
               $sql_datos =mysqli_query($conexion,"select count(*)	 FROM hse_encuesta_examen
									     where id in (select idencuesta from hse_encuesta_empresa where empresa='".$idempresa."')
									     and estado='A'
									     order by id,nombre asc");
									     
                  while($datoslog= mysqli_fetch_row($sql_datos)) {$contar=$datoslog[0]; }	  
                  
                  if($contar>=1)
                  {
                        $sql_datos =mysqli_query($conexion,"select id,nombre FROM hse_encuesta_examen
									     where id in (select idencuesta from hse_encuesta_empresa where empresa='".$idempresa."')
									     and estado='A'
									     order by id,nombre asc");
									     
                  while($datoslog= mysqli_fetch_row($sql_datos)) 
                    {
                        $id=$datoslog[0]; 	  
                        $nombre=$datoslog[1]; 	  
                    
                    //verificamos si la encuesta ya se termino para quitarla de la pantalla
                     $contestadas=1;$cop=1;
                     $sql_contar=mysqli_query($conexion,"SELECT count(*),idpregunta FROM hseencuesta_empresa 
                     									 where idexamen='".$id."' and usuario='".$vg_login."'
                    									 group by idpregunta");
                     while($datos= mysqli_fetch_row($sql_contar))
                       { $contestadas=$datos[0]+1;
                         $cop=$cop+1;
                       }	 
                    $contestadas=$cop;
                    
                    $sql_contar=mysqli_query($conexion,"SELECT count(*) FROM hse_encuesta_pregunta 
                     									 where nivel_id='".$id."'");
                     while($datos= mysqli_fetch_row($sql_contar)){  $preguntas=$datos[0];   }	 

                    if($contestadas<$preguntas)
                    {
                        echo "<center> <font size='4'><strong> $nombre</strong> </center>"; 
                    ?>
                    <center>
                    <input name='rep' type='button'  id='rep' value='COMENZAR ENCUESTA'   class="btn btn-primary"
		  title="Clic para comenzar Examen"
		  onclick="javascript:window.open('bancopreguntas/preguntas.php?idexamen=<?php echo $id; ?>','examen','menubar=1,toolbar=0,location=0,directories=0,status=1,scrollbars=1,width=900,height=600');" 
	   style="width:250px"  />
	   </center>

                    <?php
                      echo "</center>";
                    } 
                        
                    }    
                      
                  }
	  
             ?>
            
	   
              <?php

             /* 
              //VERIFICAMOS EL LOGO EMPRESA
              $sql_contar =mysqli_query($conexion,"select count(*) as contar from anexos_empresa
													where empresa='".$vg_login."' and tipoanexo='26'");
				 while($datos= mysqli_fetch_row($sql_contar)){  $contarr=$datos[0];  }
				 if($contarr>=1)										  
					{
					  $sql_datos=mysqli_query($conexion,"select imagen from anexos_empresa
														  where empresa='".$nit."' and tipoanexo='26'");
					  while($datos= mysqli_fetch_row($sql_datos)){    $imagen=trim($datos[0]);}	
					  
					   $path_a_tu_doc="../docs_empresa";
					   $lin=" / ";
					   $enlacefoto = $path_a_tu_doc.trim($lin).$imagen;
					   echo $enlacefoto;
					}  
			*/		

          }

       ?>
          <center>
           
           
         <?php
         /*
         //verificamos datos de asesor
         $sql_contar =mysqli_query($conexion,"select id from empresa	where nit='".$vg_login."'");
				 while($datos= mysqli_fetch_row($sql_contar)){  $codempresa=$datos[0];  }
				 
          $sql_contar =mysqli_query($conexion,"select count(*) as contar from empresa_asesor	where empresa='".$codempresa."'");
				 while($datos= mysqli_fetch_row($sql_contar)){  $contarr=$datos[0];  }
				 if($contarr>=1)										  
					{
					    $sql_contar =mysqli_query($conexion,"select asesor,asesorcorreo from empresa_asesor
												        	where empresa='".$codempresa."'");
				        while($datos= mysqli_fetch_row($sql_contar))
				        {  $asesor=$datos[0];  
				           $asesorcorreo=$datos[1];     
				            
				        }
				        
				        echo "<br><strong>ASESOR:$asesor - $asesorcorreo </strong>";
					} 
          */
           ?>
           </center>
           
    </section>
    <!-- /.content -->


  </div>
  <!-- /.content-wrapper -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- ChartJS -->
<script src="plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="plugins/moment/moment.min.js"></script>
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard.js"></script>




<div class="modal fade" id="empestadistica-xl">
<div class="modal-dialog modal-xl">
  <div class="modal-content">
    <div class="modal-header">
      <h4 class="modal-title">ESTADISTICAS</h4>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true" style='font-size:14px;'>Cerrar</span>
      </button>
    </div>
    <div class="modal-body">
       
       <?php
       //estadisticas de la empresa
       	         $sql_datosrs=mysqli_query($conexion,"SELECT count(*) from empresa_actividad 
													where empresa='". $idempresa."'");
				  while($datos= mysqli_fetch_row($sql_datosrs))	{ $totalactividades=$datos[0]; }	
					
					
				 $sql_datosrs=mysqli_query($conexion,"SELECT sum(costocliente) from empresa_actividad 
															where empresa='". $idempresa."'");
				  while($datos= mysqli_fetch_row($sql_datosrs))	{ 	$costocliente=$datos[0];		}
				  
				  
				   $sql_datosrs=mysqli_query($conexion,"SELECT sum(retornoempresa) from empresa_aportes 
															where empresa='". $idempresa."'");
				  while($datos= mysqli_fetch_row($sql_datosrs))	{ 	$aportes=$datos[0];		}
				  
				  $saldo=$aportes-$costocliente;
				  
				  
				  echo "Total Actividades empresa:  $totalactividades<br>";
				  echo "Total Aportes empresa:  ".number_format($aportes)."<br>";
				  echo "Total Costos Actividades empresa:  ".number_format($costocliente)."<br>";
				  echo "Total Saldo empresa:  ".number_format($saldo)."<br>";
       
       ?>
       
    </div>
    <div class="modal-footer justify-content-between">
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>              
    </div>
  </div>
  <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>

<!-- /.fin empresa -->




<div class="modal fade" id="estadisticaempresasaportes">
<div class="modal-dialog modal-xl">
  <div class="modal-content">
    <div class="modal-header">
      <h4 class="modal-title">ESTADISTICAS APORTES</h4>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true" style='font-size:14px;'>Cerrar</span>
      </button>
    </div>
    <div class="modal-body">
        <?php
            
                 $sql_datosrs=mysqli_query($conexion,"SELECT sum(retornoempresa) from empresa_aportes");
				  while($datos= mysqli_fetch_row($sql_datosrs))	{ $totalaportes=$datos[0]; }	
					
					
				 $sql_datosrs=mysqli_query($conexion,"SELECT sum(costocliente) from empresa_actividad");
				  while($datos= mysqli_fetch_row($sql_datosrs))	{ 	$costocliente=$datos[0];		}
				  
				  $saldo=$totalaportes-$costocliente;
				  
            echo "<a href='PHPExcel/Examples/aportes_periodo.php' target='otro'><img src='imagenes/imprimir.png' width='30px' height='30px'></a>";
            echo "<table width='100%' >";
            echo "<tr>";
            echo "<td valign='top' align='center'>TOTAL APORTES</td>";
            echo "<td valign='top' align='center'>".number_format($totalaportes)."</td>";
            echo "</tr>";
            
            echo "<tr>";
            echo "<td valign='top' align='center'>TOTAL ACTIVIDAD EMPRESA</td>";
            echo "<td valign='top' align='center'>".number_format($costocliente)."</td>";
            echo "</tr>";
            
            
            echo "<tr>";
            echo "<td valign='top' align='center'>TOTAL SALDO</td>";
            echo "<td valign='top' align='center'>".number_format($saldo)."</td>";
            echo "</tr>";
            
            
            echo "</table>";     
           
            
        ?>
    </div>
    <div class="modal-footer justify-content-between">
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>              
    </div>
  </div>
  <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>




<div class="modal fade" id="estadisticaempresas">
<div class="modal-dialog modal-xl">
  <div class="modal-content">
    <div class="modal-header">
      <h4 class="modal-title">ESTADISTICAS EMPRESAS</h4>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true" style='font-size:14px;'>Cerrar</span>
      </button>
    </div>
    <div class="modal-body">
        <?php
            
            echo "<table width='100%' >";
            echo "<tr>";
            echo "<td valign='top' align='center'>";
            echo "<a href='PHPExcel/Examples/comision.php' target='otro'><img src='imagenes/imprimir.png' width='30px' height='30px'></a>";
            echo "<table width='70%' border='1' bordercolor='#CCCCCC' >";
            echo "<tr><td class='btn-primary' align='center' colspan='2'>COMISION POR EMPRESA </td></tr>";
             echo "<tr><td class='btn-primary' align='center'>COMISION</td><td class='btn-primary' align='center'>TOTAL</td></tr>";
            $sql_datosrs=mysqli_query($conexion,"SELECT count(*),comision from empresa group by comision");
                      while($datos= mysqli_fetch_row($sql_datosrs))	
                        { $cantidad=$datos[0];
                          $comision=$datos[1];   
                           echo "<tr><td width='80%'>".$comision."</td><td align='right'>".number_format($cantidad)."</td></tr>";
                        }
            echo "</table>";       
            
            echo "</td>";
            echo "<td valign='top' align='center'>";
            echo "<a href='PHPExcel/Examples/politicaretorno.php' target='otro'><img src='imagenes/imprimir.png' width='30px' height='30px'></a>";
            echo "<table width='70%' border='1' bordercolor='#CCCCCC' >";
            echo "<tr><td class='btn-primary' align='center' colspan='2'>POLITICA DE RETORNO </td></tr>";
             echo "<tr><td class='btn-primary' align='center'>POLITICA</td><td class='btn-primary' align='center'>TOTAL</td></tr>";
            $sql_datosrs=mysqli_query($conexion,"SELECT count(*),politicaretorno from empresa group by politicaretorno");
                      while($datos= mysqli_fetch_row($sql_datosrs))	
                        { $cantidad=$datos[0];
                          $comision=$datos[1];   
                           echo "<tr><td width='80%'>".$comision."</td><td align='right'>".number_format($cantidad)."</td></tr>";
                        }
            echo "</table>";     
            echo "</td>";
            echo "<td valign='top' align='center'>";
            echo "<a href='PHPExcel/Examples/reteica.php' target='otro'><img src='imagenes/imprimir.png' width='30px' height='30px'></a>";
            echo "<table width='70%' border='1' bordercolor='#CCCCCC' >";
            echo "<tr><td class='btn-primary' align='center' colspan='2'>RETEICA POR EMPRESA </td></tr>";
             echo "<tr><td class='btn-primary' align='center'>RETEICA</td><td class='btn-primary' align='center'>TOTAL</td></tr>";
            $sql_datosrs=mysqli_query($conexion,"SELECT count(*),reteica from empresa group by reteica");
                      while($datos= mysqli_fetch_row($sql_datosrs))	
                        { $cantidad=$datos[0];
                          $comision=$datos[1];   
                           echo "<tr><td width='80%'>".$comision."</td><td align='right'>".number_format($cantidad)."</td></tr>";
                        }
            echo "</td>";
            echo "</tr>";
            echo "</table>";     
        ?>
    </div>
    <div class="modal-footer justify-content-between">
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>              
    </div>
  </div>
  <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>






      
</body>
</html>
