<?php
$table_name='sub_preparation';
$condition="id='".$_REQUEST['id']."'";
$record=$s->GetRecordById($table_name,  $condition);
$recordRow=DB_fetch_array($record);

if($_REQUEST['save'])
{
	if($_REQUEST['approve']!='')
	{
		$dataArray['approval_status']='Approved';
		$cond="id='".$_REQUEST['id']."'";
		$s->RecordEdit($table_name, $dataArray, $cond);
		$_SESSION['success_msg']="Approved Successfully";	
	echo "<script>location.href='index.php?route=SubContractors/workOrder/work_order_approval_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
	}
	else
	{
	echo "<script>alert('Try Again');</script>";
	}
}


?>
<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
<h3> Work Order Approval </h3>
<form action="" method="post">
<table width="100%" border="1" cellpadding="3" >
<tr>
<th width="24%" class="tabledata"><div align="left">Project</div></th>
<td width="22%">
<?php echo $s->GetFieldValue('locations',"loccode='".$recordRow['project']."'",'locationname');?></th>
<th width="28%" class="tabledata"><div align="left">Block</div></th>
<td width="26%"><?php echo $s->GetFieldValue('sub_block_master',"id='".$recordRow['block']."'",'block_name');?></th>
</tr>
<tr>
<th class="tabledata"><div align="left">Contractor Category</div></th>
<td><?php echo $s->GetFieldValue('tbl_subcontractor_contractor_category',"id='".$recordRow['contractor_category']."'",'Contractor_category_name');?></td>
<th class="tabledata"><div align="left">Contractor</div></th>
<td><?php echo $s->GetFieldValue('sub_contractor_definition',"id='".$recordRow['contractor']."'",'contractor_name');?></th>
</tr>
<tr>
<th class="tabledata"><div align="left">Work Order Date</div></th>
<td><?php echo ConvertSQLDate($recordRow['work_order_date']); ?></td>
<th class="tabledata"><div align="left">Work Order No.</div></th>
<td><?php echo $recordRow['work_order_no'];?></td>
</tr>
<tr>
<th class="tabledata"><div align="left">Work Order Start Date</div></th>
<td><?php echo ConvertSQLDate($recordRow['work_order_start_date']);?></td>
<th class="tabledata"><div align="left">Work Order Completion Date</div></th>

<td> <?php echo ConvertSQLDate($recordRow['work_order_completion_date']); ?></td>
</tr>
</table>
<br/>
<table width="100%" border="1">
	<tr >
	<td class="tabledata">Sl.No.</td>
	<td class="tabledata">Activity Group</td>
	<td class="tabledata">Activity</td>
	<td class="tabledata">Unit</td>
	<td class="tabledata">Qty</td>
	<td class="tabledata">Rate</td>
	<td class="tabledata">Amount</td>
	<td class="tabledata">Net Amount</td>
	</tr>
	<?php 
	$recchild=DB_query("select * from sub_preparation_child where parentid='".$_REQUEST['id']."'",$db);
	$i=0;
	while($recchildRow=DB_fetch_array($recchild)){
	?>
	<tr>
	<td><?php echo $i+1; ?></td>
	<td><?php echo $group_name=$s->GetFieldValue('master_boq',"id='".$recchildRow['group_id']."'",'group_title');?></td>
	<td style="width:300px;"><?php echo $activity_name=$s->GetFieldValue('master_boq',"id='".$recchildRow['activity_id']."'",'group_title');?></td>
	<td><?php echo $s->GetFieldValue('unitsofmeasure',"unitid='".$recchildRow['unit']."'",'unitname') ;?></td>
	<td><?php echo $recchildRow['qty'] ?></td>
	<td><?php echo $recchildRow['rates'] ?></td>
	<td><?php echo $recchildRow['amt'] ?></td>
	<td><?php echo $recchildRow['net_amt'] ?></td>
	</tr>
	<?php $i++; } ?>
	<tr>
	<td colspan="6">&nbsp;</td>
	<td>Grand Total Ammout</td>
	<td><? echo $recordRow['grand_total']; ?></td>
	</tr>
</table>
<p align="center">
<input name="approve" type="radio" value="Approved" id="approve"/>Approve
<input type="submit" value="Save" name="save" onclick="return f_validate();"></a></p>
</form>
