<? 
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='index.php' </script>";
  return;
}

$qry=mysqli_query($db,"select * from gst_expense where refno='$inno' and brcode='$brcode'");
if(mysqli_num_rows($qry)<=0)
{
 print"<script>alert('invalid invoice number');document.location='delete_viewinv1.php';</script>";
} 
if(($user=='mathew')||($user=='sreejith')||($user=='minosh')||($user=='antony'))
{
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>PSN </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 gst_expense where refno='$inno' and brcode='$brcode'");
$row=mysqli_fetch_array($qry1);       
$date = $row[1];
$newDate = date("d-m-Y", strtotime($date));

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


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

<tr><td align='left'><b>Expense Head</b></td><td ><b>:</b></td><td align='left'><? echo $row[2]; ?></td><td width=30%></td><td align='left'><b>Ref No </b></td><td><b> :</b></td><td align='left'><? echo $row[0]; ?></td></tr>
<tr><td align='left'><b>Customer Name</b></td><td ><b>:</b></td><td align='left'><? echo $row[3]; ?></td><td width=30%></td><td align='left'><b>Invoice Date </b></td><td><b> :</b></td><td align='left'><? echo $newDate; ?></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>Before Tax<th>CGST %<th>CGST Amt<th>SGST %<th>SGST Amt<th>IGST %<th>IGST Amt<th>Expense Amt Tot</tr>

<?
$i=1;
$s_ntot=0;
$l_ntot=0;
$res=mysqli_query($db,"select * from gst_expense where refno='$inno' and brcode='$brcode'");
while($res1=mysqli_fetch_array($res))
  {
   $tots=$res1[10];
   $disc=$res1[19]+$res1[20]+$res1[21]+$res1[23]+$res1[28];
   print "<tr><td>".$i."</td><td>".$res1['before_tax']."</td><td> ".$res1['cgstp']."</td><td>".$res1['cgstamt']."</td><td>".$res1['sgstp']."</td><td>".$res1['sgstamt']."</td><td>".$res1['igstp']."</td><td>".$res1['igstamt']."</td><td>".$res1['expense_amount']."</td></tr>";
   $i++;
   $s_ntot+= $res1['expense_amount']; 
  }

?>


</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 align='left'><a href="#pop2"  onclick='showHint1()' style="text-decoration:none;"><img src='images/back1.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>

<?
}
?>