Your IP : 3.145.92.213


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

<?php
session_start();
include("lib/connect.inc.php");
$uid = $covis->Uid();
if($uidx != 1){
    header("Location:../login.php");
}


?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>CCI Distributors</title>
    <link rel="shortcut icon" href="img/fav.png" />
    <!-- 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 -->
    <div class="content-wrapper">
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>CCI Distributors</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">CCI Distributors</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
        <!-- Content Header (Page header) -->
           <?php if(isset($report)){$covis->Alert(); } ?>
        <div 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">Structure Bonus Operations</h5>

                               
                                </div> 
                            <div class="card-body">
                                <div class="table-responsive">
                                    <?php $Ym = date('Ym'); $sql = $db->query("SELECT * FROM user WHERE mm='$Ym' "); 
                                    $n = mysqli_num_rows($sql); $s = sqL2('user','a',9,'mm',$Ym); $t=$n-$s; ?>
                                <table class="table table-bordered mb-2" width="100%">
                                    <tr>
                                        <td>Total Users:<br> <b><?= $n ?></b></td>
                                        <td>Cleared:<br> <b><?= $s ?></b></td>
                                        <td>Left:<br> <b><?= $t ?></b></td>
                                        <td>Total Paid:<br> <b>$<?php echo number_format(colSum1('walletdist','amount','mm',date('ym')),2); ?></b></td>
                                        
                                    </tr>
                                </table>
                            <form class="mt-3 float-left" method="post"><br>
                                   <button type="submit" name="shareDisPay" class="btn btn-primary">Manually Pay Distributors</button>
                                </form>
                            <form class="mt-3 float-right" method="post">
                                <table>
                                    <tr><td>Mega Distributor<input type="text" value="<?= sqLx('setup','sn',1,'d4') ?>" class="form-control" name="d4" ></td><td>Top Distributor<input type="text" value="<?= sqLx('setup','sn',1,'d3') ?>" class="form-control" name="d3" ></td><td>Distributor<input type="text" class="form-control" name="d2" value="<?= sqLx('setup','sn',1,'d2') ?>"></td><td>Sub Distributor<input type="text" class="form-control" name="d1" value="<?= sqLx('setup','sn',1,'d1') ?>"></td><td><br><button type="submit" name="UpdateTarget" class="btn btn-primary">Update Target</button></td></tr>
                                </table>
                                </form>
                            </div>
                                 
                             
                               <em>Maximum of 200 users can be processed at a time</em>

                            </div>
                        </div>
              
                    
                <div class="card">
                    <div class="card-header text-white bg-dark">
                                    <h5 style="float: left">List of Distributors</h5>

                               
                                </div> 


                            
                            <div class="card-body">
                    
                                    
                                    <div class="overflow-x-auto">

                 <table class="table table-striped table-bordered dataTable" id="example1">
                        <thead>
                        <tr>
                            <th>SN</th>
                            <th>Username</th>
                            <th>Type</th>
                            <th>Balance</th>
                            <th>Progress</th>
                            <th>Remark</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $i=1; $mm = date('ym');
                        $sql = $db->query("SELECT * FROM user WHERE level>4 ORDER BY level DESC "); 
                        while($row = mysqli_fetch_assoc($sql)) { $e = $i++; $t=$row['level']; $key=$row['sn']; $id=$row['id'];
if($t==5){$x = 'Sub Distributor'; $tg = sqLx('setup','sn',1,'d1');}elseif($t==6){$x = 'Distributor'; $tg = sqLx('setup','sn',1,'d2'); }elseif($t==7){$x = 'Top Distributor'; $tg = sqLx('setup','sn',1,'d3'); }else{$x = 'Mega Distributor'; $tg = sqLx('setup','sn',1,'d4');}
$gress = sqL2('walletdist','id',$row['sn'],'mm',$mm);
if($gress>=$tg AND sqL2('distributor','id',$id,'mm',$mm)==0){
    $db->query("INSERT INTO distributor(id,mm,type) VALUES('$id','$mm','$t') ");
}



                            ?>

                            <tr>
                                <td><?php echo $e; ?></td>
                                 <td><?php echo $row['user']; ?></td>
                                 <td><?php echo $x ?></td>
                                <td>$<?php echo number_format(colSum2('walletdist','amount','id',$key,'mm',date('ym')),2); ?></td>
                            <td><?= $gress.'/'.$tg ?></td>    <td><?= number_format(100*$gress/$tg,2) ?>%</td>
                        </tr>

                        <?php } ?>
                        </tbody>
                        <tfoot>

                        </tfoot>
                    </table>
                </div>
                                </div>
                            </div>


