<?php //error_reporting(0);
$PageSecurity = 3;
include ('includes/session.inc');
include ('includes/function_lib.php');
global $db;
include('includes/Class_Branch.php');
include('includes/AccountGroupMaster_Class.php');
?>	 
<?php 
function number_to_words($no)
{
    $string   = null;
    $fraction   = null;
    $decimal    = ' point ';
    $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' => 'fouteen',
      '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' => 'ninty',
      '100' => 'hundred &',
      '1000' => 'thousand',
      '100000' => 'lakh',
      '10000000' => 'crore');
    if($no == 0)
      return ' ';
    else {
      if (strpos($no, '.') !== false) {
          list($no, $fraction) = explode('.', $no);
      }

      $novalue='';
      $highno=$no;
      $remainno=0;
      $value=100;
      $value1=1000;
      
      while($no>=100) {
        if(($value <= $no) && ($no < $value1)) {
          $novalue=$words["$value"];
          $highno = (int)($no/$value);
          $remainno = $no % $value;
          break;
        }
        $value= $value1;
        $value1 = $value * 100;
      }

      if (null !== $fraction && is_numeric($fraction) && $fraction!=0) {
          $string = $decimal;
          $words1 = array();
          foreach (str_split((string) $fraction) as $number) {
              $words1[] = $words[$number];
          }
          $string .= implode(' ', $words1);
      }
      
      if(array_key_exists("$highno",$words))
      {
        return $words["$highno"]." ".$novalue." ".number_to_words($remainno).$string;
      }else {
        $unit=$highno%10;
        $ten =(int)($highno/10)*10;
        return $words["$ten"]." ".$words["$unit"]." ".$novalue." ".number_to_words($remainno).$string;
      }
    }
}


$payee_name=DB_fetch_assoc(DB_query("SELECT a.banks_receivedfrom,a.banks_checkdate FROM account_book a  WHERE  a.id='".$_REQUEST['id']."' ",$db));

$led=DB_fetch_assoc(DB_query("select * from account_book_details where account_bookid='".$_REQUEST['id']."' and amount_type='CR' ",$db));

$bank_conf=DB_fetch_assoc(DB_query("SELECT * FROM `cheque_print_conf` WHERE accountledger_id='".$led[ledgerid]."'",$db));
$ledger_sql=DB_query("SELECT b.AccountName,a.* FROM account_book_details a , accountledger b WHERE a.ledgerid=b.AccountsID and a.account_bookid='".$_REQUEST['id']."' AND (a.amount_type='DR' or a.amount_type='CR' )",$db);
while($ledger=DB_fetch_assoc($ledger_sql))
{
  if($ledger['amount_type']=='CR')
    {
      $name=$ledger['AccountName'];
      $amt= number_to_words($ledger['amount']).'only';
	  $amt1=$ledger['amount'];
    }
  else if($ledger['amount_type']=='CR')
    {
      $dimension=DB_fetch_assoc(DB_query("select * from  cheque_print_conf where accountledger_id='".$ledger['ledgerid']."' ",$db));
    }
}
$date_brk=explode("-",$payee_name['banks_checkdate']);
if($bank_conf['date_frmt']=='date_frmt1')
     $date=$date_brk[2]."/".$date_brk[1]."/".$date_brk[0];
else if($bank_conf['date_frmt']=='date_frmt2')
     $date=$date_brk[2].".".$date_brk[1].".".$date_brk[0];
else if($bank_conf['date_frmt']=='date_frmt3')
     $date=$date_brk[2]."-".$date_brk[1]."-".$date_brk[0];
?>
<!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=utf-8" />
<title>Untitled Document</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style>
body{ 
  margin:0px;
  padding:0px;
  font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
  color:#000;
  padding-top:200px;
}

h1,h2,h3,p{
  margin:0px;
  padding:0px;
}

.main{
  width:<?php echo $bank_conf['main_width'];?>px;
  height:<?php echo $bank_conf['main_height'];?>px;
  margin:auto;
  margin-top:17px; 
  -webkit-transform: rotate(-90deg);
  -moz-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  transform: rotate(-90deg);
}

.clear{ clear:both;}

.leftContainer{
  width:70% !important;
  float:left;
}

.rightContainer{
  width:30% !important;
  float:left;
}

.name{
  margin-top:<?php echo $bank_conf['party_top'];?>px;
  margin-left:<?php echo $bank_conf['party_left'];?>px;
}

.left{
  width:450px;
  height:100px;
  margin-top:<?php echo $bank_conf['amt_top'];?>px;
  margin-left:<?php echo $bank_conf['amt_left'];?>px;
}

.date{
  width: 163px;
  margin-top:<?php echo $bank_conf['date_top'];?>px;
  margin-left:<?php echo $bank_conf['date_left'];?>px;
  font-size: 13px;
}

.date table tr td p{
  letter-spacing:7px;
  margin:0px;
  padding:0px;
}


.right{
  width:120px;
  margin-top:<?php echo $bank_conf['inwards_top'];?>px;
  margin-left:<?php echo $bank_conf['inwards_left'];?>px;
  text-align: right;
}

.rotat{
  width:130px;
  float: left;
  height:69px;
  font-weight:bold;
  margin-top:<?php echo $bank_conf['acc_pay_top'];?>px;
  margin-left:<?php echo $bank_conf['acc_pay_left'];?>px;
}
.rotat p{
  border-top:1px solid #000;
  border-bottom: 1px solid #000;
  font-size:14px;
}

</style>
</head>

<body>
<div class="main">  
	<div class="leftContainer">  
    <div class="name">
        <p><?php echo $payee_name['banks_receivedfrom']; ?></p>
    </div>
    <div class="left">
        <p><?php echo $amt; ?></p>
    </div>
    </div>
    <div class="rightContainer">  
   		 <div class="date">
    <?php if($bank_conf['date_frmt']=='date_frmt4'){?>
        <table>
            <tr>
                <td colspan="2" valign="middle"><p><?php echo $date_brk[2];?><p></td>
                <td colspan="2" valign="middle"><p><?php echo $date_brk[1];?></p></td>
                <td colspan="4" valign="middle"><p><?php echo $date_brk[0];?></p></td>
            </tr>
        </table>
      <?php }else{
        echo $date;
      }?>
    </div>
   		<div class="right">
        <p>**<?php echo $amt1; ?>/-</p>
    </div>
    	<div class="rotat"><p>A/C Payee Only </p></div>
    </div>
</div>
</body>
</html>