<?php
session_name('CAKEPHP'); session_start();

ob_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Project Detail</title>
</head>

<body>
<?php 
$main_data=DB_fetch_assoc(DB_query("select * from boq_entry where id='".$_REQUEST['pid']."' ",$db));
//print_r($main_data);
$order_det=DB_fetch_assoc(DB_query("SELECT * FROM `manufacturing_advice` WHERE id='".$main_data['salesorder_id']."' ",$db));
?>


<?php  $com_data=DB_fetch_assoc(DB_query("select CompanyName from companies where CompanyId='".$_SESSION['ACGCompanyId']."' ",$db));  ?>
<div  style="width:100%;; float:left; text-align:center;"><h2><?php echo $com_data['CompanyName'] ?></h2></div>
<!-- Body Content Start -->
<?php if($_REQUEST['print']=="true")
{ ?>
 <div style="width:100px; float:right;"> 
 <p id="foo" align="right" style="padding-right:40px;"> <a href="#" id="print" onclick="javascript:toggle_visibility('foo');" ><button type="button"><strong>Print</strong></button></a> </p>
<?php } ?>
 </div>

<div style="clear:both;"></div>
<div id="body_content">
	<!-- TAble 1 Start --><div style="overflow:auto; margin-left:auto; margin-right:auto;" width="100%">
	
	<table width="100%" border="1" cellspacing="0" style="border-collapse:collapse;" cellpadding="3" class="">
	<!--<tr class="row1"><td colspan="6"  align="center" style="padding-left:290px;">
	</td></tr> -->
   	<tr class="row1" style="background:#E7E7E7; font:normal 11px Arial;  line-height:20px;">	
		<th class="">Branch</th>
   		<td><?php echo $s->GetfieldValue('locations',"loccode='".$order_det['branchid']."'",'locationname'); ?></td>
    	<th class="" >BOQ No</th>
	 	<td ><?php echo $main_data['boq_no']; ?></td>
	 	<th class="">Date</th>
		<td><?php echo ConvertSQLDate($main_data['project_date']); ?> </td>
	</tr>
	
	<tr class="row1" style="background:#E7E7E7; font:normal 11px Arial;  line-height:16px;">
		 <th class="">Advice No</th>
		 <td><?php echo $order_det['advice_no'] ?></td>
		 <th class="">Order Date</th>
		 <td><?php echo ConvertSQLDate($order_det['advice_date']); ?></td>
		 <th class="">Project Name</th>
		 <td><?php echo $order_det['project_name'];?></td>
	</tr>
	<tr class="row1" style="background:#E7E7E7; font:normal 11px Arial;  line-height:16px;"> 
		  <th class="">Handled By</th>
		 <td><?php echo $main_data['project_handeled_by']; ?></td>
  </tr>
</table>
	</div>
	<br />
<table border="1" width="100%" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#CCCCCC;">
<tr class="row1" style="background:#B2B2B2; font:normal 14px Arial;  line-height:20px;">
	<th class="">Activity Group</th>
	<th class="">Activity Name</th>
	<th class="">Description</th>
	<!--<th class="">Grade</th>-->
	<th class="">Unit</th>
	<th class="">Quantity</th>
	<!--<th class="">Rate</th>
	<th class="">Amount</th>-->
	<th class="">Start Date</th>
	<th class="">End Date</th>
	<th class="">Remark</th>
</tr>
<?php
$qty=array(); 
	$query = "SELECT * from boq_entry_details WHERE master_id='".$_REQUEST['pid']."'";
	$res = DB_query($query,$db) or die(DB_error());
	$m=0;
	while($result = DB_fetch_array($res)){
	   $x = $result['ItemCode'];
	?>
	<tr style="background:#E7E7E7; font:normal 11px Arial; line-height:16px;">
	<td colspan="2"><strong><?php echo $s->GetFieldVAlue('item_master',"id='".$result['itemCode']."'",'item_name'); ?></strong></td>
	<td ><?php//   $query= "select size  from salesorder_details where ItemCode='".$result['itemCode']."' and masterId='".$main_data['salesorder_id']."'";
		// $sql15=DB_query($query,$db);
		// $row25=DB_fetch_array($sql15);
	 // echo $s->GetFieldVAlue('size_master',"id='".$row25['size']."'",'size'); ?></td>
	<td><?php  
	 $unit=$s->GetFieldVAlue('item_master',"id='".$result['itemCode']."'",'mst_unitid');  echo $s->GetFieldVAlue('unitsofmeasure',"unitid='".$unit."'",'unitname'); ?></td>
	<td> <?php   $query1= "select Qty from manufacturing_advice_items where item_code='".$result['itemCode']."' and advice_id='".$main_data['salesorder_id']."'";
		 $sql115=DB_query($query1,$db);
		 $row125=DB_fetch_array($sql115);
	echo $row125['Qty']; ?></td>
	<td colspan="5">&nbsp; </td>
	</tr>
		<tr class="row1" style="background:#E7E7E7; font:normal 12px Arial;  line-height:16px;">
			<td><?php echo $s->GetFieldVAlue('sub_activity_group',"id='".$result['activity_group']."'",'group_name'); ?></td>
			<td><?php echo $result['activity_name']; ?></td>
			<td><?php echo $result['work_description']; ?></td>
			
			<td ><?php echo $result['unit']; ?></td>
			<td><?php echo $result['quantity']; ?></td>
			<!--<td><?php echo $result['rate']; ?></td>
			<td><?php echo $result['amount']; ?></td>-->
			<td><?php echo ConvertSQLDate($result['startdate']); ?></td>
			<td><?php echo ConvertSQLDate($result['enddate']); ?></td>
			<td><?php echo $result['remarks']; ?></td>
		</tr>
		
<?php } ?>
<!--<tr class="row1" style="background:#E7E7E7; font:normal 11px Arial;  line-height:16px;">
	<td colspan="6" style="text-align:right;">Total Project Amount</td>
	<?php 
$main_data=DB_fetch_assoc(DB_query("select Sum(amount) as total from boq_entry_details where master_id='".$_REQUEST['pid']."' ",$db));	
	?>
	<td colspan="6" style="text-align:left;"><?php echo $main_data['total'] ?></td>
	 </tr>-->
  <tr>
  <td colspan="10" style="background:#E7E7E7; font:normal 11px Arial;  line-height:16px; text-align:center; font-weight:bold;"> Prepared By:&nbsp;<?php
   echo $s->GetFieldValue('www_users',"id='".$_SESSION['UserID']."'",'userid'); ?></td>
  </tr>

</table>
</div><!-- Body Content Close -->


<?php 
  ?>

</body>
</html>


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