<?php
error_reporting("E_ALL");
$PageSecurity = 5;

$sql=DB_query("select * from direct_po where id='".$_REQUEST['SID']."'",$db);
$myrow1=DB_fetch_array($sql);

?>
<link rel="stylesheet" href="css/new_mxerp.css">

<link rel="stylesheet" href="css/jquery.ui.all.css" />
<script src="js/jquery-1.5.1.js"></script>
<script src="ui/jquery.ui.core.js"></script>
<script src="ui/jquery.ui.widget.js"></script>





	
			
			<div style="width:auto; margin-left:auto; margin-right:auto;">


			<table width="96%" border="1" cellpadding="3" cellspacing="0">
			 <tr>
		<th width="11%"><strong>Branch Code</strong></th>
		<td width="17%"><?php echo $s->getField('locations','loccode',$myrow1['site'],'locationname'); ?></td>
		<th width="14%"><strong>PR Number</strong></th>
		<td width="16%"><?php echo $myrow1['pr_no']; ?></td>
		<th width="15%" nowrap="nowrap"><strong>PR Date</strong></th>
		<td width="27%"><?php echo $myrow1['pr_date']; ?></td>
			 </tr>
			 <tr>
			<th><strong>Vendor Name</strong></th>
			<td><?php echo $s->getField('suppliers','id',$myrow1['vender_id'],'vendor_name'); ?></td>
			<th><strong>Vendor Code</strong></th>
			<td><?php echo $s->getField('suppliers','id',$myrow1['vender_id'],'vendor_code'); ?></td>
			<th><strong>Mobile No </strong></th>
			<td><?php echo $s->getField('suppliers','id',$myrow1['vender_id'],'mobile'); ?></td>
			 </tr>
			  <tr>
				<th height="31" nowrap="nowrap"><strong>Address1</strong></th>
				<td><?php echo $s->getField('suppliers','id',$myrow1['vender_id'],'adrress1'); ?></td>
				<th nowrap="nowrap"><strong>Address2</strong></th>
                <td><?php echo $s->getField('suppliers','id',$myrow1['vender_id'],'adrress2'); ?></td>
                <th><strong>Contact Person</strong></th>
                <td><?php echo $myrow1['contact_person']; ?></td>
			  </tr>
			 <tr>
				<th nowrap="nowrap"><strong>Delivery Date</strong></th>
				<td><?php echo $myrow1['delivery_date']; ?></td>
				<th nowrap="nowrap"><strong>Delivery Place</strong></th>
                <td>&nbsp;</td>
                <th><strong>Payment Mode</strong></th>
              <td><?php echo $payment_term=$s->getField('paymentmethods','paymentid',$myrow1['payment_mode'],'paymentname'); ?></td>
			 </tr>
			 <tr>
				<th nowrap="nowrap">Against  WO </th>
				<td><?php echo $payment_term=$s->getField('salesorder','id',$myrow1['sop_no'],'orderNo'); ?></td>
				<th nowrap="nowrap"><strong>Item Details</strong></th>
                <td><?php echo $payment_term=$s->getField('item_master','id',$myrow1['sop_mst_itemid'],'item_name'); ?></td>
                <th>Freight</th>
                <td><?php echo $myrow1['freight1']; ?></td>
			 </tr>
			  <tr>
			    <th ><strong>Quotation No</strong></th>
			    <td><?php echo $myrow1['quotation_no']; ?></td>
			    <th><strong> Quotation Date</strong></th>
			    <td ><?php echo $myrow1['quotation_date']; ?></td>
			    <th><strong>Mode Of Transport</strong></th>
				<td><?php echo $myrow1['mode_transport']; ?></td>
			  </table>
				   
									
				
			</div>
				   <br />
				 
<p align="left">&nbsp;</p>				 
<h3><center>Item Details</center></h4>

<div style="width:auto; margin-left:auto; margin-right:auto;"> 
<table align='center' width='100%;' border='1' cellpadding='3' cellspacing='0'>
<tr class='row1'>
<td class='tabledata'>Sr. No.</td>
<td class='tabledata'>Item Code</td>
 <td class='tabledata'>Item Name</td>
 <td class='tabledata'>Qty.</td>
