<?php session_start(); 

			
if ($_SESSION["dev"]!=""){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<title>Administration Panel</title>
<link media="screen" rel="stylesheet" type="text/css" href="css/admin.css"  />
<!--[if lte IE 6]><link media="screen" rel="stylesheet" type="text/css" href="css/admin-ie.css" /><![endif]-->
<script src="js/user.js"></script> 
</head>

<body>
	<!--[if !IE]>start wrapper<![endif]-->
	<div id="wrapper">
		<!--[if !IE]>start head<![endif]-->
		<div id="head">
			
			<!--[if !IE]>start logo and user details<![endif]-->
			<div id="logo_user_details">
				<h1 id="logo"><img src="images/tyres.png" alt="img" width="218" height="165" />	 </h1>
                
                 <div class="tyrename">
                <?php
				/*	if ($_SESSION['company']=="BEN"){
						echo "Benedictsons (Pvt) Ltd.";
					} else if ($_SESSION['company']=="THT"){
						echo "Tyre House Trading (Pvt) Ltd.";
					}*/
					echo $_SESSION['company'];	
				?> 
				</div>
              
							<!--[if !IE]>start user details<![endif]--><!--[if !IE]>end user details<![endif]-->
				
				
				
			</div>
			
			<!--[if !IE]>end logo end user details<![endif]-->
			
			
			
			<!--[if !IE]>start menus_wrapper<![endif]-->
			<?php
				include('menu_index.php');
			?>
			<!--[if !IE]>end menus_wrapper<![endif]-->
			
			
			
		</div>
		<!--[if !IE]>end head<![endif]-->
		
		<!--[if !IE]>start content<![endif]-->
		<div id="content">
			<?php
            	include('connectioni.php');
	
		$sqltmp="select * from invpara";
		$resulttmp=mysqli_query($GLOBALS['dbinv'],$sqltmp);
		$rowtmp = mysqli_fetch_array($resulttmp);
			
//		  echo "<label>";
//			if ($rowtmp["form_loc"]=="1"){
//				echo "<input type=\"radio\" name=\"radio\" id=\"rd_lock\" value=\"rd_lock\" checked=\"checked\" onclick=\"set_check();\"/> Lock</br></br>";
//				echo "<input type=\"radio\" name=\"radio\" id=\"rd_unlock\" value=\"rd_unlock\"  onclick=\"set_check();\"/> Un Lock</br>";
//			} else {
//				echo "<input type=\"radio\" name=\"radio\" id=\"rd_lock\" value=\"rd_lock\" onclick=\"set_check();\"/> Lock</br></br>";
//				echo "<input type=\"radio\" name=\"radio\" id=\"rd_unlock\" value=\"rd_unlock\"  checked=\"checked\" onclick=\"set_check();\"/> Un Lock</br>";
//			}
                if ($_SESSION["UserName"] == "malabe"){
			if ($rowtmp["block_c"]=="1"){
				echo "<input type=\"radio\" name=\"radio\" id=\"rd_lock\" value=\"rd_lock\" checked=\"checked\" onclick=\"set_check('1');\"/> Lock</br></br>";
				echo "<input type=\"radio\" name=\"radio\" id=\"rd_unlock\" value=\"rd_unlock\"  onclick=\"set_check('0');\"/> Un Lock</br>";
			} else {
				echo "<input type=\"radio\" name=\"radio\" id=\"rd_lock\" value=\"rd_lock\" onclick=\"set_check('1');\"/> Lock</br></br>";
				echo "<input type=\"radio\" name=\"radio\" id=\"rd_unlock\" value=\"rd_unlock\"  checked=\"checked\" onclick=\"set_check('0');\"/> Un Lock</br>";
			}	
				
                }			
                          ?>
              <div style="overflow:scroll;height: 500px;width: 500px;" class='info'>
                                    <?php
                                    include('connectioni.php');
 if (($_SESSION["CURRENT_USER"] == "gayal11111") ) {

                                    
                                        echo "<table class='CSSTableGenerator' style=\"overflow-y:scroll; color:red; height:100px;overflow:scroll;\">";
                                        echo "<tr><th colspan=4' style='color:blue'>Problem Items</th></tr>";

                                        echo "<tr><th width ='50' style='color:blue'>STK NO</th>";
                                        echo "<th width ='200' style='color:blue'>Qty IN Hand</th>";
                                        echo "<th width ='80' style='color:blue'>True QTY</th>";
                                        echo "<th width ='80' style='color:blue'>Department</th></tr>";
     
                                        $sql11 = "update s_trn set tru_qty = qty where (ledindi = 'ARN' or ledindi ='GRN' or ledindi = 'GINRN' or ledindi = 'GINRNR' or ledindi ='IIN' or ledindi = 'TRN') ";
                                        
                                        $result_1 = mysqli_query($GLOBALS['dbinv'], $sql11);
                                        
                                                  
                                        $sql12 = "update s_trn set tru_qty = qty * -1 where (ledindi = 'ISO' or ledindi = 'ARR' or ledindi ='INV' or ledindi = 'GININ' or ledindi = 'GININR' or ledindi ='IOU')";
                                        $result_2 = mysqli_query($GLOBALS['dbinv'], $sql12);
                                        
                                                  
                                        $sql13 = "select stk_no,QTYINHAND,sum(tru_qty),department  from view_trn_submas where (   LEDINDI !='GINRNR' or   LEDINDI !='GININR')  group by stk_no,department  having qtyinhand <> sum(tru_qty)	";
                                        $result_3 = mysqli_query($GLOBALS['dbinv'], $sql13);
                                        while ($row_3 = mysqli_fetch_array($result_3)) {

                                            echo "<tr><td>" . $row_3['STK_NO'] . "</td>";
                                            echo "<td>" . $row_3['QTYINHAND'] . "</td>";
                                            echo "<td>" . $row_3['sum(tru_qty)'] . "</td>";
                                            echo "<td>" . $row_3['DEPARTMENT'] . "</td></tr>";
                                        }
                                        
                                        echo "<tr><th width ='50' style='color:blue' >STK NO</th>";
                                        echo "<th width ='200' style='color:blue'>Qty IN Hand</th>";
                                        echo "<th width ='80' style='color:blue'>True QTY</th>"; 
     
//                                        $sql14 = "update s_trn set tru_qty = qty where (ledindi = 'ARN' or ledindi ='GRN' or ledindi = 'GINR' or ledindi ='IIN'  or ledindi='TRN');";
//                                        $result_4 = mysqli_query($GLOBALS['dbinv'], $sql14);
//                                        $row_4 = mysqli_fetch_array($result_4);
//                                                  
//                                        $sql15 = "update s_trn set tru_qty = qty * -1 where (ledindi = 'ISO' or ledindi = 'ARR' or ledindi ='INV' or ledindi = 'GINI' or ledindi ='IOU');";
//                                        $result_5 = mysqli_query($GLOBALS['dbinv'], $sql15);
//                                        $row_5 = mysqli_fetch_array($result_5);
                                                  
                                        $sql16 = "select stk_no,QTYINHAND,sum(tru_qty)  from view_trn_smas  group by stk_no  having qtyinhand <> sum(tru_qty)";
                                        $result_6 = mysqli_query($GLOBALS['dbinv'], $sql16);
                                        while ($row_6 = mysqli_fetch_array($result_6)) {

                                            echo "<tr><td>" . $row_6['STK_NO'] . "</td>";
                                            echo "<td>" . $row_6['QTYINHAND'] . "</td>";
                                            echo "<td>" . $row_6['sum(tru_qty)'] . "</td></tr>";
                                        }

                                         echo "<tr><th colspan=4' style='color:blue'>Minus Items</th></tr>";

                                        echo "<tr><th width ='50' style='color:blue'>Item No</th>";
                                        echo "<th width ='200' style='color:blue'>Qty IN Hand</th>"; 
                                        echo "<th width ='80' style='color:blue'>Department</th></tr>";
                                        
                                        $sql17 = "select *  from s_mas  where QTYINHAND <0   ";
                                        $result_7 = mysqli_query($GLOBALS['dbinv'], $sql17);
                                        while ($row_7 = mysqli_fetch_array($result_7)) {

                                            echo "<tr><td>" . $row_7['STK_NO'] . "</td>";
                                            echo "<td>" . $row_7['QTYINHAND'] . "</td></tr>";
                                        }
                                        
                                         $sql18 = "select *  from s_submas  where QTYINHAND <0   ";
                                        $result_8 = mysqli_query($GLOBALS['dbinv'], $sql18);
                                        while ($row_8 = mysqli_fetch_array($result_8)) {

                                            echo "<tr><td>" . $row_8['STK_NO'] . "</td>";
                                            echo "<td>" . $row_8['QTYINHAND'] . "</td>";
                                            echo "<td>" . $row_8['STO_CODE'] . "</td></tr>";
                                        }
 }
                                    ?>




                                </div>
		
		  <!--[if !IE]>start page<![endif]-->
		  <!--[if !IE]>end page<![endif]-->
		  <!--[if !IE]>start sidebar<![endif]-->
		  <!--[if !IE]>end sidebar<![endif]-->
	  </div>
	  <!--[if !IE]>end content<![endif]-->
		
	</div>
	<!--[if !IE]>end wrapper<![endif]-->
	
	<!--[if !IE]>start footer<![endif]-->
	<div id="footer">
	</div>
	<!--[if !IE]>end footer<![endif]-->
	
</body>
</html>
<?php
} else {
	echo "Invalied Login User ***********!!!"; 
}
?>