<?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="">
                        <a href="charity_list.php"><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>
					<li class="active">
                            <a href="sort_link.php"><i class="fa fa-fw fa fa-cog"></i>Manage Sort link</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="insert_ASIN_sortURL" 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:25%">ASIN</th>
                                    <th style="width:60%">LINK</th>
                                    <th style="width:15%">Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $results = $pm->fetchResult("select * from sortlink_asin");
                                $x = 1;
                                foreach ($results as $result) {
                                    $asin = $result['ASIN'];
                                    $sort_link = $result['sort_link'];
                                    echo "<tr>";
                                    echo "<td>" . $asin. "</td>";
                                    echo "<td>" . $sort_link . "</td>";
                                    echo "<td><span><input class='btn btn-info btn-sm edit_URL_ASIN' readonly='false' value='Edit' data-asin='" . $asin . "'  style='width:45%'></span>&nbsp;<span><input class='btn btn-danger btn-sm delete_URL_ASIN' readonly='false' value='Delete'  data-asin='" . $asin . "' 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>





