   <?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();
    // $Exportword = $SAP->fetc_beneficiariesword(); 
    $Exportword1 = $SAP->fetc_beneficiariesword1();  
    // $Exportword2 = $SAP->fetc_beneficiariesword2(); 
    $Exportword3 = $SAP->fetc_beneficiariesword3(); 

    /////////////////////////////////////////////////

$today = date("Y-m-d-His");

header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=Report-".$today.".doc");

?>

 <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="x-ua-compatible" content="ie=edge">

   <title>SAP Information System</title>
<!--    
   <style type="text/css">
     body{
      font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
      font-size:16px;  
      line-height:1.5;
      margin-top: 0;
      padding: 0;
      margin: 0;
      margin-bottom: 1rem;
     }
   </style> -->
   
   <style type="text/css">
    @import url('https://fonts.googleapis.com/css?family=Slabo+27px');
     body{
     font-family: "Slabo 27px", serif;
     font-size: 1.1rem;
      margin: 0 auto;
      line-height: 1.5;
      margin-bottom: 1rem;
     }
   </style>

</head>
<body>
<center>
<div class="container"><br>
<!--  <table id="word-table" border="1" class="table table-bordered table-striped">

     <thead>
      <tr>
        <th colspan="5"><center> <b>Beneficiaries Income Level</b></center></th>
      </tr>
         <tr>

             <th>No</th>
             <th>Purok</th>
             <th>Full Name</th>
             <th>Age</th>
             <th>IncomeLevel</th>


         </tr>
     </thead>
    <tbody>
   <?php
        foreach($Exportword2 as $word){ ?>

         <tr>

      
             <td><?= ucfirst(htmlentities($word['beneficiaries_id'])); ?></td>
             <td><?= ucfirst(htmlentities($word['purok_no'])); ?></td>
             <td><?= ucfirst(htmlentities(ucwords($word['full_name']))); ?></td>
             <td><?= ucfirst(htmlentities($word['age'])); ?></td>
             <td><?= ucfirst(htmlentities(number_format($word['income'],2))); ?></td>
         </tr>
         <?php $found_rows = true; }  if (!isset($found_rows)) echo "<tr><td colspan ='5'><div class='alert alert-danger' style='font-weight:bold;'>No records found.</div></td></tr>"; 
         ?>

     </tbody>

 </table> -->
<br>
 <table id="word-table" border="1" class="table table-bordered table-striped">
     <thead>
        
          <tr>
           <th colspan="7"><center> <b>Report of Beneficiaries from Barangay Hall San Lucas 1, San Pablo City Laguna</b></center></th>
          </tr>
           <tr>
             <th>No</th>
             <th>Purok</th>
             <th>Full Name</th>
             <th>Age</th>
             <th>Monthly Income Level</th>
             <th>Educational Attainment</th>
              <th>Beneficiaries of</th>



         </tr>
     </thead>
    <tbody>
   <?php
        foreach($Exportword3 as $word){ ?>
         <tr>

      
             <td><?= ucfirst(htmlentities($word['beneficiaries_id'])); ?></td>
             <td><?= ucfirst(htmlentities($word['purok_no'])); ?></td>
             <td><?= ucfirst(htmlentities(ucwords($word['full_name']))); ?></td>
             <td><?= ucfirst(htmlentities($word['age'])); ?></td>
             <td><?= ucfirst(htmlentities($word['monthly_income'])); ?></td>
             <td><?= ucfirst(htmlentities($word['educational_attainment'])); ?></td>
             <td><?= ucfirst(htmlentities($word['benificiaries_of'])); ?></td>
         </tr>
         <?php $found_rows = true; }  if (!isset($found_rows)) echo "<tr><td colspan ='5'><div class='alert alert-danger' style='font-weight:bold;'>No records found.</div></td></tr>"; 
         ?>

     </tbody>

 </table>
<br>
 <table id="word-table" border="1" class="table table-bordered table-striped">
     <thead>
         <tr>
            <th colspan="5"><center> <b>Beneficiaries per Purok</b></center></th>
          </tr>
         <tr>
             <th>Purok</th>
             <th>Beneficiaries per Purok</th>


         </tr>
     </thead>
    <tbody>
   <?php
        foreach($Exportword1 as $word){ ?>
         <tr>

      
             <td><?= ucfirst(htmlentities($word['purok_no'])); ?></td>
             <td><?= ucfirst(htmlentities($word['group_purok'])); ?></td>
         </tr>
         <?php $found_rows = true; }  if (!isset($found_rows)) echo "<tr><td colspan ='5'><div class='alert alert-danger' style='font-weight:bold;'>No records found.</div></td></tr>"; 
         ?>
         <tr>

           <?php 

                $total = 0;
                foreach ($Exportword1 as $rows):
                    $total += htmlentities($rows['group_purok']); ///for order table compute
              ?>
               <?php endforeach ?> 
   
           <td colspan="2">Total: &nbsp;&nbsp;<strong><?php echo $total;  ?></strong></td>

         </tr>

     </tbody>

 </table>
 <br>
<!--  <table id="word-table" border="1" class="table table-bordered table-striped">
     <thead>
          <tr>
            <th colspan="5"><center> <b>Beneficiaries of</b></center></th>
          </tr>
         <tr>

             <th>No</th>
             <th>Purok</th>
             <th>Full Name</th>
             <th>Age</th>
             <th>Beneficiaries of</th>


         </tr>
     </thead>
    <tbody>
   <?php
        foreach($Exportword as $word){ ?>
         <tr>

      
             <td><?= ucfirst(htmlentities($word['beneficiaries_id'])); ?></td>
             <td><?= ucfirst(htmlentities($word['purok_no'])); ?></td>
             <td><?= ucfirst(htmlentities(ucwords($word['full_name']))); ?></td>
             <td><?= ucfirst(htmlentities($word['age'])); ?></td>
             <td><?= ucfirst(htmlentities($word['benificiaries_of'])); ?></td>
         </tr>
         <?php $found_rows = true; }  if (!isset($found_rows)) echo "<tr><td colspan ='5'><div class='alert alert-danger' style='font-weight:bold;'>No records found.</div></td></tr>"; 
         ?>

     </tbody>

 </table> -->
</div>

<br>

</center>
<?php } ?>

 </body>

 </html>