<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="#">Receipt Details</a></li>
                    <li class="breadcrumb-item active">All Receipt</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">
                        All Receipt 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'] = "";
                            } ?>

                        <form method="post" action="<?php echo base_url(); ?>index.php/Demand/division_receipts" id="member_add_" enctype='multipart/form-data'>
                            <div class="row">
                                <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 >= 2022; $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($divsec) && count($divsec) > 0) { ?><br><br>
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="tile">
                                    <div class="tile-body">
                                        <table id="table_id1" class="table table-striped table-bordered" style="width:100%">
                                            <thead>
                                                <tr>
                                                    <th class="text-center">S No.</th>
                                                    <th class="text-center">Division</th>
                                                    <th class="text-center">share</th>
                                                    <th class="text-center">Books & Forms</th>
                                                    <th class="text-center">Entry Fees</th>
                                                    <th class="text-center">Thrift</th>
                                                    <th class="text-center">Principal</th>
                                                    <th class="text-center">Interest</th>
                                                    <!-- <th class="text-center">Fl Pri</th>
                                                    <th class="text-center">FL Int</th> -->
                                                    <th class="text-center">P.Int</th>
                                                    <th class="text-center">Others</th>
                                                    <th class="text-center">Due By</th>
                                                    <th class="text-center">Total</th>
                                                    <th class="text-center">Action</th>
                                                </tr>
                                            </thead>

                                            <tbody>



                                                <!-- 
$section = $div['section'];
$tot_thrift += $div['thrift_amt'];
$tot_pri += $div['loan_pri_amt'];
$tot_int += $div['loan_int_amt'];
$tot_flpri += $div['f_pri'];
$tot_flint += $div['f_int'];
$tot_ins += $div['insurance'];
$tot_others += $div['others'];
$total += $div['thrift_amt'] + $div['loan_pri_amt'] + $div['loan_int_amt'] + $div['f_pri'] + $div['f_int'] +  $div['insurance'] + $div['others'];
$paid = $div['paid_on'];
?> -->
                                                <?php $sno = 0;  ?>

                                                <?php foreach ($divsec as $div) { ?>

                                                    <?php $sno = $sno + 1;   ?>
                                                    <tr>

                                                        <td class="text-center">
                                                            <?= $sno; ?>
                                                        </td>
                                                        <td>
                                                            <?= $div['division']; ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['share_amt'] != " ") { ?>
                                                                <?= $div['share_amt']; ?>
                                                                <?php $share += $div['share_amt']; ?>

                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['books'] != " ") { ?>
                                                                <?= $div['books']; ?>
                                                                <?php $books += $div['books']; ?>

                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['ent_fees'] != " ") { ?>
                                                                <?= $div['ent_fees']; ?>
                                                                <?php $ent_fees += $div['ent_fees']; ?>

                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['thrift_amt'] != " ") { ?>
                                                                <?= $div['thrift_amt'] +  $div['old_thrift']; ?>
                                                                <?php $thrift += $div['thrift_amt'] +  $div['old_thrift'] ; ?>

                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['loan_pri_amt'] != " " || $div['last_principal'] != " "  || $div['ex_os']  != " " ||  $div['os_pay'] != " " ) { ?>
                                                                <?php $loan_pri_amt += $div['loan_pri_amt'] + $div['last_principal'] +  $div['ex_os'] +  $div['os_pay']; ?>
                                                                <?= $div['loan_pri_amt']+ $div['last_principal'] +  $div['ex_os'] +  $div['os_pay']; ?>
                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['loan_int_amt'] != " " ||  $div['last_int'] != " ") { ?>
                                                                <?php $loan_int_amt += $div['loan_int_amt'] + $div['last_int']; ?>
                                                                <?= $div['loan_int_amt'] + $div['last_int']; ?>
                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <!-- <td class="text-center">
                                                            <?php if ($div['f_pri'] != " " || $div['f_old_pri'] != " " || $div['f_ex_os'] != " " || $div['f_os_pay'] != " ") { ?>
                                                                <?php $f_pri_amt += $div['f_pri'] + $div['f_old_pri'] +  $div['f_ex_os'] +  $div['f_os_pay']; ?>
                                                                <?= $div['f_pri']+ $div['f_old_pri'] +  $div['f_ex_os'] +  $div['f_os_pay']; ?>
                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['f_int'] != " " || $div['f_old_int'] != " ") { ?>
                                                                <?php $f_int_amt += $div['f_int'] + $div['f_old_int']; ?>
                                                                <?= $div['f_int'] + $div['f_old_int']; ?>
                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td> -->
                                                        <td class="text-center">
                                                            <?php if ($div['p_int'] != " " || $div['old_p_int'] != " " || $div['f_p_int'] != " " ) { ?>
                                                                <?php $tot_p_int += $div['p_int'] +  $div['old_p_int'] +  $div['f_p_int']; ?>
                                                                <?= $div['p_int'] +  $div['old_p_int'] +  $div['f_p_int']; ?>
                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['others'] != " ") { ?>
                                                                <?php $others += $div['others']; ?>
                                                                <?= $div['others']; ?>
                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td class="text-center">
                                                            <?php if ($div['due_by'] != " ") { ?>
                                                                <?= $div['due_by']; ?>
                                                                <?php $due_by += $div['due_by']; ?>

                                                            <?php } else { ?>
                                                                <?php echo 0; ?>
                                                            <?php } ?>
                                                       
                                                        </td>
                                                        <td class="text-center">
                                                            <?= $total = $div['tot_pay']; ?>
                                                            <?php $totals += $div['tot_pay'] ;?>
                                                        </td>
                                                        <!-- <td class="text-center">
                                                            <?= date('d-m-Y', strtotime($div['paid_on'])); ?>

                                                        </td> -->

                                                        <td class="text-center">
                                                            <form method="post" action="<?php echo base_url(); ?>index.php/Demand/div_reciept" id="rec_form" enctype='multipart/form-data' target="_blank">
                                                                <input type="hidden" value="<?php echo  $div['division']; ?>" name="division">

                                                                <input type="hidden" value="<?php echo $div['share_amt']; ?>" name="share_amt">
                                                                <input type="hidden" value="<?php echo $div['books']; ?>" name="books">
                                                                <input type="hidden" value="<?php echo $div['ent_fees']; ?>" name="ent_fees">
                                                                <input type="hidden" value="<?php echo $div['thrift_amt']; ?>" name="thrift_amt">
                                                                <input type="hidden" value="<?php echo $div['loan_pri_amt'] + $div['last_principal'] +  $div['ex_os'] +  $div['os_pay']; ?>" name="loan_pri_amt">
                                                                <input type="hidden" value="<?php echo $div['loan_int_amt'] + $div['p_int'] + $div['old_p_int'] + $div['last_int']; ?>" name="loan_int_amt">
                                                                
                                                                <input type="hidden" value="<?php echo $div['f_pri'] + $div['f_old_pri'] +  $div['f_ex_os'] +  $div['f_os_pay']; ?>" name="fl_pri_amt">
                                                                <input type="hidden" value="<?php echo $div['f_int'] + $div['f_old_int'] + $div['f_p_int'] ?>" name="fl_int_amt">
                                                                
                                                                <input type="hidden" value="<?php echo $div['others']; ?>" name="others">
                                                                <input type="hidden" value="<?php echo $div['due_by']; ?>" name="due_by">

                                                                <input type="hidden" value="<?php echo $div['paid_on']; ?>" name="paidon">
                                                                <input type="hidden" value="<?php echo $total; ?>" name="total">
                                                                <button style="color:white;" class='btn btn-primary btn-xs'><span class="fa fa-search"></span><span class="sr-only">View</span></button>
                                                            </form>
                                                        </td>

                                                    </tr>
                                                    

                                                <?php } ?>
                                            
                                            </tbody>
                                            <tfoot>
                                            <tr>
                                                        <td class="text-center"></td>
                                                        <td class="text-center"></td>

                                                        <td class="text-center"> <b><?= $share; ?></b></td>
                                                         <td class="text-center"><b> <?= $books; ?></b></td>
                                                          <td class="text-center"> <b><?= $ent_fees; ?></b></td>
                                                        <td class="text-center"> <b><?= $thrift; ?></b></td>

                                                        <td class="text-center"> <b><?= $loan_pri_amt; ?></b></td>

                                                        <td class="text-center"> <b><?= $loan_int_amt; ?></b></td>

                                                        <!-- <td class="text-center"> <b><?= $f_pri_amt; ?></b></td>

                                                        <td class="text-center"> <b><?= $f_int_amt; ?></b></td> -->
                                                        <td class="text-center"> <b><?= $tot_p_int; ?></b></td>

                                                        <td class="text-center"><b> <?= $others; ?></b></td>
                                                        <td class="text-center"> <b><?= $due_by; ?></b></td> 
                                                        <!-- <td class="text-center"><b> <?= $share + $books + $tot_p_int +$ent_fees+ $thrift+ $loan_pri_amt+ $books+ $loan_int_amt+$f_pri_amt+$f_int_amt; ?></b></td> -->
                                                        <td class="text-center"><b> <?= $totals; ?></b></td>

                                                        <td class="text-center">
                                                            </td>

                                                            
                                                    </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>
    var table = $('#table_id1').DataTable({
        "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' },
    ]
}
        
    });
</script>