Your IP : 18.191.171.72


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

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

if($uidx != 1){
    header("Location:../login.php");
}

function agex($ctime){
  $age = (1625007600-$ctime)/(60*60*24*30);
return (int)$age;
}

function savT($opt=1){
    global $db;
    $sum = 0; $int=0;
    $sql = $db->query("SELECT * FROM savings ");
    while($row = $sql->fetch_assoc()){
        $sum += $row['amount']; $int += $row['amount']*0.02*agex($row['ctime']);
    }
    $sum = $opt==2 ? $int : $sum;
    return $sum;
}
function savTu($id,$opt=1){
    global $db;
    $sum = 0; $int=0;  $i=0;
    $sql = $db->query("SELECT * FROM savings WHERE id='$id' ");
    while($row = $sql->fetch_assoc()){ $i += 1;
        $sum += $row['amount']; $int += $row['amount']*0.02*agex($row['ctime']);
    }
    $sum = $opt==2 ? $int : $sum;
    $sum = $opt==3 ? $i : $sum;
    return $sum;
}
function savTuSw($id){
    global $db;
    $sum = 0; $int=0;  $i=0;
    $sql = $db->query("SELECT * FROM transfer WHERE id2='$id' AND type='sw' ");
    while($row = $sql->fetch_assoc()){ $i += 1;
        $sum += $row['amount']; 
    }
    return $sum;
}

function savTT($id){
    global $db;
  
    $sql = $db->query("SELECT * FROM transfer WHERE id2='$id' AND type='sw' ORDER BY sn DESC LIMIT 1 ");
   $row = $sql->fetch_assoc();  $x1 = strtotime($row['created']); 

    $sq = $db->query("SELECT * FROM savings WHERE id='$id' ORDER BY sn DESC LIMIT 1 ");
   $ro = $sq->fetch_assoc();  $x2 = strtotime($ro['created']);
    return $x1>$x2 ? 0 : 1;
}

function savSw(){
    global $db;
    $sum = 0; $int=0;  $i=0;
    $sql = $db->query("SELECT * FROM transfer WHERE type='sw' ");
    while($row = $sql->fetch_assoc()){ $i += 1;
        $sum += $row['amount']; 
    }
    return $sum;
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="treant/examples/tree/basic-example2.css">
    <!-- Neptune CSS -->
    <link rel="stylesheet" href="css/core.css">
    <title>Manage Savings</title>
    <link rel="shortcut icon" href="img/fav.png" />
    <link rel="stylesheet" href="treant/Treant.css">
    <link rel="stylesheet" href="treant/examples/tree/basic-example2.css">
    <!-- Neptune CSS -->
    <link rel="stylesheet" href="css/core.css">
    <!-- Neptune CSS -->


    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Neptune CSS -->
    <link rel="stylesheet" href="css/core.css">
    <!-- Vendor CSS -->
    <link rel="stylesheet" href="../vendor/bootstrap4/css/bootstrap.min.css">
    <link rel="stylesheet" href="../vendor/themify-icons/themify-icons.css">
    <link rel="stylesheet" href="../vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../vendor/animate.css/animate.min.css">
    <link rel="stylesheet" href="../vendor/jscrollpane/jquery.jscrollpane.css">
    <link rel="stylesheet" href="../vendor/waves/waves.min.css">
    <link rel="stylesheet" href="../vendor/switchery/dist/switchery.min.css">
    <link rel="stylesheet" href="../vendor/morris/morris.css">
    <link rel="stylesheet" href="../vendor/dropify/dist/css/dropify.min.css">
    <!-- Font Awesome -->
    <?php include('head.php'); ?>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
<?php include('nav.php');?>

<!-- Content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">Manage Savings</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">Dashboard </li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content-header -->

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                     <div class="row">
                        <div class="col-md-12">
                            <div class="card">
                            
                                    <div class="card-header text-white bg-dark">
                                    <h5 style="float: left;"> Savings and Deposits Accounts</h5></div>
                            <div class="card-body">
                                <?php //echo strtotime('2021-06-30');  ?>
                               <table class="table table-striped table-bordered dataTable" id="example1">
                                    <thead>
                                    <tr>
                                        <th>S/N</th>
                                       
                                        <th>Name</th>
                                        <th>User Name</th>
                                        <th>Deposit</th>
                                       
                                        <th>Interest</th>
                                        <th>count</th>
                                        <th>Withdrawn</th>
                                        <th>Balance</th>
                                        
                                        <th>Date</th>
                                    
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php
                                      $i=1;
                    $sql = $db->query("SELECT * FROM savings GROUP BY id HAVING count( * ) >=1 ");

                   $i = 0;  $x=0;
                                    while($row = $sql->fetch_assoc()){ $i +=1;  
                                       $d=savTu($row['id']); 
                                       $in = savTu($row['id'],2);
                                       $w = savTuSw($row['id']);
                                       $t = savTT($row['id'])==0 ? 0 : $d+$in-$w; 
                                       $x += $t; 

                                        
                                        ?>
                                        <tr>
                                            <td><?php echo $i; ?></td>
                                            
                                            <td><?php echo userName($row['id'])?></td>
                                            <td><?php echo userName($row['id'],'user')?></td>
                                          
                                            <td>$<?php echo $d ?></td>
                                            <td>$<?php echo $in ?></td>
                                            <td><?php echo savTu($row['id'],3) ?></td>
                                            <td><?php echo $w ?></td>
                                            <td><?php echo $t ?></td>
                                          
                                            <td><?php echo date("jS M, Y H:i",$row['ctime']) ?></td>
                                    
                                        </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                              

TOTAL SAVINGS: $<?php echo number_format(savT(),2) ?>
<br>
SAVINGS INTEREST: $<?php echo number_format(savT(2),2) ?>
<br>
SAVINGS WITHDRAWN: $<?php echo number_format(savSw(),2) ?>
<br>
USER BALANCE: $<?php echo number_format(savT()+savT(2)-savSw(),2) ?>
                            </div>
                        </div>
                       
                    </div>
                </div>
                <!-- /.row -->
            </div><!-- /.container-fluid -->
        </section>
        <!-- /.content -->
    </div>
<!-- /.content-wrapper -->
<?php include('foot.php'); ?>

</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": true,
        });
    });
</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>


?>