<?php 
ob_start();
$PageSecurity = 2;
$title = _('Purchase Bill Book List');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
$sql="Select * from purchase_billbook where id='".$_REQUEST['viewId']."'";
$result=DB_query($sql,$db);
$myrow=DB_fetch_array($result);
extract($myrow);
?>
<link rel="stylesheet" type="text/css" href="css/professional/table_frize.css">
<h2 align="center"><strong>View Purchase Bill - <?php echo $myrow['bill_book_no'];?></strong></h2>
<h2 align="center"><strong>General Details</strong></h2>
<div align="center">
<table width="65%"  cellspacing="2" cellpadding="2" style="background:#CCCCCC; border: solid 1px #999999">
<tr>
<th width="19%"><strong>Site</strong></th>
<td width="27%"><?php echo $s->getField('locations','loccode',$site,'locationname');?></td>
<th width="23%" nowrap="nowrap">
 <strong>Purchase Voucher No  </strong></th>
<td width="31%"><?php echo $bill_book_no;?>
</td>
</tr>
<tr>
<th><strong>Vendor Name </strong></th>
<td><?php echo $s->getField('suppliers','id',$vendor,'vendor_name');?></td>
<th><strong>Cash/Credit</strong></th>
<td><?php echo $cash_credit;?></td>
</tr>
<tr>
<th><strong>MRN No</strong></th>
<td><?php echo $s->getField('addmrn','id',$mrn_no,'MRNNo');?></td> 
<th><strong>Credit Days</strong></th>
<td><?php echo $credit_days;?></td>
</tr><tr>
<th><strong>Due Date</strong></th>
<td><?php echo ConvertSQLDate($due_date);?></td>
<th><strong>Date</strong></th>
<td><?php echo ConvertSQLDate($bill_book_date);?></td>
</tr>
<tr>
<th>Bill/Challan No</th>
<td><?php echo $s->getField('addmrn','id',$mrn_no,'BillNo');?></td>	
	
</tr>

</table>
</div>
<br>
<fieldset><legend><strong>ITEM DETAILS <?php echo $type_row['Type'];?></strong></legend>

<div style="overflow:scroll; width:950px ; ">
	<div id="itemid">
<table width="100%" border="0" cellspacing="3" cellpadding="5">
  <tr>
    <th scope='col'><strong>ITEM CODE </strong></th>
    <th scope='col'><strong>DESCRIPTION</strong></th>
    <th scope='col'><strong>MAKE</strong></th>
    <th scope='col'><strong>COLOR</strong></th>
	<th scope='col'><strong>GRADE</strong></th>
    <th scope='col'><strong>UOM</strong></th>
    <th scope='col'><strong>PO QTY </strong></th>
    <th scope='col'><strong>QTY AS PER BILL </strong></th>
    <th scope='col'><strong>QTY ACCEPTED </strong></th>
    <th scope='col'><strong>SHORT QUANTITY </strong></th>
    <th scope='col'><strong>RATE</strong></th>
	<th scope='col'><strong>Total Price</strong></th>	
	<th ><strong>Discount Percent</strong></th>
	<th ><strong>Discount</strong></th>
	<th ><strong>Discount Amount</strong></th>
	<th ><strong>Sub Total</strong></th>
	<TH><strong>SPECIAL DISCOUNT</strong></TH>
	<TH><strong>SPECIAL DISCOUNT AMOUNT</strong></TH>
	<th ><strong>BASIC AMOUNT</strong></th>
	<th ><strong>Tax Type</strong></th>
	<th width='59%'><strong>Excise</strong></th>
	<th><strong>E-Cess</strong></th>
	<th><strong>SAH-E Cess</strong></th>
	<th><strong>Taxable Amount </strong></th>
	<th><strong>VAT/CST</strong></th>
	<th><strong>VAT/CST Amount</strong></th>
	<TH><strong>TOTAL AMOUNT</strong></TH>    
	<th scope='col'><strong>REMARKS</strong></th>
  </tr>
  <?php 
  $sql2=DB_query("Select * from purchase_bill_details where purch_billbookid='".$_REQUEST['viewId']."'",$db);
  while($row=DB_fetch_array($sql2)){ extract($row);
 $mrn_item_details=DB_query("SELECT POQty,qty_as_per_bill,short_accessid FROM `addmrnqty` where issue_id='".$myrow['mrn_no']."' and mst_itemid='".$mst_productid."'",$db);
 $mrn_row=DB_fetch_array($mrn_item_details);
  ?>
  <tr bgcolor='#FFFFFF'>
    <td><?php echo $s->getField('item_master','id',$mst_productid,'StockID');?></td>
    <td><?php echo $s->getField('item_master','id',$mst_productid,'item_name');?></td>
    <td><?php echo $make;?></td>
    <td><?php echo $grade;?></td>
    <td><?php echo $color;?></td>
    <td><?php echo $s->getField('unitsofmeasure','unitid',$s->getField('item_master','id',$mst_productid,'unit'),'unitname');?></td>
    <td><?php echo $mrn_row['POQty'];?></td>
    <td><?php echo $mrn_row['qty_as_per_bill'];?></td>
    <td><?php echo $quantity;?></td>
    <td><?php echo $mrn_row['short_accessid'];?></td>
    <td><?php echo $rate;?></td>
    <td><?php echo $total_price;?></td>
    <td><?php echo $discount_type;?></td>
    <td><?php echo $discount;?></td>
    <td><?php echo $discount_amount;?></td>
    <td><?php echo $sub_total;?></td>
    <td><?php echo $specialdiscount;?></td>
    <td><?php echo $specialdiscount_amount;?></td>
    <td><?php echo $basic_amt;?></td>
    <td><?php echo $tax_type;?></td>
    <td><?php echo $ExcisePercentage." - ".$Excise_Duty_value;?></td>
    <td><?php echo $Edu_Cess;?></td>
    <td><?php echo $SHE_Cess;?></td>
    <td><?php echo $taxable_amt;?></td>
    <td><?php if($tax_type=='IncludeTax'){echo "-";}else{echo $vat_cst;}?></td>
    <td><?php if($tax_type=='IncludeTax'){echo "-";}else{echo $vat_cst_amt;}?></td>
    <td><?php echo $total_amount;?></td>
	<td><?php echo $remarks;?></td>
  </tr><?php } ?>
  </table>
  </div>