<?php  $mm = $_POST['mm']?date('ym',$_POST['mm']):date('ym'); $d = $_POST['mm']?date('Y-m-d',$_POST['mm']):date('Y-m-d');  ?>
 <div class="card">
                    <div class="card-header text-white bg-dark">
                                    <h5 style="float: left">Monthly Top Distributors for <?= date('F Y',strtotime($d)) ?></h5>

                               <div style="float: right;">
                                   <form method="post">
                                   <select name="mm" onchange="submit()" class="form-control">
                                      <option><?= date('F Y',strtotime($d)) ?></option> 
                                      <?php $i=1; $a=strtotime('2021-06-01'); while($i<=36 AND $a<time()){ $a +=2592000; $e=$i++; $mm1 = date("ym", $a);  $month = date("F Y", $a);  ?>
                                      <option value="<?= $a ?>"><?= $month ?></option> <?php } ?>

                                   </select> 
                               </form>
                               </div>
                                </div> 


                            
                            <div class="card-body">
                    
                                    
                                    <div class="overflow-x-auto">

                                    <!--     <div>
                                            <h4>Pay Distributor </h4>
                                            
                                            Amount to Credit
                                            <input type="number" name="amt" class="form-control">
                                            Payment Remark
                                            <input type="text" name="rem" class="form-control">
                                        </div> -->

                 <table class="table table-striped table-bordered dataTable" id="example1">
                        <thead>
                        <tr>
                            
                            <th>User</th>
                            <th>Type</th>
                            <th>Balance</th>
                            <th>Progress</th><th>Position</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
function mmValue($id,$mm){
   global $db;
$sql=$db->query("SELECT SUM(amount) AS value_sum FROM walletdist WHERE id = '$id' AND mm='$mm' AND amount>0 "); 
$row = mysqli_fetch_assoc($sql); 

return $row['value_sum'];
}

                        $i=1;
                        $sql = $db->query("SELECT * FROM distributor WHERE mm='$mm'ORDER BY sn ASC "); 
                        while($row = mysqli_fetch_assoc($sql)) { $e = $i++; $t=$row['type']; $id=$row['id'];
                        $sn = userName($id,'sn');
if($t==5){$x = 'Sub Distributor'; $tg = sqLx('setup','sn',1,'d1');}elseif($t==6){$x = 'Distributor'; $tg = sqLx('setup','sn',1,'d2'); }elseif($t==7){$x = 'Top Distributor'; $tg = sqLx('setup','sn',1,'d3'); }else{$x = 'Mega Distributor'; $tg = sqLx('setup','sn',1,'d4');}
$gress = sqL2('walletdist','id',$sn,'mm',$mm);




                            ?>

                            <tr>
                                <td><a href="javascript:;" onclick="paydx('<?= $id ?>','<?= userName($id) ?>')"> <?php echo userName($id); ?> [<?php echo userName($id,'user'); ?>]</a></td>
                                 <td><?php echo $x ?></td>
                                <td>$<?php echo number_format(mmValue($sn,$mm),2); ?></td>
                            <td><?= $gress.'/'.$tg ?></td>
                            <td><?php echo $e; ?></td>
                        </tr>

                        <?php } ?>
                        </tbody>
                        <tfoot>

                        </tfoot>
                    </table>
                    <h5>Accumulated Unpaid Bonuses for <?= date('F Y',strtotime($d)) ?>: $<?= number_format(colSum1('walletdist','amount','mm',$mm),2); ?> </h5>

                    
<form method="post">
    <?php if(date('d')<6){ ?>
    <button type="submit" name="creditDistributors" value="<?= date('ym',strtotime($d)) ?>" class="btn btn-primary"> Credit Distributors for <?= date('M Y',strtotime($d)) ?></button>
<?php } ?>
</form>
                </div>
                                </div>
                            </div>
                            </div>
                            </div><!-- /.card-header -->
                            <!-- /.card-body -->

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

        <!-- /.content -->
    </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 payd(u,v){
        alert(v+u);
    }

    $(function () {
        $("#example1").DataTable({
            "responsive": true,
            "autoWidth": false,
        });
        $('#example2').DataTable({
            "paging": true,
            "lengthChange": false,
            "searching": false,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
    });
</script>
</body>
</html>

?>