<?php 
unset($_SESSION['list']);
if($_REQUEST['action']=='delete' && !empty($_REQUEST['pre']))
{
	if($s->DeleteRecord('pms_sub_preparation_child',"parentid=".$_REQUEST['pre']) && $s->DeleteRecord('pms_sub_preparation',"id=".$_REQUEST['pre']))
	{
	$_SESSION['success_msg']="Delete Successfully";	
	$s->pageLocation("index.php?route=PMS/Transcations/work_order_preparation_index".$rurl);
	}
}

if($_REQUEST['search']!='')
{
	$filter = array();
	if(isset($_REQUEST['contractor']) && $_REQUEST['contractor'] != '')
	$filter[]="sub_preparation.contractor='".$_REQUEST['contractor']."'";
	if(isset($_REQUEST['project']) && $_REQUEST['project'] != '')
	$filter[]="sub_preparation.project like '%".$_POST['project']."%'";
	$filter1 = implode("and ",$filter); 
	if($filter1!='')
	{
	$sql="select * from pms_sub_preparation where $filter1 ";
	}
	else
	{
	$masg="No Record Found.";
	}
}
else
{
	 $sql = "SELECT * FROM pms_sub_preparation ";
}
if($_REQUEST['reset']!='')
{
unset($_REQUEST['project']);
unset($_REQUEST['contractor']);
}
?>
<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
	<script src="js1/jquery-1.7.2.js"></script>
	<script src="js1/jquery.ui.widget.js"></script>
	<script src="js1/jquery.ui.tabs.js"></script>
<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
	</script>
<!--<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>-->
<div class="tender_main_page">
<h1> Work Order Preparation</h1>
<a href="index.php?route=PMS/Transcations/work_order_preparation&action=add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>">Add New</a>
<br /><br />
<form action="" method="post">
<table width="75%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td class="tabledata">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 class="tabledata">Project</td>
    <td><input type="text" name="project" value="<?php echo $_REQUEST['project']?>"/></td>
    <td><input type="submit" name="search" value="Search" /><input type="submit" value="Reset" name="reset" /></td>
  </tr>
</table>
</form>

<div style="width:800px; overflow:auto; margin-left:auto; margin-right:auto;">
<div id="tableContainer" class="tableContainer">
<table class="scrollTable" width="100%" border="1" cellpadding="0" cellspacing="3">

	<tr class="row1">
		<td class="tabledata">Project</td>
		<td class="tabledata">Contractor Category</a></td>
		<td class="tabledata">Contractor</td>
		<td class="tabledata">Work Order No.</td>
		<td class="tabledata">Delete</td>
		
	</tr>
<?php 
	$rpp = 10; // results per page
	$adjacents = 5;
	$page = intval($_GET["page"]);
	if($page<=0) $page = 1;
	$reload ="index.php?route=PMS/Transcations/work_order_preparation_index".$rurl;
	// select appropriate results from DB:
	//$sql = "SELECT * FROM sub_preparation";
	$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 class="tabledata1">
		<!--<a href="index.php?route=PMS/Transcations/work_order_preparation<?php echo $rurl;?>" style="color:#000000">
		<a href="index.php?route=PMS/Transcations/work_order_preparation_aproval<?php echo $rurl;?>&action=edit&pre=<?php echo $id; ?>" style="color:#000000">-->
		
		<a href="index.php?route=PMS/Transcations/work_order_preparation_aproval&modid=<?php echo $_REQUEST['modid'];?>&amp;frmid=<?php echo $_REQUEST['frmid'];?>&action=edit&id=<?php echo $row['id']; ?>" style="color:#000000; text-decoration: none;">
		
		
		<?php 
		$Row1=DB_fetch_array(DB_query("Select * from locations where loccode='".$project."'",$db)); 
		echo $Row1['locationname'];
		 ?>
	      			</a></td>
		<td class="tabledata1">
		<!--<a href="index.php?route=PMS/Transcations/work_order_preparation<?php echo $rurl;?>" style="color:#000000">-->
		
		 <a href="index.php?route=PMS/Transcations/work_order_preparation_aproval<?php echo $rurl;?>&action=edit&pre=<?php echo $id; ?>" style="color:#000000">
		<?php
$rowrec=DB_fetch_array(DB_query("select * from tbl_subcontractor_contractor_category where id='".$contractor_category."'",$db)); 
	echo $rowrec['Contractor_category_name'];
		 ?></a></td>
		<td class="tabledata1">
		<a href="index.php?route=PMS/Transcations/work_order_preparation_aproval<?php echo $rurl;?>&action=edit&pre=<?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 class="tabledata1">
		<a href="index.php?route=PMS/Transcations/work_order_preparation_aproval<?php echo $rurl;?>&action=edit&pre=<?php echo $id; ?>" style="color:#000000"><?php echo $work_order_no; ?></a></td>
	
		<td class="tabledata1"><a href="index.php?route=PMS/Transcations/work_order_preparation_index<?php echo $rurl;?>&action=delete&pre=<?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>

</div>


<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']);
}

?>



