<?php
session_start();
if (!isset($_SESSION['user_logged_in']) && $_SESSION['user_logged_in'] != 1) {
    header('Location:login.php');
}
require_once 'includes/config.php';
//Get Dashboard information

$totalcash=mysqli_fetch_array(mysqli_query($con,"SELECT SUM(credits) as total_cash FROM users WHERE status=1 AND role=3"));
$totalvoucher=mysqli_fetch_array(mysqli_query($con,"SELECT SUM(vouchers) as total_voucher FROM users WHERE status=1 AND role=3"));
$totalpoints=mysqli_fetch_array(mysqli_query($con,"SELECT SUM(point_wallet) as total_points FROM users WHERE status=1 AND role=3"));

$getEmployeeCount=mysqli_fetch_array(mysqli_query($con,"SELECT count(id) as total_users FROM users WHERE status=1 AND role=3"));




if($_SESSION['role']=='admin'){
	$getItemsCount=mysqli_fetch_array(mysqli_query($con,"SELECT count(id) as total_item FROM items WHERE status=1"));
}else{
	$getItemsCount=mysqli_fetch_array(mysqli_query($con,"SELECT count(id) as total_item FROM items WHERE status=1 AND employee_id=".$_SESSION['user']));
}
include_once('includes/header.php');
?>
    
      <!-- End Navbar -->
      <div class="content">
        <div class="container-fluid">
          <div class="row">
            <div class="col-lg-3 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-warning card-header-icon">
                  <div class="card-icon">
                    <i class="material-icons">content_copy</i>
                  </div>
                  <p class="card-category">(Total Cash)</p>
                  <h3 class="card-title"><?php echo $totalcash['total_cash']; ?>
                  </h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons text-danger">warning</i>
                    <a href="#pablo">More</a>
                  </div>
                </div>
              </div>
            </div>
           <!-- <div class="col-lg-3 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-success card-header-icon">
                  <div class="card-icon">
                    <i class="material-icons">store</i>
                  </div>
                  <p class="card-category">Total vouchers</p>
                  <h3 class="card-title"><?php echo $totalvoucher['total_voucher']; ?></h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">date_range</i> 
                  </div>
                </div>
              </div>
            </div>-->
			<div class="col-lg-3 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-info card-header-icon">
                  <div class="card-icon">
                    <i class="fa fa-twitter"></i>
                  </div>
                  <p class="card-category">Total Points</p>
                  <h3 class="card-title"><?php echo $totalpoints['total_points']; ?></h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">update</i> 
                  </div>
                </div>
              </div>
            </div>
            <div class="col-lg-3 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-danger card-header-icon">
                  <div class="card-icon">
                    <i class="material-icons">info_outline</i>
                  </div>
                  <p class="card-category">Total users</p>
                  <h3 class="card-title"><?php echo $getEmployeeCount['total_users']; ?></h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">local_offer</i> 
                  </div>
                </div>
              </div>
            </div>
            
          </div>
		  
		  <a href="cron.php" target="_blank" class="btn btn-primary " >Daily Earning Cron</a>
		   <div class="row">
            <div class="col-md-12">
              <div class="card">
                <div class="card-header card-header-primary">
                  <h4 class="card-title">Member TOPUP Settings  </h4>
                  <p class="card-category"></p>
                </div>
                <div class="card-body">


<?php


