<?php include("../../include/dbconnect.php"); 

$pgno=1;
$kount=1;

$result=mysqli_query($conn," select name,gstin from company where  compcode='$compcode' order by name") or die(mysqli_error());
$row=mysqli_fetch_row($result);
$company=$row[0];
$statecode = substr($row[1],0,2);
$sresult = mysqli_query($conn,"select state_name from states where state_code = '$statecode' ") or die(mysqli_error());
$srow = mysqli_fetch_row($sresult);
$st = $srow[0];
$string1='B2C (Small) from '. $stdt. ' to  ' .$edt;



$kount=$kount+6;	

?>

<table width=1241  border=0>
 <thead>
<tr> 
<td colspan="100%"  align="center"><div align="center"></div><font size="+2" face="Arial, Helvetica, sans-serif"> <?=$company?></font></td>  </tr>
<tr>
  <td  colspan="100%" align ="center"><h5>NIL Rated Supply  from &nbsp;<? echo($stdt);?> to  &nbsp;<? echo($edt);?></td></tr>
<tr><td colspan="100%"><hr/></td></tr>

				<tr>
				
                				<td width="404" align="left"><div align="center"><font size="-1">Description</font></div></td>
		<td width="285" align="right"><div align="center"><font size="-1">Nil Rated Supplies</font></div></td>      
                    	
				<td width="327" align="right"><div align="center"><font size="-1">Exempted (Other than Nil rated Non GST Supply)</font></div></td> 
				<td width="207" align="right"><div align="right"><font size="-1">Non GST Supplies</font></div></td>  
                              								
				</tr>
			 <tr><td><hr></td><td><hr></td><td><hr></td><td><hr></td></tr>

 </thead>

<?
$todate = $stdt;
$temp = $stdt;
$startdt = substr($temp,6,4).substr($temp,3,2).substr($temp,0,2);

$temp=$edt;
$enddt = substr($temp,6,4).substr($temp,3,2).substr($temp,0,2);

$temp=' ';
$temptot=0;

$presult = mysqli_query($conn,"select sum(S.value - S.discount_amt) from salesreg8b S, buy B where B.bcode = S.bcode and B.taxtype = 'INTERSTATE' and B.gstin !='' and S.vat_percent = 0 and S.inv_date between '$startdt' and '$enddt'  ")or die(mysqli_error());
	while($prow = mysqli_fetch_row($presult))
	{
		

		?>

		<tr>

												
		<td width="404" align="left"><font size="-1"> Inter State Supplies to registered Persons</font></td>	

                													
		<td width="285" align="left"><font size="-1"  color="#CC0000">
	    &nbsp;
		  </font></td>
		<td width="327" align="center"><font size="-1"  color="#CC0000"><?=$prow[0]?>
	    
		  </font></td>      
		<td width="207" align="right"><font size="-1"  color="#CC0000">&nbsp;</font></td>	               

		</tr>
        
        
 <?
	}

	$presult = mysqli_query($conn,"select sum(S.value - S.discount_amt) from salesreg8b S, buy B where B.bcode = S.bcode and B.taxtype = 'STATE' and B.gstin !='' and S.vat_percent = 0 and S.inv_date between '$startdt' and '$enddt'  ")or die(mysqli_error());
	while($prow = mysqli_fetch_row($presult))
	{
		

		?>

		<tr>

												
		<td width="404" align="left"><font size="-1"> Intra State Supplies to registered Persons</font></td>	

                													
		<td width="285" align="left"><font size="-1"  color="#CC0000">
	    &nbsp;
		  </font></td>
		<td width="327" align="center"><font size="-1"  color="#CC0000"><?=$prow[0]?>
	    
		  </font></td>      
		<td width="207" align="right"><font size="-1"  color="#CC0000">&nbsp;</font></td>	               

		</tr>
        
        
 <?
	}

	$presult = mysqli_query($conn,"select sum(S.value - S.discount_amt) from salesreg8b S, buy B where B.bcode = S.bcode and B.taxtype = 'INTERSTATE' and B.gstin ='' and S.vat_percent = 0 and S.inv_date between '$startdt' and '$enddt'  ")or die(mysqli_error());
	while($prow = mysqli_fetch_row($presult))
	{
		

		?>

		<tr>

												
		<td width="404" align="left"><font size="-1"> Inter State Supplies to unregistered Persons</font></td>	

                													
		<td width="285" align="left"><font size="-1"  color="#CC0000">
	    &nbsp;
		  </font></td>
		<td width="327" align="center"><font size="-1"  color="#CC0000"><?=$prow[0]?>
	    
		  </font></td>      
		<td width="207" align="right"><font size="-1"  color="#CC0000">&nbsp;</font></td>	               

		</tr>
        
        
 <?
	}
	
	
	

	$presult = mysqli_query($conn,"select sum(S.value - S.discount_amt) from salesreg8b S, buy B where B.bcode = S.bcode and B.taxtype = 'STATE' and B.gstin='' and S.vat_percent = 0 and S.inv_date between '$startdt' and '$enddt'   ")or die(mysqli_error());
$prow = mysqli_fetch_row($presult);
$s1 = $prow[0];
	
$presult = mysqli_query($conn,"select sum(S.value - S.discount_amt) from salesreg8b S where S.bcode = '0' and S.vat_percent = 0 and S.inv_date between '$startdt' and '$enddt'	")	or die(mysqli_error());
$prow = mysqli_fetch_row($presult);
$s2 = $prow[0];
$sum = $s1+$s2;
		?>

		<tr>

												
		<td width="404" align="left"><font size="-1"> Intra State Supplies to unregistered Persons</font></td>	

                													
		<td width="285" align="left"><font size="-1"  color="#CC0000">
	    &nbsp;
		  </font></td>
		<td width="327" align="center"><font size="-1"  color="#CC0000"><?=$sum?>
	    
		  </font></td>      
		<td width="207" align="right"><font size="-1"  color="#CC0000">&nbsp;</font></td>	               

		</tr>
		 

		<?  
		

 // second while loop
?>

				</tr>
			 <tr><td><hr></td><td><hr></td><td><hr></td><td><hr></td></tr>

 


</table>			 



</table>


</body>
</form>

<?



