<script language="javascript" src="../jscript/calendar.js"></script>
 
<?php
$table_name = $_SESSION['db_prefix']."_loans";
$loans_query = "SELECT * FROM $table_name WHERE emp_id = '".$_SESSION['emp_id']."' AND ((amount-returned_amount)>0) ";
$loans_result = mySQL_query($loans_query);
$loans_num = mysql_num_rows($loans_result);
   
?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link href="../css/wizard.css" rel="stylesheet" type="text/css">
<link href="../css/wait.css" rel="stylesheet" type="text/css">
<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 
</head>
<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">


<form id="feedbackform" method="get" action="loansReturnWizbase.php">
<div class="wizard_page_middle_frame">
<div class="wizard_frame">
Select outstanding loan:<br>

<table width="600" id="table_resume_wizard">
<thead>
  <tr>
    <td width="61">No</td>
    <td width="77">Date</td>
    <td width="136">Issued by</td>
    <td width="109">Reason</td>
    <td width="95">Amount</td>
    <td width="94">Balance</td>
  </tr>
</thead>
<?php
$i=0;
while ($i<$loans_num) {
	$a0 = mysql_result($loans_result, $i, "loans_id");
	$a1 = mysql_result($loans_result, $i, "issue_date");
	$a2 = mysql_result($loans_result, $i, "issued_by");
	$a3 = mysql_result($loans_result, $i, "reason");
	$a4 = mysql_result($loans_result, $i, "amount");
	$a6 = $a4 - mysql_result($loans_result, $i, "returned_amount");
	
?>	
  <tr>
    <td><a href="loansReturnWizbase.php?p=3&s=2&loans_id=<?php echo $a0 ?>&outstanding=<?php echo $a6?>" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" onMouseover="ddrivetip('Click to select', 150)"; onMouseout="hideddrivetip()"><?php echo $a0 ?></a></td>
    <td><?php echo date("d-m-Y", strtotime($a1)) ?></td>
    <td><?php echo $a2 ?></td>
    <td><?php echo $a3 ?></td>
    <td align="right"><?php echo number_format($a4, 2, '.', ',') ?></td>
    <td align="right"><?php echo number_format($a6, 2, '.', ',') ?></td>
  </tr>
<?php
$i++;
}
?>
</table>

</div>
<div class="wizard_spacer_frame" style="height:70px;"></div>
<div class="wizard_frame">            
              <table width="675" height="50" align="center" id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); MM_goToURL('parent','loansReturnWizbase.php?s=&p=1'); return document.MM_returnValue; "/></td>
                  <td width="115">&nbsp;</td>
                  <td width="99">
                    <input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                  </td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="cancel_confirmation(1, '../hr_module/hr_main.php?date=0');" value="Cancel" /></td>
                  <td width="110" align="right"><label class="label_small">Click loan no<br>
                    to continue</label></td>
                </tr>
              </table>

<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("amount_text","req","- issued amount.");
  frmvalidator.addValidation("use_select","req","- issued for.");
  </script>
</div>
</div>
</form>
</body>