<?php
$sql_fetch=DB_query("select * from faberication_main where id='".$_REQUEST['SOrderId']."'",$db);
$sql_fetch_data=DB_fetch_array($sql_fetch);
extract($sql_fetch_data);
?>
<center> <h2>Fabrication Sheet</h2>
</center>
<fieldset><legend style="font-size:13px;"><strong>General Details</strong></legend>
<table width="100%" align="center" border="1" cellpadding="2" cellspacing="1">
  <tr>
    <th width="13%"><strong>Branch</strong></th>
    <td width="20%"><?php 
	  $sql_branch=DB_fetch_array(DB_query("select * from locations where loccode='".$site."' and  CompanyId='".$_SESSION['ACGCompanyId']."'",$db));     echo $sql_branch['locationname'];  ?></td>
    <th width="13%"><strong>Sheet No.</strong></th>
    <td width="20%"><?php  echo $sheet_no;  ?>  </td>
    <th><strong>Sheet Date</strong></th>
    <td width="20%"><?php echo date('d/m/Y') ; ?></td>
    </tr>
    <tr>
    <th><strong>Client</strong></th>
    <td><?php echo $s->getField('clientmaster','id',$client,'c_name'); ?>	</td>
    <th><strong>Against MMS </strong></th>
    <td><?php echo $s->getField('measurment_sheet_main','id',$against_indent,'mms_no') ?>  </td>
    <th><strong>MMS Date</strong></th>
    <td><?php echo ConvertSQLDate($s->getField('measurment_sheet_main','id',$against_indent,'mms_date') )?></td>
  </tr>
  
  <tr>
    <th><strong>Consignee</strong></th>
    <td><?php
	$consignee_sql=DB_fetch_array(DB_query("SELECT * FROM clientmaster_consignee_address where id='".$consignee."'",$db)); ?>
	<?php echo $consignee_sql['consignee_name']; ?></td>
    <th><strong>Type of Sheet</strong></th>
    <td><?php echo $type_of_sheet  ;?>    </td>
    <th><strong>Type</strong></th>
    	<?php $ty_nm=DB_fetch_array(DB_query("SELECT name FROM type_master WHERE id='".$type."'",$db)); ?>
    <td><?php echo $ty_nm['name'];?> </td>
  </tr>
</table>
</fieldset>
<br />


<fieldset><legend style="font-size:13px;"><strong>Item Details

</strong></legend>
<table width="100%" border="1" cellpadding="2" cellspacing="1">
  <tr>
    <th width="5%">Sr No</th>
    <th width="20%">Item Name</th>
    <th width="33%" align="left">Size</th>
    <th align="left">Qty</th>
	<th align="left">Unit</th>
	
  </tr>
<?php
$k1=1;
$sql=DB_query("select * from faberication_main_child_item  where  parent_id='".$_REQUEST['SOrderId']."'",$db);
while($row2=DB_fetch_array($sql))
{

$unitid=$s->getField('item_master','id',$row2['itemid'],'mst_unitid');
$unit=$s->getField('unitsofmeasure','unitid',$unitid,'unitname');

?>
 <tr>
 <td><?php  echo $k1;    ?></td>
 <td><?php  echo $s->getField('item_master','id',$row2['itemid'],'item_name');   ?> </td>
 <td><?php  echo $s->getField('size_master','id',$row2['size'],'size');   ?> </td>
 <td><?php  echo $row2['qty'];   ?> </td>
 <td><?php  echo $unit;   ?></td> 
  
  </tr>
 <?php $k1++; } ?> 
  
  </table>
  </fieldset>

<?php
$k=1;
$item=array();
$sql=DB_query("select * from faberication_main_child where parentid='".$id."'",$db); 
while($row=DB_fetch_array($sql))
{
if(!in_array($row['groupid'],$item))
{
$item[]=$row['groupid'];
?>

<fieldset><legend style="font-size:13px;"><strong>
<?php echo $s->getField('fabrication_group','id',$row['groupid'],'group_name'); ?>

</strong></legend>
<table width="100%" border="1" cellpadding="2" cellspacing="1">
  <tr>
    <th width="5%">Sr No</th>
    <th width="20%">Parameter</th>
    <th width="33%" align="left">Specification</th>
    <th align="left">Remarks</th>
  </tr>
  <?php 
  $i=1;
  $sql1=DB_query("select * from faberication_main_child where groupid='".$row['groupid']."' and parentid='".$id."'",$db);
  while($row1=DB_fetch_array($sql1))
  { 
  ?>
  <tr>
    <td><?php echo $i; ?></td>
    <td><?php  echo  $s->getField('fabrication_group_parameter','id',$row1['parameter'],'terms_conditions');	?>	</td>
    <td><?php echo   $s->getField('fabrication_group_parameter','id',$row1['specificatin'],'terms_conditions');	?> 	</td>
    <td><?php echo $row1['remarks']; ?></td>
  </tr>
  <?php $i++; }?>
  
  
</table>


</fieldset>
<?php $k++; } }?>
<br />

<br />
<table width="100%" align="center" border="1" cellpadding="2" cellspacing="1">
 <tr>
    <th>Remarks</th>
    <td colspan="5">
	<textarea rows="3" style="width:100%" readonly="readonly"><?php echo $remarks; ?></textarea>
	</td>
  </tr>
 
  <tr>
    <th width="13%"><strong>Prepared By </strong></th>
    <td width="20%"><?php echo $s->getField('www_users','id',$prepared_by	,'realname'); ?>      </td>
    <th width="13%"><strong>Checked By </strong></th>
    <td width="20%"> <?php echo $checked_by; ?> </td>
    <th><strong>Authorized By</strong></th>
    <td width="20%"><?php echo $authorized_by; ?> </td>
  </tr>
  
</table>

