<?php
ob_start();
session_name('CAKEPHP'); session_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
function convertDate($Dt)
{
	$dateBRK=explode('-',$Dt);
	$newFormat=$dateBRK[2]."/".$dateBRK[1]."/".$dateBRK[0];
	return $newFormat;
}

$sql="Select * from direct_po where id='".$_REQUEST['id']."'";
$result=DB_query($sql,$db);
$myrow=DB_fetch_array($result);
//  company Address
$sql1 = "SELECT * FROM companies where CompanyId='".$_SESSION['ACGCompanyId']."'";
$sqlres = DB_query($sql1,$db);
$companyRow = DB_fetch_array($sqlres);
?>
<?php
	

 function convert_number_to_words($number) {   
    $hyphen      = '-';
    $conjunction = ' and ';
    $separator   = ', ';
    $negative    = 'negative ';
    $decimal     = ' point ';
    $dictionary  = array(
        0                   => 'zero',
        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                  => 'fourty',
        50                  => 'fifty',
        60                  => 'sixty',
        70                  => 'seventy',
        80                  => 'eighty',
        90                  => 'ninety',
        100                 => 'hundred',
        1000                => 'thousand',
        1000000             => 'million',
        1000000000          => 'billion',
        1000000000000       => 'trillion',
        1000000000000000    => 'quadrillion',
        1000000000000000000 => 'quintillion'
    );
   
    if (!is_numeric($number)) {
        return false;
    }
   
    if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) {
        // overflow
        trigger_error(
            'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
            E_USER_WARNING
        );
        return false;
    }

    if ($number < 0) {
        return $negative . convert_number_to_words(abs($number));
    }
   
    $string = $fraction = null;
   
    if (strpos($number, '.') !== false) {
        list($number, $fraction) = explode('.', $number);
    }
   
    switch (true) {
        case $number < 21:
            $string = $dictionary[$number];
            break;
        case $number < 100:
            $tens   = ((int) ($number / 10)) * 10;
            $units  = $number % 10;
            $string = $dictionary[$tens];
            if ($units) {
                $string .= $hyphen . $dictionary[$units];
            }
            break;
        case $number < 1000:
            $hundreds  = $number / 100;
            $remainder = $number % 100;
            $string = $dictionary[$hundreds] . ' ' . $dictionary[100];
            if ($remainder) {
                $string .= $conjunction . convert_number_to_words($remainder);
            }
            break;
        default:
            $baseUnit = pow(1000, floor(log($number, 1000)));
            $numBaseUnits = (int) ($number / $baseUnit);
            $remainder = $number % $baseUnit;
            $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
            if ($remainder) {
                $string .= $remainder < 100 ? $conjunction : $separator;
                $string .= convert_number_to_words($remainder);
            }
            break;
    }
   
    if (null !== $fraction && is_numeric($fraction)) {
        $string .= $decimal;
        $words = array();
        foreach (str_split((string) $fraction) as $number) {
            $words[] = $dictionary[$number];
        }
        $string .= implode(' ', $words);
    }
   
    return $string;
}
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Purchases Order Form</title>
<link href="css/purchses.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form name="" id="" method="POST" action="">
<div id="page">
		
  <div id="form">
	<!-- Start Header --->
  	<div>
  	  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align:center; border-width:0 0 0 0;">
        <tr>
          <!--<td colspan="3" style="height:30px;font-size:30px; padding-left:0px;"><img src="images/logo1.png" width="160" height="23" /></td>-->
        </tr>
        <tr>
          <td colspan="3"><div style="text-align:center; margin:0px; border:#000000 solid 1px;">
              <?php 
		
		if($companyRow['CompanyName']!="") {echo "<b>".$companyRow['CompanyName']."</b>"; } else { echo "";}
		if($companyRow['Address1']!="") {echo "<br>".$companyRow['Address1']; } else { echo "";}
		if($companyRow['Address2']!="") {echo ",".$companyRow['Address2']; } else { echo "";}
		if($companyRow['Address3']!="") {echo ",".$companyRow['Address3']; } else { echo "";}
		if($companyRow['City']!="") {echo "<br>".$companyRow['City']; } else { echo "";}
		if($companyRow['State']!="") {echo ",".$companyRow['State']; } else { echo "";}
		if($companyRow['Country']!="") {echo ",".$companyRow['Country'];
		if($companyRow['Zipcode']!="") {echo " - ".$companyRow['Zipcode']; } else { echo "";}

		 } else { echo "";}
		echo "<br>"."<strong>Phone No</strong>.".$companyRow['Phone'].",   <strong>Fax No.</strong> ".$companyRow['fax'].",   <strong>Email ID.</strong> ".$companyRow['email'].",   <strong>Website</strong> ".$companyRow['website'];	
	?>
	<h3>Purchase Order</h3>
          </div></td>
        </tr>
      </table>

	

