<?php 
ob_start();
$PageSecurity = 3;
 include ('includes/session.inc');
  include ('includes/function_lib.php');
 global $db;
 include('includes/Class_Branch.php');
	include('includes/AccountGroupMaster_Class.php');

 
$sql="Select * from purchase_billbook where id='".$_REQUEST['viewId']."'";
$result=DB_query($sql,$db);
$myrow=DB_fetch_array($result);
extract($myrow);
?>
<link href="css/autcomplete.css" rel="stylesheet" type="text/css" />
<div class="bg1">
<h2 align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333;"><strong>Purchase Bill - <?php echo $myrow['bill_book_no'];?></strong></h2>
<h2 align="center" style="font-size:18px; font-family:Arial, Helvetica, sans-serif; color:#333;"><strong>General Details</strong></h2>
<div align="center">
<table width="70%" border="0"  cellspacing="2" cellpadding="3" style="background:#FFFFFF; border: solid 1px #999999">
<tr>
<th width="19%" align="left" valign="middle" bgcolor="#8fadcc" class="f11bold"><strong>Site</strong></th>
<td width="27%" bgcolor="#b8cfe5" class="f11normal"><?php echo $s->getField('locations','loccode',$site,'locationname');?></td>
<th width="23%" align="left" valign="middle" nowrap="nowrap"  bgcolor="#8fadcc">
 <strong class="f11bold">Purchase Voucher No  </strong></th>
<td width="31%" bgcolor="#b8cfe5" class="f11normal"><?php echo $bill_book_no;?></td>
</tr>
<tr>
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">Vendor Name </strong></th>
<td bgcolor="#b8cfe5" class="f11normal"><?php echo $s->getField('suppliers','id',$vendor,'vendor_name');?></td>
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">Cash/Credit</strong></th>
<td bgcolor="#b8cfe5" class="f11normal" ><?php echo $cash_credit;?></td>
</tr>
<tr>
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">MRN No</strong></th>
<td bgcolor="#b8cfe5" class="f11normal"><?php echo $s->getField('addmrn','id',$mrn_no,'MRNNo');?></td> 
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">Credit Days</strong></th>
<td bgcolor="#b8cfe5" class="f11normal"><?php echo $credit_days;?></td>
</tr><tr>
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">Due Date</strong></th>
<td bgcolor="#b8cfe5" class="f11normal"><?php echo ConvertSQLDate($due_date);?></td>
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">Date</strong></th>
<td bgcolor="#b8cfe5" class="f11normal"><?php echo ConvertSQLDate($bill_book_date);?></td>
</tr>
<tr>
<th align="left" valign="middle" bgcolor="#8fadcc"><strong class="f11bold">Bill/Challan No</strong></th>
<td bgcolor="#b8cfe5" class="f11normal"><?php echo $s->getField('addmrn','id',$mrn_no,'BillNo');?></td>	
	
</tr>

</table>
</div>
<br>


<div style="overflow:scroll; width:950px; padding-left:25px;">
	<div id="itemid" >
