<?php include('includes/fun-php.php')?>

  <h2>Loan Details</h2>
    <?php
	
	
		$GetProcess = "Select * from loan_management   where emp_id='".$_SESSION['mst_www_userid']."'   ";		 	   
       $ResultProcess_SalData = DB_query($GetProcess,$db);
	  
	  ?>
	  
	  <table width="50%" border="0"> 
		  
	  <?php 
	 $t=0;
   	   while($RowData = DB_fetch_array($ResultProcess_SalData))
	   {
	   $dd=explode('-',$RowData['loan_date']);
	   ?>
	    <tr>
			<td>Emp code:</td><td> <?php echo $RowData['emp_code']?></td></tr>
			<tr><td>Emp Name:</td><td> <?php echo $RowData['emp_name']?></td>
			<tr><td>No of Installment:</td><td><?php echo $RowData['no_of_installment']?></td> 
			<tr><td>Start month:</td><td><?php echo GetMonth ($RowData['loan_deduction_month'])?></td>  
			<tr><td>Loan month:</td><td><?php echo ConvertSQLDate($RowData['loan_date'])?></td>  
			<tr><td>Loan Amount:</td><td><?php echo ($RowData['loan_amount']);
			$t=$RowData['loan_amount'];
			?></td>  
		  </tr>
		  <tr><td>Loan Balance Amount:</td><td><?php echo ($RowData['loan_balance'])?></td>  
		  </tr>
 	   <?php 
	   }
	  ?>
	   <tr>
		    <td colspan="2"><table width="100%" border="0">
  <tr bgcolor="#999999">
    <td>Month</td>
    <td>Amount</td>  <td>Installment Amount</td>
			 <td>Balance Amount</td>
    <td>Status</td>
    <td>Paid Status </td>
  </tr>
  
	  <?php	    
	  $GetDetail_Process = "Select * from loan_management A , emp_loan_details B where B.emp_id='".$_SESSION['mst_www_userid']."' and A.id =B.loanid  ";		 	   
       $ResultDetailProcess = DB_query($GetDetail_Process,$db);
	   // echo DB_num_rows($ResultData);
	       $loan_remaingbal=0;
		   
   	   while($RowDetailData = DB_fetch_array($ResultDetailProcess))
	   {
	   ?>
  <tr>
	<td><?php echo ConvertSQLDate($RowDetailData['loan_paid_date']); ?>&nbsp;</td>
	<td><?php  		echo  $t ;		 ?></td>
	
	<td><?php 
	if($t< $RowDetailData['loan_amount'])
	echo  $RowDetailData['loan_amount']-$t;
	else
 	echo $RowDetailData['loan_amount'];
	
	
	 ?>&nbsp;</td>
	<td><?php    $loan_remaingbal= $t-$RowDetailData['loan_amount'];;
		   echo ($loan_remaingbal>0?$loan_remaingbal:0);
			 $t=  $loan_remaingbal;
			 
			 
	 ?>&nbsp;</td>
	<td><?php echo $RowDetailData['loan_status']; ?>&nbsp;</td>
	<td><?php echo $RowDetailData['paid_status']; ?>&nbsp;</td>
  </tr>
  <?php } ?>
</table></td>
		    
	    </tr>
	  
	   </table>
 
