<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <!-- <h1 class="m-0">Demand Generate</h1> -->
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Demand</a></li>
                    <li class="breadcrumb-item active">Demand Generate</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 no-print">
                            Demand Generate
                        </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'] = "";
                            } ?>

                            <?php if (isset($_SESSION['lesser']) && $_SESSION['lesser'] != "") { ?>
                                <div class="alert1 alert-danger">
                                    <strong><?php echo $_SESSION['lesser']; ?></strong>
                                </div>
                            <?php $_SESSION['lesser'] = "";
                            } ?>
                            <!-- <ol class="breadcrumb">
                                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>&nbsp;
                                <li class="active">Demand</li>
                               
                            </ol> -->
                            <form method="post" action="<?php echo base_url(); ?>index.php/Demand/demand_generate" id="member_add_" enctype='multipart/form-data'>
                                <div class="row no-print">
                                    <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 <?php if ($div['division'] == $division) {
                                                            echo "selected";
                                                        } ?> 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 <?php if ($section != "" && $div['section'] == $section) {
                                                            echo "selected";
                                                        } ?> 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" id="month_id">
                                            <option value="">Month</option>
                                            <option <?php if ($month == "January") {
                                                        echo "selected";
                                                    } ?> value="January">January</option>
                                            <option <?php if ($month == "February") {
                                                        echo "selected";
                                                    } ?> value="February">February</option>
                                            <option <?php if ($month == "March") {
                                                        echo "selected";
                                                    } ?> value="March">March</option>
                                            <option <?php if ($month == "April") {
                                                        echo "selected";
                                                    } ?> value="April">April</option>
                                            <option <?php if ($month == "May") {
                                                        echo "selected";
                                                    } ?> value="May">May</option>
                                            <option <?php if ($month == "June") {
                                                        echo "selected";
                                                    } ?> value="June">June</option>
                                            <option <?php if ($month == "July") {
                                                        echo "selected";
                                                    } ?> value="July">July</option>
                                            <option <?php if ($month == "August") {
                                                        echo "selected";
                                                    } ?> value="August">August</option>
                                            <option <?php if ($month == "September") {
                                                        echo "selected";
                                                    } ?> value="September">September</option>
                                            <option <?php if ($month == "October") {
                                                        echo "selected";
                                                    } ?> value="October">October</option>
                                            <option <?php if ($month == "November") {
                                                        echo "selected";
                                                    } ?> value="November">November</option>
                                            <option <?php if ($month == "December") {
                                                        echo "selected";
                                                    } ?> value="December">December</option>
                                        </select>
                                    </div>

                                    <div class="col-sm-1">
                                        <div>Year</div>
                                        <?php $y = date('Y'); ?>
                                        <select name="year" class="form-control" id="year_id">
                                            <option value="">Select Year</option>
                                            <?php for ($j = $y; $j >= 2023; $j--) { ?>
                                                <option <?php if ($j == $year) {
                                                            echo "selected";
                                                        } ?> value="<?php echo $j; ?>"><?php echo $j; ?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                    <!-- <div class="col-sm-1">
                                        <div>Days</div>
                                        <select name="month_days" class="form-control">
                                            <option value="">Days</option>
                                            <option <?php if ($month_days == "28") {
                                                        echo "selected";
                                                    } ?> value="28">28</option>
                                            <option <?php if ($month_days == "29") {
                                                        echo "selected";
                                                    } ?> value="29">29</option>
                                            <option <?php if ($month_days == "30") {
                                                        echo "selected";
                                                    } ?> value="30">30</option>
                                            <option <?php if ($month_days == "31") {
                                                        echo "selected";
                                                    } ?> value="31">31</option>
                                        </select>
                                    </div> -->
                                    <div class="col-sm-1 mt-4"><button type="submit" onclick="this.disabled=true;this.value='Submitting...'; this.form.submit();" class="btn btn-primary">Submit</button></div>
                                </div>
                            </form>
                            <?php $sno = 0;
                            $member_ft = 0;
                            $tot_os = 0;
                            $tot_pri = 0;
                            $tot_int = 0;
                            $tot_p_int = 0;
                            $tot_od_int = 0;
                            $tot_fpri = 0;
                            $tot_fint = 0;
                            $tot_fod_int = 0;
                            $tot_f_P_int = 0;
                            $tot_fos = 0;
                            $tot_td = 0;
                            $tot_ins = 0;
                            $tot_total = 0;
                            $tot_others = 0;
                            $tot_loan_amount = 0; ?>

                            <?php if (isset($members) && count($members) > 0) { ?>
                                <br><br>
                                <div class="row mt-3 " style="margin-left: 0px; margin-right: 0px;">
                                    <div class="col-sm-12 print-container" id="printableArea">
                                        <div class="tile">
                                            <div class="tile-body ">
                                                <div class="row mb-2">
                                                    <div class="col-sm-12 text-center ">
                                                        <h5><b><?php echo $common[0]['society_title']; ?></b></h5>
                                                    </div>
                                                </div>
                                                <div class="row mb-2">
                                                    <div class="col-sm-2">

                                                    </div>
                                                    <div class="col-sm-8 text-center">
                                                        <b>FORM 29</b>
                                                    </div>
                                                    <div class="col-sm-2 float-left">
                                                        <b> <?php echo date("d-m-Y"); ?></b>
                                                    </div>
                                                </div>
                                                <p>See Sub Rule (2) of the Tamil Nadu Co-Op. Societies Act) (form of requisition under Sub-Section (2) of Section 49 of the Tamil Nadu Co-Op. Societies Act 1983) Tamil Nadu Act 30 of 1983 from a society to an employer or Officer disbursing the salary of a member of such society for deducting the amount to it from
                                                    the salary payable to such member</p>

                                                <p>Sir,</p>
                                                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;With reference to the agreement executed by the following members of our society authorising you to deduct from their salary the amounts due from them to the society. We request you to be good enough to recover from their salary for the month of <?php echo $month . " " . $year; ?> the following amounts due from them to the society. We request that the amount recovered may be remitted to our society on or before 5th of next month. The duplicate copy of this demand list may be returned furnishing the details of recoveries effect." </p>


                                                <div class="row mb-2">

                                                    <div class="col-sm-4">
                                                        <b>Demand-<?php echo $month . " - " . $year; ?></b>
                                                    </div>
                                                    <div class="col-sm-5 text-center">
                                                        <b></b>
                                                    </div>
                                                    <div class="col-sm-3 float-left">
                                                        <b>
                                                            <p id="div_sec"><?php echo $division; ?></p>
                                                        </b>
                                                    </div>
                                                </div>

                                                <form>
                                                    <div class="row no-print">
                                                        <div class="col-sm-1">
                                                            <input type="submit" name="export" id="export" class="btn btn-success" value="Export" />

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

                                                <br><br>

                                                <div class="row no-print">
                                                    <div class="col-sm-8">
                                                        <h5><b><?php echo $address; ?></b></h5>
                                                    </div>
                                                    <div class="col-sm-2 text-center">

                                                    </div>
                                                    <div class="col-sm-2 float-left">

                                                    </div>
                                                </div>

                                                <table id="excel_id" class="table table-striped table-bordered ">
                                                    <thead>
                                                        <tr>
                                                            <th class="text-center">S.No.</th>
                                                            <th class="text-center">M. No.</th>
                                                            <th class="text-center">Name</th>
                                                            <th class="text-center">Desig</th>
                                                            <!-- <th class="text-center">Tot thrift</th> -->
                                                            <th class="text-center">Loan OS</th>
                                                            <th class="text-center">Dues</th>
                                                            <th class="text-center">Pri.</th>
                                                            <th class="text-center">%</th>
                                                            <th class="text-center">Int.</th>
                                                            <th class="text-center">P.Int.</th>
                                                            <!-- <th class="text-center">FL OS</th>
                                                            <th class="text-center">FL Pri.</th>
                                                            <th class="text-center">FL %</th>
                                                            <th class="text-center">FL Int.</th>
                                                            <th class="text-center">FP.Int.</th> -->
                                                            <th class="text-center">Thrift</th>
                                                            <th class="text-center">Ins</th>
                                                            <th class="text-center">Others</th>
                                                            <th class="text-center">Total</th>
                                                            <th class="text-center">Recovered</th>
                                                        </tr>
                                                    </thead>

                                                    <tbody>

                                                        <form method="post" action="<?php echo base_url(); ?>index.php/Demand/demand_generate" id="member_add_" enctype='multipart/form-data'>
                                                            <?php
                                                            $pre_section = "";
                                                            if ($division != "") {
                                                                foreach ($members as $key => $member) :
                                                                    // print_r($member);
                                                                    // die;
                                                                    $member = (object) $member;
                                                                    if ($pre_section != $member->section) {
                                                            ?>

                                                                        <tr>
                                                                            <td></td>
                                                                            <td style="color:blue;" colspan="2"><b><?php echo $member->section; ?></b></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <!-- <td></td> -->
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <!-- <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td> -->
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                            <td></td>
                                                                        </tr>
                                                                    <?php
                                                                    }
                                                                    $pre_section = $member->section;
                                                                    $sno = $sno + 1; ?>
                                                                    <?php if ($member->loan_os_amt > $member->loan_principle_amt || $member->loan_os_amt == "0" || $member->loan_os_amt == $member->loan_principle_amt) { ?>
                                                                        <tr>
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $sno; ?>
                                                                            </td>
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $member->me_no ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][me_no]" ?>" value="<?php echo $member->me_no ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_name ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_desig ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;">
                                                                                <?= $member->tot_thrift ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_os_amt">
                                                                                <?php if ($member->loan_os_amt != "") { ?>
                                                                                    <?= $member->loan_os_amt ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td class="text-right" style="padding:5px; margin:0px;">
                                                                                <?php if ($member->loan_instalment  != "0" ||   $member->curr_instalment != "0") { ?>
                                                                                    <?= $member->curr_instalment . '/' . $member->loan_instalment ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_principle_amt">
                                                                                <?php if ($member->loan_principle_amt > 0) { ?>
                                                                                    <?php echo $member->loan_principle_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_principal]" ?>" value="<?php echo $member->loan_principle_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_principal]" ?>" value="<?php echo $member->old_due_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_amount]" ?>" value="<?php echo $member->loan_amount ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_os]" ?>" value="<?php echo $member->loan_os_amt ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_os_amt > 0) { ?>
                                                                                    <?= $member->loan_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_int_amt > 0) { ?>
                                                                                    <?php echo $member->loan_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][p_int]" ?>" value="<?php echo $member->old_pri_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_int]" ?>" value="<?php echo $member->old_due_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_p_int]" ?>" value="<?php echo $member->old_p_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->old_pri_int > 0) { ?>
                                                                                    <?php echo $member->old_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_os ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_os]" ?>" value="<?php echo $member->f_os ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri > 0) { ?>
                                                                                    <?php echo $member->f_pri; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_pri]" ?>" value="<?php echo $member->f_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_p_int]" ?>" value="<?php echo $member->f_old_p_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_pri]" ?>" value="<?php echo $member->f_old_pri ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_int_amt > 0) { ?>
                                                                                    <?php echo $member->f_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_int]" ?>" value="<?php echo $member->f_old_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_p_int]" ?>" value="<?php echo $member->f_pri_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri_int > 0) { ?>
                                                                                    <?php echo $member->f_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->thrift_amt != "") { ?>
                                                                                    <?= $member->thrift_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_thrift]" ?>" value="<?php echo $member->thrift_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_thrift]" ?>" value="<?php echo $member->old_thrift ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][tot_thrift]" ?>" value="<?php echo  $member->tot_thrift; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php echo $member->insurance; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_insurance]" ?>" value="<?php echo $member->insurance; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_ins]" ?>" value="<?php echo $member->old_ins; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" width="50px">
                                                                                <?php echo $member->others_amt; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_others]" ?>" value="<?php echo $member->others_amt; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_others]" ?>" value="<?php echo $member->old_others; ?>">

                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->total > 0) { ?>
                                                                                    <p style="padding-top: 0px;margin-bottom: 0px;" data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" id="total_<?php echo $sno; ?>" data-id="<?php echo $sno; ?>"><?= $member->total + $member->old_thrift + $member->others_amt; ?> </p>
                                                                                <?php } ?>
                                                                                <input data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_total]" ?>" id="tot_<?php echo $sno; ?>" value="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" data-id="<?php echo $sno; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;"></td>
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int_rate]" ?>" value="<?php echo $member->loan_int_rate ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_f_int_rate]" ?>" value="<?php echo $member->f_int_rate ?>">
                                                                            <input data-initial-total="<?= $member->loan_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int]" ?>" id="int_<?php echo $sno; ?>" value="<?= $member->loan_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input data-initial-total="<?= $member->f_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_int]" ?>" id="intf_<?php echo $sno; ?>" value="<?= $member->f_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_month]" ?>" value="<?php echo $month; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_year]" ?>" value="<?php echo $year; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_no_of_days]" ?>" value="<?php echo $month_days; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][added_on]" ?>" value="<?php echo date("Y-m-d"); ?>">

                                                                        </tr>
                                                                        <?php
                                                                        if ($member->old_due_pri > 0 || $member->old_due_int > 0 || $member->f_old_pri > 0 || $member->f_old_int + $member->f_pri_int > 0 || $member->f_old_p_int > 0 || $member->old_thrift > 0 || $member->old_ins || $member->old_others) {
                                                                        ?>
                                                                            <tr style="color:red;height:45px;">
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <!-- <td></td> -->
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <!-- <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_pri > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int  + $member->f_old_p_int  + $member->f_pri_int > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td> -->
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_thrift > 0) { ?>
                                                                                        <b> <?php echo $member->old_thrift; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_ins > 0) { ?>
                                                                                        <b> <?php echo $member->old_ins; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_others > 0) { ?>
                                                                                        <b> <?php echo $member->old_others; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td>

                                                                                </td>
                                                                                <td></td>
                                                                            </tr>
                                                                        <?php } ?>
                                                                        <?php $member_ft += $member->total + $member->old_thrift + $member->others_amt;
                                                                        $tot_loan_amount += $member->loan_amount;
                                                                        $tot_os += $member->loan_os_amt;
                                                                        $tot_pri += $member->loan_principle_amt + $member->old_due_pri;
                                                                        $tot_int += $member->loan_int_amt + $member->old_due_int;
                                                                        $tot_p_int += $member->old_pri_int + $member->old_p_int;
                                                                        $tot_thrift += $member->tot_thrift;
                                                                        $tot_od_int +=  $member->old_due_int;
                                                                        $tot_fpri += $member->f_pri + $member->f_old_pri;
                                                                        $tot_fint += $member->f_int_amt + $member->f_old_int;
                                                                        $tot_fod_int += $member->f_old_int + $member->f_old_p_int;
                                                                        $tot_f_P_int += $member->f_pri_int + $member->f_old_p_int;
                                                                        $tot_fos += $member->f_os;
                                                                        $tot_td += $member->thrift_amt + $member->old_thrift;
                                                                        $tot_others += $member->others_amt + $member->old_others;  ?>
                                                                    <?php } else { ?>
                                                                        <input type="hidden" id="checking" value="<?= $member->loan_os_amt ?>">
                                                                        <tr style="background-color:red;color:white;">
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $sno; ?>
                                                                            </td>
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $member->me_no ?>
                                                                                <input type="hidden" value="<?php echo $member->me_no ?>" id="greater">
                                                                                <input type="hidden" value="<?php echo $member->mem_name ?>" id="greater2">

                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][me_no]" ?>" value="<?php echo $member->me_no ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_name ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_desig ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;">
                                                                                <?= $member->tot_thrift ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_os_amt">
                                                                                <?php if ($member->loan_os_amt != "") { ?>
                                                                                    <?= $member->loan_os_amt ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td class="text-right" style="padding:5px; margin:0px;">
                                                                                <?php if ($member->loan_instalment  != "0" ||   $member->curr_instalment != "0") { ?>
                                                                                    <?= $member->curr_instalment . '/' . $member->loan_instalment ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_principle_amt">
                                                                                <?php if ($member->loan_principle_amt > 0) { ?>
                                                                                    <?php echo $member->loan_principle_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_principal]" ?>" value="<?php echo $member->loan_principle_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_principal]" ?>" value="<?php echo $member->old_due_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_amount]" ?>" value="<?php echo $member->loan_amount ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_os]" ?>" value="<?php echo $member->loan_os_amt ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_os_amt > 0) { ?>
                                                                                    <?= $member->loan_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_int_amt > 0) { ?>
                                                                                    <?php echo $member->loan_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][p_int]" ?>" value="<?php echo $member->old_pri_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_int]" ?>" value="<?php echo $member->old_due_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_p_int]" ?>" value="<?php echo $member->old_p_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->old_pri_int > 0) { ?>
                                                                                    <?php echo $member->old_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_os ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_os]" ?>" value="<?php echo $member->f_os ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri > 0) { ?>
                                                                                    <?php echo $member->f_pri; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_pri]" ?>" value="<?php echo $member->f_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_p_int]" ?>" value="<?php echo $member->f_old_p_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_pri]" ?>" value="<?php echo $member->f_old_pri ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_int_amt > 0) { ?>
                                                                                    <?php echo $member->f_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_int]" ?>" value="<?php echo $member->f_old_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_p_int]" ?>" value="<?php echo $member->f_pri_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri_int > 0) { ?>
                                                                                    <?php echo $member->f_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->thrift_amt != "") { ?>
                                                                                    <?= $member->thrift_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_thrift]" ?>" value="<?php echo $member->thrift_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_thrift]" ?>" value="<?php echo $member->old_thrift ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][tot_thrift]" ?>" value="<?php echo  $member->tot_thrift; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php echo $member->insurance; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_insurance]" ?>" value="<?php echo $member->insurance; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_ins]" ?>" value="<?php echo $member->old_ins; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" width="50px">
                                                                                <?php echo $member->others_amt; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_others]" ?>" value="<?php echo $member->others_amt; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_others]" ?>" value="<?php echo $member->old_others; ?>">

                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->total > 0) { ?>
                                                                                    <p style="padding-top: 0px;margin-bottom: 0px;" data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" id="total_<?php echo $sno; ?>" data-id="<?php echo $sno; ?>"><?= $member->total + $member->old_thrift + $member->others_amt; ?> </p>
                                                                                <?php } ?>
                                                                                <input data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_total]" ?>" id="tot_<?php echo $sno; ?>" value="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" data-id="<?php echo $sno; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;"></td>
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int_rate]" ?>" value="<?php echo $member->loan_int_rate ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_f_int_rate]" ?>" value="<?php echo $member->f_int_rate ?>">
                                                                            <input data-initial-total="<?= $member->loan_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int]" ?>" id="int_<?php echo $sno; ?>" value="<?= $member->loan_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input data-initial-total="<?= $member->f_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_int]" ?>" id="intf_<?php echo $sno; ?>" value="<?= $member->f_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_month]" ?>" value="<?php echo $month; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_year]" ?>" value="<?php echo $year; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_no_of_days]" ?>" value="<?php echo $month_days; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][added_on]" ?>" value="<?php echo date("Y-m-d"); ?>">

                                                                        </tr>
                                                                        <?php
                                                                        if ($member->old_due_pri > 0 || $member->old_pri_int + $member->old_due_int > 0 || $member->f_old_pri > 0 || $member->f_old_int + $member->f_pri_int > 0 || $member->f_old_p_int > 0 || $member->old_thrift > 0 || $member->old_ins || $member->old_others) {
                                                                        ?>
                                                                            <tr style="color:red;height:45px;">
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <!-- <td></td> -->
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_pri > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int  + $member->f_old_p_int  + $member->f_pri_int > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_thrift > 0) { ?>
                                                                                        <b> <?php echo $member->old_thrift; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_ins > 0) { ?>
                                                                                        <b> <?php echo $member->old_ins; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_others > 0) { ?>
                                                                                        <b> <?php echo $member->old_others; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td>

                                                                                </td>
                                                                                <td></td>
                                                                            </tr>
                                                                        <?php } ?>
                                                                        <?php $member_ft += $member->total + $member->old_thrift + $member->others_amt;
                                                                        $tot_loan_amount += $member->loan_amount;
                                                                        $tot_os += $member->loan_os_amt;
                                                                        $tot_pri += $member->loan_principle_amt + $member->old_due_pri;
                                                                        $tot_int += $member->loan_int_amt + $member->old_due_int;
                                                                        $tot_p_int += $member->old_pri_int + $member->old_p_int;
                                                                        $tot_thrift += $member->tot_thrift;
                                                                        $tot_od_int +=  $member->old_due_int;
                                                                        $tot_fpri += $member->f_pri + $member->f_old_pri;
                                                                        $tot_fint += $member->f_int_amt + $member->f_old_int;
                                                                        $tot_fod_int += $member->f_old_int + $member->f_old_p_int;
                                                                        $tot_f_P_int += $member->f_pri_int + $member->f_old_p_int;
                                                                        $tot_fos += $member->f_os;
                                                                        $tot_td += $member->thrift_amt + $member->old_thrift;
                                                                        $tot_others += $member->others_amt + $member->old_others;  ?>
                                                                    <?php
                                                                    } ?>
                                                                <?php endforeach; ?>

                                                            <?php } else { ?>

                                                                <?php foreach ($members as $key => $member) :
                                                                    // print_r($member);
                                                                    // die;
                                                                    $member = (object) $member;
                                                                ?>


                                                                    <?php
                                                                    $pre_section = $member->section;
                                                                    $sno = $sno + 1; ?>
                                                                    <?php if ($member->loan_os_amt > $member->loan_principle_amt || $member->loan_os_amt == "0" || $member->loan_os_amt == $member->loan_principle_amt) { ?>
                                                                        <tr>
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $sno; ?>
                                                                            </td>
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $member->me_no ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][me_no]" ?>" value="<?php echo $member->me_no ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_name ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_desig ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;">
                                                                                <?= $member->tot_thrift ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_os_amt">
                                                                                <?php if ($member->loan_os_amt != "") { ?>
                                                                                    <?= $member->loan_os_amt ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td class="text-right" style="padding:5px; margin:0px;">
                                                                                <?php if ($member->loan_instalment  != "0" ||   $member->curr_instalment != "0") { ?>
                                                                                    <?= $member->curr_instalment . '/' . $member->loan_instalment ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_principle_amt">
                                                                                <?php if ($member->loan_principle_amt > 0) { ?>
                                                                                    <?php echo $member->loan_principle_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_principal]" ?>" value="<?php echo $member->loan_principle_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_principal]" ?>" value="<?php echo $member->old_due_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_amount]" ?>" value="<?php echo $member->loan_amount ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_os]" ?>" value="<?php echo $member->loan_os_amt ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_os_amt > 0) { ?>
                                                                                    <?= $member->loan_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_int_amt > 0) { ?>
                                                                                    <?php echo $member->loan_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][p_int]" ?>" value="<?php echo $member->old_pri_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_int]" ?>" value="<?php echo $member->old_due_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_p_int]" ?>" value="<?php echo $member->old_p_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->old_pri_int > 0) { ?>
                                                                                    <?php echo $member->old_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_os ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_os]" ?>" value="<?php echo $member->f_os ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri > 0) { ?>
                                                                                    <?php echo $member->f_pri; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_pri]" ?>" value="<?php echo $member->f_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_p_int]" ?>" value="<?php echo $member->f_old_p_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_pri]" ?>" value="<?php echo $member->f_old_pri ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_int_amt > 0) { ?>
                                                                                    <?php echo $member->f_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_int]" ?>" value="<?php echo $member->f_old_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_p_int]" ?>" value="<?php echo $member->f_pri_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri_int > 0) { ?>
                                                                                    <?php echo $member->f_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->thrift_amt != "") { ?>
                                                                                    <?= $member->thrift_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_thrift]" ?>" value="<?php echo $member->thrift_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_thrift]" ?>" value="<?php echo $member->old_thrift ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][tot_thrift]" ?>" value="<?php echo  $member->tot_thrift; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php echo $member->insurance; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_insurance]" ?>" value="<?php echo $member->insurance; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_ins]" ?>" value="<?php echo $member->old_ins; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" width="50px">
                                                                                <?php echo $member->others_amt; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_others]" ?>" value="<?php echo $member->others_amt; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_others]" ?>" value="<?php echo $member->old_others; ?>">

                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->total > 0) { ?>
                                                                                    <p style="padding-top: 0px;margin-bottom: 0px;" data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" id="total_<?php echo $sno; ?>" data-id="<?php echo $sno; ?>"><?= $member->total + $member->old_thrift + $member->others_amt; ?> </p>
                                                                                <?php } ?>
                                                                                <input data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_total]" ?>" id="tot_<?php echo $sno; ?>" value="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" data-id="<?php echo $sno; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;"></td>
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int_rate]" ?>" value="<?php echo $member->loan_int_rate ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_f_int_rate]" ?>" value="<?php echo $member->f_int_rate ?>">
                                                                            <input data-initial-total="<?= $member->loan_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int]" ?>" id="int_<?php echo $sno; ?>" value="<?= $member->loan_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input data-initial-total="<?= $member->f_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_int]" ?>" id="intf_<?php echo $sno; ?>" value="<?= $member->f_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_month]" ?>" value="<?php echo $month; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_year]" ?>" value="<?php echo $year; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_no_of_days]" ?>" value="<?php echo $month_days; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][added_on]" ?>" value="<?php echo date("Y-m-d"); ?>">

                                                                        </tr>
                                                                        <?php
                                                                        if ($member->old_due_pri > 0 || $member->old_pri_int + $member->old_due_int > 0 || $member->f_old_pri > 0 || $member->f_old_int + $member->f_pri_int > 0 || $member->f_old_p_int > 0 || $member->old_thrift > 0 || $member->old_ins || $member->old_others) {
                                                                        ?>
                                                                            <tr style="color:red;height:45px;">
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <!-- <td></td> -->
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <!-- <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_pri > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int  + $member->f_old_p_int  + $member->f_pri_int > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td> -->
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_thrift > 0) { ?>
                                                                                        <b> <?php echo $member->old_thrift; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_ins > 0) { ?>
                                                                                        <b> <?php echo $member->old_ins; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_others > 0) { ?>
                                                                                        <b> <?php echo $member->old_others; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td>

                                                                                </td>
                                                                                <td></td>
                                                                            </tr>
                                                                        <?php } ?>
                                                                        <?php $member_ft += $member->total + $member->old_thrift + $member->others_amt;
                                                                        $tot_loan_amount += $member->loan_amount;
                                                                        $tot_os += $member->loan_os_amt;
                                                                        $tot_pri += $member->loan_principle_amt + $member->old_due_pri;
                                                                        $tot_int += $member->loan_int_amt + $member->old_due_int;
                                                                        $tot_p_int += $member->old_pri_int + $member->old_p_int;
                                                                        $tot_thrift += $member->tot_thrift;
                                                                        $tot_od_int +=  $member->old_due_int;
                                                                        $tot_fpri += $member->f_pri + $member->f_old_pri;
                                                                        $tot_fint += $member->f_int_amt + $member->f_old_int;
                                                                        $tot_fod_int += $member->f_old_int + $member->f_old_p_int;
                                                                        $tot_f_P_int += $member->f_pri_int + $member->f_old_p_int;
                                                                        $tot_fos += $member->f_os;
                                                                        $tot_td += $member->thrift_amt + $member->old_thrift;
                                                                        $tot_others += $member->others_amt + $member->old_others; ?>
                                                                    <?php } else { ?>
                                                                        <input type="hidden" id="checking" value="<?= $member->loan_os_amt ?>">
                                                                        <tr style="background-color:red;color:white;">
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $sno; ?>
                                                                            </td>
                                                                            <td class="text-center" style="padding:5px; margin:0px;">
                                                                                <?= $member->me_no ?>
                                                                                <input type="hidden" value="<?php echo $member->me_no ?>" id="greater">
                                                                                <input type="hidden" value="<?php echo $member->mem_name ?>" id="greater2">

                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][me_no]" ?>" value="<?php echo $member->me_no ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_name ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;">
                                                                                <?= $member->mem_desig ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;">
                                                                                <?= $member->tot_thrift ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_os_amt">
                                                                                <?php if ($member->loan_os_amt != "") { ?>
                                                                                    <?= $member->loan_os_amt ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td class="text-right" style="padding:5px; margin:0px;">
                                                                                <?php if ($member->loan_instalment  != "0" ||   $member->curr_instalment != "0") { ?>
                                                                                    <?= $member->curr_instalment . '/' . $member->loan_instalment ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" id="loan_principle_amt">
                                                                                <?php if ($member->loan_principle_amt > 0) { ?>
                                                                                    <?php echo $member->loan_principle_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_principal]" ?>" value="<?php echo $member->loan_principle_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_principal]" ?>" value="<?php echo $member->old_due_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_amount]" ?>" value="<?php echo $member->loan_amount ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_loan_os]" ?>" value="<?php echo $member->loan_os_amt ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_os_amt > 0) { ?>
                                                                                    <?= $member->loan_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->loan_int_amt > 0) { ?>
                                                                                    <?php echo $member->loan_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][p_int]" ?>" value="<?php echo $member->old_pri_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_int]" ?>" value="<?php echo $member->old_due_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_p_int]" ?>" value="<?php echo $member->old_p_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->old_pri_int > 0) { ?>
                                                                                    <?php echo $member->old_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td>
                                                                            <!-- <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_os ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_os]" ?>" value="<?php echo $member->f_os ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri > 0) { ?>
                                                                                    <?php echo $member->f_pri; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_pri]" ?>" value="<?php echo $member->f_pri ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_p_int]" ?>" value="<?php echo $member->f_old_p_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_pri]" ?>" value="<?php echo $member->f_old_pri ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_os > 0) { ?>
                                                                                    <?= $member->f_int_rate ?> %
                                                                                <?php } ?>
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_int_amt > 0) { ?>
                                                                                    <?php echo $member->f_int_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_old_int]" ?>" value="<?php echo $member->f_old_int ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_p_int]" ?>" value="<?php echo $member->f_pri_int ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->f_pri_int > 0) { ?>
                                                                                    <?php echo $member->f_pri_int; ?>
                                                                                <?php } ?>
                                                                            </td> -->
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->thrift_amt != "") { ?>
                                                                                    <?= $member->thrift_amt; ?>
                                                                                <?php } ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_thrift]" ?>" value="<?php echo $member->thrift_amt ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_last_thrift]" ?>" value="<?php echo $member->old_thrift ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][tot_thrift]" ?>" value="<?php echo  $member->tot_thrift; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php echo $member->insurance; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_insurance]" ?>" value="<?php echo $member->insurance; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_ins]" ?>" value="<?php echo $member->old_ins; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;" width="50px">
                                                                                <?php echo $member->others_amt; ?>
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_others]" ?>" value="<?php echo $member->others_amt; ?>">
                                                                                <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][old_others]" ?>" value="<?php echo $member->old_others; ?>">

                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;text-align:right;">
                                                                                <?php if ($member->total > 0) { ?>
                                                                                    <p style="padding-top: 0px;margin-bottom: 0px;" data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" id="total_<?php echo $sno; ?>" data-id="<?php echo $sno; ?>"><?= $member->total + $member->old_thrift + $member->others_amt; ?> </p>
                                                                                <?php } ?>
                                                                                <input data-initial-total="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_total]" ?>" id="tot_<?php echo $sno; ?>" value="<?= $member->total + $member->old_thrift + $member->others_amt; ?>" data-id="<?php echo $sno; ?>">
                                                                            </td>
                                                                            <td style="padding:5px; margin:0px;"></td>
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int_rate]" ?>" value="<?php echo $member->loan_int_rate ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_f_int_rate]" ?>" value="<?php echo $member->f_int_rate ?>">
                                                                            <input data-initial-total="<?= $member->loan_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_int]" ?>" id="int_<?php echo $sno; ?>" value="<?= $member->loan_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input data-initial-total="<?= $member->f_int_amt ?>" type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][f_int]" ?>" id="intf_<?php echo $sno; ?>" value="<?= $member->f_int_amt ?>" data-id="<?php echo $sno; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_month]" ?>" value="<?php echo $month; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_year]" ?>" value="<?php echo $year; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][d_no_of_days]" ?>" value="<?php echo $month_days; ?>">
                                                                            <input type="hidden" name="<?php echo "postvalue[" . $member->me_no . "][added_on]" ?>" value="<?php echo date("Y-m-d"); ?>">

                                                                        </tr>
                                                                        <?php
                                                                        if ($member->old_due_pri > 0 || $member->old_pri_int + $member->old_due_int > 0 || $member->f_old_pri > 0 || $member->f_old_int + $member->f_pri_int > 0 || $member->f_old_p_int > 0 || $member->old_thrift > 0 || $member->old_ins || $member->old_others) {
                                                                        ?>
                                                                            <tr style="color:red;height:45px;">
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <!-- <td></td> -->
                                                                                <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_pri > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_due_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_due_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <!-- <td></td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_pri > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_pri; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int  + $member->f_old_p_int  + $member->f_pri_int > 0) { ?>
                                                                                        <b>3%</b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->f_old_p_int > 0) { ?>
                                                                                        <b> <?php echo $member->f_old_p_int; ?></b>
                                                                                    <?php } ?>
                                                                                </td> -->
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_thrift > 0) { ?>
                                                                                        <b> <?php echo $member->old_thrift; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_ins > 0) { ?>
                                                                                        <b> <?php echo $member->old_ins; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                                    <?php if ($member->old_others > 0) { ?>
                                                                                        <b> <?php echo $member->old_others; ?></b>
                                                                                    <?php } ?>
                                                                                </td>
                                                                                <td>

                                                                                </td>
                                                                                <td></td>
                                                                            </tr>
                                                                        <?php } ?>
                                                                        <?php $member_ft += $member->total + $member->old_thrift + $member->others_amt;
                                                                        $tot_loan_amount += $member->loan_amount;
                                                                        $tot_os += $member->loan_os_amt;
                                                                        $tot_pri += $member->loan_principle_amt + $member->old_due_pri;
                                                                        $tot_int += $member->loan_int_amt + $member->old_due_int;
                                                                        $tot_p_int += $member->old_pri_int + $member->old_p_int;
                                                                        $tot_thrift += $member->tot_thrift;
                                                                        $tot_od_int +=  $member->old_due_int;
                                                                        $tot_fpri += $member->f_pri + $member->f_old_pri;
                                                                        $tot_fint += $member->f_int_amt + $member->f_old_int;
                                                                        $tot_fod_int += $member->f_old_int + $member->f_old_p_int;
                                                                        $tot_f_P_int += $member->f_pri_int + $member->f_old_p_int;
                                                                        $tot_fos += $member->f_os;
                                                                        $tot_td += $member->thrift_amt + $member->old_thrift;
                                                                        $tot_others += $member->others_amt + $member->old_others;
                                                                        ?>
                                                                    <?php
                                                                    } ?>
                                                                <?php endforeach; ?>

                                                            <?php } ?>

                                                            <tr style="height:30px;">
                                                                <td>

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

                                                                </td>


                                                                <td>

                                                                </td>
                                                                <td>

                                                                </td>
                                                                <!-- <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_thrift; ?></b>
                                                                </td> -->
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_os; ?></b>
                                                                </td>
                                                                <td></td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_pri; ?></b>
                                                                </td>
                                                                <td></td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_int; ?></b>
                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_p_int; ?></b>
                                                                </td>
                                                                <!-- <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_fos; ?></b>
                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_fpri; ?></b>
                                                                </td>
                                                                <td>

                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_fint; ?></b>
                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_f_P_int; ?></b>
                                                                </td> -->
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_td; ?></b>
                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b> <?php echo $tot_ins; ?></b>
                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b><?php echo $tot_others; ?> </b>
                                                                </td>
                                                                <td style="padding:5px; margin:0px;text-align:right;">
                                                                    <b>
                                                                        <p style="padding-top: 0px;margin-bottom: 0px;" id="tot_tot_tot"> <?php echo $member_ft; ?></p>
                                                                    </b>
                                                                </td>
                                                                <td></td>
                                                            </tr>
                                                    </tbody>
                                                </table>
                                                <input type="hidden" name="sno" id="sno" data-tot-tot="<?php echo $member_ft; ?>" data-tot_int="<?php echo $tot_od_int; ?>" data-tot_fint="<?php echo $tot_fod_int; ?>" data-id="<?php echo $sno; ?>" value="<?php echo $sno; ?>">
                                               
                                                <div class="row mt-3">
                                                    <div class="col-sm-3">
                                                        <b>Society Phone No: 97865 00345</b>
                                                    </div>
                                                    <div class="col-sm-5 text-center">
                                                        <b></b>
                                                    </div>
                                                    <div class="col-sm-4 float-left">
                                                        <b></b>
                                                    </div>
                                                </div>
                                                <div class="row no-print">
                                                    <div class="col-sm-5"></div> <button type="submit" class="btn btn-primary col-sm-3" onclick="confirm();this.disabled=true;this.value='Submitting...'; this.form.submit();">Save</button>
                                                </div>
                                            </div>

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


                            <?php } ?>



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


