<?php
error_reporting(0);
include ("../../include/db.php");
date_default_timezone_set('Asia/Kolkata');
ob_start();
session_start();
$user_id = $_SESSION['login_user_id'];
?>
<table width="850px" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #999;">
<tr style="height:60">
<td width="137" height="106" align="left" style="font-size:12px; border-bottom:1px solid #999;"><img src="../../img/logo_image.png" width="126" height="130"/></td>
<td width="711" colspan="5" align="center" valign="top" style="border-bottom:1px solid #999;"><strong style="font-size: 30px; color: #06F; padding-top: 5px; width: 80px; font-family: Verdana, sans-serif">SRI AMMAN DIGITAL PRINTS</strong><br />
        <span width="80%" class="title1" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b> DOOR No: 1/2,1/3  KOMBAI THOTTAM MAIN ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>SELLANDIAMMAN THURAI ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>TIRUPPUR-641604 TAMILNADU STATE INDIA,</span><br/>
       <span width="80%" class="title00" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Contact Office: 0421-4355333,+91 83442-33555,+91 83442-3388,</span><br/>
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Email Id : sriammandigitalprints@gmail.com/yahoo.com.</span><br/>
       <br/></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" >
       <tr>
        <td width="543" height="20"  style="padding:3px; font-family:Verdana, sans-serif; font-size:12px; font-weight:bold;border-right:1px solid #999;"><strong>Customer Details</strong></td>
        <td width="95" colspan="-2" style="font-family:Verdana; font-size:12px;">&nbsp;Jobcard No</td>
        <td width="20" colspan="-2" align="center">:</td>
        <td width="192" colspan="-2" style="font-family:Verdana, sans-serif; font-size:12px;">&nbsp;<?php echo $_GET['jobcard_no']; ?></td>
      </tr>
     <?PHP 
	$cust_name=$_GET['cust_name'];
    $sql="select * from   party_creation where party_name='$cust_name' and `party_type`='Customer' and delete_status!='1'   order by party_name ASC ";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$party_name=$rsdata['party_name'];
     			$mobile_no=$rsdata['mobile_no'];
				$address=$rsdata['address'];
   				$city=$rsdata['city'];
			}

?>  

 <?PHP 
	$jobcard_no=$_GET['jobcard_no'];
    $sql="select * from   jobcard_main where jobcard_no='$jobcard_no'";
    $rs=mysql_query($sql);
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$style_no=$rsdata['style_no'];
     			$style_name=$rsdata['style_name'];
				$job_type=$rsdata['job_type'];
   				$fabric_type=$rsdata['fabric_type'];
				$combo2=$rsdata['combo'];
				$entry_date=$rsdata['entry_date'];
				$order_by=$rsdata['order_by'];
				$cust_po_no=$rsdata['cust_po_no'];
			}

