<?php
require_once '../config.php';
$_settings->require_permission('reports','ver');
?>

<div class="row">

    <div class="col-lg-4 col-md-6">
        <div class="info-box bg-gradient-light shadow">
            <span class="info-box-icon bg-secondary"><i class="fas fa-eye"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Proyectos en Seguimiento</span>
                <span class="info-box-number">
                    <?= $conn->query("
                        SELECT id FROM project_list WHERE status=1
                    ")->num_rows ?>
                </span>
            </div>
        </div>
    </div>

    <div class="col-lg-4 col-md-6">
        <div class="info-box bg-gradient-light shadow">
            <span class="info-box-icon bg-danger"><i class="fas fa-exclamation-circle"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Desviaciones</span>
                <span class="info-box-number">
                    <?= $conn->query("
                        SELECT id FROM project_list
                        WHERE status=1 AND avance < 40
                    ")->num_rows ?>
                </span>
            </div>
        </div>
    </div>

</div>
<?php
$ok    = $conn->query("SELECT id FROM project_list WHERE status=1 AND avance >= 50")->num_rows;
$riesgo = $conn->query("SELECT id FROM project_list WHERE status=1 AND avance < 50")->num_rows;
?>

<div class="card mt-4">
    <div class="card-header bg-danger text-white">
        Estado de Proyectos
    </div>
    <div class="card-body">
        <canvas id="supervisorChart"></canvas>
    </div>
</div>

<script>
new Chart(document.getElementById('supervisorChart'), {
    type: 'bar',
    data: {
        labels: ['OK', 'En Riesgo'],
        datasets: [{
            data: [<?= $ok ?>, <?= $riesgo ?>]
        }]
    }
});
</script>
