<?php

/* $Revision: 1.20 $ */

$PageSecurity = 2;

include('includes/session.inc');

$title = _('Issue');

include('includes/header.inc');

?>
<br />
<div align="center"><a href="issue.php">Issue Items</a></div><br />
<form method="post" action="" name="IntentSearchForm">	
	<table width="50%" border="0" align="center">
	  <tr>
		<td class="number">Indent No.</td>
		<td width="30%"><input type="text" name="search_indent" /></td>
		<td><input type="submit" name="submit" value="Search Indent" /></td>
	  </tr>
	</table>	
</form><br />
<table width="100%" border="0">
  <tr>
    <th>Indent No.</th>
    <th>Indent Date</th>
    <th>Options</th>
  </tr>
<?php
if(isset($_SESSION['search_indent']) or isset($_POST['search_indent'])){
	$_SESSION['indent_id'] = $_POST['search_indent'];
	if(!empty($_SESSION['indent_id'])){
		$SQL='SELECT * FROM issue WHERE indent_id="'.$_SESSION['indent_id'].'"';
	}else{
		$SQL='SELECT * FROM issue';
	}
	//echo $SQL;
	$result=DB_query($SQL, $db);
?>

<?php 
if(DB_num_rows($result)>0){
	while($myrow=DB_fetch_array($result)) { ?>
	  <tr>
		<td><?=$myrow['indent_id'];?></td>
		<td><?=date('d-m-Y',strtotime($myrow['date_added']));?></td>
		<td>
		<?php
		$chkSql = "select count(*) as `totCount` from indent_items where indent_id = $myrow[indent_id] and issue_status = 'pending'";
$chkresult=DB_query($chkSql, $db);
$chkrow=DB_fetch_array($chkresult);
if($chkrow['totCount']>0){
	?>
	<a href="issue.php?indent_id=<?=$myrow['indent_id'];?>&issue_id=<?=$myrow['issue_id'];?>">Issue Items</a>
<?php } ?>
		&nbsp;<a href="issue_PDFIssue.php?indentno=<?=$myrow['indent_id'];?>&issue_id=<?=$myrow['issue_id'];?>" target="_blank">Print</a>
		</td>
	  </tr>
 <?php } 
}?>
</table>
<?php } ?>