<td class='tabledata'>Price</td>
<td class='tabledata'>Value</td>
<td class='tabledata'>Discount Type</td>
<td class='tabledata'>Discount Per</td>
<td class='tabledata'>Discount Price</td>
<td class='tabledata'>Net Discount</td>
<td class='tabledata'>Delivery Date</td>
</tr>
<?php
$i=1; 
$sql1=DB_query("select * from direct_po_details where parent_id='".$_REQUEST['SID']."'",$db);
while($row=DB_fetch_array($sql1))
{
?>
 <tr class='row1'>
 <td class='tabledata'><?php echo $i; ?></td>
<td style='white-space:nowrap;' class='tabledata'><?php echo $s->getField('item_master','id',$row['mst_itemid'],'StockID'); ?></td>
<td class='tabledata'><?php echo $s->getField('item_master','id',$row['mst_itemid'],'item_name'); ?></td>
<td class='tabledata'><?php echo $row['qty']; ?></td>
<td class='tabledata' style='white-space:nowrap'><?php echo $row['rate']; ?></td>
<td class='tabledata'><?php echo $row['amt']; ?></td>
<td class='tabledata'><?php echo $row['dis_type']; ?></td>
<td class='tabledata'><?php echo $row['dis_per']; ?></td>
<td class='tabledata'><?php echo $row['dis_price']; ?></td>
<td class='tabledata'><?php echo $row['net_amt']; ?></td>
<td class='tabledata'><?php echo $row['delivery_date']; ?></td>
 </tr>
<?php  $i++; } ?>			
	</table>
  </div>
			</div>
	<br />	
<div align="right">			
			<table width="100%" border="0" cellspacing="2" cellpadding="0" style="border-width:0 0 0 0px;">
  <tr>
    <td colspan="3" valign="top">
	<br /><br /><br /><br /><br /><br /><br /><br />
	<h2 style="font-size:14px; color:#003399; margin:0px;">Amounts in Words :&nbsp;&nbsp;&nbsp;<strong><lable id="rupee">	
	</label></strong></h2>	
	</td>
    <td width="40%" colspan="3" style="padding-left:10px; padding-top:10px;">
	<table width="81%" 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">
 
  
	<tr>
                  <td width="214" style="width:150px; padding-top:3px; padding-bottom:0px;"><strong>Total Amount</strong> </td>
				  <td width="12" style="width:10px;">:</td>
                  <td width="73" style="text-align:right"><?php echo $myrow1['basic_amt'];?></td>
          </tr>
               
			   <tr>
                  <td style="padding-top:3px; padding-bottom:0px;"><strong>Packing & Forwarding</strong> </td>
				  <td>:</td>
                  <td style="text-align:right"><?php echo $myrow1['pkg_charge']; ?></td>
          </tr>
				 <tr>
				 <?php
				 $exper=$myrow1['total_excise_amt'];
				 $exper1=($exper/$myrow1['basic_amt'])*100;
				  
				 ?>
           <td style="padding-top:3px; padding-bottom:0px;"><strong>Excise &nbsp;&nbsp; (<?php echo $exper1."%" ?>) </strong> </td>
				  <td>:</td>
                  <td style="text-align:right"><?php echo $exper; ?></td>
                </tr>
                <?php
                $Taxsql="SELECT id,tax_code, taxrate FROM service_tax_master where id='".$myrow1['vat_cst']."'";
				$Taxresult=DB_query($Taxsql,$db); 
				$Taxmyrow=DB_fetch_array($Taxresult);
                ?>
			   
			    <tr>
                  <td style="padding-top:3px; padding-bottom:0px;"><strong>Vat/CST <strong>
                    <?php if(!empty($Taxmyrow['taxrate'])){ ?>
                  </strong> (
                    <?php  echo $Taxmyrow['tax_code']." --- ".$Taxmyrow['taxrate']."%"; ?>)<?php } ?></strong> </td>
				  <td>:</td>
                  <td style="text-align:right"><?php echo $myrow1['vat_amt']; ?></td>
                </tr>
			   
			   
                <tr>
                	<?php  $c=$myrow['sur_per']; ?>
                  <td style="padding-top:3px; padding-bottom:0px;"><strong>Surcharge on VAT/CST <?php if(!empty($c)){ ?>(<?php  echo $myrow1['sur_per']."%";  ?>)<?php } ?></strong> </td>
				  <td>:</td>
                  <td style="text-align:right"><?php echo $myrow1['sur_amt']; ?></td>
                </tr>
                <tr>
                  <td style="padding-top:3px; padding-bottom:0px;"><strong>Freight</strong> </td>
				  <td>:</td>
                  <td style="text-align:right"><?php echo $myrow1['freight']; ?></td>
                </tr>
               
                <tr>
                  <td style="padding-top:3px; padding-bottom:0px;"><strong>Additional Charges</strong> </td>
				  <td>:</td>
                  <td style="text-align:right"><?php echo $myrow1['add_charges']; ?></td>
                </tr>
				
				<?php $number1=explode('.',$myrow1['grand_total']); ?>
                <tr>
                <td style="padding-top:4px;padding-bottom:4px;font-size:15px; font-weight:bold;background-top-color:#000000; border-top-style:solid; border-top-width:2px;"><strong>Grand Total</strong></td>
				  <td style="background-top-color:#000000; border-top-style:solid; border-top-width:2px;">:</td>
                  <td style="background-top-color:#000000; border-top-style:solid; border-top-width:2px; text-align:right;"><?php echo $myrow1['grand_total'];?><input type="hidden" name="purchase_order_print[grand_total]" id="grand_total"  value="<?php	echo $myrow1['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" />                  </td>
                </tr>
</table>	</td>
  </tr>
</table>

<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>