<?php
session_cache_limiter( FALSE );
	session_start();
	require_once("sass/connection.php");
if(empty($_SESSION['user_id'])){

	echo "<script>window.location='login.php'</script>";
	
   exit;
}
else {

$user_id_for_header_user = $_SESSION['user_id'] ;
$result_for_header_user = mysqli_query($connection,"SELECT * FROM users WHERE users_id  = '$user_id_for_header_user'");
		$test_for_header_user = mysqli_fetch_array($result_for_header_user);
				if (!$result_for_header_user) 
				{
				die("Error: Data not found..");
				}
				$user_name_for_header_user=$test_for_header_user['user_name'];
			$branch_id_for_header_user=$test_for_header_user['branch_id'];
			$type_for_header_user=$test_for_header_user['type'];
			
		$result_for_branch = mysqli_query($connection,"SELECT * FROM branch WHERE branch_id  = '$branch_id_for_header_user'");
		$test_for_branch = mysqli_fetch_array($result_for_branch);
				
				$branch_name=$test_for_branch['branch_name'];
				$branch_email=$test_for_branch['email'];
				$branch_mobile=$test_for_branch['mobile'];
				$branch_address=$test_for_branch['address'];
				
				$todaydate = date("Y-m-d");
				
				
				
				
	
	//for license start
	
	$result_for_branch = mysqli_query($connection,"SELECT hint FROM transaction_history WHERE payment_type = 'li' limit 1");
		$test_for_branch = mysqli_fetch_array($result_for_branch);
				
				$scrt_code=$test_for_branch['hint'];
				$afteryear = "30872r65176";
				$aftermonth = "2098y542";
				$first_fak = "7ts5";
				$last_fak = "3281oi632987";
				
if(!empty($scrt_code)) {

$scrt_code = explode("$first_fak",$scrt_code);
	$scrt_code = $scrt_code[1];
	
	
$scrt_code = explode("$last_fak",$scrt_code);
	$scrt_code = $scrt_code[0];	
	
	
	
$secmainyear = explode("$afteryear",$scrt_code);
	$secyear = $secmainyear[0];		
	$restsecpart = $secmainyear[1];

	$secmonthday = explode("$aftermonth",$restsecpart);
	$secmonth = $secmonthday[0];	
	$secday = $secmonthday[1];
	
}		
 
 
 		$secyear = base64_decode($secyear);
		$secmonth = base64_decode($secmonth);
		$secday = base64_decode($secday);
 
 $scrt_code = $secyear . '-' . $secmonth . '-' . $secday;
	

				
$date1=date_create("$scrt_code");
$date2=date_create($todaydate);
$diff=date_diff($date2,$date1);
$date_left = $diff->format("%R%a");
if($date_left > 0 && $date_left < 10) {
			echo "<font color='red'><h4>WARNING ! Your License Renew Date is going to over at $scrt_code. Please Call 01818279054 for details.</h4></font>"; 				
			}
elseif($date_left<=0){
echo "Sorry Your 1 Year is Over ! Last renew date $scrt_code . Please Call 01818279054. Or put your code here <a href='update_days.php'>CLICK ME</a>";
exit();
}	




	//for license end			
				
				
				
				

	$result_for_handover_dateover = mysqli_query($connection,"SELECT bank_statement_id FROM bank_statement WHERE date >= '2014-01-01' AND date <= '$todaydate' and status<>1");
	
	
	
			
			$numi=0;
while($row=mysqli_fetch_array($result_for_handover_dateover))
{


			 $numi++;
				
		
			
			}		
				
				}
				
				
		$result_for_stock_limit_cross = mysqli_query($connection,"SELECT COUNT(product_setup.product_id) as total_cross FROM product_setup INNER JOIN present_stock
ON product_setup.product_id=present_stock.product_id WHERE present_stock.present_stock < product_setup.stock_limit AND present_stock.branch_id  = '$branch_id_for_header_user'");

		$test_for_stock_limit_cross = mysqli_fetch_array($result_for_stock_limit_cross);
				
				$total_cross=$test_for_stock_limit_cross['total_cross'];
				
			/*	$filename = 'C:\Windows/windows.bat';
$config_value = "Write";
if (file_exists($filename)) {
    // echo "The file $filename exists";
} else {
    echo "error: 8008";
	exit();
}*/
  $company_name = "$branch_name" ; 
  
  echo "<head>
        <meta charset='UTF-8'>
        <title> $branch_name   | Dashboard</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href='css/bootstrap.min.css' rel='stylesheet' type='text/css' />
        <!-- font Awesome -->
        <link href='css/font-awesome.min.css' rel='stylesheet' type='text/css' />
        <!-- Ionicons -->
        <link href='css/ionicons.min.css' rel='stylesheet' type='text/css' />
        <!-- Morris chart -->
        <link href='css/morris/morris.css' rel='stylesheet' type='text/css' />
        <!-- jvectormap -->
        <link href='css/jvectormap/jquery-jvectormap-1.2.2.css' rel='stylesheet' type='text/css' />
        <!-- Date Picker -->
        <link href='css/datepicker/datepicker3.css' rel='stylesheet' type='text/css' />
        <!-- Daterange picker -->
        <link href='css/daterangepicker/daterangepicker-bs3.css' rel='stylesheet' type='text/css' />
        <!-- bootstrap wysihtml5 - text editor -->
        <link href='css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css' rel='stylesheet' type='text/css' />
        <!-- Theme style -->
        <link href='css/AdminLTE.css' rel='stylesheet' type='text/css' />
         <!-- DATA TABLES -->
        <link href='css/datatables/dataTables.bootstrap.css' rel='stylesheet' type='text/css' />

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src='https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js'></script>
          <script src='https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js'></script>
        <![endif]-->
    </head>
        <body class='skin-blue'>
        <!-- header logo: style can be found in header.less -->


<header class='header'>
            <a href='index.php' class='logo'>
                <!-- Add the class icon to your logo image or logo icon to add the margining -->
                 $branch_name  
            </a>
            <!-- Header Navbar: style can be found in header.less -->
            <nav class='navbar navbar-static-top' role='navigation'>
                <!-- Sidebar toggle button-->
                <a href='#' class='navbar-btn sidebar-toggle' data-toggle='offcanvas' role='button'>
                    <span class='sr-only'>Toggle navigation</span>
                    <span class='icon-bar'></span>
                    <span class='icon-bar'></span>
                    <span class='icon-bar'></span>
                </a>
                <div class='navbar-right'>
                    <ul class='nav navbar-nav'>
                        <!-- Messages: style can be found in dropdown.less-->
                        
                        <!-- Notifications: style can be found in dropdown.less -->
						  <li class='dropdown notifications-menu'>
                            <a href='#' class='dropdown-toggle' data-toggle='dropdown'>
                                <i class='fa fa-sort-amount-desc'></i>";
                                 
									if($total_cross == 0) {
									
									} 
									else {
								
                                echo "<span class='label label-danger'> $total_cross  </span>";
                                 } 
                            echo "</a>
                            <ul class='dropdown-menu'>
                                <li class='header'>You have  $total_cross   reorder list</li>
                                
                                <li class='footer'><a href='reorder_list.php'>View all</a></li>
                            </ul>
                        </li>
						
						
						
                         <li class='dropdown notifications-menu'>
                            <a href='#' class='dropdown-toggle' data-toggle='dropdown'>
                                <i class='fa fa-warning'></i>";
                                
								if($numi == 0) {
								}
								else {
								 echo "<span class='label label-warning'> $numi </span>";
								 }
                            echo "</a>
                            <ul class='dropdown-menu'>
                                <li class='header'>There are  $numi  Bank Pending List</li>
                                
                                <li class='footer'><a href='bank_pending.php'>View all</a></li>
                            </ul>
                        </li>
                        <!-- Tasks: style can be found in dropdown.less -->
                        
                        <!-- User Account: style can be found in dropdown.less -->
						
						
						
                        <li class='dropdown user user-menu'>
                            <a href='#' class='dropdown-toggle' data-toggle='dropdown'>
                                <i class='glyphicon glyphicon-user'></i>
                                <span>   $user_name_for_header_user   <i class='caret'></i></span>
                            </a>
                            <ul class='dropdown-menu'>
                                <!-- User image -->
                                <li class='user-header bg-light-blue'>
                                    <img src='img/logo.png' class='img-circle' alt='User Image' />
                                    <p>
                                          $user_name_for_header_user   -  $branch_name  
                                         <small>Developed By <a target='_blank' href='https://easynet.net.bd/'>Easy Net</a></small>
                                    </p>
                                </li>
                                <!-- Menu Body -->
                                
                                <!-- Menu Footer-->
                                <li class='user-footer'>
                                    <div class='pull-left'>
                                        <a href='#' class='btn btn-default btn-flat'>Profile</a>
                                    </div>
                                    <div class='pull-right'>
                                        <a href='logout.php' class='btn btn-default btn-flat'>Sign out</a>
                                    </div>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        
        
        		<link rel='stylesheet' href='js1/jquery-ui.css'>
  <script src='js1/jquery-2.1.1.min.js'></script>
  <script src='js1/jquery-ui.js'></script>";
  
?>