<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <!-- <h1 class="m-0">Deactive Member </h1> -->
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Check List</a></li>
                    <li class="breadcrumb-item active">Thrift Details </li>
                </ol>
            </div>
        </div>
    </div>
</div>




<section class="content">
    <div class="container-fluid">




        <div class="row">

            <section class="col-lg-12 connectedSortable">

                <div class="card">
                    <div class="card-header " style="background-color:#31708e;color:white">
                        <h3 class="card-title">
                        Edited Thrift Details
                        </h3>
                        <div class="card-tools">
                            <ul class="nav nav-pills ml-auto">
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="tab-content p-0">



                            <?php if (isset($_SESSION['mem_add']) && $_SESSION['mem_add'] != "") { ?>
                                <div class="alert alert-success">
                                    <strong><?php echo $_SESSION['mem_add']; ?></strong>
                                </div>
                            <?php $_SESSION['mem_add'] = "";
                            } ?>

                        </div>
                        <form method="post" action="<?php echo base_url(); ?>index.php/Member/edited_thrift_details" id="member_add_" enctype='multipart/form-data'>
                            <div class="row">
                                <div class="col-sm-3">
                                    <div>Division</div>
                                    <select name="division" id="division_id" class="form-control">
                                        <option value="">All</option>
                                        <?php foreach ($divisions as $div) { ?>
                                            <option value="<?php echo $div['division']; ?>"><?php echo $div['division']; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-sm-3">
                                    <div>Section</div>
                                    <select name="section" id="section_id" class="form-control">
                                        <option value="">All</option>
                                        <?php foreach ($sections as $sec) { ?>
                                            <option value="<?php echo $sec['section']; ?>"><?php echo $sec['section']; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-sm-2">
                                    <div>Month</div>
                                    <?php $m = date('F'); ?>
                                    <select name="month" class="form-control">
                                        <option value="">Select Month</option>
                                        <option <?php if ($m == "January") {
                                                    echo "";
                                                } ?> value="January">January</option>
                                        <option <?php if ($m == "February") {
                                                    echo "";
                                                } ?> value="February">February</option>
                                        <option <?php if ($m == "March") {
                                                    echo "";
                                                } ?> value="March">March</option>
                                        <option <?php if ($m == "April") {
                                                    echo "";
                                                } ?> value="April">April</option>
                                        <option <?php if ($m == "May") {
                                                    echo "";
                                                } ?> value="May">May</option>
                                        <option <?php if ($m == "June") {
                                                    echo "";
                                                } ?> value="June">June</option>
                                        <option <?php if ($m == "July") {
                                                    echo "";
                                                } ?> value="July">July</option>
                                        <option <?php if ($m == "August") {
                                                    echo "";
                                                } ?> value="August">August</option>
                                        <option <?php if ($m == "September") {
                                                    echo "";
                                                } ?> value="September">September</option>
                                        <option <?php if ($m == "October") {
                                                    echo "";
                                                } ?> value="October">October</option>
                                        <option <?php if ($m == "November") {
                                                    echo "";
                                                } ?> value="November">November</option>
                                        <option <?php if ($m == "December") {
                                                    echo "";
                                                } ?> value="December">December</option>
                                    </select>
                                </div>
                                <div class="col-sm-2">Year
                                    <?php $y = date('Y'); ?>
                                    <select name="year" class="form-control">
                                        <option value="">Select Year</option>
                                        <?php for ($j = $y; $j >= 2019; $j--) { ?>
                                            <option <?php if ($j == $y) {
                                                        echo "";
                                                    } ?> value="<?php echo $j; ?>"><?php echo $j; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-sm-2 mt-4"><button type="submit" class="btn btn-primary">Submit</button></div>
                        </form>
                    </div>
                    <?php $member_ft = 0;
                    $tot_os = 0;
                    $tot_pri = 0;
                    $tot_int = 0;
                    $tot_fpri = 0;
                    $tot_fint = 0;
                    $tot_fos = 0;
                    $tot_td = 0;
                    $tot_others = 0;
                    $tot_ins = 0;
                    $tot_recover = 0; ?>
                    <?php if (isset($members) && count($members) > 0) { ?><br><br>
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="tile">
                                        <div class="tile-body">
                                            <table id="table_id" class="table table-striped table-bordered " style="width:100%">
                                                <thead>

                                                    <tr>
                                                        <th class="text-center">S.No.</th>
                                                        <th class="text-center">Mem. No.</th>
                                                        <th class="text-center">Mem. Name</th>
                                                        <th class="text-center">Division</th>
                                                        <th class="text-center">Section</th>
                                                        <th class="text-center">Thrift Amount</th>
                                                        <th class="text-center">Total Thrift Amount</th>
                                                        <th class="text-center">Updated On</th>
                                                    </tr>
                                                    </tr>
                                                </thead>
                                                <!-- Here's where we iterate through our $articles query object, printing out article info -->
                                                <tbody>
                                                    <?php $sno = 0; ?>
                                                    <?php foreach ($members as $key => $member) : ?>
                                                        <?php
                                                        //write query to get thrift from thrfit table by memeber no
                                                     
                                                        $sno = $sno + 1; ?>
                                                            <tr class="text-center">
                                                                <td>
                                                                    <?= $sno; ?>
                                                                </td>
                                                                <td class="text-center">
                                                                    <?= $member->me_no ?>
                                                                </td>
                                                                <td>
                                                                    <?= $member->mem_name ?>
                                                                </td>
                                                                <td>
                                                                    <?= $member->division ?>

                                                                </td>
                                                                <td>
                                                                    <?= $member->section  ?>

                                                                </td>
                                                                <td>
                                                                    <?= $member->thrift_amt  ?>

                                                                </td>
                                                                <td>
                                                                    <?= $member->tot_thrift  ?>

                                                                </td>
                                                                <td>
                                                                    <?= date("d-m-Y", strtotime($member->updated_on));  ?>

                                                                </td>
                                                            </tr>

                                                    <?php endforeach; ?>
                                                  
                                                </tbody>
                                                <tfoot>
            <tr>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
                <th style="text-align:right">Total:</th>
                <th style="text-align:right"></th>
                <th style="text-align:right"></th>
                <th style="text-align:right"></th>
                        </tr>
        </tfoot>
                                            </table>
                </div>
            </div>
        </div>
    </div>
<?php } ?>


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



          
<style>
   div.dt-buttons{
        margin-left: 176px;
    }
    div.dataTables_wrapper div.dataTables_length label {
        position: absolute;
    }
    div.dataTables_wrapper div.dataTables_filter {
        text-align: right;
        margin-top: -37px;
    }

    .copyButton {
background-color: #dc3545;
border: 1px solid white;
}
.excelButton {
background-color: #dc3545;
border: 1px solid white;

}
.pdfButton{
background-color: #dc3545;
border: 1px solid white;

}
.printButton {
background-color: #dc3545;
border: 1px solid white;

}
.colvisButton{
background-color: #dc3545;
border: 1px solid white;

}
</style>
            



<script src="<?php echo base_url() ?>assets/datatables/dataTables.bootstrap.js"></script>
<script src="<?php echo base_url() ?>assets/datatables/jquery.dataTables.js"></script>
<script>

$('.alert').fadeOut(3000);
    var table = $('#table_id').DataTable({

        "footerCallback": function ( row, data, start, end, display ) {
            var api = this.api();
 
            // Remove the formatting to get integer data for summation
            var intVal = function ( i ) {
                return typeof i === 'string' ?
                    i.replace(/[\$,]/g, '')*1 :
                    typeof i === 'number' ?
                        i : 0;
            };
            // Total over all pages
            total = api
                .column( 5 )
                .data()
                .reduce( function (a, b) {
                    return intVal(a) + intVal(b);
                }, 0 );
                totals = api
                .column( 6 )
                .data()
                .reduce( function (a, b) {
                    return intVal(a) + intVal(b);
                }, 0 );

              
            // Total over this page
            pageTotal = api
                .column( 5, { page: 'current'} )
                .data()
                .reduce( function (a, b) {
                    return intVal(a) + intVal(b);
                }, 0 );
                pageTotals = api
                .column(6, { page: 'current'} )
                .data()
                .reduce( function (a, b) {
                    return intVal(a) + intVal(b);
                }, 0 );
                // Total over this page
           
 
            // Update footer
            $( api.column( 5).footer() ).html(
                '<span style="color:blue;display:none">' + pageTotal + '<br> </span>  (' + total +' Total)'
            );
            $( api.column( 6).footer() ).html(
                '<span style="color:blue;display:none">' + pageTotals + '<br> </span>  (' + totals +' Total)'
            );
        },


        "processing": true,
        "dom": 'lBfrtip',
        "lengthMenu": [
            [100, 250, 500, 1000, -1],
            [100, 250, 500, 1000, "All"]
        ],
        "buttons": 
        {
    buttons: [
        { extend: 'copy', className: 'copyButton' },
        { extend: 'excel', className: 'excelButton' },
        { extend: 'pdf', className: 'pdfButton' },
        { extend: 'print', className: 'printButton' },
        { extend: 'colvis', className: 'colvisButton' },
    ]
}
        
    });

    $("div.dataTables_filter input").keyup( function (e) {
        if(table.search()!=""){
            $("span").show();

        }else{
            $("span").hide();

        }
} );
</script>