   <?php

   session_start();

    include_once('../../config/conn/db-connection.php');
    include_once('../../config/class/sap_model.php');


   if(!isset($_SESSION['logged_in']))
    {
       header("location:../../index.php");
    }else{

    $user_session = trim($_SESSION['user_no']);
    $SAP = new SAP_infosytem();
    $countbeneficiaries = $SAP->count_beneficiaries();
    $counthousehold = $SAP->count_household();   
    $countbeneficiariessesenior = $SAP->count_beneficiariessesenior();    
    $countbeneficiariesfemale = $SAP->count_beneficiariesfemale(); 
    $countbeneficiariesmale = $SAP->count_beneficiariesmale();  
    $countsapform = $SAP->count_sapform();          

?>

<?php include '../header/main-header2.php';?>
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">Dashboard</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active">Dashboard</li>
            </ol>
          </div>
        </div>
      </div>
    </div>

    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-users"></i></span>
             <?php
              foreach($countbeneficiaries as $beneficiary){ ?>
              <div class="info-box-content">
                <span class="info-box-text">Total Beneficiaries</span>
                <span class="info-box-number">
                  <a href="Beneficiaries-group.php?beneficiaries-group=<?= htmlentities($beneficiary['beneficiaries_id']); ?>"> <?= htmlentities(number_format($beneficiary['beneficiaries_id'])); ?></a>
                </span>
              </div>
            </div>
            <?php } ?>
          </div>
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-house-user"></i></span>
             <?php
              foreach($counthousehold as $counthouseh){ ?>
              <div class="info-box-content">
                <span class="info-box-text">Total Household </span>
                <span class="info-box-number">
                   <a href="household-group.php?household-group=<?= htmlentities($counthouseh['household_id']); ?>"><?= htmlentities(number_format($counthouseh['household_id'])); ?></a>
                </span>
              </div>
            </div>
          <?php } ?>
          </div>
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-user"></i></span>
             <?php
              foreach($countbeneficiariessesenior as $senior){ ?>
              <div class="info-box-content">
                <span class="info-box-text">Total Senior </span>
                <span class="info-box-number">
                 <a href="beneficiariessenior-group.php?beneficiariessenior-group=<?= htmlentities($senior['senior']); ?>"><?= htmlentities(number_format($senior['senior'])); ?></a>
                </span>
              </div>
            </div>
            <?php } ?>
          </div>
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-female"></i></span>
             <?php
              foreach($countbeneficiariesfemale as $female){ ?>
              <div class="info-box-content">
                <span class="info-box-text">Total Female </span>
                <span class="info-box-number">
                    <a href="beneficiariesfemale-group.php?beneficiariesfemale-group=<?= htmlentities($female['fmale']); ?>"><?= htmlentities(number_format($female['fmale'])); ?></a>
                </span>
              </div>
            </div>
             <?php } ?>
          </div>
        </div>

<!---/////////////////////////////////////////////////////////////////--->

        <div class="row">
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-male"></i></span>
            <?php
              foreach($countbeneficiariesmale as $male){ ?>
              <div class="info-box-content">
                <span class="info-box-text">Total Male </span>
                <span class="info-box-number">
                  <a href="beneficiariesmale-group.php?beneficiariesmale-group=<?= htmlentities(number_format($male['male'])); ?>"><?= htmlentities(number_format($male['male'])); ?></a>
                </span>
              </div>
            </div>
            <?php } ?>
          </div>
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-file-alt"></i></span>
              <?php
              foreach($countsapform as $sap){ ?>
              <div class="info-box-content">
                <span class="info-box-text">Total SAP Form </span>
                <span class="info-box-number">
                   <a href="sapformapproved-group.php?sapformapproved-group=<?= htmlentities($sap['stat_approved']); ?>"><?= htmlentities(number_format($sap['stat_approved'])); ?></a>
                </span>
              </div>
             <?php } ?>
            </div>
          </div>

     
 <!--     <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-cog"></i></span>

              <div class="info-box-content">
                <span class="info-box-text">CPU Traffic</span>
                <span class="info-box-number">
                  10
                  <small>%</small>
                </span>
              </div>
            </div>
          </div>
 
          <div class="col-12 col-sm-6 col-md-3">
            <div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-cog"></i></span>

              <div class="info-box-content">
                <span class="info-box-text">CPU Traffic</span>
                <span class="info-box-number">
                  10
                  <small>%</small>
                </span>
              </div>
            </div>
          </div> -->
          <!-- /.col -->
          
        </div>
        <!-- /.row -->
      </div>
    </section>
  </div>
<?php } ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  <footer class="main-footer">
    <strong>Copyright &copy; 2021 <b>SAP Information System </b>.</strong>
    All rights reserved.
    <div class="float-right d-none d-sm-inline-block">
      <b>Version</b> 1.0.0
    </div>
  </footer>
</div>


   <script src="../../plugins/jquery/jquery.min.js"></script>
   <script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
   <script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
   <script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
   <script src="../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
   <script src="../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
   <script src="../../dist/js/adminlte.min.js"></script>
   <script src="../../dist/js/demo.js"></script>

</body>
</html>