<div class="left_part" style="border:#000000 solid 1px;">

		<table width="100%" border="0" cellspacing="1" cellpadding="2">
  
  
  <tr>
    <td rowspan="6" style="width:150px; padding-left:10px; border-right-color:#000000; border-right-style:solid; border-right-width:1px;"><strong>SHIP TO</strong></td>
	
    <th>Branch Name</th>
	<td>:</td>
    <td><strong><?php echo ucwords($branchname=$s->getField('locations','loccode',$myrow['site'],locationname));?></strong></td>
	<?php
	$citysql="Select * from locations where loccode='".$myrow['site']."'";
		$cityrow=DB_query($citysql,$db);
		$city_res=DB_fetch_array($cityrow);
	?>
	<th>Phone</th>
	<td>:</td>
	<td><?php echo $city_res['mobile'];?></td>
  </tr>
	<tr>	
    <th>Address</th>	
	<td>:</td>
    <td>
		<?php echo $branch_address1=$s->getField('locations','loccode',$myrow['site'],deladd1);?>,
    	
    	<?php echo $branch_address2=$s->getField('locations','loccode',$myrow['site'],deladd2);?>
    	<?php echo $branch_address3=$s->getField('locations','loccode',$myrow['site'],deladd3);?>
    	<?php 
	    
		echo $branch_city=$s->getField('city_master','id',$city_res['city'],'city'); ?><br>
		<?php
    	 echo $branch_state=$s->getField('state_master','id',$city_res['state'],'state'); ?>
		
		,		<?php  echo $branch_state=$s->getField('country_master','id',$city_res['country'],'country'); ?></td>		
		
    <th>TIN No.</th>
	<td>:</td>
    <td><?php echo $city_res['tin_no'];?></td>
  </tr>
  <tr>
  	 <th>Email</th>
	<td>:</td>
    <td><?php echo  $city_res['email'];?></td>
      
    <th>Fax</th>
	<td>:</td>
    <td><?php echo $city_res['fax'];?>	</td>   
  </tr>
  
</table>
	<div style="clear:both;"></div>
	</div>
