<?php
$sql_fetch=DB_query("select * from measurment_sheet_main where id='".$_REQUEST['SOrderId']."'",$db);
$sql_fetch_data=DB_fetch_array($sql_fetch);
extract($sql_fetch_data);
?>
<center> <h2>Measurement 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_query("select * from locations where loccode='".$site."'",$db);
	  while($row1=DB_fetch_array($sql_branch))
	  {
	  ?>
      <?php echo $row1['locationname'];  ?>
	  <?php } ?>
     </td>
    <th width="13%"><strong>Sheet No.</strong></th>
    <td width="20%"><?php  echo "Auto Generate" ?>   </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 Indent</strong></th>
    <td><?php echo $s->getField('indent_so_main','id',$against_indent,'indent_no') ?>  </td>
    <th><strong>Date</strong></th>
    <td><?php echo ConvertSQLDate($s->getField('indent_so_main','id',$against_indent,'indent_date') )?></td>
  </tr>
  
  <tr>
    <th><strong>Consignee</strong></th>
    <td>
       	<?php
	$consignee_sql=DB_query("SELECT * FROM clientmaster_consignee_address where id='".$consignee."'",$db);
	while($row_cons=DB_fetch_array($consignee_sql))
	{	
	?>
	<?php echo $row_cons['consignee_name']; ?>
	 <?php } ?>	
    </td>
    <th><strong>Type of Sheet</strong></th>
    <td><?php echo $type_of_sheet  ;?>    </td>
    <th><strong>Type</strong></th>
    <td><?php echo 	$s->getField('stockcategory','id',$type,'categorydescription');?> </td>
  </tr>
</table>
</fieldset>
<br />

<?php
$k=1;
$item=array();
$sql=DB_query("select * from measurment_sheet_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('Measurement_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 measurment_sheet_main_child where groupid='".$row['groupid']."'",$db);
  while($row1=DB_fetch_array($sql1))
  {
 
  ?>
  <tr>
    <td><?php echo $i; ?></td>
    <td><?php  echo  $s->getField('Measurement_group_parameter','id',$row1['parameter'],'terms_conditions');	?>	</td>
    <td><?php echo   $s->getField('Measurement_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%"><?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>
<br />
<div align="center" id="foo">
	<a href="#" onclick="toggle_visibility(this.id)" id="print"><input type="button" value="Print" id="print" /></a>
	
	</div>
	<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
 
	
       var e = document.getElementById("print");
            
	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
</script>
