<?php
include ('class.ezpdf.php');


	$conn = mysql_connect("localhost","evolve8_mandara","mandara");
	
	mysql_select_db("evolve8_accounts",$conn);
	
	/*$conn = mysql_connect("localhost","root","");
	
	mysql_select_db("danu_acc",$conn);*/
	
	
	$pri = "0_";
	
	
	require_once ('class.numbertoword.php');

	 echo $sql = "SELECT ".$pri."supp_trans.*, 
   		(".$pri."supp_trans.ov_amount+".$pri."supp_trans.ov_gst+".$pri."supp_trans.ov_discount) AS Total, 
   		".$pri."suppliers.supp_name,  ".$pri."suppliers.supp_account_no,
   		".$pri."suppliers.curr_code, ".$pri."suppliers.payment_terms, ".$pri."suppliers.gst_no AS tax_id, 
   		".$pri."suppliers.address, ".$pri."suppliers.contact
		FROM ".$pri."supp_trans, ".$pri."suppliers
		WHERE ".$pri."supp_trans.supplier_id = ".$pri."suppliers.supplier_id
		AND ".$pri."supp_trans.type = 22
		AND ".$pri."supp_trans.trans_no = ".$_REQUEST['id']."";//69";//
exit;

	$result = mysql_query($sql);
	
	$amount = abs(db_fetch($result,0,'Total'));
	$payee_name = db_fetch($result,0,'supp_name');

	//$iNumber = 223233.25;number_format($row_strsql['roomprice'],2,'.','')
	$iNumber = number_format($amount,2,'.','');
		
		$values = explode(".", $iNumber);
		$rupees  = intval($values[0]);
		$cents  = intval($values[1]);
		
		str_pad($iNumber,'0',STR_PAD_LEFT);
		
		//$amount_w_db =  '**'.CLASS_Numbertoword::convert($rupees,'en').' and '.CLASS_Numbertoword::convert($cents,'en').' Cents Only';
		


		switch ($cents) {
			case 0:
				$amount_w_db =  '**'.CLASS_Numbertoword::convert($rupees,'en').' Only';
				break;
			case 1:
				$amount_w_db =  '**'.CLASS_Numbertoword::convert($rupees,'en').' and '.CLASS_Numbertoword::convert($cents,'en').' Cent Only';
				break;
			default:
			   $amount_w_db =  '**'.CLASS_Numbertoword::convert($rupees,'en').' and '.CLASS_Numbertoword::convert($cents,'en').' Cents Only';
		}
		
		 
		 
		$date = date("ymd");
		$date_array = str_split($date);



$pdf =& new Cezpdf();
$pdf->selectFont('./fonts/Helvetica.afm');




//$pdf->ezText('2  5  0  5    1  1',10,array('justification'=>'right'));




$pdf->addText(355,218,10,$date_array[4],0);
$pdf->addText(375,218,10,$date_array[5],0);
$pdf->addText(390,218,10,$date_array[2],0);
$pdf->addText(405,218,10,$date_array[3],0);

$pdf->addText(450,218,10,$date_array[1],0);
$pdf->addText(465,218,10,$date_array[0],0);


//$date = array(array('name'=>'2  5  0  5  2  0  1  1'));
//$pdf->ezTable($date,array('name'=>''),'',array('showHeadings'=>0,'shaded'=>0,'width'=>130,'xPos'=>'430','showLines'=>0));//,'showLines'=>0


$pdf->ezText('',10);
$pdf->ezText('',12);

//$pdf->ezText('Danuhska Widanage',10,array('justification'=>'left'));

$pdf->addText(50,180,10,$payee_name,0);
//$pdf->addText(50,180,10,"Danuhska Widanage",0);



$pdf->ezText('',10);
$pdf->ezText('',10);
$pdf->ezText('',10);
$pdf->ezText('',10);



//$amount_word = array(array('name'=>'Hundred and Fifty-Two Rupees  Hundred and Fifty-Two Rupees Hundred and Fifty-Two Hundred and Fifty-Two Rupees Hundred and Fifty-Two Rupees and Fifteen Cents Only'));

$amount_word = array(array('name'=>$amount_w_db));



$pdf->ezTable($amount_word,array('name'=>''),'',array('showHeadings'=>0,'shaded'=>0,'width'=>290,'xPos'=>'200','xOrientation'=>'centre','showLines'=>0));//



$pdf->addText(360,150,10,"**".number_format($amount, 2, '.', ''),0);

 

//$pdf->addText(150,$y,10,"the quick brown fox <b>jumps</b><i>over</i> the lazy dog!",-10);

//$amount_val = array(array('name'=>'**115,412,545.15'));

//$pdf->ezTable($amount_val,array('name'=>''),'',array('showHeadings'=>0,'shaded'=>0,'width'=>130,'xPos'=>'430'));//,'showLines'=>0//'splitRows'=>3

$pdf->ezStream();

?>

