<?php $this->load->view("common/header"); ?>
<body>
  <div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button"> <span class="clip-list-2"></span> </button>
        <?php $this->load->view("common/logo"); ?>
      </div>
      <div class="navbar-tools">
        <?php $this->load->view("common/notifications.php"); ?>
      </div>
    </div>
  </div>
  <div class="main-container">
    <div class="navbar-content">
      <?php $this->load->view("common/navigation"); ?>
    </div>
    <div class="main-content">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <ol class="breadcrumb">
                    <li><a href="<?php echo base_url('dashboard'); ?>">Dashboard</a></li>
                    <li><a href="#">Reports</a></li>
                    <li class="active">Customers – No Repeat Loan</li>
                </ol>
                <div class="page-header">
                    <h1>Customers Who Have Not Obtained a Loan Again</h1>
                </div>
                <p>List of customers whose last loan is fully paid and have not taken any new loan afterward.</p>
            </div>
        </div>

        <!-- Printable Header -->
        <div id="printableArea" style="display:none;">
            <h4 style="margin:0;">Customers Who Have Not Obtained a Loan Again</h4>
            <p style="margin-top:5px; font-size:14px;">Generated on: <?php echo date('d M Y'); ?></p>
        </div>

        <!-- Data Table -->
        <table class="table table-bordered table-hover table-condensed dataTable" id="no_repeat_table">
            <thead>
                <tr>
                    <th width="8%">#</th>
                    <th>Customer Name</th>
                    <th>Last Loan #</th>
                    <th>Last Loan Date</th>
                    <th class="text-center">Terms</th>
                </tr>
            </thead>
            <tbody>
                <?php if (!empty($report)): ?>
                    <?php $i = 1; foreach ($report as $row): ?>
                        <tr>
                            <td><?php echo $i++; ?></td>
                            <td><?php echo htmlspecialchars($row['customer_name']); ?></td>
                            <td><?php echo htmlspecialchars($row['last_loan_number']); ?></td>
                            <td><?php echo date('d M Y', strtotime($row['last_loan_date'])); ?></td>
                            <td class="text-center"><?php echo $row['loan_no_of_terms']; ?></td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr>
                        <td colspan="5" class="text-center text-muted">
                            No customers found who have fully repaid their last loan without taking a new one.
                        </td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
    <div class="footer clearfix">
      <div class="footer-inner"> <?php echo date("Y"); ?> &copy; A.S.S.K Loan Management System </div>
      <div class="footer-items"> <span class="go-top"><i class="clip-chevron-up"></i></span> </div>
    </div>
    <?php $this->load->view("common/footer"); ?>
    <script src="<?php echo asset_url(); ?>js/jquery-ui.js"></script>
    <script src="<?php echo asset_url(); ?>js/moment-with-locales.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/bootbox.min.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.min.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/dataTables.bootstrap.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js"></script>
   <script>
$(document).ready(function () {
    $('#no_repeat_table').DataTable({
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'print',
                text: 'Print Report',
                title: '',
                messageTop: function () {
                    return $('#printableArea').html();
                },
                exportOptions: {
                    columns: [0, 1, 2, 3, 4]
                },
                customize: function (win) {
                    $(win.document.body).css('font-size', '12pt');
                    $(win.document.body).find('table').addClass('compact').css('font-size', 'inherit');
                }
            }
        ],
        pageLength: 25,
        order: [[1, 'asc']],
        language: {
            emptyTable: "No customers match the criteria."
        }
    });
});
</script>

<style>
@media print {
    #printableArea { display: block !important; }
    .dataTables_wrapper .dt-buttons { display: none; }
}
</style>
</body>
</html>