<div class="bordertop" style="border-collapse:collapse;">	  
	<div style="width:280px; float:left; margin:0px; padding-bottom:28px; border-right:#000000 solid 1px; height:180px;">
	<h1>PO Details</h1>	
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:120px;">Purchase Order No</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo $myrow['pr_no'];?></td>
  </tr>
  <tr>
    <th>Purchase Order Date</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo convertDate($myrow['pr_date']);?></td>
  </tr> 
  <tr>
    <th>Vendor Quotation Ref</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo $myrow['quotation_no']?></td>
  </tr>  
  <tr>
    <th>Vendor Quote Date</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo convertDate($myrow['quotation_date']);?></td>
  </tr>  
   <tr>
    <th>Payment mode</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo $payment_term=$s->getField('paymentmethods','paymentid',$myrow['payment_mode'],'paymentname');
	 ?></td>
  </tr> 
  <tr>
    <td colspan="3" style="height:5px;"></td>
  </tr>
  </table>  
	</div><!-- Table 1 close -->	
	<div style="width:247px; float:left;">
		<h1>Vendor Information</h1>		
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
       <tr>
    <th style="width:90px;">Vendor Name</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php
    	echo $vendor_name=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'vendor_name');
    	?></td>
  </tr>
  <tr>
    <th valign="top">Address</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;">
   	<?php echo $vender_address1=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'adrress1'); ?>&nbsp;<?php echo $vender_address1=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'adrress2'); ?>&nbsp;<?php echo $vender_address1=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'address3'); ?></td>
  </tr>
  <tr>
    <td colspan="3" style="padding-left:5px; padding-right:5px;"> </td>		
  </tr>
  <tr>
    <td colspan="3" style="padding-left:5px; padding-right:5px;"> </td>		
  </tr>
  <tr>
    <th>Ph.</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo $vender_address1=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'mobile'); ?></td>
  </tr>
  <tr>
    <th>TIN No.</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo $vender_address1=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'tin_no'); ?></td>
  </tr>
  <tr>
    <th>Email ID</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo $vender_address1=$s->GetFieldValue('suppliers',"id='".$myrow['vender_id']."'" ,'email'); ?></td>
  </tr>  
</table>
	
	</div><!-- Table 2 close -->

	<div style="width:261px; float:left; border-left-color:#000000; border-left-style:solid;  padding-bottom:28px;border-left-width:1px; height:180px;">
		<h1>Other Information</h1>
	
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:115px;">Delivery Place</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;">
    	<?php 
    	 echo $myrow['delivery_place'];
    	?></td>
  </tr>
  <tr>
    <th>Mode of Transport</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php 
	//echo "Select mode_transport from direct_po where id='".$_REQUEST['id']."'";
	$site_sql=DB_query("Select mode_transport from direct_po where id='".$_REQUEST['id']."'",$db);
	$site_row=DB_fetch_array($site_sql);?>
	<?php  echo $aa=$s->GetFieldValue('mode_transport',"id='".$site_row['mode_transport']."'" ,'name'); ?>
	
	</td>
  </tr>
  <tr>
    <th>Delivery Date</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php echo convertDate($myrow['delivery_date']);?></td>
  </tr>
  <tr>
    <th>Contact Person</th>
	<td>:</td>
    <td style="padding-left:5px; padding-right:5px;"><?php  echo $contact=$s->GetFieldValue('contact_information_master',"id='".$myrow['contact_person']."'" ,'person'); ?>
	</td>
  </tr>
</table>
	
	</div><!-- Table 3 close -->			
		<div class="cl"></div>
	  </div>