?>  
      <tr>
        <td rowspan="4" valign="top"  style="font-family:Verdana; font-size:12px;  letter-spacing:1px;line-height:16px; padding-left:10px;border-right:1px solid #999;">To.M/S&nbsp;<?php echo $_GET['cust_name'];?>,<br /><?php echo $address;?>&nbsp;<br /><?php echo $city;?>&nbsp;<br /></td>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;Date</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php  echo date('d-m-Y',strtotime($entry_date)); ?>
          </td>
      </tr>
      <tr>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;"> &nbsp;Job Type</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $job_type;?></td>
      </tr>
      <tr>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;Fabric Type</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $fabric_type;?></td>
      </tr>
      <tr>
        <td height="19" colspan="-2" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;Style No</td>
        <td width="20" colspan="-2" align="center" valign="top" >:</td>
        <td colspan="-2"  align="left" valign="top"  style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $style_no;?></td>
      </tr>
      <tr>
        <td valign="top" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;">&nbsp;&nbsp;</td>
        <td height="18" style="font-family:Verdana; font-size:12px;">&nbsp;Style Name</td>
        <td align="center" style="font-family:Verdana; font-size:12px;">:</td>
        <td style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $style_name;?></td>
      </tr>
      <tr>
        <td valign="top" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;">&nbsp;&nbsp;Order By : <?php echo $order_by;?></td>
        <td height="18" style="font-family:Verdana; font-size:12px;">&nbsp;Combo</td>
        <td align="center" style="font-family:Verdana; font-size:12px;">:</td>
        <td style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $combo2;?></td>
      </tr>
        <tr>
        <td valign="top" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;">&nbsp;&nbsp;</td>
        <td height="18" style="font-family:Verdana; font-size:12px;">&nbsp;Po.No</td>
        <td align="center" style="font-family:Verdana; font-size:12px;">:</td>
        <td style="font-family:Verdana; font-size:12px;">&nbsp;<?php echo $cust_po_no;?></td>
      </tr>
     <?php if(($user_id=='1')||($user_id=='3'))
	 { 
	 ?>
      <tr>
        <td colspan="12" height="220" valign="top">
          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> 
           <tr>
       <td width="36" height="21" align="center"  style="font-family:Verdana; font-size:12px; font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">S.No</td>
       
             
              <td width="170"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Particulars</td>
              <td width="55"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Width&nbsp;</td>
              <td width="61"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Height&nbsp;</td>
              <td width="76"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Order Qty&nbsp;</td>
              <td width="69"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Plan Qty&nbsp;</td>
			  <td width="84"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Roll Size</td>
			  <td width="69"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Req By&nbsp;</td>
			    <td width="84"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Steps Used&nbsp;</td>
				<td width="69"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Steps&nbsp;</td>
				 <td width="84"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Total Repeats&nbsp;</td>
               <td width="53"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Gap&nbsp;</td>
			    <td width="84"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Gap Mtr&nbsp;</td>
               
              
               
              
              <td width="85"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999">Total Req&nbsp;</td>
              

                 
              </tr>
              <?php
			  $jobcard_no_get=$_GET['jobcard_no'];
    $jobcard_no_post=$_POST['jobcard_no'];
    $sql="select * from  media_sub_list where jobcard_no='$jobcard_no_post' or jobcard_no='$jobcard_no_get'";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$id=$rsdata['id'];
				$jobcard_no=$rsdata['jobcard_no'];
				$roll_name=$rsdata['roll_name'];
				$entrydates=$rsdata['entrydates'];
				$media_date=$rsdata['media_date'];
   				$media_particular=$rsdata['media_particular'];
				$order_qty=$rsdata['order_qty'];
				$plan_qty=$rsdata['plan_qty'];
				 $steps=$rsdata['steps'];
				$steps_used=$rsdata['steps_used'];
				$gap_mtr = $rsdata['gap_mtr'];
				$gap=$rsdata['gap'];
				$total_steps=$rsdata['total_steps'];
				$req_by=$rsdata['req_by'];
				$tot_req_by=$rsdata['tot_req_by'];
				$roll_size=$rsdata['roll_size'];
				$width=$rsdata['width'];
				$height=$rsdata['height'];
				
				$row=$row+1;
								  $row1=$row%2;
								  if($row1==0)
								  {
								  $class='style="background-color:#f6faff;border-bottom:solid 1px;border-color:#E2E2E2"';
								  }
								  else
								  {
								  $class='style="background-color:#f3f3ff;border-bottom:solid 1px;border-color:#E2E2E2"';
								  }
								  ?>
                         
            
              <tr>
              <td width="36" height="26" align="center"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $sno; ?>&nbsp;</td>
              
             
             <td width="180" align="left" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;">&nbsp;&nbsp;<?php echo $media_particular;?>&nbsp;</td>
              <td width="55" align="right" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $width;?>&nbsp;</td>
              <td width="61" align="right"  style=";font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $height;?>&nbsp;&nbsp;</td>
              <td width="76" align="right" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $order_qty;?>&nbsp;</td>
              <td width="69" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $plan_qty;?>&nbsp;</td>
			   <td width="84" align="left" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;">&nbsp;&nbsp;<?php echo $roll_name;?>&nbsp;</td>
			    <td width="69" align="center"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $req_by;?>&nbsp;</td>
				  <td width="84" align="right" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;">&nbsp;&nbsp;<?php echo $steps_used;?>&nbsp;</td>
			    <td width="69" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $steps;?>&nbsp;</td>
				 <td width="80" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $total_steps;?>&nbsp;</td>
               <td width="53" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $gap;?>&nbsp;</td>
			    <td width="53" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $gap_mtr;?>&nbsp;</td>
               
               
                  <td width="85" align="right" style="font-family:Verdana; font-size:12px;border-bottom:1px solid #999;"><?php echo $tot_req_by;?>&nbsp;</td>
              
 
                
              </tr>
              <?php 
			  $tot_req_by3+=$tot_req_by;
			  $qty+=$plan_qty;

			  $overall_values+= $jobcard_values;
			  $qtys+= $qty;
			  }?>
  </table>
          </td>
      </tr>
      <?php } else { ?>
          <tr>
        <td colspan="12" height="220" valign="top">
          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> 
           <tr>
       <td width="34" height="21" align="center"  style="font-family:Verdana; font-size:12px; font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">S.No</td>
       <td width="178"  align="left"  style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;&nbsp;Particulars</td>
              <td width="85"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Width</td>
              <td width="89"  align="center" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">&nbsp;Height</td>
              <td width="83"  align="right" style="font-family:Verdana; font-size:12px;font-weight:bold; border-bottom:1px solid #999; border-top:1px solid #999;border-right:1px solid #999;">Qty&nbsp;</td>
              </tr>
              <?PHP 
	$jobcard_no=$_GET['jobcard_no'];
    $sql="select * from   jobcard_sublist where jobcard_no='$jobcard_no'";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$job_id=$rsdata['job_id'];
     			$jobcard_no=$rsdata['jobcard_no'];
				$particulars=$rsdata['particulars'];
   				$width=$rsdata['width'];
				$height=$rsdata['height'];
				$rate=$rsdata['rate'];
				$amount=$rsdata['amount'];
				$conformed_amt=$rsdata['conformed_amt'];
				$qty=$rsdata['qty'];
				$jobcard_values=$rsdata['jobcard_values'];
				if($weight_kg=="0.00")
				{
					$weight_kg_res='';
				}
				else
				{
					$weight_kg_res=$weight_kg;
				}
				$kg_rate=$rsdata['kg_rate'];
				
				if($kg_rate=="0.00")
				{
					$kg_rate_res='';
				}
				else
				{
					$kg_rate_res=$kg_rate;
				}
				$frieght_charge=$rsdata['frieght_charge'];
?>
              <tr>
              <td width="34" height="26" align="center"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $sno; ?>&nbsp;</td>
              <td width="178" align="left"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;">&nbsp;&nbsp;<?php echo $particulars; ?>&nbsp;</td>
              <td width="85" align="center" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $width; ?>&nbsp;</td>
              <td width="89" align="center" style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $height; ?>&nbsp;</td>
              <td width="83" align="right"  style="font-family:Verdana; font-size:12px;border-right:1px solid #999;border-bottom:1px solid #999;"><?php echo $qty; ?>&nbsp;</td>
              </tr>
              <?php $overall_values+= $jobcard_values;
			  $qtys+= $qty;
			  } ?>
  </table>
          </td>
      </tr>
      <?php } ?>
    </table>
    </td>
  </tr>
  <tr>
 <td>
