<?php 
include('config.php');
include('includes/ConnectDB.inc');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
$SQLSales=DB_query("select * from measurment_sheet_main where id='".$_REQUEST['SOrderId']."'",$db);
$GetSalesData=DB_fetch_array($SQLSales);
extract($GetSalesData);
session_name('CAKEPHP'); session_start();
?>
<center><h2 style="font-family:Arial; font-size:18px; color:#003399;"><u><?php //echo"<pre>"; print_r($_SESSION);
$company_name=DB_fetch_assoc(DB_query("select CompanyName from companies where CompanyId='".$_SESSION[ACGCompanyId]."'",$db)); 
echo strtoupper($company_name[CompanyName]);?></u></h3></center>
<center><h2 style="font-family:Arial; font-size:18px; color:#003399;">Measurement Sheet</h2>
</center>
<!--<link rel="stylesheet" href="css/new_mxerp.css">-->
<fieldset><legend style="font-size:16px;"><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);
	  $row1=DB_fetch_array($sql_branch)
	 
	  ?>
     <?php echo $row1['locationname'];  ?>
	 
  
    </td>
    <th width="13%"><strong>MMS No.</strong></th>
    <td width="20%"><?php echo $mms_no; ?></td>
	 <th><strong>MMS Date</strong></th>
    <td width="20%"><?php echo ConvertSQLDate($mms_date); ?></td>
  </tr>
  <tr>
    <th><strong>Format</strong></th>
    <td><?php echo $format; ?></td>
    <th><strong>Type of MMS</strong></th>
    <td><?php echo $mms_type; ?> </td>
    <th><strong>Type</strong></th>
    <td><?php $SubCatSQl=DB_query("SELECT * FROM stockcategory WHERE id ='".$type."'",$db);?>
		
		
	<?php while($SubCatId=DB_fetch_array($SubCatSQl)){ ?>
			<?php echo $SubCatId['categorydescription']; ?>
	<?php }?>
		</td>
  </tr>
  <tr>
    <th><strong>Client</strong></th>
    <td><?php  
	$cl_sql=DB_query("select c_name from clientmaster where id='".$client."'",$db);
	$cl_res=DB_fetch_array($cl_sql);
	
	echo $cl_res['c_name'];  ?></td>
    <th><strong>Order No</strong></th>
    <td><?php echo $order_no; ?></td>
    <th><strong>Order Date</strong></th>
    <td><?php echo ConvertSQlDate($order_date); ?></td>
  </tr>
  <tr>
    <th><strong>P.O. No.</strong></th>
    <td><?php echo $po_no; ?></td>
    <th><strong>Po Date</strong></th>
    <td><?php echo ConvertSQlDate($po_date); ?></td>
    <th><strong>Delivery Date</strong></th>
    <td><?php echo ConvertSQlDate($delivery_date); ?></td>
  </tr>
  <tr>
    <th> <strong>Consignee</strong></th>
    <td>
	<?php  
	$ss_sql=DB_query("select consignee_name from clientmaster_consignee_address where id='".$consignee."'",$db);
	$ss_res=DB_fetch_array($ss_sql);
	
	echo $ss_res['consignee_name'];  ?>
	</td>
    <th><strong>Measurement By</strong></th>			
	<td>
	<?php  
	$ss_sql=DB_query("select technician from technicians where id='".$measurement."'",$db);
	$ss_res=DB_fetch_array($ss_sql);
	
	echo $ss_res['technician'];  ?></td>
    <th><strong>Mobile No. </strong></th>
    <td><?php echo $mobile_no; ?></td>
  </tr>
