
<?php

	if($_REQUEST['action']=='delete' && !empty($_REQUEST['del']))
	{
		if($s->DeleteRecord('sub_bill_deletion',"id=".$_REQUEST['del']))
		{
						
			$_SESSION['success_msg']="Delete Successfully";	
			echo "<script>location.href='index.php?route=SubContractors/RaBill/verified_bill_deletion_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";	
		}
	}

?>
<?php
if($_REQUEST['search']!='')
{
	//print_r($_REQUEST);
	$filter = array();
	
	if(isset($_REQUEST['contractor']) && $_REQUEST['contractor'] != '')
			
	$filter[]="sub_bill_deletion.contractor='".$_REQUEST['contractor']."'";
	if(isset($_REQUEST['project']) && $_REQUEST['project'] != '')
			
	$filter[]="sub_bill_deletion.project='".$_POST['project']."'";
	$filter1 = implode("and ",$filter); 
	if($filter1!='')
			{
				$sql="select * from sub_bill_deletion where $filter1";
			}
			else
			{
				$masg="No Record Found.";
				
			}
	
}
else
{
	$sql = "SELECT * FROM sub_bill_deletion";
				
}
?>


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

<h3>Verified Bill Deletion</h3>
<form action="" method="post">
<table width="75%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td><strong>Contractor </strong></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><strong>Project</strong></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>
<p>&nbsp;</p>
<div><br></div>

<div id="tableContainer" class="tableContainer">
<table class="scrollTable" width="100%" border="0" cellpadding="0" cellspacing="0">

	<tr>
		<th width="30%"><strong>Project</strong></th>
		<th width="20%"><strong>Block</strong></th>
		<th width="20%"><strong>Contractor</strong></a></th>
		<th width="20%"><strong>Work Order No.</strong></th>
		
		<th width="5%">Delete</th>
		
	</tr>
	
	<?php 
          	
			$rpp = 10; // results per page
			$adjacents = 5;
			
			$page = intval($_GET["page"]);
			if($page<=0) $page = 1;
			
			$reload ="index.php?route=SubContractors/RaBill/verified_bill_deletion_index".$rurl;
			
			
			// select appropriate results from DB:
			
			
			//$sql = "SELECT * FROM sub_bill_deletion";
			$result =DB_query($sql,$db);
			
			// count total number of appropriate listings:
			$tcount = DB_num_rows($result);
			
			// count number of pages:
			$tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number
			
			$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="#FFFFFF" onMouseOver="this.style.backgroundColor='#fffeb3'; this.style.color='#00f';" onMouseOut="this.style.backgroundColor='#FFF'; this.style.color='#000000';">
		<td width="30%"><a href="index.php?route=SubContractors/RaBill/verified_bill_deletion_add<?php echo $rurl;?>&action=edit&del=<?php echo $id; ?>" style="color:#000000"><?php echo $project; ?></a></td>
		<td width="20%"><a href="index.php?route=SubContractors/RaBill/verified_bill_deletion_add<?php echo $rurl;?>&action=edit&del=<?php echo $id; ?>" style="color:#000000"><?php echo $block; ?></a></td>
		<td width="20%"> <a href="index.php?route=SubContractors/RaBill/verified_bill_deletion_add<?php echo $rurl;?>&action=edit&del=<?php echo $id; ?>" style="color:#000000">
		<?php
$rowrec=DB_fetch_array(DB_query("select * from sub_contractor_definition where id='".$contractor."'",$db)); 
	echo $rowrec['contractor_name'];
		 ?></a></td>
		
		<td width="20%"><a href="index.php?route=SubContractors/RaBill/verified_bill_deletion_add<?php echo $rurl;?>&action=edit&del=<?php echo $id; ?>" style="color:#000000"><?php echo $work_order_no; ?></a></td>
	
		<td width="5%"><a href="index.php?route=SubContractors/RaBill/verified_bill_deletion_index<?php echo $rurl;?>&action=delete&del=<?php echo $id; ?>" onclick="return confirm('Are you sure you want to delete?')"> <img src="images/Icon_Delete.png" /></a></td>
	</tr>
	
	<?php  $i++;  $count++; }
	// call pagination function:

echo paginate_two($reload, $page, $tpages, $adjacents);
 ?>
</table>
 <font color="#FF0000"><?php echo $masg; ?></font>





</div>

<div><br></div>
<p align="left"><a href="index.php?route=SubContractors/RaBill/verified_bill_deletion_add&modid=<?php echo $_REQUEST['modid'];?>&amp;frmid=<?php echo $_REQUEST['frmid'];?>">Add New</a>
</p>

<script>
//$(document).ready(function(){
 //   $('table tr').click(function(){
    //    window.location = $(this).attr('href');
    //    return false;
   // });
//});


</script>
<?php if(isset($_SESSION['success_msg']))
{ ?>
	<script> alert("<?php echo ($_SESSION['success_msg']);?>");</script>
<?php 
unset($_SESSION['success_msg']);
}

?>



