<?php include('../includes/db_conx.php');

isset($_SESSION['detect_login']);
if (!isset($_SESSION['detect_login'])) {
    header("location: ../online/customer_login");
    exit();
} else {
    $id = $_SESSION['id'];
    // echo $id;
    // get all the varible from the database for personal information 
    include('../includes/cus-info.php');

    include('../includes/dash-header.php');
}
?>

<link rel="stylesheet" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.css" />

<script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>

<body>
    <?php
    include('../includes/side-nav.php');
    ?>
    <div class="main-content" id="panel">
        <!-- Topnav -->
        <?php
        include('../includes/top-nav.php');
        ?>

        <div class="header pb-4">
            <div class="container-fluid">
                <div class="header-body">
                </div>
            </div>
        </div>
        <br>
        <br>
        <!-- header end -->

        <div class="container-fluid mt--6">
            <div class="content-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card bg-white">
                            <div class="card-body">
                                <div class="">
                                    <h3 class="">Loan history</h3>
                                    <p class="mt-0 mb-5">This is your loan statement page, always keep track for your account Loan History</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card bg-white shadow">
                            <div class="card-header bg-transparent">
                                <div class="row align-items-center">
                                    <div class="col-8">
                                        <!-- Title -->
                                        <h3 class="mb-0 text-dark">Loan timeline</h3>
                                    </div>
                                    <div class="col-4 text-right">
                                        <a href="javascript:void;" onclick="window.print();" class="btn btn-sm btn-neutral">Print</a>
                                    </div>
                                </div>
                            </div>
                            <div class="card-body ">
                                <div class="" style='overflow:scroll'>
                                    <table id="myTable" class="display ">
                                        <thead>
                                            <tr>
                                                <th>Name</th>
                                                <th>Amount</th>
                                                <th>Reason</th>
                                                <th>Type</th>
                                                <th>Duration</th>
                                                <th>Date</th>
                                                <th>Status</th>
                                            </tr>
                                        </thead>

                                        <?php
                                        while ($row_trans_loan = mysqli_fetch_assoc($query_trans_loan)) {
                                            $name = $row_trans_loan['name'];
                                            $loan_amount = $row_trans_loan['loan_amount'];
                                            $reason = $row_trans_loan['reason'];
                                            $type = $row_trans_loan['type'];
                                            $tenure = $row_trans_loan['tenure'];
                                            $loan_date = $row_trans_loan['loan_date'];
                                            $loan_status = $row_trans_loan['loan_status'];
                                            $means_of_identification = $row_trans_loan['means_of_identification'];
                                            $photo = $row_trans_loan['photo'];



                                        ?>

                                            <?php
                                            if ($trans_no <= 0) {
                                                echo '<div class="alert alert-info" role="alert">
                                                       No records found
                                                    </div>';
                                            } else {
                                            ?>
                                                <tbody>
                                                    <tr>
                                                        <td><?= $name ?></td>
                                                        <td>$<?php echo number_format($loan_amount, 2) ?></td>
                                                        <td><?= $reason ?></td>
                                                        <td><?= $type ?></td>
                                                        <td><?= $tenure ?></td>
                                                        <td><?= $loan_date ?></td>
                                                        <td><?php
                                                            if ($loan_status == 0) {
                                                                echo 'Pending';
                                                            } else {
                                                                echo 'Approved';
                                                            }

                                                            ?></td>
                                                    </tr>

                                                </tbody>
                                        <?php
                                            }
                                        }

                                        ?>
                                    </table>


                                </div>
                            </div>
                        </div>
                    </div>
                </div>


                <!-- footer begin -->
                <footer class="footer pt-0">

                </footer>
            </div>
        </div>
        <?php
        include('../includes/dash_footer.php') ?>

</body>


<!-- -->

</html>


<script type="text/javascript">
    $('.preloader').fadeOut(1000);
</script>
<script type="text/javascript">
    "use strict";

    function sellVals() {
        var amount1 = $("#amount1").val();
        var asset_price1 = $("#asset_price1").find(":selected").text();
        var myarr1 = asset_price1.split("-");
        var dar1 = myarr1[1].split("<");
        var rate1 = parseFloat(dar1) * parseFloat(amount1 / 1);
        $("#gain1").val(rate1);
    }
    $("#amount1").change(sellVals);
    sellVals();
    $("#asset_price1").change(sellVals);
    sellVals();
</script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#myTable').DataTable();
    });
</script>