</div>

</fieldset>
	

<br>
<div align="right">

<table border="1" cellspacing="1" cellpadding="2" width="100%">
<tr>
<td valign="top">
<table width="100%" align="left" style="border:solid 1px #999999; background:#CCCCCC">
<tr>
<th><strong>Ledger</strong></th>
<td><?php echo $s->getField('accountledger','AccountsID',$ledger,'AccountName');?></td>
</tr>
<tr>
<th><strong>Remarks If Any</strong></th>
<td>
<textarea name="remarks" id="remarks" rows="3" cols="25"><?php echo $myrow['remarks'];?></textarea></td>
</tr>
  <tr>
    <th valign="top"><strong>Excise Effect</strong></th>
    <td valign="top"><select name='Excise_Effect' style="width:auto">
	<option value="0">---</option>
	<option value="RG-23A"  <?php echo ($myrow['Excise_Effect']=='RG-23A')?'selected':''?>  >RG 23A &Iota; &Iota;nd</option>
		<option value="RG-23C"  <?php echo ($myrow['Excise_Effect']=='RG-23C')?'selected':''?>  >RG 23C &Iota; &Iota;nd</option>
		<option value="modvat"  <?php echo ($myrow['Excise_Effect']=='modvat')?'selected':''?>  >Mod Vat</option>
 	</select>&nbsp;</td>
  </tr>
  <tr>
  <th>Form Type</th>
  <td><select  name="form_type" id="form_type" style="width:100%; height:20px;">
  <option value="">Select</option>
  <?php
 $formSql=DB_query("Select * from form_type_master",$db);
while($formRow=DB_fetch_array($formSql))
{
?>
  <option value="<?php  echo $formRow['id']?>"<?php echo ($form_type==$formRow['id']?'selected':'')?>><?php  echo $formRow['form_name']?></option>
  <?php }?>
</select></td>
  </tr>
  </table></td>
<td align="right" width="50%">
<table width="100%" border="0" cellspacing="2" cellpadding="2"  style="border:solid 1px #999999; background:#CCCCCC">
                <tr>
                  <td><strong>TOTAL AMOUNT</strong> </td>
                  <td ><input type="text" name="total_item_amount" id="total_item_amount" style="width:100%;" onfocus="cal_totalamount()" readonly="readonly" value="<?php echo $total_item_amount;?>" /></td>
                </tr>
               
                <tr>
                  <td><strong>Surcharge Amount</strong> </td>
                  <td><input name="sur_oct_amt" type="text" id="sur_oct_amt" value="<?php echo $sur_oct_amt;?>" style="width:100%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="freight" id="TotalCharge" style="width:100%;" value="<?php echo $freight;?>"/></td>
                </tr>
                <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input name="pkg_charges" id="packagingCharges" type="text" value="<?php echo $pkg_charges;?>" size="25" style="width:100%;" /></td>
                </tr>
                <tr>
                  <td><strong>Additional Charges</strong> </td>
                  <td><input name="add_charges" id="additionalCharges" type="text" value="<?php echo $add_charges;?>" size="25" style="width:100%;" /></td>
                </tr>
				<tr>
					<td><strong>Round Off</strong></td>
					<td><input type="text" name="round_off" id="round_off" style="width:100%;" value="<?php echo $round_off;?>" /></td>
				</tr>
				
                <tr>
                  <td><strong>Grand Total</strong></td>
                  <td><input type="text" name="GrandTotal" id="GrandTotal" style="width:100%;" readonly="readonly"  value="<?php echo $GrandTotal;?>"/></td>
                </tr>
              </table>
</td>
</tr>
</table>