<!DOCTYPE html>
<?php
session_start();
if (empty($_SESSION['user_name'])) {
    header('Location:login.php');
}
require_once ("db/AppManager.php");
$pm = AppManager::getPM();
?>
<?php include 'fragments/head.php'; ?>
<body style="background: #fff">
    <div id="wrapper">
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index.php">Amazon Survey</a>
            </div>
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <a class="navbar-brand" href="logout.php" style="float: right">Logout</a>
                <ul class="nav navbar-nav side-nav">
                    <li class="">
                        <a href="manage_questions.php"><i class="fa fa-fw fa-dashboard"></i> Manage Questions</a>
                    </li>
                    <li class="">
                        <a href="amazon_key.php"><i class="fa fa-fw fa-key"></i> Amazon Key</a>
                    </li>
                    <li class="active">
                        <a href=""><i class="fa fa-fw fa-list"></i>Charity List</a>
                    </li>
                    <li class="">
                        <a href="#" id="modelpopforpasschange"><i class="fa fa-fw fa fa-cog"></i>Manage Password</a>
                    </li>
                </ul>
            </div>
        </nav>

        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-12">
                        <input class="btn btn-success btn-sm pull-right" id="insertitemtodrop" value="Add" id="insertdropval" readonly="true"> <br><br><br>              
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12" id="needtoreload">
                        <table class="table table-bordered" align="left">
                            <thead>
                                <tr>
                                    <th style="width:15%">ID</th>
                                    <th style="width:70%">Value</th>
                                    <th style="width:15%">Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $results = $pm->fetchResult("select * from charity");
                                $x = 1;
                                foreach ($results as $result) {
                                    $id = $result['id'];
                                    $pagnumber = $result['value'];
                                    echo "<tr>";
                                    echo "<td>" . $x . "</td>";
                                    echo "<td>" . $pagnumber . "</td>";
                                    echo "<td><span><input class='btn btn-info btn-sm editdrop' readonly='false' value='Edit' data-id='" . $id . "'  style='width:45%'></span>&nbsp;<span><input class='btn btn-danger btn-sm deletedrop' readonly='false' value='Delete'  data-id='" . $id . "' style='width:45%'></span></td>";
                                    echo "</tr>";
                                    $x++;
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <?php include 'fragments/modal.php'; ?>
        </div>
    </div>
    <?php include 'fragments/js.php'; ?>
</body>
</html>





