<?php 
ob_start();
session_start();
include 'config/config.php';
include 'config/function.php';
if($_SESSION['member_user_id']=='')
{
    header("Location:Login");
    exit();
}

?>
<html lang="en">

<head>
    <title>Dashboard : <?php echo get_company(); ?> </title>
   
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="Phoenixcoded">
    <!-- Favicon icon -->
    <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">

    <!-- vendor css -->
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
    
  <style>
/*      body {*/
/*   background-color: rgb(241, 241, 241); */
/*  background-color:black;*/
/*} */
.grid{
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(4, 1fr);
    margin-top: 3rem;
}
h1
{
/*   margin-top:200px; */
  color:black;
}
.lamp {
  position: relative;
  top: 70px;
  margin: 0 auto;
  height: 70px;
  width: 70px;
  background-color: brow;
  border-radius: 0px 10px 100% 0px;
  border-bottom: 3px solid rgb(144, 17, 58);
  box-shadow: inset 0 -50px 50px -20px rgb(144, 17, 58);
}

.lamp:before {
  content: '';
  display: block;
  height: 70px;
  width: 70px;
  margin-left: -70px;
  background-color: lightb;
  border-radius: 10px 0px 0px 100%;
  box-shadow: inset 0 -50px 50px -20px rgb(144, 17, 58);
  border-bottom: 3px solid rgb(144, 17, 58);
}

.flame {
  position: absolute;
  top: -65px;
  left: -30px;
  width: 60px;
  height: 60px;
  background: OrangeRed;
  border-radius: 0 110px 20px 110px;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
}

.flame:after {
  content: '';
  display: block;
  width: 60px;
  height: 60px;
  background: OrangeRed;
  border-radius: 0 110px 20px 110px;
  transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
  animation: flame_glare 1.5s linear infinite;
  -webkit-animation: flame_glare 1.5s linear infinite;
  -moz-animation: flame_glare 1.5s linear infinite;
}

.top {
  position: absolute;
  top: -40px;
  left: -70px;
  height: 85px;
  width: 120px;
  background-color: brown;
  border-radius: 100%;
  border-left: 10px solid rgb(144, 17, 58);
  border-right: 10px solid rgb(144, 17, 58);
  transform: rotateX(-60deg);
  -webkit-transform: rotateX(-60deg);
  -moz-transform: rotateX(-60deg);
  background: radial-gradient(OrangeRed, rgb(214, 23, 92) 40%, rgb(144, 17, 58));
  background: -webkit-radial-gradient(OrangeRed, rgb(214, 23, 92) 40%, rgb(144, 17, 58));
  background: -moz-radial-gradient(OrangeRed, rgb(214, 23, 92) 40%, rgb(144, 17, 58));
}