<div>
	
	
	<table  width="100%" border="0" cellspacing="0" cellpadding="0" class="tbale1" >
  <tr style="text-align:center; font-weight:bold;">
    <td width="8%" style="padding-top:5px; padding-bottom:5px; padding-left:5px;" align="left" class="row2">Item Code</td>
    <td width="13%" align="left" style="padding-left:5px;" class="row2">Item Name </td>
    <td width="18%" align="left" style="padding-left:5px;" class="row2">Description</td>
   
	
    <td width="7%" align="left" style="padding-left:5px;" class="row2">UOM</td>
    <td width="8%" align="left" style="padding-left:5px;" class="row2">PO.Qty</td>
    <td width="8%" align="left" style="padding-left:5px;" class="row2">Rate</td>
	<td width="8%" align="left" style="padding-left:5px;" class="row2">Currency</td>
	<td width="8%" align="left" style="padding-left:5px;" class="row2">Amount</td>
    <td width="7%" align="left" style="padding-left:5px;" colspan="2" class="row2">Discount</td>
     <td width="13%" class="row4">Basic Amt.</td>
  </tr>
   <?php 
 
		
         $sql="Select * from direct_po_details where parent_id='".$_REQUEST['id']."'";
		$result=DB_query($sql,$db);
        $i=1;
        while($myrow1=DB_fetch_array($result))
        {       
		$itemname=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'item_name');
		$itemcode=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'StockID');
		$itemdesc=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'item_desc');
		$unitname=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'mst_unitid');
		$unit=$s->GetFieldValue('unitsofmeasure',"unitid='".$unitname."'" ,'unitname');
		$secunit=$s->getField('item_master','id',$myrow1['mst_itemid'],'conv_unit'); 
        $confac=$s->getField('item_master','id',$myrow1['mst_itemid'],'conv_factor');	
		?>
    <tr>
    <td style="padding-top:5px; padding-bottom:5px; padding-left:5px;" class="row3"><?php echo $itemcode;?>    </td>
    <td style=" padding-left:5px;" class="row3"><?php echo $itemname;?></td>
    <td style=" padding-left:5px;" class="row3"><?php echo $itemdesc;?></td>
	<td style=" padding-left:5px;" class="row3"><?php echo $unit; ?></td>
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo $myrow1['qty'];?></td>
	<?php 
   if($confac!='')
   {
   $sec=round($row2['qty']/$confac,2);
   }
   else
   {
   $sec=0;
   }
   ?>
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo $myrow1['rate']; ?></td>
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php  $curency=DB_fetch_array(DB_query("select * from `currency_master` where id='".$myrow1['currency']."'",$db)); echo $curency['abbreviation']; ?></td>
	
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo $myrow1['amt']; ?></td>
		<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo $myrow1['dis_per']; ?></td>
		<td style=" padding-right:5px; text-align: right;" class="row3"><?php if( $myrow1['dis_type']=='Amount') {	echo 'Amt'; } else { echo '%'; } ?></td>
	
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo $myrow1['basic']; ?></td>
	 </tr>
  <?php $i++;} ?>	
</table>

	
	
	</div>
	<div style="padding-top:13px;">
	
	<table width="100%" border="0" cellspacing="2" cellpadding="0" style="border-width:0 0 0 0px;">
  <tr>
    <td valign="top">
	<span style="font-size:14px; color:#003399; margin:0px;"><strong>Amount in Words :</strong></span><lable id="rupee">	
	</label>	
	</td>
    <td width="40%" style="padding-left:10px;">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-family:Arial, Helvetica, sans-serif; font-size:7.9pt; border-width: 0 0 0 0;" align="right">
 
				<?php $number1=explode('.',$myrow['grand_total']); ?>
                <tr>
                <td width="75%" align="right" style="padding-top:4px;padding-bottom:4px; padding-right:50px;font-size:15px; font-weight:bold;background-top-color:#000000; "><strong>Basic Amount Total: </strong></td>
                  <td style="background-top-color:#000000; text-align:right; font-size:15px;"><strong><?php echo $myrow['grand_total'];?><input type="hidden" name="purchase_order_print[grand_total]" id="grand_total"  value="<?php	echo $myrow['grand_total'];?>" style="width:100%;" readonly="readonly" onfocus="cal_grandamount();" />
                  <input type="hidden" name="rupee1" value="<?php echo $number1[0];?>" id="rupee1" />
                  <input type="hidden" name="rupee2" value="<?php echo $number1[1];?>" id="rupee2" />   </strong>               </td>
                </tr>
				
</table>	</td>
  </tr>
</table>


	</div>

<!--<?php // if($remarks!=''){ ?>
<table width="100%" border="0" cellspacing="2" cellpadding="2" align="right" class="label">
                <tr>
                  <td style="padding-top:3px; padding-bottom:0px;"><h2 style="margin:0px; padding-bottom:0px; font-size:18px; text-decoration:underline;">Remarks</h2> </td>
          </tr>
                 <tr>
                  <td ><textarea  name="remarks" id="remarks"  style="width:100%;  padding-top:0px; text-align:justify; padding-left:10px; padding-right:10px; border-width:0 0 0 0;" ><?php // echo $remarks; ?></textarea></td>
                </tr>	</table> <?php // } ?>-->

	  </div><!-- end Header -->