</table>
</fieldset>
<br />
<fieldset><legend style="font-size:16px;"><strong>Product Information</strong></legend>
<div  > 
<table width="100%" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <th>Sr.No</th>
    <th>Tower</th>
	<th>Floor</th>
    <th>Location</th>
    <th>Item Name</th>
    <th>Size</th>
	<th>Width</th>
  	<th>Height</th>
	<th>Qty</th>
    <th>unit</th>
    <th>Opening Type</th>
	<?php 
	 $sql_4=DB_query("SELECT * FROM `measurment_hardware_details` where parent_id ='".$_REQUEST['SOrderId']."' AND hardware<>0",$db);
			
	    $kk1=0;
		while($row_4=DB_fetch_array($sql_4))
		{
			$item_array1[$kk1]['qty']=$row_4['qty'];
			
			$kk1++;
		}
	
	
	$sql1=DB_query("select * from product_manufacture where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	$numrow1=DB_num_rows($sql1);
	while($row1=DB_fetch_array($sql1))
	{
	?>
    <th><?php   echo $row1['manufacturer']; ?></th>
	<?php } ?>	
    <th>Remarks</th>
  </tr>
  <tbody id="dataTable">
  <?php 
  $t=1;
  $sql=DB_query("select * from measurment_sheet_details where parent_id='".$_REQUEST['SOrderId']."'",$db);
	$numrow=DB_num_rows($sql);
	while($row=DB_fetch_array($sql))
	{
  
  ?>
  <tr>
<td style="white-space:nowrap;" class="tabledata"><?php echo $t; ?></td>	
<td class="tabledata">
<?php  
	$ss1_sql=DB_query("select group_name from tower_master where id='".$row['tower']."'",$db);
	$ss1_res=DB_fetch_array($ss1_sql);
	
	echo $ss1_res['group_name'];  ?></td>
	<td class="tabledata"><?php  
	$ss2_sql=DB_query("select terms_conditions from tower_floor_master where id='".$row['floor']."'",$db);
	$ss2_res=DB_fetch_array($ss2_sql);
	
	echo $ss2_res['terms_conditions'];  ?></td>
	<td class="tabledata" style="white-space:nowrap">
	<?php  
	$ss3_sql=DB_query("select terms_conditions from tower_floor_master where id='".$row['location']."'",$db);
	$ss3_res=DB_fetch_array($ss3_sql);
	
	echo $ss3_res['terms_conditions'];  ?></td>
 
	<td class="tabledata"><?php  
	$ss4_sql=DB_query("select item_name from item_master where id='".$row['itemid']."'",$db);
	$ss4_res=DB_fetch_array($ss4_sql);
	
	echo $ss4_res['item_name'];  ?>
	</td>
	<td class="tabledata"><?php 
		$sz6_sql=DB_query("select size from size_master where id='".$row['size']."'",$db);
	$sz6_res=DB_fetch_array($sz6_sql);
	
	echo $sz6_res['size'];?></td>
	<td class="tabledata"><?php echo $row['width']; ?></td>
	<td class="tabledata"><?php echo $row['height']; ?></td>
	<?php 
	
	?>
	<td class="tabledata"><?php echo $row['qty'];  $qtydata[]=$row['qty'];?></td>
	<td class="tabledata"><?php echo $row['unit']; ?> </td>
	<td class="tabledata"><?php 
		$sz7_sql=DB_query("select group_name from type_of_opening where id='".$row['opening_type']."'",$db);
	$sz7_res=DB_fetch_array($sz7_sql);
	
	echo $sz7_res['group_name'];?>
	</td><?php 	
	
	foreach($item_array1 as $key=>$v)
    { 
	?>
		
   <td class="tabledata"><?php  echo $v['qty'];  ?></td>
	<?php } ?>
		
    <td class="tabledata"></td> 
	
	
	</tr>
	<?php $t++; } ?>
	
	
	
  </tbody>
  
</table>
</div>


<br />
<table width="100%" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <th width="20%">Remarks</th>
    <td colspan="3">
	<textarea cols="25" rows="3" style="width:100%;" readonly="readonly"><?php echo $remarks; ?></textarea>
	</td>
  </tr>
  <tr>
    <th>Prepared By</th>
    <td width="30%"><input name="prepared_by" id="prepared_by" type="hidden"  style="width:100%;" value="<?php echo $_SESSION['UserID']; ?>" readonly="readonly" />
	<input name="prepared_by1" id="prepared_by1" type="text"  style="width:100%;" value="
	
	<?php 
		$sz8_sql=DB_query("select realname from www_users where id='".$_SESSION['UserID']."'",$db);
	$sz8_res=DB_fetch_array($sz8_sql);
	
	echo $sz8_res['realname'];?>" readonly="readonly" />
	</td>
    <th width="20%">Approved By </th>
    <td><input name="approved_by" id="approved_by" type="text"  style="width:100%;" value="
	
	<?php echo $approved_by; ?>" readonly="readonly"/></td>
  </tr>
</table>

</fieldset>
<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>

