<?php $PageSecurity = 11;
include('includes/session.inc');
include('includes/function_lib.php');
if($_REQUEST['bomid']==1)
{
if($_REQUEST['site']!='')
{
 //echo "select mst_itemid from job_card_item_details";
//echo $_REQUEST['jobid'];
$partcode=$s->getField('job_card','id',$_REQUEST['jobid'],'work_itemid');


$query = "SELECT id FROM bill_material WHERE part_id='".$partcode."' and brach_code='".$_REQUEST['site']."' and CompanyId='".$_SESSION['ACGCompanyId']."'";
$result = DB_query($query,$db);
$row = DB_fetch_array($result);

$sql = "SELECT B.part_code, B.mst_itemid, B.bom_uom, B.bom_qty as qty, I.item_name FROM bill_raw_material B INNER JOIN item_master I ON I.id=B.mst_itemid WHERE B.bill_material_id='".$row['id']."'";

$bill = DB_query($sql,$db);
$i=1;
$str .= '
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
	<td class="tabledata">&nbsp;</td>
	<td class="tabledata">Item Code </td>
	<td class="tabledata">Item Name </td>
	<td class="tabledata">Unit</td>
	<!--<td class="tabledata">Size</td> -->
	<td class="tabledata">Total Req Qty</td>
  </tr>
  <tbody id="dataTable">';
	while($billRow = DB_fetch_array($bill)){
	 $qty = (int)$billRow['qty'] * $_REQUEST['prd_qty'];		  
$str .='
<tr bgcolor="#c1c1c1">
  	<td>'.$i.'<input type="hidden" name="mst_itemid[]" id="itemid_'.$i.'" 
	value="'.$billRow['mst_itemid'].'"  /></td>
  	<td><input type="text" name="itemcode[]" id="itemcode_'.$i.'" value="'.$billRow['part_code'].'" style="width:100%" readonly="" /></td>
    <td><input type="text" name="item_name[]" id="item_name_'.$i.'" value="'.$billRow['item_name'].'" style="width:100%"></td>
    <td><input type="text" name="uom[]" id="uom" value="'.$billRow['bom_uom'].'" style="width:100%" readonly ></td>
  <!--<td><input type="text" name="size" id="size_'.$i.'" style="width:100%" value="'.$billRow['size'].'" /></td>-->
       
    <td><input type="text" name="amount[]" id="amount_'.$i.'" value="'.$qty.'" style="width:100%"></td>
  </tr>';
$i++; }
 
 $str .= '</tbody></table>';
 
 echo $str;
  }  
}else{  
  $str .='
  <table border="1" cellpadding="3" cellspacing="0" width="100%" style="border:1px solid #333333;">
<tr bgcolor="#d4d4d4">
	     <td class="tabledata"><strong>Select</strong></td>
         <td class="tabledata"><strong>Item Code</strong></td>
		 <td class="tabledata"><strong></strong></td>
         <td class="tabledata"><strong>Item Name</strong></td>
	     <td class="tabledata"><strong>UOM</strong></td>		 
         <!--<td class="tabledata"><strong>Size</strong></td>-->
         <td class="tabledata"><strong>Total Req Qty</strong></td>
</tr>
<tbody id="dataTable">
<tr class="rowdata">
<td><input name="delitem[]" type="checkbox"  id="delitem" /></td>
<td><input type="text" name="itemcode[]" id="itemcode" style="width:100%" readonly="true"  /></td>
<td><input type="hidden" name="mst_itemid[]" id="itemid" value="" /></td>
<td><input type="text" name="item_name[]" id="itemname" style="width:100%" readonly/> </td>
<td><input type="text" name="uom[]" id="Unit" style="width:100%" readonly /></td>
<!--<td><input type="text" name="size[]" id="size"  style="width:100%" readonly /></td>-->
<td><input name="amount[]" type="text" id="amount" style="width:100%" onblur="CalrequiredQty(this.value,this.id)" /></td>

</tr>
</tbody>
</table>

<input type="hidden" name="hiditemcount" id="hiditemcount" value="" />
  <input type="hidden" name="" value="0" id="edit_cnt" />
    <input type="hidden" name="" value="0" id="rowcount1" />
  
  
  
  
  ';
  
 echo $str; 
}  
  ?>