<br />  
  <div style="width:100%;">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" style=" border:1px; border-collapse:collapse;">
	<tr>
	<td width="50%" align="left" valign="top">
		<table width="100%" border="1" cellpadding="2" cellspacing="0" style=" border:1px; border-collapse:collapse;">
			<tr>
				<th width="3%" style="font-size:14px;background-color:#CCCCCC;"><strong>Sr No</strong>.</th>
				<th colspan="2" style="font-size:14px;background-color:#CCCCCC; text-align:center;"><strong>Terms & Conditions</strong></th>
				
				
			</tr>
	<?php
	$j=1;
  $s_con=DB_query("SELECT * FROM direct_po_terms_conditions where parant_id='".$_REQUEST['id']."'",$db);
while($s_ress=DB_fetch_array($s_con))
{

 $query = "SELECT * FROM terms_condition where parant_id='0' and id='".$s_ress['termsid']."' and frm_id='".$s_ress['frm_id']."'";
 $s_con1=DB_query($query ,$db);
$s_ress1=DB_fetch_array($s_con1);
$query1 = "SELECT * FROM terms_condition where id='".$s_ress['condid']."' and frm_id='".$s_ress['frm_id']."'";
 $s_con11=DB_query($query1 ,$db);
$s_ress11=DB_fetch_array($s_con11);
?>
			<tr>
			<td style="text-align:center;"><?php echo $j; ?></td>
			<td><strong>&nbsp;&nbsp;<?php echo $s_ress1['terms_conditions'];?></strong></td>
			<td>&nbsp;&nbsp;<?php echo $s_ress11['terms_conditions']; ?></td>
			
			</tr>
			
		
<?php $j++; } ?>

</table>
	</td>
	<td width="50%" align="right" valign="top" style="padding-left:20px;"><table width="100%" border="1" align="left" cellpadding="2" cellspacing="0" style=" border:1px; border-collapse:collapse;">
			<tr>
				<th align="left" valign="top" style="font-size:14px; background-color:#CCCCCC;"><strong>Shipping/Agent Details</strong></th>
				<td  width="65%"  align="left" valign="top" style="height:50px;" ><?php echo $agent= $myrow['agent_detail']; ?></td>
			</tr>
			<tr>
				<th align="left" valign="top" style="font-size:14px; background-color:#CCCCCC;"><strong>Other Details</strong></th>
				<td align="left" valign="top" style="height:32px;"><?php echo $ss=$myrow['remarks'] ; ?></td>
			</tr>
		</table>
	</td>
	</tr>
	</table>	
</div>

	  <div style="margin-top:20px;">
	    
		<h2 style="font-size:13px; margin:0px; padding:0px;">Note:-The material supplied shall confirm to the specification, Defective material shall be rejected and has to be lifted by vender immediately at his own cost.
		
		</h2>
	<br />	<br />	<br />	<br />
	</div>
	
	<div style="clear:both;"></div>
	
	<div class="authorize1">
		<table width="100%" border="0" cellspacing="0" cellpadding="2">
		<tr>
    <td width="33%" align="left" valign="top"><?php echo $s->getField('www_users','id',$myrow['createdBy'],'realname'); ?></td>
	</tr>
  <tr>
    <td width="33%" align="left" valign="top">(Prepared By)	</td>
    <td width="33%" align="left" valign="top">(Checked By.)</td>
    <td  width="33%" align="left" valign="top">(Approved By)</td>
	 <td align="left" valign="middle">(Accepted By)</td>
  </tr>
</table>

		
	</div>
	
      
    </div>	
  </div>
	<div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
