<?php
/* $Revision: 1.73 $ */
$PageSecurity = 11;
include('includes/session.inc');
$title = _('Show PC Opening');
include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');

if(isset($_GET['action']) && $_GET['action']=='remRec'){
	$sql = "DELETE FROM pcopening WHERE id='".$_GET['pc_no']."'";
	$res = DB_query($sql,$db,$ErrMsg,$DbgMsg);
	prnMsg(_('PC Opning') .  _('Record') . ' ' . _('has been deleted') ,'success');
}
?>
<p><a href="index.php">Main Menu>></a></p>
<link rel="stylesheet" href="css/jquery.ui.all.css" />
<script src="js/jquery-1.5.1.js"></script>
<script src="ui/jquery.ui.core.js"></script>
<script src="ui/jquery.ui.widget.js"></script>


<script>
$(function() {
$(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' ,changeMonth: true,
		changeYear: true,
		yearRange: '-80:+20'});
});
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function(){


    $(".slidingDiv").hide();
	$(".show_hide").show();
	
	$('.show_hide').click(function(){
	$(".slidingDiv").slideToggle();
	});

});

</script>
<style>

body{
font-family:Verdana, Geneva, sans-serif;
font-size:14px;

}

.slidingDiv {
	height:100px;
	/*background-color: #FFFFFF;*/
	padding:10px;
	margin-top:10px;
    border-bottom:2px solid #666666;
}

.show_hide {
	display:none;
}


</style>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php	echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title; ?>
	<?php echo '<p class="page_title_text"><br><br>&nbsp;&nbsp;<a href="' . $rootpath . '/PC_Opening.php?' .SID . '&NewOrder=Yes">' . _('Add PC Opening') . '</a>'; ?>
	</td>
  </tr>

 	<tr>
    	<td><div align="center"><a href="#" class="show_hide">Search</a></div>
	</td>
 
    <tr>
    <td><div class="slidingDiv"><div align="center">
	<form action="" method="post">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="9%">&nbsp;</td>
    <td width="12%">&nbsp;</td>
    <td width="9%">PC Code:</td>
    <td width="12%"><input name="code" type="text" id="code" size="10" /></td>
    <td width="11%">&nbsp;PC Name:</td>
    <td width="19%"><input name="name" type="text" id="name" size="30" /></td>
    <td width="17%"><input type="submit" name="Submit" value="Submit" /></td>
    <td width="11%">&nbsp;</td>
  </tr>
</table>
</form>
</div></div>
	</td>
  </tr>
  <tr> 
    <td align="center"><table width="100%" cellpadding="0" cellspacing="0" style="margin-top:20px;">
<?php	
		
		if(isset($_POST['Submit']))
			{
			$filter = array();
			$SQL = "select id, pc_code, pc_name, short_name, category, type from pcopening ";
			if(isset($_POST['code']) && $_POST['code'] != '')
			$filter[]="pc_code like '%".$_POST['code']."%' ";
			if(isset($_POST['name']) && $_POST['name'] != '')
			$filter[]="pc_name like '%".$_POST['name']."%' ";
			if($filter != '')
			{
				$SQL = $SQL." where ".implode(" and ",$filter);
			}
			//echo $SQL;
			}
			else
			{
				 $SQL="SELECT id, pc_code, pc_name, short_name, category, type from pcopening ORDER BY id ASC";
		    }
		 
		 $PC_OpeningResult = DB_query($SQL,$db);
		if (isset($PC_OpeningResult)) {
		echo '<table cellpadding="3" cellspacing="1" colspan="7" BORDER="0" width="90%" class="inborder" style="background:#dce6f2;"';
		$TableHeader = 	'<tr class="headingtable"><th>' . _('PC Code') . '</th>
				<th>' . _('PC Name') . '</th>
				<th>' . _('Short Name') . '</th>
				<th>' . _('Category') . '</th>
				<th>' . _('Type') . '</th>
				<th>' . _('Edit') . '</th>
				<th>' . _('Delete') . '</th>
				</tr>';
		echo $TableHeader;
		$j = 1;
		$k=0; //row colour counter
	   if(DB_num_rows($PC_OpeningResult)>0)
		 {
		while ($res=DB_fetch_array($PC_OpeningResult)) {
			if ($k==1){
				echo '<tr class="EvenTableRows">';
				$k=0;
			} else {
				echo '<tr class="OddTableRows">';
				$k=1;
			}
			printf("<td>%s</td>
			<td>%s</td>
		<td>%s</td>
		<td>%s</td>
		<td>%s</td>
		<td><a href='%sPC_Opening.php?action=editRec&pc_no=%s'>" . _('Edit') . "</td>
		<td><a href='%saction=remRec&pc_no=%s&delete=yes' onclick=\"return confirm('" . _('Are you sure you wish to delete This PC Opning Record') . "');\">" . _('Delete') . "</td>
		</tr>",
		$res['pc_code'],
		$res['pc_name'],
		$res['short_name'],
		$res['category'],
		$res['type'],
		SID, $res['id'],
		$_SERVER['PHP_SELF'] . '?' . SID, $res['id']);
			$j++;
			If ($j == 12){
				$j=1;
				echo $TableHeader;
			}
	//end of page full new headings if
		}
	}else
	{
	 echo '<td><div align="center"><font color="#FF0000"> Record Not Found </font></div></td>';
	}
	//end of while loop
	
		echo '</table>';
	}	
		
?>
</table></td>
  </tr>
</table>


