<?php
//**************************************SEARCHING******************START HERE*******************************************
if($_REQUEST['search']!='')
{
	$filter = array();
	if(isset($_REQUEST['contractor']) && $_REQUEST['contractor'] != '')
	$filter[]="contractor='".$_REQUEST['contractor']."'";
	if(isset($_REQUEST['project']) && $_REQUEST['project'] != '')
	$filter[]="project='".$_POST['project']."'";
	$filter1 = implode("and ",$filter); 
	if($filter1!='')
	{
	$sql="select * from sub_preparation where $filter1";
	}
	else
	{
	$sql = "SELECT * FROM sub_preparation";
	
	}

}
else
{
 $sql = "SELECT * FROM sub_preparation ";
}

//**************************************SEARCHING******************END HERE*******************************************

?>
<link rel="stylesheet" type="text/css" href="SubContractors/css/paginate.css" />

<style>
.label{
background-color: #B7B7B7;
    color: #000000;
    font-size: 10.5px;
    font-weight: bold !important;
    padding: 5px 10px;
    text-align: left;
}
</style>
<h3> Work Order Ammendment Approval</h3>
<!--<form action="" method="post">
<table width="75%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td>Contractor </td>
    <td><select name="contractor">
		<option value="">Select CategoryName</option>
		<?php
		$sqlcategory=DB_query("select * from sub_contractor_definition",$db);
		while($category_row=DB_fetch_array($sqlcategory))
		{
				$s='';
				if($_REQUEST['contractor']==$category_row['id'])
				$s="selected";
		?>
		 <option value="<?php echo $category_row['id'];?>" <?php echo $s;?>><?php echo $category_row['contractor_name'];?></option>
		<?php } ?>
	</select>
	</td>
    <td>Project</td>
    <td><input type="text" name="project"/></td>
    <td><input type="submit" name="search" value="Search" /><input type="reset" value="Reset" name="reset" /></td>
  </tr>
</table>
</form>-->
<div style="width:832px;">
<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
	<tr>
	
<!-----------------------------BEFORE APPROVAL-------------------START HERE-------------------------------------------------->
	
		<td>
		<div style="width:416px">
		<h1 style="font-size:12px; color:#003333; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:10px;">Pending Work Order</h1>
		<p style="margin:0px; padding-bottom:5px;"></p>
		<!--Table 1 Start here --><div style="margin:0px; width:300px;">
		<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
		<tr bgcolor="#CCCCCC">
		<td height="35" style="width:100px; padding-top:5px; padding-bottom:5px; padding-left:10px;">Projects</td>
		<td style="padding-left:5px;">Contractor</td>
		<td style="padding-left:5px;">Work Order</td>
		<td style="padding-left:5px;">Date</td>
		</tr>
		<?php 
		$notapp="select * from sub_amendment where approval_status='Pending'";	
		$rpp = 10; 
		$adjacents = 5;
		$page = intval($_GET["page"]);
		if($page<=0) $page = 1;
		$reload ="index.php?route=SubContractors/workOrder/work_order_amendment_approval_index".$rurl;		
		$result =DB_query($notapp,$db);			
		$tcount = DB_num_rows($result);			
		$tpages = ($tcount) ? ceil($tcount/$rpp) : 1; 
		$count = 0;
		$i = ($page-1)*$rpp;
		while(($count<$rpp) && ($i<$tcount)) {
		DB_data_seek($result,$i);
		$query = DB_fetch_array($result);
		extract($query);
		
		?>
		<tr bgcolor="#e7e7e7">
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_add<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php 
		$s=new db_query;
		echo $s->GetFieldValue('locations',"loccode='".$project."'",'locationname'); ?>
		</a>
		</div></td>
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_add<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php echo $s->GetFieldValue('sub_contractor_definition',"id='".$contractor."'",'contractor_name'); ?>
		</a>
		</div></td>
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_add<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php echo $s->GetFieldValue('sub_preparation',"id='".$work_order_no."'",'work_order_no'); ?>
		</a>
		</div></td>
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_add<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php echo ConvertSQLDate($amendment_date); ?>
		</a>
		</div></td>
		</tr>
		
		<?php  $i++;  $count++; }
		//echo paginate_two($reload, $page1, $tpages, $adjacents);
		// call pagination function:
		?>
		</table>
		</div><!--Table 1 Close here -->
		</div>
		</td>
	
	
<!-----------------------------BEFORE APPROVAL--------------------END HERE------------------------------------------------->
	
	
<!-----------------------------AFTER APPROVAL-------------------START HERE-------------------------------------------------->
	
		<td>
		<div style="width:416px">
		<h1 style="font-size:12px; color:#003333; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:10px;">Approved Work Order</h1>
		<p style="margin:0px; padding-left:10px; padding-bottom:5px;"></p>
		<!--Table 1 Start here -->
		<div style="width:300px; margin:0px;">
		<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
		<tr bgcolor="#CCCCCC">
		<td style="width:200px; padding-top:5px; padding-bottom:5px; padding-left:10px;">Projects</td>
		<td style="padding-left:5px; width:200px;">Contractor</td>
		<td style="padding-left:5px; width:200px;">Work Order</td>
		<td style="padding-left:5px; width:200px;">Date</td>
		</tr>
		<?php 
		$app="select * from sub_amendment where approval_status='Approved'";	
		$rpp = 10; 
		$adjacents = 5;
		$page = intval($_GET["page"]);
		if($page<=0) $page = 1;
		$reload ="index.php?route=SubContractors/workOrder/work_order_amendment_approval_index".$rurl;		
		$result =DB_query($app,$db);			
		$tcount = DB_num_rows($result);			
		$tpages = ($tcount) ? ceil($tcount/$rpp) : 1; 
		$count = 0;
		$i = ($page-1)*$rpp;
		while(($count<$rpp) && ($i<$tcount)) {
		DB_data_seek($result,$i);
		$query = DB_fetch_array($result);
		extract($query);
		?>
		<tr bgcolor="#e7e7e7">
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_view<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php
		$s=new db_query;
		echo $s->GetFieldValue('locations',"loccode='".$project."'",'locationname'); ?> 
		</a></div></td>
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_view<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php echo $s->GetFieldValue('sub_contractor_definition',"id='".$contractor."'",'contractor_name'); ?>
		</a></div></td>
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_view<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php echo $s->GetFieldValue('sub_preparation',"id='".$work_order_no."'",'work_order_no'); ?>
		</a></div></td>
		<td>
		<div style="width:98px;  white-space:nowrap; margin:0px; padding-top:5px; padding-bottom:5px; padding-left:5px;">
		<a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_view<?php echo $rurl;?>&action=Approve&id=<?php echo $id; ?>" style="color:#000000">
		<?php echo ConvertSQLDate($amendment_date); ?>
		</a></div></td>
		</tr>
		<?php  $i++;  $count++; }
		//echo paginate_two($reload, $page1, $tpages, $adjacents);
		// call pagination function:
		?>
		</table>
		</div><!--Table 1 Close here -->
		</div>
		</td>
	
<!-----------------------------AFTER APPROVAL--------------------END HERE------------------------------------------------->

</tr>
</tr>
</table>
</div>
<div><br></div>
<!--<p align="left"><a href="index.php?route=SubContractors/workOrder/work_order_amendment_approval_add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>">Add New</a>
</p>-->
<?php if(isset($_SESSION['success_msg']))
{ ?>
	<script> alert("<?php echo ($_SESSION['success_msg']);?>");</script>
<?php 
unset($_SESSION['success_msg']);
}

?>



