<?php
	ob_start();
	session_start();
?>
<?php
	if(!isset($_SESSION["adminname"]) && !isset($_SESSION["username"]))
	{
		header("Location: index.php");
	}
?>
<html>
<head><title>BM BIO ENERGY</title>
<style type="text/css">
.view
{
padding: 2px;
font-weight: bold;
width: 11%;
background: #5CB85C none repeat scroll 0% 0%;
font-size: 24px;
color: #FFF;
text-decoration: none;
border: 1px solid #FFF;
text-align: center;
border-radius: 4px;
height: 27px;
position: absolute;
right: 516px;
top: 566px;
}
.pdf
{
padding: 2px;
font-weight: bold;
width: 11%;
background: #5CB85C none repeat scroll 0% 0%;
font-size: 24px;
color: #FFF;
text-decoration: none;
border: 1px solid #FFF;
text-align: center;
border-radius: 4px;
height: 27px;
position: absolute;
right: 350px;
top: 56px;
}
label{ 
font-size: 25px; 
width:29%;
float: left;
} 
.box1
{
margin-top: -36px;
width:100%;

}

.box2
{
width: 33%;
float: left;
margin-top: 30px;
}
.box22
{
width: 67%;
float: left;
margin-top: -311px;
margin-left: 418px;
}
.box33
{
width: 26%;
float: right;
margin-top: -357px;
margin-right: 73px;
}
.box44
{
width: 60%;
float: left;
margin-top: -212px;
margin-left: 1061px;
}
.box3
{
width: 66%;
float: left;
font-size: 24px;
}
.seae
{
width: 7%;
float: left;
font-size: 18px;
font-weight: bold;
}
.box4
{
width: 85%;
float: left;
margin-top: 13px;
}
.don
{
width: 100%;
float: left;
}
.inpu
{ 
width: 100%;
border: 1px solid #000;
height: 35px;
font-size: 18px;
border-radius: 4px;
margin-top: 8px;
}

.inpu1
{ 
width: 100%;
}
table, tr, td {
border: 1px solid white;
border-collapse: collapse;
padding: 8px;
font-size: 19px;
}
table  input[type=text]
{
height: 33px;
border: 1px solid #000;
border-radius: 4px;
font-size: 15px;
padding: 9px;
}

table {
width: 100%;
}
.table
{
margin: 29px;
width: 90%;
font-size: 23px;
}
.fool
{
width: 60%;
float: left;
margin-left: 12%;
}
.thala 
{
width: 100%;
color: #FFF;
margin-top: 0px;
}
.bo
{
margin-top: 12px;
width: 99%;
margin-left: 23px;
}
.se
{
margin-top: 11px;
width: 38%;
}
.out
{
background-color: #5CB85C;
text-decoration: none;
width: 12%;
height: 28px;
float: right;
text-align: center;
color: #FFF;
border-radius: 4px;
border: 1px solid #FFF;
top: 0px !important;
position: absolute;
margin-left: 40px;
}
.voice
{
width: 20%;
height: 28px;
border-radius: 4px;
border: 1px solid black;
font-size: 18px;
}
.sub
{
font-weight: bold;
width: 11%;
background: #5CB85C none repeat scroll 0% 0%;
font-size: 24px;
color: #FFF;
text-decoration: none;
border: 1px solid #FFF;
text-align: center;
border-radius: 4px;
height: 33px;
position: absolute;
right: 684px;
top: 566px;
font-family: times new;

}
.ser
{
width: 100%;
}
</head>
</style>


