<?php
//************************DELETE THE DATA***********************START HERE************************************************/

if($_REQUEST['action']=='delete' && !empty($_REQUEST['id']))
{
	if($s->DeleteRecord('sub_ra_bill_preparation',"id='".$_REQUEST['id']."'"))// QUERY FOR DELETE RECORD
	{
	$_SESSION['success_msg']="Delete Successfully";	
	$s->pageLocation("index.php?route=SubContractors/RaBill/ra_bill_verification".$rurl);// FOR PAGE REDIRECTION
	}
}



//************************DELETE THE DATA***********************START HERE************************************************/






//************************SEARCHING***********************START HERE******************************************************/

if($_REQUEST['Search'])
{
	if($_REQUEST['project']!='')
	{
	$filter[]="project='".$_REQUEST['project']."'";
	}
	if($_REQUEST['bill_no']!='')
	{
	$filter[]="bill_no='".$_REQUEST['bill_no']."'";
	}
	if($filter!='')
	{
	$filter1=implode(" and ",$filter);
	$sql="select * from sub_ra_bill_preparation where $filter1";//QUERY WITH FILTER DATA
	}
	
}
else
{
$sql="select * from sub_ra_bill_preparation";//QUERY WITHOUT FILTER DATA
}
//************************SEARCHING***********************END HERE************************************************/

?>

<!------------------------------AJAX FILES-------------------START HERE-------------------------------------------->


<script type="text/javascript" language="javascript">
function ger_rabill_no(str)
{
	//alert(str);
	if(str=='')
	{
	document.getElementById("project").innerHTML='';
	return false;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if(xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	var data=xmlhttp.responseText;
	document.getElementById("BILLNO").innerHTML=data;
	}
	}
	xmlhttp.open("GET","Get_rabillno.php?pro="+str,true);
	xmlhttp.send();
}
</script>

<!------------------------------AJAX FILES-------------------END HERE----------------------------------------------->




<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
<div class="tender_main_page">
<h3> RA BILL Verification</h3>
<form action="" method="post">
<table width="100%" border="1" cellpadding="3" >
  <tr>
    <td class="tabledata">Criteria</td>
    <td width="17%"><select name="project" id="project" style="width:150px;" onchange="ger_rabill_no(this.value)">
		<option value="">Select </option>
		<?php
		$proj=DB_query("select * from locations",$db);
		while($row=DB_fetch_array($proj))
		{
		$sel='';
		if($_REQUEST['project']==$row['loccode'])
		$sel='selected';
		?>
		<option value="<?php echo $row['loccode']; ?>"<? echo $sel; ?>><?php echo $row['locationname']; ?></option>
		<?php } ?>
	</select>
	<td class="tabledata">Bill No</td>
    <td width="32%" id="BILLNO">
   <select name="bill_no" id="bill_no" style="width:150px;">
		<option value="">Select</option>
		<?php
		$bill=DB_query("select * from sub_ra_bill_preparation",$db);
		while($rowbill=DB_fetch_array($bill))
		{
		$sel1='';
		if($_REQUEST['bill_no']==$rowbill['bill_no'])
		$sel1='selected';
		?>
		<option value="<?php echo $rowbill['bill_no']; ?>"<? echo $sel1; ?>><?php echo $rowbill['bill_no']; ?></option>
		<?php } ?>
	</select>
	</td>
	<td width="29%"><input type="submit" name="Search" value="Search" /></td>
  </tr>
</table>
</form>
<br /><br /><br />
	<div style="overflow: auto; width:810px;">	
	<table width="100%" border="1" cellpadding="3" >
      <tr>
        <td class="tabledata">Project</strong></td>
        <td class="tabledata">Block</strong></td>
        <td class="tabledata">Contractor</strong></a></td>
        <td class="tabledata">Work Order</strong></td>
        <td class="tabledata">Bill No.</strong></td>
        <td class="tabledata">Bill Ref No</strong></td>
        <td class="tabledata">Ammount</strong></td>
		<td class="tabledata">Verify Status</strong></td>
		<!--<td class="tabledata">Delete</strong></td>-->
       
      </tr>
	  <? $sql1=DB_query($sql,$db);
	//  echo $test=DB_num_rows($sql1);
	  	 while($getdata=DB_fetch_array($sql1)){
		 if($getdata['verify_status']=='Pending'){
	   ?>
      <tr>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $s->GetFieldValue('locations',"loccode='".$getdata['project']."'",'locationname'); ?></a></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $s->GetFieldValue('sub_block_master',"id='".$getdata['block']."'",'block_name'); ?></a></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $s->GetFieldValue('sub_contractor_definition',"id='".$getdata['contractor']."'",'contractor_name'); ?></a></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $s->GetFieldValue('sub_preparation',"id='".$getdata['work_order_no']."'",'work_order_no'); ?></a></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $getdata['bill_no']; ?></a></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=view&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $getdata['bill_ref_no']; ?></a></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $getdata['net_amt']; ?></a></td>
		<td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=verify&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $getdata['verify_status']; ?></a></td>
		<!--<td><a href="index.php?route=SubContractors/RaBill/ra_bill_verification<?php echo $rurl;?>&action=delete&id=<?php echo $getdata['id']; ?>" onclick="return confirm('Are you sure you want to delete?')" style="color:#000000">Delete</a></td>-->
      </tr>
	  <? } else { ?>
	  
	  
	  <tr>
        <td><? echo $s->GetFieldValue('locations',"loccode='".$getdata['project']."'",'locationname'); ?></td>
        <td><? echo $s->GetFieldValue('sub_block_master',"id='".$getdata['block']."'",'block_name'); ?></td>
        <td><? echo $s->GetFieldValue('sub_contractor_definition',"id='".$getdata['contractor']."'",'contractor_name'); ?></td>
        <td><? echo $s->GetFieldValue('sub_preparation',"id='".$getdata['work_order_no']."'",'work_order_no'); ?></td>
        <td><? echo $getdata['bill_no']; ?></td>
        <td><a href="index.php?route=SubContractors/RaBill/ra_bill_verify<?php echo $rurl;?>&action=view&id=<?php echo $getdata['id']; ?>" style="color:#000000"><? echo $getdata['bill_ref_no']; ?></a></td>
        <td><? echo $getdata['net_amt']; ?></td>
		<td><? echo $getdata['verify_status']; ?></td>
		<!--<td><a href="index.php?route=SubContractors/RaBill/ra_bill_verification<?php echo $rurl;?>&action=delete&id=<?php echo $getdata['id']; ?>" onclick="return confirm('Are you sure you want to delete?')" style="color:#000000">Delete</a></td>-->
      </tr>
	  <?php } } ?>
    </table>
	<br /><br />
    </div>
    <div align="centre"><input type="button" name="Print" value="Print" onclick="popup('filename',700,400)"><input type="submit" name="Close" value="Close"></div>
 </div>     


