Your IP : 18.119.124.204


Current Path : /home/lentoinv/covisclubinternational.com/profile/
Upload File :
Current File : //home/lentoinv/covisclubinternational.com/profile/contribution.php

<?php
session_start();ob_start();
include("lib/connect.inc.php");

if(isset($_POST['EditSavingContribution'])){
    $sn = $_POST['EditSavingContribution'];
    $sql = $db->query("SELECT * FROM contributions WHERE sn = '$sn' LIMIT 1");

    $edit = $sql->fetch_object();
    $sql5 = $db->query("SELECT * FROM contributedmoney WHERE savings_id = '$edit->id'");
    $readonly = (($sql5->num_rows > 0) || isset($edit->start)) ? 'readonly' : '';
}

$button = (isset($edit)) ? 'UpdateContribution' : 'CreateContribution';
$btnValue = (isset($edit)) ? 'Update' : 'Submit';
$report = isset($_SESSION['report']) ? $_SESSION['report'] : null;
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Contribution</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Font Awesome -->
    <?php include('head.php'); ?>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">

    <?php include('nav.php'); ?>

    <!-- Content Wrapper. Contains page content -->

    <!-- Content Header (Page header) -->
    
        <!-- Content Header (Page header) -->
            <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>SAVINGS CONTRIBUTION</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="index.php">Home</a></li>
                            <li class="breadcrumb-item active">Savings Contribution</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>                <!-- Content Header (Page header) -->
        <div class="content">
            <div class="container-fluid">
                <div id="refresh"><?php if(isset($report)){$covis->Alert(); }
                    //        $lastMonth = strtotime('-2 weeks', time());
                    //        $time = time();
                    //        $month = floor(($time - $lastMonth) / 2592000);

                    $val = 5;?>
                </div>

                <?php  if(!checkCovisEconomy($uid)): ?>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card-box">
                                <div class="card-header bg-dark text-white">
                                    OOPS!!!
                                </div>
                                <div class="card-body">
                                    <h4>This option is only available for Covis Economy Users, Please
                                        upgrade your account to Covis Economy in other to
                                        participate</h4>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php else: ?>
                <div class="row">
                    <div class="col-lg-4 col-sm-12">
                        <div class="card">
                            <div  class="card-header bg-dark text-white">
                                <h5>Create New Savings Contribution
                                    <!--                                     --><?//= floor(($time - $lastMonth) / 2592000) ?>
                                </h5>
                            </div>
                            <div class="card-body">
                                <div>
                                    <form method="POST">
                                        <em>Note:
                                            <ol>
                                                <li>It is a Monthly Contribution (AJO)</li>
                                                <li>(No of Participants / Monthly Beneficiary) =
                                                    Even Number</li>
                                                <li>Minimum of 5 Participants</li>
                                                <li>Maximum of 12 Participants</li>

                                            </ol>
                                        </em>
                                        <!--                                        <em>-->
                                        <!--                                            <span class="text-red">Disclaimer: Covis Economy will not be responsible for-->
                                        <!--                                            any default of any Members, so please know-->
                                        <!--                                            your contribution(AJO) plan Members</span>-->
                                        <!---->
                                        <!--                                        </em>-->
                                        <div class="form-group">
                                            <label>Title</label>
                                            <input type="text" name="title" class="form-control"
                                                   placeholder="Enter the Title" value="<?=
                                            $edit->title ?? ''  ?>"
                                                   required>
                                        </div>
                                        <div class="form-group">
                                            <label>Amount</label>
                                            <input type="number" name="amount" class="form-control"
                                                   value="<?= $edit->amount ?? ''  ?>"
                                                <?= $readonly ?? '' ?>

                                                   placeholder="Savings Amount" required>
                                        </div>
                                        <div class="form-group">
                                            <label>No of Participants</label>
                                            <input type="number" name="participant"
                                                   class="form-control" id="participants"
                                                   value="<?= $edit->participant ?? ''  ?>"
                                                <?= $readonly ?? '' ?>
                                                   max="12" min="5"
                                                   placeholder="Enter the No of Members" required>
                                        </div>

                                        <div class="form-group">
                                            <label>No of Monthly Beneficiary</label>
                                            <input type="number" name="shared"
                                                   class="form-control" id="shared"
                                                   value="<?= $edit->shared ?? ''  ?>"
                                                <?= $readonly ?? '' ?>
                                                   placeholder="Enter the No of Monthly Beneficiary"
                                                   required>
                                        </div>

                                        <!--                                        <div class="form-group">-->
                                        <!--                                            <label>Start Date:</label>-->
                                        <!--                                            <input type="date" name="start"-->
                                        <!--                                                   class="form-control"-->
                                        <!--                                                   value="--><?php //date('Y-m-d',$edit->start)
                                        ////?? ''  ?><!--"-->
                                        <!--                                                    --><?//= $readonly ?? '' ?>
                                        <!--                                                   required>-->
                                        <!--                                        </div>-->
                                        <!--                                        <div class="form-group">-->
                                        <!--                                            <label>End Date:</label>-->
                                        <!--                                            <input type="date" name="end"-->
                                        <!--                                                   class="form-control"-->
                                        <!--                                                   value="--><!--"-->
                                        <!--                                                    required>-->
                                        <!--                                        </div>-->
                                        <input type="hidden" name="id" value="<?= $uid ?>">
                                        <button class="btn btn-success btn-block"
                                                id="submitSaving" type="submit"
                                                value="<?= $edit->sn ?? '' ?>"
                                                name="<?= $button ?>"><?= $btnValue ?></button>
                                        <p id="result" style="display: none" class="alert
                                        alert-danger"></p>
                                    </form>
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="col-lg-8 col-sm-12">
                        <div class="row">
                            <div class="card">

                                <div  class="card-header bg-dark text-white">
                                    <h5>Contribution Plan</h5>
                                </div>
                                <div class="card-body table-responsive">
                                    <table class="table table-striped table-bordered dataTable" id="example2">
                                        <thead>
                                        <tr>
                                            <th>S/N</th>
                                            <th>ID</th>
                                            <th>Title</th>
                                            <th>Amount</th>
                                            <th>Created By</th>
                                            <th>Max Participants</th>
                                            <th>Active Participants</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                            <!-- <th>Action</th> -->

                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $i=1;
                                        $sql = $db->query("SELECT * FROM contributions WHERE user_id='$uid' ORDER BY sn DESC");
                                        while($row = $sql->fetch_assoc()) { $e = $i++;
                                            ?>
                                            <tr>
                                                <td><?php echo $e; ?></td>
                                                <td><?php  echo $row['id']    ?></td>
                                                <td><?php  echo $row['title']    ?></td>
                                                <td>$<?php echo $row['amount'] ?></td>
                                                <td><?php echo userName($row['user_id']). '('
                                                    .userName($row['user_id'], "user").')'
                                                    ?></td>

                                                <td><?php echo $row['participant'] ?> </td>
                                                <td><?= activeParticipant($row['id']) ?></td>
                                                <td><?= $row['start'] ?  date('jS M, Y',
                                                        $row['start']) : '-'; ?></td>
                                                <td><?= $row['stop'] ?  date('jS M, Y',
                                                        $row['stop']) : '-';
                                                    ?></td>
                                                <td>
                                                    <form method="POST">
                                                        <?php if($row['user_id']  == $uid) : ?>
                                                            <button class="btn btn-primary
                                                                        btn-sm btn-block" value="<?=
                                                            $row['sn'] ?>"
                                                                    name="EditSavingContribution">
                                                                Edit
                                                            </button>
                                                            <button class="btn btn-warning
                                                                        btn-sm btn-block" value="<?=
                                                            $row['id'] ?>"
                                                                    name="MySavingContributionProfile">
                                                                Profile
                                                            </button>

                                                            <?php if(!isset($row['start'])):  ?>
                                                                <button class="btn btn-outline-success
                                                                                btn-sm btn-block" value="<?=
                                                                $row['id'] ?>"
                                                                        onclick="return confirm('Are' +
                                                                      ' you sure you want to ' +
                                                                       'start this plan' +
                                                                       ' ?')"
                                                                        name="StartContributionTime">
                                                                    Start
                                                                </button>
                                                            <?php endif; ?>
                                                            <?php if(!isset($row['start']) &&
                                                                activeParticipant($row['id']) < 2):
                                                                ?>
                                                                <button class="btn btn-outline-danger
                                                                                btn-sm btn-block" value="<?=
                                                                $row['id'] ?>" onclick="return confirm
                                                         ('Are you sure you want to delete this ' +
                                                          'plan ?')"
                                                                        name="DeleteContribution">
                                                                    Delete
                                                                </button>
                                                            <?php endif; endif; ?>
                                                        <?php
                                                        $disabled1 = ( (!isset($row['start'])
                                                            || time() < $row['start']))
                                                            ?'disabled': '';
                                                        ?>
                                                        <button class="btn btn-success
                                                                                btn-block"
                                                                data-savings="<?= $row['id'] ?>"
                                                                data-id="<?= $uid ?>"
                                                                data-period="<?= $row['period'] ?>"
                                                                value="<?= $row['id'] ?>"
                                                                data-amount="<?= $row['amount']  ?>"
                                                            <?= $disabled1 ?>
                                                                id="PaySavingsContribution1"
                                                                name="PaySavingsContribution">
                                                            Pay
                                                        </button>
                                                    </form>


                                                </td>
                                            </tr>

                                        <?php } ?>
                                        </tbody>

                                    </table>


                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="card">

                                <div  class="card-header bg-dark text-white">
                                    <h5>Available Contribution Plans</h5>
                                </div>
                                <div class="card-body table-responsive">
                                    <table class="table table-striped table-bordered dataTable"
                                           id="example4">
                                        <thead>
                                        <tr>
                                            <th>S/N</th>
                                            <th>ID</th>
                                            <th>Title</th>
                                            <th>Amount</th>
                                            <th>Created By</th>
                                            <th>Max Participants</th>

                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                            <!-- <th>Action</th> -->

                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $i=1;
                                        $sql = $db->query("SELECT * FROM contributions where user_id != '$uid' ORDER BY sn DESC");
                                        while($row = $sql->fetch_assoc()) { $e = $i++;
                                            ?>
                                            <tr>
                                                <td><?php echo $e; ?></td>
                                                <td><?php  echo $row['id']    ?></td>
                                                <td><?php  echo $row['title']    ?></td>
                                                <td>$<?php echo $row['amount'] ?></td>
                                                <td><?php echo userName($row['user_id']). '('
                                                        .userName($row['user_id'], "user").')'
                                                    ?></td>

                                                <td><?php echo $row['participant'] ?> </td>

                                                <td><?= $row['start'] ? date('jS M, Y',
                                                        $row['start']) : '-';
                                                    ?></td>
                                                <td><?= $row['stop'] ? date('jS M, Y',
                                                        $row['stop']) : '-'; ?></td>
                                                <td>
                                                    <form method="POST">
                                                        <?php if(participated($uid, $row['id'])) :
                                                            if (getContributionParticipantsField($uid, $row['id'], 'status') == 0){ ?>
                                                                <a href="#" class="btn
                                                                            btn-success btn-sm" disabled="">
                                                                    Awaiting Confirmation
                                                                </a>
                                                            <?php } else {
                                                                $disabled1 = ( !isset($row['start'])
                                                                    || time() < $row['start'])
                                                                    ?'disabled': '';
                                                                ?>
                                                                <button class="btn btn-success
                                                                                btn-block"
                                                                        data-savings="<?= $row['id'] ?>"
                                                                        data-id="<?= $uid ?>"
                                                                        data-period="<?= $row['period'] ?>"
                                                                        value="<?= $row['id'] ?>"
                                                                        data-amount="<?= $row['amount']  ?>"
                                                                    <?= $disabled1 ?>
                                                                        id="PaySavingsContribution"
                                                                        name="PaySavingsContribution">
                                                                    Pay
                                                                </button>
                                                            <?php }
                                                        else:
                                                            $disabled = (!isset($row['start']) ||
                                                                (time()
                                                                    <= $row['start']
                                                                    && activeParticipant($row['id'])
                                                                    < $row['participant']))
                                                                ? '' :
                                                                'disabled' ;
                                                            ?>
                                                            <button class="btn btn-success btn-sm" value="<?= $row['id'] ?>"
                                                                <?= $disabled ?>
                                                                    name="JoinSavingContribution">
                                                                Join
                                                            </button>
                                                        <?php endif; ?>
                                                    </form>


                                                </td>
                                            </tr>

                                        <?php } ?>
                                        </tbody>

                                    </table>


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

                    </div>

                    <!-- /.card-body -->
                </div>

                <?php endif; ?>

                <?php if(isset($_POST['MySavingContributionProfile'])): $savings = $_POST['MySavingContributionProfile'] ?>
                    <div class="row">
                        <div class="col-md-12 col-lg-12">
                            <div class="card">
                                <div class="card-header bg-dark text-white">
                                    My Contribution Plan (Pending Request)
                                </div>
                                <div class="card-body">
                                    <div class="card-body table-responsive">
                                        <table class="table table-striped table-bordered dataTable"
                                               id="example3">
                                            <thead>
                                            <tr>
                                                <th>S/N</th>
                                                <th>Username</th>
                                                <th>Full Name</th>
                                                <th>Phone</th>
                                                <th>Email</th>
                                                <th>Stage</th>
                                                <th>Level</th>
                                                <th>Date</th>
                                                <th>Action</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            $i=1;
                                            $sql = $db->query("SELECT * FROM contributionparticipants WHERE savings_id = '$savings' AND status = 0 ORDER BY sn DESC");
                                            while($row = $sql->fetch_assoc()) { $e = $i++;
                                                ?>
                                                <tr>
                                                    <td><?php echo $e; ?></td>
                                                    <td><?php  echo userName($row['user_id'], 'user')
                                                        ?></td>
                                                    <td><?= userName($row['user_id'], 'firstname'). ' '
                                                        .userName($row['user_id'], 'lastname') ?></td>
                                                    <td><?= userName($row['user_id'], 'phone') ?></td>
                                                    <td><?= userName($row['user_id'], 'email') ?></td>
                                                    <td><?= $covis->stageCalc(userName($row['user_id'],
                                                            'sn')).'('.stageName($covis->stageCalc(userName($row['user_id'], 'sn'))).')' ?>
                                                    </td>
                                                    <td><?= $covis->stageLevel(userName($row['user_id'],
                                                            'sn')) ?>
                                                    </td>
                                                    <td><?= date('jS M, Y', strtotime($row['created_at'])); ?>
                                                    </td>
                                                    <td>
                                                        <form method="POST">
                                                            <button class="btn btn-primary
                                                                btn-sm" value="<?= $row['sn'] ?>"
                                                                    name="ApproveMySavingsPlan">
                                                                Approve
                                                            </button>
                                                            <button class="btn btn-danger
                                                                btn-sm" value="<?= $row['sn'] ?>"
                                                                    name="DeclineMySavingsPlan">
                                                                Decline
                                                            </button>
                                                        </form>
                                                    </td>
                                                </tr>

                                            <?php } ?>
                                            </tbody>

                                        </table>


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

                    <div class="row">
                        <div class="col-md-12 col-lg-12">
                            <div class="card">
                                <div class="card-header bg-dark text-white">
                                    My Contribution Plan (Active Members)
                                </div>
                                <div class="card-body">
                                    <div class="card-body table-responsive">
                                        <table class="table table-striped table-bordered dataTable"
                                               id="example3">
                                            <thead>
                                            <tr>
                                                <th>S/N</th>
                                                <th>Username</th>
                                                <th>Full Name</th>
                                                <th>Phone</th>
                                                <th>Email</th>
                                                <th>Stage</th>
                                                <th>Level</th>
                                                <th>Total Amount Contributed</th>
                                                <th>No of Contribution</th>
                                                <th>Paid Status</th>
                                                <th>Action</th>
                                                <!--                                            <th>Action</th>-->
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            $i=1;
                                            $sum = 0;
                                            $sql =
                                                $db->query("SELECT * FROM contributionparticipants 
                                                                WHERE savings_id = '$savings' AND status = 1 ORDER BY sn DESC");
                                            while($row = $sql->fetch_assoc()) { $e = $i++;
                                                $sum += getTotalContribution($row['user_id'],
                                                    $savings, 1);
                                                ?>
                                                <tr>
                                                    <td><?php echo $e; ?></td>
                                                    <td><?php  echo userName($row['user_id'], 'user')
                                                        ?></td>
                                                    <td><?= userName($row['user_id'], 'firstname'). ' '
                                                        .userName($row['user_id'], 'lastname') ?></td>
                                                    <td><?= userName($row['user_id'], 'phone') ?></td>
                                                    <td><?= userName($row['user_id'], 'email') ?></td>
                                                    <td><?= $covis->stageCalc(userName($row['user_id'],
                                                            'sn')).'('.stageName($covis->stageCalc(userName($row['user_id'], 'sn'))).')' ?>
                                                    </td>
                                                    <td><?= $covis->stageLevel(userName($row['user_id'],
                                                            'sn')) ?>
                                                    </td>
                                                    <td>$<?= getTotalContribution($row['user_id'],
                                                            $savings, 1) ?? 0 ?></td>
                                                    <td><?= getTotalContribution($row['user_id'],
                                                            $savings) ?></td>
                                                    <td><?= $row['paid'] == 1 ? 'Paid': '-' ?></td>
                                                    <td>
                                                        <button class="btn btn-info"
                                                                data-id="<?= $row['user_id'] ?>"
                                                                data-saving="<?= $savings ?>"
                                                                id="showPayDetails">
                                                            Show History
                                                        </button>
                                                    </td>
                                                </tr>

                                            <?php } ?>
                                            <tr>
                                                <td colspan="7">TOTAL</td>
                                                <td colspan="4">$<?= $sum ?></td>
                                            </tr>
                                            </tbody>

                                        </table>


                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>

                <!-- /.card -->

                <!-- right col -->
            </div>
            <!-- /.row (main row) -->
        </div><!-- /.container-fluid -->

        <!-- /.content -->
    </div>

    <div class="modal fade" role="dialog" tabindex="-1" id="paySavings">
        <div class="modal-dialog modal-dialog-centered modal-sm modal-dialog-scrollable"
             role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="editTitle">Contribution Details (Wallet:
                        $<?= number_format($covis->totalEarnings($uidx), 2) ?>)
                    </h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span></button></div>
                <div class="modal-body">
                    <form method="POST">
                        <div id="showTable" class="table-responsive"></div>

                        <input type="hidden" id="savingsM" name="savingsM">
                        <input type="hidden" id="amountM" name="amountM">
                        <input type="hidden" id="monthM" name="monthM">
                        <button class="btn btn-primary float-right" type="submit"
                                name="PayContribution" id="PayContribution">
                            Pay
                        </button>
                    </form>


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

    <div class="modal fade" role="dialog" tabindex="-1" id="payDetails">
        <div class="modal-dialog modal-dialog-centered modal-md  modal-dialog-scrollable"
             role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="editTitle">
                        Payment History
                    </h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span></button></div>
                <div class="modal-body">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>Month</th>
                            <th>Amount</th>
                            <th>Date</th>
                        </tr>
                        </thead>
                        <tbody id="detailsBody">

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- /.content-wrapper -->
<?php include('foot.php'); ?>

<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>


<!-- jQuery UI 1.11.4 -->
<script src="../plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- ChartJS -->
<script src="../plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="../plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="../plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="../plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="../plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="../plugins/moment/moment.min.js"></script>
<script src="../plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="../plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="../plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="../dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- DataTables -->
<script src="../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>

<!-- page script -->
<script>
    $(function () {

        $("#example1").DataTable({
            "responsive": true,
            "autoWidth": false,
        });
        $('#example2').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": false,
        });
         $('#example3').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
          $('#example4').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": false,
        });
           $('#example5').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
            $('#example6').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
             $('#example7').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });

             $('#shared').on('input', function() {

                 const shared = $('#shared').val();
                 const participant = $('#participants').val();
                // console.log(participant)
                 let result = participant % shared;
                 if(result !== 0 && shared.trim() !== ''){

                     $('#result').show().html('Please make sure the division of participants and ' +
                         'no of' +
                         ' ' +
                         'beneficials' +
                         ' ' +
                         'result to even number')
                     $('#submitSaving').attr('disabled', 'disabled')
                 } else {
                     $('#result').hide();
                     $('#submitSaving').removeAttr('disabled')
                 }
             });

        $('body').on('click','#PaySavingsContribution' , function (e) {
            e.preventDefault();

            const savings = $(this).data('savings')
            const user = $(this).data('id')
            const amount = $(this).data('amount')
            const period = $(this).data('period')

            const request = {
                savings, user
            }
            $('#paySavings').modal('show')
            // console.log(request)
            $.ajax({
                url: 'ajax.php?paySavings='+JSON.stringify(request),
                method: 'GET'
            }).done((res) => {
                 res = JSON.parse(res)

                let table = `<table class="table">`

                if(res.count === period){
                    $('#PayContribution').hide();
                }

                // if(res.count < 1){
                    for(let i = 1; i <= period; i++){
                        let styleShow = '';
                        if(i < (res.count+1)){
                            styleShow = "background-color: gray; color: white"
                        } else if(i === (res.count+1)){
                            styleShow = "background-color: blue; color: white"
                        } else {
                            styleShow = ""
                        }

                        table += `<tbody>
                                <tr class="active" style="${styleShow}">
                                    <td><input type="checkbox"
                                        ${i <= (res.count+1) ? 'checked': ''} disabled
                                        class="form-control"
                                        /></td>
                                    <td>$${amount}</td>
                                    <td>Month ${i}</td>
                                </tr></tbody>`

                    }
                // }
                table += '</table>'
                $('#showTable').html(table)

                $('#amountM').val(amount)
                $('#savingsM').val(savings)
                $('#monthM').val((res.count + 1))
            })

            // $('#showTable').html(user+' Savings: '+savings)
        })

            .on('click','#PaySavingsContribution1', function (e) {
            e.preventDefault();

            const savings = $(this).data('savings')
            const user = $(this).data('id')
            const amount = $(this).data('amount')
            const period = $(this).data('period')

            const request = {
                savings, user
            }
            $('#paySavings').modal('show')
            // console.log(request)
            $.ajax({
                url: 'ajax.php?paySavings='+JSON.stringify(request),
                method: 'GET'
            }).done((res) => {
                 res = JSON.parse(res)

                let table = `<table class="table">`

                if(res.count === period){
                    $('#PayContribution').hide();
                }
                // if(res.count < 1){
                    for(let i = 1; i <= period; i++){
                        let styleShow = '';
                        if(i < (res.count+1)){
                            styleShow = "background-color: gray; color: white"
                        } else if(i === (res.count+1)){
                            styleShow = "background-color: blue; color: white"
                        } else {
                            styleShow = ""
                        }

                        table += `<tbody>
                                <tr class="active" style="${styleShow}">
                                    <td><input type="checkbox"
                                        ${i <= (res.count+1) ? 'checked': ''} disabled
                                        class="form-control"
                                        /></td>
                                    <td>$${amount}</td>
                                    <td>Month ${i}</td>
                                </tr></tbody>`

                    }
                // }
                table += '</table>'
                $('#showTable').html(table)

                $('#amountM').val(amount)
                $('#savingsM').val(savings)
                $('#monthM').val((res.count + 1))
            })

            // $('#showTable').html(user+' Savings: '+savings)
        })

    })
        .on('click', '#showPayDetails', function(e) {
            e.preventDefault();

            const savings = $(this).data('saving')
            const user = $(this).data('id')

            const request = {
                savings, user
            }
            let table = '';
            $.ajax({
                url: 'ajax.php?payDetails='+JSON.stringify(request),
                method: 'GET'
            }).done((res) => {
                res = JSON.parse(res);
                console.log(res.data)
                // console.log((JSON.parse(res)))
                if(res.count < 1){
                    table += `No records found`
                } else {
                    res.data.map((record) => {
                        console.log(record.month)
                        table += `<tr>
                                    <td>Month ${record.month}</td>
                                    <td>$${record.amount}</td>
                                    <td>${record.created_at.slice(0,10)}</td>
                                </tr>`
                    })
                }

                $('#detailsBody').html(table);
            }).fail((err) => {

            })

            $('#payDetails').modal('show');
        })

    ;
</script>



<!-- page script -->
<script type="text/javascript">
    <?php
    // if($covis->globeStage($uidy)==1 ){
    if($stages==1 ){
        echo $covis->covisTreeGlobe($uid);
    }else{
        echo $covis->covisTree4Globe($uid);
    }
    ?>
</script>

<script src="treant/vendor/raphael.js"></script>
<script src="treant/Treant.js"></script>


<script>
    new Treant( chart_config );
</script>


</body>
</html>

?>