<?php
include("config.php");
if(isset($_POST['submit']))
{
$sqry=mysql_query("select * from report order by id desc limit 0,1");
$srw=mysql_fetch_array($sqry);
$rr=mysql_num_rows($sqry);	
$ss=1;
$d=date("d");
$m=date("m");
if($m=='04' )
{
	$dbd=$srw['date'];
	$rcindate_array=explode("-",$dbd);
	$dbdate=$rcindate_array[0];
	$dbmnth=$rcindate_array[1];
	if($d!=$dbdate && $m!=$dbmnth)
	{
		$ss=0;
	}
	else
	{
		$ss=1;
	}
}

if($rr==0 || $ss==0)
{
	$invoiceno=1;
}
else
{
	$dcn=$srw['invoiceno'];
	$invoiceno=$dcn+1;
}
$in=3;
$invoiceno = str_pad($invoiceno, $in, "0", STR_PAD_LEFT);
if($rr==0 || $ss==0)
{
	$dcno=001;
}
else
{
	$dcnum=$srw['dcno'];
	$dcno=$dcnum+1;
}
$dcno = str_pad($dcno, $in, "0", STR_PAD_LEFT);
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$address4=$_POST['address4'];
$lrno=$_POST['lrno'];
$invoiceno=$_POST['invoiceno'];
$orderno=$_POST['orderno'];
$dcno=$_POST['dcno'];
$tinno=$_POST['tinno'];
$remarks=$_POST['remarks'];
$date=$_POST['date'];
$dat1=$_POST['dat1'];
$dat2=$_POST['dat2'];
$transport=$_POST['transport'];
$adescription=$_POST['adescription'];
$a1l=$_POST['a1l'];
$a5l=$_POST['a5l'];
$a50l=$_POST['a50l'];
$aquantity=$_POST['aquantity'];
$aunitprice=$_POST['aunitprice'];
$sgst=$_POST['sgst'];
$sgstamount=$_POST['sgstamount'];
$cgst=$_POST['cgst'];
$cgstamount=$_POST['cgstamount'];
$igst=$_POST['igst'];
$igstamount=$_POST['igstamount'];
$aamount=$_POST['aamount'];
$aamount1=$_POST['aamount1'];
$taxamount=$_POST['taxamount'];
$cdate=date('Y-m-d');
$created_date=date('Y-m-d H:i:s');
 $sql="insert into report set cdate='{$cdate}',address1='{$address1}',address2='{$address2}',address3='{$address3}',address4='{$address4}',lrno='{$lrno}',invoiceno='{$invoiceno}',orderno='{$orderno}',dcno='{$dcno}',tinno='{$tinno}',remarks='{$remarks}',date='{$date}',dat1='{$dat1}',dat2='{$dat2}',transport='{$transport}',adescription='{$adescription}',a1l='{$a1l}',a5l='{$a5l}',a50l='{$a50l}',aquantity='{$aquantity}',aunitprice='{$aunitprice}',sgst='{$sgst}',sgstamount='{$sgstamount}',cgst='{$cgst}',cgstamount='{$cgstamount}',igst='{$igst}',igstamount='{$igstamount}',aamount='{$aamount}',aamount1='{$aamount1}',taxamount='{$taxamount}',created_date='{$created_date}',updated_date='{$created_date}'";
 mysql_query($sql)or die (mysql_error());
 
 
function convert_number_to_words($num) 
{
	$number =(float)number_format($num, 2, '.', '');echo '<br>';
	 $no = (float)number_format($number, 2, '.', '');echo '<br>';
	$pos=strrpos($number,'.');
	$type='';
	if($pos)
	{
	$type=substr($number,$pos+1);
	}
	$point = $type ;
	$hundred = null;
	$digits_1 = strlen($no);
	$digits_2 = strlen($point);
	$i = 0;
    $j = 0;
    $str = array();
    $str1 = array();
    $words = array('0' => '', '1' => 'one', '2' => 'two',
	'3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
	'7' => 'seven', '8' => 'eight', '9' => 'nine',
	'10' => 'ten', '11' => 'eleven', '12' => 'twelve',
	'13' => 'thirteen', '14' => 'fourteen',
    '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
    '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
    '30' => 'thirty', '40' => 'forty', '50' => 'fifty',
    '60' => 'sixty', '70' => 'seventy',
    '80' => 'eighty', '90' => 'ninety');
    $digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
    while ($i < $digits_1) {
     $divider = ($i == 2) ? 10 : 100;
     $number = floor($no % $divider);
     $no = floor($no / $divider);
     $i += ($divider == 10) ? 1 : 2;
     if ($number) {
        $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
        $str [] = ($number < 21) ? $words[$number] .
            " " . $digits[$counter] . $plural . " " . $hundred
            :
            $words[floor($number / 10) * 10]
            . " " . $words[$number % 10] . " "
            . $digits[$counter] . $plural . " " . $hundred;
     } else $str[] = null;
  }
   $str = array_reverse($str);
   $result = implode('', $str);
  while ($j < $digits_2) {
     $divider = ($j == 2) ? 10 : 100;
     $number1= floor($point % $divider);
     $point = floor($point / $divider);
     $j += ($divider == 10) ? 1 : 2;
     if ($number1) {
        $plural = (($counter = count($str1)) && $number1> 9) ? 's' : null;
        $hundred = ($counter == 1 && $str1[0]) ? ' and ' : null;
        $str1 [] = ($number1 < 21) ? $words[$number1] .
            " " . $digits[$counter] . $plural . " " . $hundred
            :
            $words[floor($number1 / 10) * 10]
            . " " . $words[$number1 % 10] . " "
            . $digits[$counter] . $plural . " " . $hundred;
     } else $str1[] = null;
  }
  $result1 = implode('', $str1);
   if($result1!='')
   {
	 $result1 ='And '. $result1.'Paise';
   }
   else
   {
	 $result1 ='';
	 
   }
  $string=$result . "Rupees  " .$result1. " Only";
  
    return strtoupper($string);
}
 
include("MPDF/mpdf.php");
//require_once("numberinword.php");
$mpdf=new mPDF(''); 
$mpdf=new mPDF('c','A4','','',0,0,0,0,0,0); 
//$mpdf=new mPDF('c','A4','','',10,15,50,35,10,10); 
$mpdf->useOnlyCoreFonts = true;    // false is default
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("");
$mpdf->SetAuthor("");
$mpdf->SetWatermarkText("");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
//$mpdf->mirrorMargins = 1;
$html = '
<html>
<head>
<title>BM BIO ENERGY</title>
<style>
.box2
{
position: absolute;
width: 100%;
left:77px;
top:137px;
font-size: 18px;
line-height:28px;
}
.box3
{
position: absolute;
width: 100%;
left:503px;
top:133px;
font-size: 18px;
line-height:30px;
}
.box4
{
position: absolute;
width: 100%;
left:682px;
top:129px;
font-size: 18px;
line-height:30px;
}
.box5
{
position: absolute;
width: 100%;
left:22px;
top:362px;
font-size: 14px;
line-height:27px;
}
.box6
{
position: absolute;
width: 100%;
left:60px;
top:793px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box7
{
position: absolute;
width: 100%;
left:145px;
top:879px;
font-size: 11px;	
line-height:40px;
}
.box8
{
position: absolute;
width: 100%;
left:18px;
top:393px;
font-size: 14px;
line-height:27px;
}
.box9
{
position: absolute;
width: 100%;
left:500px;
top:787px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box10
{
position: absolute;
width: 100%;
left:500px;
top:817px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box11
{
position: absolute;
width: 100%;
left:500px;
top:844px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box12
{
position: absolute;
width: 100%;
left:580px;
top:787px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box13
{
position: absolute;
width: 100%;
left:700px;
top:787px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box14
{
position: absolute;
width: 100%;
left:580px;
top:817px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box15
{
position: absolute;
width: 100%;
left:700px;
top:817px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box16
{
position: absolute;
width: 100%;
left:580px;
top:845px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.box17
{
position: absolute;
width: 100%;
left:700px;
top:845px;
font-size: 15px;	
line-height:40px;
font-weight: bold;
}
.don1
{
position: absolute;	
margin-left:15px !important;
margin-top: -13px !important;	
}
.don2
{
position: absolute;
margin-left:358px !important;
margin-top: -35px !important;	
}
.don3
{
position: absolute;
margin-left:395px !important;
margin-top: -28px !important;	
}
.don4
{
position: absolute;
margin-left: 426px !important;
margin-top: -24px !important;	
}
.don5
{
position: absolute;
margin-left: 473px !important;
margin-top: -23px !important;	
	
}
.don6
{
position: absolute;
margin-left: 575px !important;
margin-top: -25px !important;	
}
.don7
{
position: absolute;
margin-left: 675px !important;
margin-top: -25px !important;	
}
.don8
{
position: absolute;	
margin-left:35px !important;
margin-top: -8px !important;	
}
.don9
{
position: absolute;	
margin-left:35px !important;
margin-top: -10px !important;	
}
.don10
{
position: absolute;
margin-left: 500px !important;
margin-top: 795px !important;		
}
.don11
{
position: absolute;
margin-left: 575px !important;
margin-top: -75px !important;	
}
</style>
</head>
<body>
<!--mpdf

<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />';
										
									//	$html.="<div class=''><img src='img/vetri.jpg' width='100%' height='100%'></img></div>"; 
										
											$q1=mysql_query("select * from report where invoiceno='$invoiceno' and cdate='$cdate'");
											$q1res=mysql_fetch_assoc($q1);
											$html.="<div class='box2' ><div class='don'>".$q1res['address1']."</div><div class='don'>".$q1res['address2']."</div><div class='don'>".$q1res['address3']."</div><div class='don'>".$q1res['address4']."</div></div>";
											
											$html.="<div class='box3'><div class='don' >".$q1res['invoiceno']."</div><div class='don' >".$q1res['orderno']."</div><div class='don' >".$q1res['dcno']."</div><div class='don'>".$q1res['tinno']."</div></div>";
											
											$html.="<div class='box4'><div class='don' >".$q1res['date']."</div><div class='don'>".$q1res['dat1']."</div><div class='don'>".$q1res['dat2']."</div></div>";
											
											
										$html.="<div class='box5'><div class='don don1' ></div><div class='don don2' >".$q1res['a1l']."</div><div class='don don3' >".$q1res['a5l']."</div><div class='don don4' >".$q1res['a50l']."</div><div class='don don5' >".$q1res['aquantity']."</div><div class='don don6' >".$q1res['aunitprice']."</div><div class='don don7' style='font-weight: bold;font-size:15px' >".$q1res['aamount1']."</div></div><br>";
										$html.="<div class='box5'><div class='don don8'> GST No   : 34AAMFB9946N1ZO</div></div> <br>";
										$html.="<div class='box8'><div class='don don9' >HSN Code:38081011</div></div><br>";
											
											//$html.="<div class='box6'>ALWAYS DILUTE ONE LITRE OF AGRITONE 4.5 WITH 50 TIMES OF WATER.</div><br>";
											$html.="<div class='box6'><b>Remarks :</b>".$q1res['remarks']."</div><br><div class='box9' >SGST</div><div class='box12' >".$q1res['sgst']."</div><div class='box13' >".$q1res['sgstamount']."</div>";
											$html.="<div class='box10' >CGST</div><div class='box14' >".$q1res['cgst']."</div><div class='box15' >".$q1res['cgstamount']."</div>";
											$html.="<div class='box11' >IGST</div><div class='box16' >".$q1res['igst']."</div><div class='box17' >".$q1res['igstamount']."</div>";
											
											$html.="<div class='box7' style='font-weight: bold;' >".convert_number_to_words($taxamount)."<div style='margin-top:-47;margin-left: 555px !important;font-weight: bold;font-size:15px' >".$q1res['taxamount']."</div></div>";

$mpdf->useAdobeCJK = true;
$mpdf->SetAutoFont(AUTOFONT_ALL);
$mpdf->WriteHTML($html);

$date=date('d-m-Y');
$val='pdf/'.$date.'-'.$invoiceno.'.pdf'; 
$mpdf->Output($val, 'F');
$up=mysql_query("update report set pdf='$val' where invoiceno='$invoiceno'");
if($up){
	$_SESSION['s_msg']="Sales Order Status Updated Successfully!!!";
	?>
		<!--<script type="text/javascript">window.location.href="viewreport";</script>-->
		<?php
}
if($sql)
  {
	?>
<script type="text/javascript">window.location.href="pdfgen.php?dcno=<?=$dcno;?>";</script>
	<?php
  }

	?>
		<!--<script type="text/javascript">window.location.href="report1";</script>-->
		<?php
 }
$sqry=mysql_query("select * from report order by id desc limit 0,1");
$srw=mysql_fetch_array($sqry);
$rr=mysql_num_rows($sqry);	
	$ss=1;
	$d=date("d");
	$m=date("m");
	if($m=='04' )
	{
		$dbd=$srw['date'];
		$rcindate_array=explode("-",$dbd);
		$dbdate=$rcindate_array[0];
		$dbmnth=$rcindate_array[1];
		if($d!=$dbdate && $m!=$dbmnth)
		{
			$ss=0;
		}
		else
		{
			$ss=1;
		}
	}

	if($rr==0 || $ss==0)
	{
		$invoiceno=1;
	}
	else
	{
		$dcn=$srw['invoiceno'];
		$invoiceno=$dcn+1;
	}
	$in=3;
	$invoiceno = str_pad($invoiceno, $in, "0", STR_PAD_LEFT);
if($rr==0 || $ss==0)
{
	$dcno=001;
}
else
{
	$dcnum=$srw['dcno'];
	$dcno=$dcnum+1;
}
$dcno = str_pad($dcno, $in, "0", STR_PAD_LEFT);
	
?>


<body style="background-color: rgb(0, 150, 136);">
<div class="thala">
<center><h1>BM BIO ENERGY</h1></center><h2 style="margin-left:85%; ">
<a class="out" href="logout.php">Logout</a></h2>
</div>
<?php
if(isset($val))
{
?>
	<center><a target="_blank" href="<?php echo $val; ?>" class="pdf">Print PDF</a></center>
<?php
}
?>
<form method="post" enctype="multipart/form-data">
		<div class="box1">
			<div class="box2">
				<label>Address 1:</label>
				<div class="box3">
					<input type="text" placeholder="Address 1" class="inpu" name="address1" id="address1"  required maxlength=30/>
				</div>
			</div>
			<div class="box2">
				<label>Invoice No:</label>
				<div class="box3">
					<input type="text" placeholder="Invoice No" class="inpu" name="invoiceno" id="invoiceno" value="<?php echo $invoiceno;?>" required readonly />
				</div>
			</div>
			<div class="box2">
				<label>Date 1:</label>
				<div class="box3">
					<input type="text" placeholder="Date 1" class="inpu" name="date" id="date" onmouseover='datepickvals(this.id);'  />
				</div>
			</div>
		</div>
		<div style="clear:both;"></div>
		<div class="box1">
			<div class="box2">
				<label>Address 2:</label>
				<div class="box3">
					<input type="text" placeholder="Address 2" class="inpu" name="address2" id="address2"  required maxlength=30/>
				</div>
			</div>
			<div class="box2">
				<label>Order No:</label>
				<div class="box3">
					<input type="text" placeholder="Order No" class="inpu" name="orderno" id="orderno"  value='NIL' maxlength=10 readonly/>
				</div>
			</div>
			<div class="box2">
				<label>Date 2:</label>
				<div class="box3">
					<input type="text" placeholder="Date 2" class="inpu" name="dat1" id="dat1"  onmouseover='datepickvals(this.id);'/>
				</div>
			</div>
		</div>
		<div style="clear:both;"></div>
		<div class="box1">
			<div class="box2">
				<label>Address 3 :</label>
				<div class="box3">
					<input type="text" placeholder="Address 3" class="inpu" name="address3" id="address3"  required maxlength=30/>
				</div>
			</div>
			<div class="box2">
				<label>D.C No:</label>
				<div class="box3">
					<input type="text" class="inpu"name="dcno" id="dcno" placeholder="Our DC No"  value="<?php echo $dcno;?>" readonly  />
				</div>
			</div>
			<div class="box2">
				<label>Date 3 :</label>
				<div class="box3">
					<input type="text" class="inpu" name="dat2" id="dat2" onmouseover='datepickvals(this.id);' placeholder="Date 3"/>
				</div>
			</div>
		</div>
		<div style="clear:both;"></div>
		<div class="box1">
			<div class="box2">
				<label>Address 4 :</label>
				<div class="box3">
					<input type="text" placeholder="Address 4" class="inpu" name="address4" id="address4"  required maxlength=30/>
				</div>
			</div>
			<div class="box2">
				<label>TIN No:</label>
				<div class="box3">
					<input type="text" class="inpu" placeholder="Party`s TIN No" name="tinno" id="tinno"  maxlength=15 required/>
				</div>
			</div>
			<div class="box2">
				<label>Transport :</label>
				<div class="box3">
					<input type="text" class="inpu" name="transport" id="transport" placeholder="Transport">
				</div>
			</div>
		</div>
		<div style="clear:both;"></div>
		<div class="box1">
			<div class="box2">
				<label>LR No:</label>
				<div class="box3">
					<input type="text" class="inpu" name="lrno" id="lrno"  required maxlength=30 placeholder="LR No"/>
				</div>
			</div>
			<div class="box2">
				<label>Remarks:</label>
				<div class="box3">
					<input type="text" class="inpu" name="remarks" id="remarks" placeholder="Remarks"/>
				</div>
			</div>
		</div>
		
	<div style="clear:both;"></div><br>
		<table>
			<tbody>
			<tr><td>Description</td><td>1L</td><td>5L</td><td>50L</td><td>Quantity</td><td>Unit Price</td><td>SGST</td><td>CGST</td><td>IGST</td><td>Amount</td></tr>
			<tr><td><input type="text" class="inpu1" name="adescription"   id="adescription" value="AGRITONE 4.5" readonly /></td>
			<td><input type="text" class="inpu1" name="a1l" id="a1l" value="0"   onKeyUp="vetri(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" ></td>
			<td><input type="text" class="inpu1" name="a5l" id="a5l" value="0"   onKeyUp="vetri(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" ></td>
			<td><input type="text" class="inpu1" name="a50l" id="a50l" value="0"  onKeyUp="vetri(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" ></td>
			<td><input type="text" class="inpu1" name="aquantity" id="aquantity" value="" readonly /></td>
			<td><input type="text" class="inpu1" name="aunitprice" id="aunitprice" value="0"  onKeyUp="selvan(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" /></td>
			<td><input type="text" class="inpu1" name="sgst" id="sgst" value="0" onKeyUp="stax(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');"  ><input type="hidden" class="inpu1" name="sgstamount" id="sgstamount" value="0" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" ></td>
			<td><input type="text" class="inpu1" name="cgst" id="cgst" value="0"   onKeyUp="ctax(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" >
			<input type="hidden" class="inpu1" name="cgstamount" id="cgstamount" value="0"  onkeypress="this.value.replace(/[^0-9,\.]/g,'');" ></td>
			<td><input type="text" class="inpu1" name="igst" id="igst" value="0"   onKeyUp="itax(this.value);" onkeypress="this.value.replace(/[^0-9,\.]/g,'');" >
			<input type="hidden" class="inpu1" name="igstamount" id="igstamount" value="0"   onkeypress="this.value.replace(/[^0-9,\.]/g,'');" ></td>
			<td><input type="text" class="inpu1" name="aamount" value="" readonly id="aamount"/></td><input type="hidden" class="inpu1" name="taxamount" value="" readonly id="taxamount"/><input type="hidden" class="inpu1" name="aamount1" value="" readonly id="aamount1"/></td></tr>
			</tbody>
			</table>
			<div style="clear:both;"></div></br><br></br>
		    <div class="fool">
			<center>
			<input type="submit" name="submit" id="submit" class="sub"  value="Save">
			<a href="viewreport.php" class="view">Bill View</a>
			</center>	
			</div>
			
			</form>	

</body>
</html>
<script type="text/javascript">
	function vetri(e)
{
		e= e.replace(/[^0-9,\.]/g,'');
		var a1l=document.getElementById('a1l').value;
		var a5l=document.getElementById('a5l').value;
		var a50l=document.getElementById('a50l').value;
		if(a1l=='')
		{
			var a1l='0';
		}
		if(a5l=='')
		{
			var a5l='0';
		}
		if(a50l=='')
		{
			var a50l='0';
		}
		var aquantity= parseInt(a1l)+(parseInt(a5l)*5)+(parseInt(a50l)*50);
		document.getElementById('aquantity').value=aquantity;
		selvan();
}
	function selvan()
{
		var aquantity=document.getElementById('aquantity').value;
		var aunitprice=document.getElementById('aunitprice').value;
		if(aquantity=='')
		{
			var aquantity='0';
		}
		if(aunitprice=='')
		{
			var aunitprice='0';
		}
		var aamount3= parseInt(aquantity)*parseFloat(aunitprice);
		var aamount=Math.round(aamount3).toFixed(2);
		document.getElementById('aamount').value=aamount;
		document.getElementById('aamount1').value=aamount;
		cal();
}
	
	function stax()
{
		var aamount=document.getElementById('aamount').value;
		var aamount1=document.getElementById('aamount1').value;
		var aqty=document.getElementById('aquantity').value;
		var auprice=document.getElementById('aunitprice').value;
		var totamount = parseInt(aqty) * parseFloat(auprice);
		var sgst=document.getElementById('sgst').value;
		var cgst=document.getElementById('cgst').value;
		var igst=document.getElementById('igst').value;
		if(aamount1=='')
		{
			var aamount1='0';
		}
		if(sgst=='')
		{
			var sgst='0';
		}
		var aamounts= (parseInt(sgst)/100)*parseFloat(totamount);
		var aamountc= (parseInt(cgst)/100)*parseFloat(totamount);
		var aamounti= (parseInt(igst)/100)*parseFloat(aamount1);
		var taxamount = aamountc + aamounts + aamounti;
		var saamount=taxamount.toFixed(2);
		var saamounts= aamounts.toFixed(2);

		document.getElementById('sgstamount').value=saamounts;
		var staamount3=parseFloat(taxamount)+parseFloat(totamount);
		var staamount=Math.round(staamount3).toFixed(2);
		document.getElementById('aamount').value=staamount;
		document.getElementById('taxamount').value=staamount;
		cal();
}
function ctax()
{
		var aamount=document.getElementById('aamount').value;
		var aamount1=document.getElementById('aamount1').value;
		var aqty=document.getElementById('aquantity').value;
		var auprice=document.getElementById('aunitprice').value;
		var totamount = parseInt(aqty) * parseFloat(auprice);
		var cgst=document.getElementById('cgst').value;
		var sgst=document.getElementById('sgst').value;
		var igst=document.getElementById('igst').value;
		if(aamount1=='')
		{
			var aamount1='0';
		}
		if(cgst=='')
		{
			var cgst='0';
		}
		var aamountc= (parseInt(cgst)/100)*parseFloat(totamount);
		var aamounts= (parseInt(sgst)/100)*parseFloat(totamount);
		var aamounti= (parseInt(igst)/100)*parseFloat(aamount1);
		var taxamount = aamountc + aamounts + aamounti;
		var caamount=taxamount.toFixed(2);
		var caamountc= aamountc.toFixed(2);

		document.getElementById('cgstamount').value=caamountc;
		var ctaamount3=parseFloat(taxamount)+parseFloat(totamount);
		var ctaamount=Math.round(ctaamount3).toFixed(2);
		document.getElementById('aamount').value=ctaamount;
		document.getElementById('taxamount').value=ctaamount;
		cal();
}
function itax()
{
		var aamount1=document.getElementById('aamount1').value;
		var aamount=document.getElementById('aamount').value;
		var aqty=document.getElementById('aquantity').value;
		var auprice=document.getElementById('aunitprice').value;
		var totamount = parseInt(aqty) * parseFloat(auprice);
		var igst=document.getElementById('igst').value;
		if(aamount1=='')
		{
			var aamount1='0';
		}
		if(igst=='')
		{
			var igst='0';
		}
		var aamounti= (parseInt(igst)/100)*parseFloat(totamount);
		//alert(aamounti);
		var iaamount=aamounti.toFixed(2);
		document.getElementById('igstamount').value=iaamount;
		var itaamount3=parseFloat(iaamount)+parseFloat(totamount);
		var itaamount=Math.round(itaamount3).toFixed(2);
		document.getElementById('aamount').value=itaamount;
		document.getElementById('taxamount').value=itaamount;
		cal();
}

</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="dp/js/jquery.timepicker.js"></script>
<script src="dp/lib/bootstrap-datepicker.js"></script>
 <link rel="stylesheet" type="text/css" href="dp/lib/bootstrap-datepicker.css" />
		<script>
			function datepickvals(a)
		{
			$('#'+a).datepicker({
				'format': 'dd-mm-yyyy',
				'autoclose': true
			});
		}
		</script>
		 <script>
                $('#basicExample .time').timepicker({
                    'showDuration': true,
                    'timeFormat': 'g:ia'
                });

                $('#basicExample .date').datepicker({
							'minDate': '0',
							'numberOfMonths': '1',
                    'format': 'dd-mm-yyyy',
                    'autoclose': true
                });

        </script>