<script src="//cdn.rawgit.com/rainabba/jquery-table2excel/1.1.0/dist/jquery.table2excel.min.js"> </script>
<script>
    $(document).ready(function() {
        $("#export").click(function() {
            $("#excel_id").table2excel({
                filename: "Demand_Details",
            });
            return false;
        });
    })

    function disable_month_year() {
        var month_days = $("#month_days").val();
        if (month_days != "") {
            // $("#division_id").val("");
            // $("#section_id").val("");
            $("#month_id").val("");
            $("#year_id").val("");

            $('#month_id').prop('disabled', 'disabled');
            $('#year_id').prop('disabled', 'disabled');
            $("#division_id").attr("readonly", true);
            $("#section_id").attr("readonly", true);
            $('#division_id').prop('disabled', 'disabled');
            $('#section_id').prop('disabled', 'disabled');
        } else {
            $('#month_id').prop('disabled', false);
            $('#year_id').prop('disabled', false);
            $("#division_id").attr("readonly", false);
            $("#section_id").attr("readonly", false);
            $('#division_id').prop('disabled', false);
            $('#section_id').prop('disabled', false);
        }
    }
</script>
<script>
    $('#division_id').on('change', function() {
        var division = this.value;
        var section = $('#section_id').val();

        $.ajax({
            type: 'POST',
            url: "<?php echo base_url() ?>index.php/Member/getsection",
            data: {
                division: division
            },
            dataType: 'html',
            success: function(data) {

                $('#section_id').html(data);
            }
        });

    });

    function confirm() {
        var checking = $('#checking').val();
        var greater = $('#greater').val();
        var greater2 = $('#greater2').val();
        if (checking > 0) {
            $("form").submit(function(e) {
                e.preventDefault();
            });
            alert("Principal Amount is greater than Loan os for Member Number =" + greater + "Member Name =" + greater2);
            $('#checking').focus();
            e.preventDefault();
        }
    };
    $(document).ready(function() {
        $('.alert').fadeOut(3000);
        $('.alert1').show(9000);
        var division = $('#division_id').val();
        var section = $('#section_id').val();

        $.ajax({
            type: 'POST',
            url: "<?php echo base_url() ?>index.php/Member/getsection",
            data: {
                division: division
            },
            dataType: 'html',
            success: function(data) {

                $('#section_id').html(data);
            }
        });
        $(".others_button,.insurance_button,.d_others").keyup(function() {
            var id = $(this).attr("data-id");
            // alert(id);
            var others = $('#others_' + id).val() == "" ? 0 : $('#others_' + id).val();
            var d_others = $('#d_others_' + id).val() == "" ? 0 : $('#d_others_' + id).val();
            var f_others = $('#f_others_' + id).val() == "" ? 0 : $('#f_others_' + id).val();
            var _total = $('#total_' + id).attr("data-initial-total");
            var _int = $('#f_int_' + id).attr("data-initial-int");
            var int = parseInt(_int);
            var _f_int = $('#ff_int_' + id).attr("data-initial-int");
            var f_int = parseInt(_f_int);
            var total_txt = _total.replace(",", "");
            var init_total = parseInt(total_txt);
            var others_val = parseInt(others);
            var d_others_val = parseInt(d_others);
            var f_others_val = parseInt(f_others);
            var interest = int + others_val;
            var f_interest = f_int + f_others_val;
            if (interest >= 0) {
                $('#f_int_' + id).text(interest);
                $('#int_' + id).val(interest);
            } else if (interest < 0) {
                alert("Interest Cannot be lessthan 0")
                $('#f_int_' + id).text(int);
                $('#others_' + id).val(0);
            }
            if (f_interest >= 0) {
                $('#ff_int_' + id).text(f_interest);
                $('#intf_' + id).val(f_interest);
            } else if (f_interest < 0) {
                alert("Interest Cannot be lessthan 0")
                $('#ff_int_' + id).text(f_int);
                $('#f_others_' + id).val(0);
            }
            // alert("it="+init_total+"ov="+others_val+"fov="+f_others_val+"dov="+d_others_val);
            var total = init_total + d_others_val;

            $('#total_' + id).text(total);
            $('#tot_' + id).val(total);
            var tot_m = $('#sno').attr("data-id");
            var tot_others = 0;
            for (j = 1; j <= tot_m; j++) {
                var others_ = $('#others_' + j).val() == "" ? 0 : $('#others_' + j).val();
                tot_others += parseInt(others_);
            }
            $('#tot_others').val(tot_others);
            var final_t = $('#sno').attr("data-id");
            var tot_int = $('#sno').attr("data-tot_int");
            var tot_fint = $('#sno').attr("data-tot_fint");
            var data_tot_tot = $('#sno').attr("data-tot-tot");
            var tot = 0;
            for (i = 1; i <= final_t; i++) {
                tot += parseInt($('#tot_' + i).val());
            }
            $('#final_tot').val(tot);
            var int_tot = 0;
            for (i = 1; i <= final_t; i++) {
                int_tot += parseInt($('#f_int_' + i).text());
            }
            var fi_tint = parseInt(tot_int);
            $('#f_int_tot').val(int_tot + fi_tint);
            var fint_tot = 0;

            for (i = 1; i <= final_t; i++) {
                fint_tot += parseInt($('#ff_int_' + i).text());
            }
            var fi_tfint = parseInt(tot_fint);
            $('#ff_int_tot').val(fint_tot + fi_tfint);

            var d_o_tot = 0;
            for (i = 1; i <= final_t; i++) {
                d_o_tot += parseInt($('#d_others_' + i).val() == "" ? 0 : $('#d_others_' + i).val());
                d_o_tot += parseInt($('#old_others_' + i).val() == "" ? 0 : $('#old_others_' + i).val());
            }

            var d_oth_tot = parseInt(d_o_tot);
            $('#d_others_total').val(d_oth_tot);
            var tot_tot = parseInt(data_tot_tot) + parseInt(d_oth_tot);
            $("#tot_tot_tot").html(tot_tot);
        });
    });
</script>