<?php
$role = $_settings->userdata('role');
$user_id = $_settings->userdata('id');
?>

<div class="container-fluid">
  <h3 class="mb-3">Dashboard</h3>

  <div class="row">

  <!-- ================= ADMIN ================= -->
  <?php if($role === 'ADMIN'): ?>

    <div class="col-lg-3 col-6">
      <div class="small-box bg-primary">
        <div class="inner">
          <h3><?= $conn->query("SELECT id FROM projects")->num_rows ?></h3>
          <p>Proyectos Totales</p>
        </div>
        <div class="icon"><i class="fas fa-project-diagram"></i></div>
      </div>
    </div>

    <div class="col-lg-3 col-6">
      <div class="small-box bg-success">
        <div class="inner">
          <h3><?= $conn->query("SELECT id FROM users WHERE active=1")->num_rows ?></h3>
          <p>Usuarios Activos</p>
        </div>
        <div class="icon"><i class="fas fa-users"></i></div>
      </div>
    </div>

  <?php endif; ?>


  <!-- ================= GESTOR PMO ================= -->
  <?php if($role === 'GESTOR'): ?>

    <div class="col-lg-3 col-6">
      <div class="small-box bg-info">
        <div class="inner">
          <h3><?= $conn->query("
            SELECT id FROM projects WHERE approval_status IN (1,3)
          ")->num_rows ?></h3>
          <p>En Seguimiento PMO</p>
        </div>
        <div class="icon"><i class="fas fa-tasks"></i></div>
      </div>
    </div>

    <div class="col-lg-3 col-6">
      <div class="small-box bg-warning">
        <div class="inner">
          <h3><?= $conn->query("
            SELECT id FROM projects WHERE approval_status = 2
          ")->num_rows ?></h3>
          <p>Proyectos Observados</p>
        </div>
        <div class="icon"><i class="fas fa-exclamation-triangle"></i></div>
      </div>
    </div>

  <?php endif; ?>


  <!-- ================= PO ================= -->
  <?php if($role === 'PO'): ?>

    <div class="col-lg-3 col-6">
      <div class="small-box bg-secondary">
        <div class="inner">
          <h3><?= $conn->query("
            SELECT id FROM projects
            WHERE owner_id = $user_id
          ")->num_rows ?></h3>
          <p>Mis Proyectos</p>
        </div>
        <div class="icon"><i class="fas fa-folder"></i></div>
      </div>
    </div>

    <div class="col-lg-3 col-6">
      <div class="small-box bg-info">
        <div class="inner">
          <h3><?= $conn->query("
            SELECT id FROM projects
            WHERE owner_id = $user_id
            AND approval_status = 0
          ")->num_rows ?></h3>
          <p>Borradores</p>
        </div>
        <div class="icon"><i class="fas fa-edit"></i></div>
      </div>
    </div>

  <?php endif; ?>

  </div>
</div>