@keyframes flame_glare {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}
@keyframes glow
{
    0% { text-shadow: 0 0 10px violet, 0 0 20px #fff, 0 0 30px #EAB72F, 0 0 40px #e60073, 0 0 50px #e60073, 0 0 60px #EAB72F, 0 0 70px #EA5C2F}
    25% { text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fafa05, 0 0 40px #fafa05, 0 0 50px #2fa9ea, 0 0 60px #2fa9ea, 0 0 70px }
    50% { textShadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #e60073, 0 0 40px #e60073, 0 0 50px #362FEA, 0 0 60px #e60073, 0 0 70px #362FEA}
    100% { textShadow: 0 0 10px #fff, 0 0 20px #ff4da6, 0 0 30px #362FEA, 0 0 40px #EA5C2F, 0 0 50px #EAB72F, 0 0 60px #ff4da6, 0 0 70px #ff4da6}
}

.glow {
    font-size: 80px;
    color: #fff;
    text-align: center;
    animation: glow 1s infinite ease-in-out alternate;
}

.reward {
    text-align: center;
    animation: animate 
    1.5s linear infinite;
        }
        
 @keyframes animate {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 0;
    }
}

.crm-card:after {
    content: "";
    position: absolute;
    z-index: -1;
    height: 100%;
    width: 100%;
    inset-inline-end: -1.85rem;
   
    background-image: url(assets/images/cardbackground.png);
    background-repeat: no-repeat;
    opacity: 0.4;
    transform: scaleX(-1);
}
.crm-card {
  position: relative;
  overflow: hidden;
  z-index: 0;
  background:white;
  /*box-shadow:0px 3px 15px #ccc;*/
  margin-bottom:10px;

}
  </style>  

</head>
<body class="">
	<!-- [ Pre-loader ] start -->
	<div class="loader-bg">
		<div class="loader-track">
			<div class="loader-fill"></div>
		</div>
	</div>
	<!-- [ Pre-loader ] End -->
	<!-- [ Header ]  -->
<?php include 'inc/vertical.php'; ?>

<!-- [ Main Content ] start -->
<div class="pcoded-main-container">
    <div class="pcoded-content">
         <!--<h1 class="glow" style="color:black"><?php echo get_company(); ?></h1>-->
<!--<div class="grid">-->
<!--  <div>-->
<!--    <div class="lamp">-->
<!--			  <div class="top"></div>-->
<!--			  <div class="flame"></div>-->
<!--		</div>-->
<!--  </div>-->
<!--  <div>-->
<!--    <div class="lamp">-->
<!--			  <div class="top"></div>-->
<!--			  <div class="flame"></div>-->
<!--		</div>-->
<!--  </div>-->
<!--  <div>-->
<!--    <div class="lamp">-->
<!--			  <div class="top"></div>-->
<!--			  <div class="flame"></div>-->
<!--		</div>-->
<!--  </div>-->
<!--  <div>-->
<!--    <div class="lamp">-->
<!--			  <div class="top"></div>-->
<!--			  <div class="flame"></div>-->
<!--		</div>-->
<!--  </div>-->
<!--</div>-->
        <!-- [ breadcrumb ] start -->
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                            <h5 class="m-b-10 text-black">Dashboard Analytics</h5>
                            <h6 class="text-black"> <?php echo $member_user_id=$_SESSION['member_user_id']; ?> (<?php echo $_SESSION['member_name'] ?>)</h6>
                        </div>
                       
                    </div>
                </div>
            </div>
        </div>
<!-- <div id="myModal" class="modal fade">-->
<!--    <div class="modal-dialog">-->
<!--        <div class="modal-content">-->
<!--            <div class="modal-header">-->
<!--                  <button type="button" class="close" data-dismiss="modal">&times;</button>-->
<!--            </div>-->
<!--            <div class="modal-body">-->
<!--			<img src="images/goatour.png" style="height:100%;width:100%">-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->
        <!-- [ Main Content ] start -->
        <div class="row">
            <!-- table card-1 start -->
            <div class="col-md-12 col-xl-6">
                <div class="card flat-card">
                    <div class="row-table">
                        <div class="col-sm-6 card-body br">
                            <a href="ActiveCustomer">
                            <div class="row">
                                <div class="col-sm-5">
                                    <!--<i class="icon feather icon-eye text-c-green mb-1 d-block"></i>-->
                                    <img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                <?php
                                $strC="Select count(member_user_id) as cnt from tbl_memberreg where sponcer_id='$member_user_id' and is_customer=1";
                                $customer=get_value($strC);
                                ?>
                                <div class="col-sm-7 text-md-center">
                                    <h5 class="text-black"><?php echo $customer; ?></h5>
                                    <h6 class="text-black">Customer</h6>
                                </div>
                            </div></a>
                        </div>
                        <div class="col-sm-6 card-body">
                            <div class="row">
                                <div class="col-sm-5">
                              <img src="assets/images/team.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                 <?php
                                $strC="Select left_member from tbl_memberreg where member_user_id='$member_user_id' ";
                                $left_member=get_value($strC);
                                ?>
                                <div class="col-sm-7 text-md-center">
                              
                                    <h5 class="text-black"><?php echo $left_member; ?></h5>
                                    <h6 class="text-black">Left Team</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row-table">
                        <div class="col-sm-6 card-body br">
                            <div class="row">
                                 <div class="col-sm-5">
                              <img src="assets/images/team.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                  <?php
                                $strC="Select right_member from tbl_memberreg where member_user_id='$member_user_id' ";
                                $right_member=get_value($strC);
                                ?>
                                <div class="col-sm-7 text-md-center">
                                    <h5 class="text-black"><?php echo $right_member; ?></h5>
                                    <h6 class="text-black">Right Team</h6>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6 card-body">
                            <div class="row">
                                 <div class="col-sm-5">
                              <img src="assets/images/team.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                <div class="col-sm-7 text-md-center">
                                    <h5 class="text-black"><?php echo $right_member+$left_member ?></h5>
                                    <h6 class="text-black">Total Team</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- table card-1 end -->
            <!-- table card-2 start -->
            <div class="col-md-12 col-xl-6">
                <div class="card flat-card">
                    <div class="row-table">
                        <div class="col-sm-6 card-body br">
                            <div class="row">
                                <div class="col-sm-4">
                              <img src="assets/images/business.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                  <?php
                                $strC="Select  direct_business from tbl_memberreg where member_user_id='$member_user_id' ";
                                $direct_business=get_value($strC);
                                ?>
                                <div class="col-sm-8 text-md-center">
                                    <h4 class="text-black"><?php echo $direct_business; ?></h5>
                                    <h6 class="text-black">Direct Business</h6>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6 card-body">
                            <div class="row">
                                 <div class="col-sm-4">
                              <img src="assets/images/business.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                 <?php
                                $strC="Select  left_business from tbl_memberreg where member_user_id='$member_user_id' ";
                                $left_business=get_value($strC);
                                ?>
                                <div class="col-sm-8 text-md-center">
                                    <h5 class="text-black"><?php echo $left_business; ?></h5>
                                    <h6 class="text-black">Left Business</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row-table">
                        <div class="col-sm-6 card-body br">
                            <div class="row">
                                  <div class="col-sm-4">
                              <img src="assets/images/business.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                 <?php
                                $strC="Select  right_business from tbl_memberreg where member_user_id='$member_user_id' ";
                                $right_business=get_value($strC);
                                ?>
                                <div class="col-sm-8 text-md-center">
                                    <h5 class="text-black"><?php echo $right_business; ?></h5>
                                    <h6 class="text-black">Right Business</h6>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6 card-body">
                            <div class="row">
                                 <div class="col-sm-4">
                              <img src="assets/images/business.png" class="img-fluid img-4x " alt="" width="60">
                                </div>
                                 <?php
                                $strC="Select  paid_business from tbl_memberreg where member_user_id='$member_user_id' ";
                                $paid_business=get_value($strC);
                                ?>
                                <div class="col-sm-8 text-md-center">
                                 
                                    <h5 class="text-black"><?php echo $paid_business; ?></h5>
                                    <h6 class="text-black">Paid Business</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
               
            </div>
      
             <div class="col-md-12 col-xl-4">
          <div class="card custom-card crm-card card_border">
        <div class="card-body">
               <?php
              $strC="SELECT IFNULL(sum(net_amt),0) as income_id FROM tbl_member_income_dtails WHERE member_user_id='$member_user_id' and income_type='DIRECT INCOME'";
                                $DirectIncome=get_value($strC);
                                ?>
           <div class="d-flex flex-column mt-1">
                    <!--<img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="40" >-->
               <h5>Direct Income</h5>
                <h5 class="mb-0 d-flex align-items-center"><i class="fas fa-rupee-sign" style="color: #000;font-size: 15px;margin-top: 2px;}"></i> <span style="margin-left:6px"><?php echo $DirectIncome; ?> </span>
                </h5>
            </div>
        </div>
    </div>
            </div>
            <div class="col-md-12 col-xl-4">
          <div class="card custom-card crm-card card_border">
        <div class="card-body">
               <?php
                   $strC="SELECT IFNULL(sum(net_amt),0) as income_id FROM tbl_member_income_dtails WHERE member_user_id='$member_user_id' and income_type='BINARY INCOME'";
                                $MatchingIncome=get_value($strC);
                                ?>
           <div class="d-flex flex-column mt-1">
                    <!--<img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="40" >-->
               <h5>Binary Income</h5>
              <h5 class="mb-0 d-flex align-items-center"><i class="fas fa-rupee-sign" style="color: #000;font-size: 15px;margin-top: 2px;}"></i> <span style="margin-left:6px"><?php echo $MatchingIncome; ?> </span>
                </h5>
            </div>
        </div>
    </div>
            </div>
            <div class="col-md-12 col-xl-4">
          <div class="card custom-card crm-card card_border">
        <div class="card-body">
               <?php
                    $strC="SELECT IFNULL(sum(net_amt),0) as income_id FROM tbl_member_income_dtails WHERE member_user_id='$member_user_id' and paid_status=0";
                    $unpaidIncome=get_value($strC);
                                ?>
           <div class="d-flex flex-column mt-1">
                    <!--<img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="40" >-->
               <h5>Unpaid Income</h5>
                 <h5 class="mb-0 d-flex align-items-center"><i class="fas fa-rupee-sign" style="color: #000;font-size: 15px;margin-top: 2px;}"></i> <span style="margin-left:6px"><?php echo $MatchingIncome; ?> </span>
                </h5>
            </div>
        </div>
    </div>
            </div>
            <?php
            $strRe="Select * from tbl_reward_achivers where member_user_id='$member_user_id'";
            $resRe=mysqli_query($connection,$strRe);
            while($rowRe=mysqli_fetch_array($resRe))
            {
                $reward=$rowRe['reward_name'];
                $rewardAmt=$rowRe['rewardAmt'];
                $paid_status=$rowRe['paid_status'];
            ?>
            <!-- <div class="col-md-12 col-xl-4">-->
            <!--     <div class="card flat-card widget-purple-card" style="background-color: #f1c40f; padding:20px 0px">-->
            <!--        <div class="row-table" style="background-color: #f1c40f">-->
            <!--            <div class="col-sm-3" style="background-color: #f1c40f">-->
            <!--                <span class="reward">-->
            <!--                <img src="reward/<?php echo $reward; ?>.png" width="50" height="50"></span>-->
            <!--            </div>-->

            <!--            <div class="col-sm-9 text-center">-->
            <!--                <h4><?php echo $reward; ?></h4> Or-->
            <!--                <h4><?php echo $rewardAmt; ?> Rs.</h4>-->
            <!--                <h6>Achived Date : <?php echo date("d-M-Y",strtotime($rowRe['reward_date'])); ?> </h6>-->
            <!--                <h6><?php if($paid_status==0) { echo "Unpaid"; } else { echo "Paid"; } ?></h6>-->
            <!--            </div>-->
            <!--        </div>-->
            <!--    </div>-->
             
            <!--</div>-->
           <?php } ?>
           <!-- prject ,team member start -->
            <div class="col-xl-12 col-md-12 mt-5">
                <div class="card table-card">
                     <?php
                    $strC="SELECT calculate_date FROM tbl_member_income_dtails order by calculate_date desc limit 0,1";
                     $calculate_date=get_value($strC);
                     $last_closing=date("Y-m-d",strtotime($calculate_date));
                    ?>
                    <div class="card-header">
                        <h4>Current Income as on <?php echo date("d-M-Y",strtotime($calculate_date)); ?> </h4>
                    </div>
                    <div class="card-body p-0">
                        <div class="table-responsive">
                            <table class="table table-hover mb-0">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                      <th>Income Date</th>
                                      <th>Income Type</th>
                                      <th>Description</th>
                                      <th style="text-align:right">Income Amt</th>
                                      <th style="text-align:right">Deduction</th>
                                      <th style="text-align:right">Net Amt</th>
                                      <th style="text-align:right">Business(%)</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   <?php
                        $cnt=1;$income_amt=0;$ded_amt=0;$net_amt=0;
                        $qry="Select * from tbl_member_income_dtails where member_user_id='$member_user_id' and paid_status=0"; 
                        $ress=mysqli_query($connection,$qry);
                        while($row=mysqli_fetch_array($ress))
                        {
                            $income_amt=$income_amt+$row['income_amt'];
                            $ded_amt=$ded_amt+$row['tds_amt']+$row['admin_amt'];
                            $net_amt=$net_amt+$row['net_amt'];
                        ?>
                      <tr>
                        <td><?php echo $cnt++; ?></td>
                        <td><?php echo date("d-M-Y",strtotime($row['calculate_date'])); ?></td>
                        <td><?php echo $row['income_type']; ?></td>
                        <td><?php echo get_associate_name($row['income_member_user_id']); ?>(<?php echo$row['income_member_user_id']; ?>)</td>
                        <td style="text-align:right"><?php echo $row['income_amt']; ?></td>
                        <td style="text-align:right"><?php echo $row['tds_amt']+$row['admin_amt']; ?></td>
                        <td style="text-align:right"><?php echo $row['net_amt']; ?></td>
                         <td style="text-align:right"><?php echo $row['matching_business']; ?>-<?php echo $row['income_per']; ?>%</td>
                      </tr>
                      <?php } ?>
                      <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td style="text-align:right"><b>Total</b></td>
                        <td style="text-align:right"><b><?php echo $income_amt; ?></b></td>
                        <td style="text-align:right"><b><?php echo $ded_amt; ?></b></td>
                        <td style="text-align:right"><b><?php echo $net_amt; ?></b></td>
                        <td></td>
                      </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        
        </div>
        <!-- [ Main Content ] end -->
    </div>
</div>

    <!-- Required Js -->
    <script src="assets/js/vendor-all.min.js"></script>
    <script src="assets/js/plugins/bootstrap.min.js"></script>
    <script src="assets/js/pcoded.min.js"></script>

<!-- Apex Chart -->
<script src="assets/js/plugins/apexcharts.min.js"></script>
<!-- custom-chart js -->
<script src="assets/js/pages/dashboard-main.js"></script>
<script>
	$(document).ready(function(){
		$("#myModal").modal('show');
	});
</script>
</body>

</html>