<table width="100%" class="pretty-table" align="center">
  <tr>
    <th scope='col' align="left" valign="middle"><strong>Item Code</strong></th>
    <th scope='col' align="left" valign="middle"><strong>Description</strong></th>
    <th scope='col' align="left" valign="middle"><strong>Make</strong></th>
    <th scope='col' align="left" valign="middle"><strong>Color</strong></th>
	<th scope='col' align="left" valign="middle"><strong>Grade</strong></th>
    <th scope='col' align="left" valign="middle"><strong>Uom</strong></th>
    <th scope='col' align="left" valign="middle"><strong>PO Qty  </strong></th>
    <th scope='col' align="left" valign="middle"><strong>Bill Qty  </strong></th>
    <th scope='col' align="left" valign="middle"><strong>Qty Accepted </strong></th>
    <th scope='col' align="left" valign="middle"><p><strong>Short Qty </strong></p>
      </th>
    <th scope='col' align="left" valign="middle"><strong>Rate</strong></th>
	<th scope='col' align="left" valign="middle"><strong>Total Price</strong></th>	
	<th scope='col' align="left" valign="middle"><strong>Discount Percent</strong></th>
	<th  scope='col' align="left" valign="middle" ><strong>Discount</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>Discount Amount</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>Sub Total</strong></th>
	<TH scope='col' align="left" valign="middle" ><strong>Special Disc. </strong></TH>
	<TH scope='col' align="left" valign="middle" ><strong>Special Disc. Amt. </strong></TH>
	<th scope='col' align="left" valign="middle" ><strong>Basic Amt. </strong></th>
	<th scope='col' align="left" valign="middle" ><strong>Tax Type</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>Excise</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>E-Cess</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>SAH-E Cess</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>Taxable Amount </strong></th>
	<th scope='col' align="left" valign="middle" ><strong>VAT/CST</strong></th>
	<th scope='col' align="left" valign="middle" ><strong>VAT/CST Amount</strong></th>
	<TH scope='col' align="left" valign="middle" ><strong>Total Amt. </strong></TH>    
	<th scope='col'align="left" valign="middle" ><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='#c9d9e9'>
    <td align="left" valign="middle" class="f11normal"><?php echo $s->getField('item_master','id',$mst_productid,'StockID');?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $s->getField('item_master','id',$mst_productid,'item_name');?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $make;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $grade;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $color;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $s->getField('unitsofmeasure','unitid',$s->getField('item_master','id',$mst_productid,'unit'),'unitname');?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $mrn_row['POQty'];?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $mrn_row['qty_as_per_bill'];?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $quantity;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $mrn_row['short_accessid'];?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $rate;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $total_price;?></td>
    <td><?php echo $discount_type;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $discount;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $discount_amount;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $sub_total;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $specialdiscount;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $specialdiscount_amount;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $basic_amt;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $tax_type;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $ExcisePercentage." - ".$Excise_Duty_value;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $Edu_Cess;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $SHE_Cess;?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $taxable_amt;?></td>
    <td align="left" valign="middle" class="f11normal"><?php if($tax_type=='IncludeTax'){echo "-";}else{echo $vat_cst;}?></td>
    <td align="left" valign="middle" class="f11normal"><?php if($tax_type=='IncludeTax'){echo "-";}else{echo $vat_cst_amt;}?></td>
    <td align="left" valign="middle" class="f11normal"><?php echo $total_amount;?></td>
	<td align="left" valign="middle" class="f11normal"><?php echo $remarks;?></td>
  </tr><?php } ?>
  </table>
  </div>
</div>


<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:#c9d9e9;">
<tr>
<th width="25%" align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Ledger</strong></th>
<td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#333; line-height:18px;"><?php echo $s->getField('accountledger','AccountsID',$ledger,'AccountName');?></td>
</tr>
<tr>
<th align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Remarks If Any</strong></th>
<td align="left" valign="middle" >
<textarea name="remarks" id="remarks" rows="3" cols="25" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:70px;
	height:70px\0/;"> <?php echo $myrow['remarks'];?></textarea></td>
</tr>
  <tr>
    <th align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Excise Effect</strong></th>
    <td valign="top"><select name='Excise_Effect' style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;">
	<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 align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Form Type</strong></th>
  <td><select  name="form_type" id="form_type" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;">
  <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:#c9d9e9">
                <tr>
                  <td width="30%" align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>TOTAL AMOUNT</strong> </td>
                  <td align="left" valign="middle" ><input type="text" name="total_item_amount" id="total_item_amount" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" onfocus="cal_totalamount()" readonly="readonly" value="<?php echo $total_item_amount;?>" /></td>
                </tr>
               
                <tr>
                  <td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Surcharge Amount</strong> </td>
                  <td align="left" valign="middle" ><input name="sur_oct_amt" type="text" id="sur_oct_amt" value="<?php echo $sur_oct_amt;?>" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" /></td>
                </tr>
                <tr>
                  <td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Freight</strong> </td>
                  <td align="left" valign="middle" ><input type="text" name="freight" id="TotalCharge" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" value="<?php echo $freight;?>"/></td>
                </tr>
                <tr>
                  <td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Pkg Charges</strong> </td>
                  <td align="left" valign="middle" ><input name="pkg_charges" id="packagingCharges" type="text" value="<?php echo $pkg_charges;?>" size="25" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" /></td>
                </tr>
                <tr>
                  <td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Additional Charges</strong> </td>
                  <td align="left" valign="middle" ><input name="add_charges" id="additionalCharges" type="text" value="<?php echo $add_charges;?>" size="25" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" /></td>

                </tr>
				<tr>
					<td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Round Off</strong></td>
					<td align="left" valign="middle" ><input type="text" name="round_off" id="round_off" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" value="<?php echo $round_off;?>" /></td>
				</tr>
				
                <tr>
                  <td align="left" valign="middle" style="font-weight:normal; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000;"><strong>Grand Total</strong></td>
                  <td align="left" valign="middle" ><input type="text" name="GrandTotal" id="GrandTotal" style="width:80%;
	font-family: Arial, Helvetica, sans-serif;
	background-color: #e6e6e6;
	font-size: 11px;
	height:24px;
	height:24px\0/;" readonly="readonly"  value="<?php echo $GrandTotal;?>"/></td>
                </tr>
      </table>
</td>
</tr>
</table>
</div>