</td>
</tr>
<?php if(($user_id=='1')||($user_id=='3'))
	 { 
	 ?>
  <tr>
    <td height="34" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" >
      <tr >
        <td width="564" height="34"   style="font-family: Verdana; font-size: 12px; border-top: 1px solid #999;  font-weight: bold;">&nbsp;&nbsp; <?php echo convert_number($tot_req_by3);?>&nbsp;Only.<strong>&nbsp;</strong></td>
        <td width="86" align="center"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;"><span style="font-weight: bold">Qty</span> &nbsp;&nbsp;&nbsp;</td>
        <td width="87" align="left"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;border-right:1px solid #999;"><?php echo number_format($qty,2); ?></td>
        <td width="77"  style="font-family: Verdana; font-size: 12px; border-top: 1px solid #999; font-weight: bold;">&nbsp;&nbsp;Amt</td>
        <td width="34"  style="font-family:Verdana; font-size:12px;border-top:1px solid #999;"><span style="padding-right:10px;"><?php echo number_format($tot_req_by3,2); ?></span></td>
      </tr>
    </table></td>
  </tr>
  <?php } else { ?>
  <tr>
    <td height="34" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" >
      <tr>
        <td width="564" height="34"   style="font-family: Verdana; font-size: 12px; border-top: 1px solid #999;  font-weight: bold;">&nbsp;</td>
        <td width="86" align="center"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;"><span style="font-weight: bold">Qty</span> &nbsp;&nbsp;&nbsp;</td>
        <td width="87" align="left"   style="font-family:Verdana; font-size:12px;border-top:1px solid #999;border-right:1px solid #999;"><?php echo number_format($qtys,2); ?></td>
        </tr>
    </table></td>
  </tr>
  <?php } ?>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td width="37%" style="border-top:1px solid #999;" ><?php 
	  $sql="select * from  file_upload_jobcard where job_card_no='$_GET[jobcard_no]'";
    $rs=mysql_query($sql);
	$fcount=mysql_num_rows($rs);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				
   				$file_id=$rsdata['file_id'];
     			$file_name=$rsdata['file_name'];
			}
			if(($fcount==1)||($fcount==0)||($fcount==''))
			{
if($file_name!='')
{
?>

<?php } 
else 
{ ?>
<img  src="../../img/images.jpg" width="130" height="105"/>
<?php } }?>
</td>
   <td width="17%" align="center"  valign="bottom" style="border-top:1px solid #999;border-right:1px solid #999;border-left:1px solid #999;font-family:Verdana; font-size:12px;padding:3px; font-weight:bold;" >&nbsp;&nbsp;Manager</td>
   <td width="19%" align="center"  valign="bottom" style="border-top:1px solid #999;border-right:1px solid #999;font-family:Verdana; font-size:12px;padding:3px; font-weight:bold;" >Designer Signature</td>
   <td width="27%" align="center" valign="bottom"   style="font-family: Verdana; font-size: 12px; padding: 3px; border-top: 1px solid #999; font-weight: bold;"><strong>For <span style="color: #06F">SRI AMMAN DIGITAL PRINTS</span>&nbsp;</strong>
          <p>&nbsp;</p>
          <p>Authorised Signature</p></td>
      </tr>
    </table></td>
  </tr>