<div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
	<div style="background-image:url(images/print_icon.png); background-repeat:no-repeat; width:50px; height:100; float:left; padding:5px;" onclick="toggle_visibility()" id="print">&nbsp;</div>	
	
	</div>
		</div> <!-- end of  T & C -->
</div>
</form>
</body>
</html>
<?php if(isset($_SESSION['success_msg']))
{ ?>
	<script> alert("<?php echo ($_SESSION['success_msg']);?>");</script>
<?php 
}	unset($_SESSION['success_msg']);
?>

<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
	
       var e = document.getElementById("print");
      
     	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
</script>

<script>
	window.onload=function test_skill() {

	    var junkVal=document.getElementById('grand_total').value;
	    
	   junkVal=Math.floor(junkVal);
	   
	    var obStr=new String(junkVal);
	    numReversed=obStr.split("");	    
	    actnumber=numReversed.reverse();
	 
	    if(Number(junkVal) >=0){
	        //do nothing
	    }
	    else{
	       
	        return false;
	    }
	    if(Number(junkVal)==0){
	        document.getElementById('rupee').innerHTML=obStr+''+'Rupees Zero Only';
	        return false;
	    }
	    if(actnumber.length>9){
	       
	        return false;
	    }
	 
	    var iWords=["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
	    var ePlace=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'];
	    var tensPlace=['dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];
	 
	    var iWordsLength=numReversed.length;
    var totalWords="";
	    var inWords=new Array();
	    var finalWord="";
	    j=0;
	    for(i=0; i<iWordsLength; i++){
	        switch(i)
	        {
	        case 0:
	            if(actnumber[i]==0 || actnumber[i+1]==1 ) {
	                inWords[j]='';
	            }
	            else {
	                inWords[j]=iWords[actnumber[i]];
	            }
	            inWords[j]=inWords[j]+' Only';
            break;
        case 1:
	            tens_complication();
	            break;
	        case 2:
	            if(actnumber[i]==0) {
	                inWords[j]='';
	            }
	            else if(actnumber[i-1]!=0 && actnumber[i-2]!=0) {
	                inWords[j]=iWords[actnumber[i]]+' Hundred and';
	            }
	            else {
	                inWords[j]=iWords[actnumber[i]]+' Hundred';
	            }
	            break;
	        case 3:
	            if(actnumber[i]==0 || actnumber[i+1]==1) {
	                inWords[j]='';
	            }
	            else {
	                inWords[j]=iWords[actnumber[i]];
	            }
	            if(actnumber[i+1] != 0 || actnumber[i] > 0){
	                inWords[j]=inWords[j]+" Thousand";
	            }
	            break;
	        case 4:
	            tens_complication();
	            break;
	        case 5:
	            if(actnumber[i]==0 || actnumber[i+1]==1) {
	                inWords[j]='';
	            }
	            else {
	                inWords[j]=iWords[actnumber[i]];
	            }
	            if(actnumber[i+1] != 0 || actnumber[i] > 0){
	                inWords[j]=inWords[j]+" Lakh";
	            }
	            break;
	        case 6:
	            tens_complication();
	            break;
	        case 7:
	            if(actnumber[i]==0 || actnumber[i+1]==1 ){
	                inWords[j]='';
	            }
           else {
                inWords[j]=iWords[actnumber[i]];
	            }
	            inWords[j]=inWords[j]+" Crore";
	            break;
	        case 8:
	            tens_complication();
	            break;
        default:
	            break;
	        }
	        j++;
	    }
	 
	    function tens_complication() {
	        if(actnumber[i]==0) {
	            inWords[j]='';
	        }
	        else if(actnumber[i]==1) {
            inWords[j]=ePlace[actnumber[i-1]];
	        }
	        else {
	            inWords[j]=tensPlace[actnumber[i]];
	        }
	    }
	    inWords.reverse();
	    for(i=0; i<inWords.length; i++) {
	        finalWord+=inWords[i];
	    }
	   
	    document.getElementById('rupee').innerHTML=finalWord;
	}	
</script>