<?php
session_start();
?>
<!DOCTYPE html>
<html>

<head>
    <title>Polytical Edge | Manage Income</title>
    <?php include 'css.php';
  include './assets/database/fetch.php'; ?>
</head>

<body>
    <div class="main-wrapper">
        <?php $currentPage = 'data-table';
    include 'sidebar.php'; ?>
        <div class="page-wrapper">
            <?php include 'header.php'; ?>
            <div class="page-content">
                <div class="row">
                    <div class="col-md-12 grid-margin stretch-card">
                        <div class="card add-row">
                            <div class="card-body">
                                <h6 class="card-title">Manage Reports
                                    <?php if ($_SESSION['role'] == 'Admin'){?>
                                    <a href="add-report.php" class="add-element add-element btn ml-5 btn-primary">Add
                                        Report</a><a href="add-bulk-report.php"
                                        class="add-element add-element btn btn-primary">Add Bulk Report</a>
                                    <?php }?>
                                </h6>
                                <div class="table-responsive">
                                    <table id="dataTableExample" class="table text-center">
                                        <thead>
                                            <tr>
                                                <th>Sr.no</th>
                                                <th>Report Name</th>
                                                <th>Date & Time</th>
                                                <th>Rows Inserted</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                      $data = fetch_reports();
                      $count = 1;
                      foreach ($data as $key => $values) {
                        echo '
                      <tr>
                        <td>' . $count . '</td>
                        <td>' . $values['report_title'] . '</td>
                        <td>' . $values['date_and_time'] . '</td>
                        <td>' . $values['rows'] . '</td>
                        <td>
                          <a href="edit-report.php?id=' . $values['id'] . '" class="edit btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                          <a href="delete-report.php?id=' . $values['id'] . '" class="delete btn btn-danger"><i class="fa fa-trash" aria-hidden="true"></i></a>
                          <a href="view-report.php?id=' . $values['id'] . '" class="delete btn btn-info"><i class="fa fa-eye" aria-hidden="true"></i></a>
                        </td>
                      </tr>';
                        $count++;
                      } ?>
                                            <tr>
                                                <td colspan="1" class="text-right font-weight-bold">Total Reports:</td>
                                                <td colspan="2" class="text-left font-weight-bold">110</td>
                                                <td colspan="4" class="text-right font-weight-bold">Total rows:</td>
                                                <td colspan="2" class="text-left font-weight-bold">12200</td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include 'footer.php'; ?>
            <?php include 'js.php'; ?>
        </div>
    </div>
</body>

</html>