<? 
session_start();
include_once('../opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$inno=$_REQUEST['inno'];

if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}

$qry=mysqli_query($db,"select * from sparepurchase where purno='$inno' and brcode='$brcode'");
if(mysqli_num_rows($qry)<=0)
{
 print"<script>alert('invalid Purchase number');document.location='delete_itmpurch1.php';</script>";
} 

?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Online Shopping and Inventory Management System</title>
<style>


#mask {
	display: none;
	background:url(images/bgimg1.gif) repeat;
	//background: #000; 
	position: fixed; left: 0; top: 0; 
	z-index: 10;
	width: 100%; height: 100%;
	opacity: 0.8;
	z-index: 999;
}

.login-popup{
		display:none;
	background:white;
	padding: 10px; 	
	border: 2px solid #ddd;
	float: left;
	font-size: 1.2em;
	position: fixed;
	top: 4%; left: 45%;
	z-index: 99999;
	box-shadow: 0px 0px 20px #999;
	-moz-box-shadow: 0px 0px 20px #999; /* Firefox */
    -webkit-box-shadow: 0px 0px 20px #999; /* Safari, Chrome */
	border-radius:3px 3px 3px 3px;
    -moz-border-radius: 3px; /* Firefox */
    -webkit-border-radius: 3px; /* Safari, Chrome */
}
}

img.btn_close {
	float: right; 
	margin: -28px -28px 0 0;
}

fieldset { 
	border:none; 
}

form.signin .textbox label { 
	display:block; 
	padding-bottom:7px; 
}

form.signin .textbox span { 
	display:block;
}

form.signin p, form.signin span { 
	color:white; 
	font-size:11px; 
	line-height:18px;
} 

form.signin .textbox input { 
	background:#666666; 
	border-bottom:1px solid #333;
	border-left:1px solid #000;
	border-right:1px solid #333;
	border-top:1px solid #000;
	color:white; 
	border-radius: 3px 3px 3px 3px;
	-moz-border-radius: 3px;
    -webkit-border-radius: 3px;
	font:13px Arial, Helvetica, sans-serif;
	padding:6px 6px 4px;
	width:200px;
}

form.signin input:-moz-placeholder { color:white; text-shadow:0 0 2px #000; }
form.signin input::-webkit-input-placeholder { color:hwite; text-shadow:0 0 2px #000;  }

.submit button { 
	background: -moz-linear-gradient(center top, #f3f3f3, #dddddd);
	background: -webkit-gradient(linear, left top, left bottom, from(#f3f3f3), to(#dddddd));
	background:  -o-linear-gradient(top, #f3f3f3, #dddddd);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f3f3f3', EndColorStr='#dddddd');
	border-color:#000; 
	border-width:1px;
	border-radius:4px 4px 4px 4px;
	-moz-border-radius: 4px;
    -webkit-border-radius: 4px;
	color:#333;
	cursor:pointer;
	display:inline-block;
	padding:6px 6px 4px;
	margin-top:10px;
	font:12px; 
	width:100px;
}

.button:hover { background:#ddd; }

</style>

<style>
.cont
	{
	background-color:#3b5998;

	//background:url(images/bg-inner.jpg) #e9e0c3 repeat-x;
  	width: 100%;position: absolute ;
	height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
    }
.tble1 input {
background-color:transparent;
border: 0px solid;
height:20px;
//width:160px;
color:black;
}
.tble1
{
border-collapse:collapse;
//font-style:normal;
}	



</style>
 <?

$qry1=mysqli_query($db,"select * from sparepurchase where purno='$inno' and brcode='$brcode'");
$row=mysqli_fetch_array($qry1);       
$date = $row[entrydate];
//$newDate = date("d-m-Y", strtotime($date));

?>    
<body style="text-align: center;"  >


<center ><h2>ITEM PURCHASE</h2></center >
<form name='form1' id='form1' method='POST'>
 <table class='tbl2' id='tbl2' ><tr><td colspan='3'>
<table width=100%>

<tr><td align='left'><b>Supplier Name</b></td><td ><b>:</b></td><td align='left'><? echo $row[2]; ?></td><td width=40%></td><td align='left'><b>Purchase No </b></td><td><b> :</b></td><td align='left'><? echo $row[0]; ?></td></tr>
<tr><td align='left'><b>Purchase Date</b></td><td ><b>:</b></td><td align='left'><? echo $date; ?></td><td width=40%></td><td align='left'><b></b></td><td><b></b></td><td align='left'></td></tr>



</table>
</td></tr><tr><td colspan='3'>
<table width=100% class='tble1' border=1>

<tr bgcolor='#767668' style='color:white'><th>Sl No<th>Item<th>Item Name<th>Quantity<th>Price<th>Total Amount</tr>

<?
$i=1;
$s_ntot=0;
$l_ntot=0;
$res=mysqli_query($db,"select * from sparepurchase where purno='$inno' and brcode='$brcode'");
while($res1=mysqli_fetch_array($res))
  {
   $tots=$res1[supqty]*$res1[10];
   
   print "<tr><td>".$i."</td><td>".$res1[partcode]."</td><td> ".$res1[partname]."</td><td align=right>".$res1[supqty]."</td><td align=right>".$res1[10]."</td><td align=right>".$tots."</td></tr>";
   $i++;
   $s_ntot+=$tots; 
  }

$disc=0;
$disc=round($disc,2);
$additions=0;
$nettotal=$s_ntot-$disc+$additions;
?>


</table>

</td></tr>



             

<tr><td colspan='3' style="text-align:right;">
                    Grand Total
               
                    <input style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="sum_total" id="sum_total" value="<?echo $s_ntot; ?>" type="text">

</td><td></td></tr>
<tr><td colspan='3' style="text-align:right;">
                    Less: Discounts

                    <input style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="dis_total" id="dis_total" value="<?echo $disc; ?>" type="text">

</td><td></td></tr>
<tr><td colspan='3' style="text-align:right;">
                    Add:

                    <input style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="ad_total" id="ad_total" value="<?echo $additions; ?>" type="text">

</td><td></td></tr>
<tr><td colspan='3' style="text-align:right;">
                    Net Total

                    <input style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="nt_total" id="nt_total" value="<?echo $nettotal; ?>" type="text">

</td><td></td></tr>
<tr><td align='left'><a href="#pop2"  onclick='showHint1()' style="text-decoration:none;"><img src='../images/back.png'/></a></td><td colspan=2 align='center'><input type=button value='Delete' name='del' onClick=delfun('<? echo $inno ?>')></td></tr>
<tr><td colspan=3 align='left'></td></tr>

</table>
  </form>
	

		
</body></html>
