<?php
include('../include/session.php');

$table_name = $_SESSION['db_prefix']."_loans_lines_temp";
$delete_query = "DELETE FROM $table_name WHERE  user_name = '".$_SESSION['username']."'   "; 
execsql($delete_query);

$line_num = $_GET['line_num'];
$i=0;
while ($i<$line_num) {
if (isset($_GET['line_checkbox'.$i])) {
$reference_date = $_GET['inputDate'.$i];	
$reference = $_GET['reference_text'.$i];
$ref_no = $_GET['ref_no_text'.$i];
$amount = $_GET['amount_text'.$i];

$reference_date = date("Y-m-d", strtotime($reference_date ));
if(isset($_GET['line_checkbox'.$i]) ) {
$table_name = $_SESSION['db_prefix']."_loans_lines_temp";
$loans_query = "INSERT INTO $table_name (loans_id, reference_date, reference, reference_no,  amount_debit, user_name) VALUES ('".$_SESSION['loans_id']."', '".$reference_date."','".$reference."', '".$ref_no."', '".$amount."', '".$_SESSION['username']."' ) ";
execsql($loans_query);
}
}
$i++;
}
?>

<script language="javascript" type="text/javascript">
          window.location="loansReturnWizbase.php?p=3&s=&loans_id=<?php echo $_SESSION['loans_id']?>";
</script>

