Your IP : 3.144.16.40


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

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

if(isset($_POST['ProcessCharity'])){
    $note = $_POST['note'];
    $amount='-'.$_POST['amount'];
    $db->query("INSERT INTO charity (note,amount) VALUES ('$note','$amount')");
    $report= 'Operation Successful';
}

function addCharityFund($id,$amount=10){
     global $db;
    //if(sqL1('charity','id',$id)==0){
    $db->query("INSERT INTO charity (id,amount) VALUES ('$id','$amount')");
    $db->query("UPDATE globeuser SET charity=1 WHERE id='$id' ");
       // }
return;   
}
function autoMateCharity(){
    global $db;
   $sql = $db->query("SELECT * FROM globeuser WHERE level>3 AND charity=0 LIMIT 20 ");
   while($row=mysqli_fetch_assoc($sql)){
    addCharityFund($row['id']);
   }
}

autoMateCharity();

function charityFunds($type){
    global $db;
    $sql = $type==1 ? $db->query("SELECT SUM(amount) AS sum FROM charity WHERE amount>0 ") : $db->query("SELECT SUM(amount) AS sum FROM charity WHERE amount<0 ");
    $sql = $type==3 ? $db->query("SELECT SUM(amount) AS sum FROM charity ") : $sql;
    $row = mysqli_fetch_assoc($sql);
    return $row['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>Global Charity</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">CCI Charity Funds</h1>
                        </div><!-- /.col -->
                        <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">Global Charity</li>
                            </ol>
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                </div><!-- /.container-fluid -->
            </div>
            <!-- /.content-header -->

            <!-- Main content -->
            
                                    <div id="refresh"><?php if(isset($report)){$covis->Alert(); } ?></div>

        <div class="content-area py-1">
            <div class="container-fluid">


                <div class="row">
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-warning">
              <div class="inner">
                <div class="t-content">
                            <h6 class="text-uppercase mb-1">Contributors</h6>
                            <h1 class="mb-1" style="font-size: 28px"><?php echo number_format(sqL1('globeuser','charity',1)) ?></h1>
                        </div>
              </div>
              <div class="icon">
                <i class="ion ion-bag"></i>
              </div>
              <a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-info">
              <div class="inner">
                <div class="t-content">
                            <h6 class="text-uppercase mb-1">Contributed</h6>
                            <h1 class="mb-1" style="font-size: 28px">$<?php echo number_format(charityFunds(1),2) ?></h1>
                        </div>
              </div>
              <div class="icon">
                <i class="ion ion-bag"></i>
              </div>
              <a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-success">
              <div class="inner">
               <div class="t-content">
                        <h6 class="text-uppercase mb-1">Expended</h6>
                        <h1 class="mb-1" style="font-size: 28px">$<?php echo number_format(abs(charityFunds(2)),2) ?></h1>
                    </div>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              <a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-danger">
              <div class="inner">
                <div class="t-content">
                    <h6 class="text-uppercase mb-1">Balance</h6>
                    <h1 class="mb-1" style="font-size: 28px">$<?php echo number_format(charityFunds(3),2) ?></h1>
                </div>
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>

        </div>
</div>

          <div class="col-md-12">
               <div class="card">
                   <div class="card-header text-white bg-dark">
                                    <h5 style="float: left">Recent Contributions</h5>
                                    <form class="mt-3" method="post">
                                    <div class="float-right" style="margin-top: -20px"><table><tr><td><input type="text" name="q" required class="form-control" placeholder="Username"></td><td><button type="submit" name="Serach" class="btn btn-primary">Search Contributor</button></td><td></td></tr></table></div>
                                </form>
                                </div> 
                             <div class="card-body table-responsive">
                                 <table class="table table-bordered table-hover table-sm" id="example2">
                                        <tr>
                                            <th>S/N</th>
                                            <th>Contributor</th>
                                            <th>Username</th>
                                            <th>Location</th>
                                            <th>Amount</th>
                                            <th>Date</th>
                                        </tr>
                        <?php $q = isset($_POST['q']) ? $covis->userName3($_POST['q']) : '';
                         $sql = isset($_POST['q']) ? $db->query("SELECT * FROM charity WHERE id='$q' ORDER BY sn DESC LIMIT 20") : $db->query("SELECT * FROM charity WHERE amount>0 ORDER BY sn DESC LIMIT 20"); $sum = 0; $i=0;
                              while($row = $sql->fetch_assoc()){ $i +=1; $sum += $row['amount'];
                                        
                                            ?>
                                            <tr>
                                                <th><?php echo $i  ?></th>
                                                <th><?php echo userName($row['id'])  ?></th>
                                            <th><?php echo userName($row['id'],'user')  ?></th>
                                          <th><?php echo userName($row['id'],'state').' '.userName($row['id'],'country')  ?></th>
                                                
                                                <th>$<?php echo number_format($row['amount'],2)  ?></th>
                                             
                                                <th><?php echo date("jS M, Y H:i",strtotime($row['created']))  ?></th>
                                            </tr>
                                        <?php } ?>
                                        <tr>
                                            <th colspan="4">TOTAL</th>
                                            <th colspan="2">$<?php echo number_format($sum,2) ?></th>
                                        </tr>
                                    </table>
                             </div>



</div></div>
          <div class="col-md-12">
               <div class="card">
                   <div class="card-header text-white bg-dark">
                                    <h5>Charity Operations</h5>
                                </div> 
                             <div class="card-body table-responsive">
                                 <table class="table table-bordered table-hover table-sm" id="example2">
                                        <tr>
                                            <th>S/N</th>
                                            <th>Charity Information</th>
                                           
                                            <th>Amount</th>
                                            <th>Date</th>
                                        </tr>
                        <?php $sql = $db->query("SELECT * FROM charity WHERE amount<0 ORDER BY sn DESC LIMIT 20"); $sum = 0; $i=0;
                              while($row = $sql->fetch_assoc()){ $i +=1; $sum += $row['amount'];
                                        
                                            ?>
                                            <tr>
                                                <th><?php echo $i  ?></th>
                                                <th><?php echo $row['note']  ?></th>
                                                
                                                <th>$<?php echo number_format(abs($row['amount']),2)  ?></th>
                                             
                                                <th><?php echo date("jS M, Y H:i",strtotime($row['created']))  ?></th>
                                            </tr>
                                        <?php } ?>
                                        <tr>
                                            <th colspan="2">TOTAL</th>
                                            <th colspan="2">$<?php echo number_format(abs($sum),2) ?></th>
                                        </tr>
                                    </table>
                             </div>



</div></div>

<?php if($uidx==1){ ?>
<!-- /.row -->          <div class="col-md-12">
               <div class="card">
                   <div class="card-header text-white bg-dark">
                                    <h5>Process Charity Funds</h5>
                                </div> 
                             <div class="card-body">
                         <form method="post">
                            <textarea name="note" class="form-control" placeholder="Charity Details"></textarea>
                            <br>
                            <input type="number" class="form-control" name="amount" placeholder="Charity Amount">
<br>
                            <button class="btn btn-primary btn-block" name="ProcessCharity">Submit Charity Expenses</button></form>
                             </div>



</div></div>
<!-- /.row -->
<?php } ?>
                </div><!-- /.container-fluid -->
            </section>
            <!-- /.content -->
        </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 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>
       <script type="text/javascript">
            $(function(){
                $("#username").keyup(function(){
            var v = $(this).val();
            
            $.ajax({
                type: 'get',
                url : 'js/username.php?val='+v
            }).done(function(data){
                
                if(data == 0){
                    $("#output").html('');
                }
                else if(data == 1){
                    $("#output").html('Username Does Not Exist');
                }
                else {
                    $("#output").html(data);
                }
            })
        })
            })
    </script>
</body>
</html>

?>