<!-- File: src/Template/Articles/index.ctp -->
<style>
    .btn-circle.btn-sm {
        width: 30px;
        height: 30px;
        padding: 6px 0px;
        border-radius: 15px;
        font-size: 8px;
        text-align: center;
    }
</style>


                            <div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <!-- <h1 class="m-0">Deactive Member </h1> -->
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Cash Group</a></li>
                    <li class="breadcrumb-item active">Create Group </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">
                        Create Group
                        </h3>
                        <div class="card-tools">
                            <ul class="nav nav-pills ml-auto">
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="tab-content p-0">
                            <?php if (isset($_SESSION['mem_add']) && $_SESSION['mem_add'] != "") { ?>
                                <div class="alert alert-success">
                                    <strong><?php echo $_SESSION['mem_add']; ?></strong>
                                </div>
                            <?php $_SESSION['mem_add'] = "";
                            } ?>
                        </div>
                        <form method="post" action="<?php echo base_url(); ?>index.php/Demand/print_group" id="member_add_" enctype='multipart/form-data'>
                            <div class="row">
                                <div class="col-sm-2">
                                    <div>
                                        Date
                                    </div>
                                    <input type="date" name="added_on" id="added_on_id" value="<?php echo date("Y/m/d"); ?>" onchange="disable_month_year();" class="form-control mt-2">
                                </div>
                                <div class="col-sm-1 mt-4"><button type="submit" class="btn btn-primary">Submit</button></div>
                        </form>

                    </div>
                    <?php if (isset($payment) && count($payment) > 0) { ?>
                        <?php $sno = 0;
                        $member_ft = 0; ?>
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="tile">
                                    <div class="tile-body">
                                        <br><br>
                                        <?php  foreach ($payment as $pay) {?>

                                        <table id="table_id" class="table table-striped table-bordered ">

                                            <thead>
                                                <tr>
                                                    <th>Share</th>
                                                    <th class="text-center"><?=  $pay['share_amt']; ?></th>
                                                </tr>
                                                <tr>
                                                    <th>Thrift</th>
                                                    <th class="text-center"><?= $pay['thrift_amt'];?></th>
                                                </tr>
                                                <tr>
                                                    <th>Principle</th>
                                                    <th class="text-center"><?= $pay['loan_pri_amt']; ?></th>
                                                </tr>
                                                <tr>
                                                    <th>Interest</th>
                                                    <th class="text-center"><?= $pay['loan_int_amt']; ?></th>
                                                </tr>
                                                <tr>
                                                    <th>Insurence</th>
                                                    <th class="text-center"><?= $pay['insurance']; ?></th>
                                                </tr>

                                            </thead>
                                            <tbody>

                                            </tbody>
                                        </table>
                                        <?php  } ?>

                                    </div>
                                </div>
                            </div>
                            <?php $sno =0;?>
                            <?php  foreach ($group as $pay) { ?>

                            <div class="col-sm-1" style="top: 43px;padding-right: 0px;padding-left: 76px;">
                                <a class="btn btn-primary btn-circle btn-sm" onclick="display(<?= $sno; ?>); show(<?= $sno; ?>);"><i class="fas fa-plus mt-5" style="color:#fff; font-size:17px;"></i></a>
                            </div>
                            <div class="col-sm-5">
                                <div class="tile">
                                    <div class="tile-body">
                                        <br><br>
                                       
                                        <table id="table_id" class="table table-striped table-bordered table-responsive" style="width:100%">


                                                <thead>

                                                    <tr>
                                                        <th>Total</th>
                                                        <th class="text-center">
                                                            <input type="hidden" id="group_id<?= $sno; ?>" name="group_id" value=" <?= $pay['group_id']; ?> " class="form-control mt-2">
                                                            <?= $pay['group_cash']; ?>
                                                        </th>

                                                    </tr>

                                                </thead>
                                                <tbody>

                                                </tbody>
                                        </table>
                                        
                                        <table id="table_id3<?= $sno; ?>" class="table table-striped table-bordered " style="width:100%;display:none">
                                            <tbody id="tbody<?= $sno; ?>">


                                                <?php foreach ($data as $value) { ?>
                                                    <tr>
                                                        <td><?php echo  $value->me_no; ?></td>
                                                        <td><?php echo  $value->mem_name; ?></td>
                                                        <td><?php echo  $total = $value->share_amt + $value->thrift_amt + $value->loan_pri_amt + $value->loan_int_amt + $value->f_pri + $value->f_int + $value->insurance; ?></td>
                                                        <!-- <!?php $total1 += $total; ?> -->
                                                    </tr>
                                                <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <?php $sno ++;?>

                            <?php  } ?>
                        </div>
                    <?php } ?>



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








                    <script>
                        function display(sno) {
                            var id = $("#group_id" +sno).val();
                            if (id != "") {
                                $.ajax({

                                    type: 'POST',
                                    url: "<?php echo base_url() ?>index.php/Demand/get_grouping_id",
                                    data: {
                                        id: id,
                                    },
                                    dataType: 'html',
                                    success: function(data) {
                                        $('#tbody'+sno).html(data);

                                    }
                                });
                            }
                            // alert(id);
                        }

                        function show(sno) {
                            $("#table_id3"+sno).toggle();
                        }
                    </script>