<?php
session_start();
  	if(!isset($_SESSION["adminname"]) && !isset($_SESSION["username"]))
	{
		header("Location: index.php");
	}
 
 
 
 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('config.php');
 $invid=$_GET['id'];

$result=mysql_query("select * from report where id=$invid");


if (mysql_num_rows($result) > 0) {
  // output data of each row
  while($row = mysql_fetch_assoc($result)) {
  //  echo "id: " . $row["id"]. " - Name: " . $row["tenant_id"]. " " . $row["amount"]. "<br>";
    $address1=$row["address1"];
    $address2=$row["address2"];
    $address3=$row["address3"];
    $address4=$row["address4"];
    
     $invoiceno=$row["invoiceno"];
    $orderno=$row["orderno"];
    $dcno=$row["dcno"];
    $tinno=$row["tinno"];
    
    
     $date=$row["date"];
    $dat1=$row["dat1"];
    $dat2=$row["dat2"];
    
     $a1l=$row["a1l"];
    $a5l=$row["a5l"];
    $a50l=$row["a50l"];
    $aquantity=$row["aquantity"];
    $aunitprice=$row["aunitprice"];
    $aamount1=$row["aamount1"];
    
    
     $remarks=$row["remarks"];
    $sgst=$row["sgst"];
    $sgstamount=$row["sgstamount"];
     $cgst=$row["cgst"];
      $cgstamount=$row["cgstamount"];
       $igst=$row["igst"];
        $igstamount=$row["igstamount"];
         $taxamount=$row["taxamount"];
     
     
     
   
  }
} else {
  echo "0 results";
}
 ?>



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta charset="utf-8" />
<style>
    @media print {
  #printPageButton {
    display: none;
  }
}
</style>
</head>

<body style="margin: 0;">
<input type="button" id="printPageButton" value="Print this page" onClick="window.print()">


<div id="p1" style="overflow: hidden; position: relative; background-color: white; width: 909px; height: 1286px;">

<!-- Begin shared CSS values -->
<style class="shared-css" type="text/css" >
.t {
	transform-origin: bottom left;
	z-index: 2;
	position: absolute;
	white-space: pre;
	overflow: visible;
	line-height: 1.5;
}
.text-container {
	white-space: pre;
}
@supports (-webkit-touch-callout: none) {
	.text-container {
		white-space: normal;
	}
}
@page { margin: 0; }
</style>
<!-- End shared CSS values -->


<!-- Begin inline CSS -->
<style type="text/css" >

#t1_1{left:88px;bottom:1076px;letter-spacing:-0.17px;}
#t2_1{left:88px;bottom:1044px;letter-spacing:-0.17px;}
#t3_1{left:88px;bottom:1012px;letter-spacing:-0.17px;}
#t4_1{left:88px;bottom:980px;letter-spacing:-0.18px;}
#t5_1{left:576px;bottom:1080px;letter-spacing:-0.19px;}
#t6_1{left:576px;bottom:1046px;letter-spacing:-0.21px;}
#t7_1{left:576px;bottom:1011px;letter-spacing:-0.19px;}
#t8_1{left:576px;bottom:977px;letter-spacing:-0.23px;}
#t9_1{left:781px;bottom:1085px;letter-spacing:-0.17px;}
#ta_1{left:781px;bottom:1050px;letter-spacing:-0.17px;}
#tb_1{left:781px;bottom:1016px;letter-spacing:-0.17px;}
#tc_1{left:435px;bottom:878px;}
#td_1{left:478px;bottom:879px;}
#te_1{left:513px;bottom:876px;}
#tf_1{left:567px;bottom:871px;}
#tg_1{left:684px;bottom:869px;letter-spacing:0.02px;}
#th_1{left:799px;bottom:866px;letter-spacing:0.09px;}
#ti_1{left:65px;bottom:832px;letter-spacing:0.02px;}
#tj_1{left:61px;bottom:799px;letter-spacing:0.02px;}
#tk_1{left:69px;bottom:341px;letter-spacing:0.09px;}
#tl_1{left:573px;bottom:348px;letter-spacing:0.12px;}
#tm_1{left:665px;bottom:348px;}
#tn_1{left:802px;bottom:348px;}
#to_1{left:573px;bottom:313px;letter-spacing:0.13px;}
#tp_1{left:665px;bottom:313px;}
#tq_1{left:802px;bottom:313px;}
#tr_1{left:573px;bottom:282px;letter-spacing:0.11px;}
#ts_1{left:665px;bottom:281px;letter-spacing:0.09px;}
#tt_1{left:802px;bottom:281px;letter-spacing:0.09px;}
#tu_1{left:166px;bottom:263px;letter-spacing:-0.25px;}
#tv_1{left:802px;bottom:250px;letter-spacing:0.09px;}

