<div id="page-wrapper">
    <div class="header">
        <h1 class="page-header">

        </h1>
        <ol class="breadcrumb">
            <li><a href="#">Demand</a></li>
            <li class="active">Demand Generate</li>
        </ol>

    </div>
    <div id="page-inner">



        <div class="row">
            <div class="col-md-12">
                <!--   Kitchen Sink -->
                <div class="panel panel-default">
                    <div class="panel-heading d-flex justify-content-center">
                        Demand Generate
                    </div>
                    <div class="panel-body">
<?php
// print_r($month);die();
if (isset($members) && count($members) > 0) { ?>
    <div class="row mt-3">
        <div class="col-sm-12">
            <div class="tile">
                <div class="tile-body">
                    <div class="row mb-2">
                        <div class="col-sm-12 text-center">
                            <h5><b> <h5><b><?php echo $common[0]['society_title']; ?></b></h5></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><b>Sir,</b></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>
                    <div class="row ">
                        <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="table_id" class="table table-bordered table-responsive" style="width:100%;">
                        <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">Loan No.</th>
                                <th class="text-center">Loan Amt</th>
                                <th class="text-center">Loan OS</th>
                                <th class="text-center">Pri.</th>
                                <th class="text-center">Int.</th>
                                <th class="text-center">Dues</th>
                                <th class="text-center">FL OS</th>
                                <th class="text-center">FL Pri.</th>
                                <th class="text-center">FL Int.</th>
                                <th class="text-center">TD</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>
                        <!-- Here's where we iterate through our $articles query object, printing out article info -->
                        <tbody>
                            <?php
                            $pre_section = "";
                            foreach ($members as $key => $member) :
                                $member = (object) $member;
                                if ($pre_section != $member->section) {
                            ?>
                                    <tr>
                                        <td></td>
                                        <td style="color:blue;" colspan="2"><b><strong><?php echo $member->section; ?></strong</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>
                                    </tr>
                                <?php
                                }
                                $pre_section = $member->section;
                                $sno = $sno + 1; ?>

                                <tr style="height:30px;">
                                    <td class="text-center" style="padding:5px; margin:0px;">
                                        <?= $sno; ?>
                                    </td>
                                    <td class="text-center" style="padding:5px; margin:0px;">
                                        <?= $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;">
                                        <?php if ($member->d_loan_no != "") { ?>
                                            <?= $member->d_loan_no ?>
                                        <?php } ?>

                                    </td>
                                    <td>
                                        <?php if ($member->d_loan_amount > 0) { ?>
                                            <?= $member->d_loan_amount ?>
                                        <?php } ?>

                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_loan_os > 0) { ?>
                                            <?= $member->d_loan_os ?>
                                        <?php } ?>

                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_principal > 0) { ?>
                                            <?php echo $member->d_principal; ?>
                                        <?php } ?>
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_int > 0) { ?>
                                            <?php echo $member->d_int; ?>
                                        <?php } ?>
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_instalment > 0) {
                                            echo $member->d_curr_instalment . "/" . $member->d_instalment;
                                        } ?>
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->f_os > 0) { ?>
                                            <?= $member->f_os ?>
                                        <?php } ?>
                                    </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_pri]" ?>" value="<?php echo $member->f_old_pri ?>">
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->f_int > 0) { ?>
                                            <?php echo $member->f_int; ?>
                                        <?php } ?>
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_thrift > 0) { ?>
                                            <?php echo $member->d_thrift; ?>
                                        <?php } ?>
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_insurance > 0) { ?>
                                            <?php echo $member->d_insurance; ?>
                                        <?php } ?>

                                    </td>
                                    <td width="50px" s style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_others > 0) { ?>
                                            <?php echo $member->d_others; ?>
                                        <?php } ?>
                                    </td>
                                    <td style="padding:5px; margin:0px;text-align:right;">
                                        <?php if ($member->d_total > 0) { ?>
                                            <?php echo $member->d_total; ?>
                                        <?php } ?>
                                    </td>
                                    <td></td>
                                </tr>
                                <?php
                                if ($member->d_last_principal > 0 || $member->p_int + $member->d_last_int > 0 || $member->f_old_pri > 0 || $member->f_old_int + $member->f_p_int > 0 || $member->old_thrift > 0 || $member->old_ins > 0) {
                                ?>
                                    <tr style="height:30px;color:red;">
                                        <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->d_last_principal > 0) { ?>
                                                <?php echo $member->d_last_principal; ?>
                                            <?php } ?>
                                        </td>

                                        <td style="padding:5px; margin:0px;text-align:right;">
                                            <?php if ($member->p_int > 0 || $member->d_last_int > 0) { ?>
                                                <?php echo $member->p_int + $member->d_last_int; ?>
                                            <?php } ?>
                                        </td>
                                        <td></td>
                                        <td></td>
                                        <td style="padding:5px; margin:0px;text-align:right;">
                                            <?php if ($member->f_old_pri > 0) { ?>
                                                <?php echo $member->f_old_pri; ?>
                                            <?php } ?>
                                        </td>
                                        <td style="padding:5px; margin:0px;text-align:right;">
                                            <?php if ($member->f_old_int + $member->f_p_int > 0) { ?>
                                                <?php echo $member->f_old_int + $member->f_p_int; ?>
                                            <?php } ?>
                                        </td>
                                        <td style="padding:5px; margin:0px;text-align:right;">
                                            <?php if ($member->old_thrift > 0) { ?>
                                                <?php echo $member->old_thrift; ?>
                                            <?php } ?>
                                        </td>
                                        <td style="padding:5px; margin:0px;text-align:right;">
                                            <?php if ($member->old_ins > 0) { ?>
                                                <?php echo $member->old_ins; ?>
                                            <?php } ?>
                                        </td>
                                        <td>
                                            <?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->d_total;
                                $tot_loan_amount += $member->d_loan_amount;
                                $tot_os += $member->d_loan_os;
                                $tot_pri += $member->d_principal + $member->d_last_principal;
                                $tot_int += $member->d_int + $member->p_int + $member->d_last_int;
                                $tot_fpri += $member->f_pri + $member->f_old_pri;
                                $tot_fint += $member->f_int + $member->f_old_int + $member->f_p_int;
                                $tot_fos += $member->f_os;
                                $tot_td += $member->d_thrift + $member->old_thrift;
                                $tot_ins += $member->d_insurance + $member->old_ins;
                                $tot_others += $member->d_others + $member->old_others; ?>

                            <?php endforeach; ?>


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

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

                                </td>
                                <td>

                                </td>
                                <td>

                                </td>
                                <td>

                                </td>
                                <td style="padding:5px; margin:0px;text-align:right;">
                                    <b> <?php echo $tot_loan_amount; ?></b>
                                </td>
                                <td style="padding:5px; margin:0px;text-align:right;">
                                    <b> <?php echo $tot_os; ?></b>
                                </td>
                                <td style="padding:5px; margin:0px;text-align:right;">
                                    <b> <?php echo $tot_pri; ?></b>
                                </td>

                                <td style="padding:5px; margin:0px;text-align:right;">
                                    <b> <?php echo $tot_int; ?></b>
                                </td>
                                <td>

                                </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 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_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> <?php echo $member_ft; ?></b>
                                </td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="row mt-5 mb-5">
                        <div class="col-sm-2">

                        </div>
                        <div class="col-sm-5">
                            <b>Secretary</b>
                        </div>
                        <div class="col-sm-5 ">
                            <b>Pay Disbursing Officer</b>
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-sm-3">
                            <b>Society Phone No: 0431 - 2420 540</b>
                        </div>
                        <div class="col-sm-5 text-center">
                            <b></b>
                        </div>
                        <div class="col-sm-4 float-left">
                            <b></b>
                        </div>
                    </div>

                </div>

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

<?php } ?>
</div>


</div>
</div>