if (isset($_POST['topup_level'])) {
    
	
	$level_one=$_POST['level_one'];
	$one_voucher=$_POST['one_voucher'];
	$one_points=$_POST['one_points'];
	$level_two=$_POST['level_two'];
	$two_voucher=$_POST['two_voucher'];
	$two_points=$_POST['two_points'];
	$level_three=$_POST['level_three'];
	$three_voucher=$_POST['three_voucher'];
	$three_points=$_POST['three_points'];
	$level_four=$_POST['level_four'];
	$four_voucher=$_POST['four_voucher'];
	$four_points=$_POST['four_points'];
	
	
		$createCustomer=mysqli_query($con,"UPDATE member_topup_settings SET level_one='".$level_one."', one_voucher='".$one_voucher."', one_points='".$one_points."', level_two='".$level_two."', two_voucher='".$two_voucher."', two_points='".$two_points."', level_three='".$level_three."', three_voucher='".$three_voucher."', three_points='".$three_points."', level_four='".$level_four."', four_voucher='".$four_voucher."', four_points='".$four_points."', status=1 WHERE id=1");
		
		
	
	
	
}
$topups=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM member_topup_settings WHERE id=1"));
?>
  <form role="form" method="post" enctype="multipart/form-data">
   <div class="box-body">
   

   
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>Level 1</label>
	<input type="text" name="level_one" value="<?php echo $topups['level_one']; ?>" class="form-control"  >
	
   </div>
   </div>
   
    <!--<div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="one_voucher" value="<?php echo $topups['one_voucher']; ?>"  class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="one_points" value="<?php echo $topups['one_points']; ?>"  class="form-control"  >
    </div>
	
   </div>
   </div>
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>Level 2</label>
	<input type="text" name="level_two" value="<?php echo $topups['level_two']; ?>"  class="form-control"  >
	
   </div>
   </div>
   
   <!-- <div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="two_voucher" value="<?php echo $topups['two_voucher']; ?>"  class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="two_points" value="<?php echo $topups['two_points']; ?>"  class="form-control"  >
    </div>
	
   </div>
   </div>
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>Level 3</label>
	<input type="text" name="level_three" value="<?php echo $topups['level_three']; ?>"  class="form-control"  >
	
   </div>
   </div>
   
   <!-- <div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="three_voucher" value="<?php echo $topups['three_voucher']; ?>"  class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="three_points" value="<?php echo $topups['three_points']; ?>"  class="form-control"  >
    </div>
	
   </div>
   </div>
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>Level 4</label>
	<input type="text" name="level_four" value="<?php echo $topups['level_four']; ?>"  class="form-control"  >
	
   </div>
   </div>
   
   <!-- <div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="four_voucher" value="<?php echo $topups['four_voucher']; ?>"  class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="four_points"  value="<?php echo $topups['four_points']; ?>" class="form-control"  >
    </div>
	
   </div>
   </div>
   <div class="box-footer">
		<input type="submit" class="btn btn-primary " value="Update" name="topup_level">
   </div>
			  
   </form>
  </div>
  </div>
  </div>
  </div>
  </div>
  
     <div class="row">
            <div class="col-md-12">
              <div class="card">
                <div class="card-header card-header-primary">
                  <h4 class="card-title">Member Daily Commission  Settings </h4>
                  <p class="card-category"></p>
                </div>
                <div class="card-body">



<?php