</table> 
<table>
    <td align="center" style=" font-family:Verdana, sans-serif; font-size:12px; padding-left: 800px;"><br>Printed Date : <?php echo $curdate=date('d-m-Y');?>&nbsp;&nbsp;&nbsp;&nbsp;<br>Printed Time : <?php echo $current_time=date('h:i:s A');?>&nbsp;&nbsp;<br>IP Address   &nbsp;&nbsp;&nbsp;: <?php echo $ip_address = $_SERVER['REMOTE_ADDR'];?>&nbsp;</p></td>
    </table>
<br/><br/>


<style>




.title {
	color: #444;
	text-align: center;
}

.section {
	margin-bottom: 1%;
}

.red {
	background: #F6B89E;
}
.green {
	background: #AFD19F;
}
.left {
	float: left;
}

.leftmargin {
	margin-right: 1%;
}

.right {
	float: right;
}
.center {
	text-align:center;
 
}


.rightmargin {
	margin-left: 1%;
}

.box {
	height: 125px;
	width:125px;
	padding-top:60px;
	padding-right:6px;
	padding-left:15px;
	padding-bottom:30px;
}

.cf {
	clear: both;
}



</style>


<?php 
function convert_number($number) 
{ 
    if (($number < 0) || ($number >99999999)) 
    { 
    throw new Exception("Number is out of range");
    } 
    $Gn = floor($number / 10000000); 
    $number -= $Gn * 1000000; 
	$ln = floor($number / 100000);  
    $number -= $ln * 100000; 
    $kn = floor($number / 1000);   
    $number -= $kn * 1000; 
    $Hn = floor($number / 100);    
    $number -= $Hn * 100; 
    $Dn = floor($number / 10);      
    $n = $number % 10;               

    $res = ""; 

    if ($Gn) 
    { 
        $res .= convert_number($Gn) . " Crores"; 
    } 
  if ($ln) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($ln) . " Laksh"; 
    } 
    if ($kn) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($kn) . " Thousand"; 
    } 

    if ($Hn) 
    { 
        $res .= (empty($res) ? "" : " ") . 
            convert_number($Hn) . " Hundred"; 
    } 

    $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", 
        "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", 
        "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", 
        "Nineteen"); 
    $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", 
        "Seventy", "Eigthy", "Ninety"); 

    if ($Dn || $n) 
    { 
        if (!empty($res)) 
        { 
            $res .= " and "; 
        } 

        if ($Dn < 2) 
        { 
            $res .= $ones[$Dn * 10 + $n]; 
        } 
        else 
        { 
            $res .= $tens[$Dn]; 

            if ($n) 
            { 
                $res .= " " . $ones[$n]; 
            } 
        } 
    } 
    if (empty($res)) 
    { 
        $res = "zero"; 
    } 
    return $res; 
} 
?>       		