<?php
ob_start();
error_reporting(0);
include("connect.php");
session_start();
$ver = $_SESSION['distributor_user_id'];
$user_role= $_SESSION['user_role']; 
if(!isset($_SESSION["distributor_user_id"])){
   header('location:https://tarkashcorp.appexperts.net/index.php');
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
      <?php include("link_head.php");?>
	  
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">-->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
	<script type="text/javascript">
		$(document).ready(function(){
			$("#myModal").modal('show');
		});
	</script>
	  
	  <style>
		::-webkit-scrollbar {
			display: none;
			overflow: hidden;
		}
	  </style>
	  <script>
		window.onscroll = function () {
		window.scrollTo(0,0);
		}
	  </script>
	  
<script>

// Both arguments are optional
function Toast(bgColor, textColor){
    this.bgColor = bgColor == null ? 'rgba(32, 32, 32, 0.9)' : bgColor;
    this.textColor = textColor == null ? '#DDD' : textColor;
    this.toastTime = 0;
    this.id = null;

    // document.head.style.innerText += 'Akash';
    this.show = function(msg){
      if(_(this.id) && _(this.id).style.display != "none"){
          clearTimeout(this.toastTime);
      }
      if(!(_(this.id))){
          var div = document.createElement("div");
          if(_("toast_div") !== null){
            this.id = 'toast_div' + document.querySelectorAll('#toast_div').length;
          }else{
            this.id = 'toast_div';
          }
        
          div.setAttribute("id", this.id);  
          div.style.minWidth = "5em";
          div.style.backgroundColor = this.bgColor;
          div.style.borderRadius = "3px";
          div.style.position = "fixed";
          div.style.bottom = "10%";
          div.style.right = "3%";
          div.style.padding = "1em";
          div.style.zIndex= "99";
          div.style.webkitAnimation= "popup 0.2s ease";
          div.style.animation= "popup 0.2s ease";
          var p = document.createElement("p");
          p.style.color = this.textColor;
          p.style.width = "100%";
          p.style.margin = "0%";
          p.style.display = "inline";
          p.style.fontFamily = "Arial";
          div.style.boxShadow = "0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)";
          var text = document.createTextNode(msg);
          p.appendChild(text);
          div.appendChild(p);
          document.body.appendChild(div);
          div.style.transition = "all 0.2s ease-in";
      }else{
          if(_(this.id).style.display != "none"){
              _(this.id).style.display = "none";
          }
          _(this.id).firstElementChild.innerHTML = msg;
      }
      _(this.id).style.display = "block";
      this.toastTime = setTimeout(function(){
          _(this.id).style.display = "none";
      }.bind(this), 10000);
    }

    function _(key){
      return document.getElementById(key);
    }
    
    if(_('toast_popup_animation') == null){
      var style = document.createElement('style');
      style.type = 'text/css';
      style.id = 'toast_popup_animation'; 
      style.textContent= '@-webkit-keyframes popup{ from { transform: scale(0); } to { transform: scale(1);} }' +
                        '@keyframes popup{ from { transform: scale(0); } to { transform: scale(1);} }';
      document.getElementsByTagName('head')[0].appendChild(style);  
    }
}

var toast = new Toast();
toast.show('Popup Message!');
</script>

<style>
.modal {
   position: absolute;
   width:22%;
   top: 50px;
   left: 77.9%;
   bottom: 0;
   right: 0;
   overflow: auto;
   overflow-y: auto;
}
</style>
	</head>
    <!-- END HEAD -->

    <body class="" onload="change();">
        <!-- BEGIN HEADER -->
		<?php include("header.php");?>
        <!-- END HEADER -->
		
		<!-- BEGIN Welcome Popup -->
<div id="myModal" class="modal fade" style="">
    <div class="modal-dialog">
        <div class="modal-content">
			<?php
			$res1 = mysqli_query($con,"select * from tbl_distributor_users where distributor_user_id='$ver'");
			$row1  = mysqli_num_rows($res1);
			$a=mysqli_fetch_array($res1);
			if($row1>0)
			{
				$r_temp=$_SESSION['user_session'];
				$user_name=$a['distributor_name'];
				$temp_activity=$a['activity_time'];
				$session_temp_r=$a['session_id'];
				$temp_time=time();
			}
			?>
            <center><div class="modal-header" style="border-top:3px solid #0AE68B; color:#36C6B8;">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right:300px;">&times;</button>
                <h3 class="modal-title" style="font-weight:bold;">Hello <?php echo $user_name; ?></h3>
            </div></center>
			<div class="modal-body" style="background-color:black; color:white; border-top:3px solid red; border-bottom:3px solid #0AE68B;">
				<?php
				$res2 = mysqli_query($con,"select * from tbl_master_customer where distributor_id='$ver'");
				$row2  = mysqli_num_rows($res2);
				?>
				<i class="glyphicon glyphicon-user" style="float:left; margin-top:22px; margin-left:10%; margin-right:2%;"></i>
				<p style="margin-left:5%;">Total Customers: <?php echo $row2 ?></p>
				<?php
				$res3 = mysqli_query($con,"select * from tbl_master_customer,tbl_transaction where tbl_master_customer.customer_id=tbl_transaction.customer_id and tbl_master_customer.distributor_id='$ver' && tbl_transaction.transaction_status='Pending'");
				$row3  = mysqli_num_rows($res3);
				?>
				<i class="icon-list" style="float:left; margin-top:3px; margin-left:10%; margin-right:2%;"></i>
				<p style="margin-left:5%;">Pending Orders: <?php echo $row3; ?></p>
				<?php
				$res4 = mysqli_query($con,"select * from tbl_master_customer,tbl_transaction where tbl_master_customer.customer_id=tbl_transaction.customer_id and tbl_master_customer.distributor_id='$ver' && tbl_transaction.transaction_status='Accept'");
				$row4  = mysqli_num_rows($res4);
				?>
				<i class="icon-check" style="float:left; margin-top:3px; margin-left:10%; margin-right:2%;"></i>
				<p style="margin-left:5%;">Accepted Orders: <?php echo $row4; ?></p>
			</div>
        </div>
    </div>
</div>
		<!-- END Welcome Popup -->
		
        <!-- BEGIN CONTAINER -->
        <div class="container-fluid">
            <div class="page-content page-content-popup" style="padding-bottom:0; margin-bottom:0;">
                <div class="page-sidebar-wrapper">
                    <!-- BEGIN SIDEBAR -->
                    <?php include("menu.php");?> 
				    <!-- END SIDEBAR -->
                </div>
                <div class="page-fixed-main-content">
                  
				<div class="row">
					<?php
					$res = mysqli_query($con,"select * from tbl_master_customer where distributor_id='$ver'");
					$row  = mysqli_num_rows($res);
					?>
					<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
						<a class="dashboard-stat dashboard-stat-v2 purple" href="customer-master.php">
							<div class="visual">
								<i class="fa fa-globe"></i>
							</div>
							<div class="details">
								<div class="number">
									<span data-counter="counterup" data-value="<?php echo $row; ?>"></span></div>
								<div class="desc">Total Customers </div>
							</div>
						</a>
					</div>
					
					<?php
					$res2 = mysqli_query($con,"select * from tbl_master_category where distributor_id='$ver'");
					$row2  = mysqli_num_rows($res2);
					?>
					<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
						<a class="dashboard-stat dashboard-stat-v2 blue" href="category-detail.php">
							<div class="visual">
								<i class="fa fa-globe"></i>
							</div>
							<div class="details">
								<div class="number">
									<span data-counter="counterup" data-value="<?php echo $row2; ?>"></span></div>
								<div class="desc">Total Categories </div>
							</div>
						</a>
					</div>	
					
					<?php
					$res3 = mysqli_query($con,"select * from tbl_master_category,tbl_master_product where tbl_master_category.category_id=tbl_master_product.category_id and tbl_master_category.distributor_id='$ver'");
					$row3  = mysqli_num_rows($res3);
					?>
					<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
						<a class="dashboard-stat dashboard-stat-v2 red" href="product_detail.php">
							<div class="visual">
								<i class="fa fa-globe"></i>
							</div>
							<div class="details">
								<div class="number">
									<span data-counter="counterup" data-value="<?php echo $row3; ?>"></span></div>
								<div class="desc">Total Products </div>
							</div>
						</a>
					</div>

					<?php
					$res4 = mysqli_query($con,"select * from tbl_master_customer,tbl_transaction where tbl_master_customer.customer_id=tbl_transaction.customer_id and tbl_master_customer.distributor_id='$ver' && tbl_transaction.transaction_status='Pending'");
					$row4  = mysqli_num_rows($res4);
					?>
					<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
						<a class="dashboard-stat dashboard-stat-v2 green" href="pending-orders.php">
							<div class="visual">
								<i class="fa fa-globe"></i>
							</div>
							<div class="details">
								<div class="number">
									<span data-counter="counterup" data-value="<?php echo $row4; ?>"></span></div>
								<div class="desc">Pending Orders </div>
							</div>
						</a>
					</div>	
					
					<?php
					$res5 = mysqli_query($con,"select * from tbl_master_customer,tbl_transaction where tbl_master_customer.customer_id=tbl_transaction.customer_id and tbl_master_customer.distributor_id='$ver' && tbl_transaction.transaction_status='Accept'");
					$row5  = mysqli_num_rows($res5);
					?>
					<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
						<a class="dashboard-stat dashboard-stat-v2 blue" href="accepted-orders.php">
							<div class="visual">
								<i class="fa fa-globe"></i>
							</div>
							<div class="details">
								<div class="number">
									<span data-counter="counterup" data-value="<?php echo $row5; ?>"></span></div>
								<div class="desc">Accepted Orders </div>
							</div>
						</a>
					</div>
					
					<?php
					$res1 = mysqli_query($con,"select * from tbl_master_customer,tbl_transaction where tbl_master_customer.customer_id=tbl_transaction.customer_id and tbl_master_customer.distributor_id='$ver' && tbl_transaction.transaction_status='Reject'");
					$row1  = mysqli_num_rows($res1);
					?>
					<div class="col-lg-2 col-md-3 col-sm-6 col-xs-12">
						<a class="dashboard-stat dashboard-stat-v2 purple" href="rejected-orders.php">
							<div class="visual">
								<i class="fa fa-globe"></i>
							</div>
							<div class="details">
								<div class="number">
									<span data-counter="counterup" data-value="<?php echo $row1; ?>"></span></div>
								<div class="desc">Rejected Orders</div>
							</div>
						</a>
					</div>
					
					
                </div>
				<!--<?php include("new1.php");?>-->
				<!--<button onclick="toast.show('Pending Order : <?php echo $row1; ?> Accepted Order : <?php echo $row2; ?>');">Notification</button>-->
                <!-- END FOOTER -->
              </div>
		   
		   </div>
		   
		   <div class="copyright-v2" style="padding:3px; margin-top:2px;"> 
		    <?=date("Y")?> &copy; Tarkashcorp Developed By <a target="_blank" href="http://www.belltechnology.in">Bell Technology</a>
           </div>
		   
	     </div>
        <!-- END CONTAINER -->
        		
        <!-- BEGIN CORE PLUGINS -->
        <?php include("link_script.php");?>  
        <!-- END THEME LAYOUT SCRIPTS -->
    </body>
</html>