if (isset($_POST['member_commi'])) {
    
	
	$normal=$_POST['normal'];
	$normal_voucher=$_POST['normal_voucher'];
	$normal_points=$_POST['normal_points'];
	$vip=$_POST['vip'];
	$vip_voucher=$_POST['vip_voucher'];
	$vip_points=$_POST['vip_points'];
	$platinum=$_POST['platinum'];
	$platinum_voucher=$_POST['platinum_voucher'];
	$platinum_points=$_POST['platinum_points'];
	
	
	
		$createCustomer=mysqli_query($con,"UPDATE member_commission_settings SET normal='".$normal."', normal_voucher='".$normal_voucher."', normal_points='".$normal_points."', vip='".$vip."', vip_voucher='".$vip_voucher."', vip_points='".$vip_points."', platinum='".$platinum."', platinum_voucher='".$platinum_voucher."', platinum_points='".$platinum_points."',  status=1 WHERE id=1");
		
		
	
	
	
}
$commission=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM member_commission_settings WHERE id=1"));
?>

  <form role="form" method="post" enctype="multipart/form-data">
   <div class="box-body">
   

   
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>Normal User</label>
	<input type="text" name="normal" value="<?php echo $commission['normal']; ?>"  class="form-control"  >
	
   </div>
   </div>
   
    <!--<div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="normal_voucher" value="<?php echo $commission['normal_voucher']; ?>"  class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="normal_points" value="<?php echo $commission['normal_points']; ?>"  class="form-control"  >
    </div>
	
   </div>
   </div>
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>VIP</label>
	<input type="text" name="vip"  value="<?php echo $commission['vip']; ?>" class="form-control"  >
	
   </div>
   </div>
   
   <!-- <div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="vip_voucher"  value="<?php echo $commission['vip_voucher']; ?>" class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="vip_points" value="<?php echo $commission['vip_points']; ?>"  class="form-control"  >
    </div>
	
   </div>
   </div>
   <div class="row">
   
   <div class="col-md-4">
   
   <div class="form-group">
   <label>Platinum</label>
	<input type="text" name="platinum" value="<?php echo $commission['platinum']; ?>"  class="form-control"  >
	
   </div>
   </div>
   
   <!-- <div class="col-md-4">
	 <div class="form-group">
	<label>Vouchers %</label>
	<input type="text" name="platinum_voucher" value="<?php echo $commission['platinum_voucher']; ?>"  class="form-control"  >
    </div>
	
   </div>-->
   <div class="col-md-4">
	 <div class="form-group">
	<label>Points %</label>
	<input type="text" name="platinum_points" value="<?php echo $commission['platinum_points']; ?>" class="form-control"  >
    </div>
	
   </div>
   </div>
   
   <div class="box-footer">
		<input value="Update" type="submit" name="member_commi" class="btn btn-primary">
   </div>
			  
   </form>
  </div>
  </div>
  </div>
  </div>
  </div>
          <!--<div class="row">
            <div class="col-md-4">
              <div class="card card-chart">
                <div class="card-header card-header-success">
                  <div class="ct-chart" id="dailySalesChart"></div>
                </div>
                <div class="card-body">
                  <h4 class="card-title">Daily Sales</h4>
                  <p class="card-category">
                    <span class="text-success"><i class="fa fa-long-arrow-up"></i> 55% </span> increase in today sales.</p>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">access_time</i> updated 4 minutes ago
                  </div>
                </div>
              </div>
            </div>
            <div class="col-md-4">
              <div class="card card-chart">
                <div class="card-header card-header-warning">
                  <div class="ct-chart" id="websiteViewsChart"></div>
                </div>
                <div class="card-body">
                  <h4 class="card-title">Email Subscriptions</h4>
                  <p class="card-category">Last Campaign Performance</p>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">access_time</i> campaign sent 2 days ago
                  </div>
                </div>
              </div>
            </div>
            <div class="col-md-4">
              <div class="card card-chart">
                <div class="card-header card-header-danger">
                  <div class="ct-chart" id="completedTasksChart"></div>
                </div>
                <div class="card-body">
                  <h4 class="card-title">Completed Tasks</h4>
                  <p class="card-category">Last Campaign Performance</p>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">access_time</i> campaign sent 2 days ago
                  </div>
                </div>
              </div>
            </div>
          </div>-->
          <!--<div class="row">
            <div class="col-lg-6 col-md-12">
              <div class="card">
                <div class="card-header card-header-tabs card-header-primary">
                  <div class="nav-tabs-navigation">
                    <div class="nav-tabs-wrapper">
                      <span class="nav-tabs-title">Tasks:</span>
                      <ul class="nav nav-tabs" data-tabs="tabs">
                        <li class="nav-item">
                          <a class="nav-link active" href="#profile" data-toggle="tab">
                            <i class="material-icons">bug_report</i> Bugs
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#messages" data-toggle="tab">
                            <i class="material-icons">code</i> Website
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#settings" data-toggle="tab">
                            <i class="material-icons">cloud</i> Server
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                      </ul>
                    </div>
                  </div>
                </div>
                <div class="card-body">
                  <div class="tab-content">
                    <div class="tab-pane active" id="profile">
                      <table class="table">
                        <tbody>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="" checked>
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Sign contract for "What are conference organizers afraid of?"</td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="">
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Lines From Great Russian Literature? Or E-mails From My Boss?</td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="">
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Flooded: One year later, assessing what was lost and what was found when a ravaging rain swept through metro Detroit
                            </td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="" checked>
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Create 4 Invisible User Experiences you Never Knew About</td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                        </tbody>
                      </table>
                    </div>
                    <div class="tab-pane" id="messages">
                      <table class="table">
                        <tbody>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="" checked>
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Flooded: One year later, assessing what was lost and what was found when a ravaging rain swept through metro Detroit
                            </td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="">
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Sign contract for "What are conference organizers afraid of?"</td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                        </tbody>
                      </table>
                    </div>
                    <div class="tab-pane" id="settings">
                      <table class="table">
                        <tbody>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="">
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Lines From Great Russian Literature? Or E-mails From My Boss?</td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="" checked>
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Flooded: One year later, assessing what was lost and what was found when a ravaging rain swept through metro Detroit
                            </td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="form-check">
                                <label class="form-check-label">
                                  <input class="form-check-input" type="checkbox" value="" checked>
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                              </div>
                            </td>
                            <td>Sign contract for "What are conference organizers afraid of?"</td>
                            <td class="td-actions text-right">
                              <button type="button" rel="tooltip" title="Edit Task" class="btn btn-primary btn-link btn-sm">
                                <i class="material-icons">edit</i>
                              </button>
                              <button type="button" rel="tooltip" title="Remove" class="btn btn-danger btn-link btn-sm">
                                <i class="material-icons">close</i>
                              </button>
                            </td>
                          </tr>
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-lg-6 col-md-12">
              <div class="card">
                <div class="card-header card-header-warning">
                  <h4 class="card-title">Employees Stats</h4>
                  <p class="card-category">New employees on 15th September, 2016</p>
                </div>
                <div class="card-body table-responsive">
                  <table class="table table-hover">
                    <thead class="text-warning">
                      <th>ID</th>
                      <th>Name</th>
                      <th>Salary</th>
                      <th>Country</th>
                    </thead>
                    <tbody>
                      <tr>
                        <td>1</td>
                        <td>Dakota Rice</td>
                        <td>$36,738</td>
                        <td>Niger</td>
                      </tr>
                      <tr>
                        <td>2</td>
                        <td>Minerva Hooper</td>
                        <td>$23,789</td>
                        <td>Curaçao</td>
                      </tr>
                      <tr>
                        <td>3</td>
                        <td>Sage Rodriguez</td>
                        <td>$56,142</td>
                        <td>Netherlands</td>
                      </tr>
                      <tr>
                        <td>4</td>
                        <td>Philip Chaney</td>
                        <td>$38,735</td>
                        <td>Korea, South</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>-->
        </div>
      </div>
	  
	  <?php include_once('includes/footer.php'); ?>
     