.s0{font-size:21px;font-family:'Times New Roman', Times, serif;color:#000;}
.s1{font-size:16px;font-family:'Times New Roman', Times, serif;color:#000;}
.s2{font-size:17px;font-family:'Times New Roman', Times, serif;color:#000;font-weight:bold;}
.s3{font-size:13px;font-family:'Times New Roman', Times, serif;color:#000;font-weight:bold;}
</style>
<!-- End inline CSS -->

<!-- Begin page background -->
<div id="pg1Overlay" style="width:100%; height:100%; position:absolute; z-index:1; background-color:rgba(0,0,0,0); -webkit-user-select: none;"></div>
<div id="pg1" style="-webkit-user-select: none;"><object width="909" height="1286" data="1/1.svg" type="image/svg+xml" id="pdf1" style="width:909px; height:1286px; -moz-transform:scale(1); z-index: 0;"></object></div>
<!-- End page background -->


<!-- Begin text definitions (Positioned/styled in CSS) -->
<div class="text-container"><span id="t1_1" class="t s0"><?php echo  $address1; ?></span>
<span id="t2_1" class="t s0"><?php echo  $address2; ?> </span>
<span id="t3_1" class="t s0"><?php echo  $address3; ?></span>
<span id="t4_1" class="t s0"><?php echo  $address4; ?></span>
<span id="t5_1" class="t s0"><?php echo  $invoiceno; ?></span>
<span id="t6_1" class="t s0"><?php echo  $orderno; ?></span>
<span id="t7_1" class="t s0"><?php echo  $dcno; ?> </span>
<span id="t8_1" class="t s0"><?php echo  $tinno; ?> </span>
<span id="t9_1" class="t s0"><?php echo  $date; ?>  </span>
<span id="ta_1" class="t s0"><?php echo  $dat1; ?>  </span>
<span id="tb_1" class="t s0"><?php echo  $dat2; ?>  </span>
<span id="tc_1" class="t s1"><?php echo  $a1l; ?></span><span id="td_1" class="t s1"><?php echo  $a5l; ?> </span>
<span id="te_1" class="t s1"><?php echo  $a50l; ?> </span>
<span id="tf_1" class="t s1"><?php echo  $aquantity; ?> </span>
<span id="tg_1" class="t s1"><?php echo  $aunitprice; ?> </span>
<span id="th_1" class="t s2"><?php echo  $aamount1; ?> </span>
<span id="ti_1" class="t s1">GST No : 34AAMFB9946N1ZO </span>
<span id="tj_1" class="t s1">HSN Code:38081011 </span>
<span id="tk_1" class="t s2">Remarks : <?php //echo  $remarks; ?></span>
<span id="tl_1" class="t s2">SGST </span><span id="tm_1" class="t s2"><?php echo  $sgst; ?></span><span id="tn_1" class="t s2"><?php echo  $sgstamount; ?> </span>
<span id="to_1" class="t s2">CGST </span><span id="tp_1" class="t s2"><?php echo  $cgst; ?> </span><span id="tq_1" class="t s2"><?php echo  $cgstamount; ?> </span>
<span id="tr_1" class="t s2">IGST </span><span id="ts_1" class="t s2"><?php echo  $igst; ?></span><span id="tt_1" class="t s2"><?php echo  $igstamount; ?> </span>
<span id="tu_1" class="t s3"><?php echo convert_number_to_words($taxamount); ?> </span>
<span id="tv_1" class="t s2"><?php echo  $taxamount; ?></span></div>
<!-- End text definitions -->


</div>
</body>
</html>
