<style>
.paymentmodal {
    width: 75%;
    margin: 30px auto;
}
</style>
<script src="assets/js/king-table.js"></script>
<script src="assets/js/popper.min.js"></script>
<?php
$LoanTotalPaid=0;
?>
<!-- MAIN CONTENT WRAPPER -->
<div class="content"  id="printableArea">	
	<div class="main-content">
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> View Loan Account detail</h3>
			</div>
			<div class="widget-content">
			<form id="frmLoanApplication" name="frmLoanApplication" data-parsley-validate novalidate method="POST">
				<table  class="table table-striped table-bordered">
					<?php  $i=1;?>
					<?php $__currentLoopData = $data['LoanApplicantRecords']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $LoanApplicantRec): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<?php $lacc_id = $LoanApplicantRec->lacc_id; ?>
				<input type="hidden" name="lacc_id" id="lacc_id" value="<?php echo e($LoanApplicantRec->lacc_id); ?>">
				<input type="hidden" name="lacc_no" id="lacc_no" value="<?php echo e($LoanApplicantRec->lacc_no); ?>">
						<tr>
							<th>Application No.</th><td><b><?php echo $loanacc = $LoanApplicantRec->lacc_no; ?></b></td>	
							<th>Loan amount</th><td><b> <?php echo e($LoanApplicantRec->lacc_loanamt); ?></b></td>								
						</tr>						
						<tr>
							<th>Name</th><td><b><?php echo e($LoanApplicantRec->lacc_custname); ?></b></td>	
							<th>Tenor</th><td><b><?php echo e($LoanApplicantRec->lacc_tenor); ?> months</b></td>								
						</tr>
						<tr>
							<th>Branch</th><td><b><?php echo e($LoanApplicantRec->br_name); ?></b></td>	
							<th>Interest</th><td><b><?php echo e($LoanApplicantRec->lacc_intrate); ?>% (per year)</b></td>
						</tr>
						<tr>
							<th>Loan open date</th><td><b><?php echo date("Y-m-d"); ?></b></td>	
							<th>Paid Amount</th>
							<td><font color="green"><b> <?php echo $LoanTotalPaid = $data['LoanTotalPaid']; ?></b></font></td>
						</tr>		
					<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>	
				</table>
			</div>
		</div>
		<!-- END DATA EXPORT -->
		
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> Loan Installment detail </h3>
			</div>
			<div class="widget-content">
				<table class='table table-sorting table-striped table-hover table-bordered datatable'>
					<thead>
						<tr>
							<th>Dates</th>
							<th>Transaction type</th>
							<th>Particulars</th>
							<th>Credit</th>
							<th>Paid</th>		
							<th>Balance</th>		
						</tr>
					</thead>
					<tbody>
		<?php
		$balamt = 0;
		$datarec="";
		$LoanRpt  = $data['LoanRpt'];
		foreach($LoanRpt as $LoanApplicantRec)
		{
			if($LoanApplicantRec->ltr_status=="Cancelled")
			{
				$datarec .= "<tr style='text-decoration: line-through;'>";
			}
			else
			{
				$datarec .= "<tr>";
			}
					$datarec .= "<td>". date("d-m-Y",strtotime($LoanApplicantRec->ltr_transdt)) . "</td>";
					//#######Transaction Type Starts here #######
					$datarec .= "<td>";
					if($LoanApplicantRec->ltr_transtype=="Principle" || $LoanApplicantRec->ltr_transtype=="Interest" )
					{
					$datarec .= "<b style='color: blue;' >" . $LoanApplicantRec->ltr_transtype . "</b>";
					}
					if($LoanApplicantRec->ltr_transtype=="Cheque Bounce" || $LoanApplicantRec->ltr_transtype=="Case" || $LoanApplicantRec->ltr_transtype=="Delay payment" || $LoanApplicantRec->ltr_transtype=="Others")
					{
					$datarec .= "<b style='color: red;' >" . $LoanApplicantRec->ltr_transtype . "</b>";
					}
					if($LoanApplicantRec->ltr_transtype=="Payment")
					{
					$datarec .= "<b style='color: green;'>" . $LoanApplicantRec->ltr_transtype . "</b>";
					}
					$datarec .= "</td>";
					//#######Transaction Type Ends here #######
					//#######Transaction Note starts here #######
					$datarec .= "<td width='350'>";
					if($LoanApplicantRec->ltr_transtype=="Payment")
					{
					$datarec .= "<b>Bill No : </b>".$LoanApplicantRec->ltr_billno."<br>";
					}
					if($LoanApplicantRec->ltr_note != "")
					{
					$datarec .= "<b>Note:</b>".$LoanApplicantRec->ltr_note;
					}
						//###Cheque and Bank details starts here
						if($LoanApplicantRec->ltr_chqno != "")
						{
						$datarec .= "<br><b>Cheque:</b>".$LoanApplicantRec->ltr_chqno;
						}
						if($LoanApplicantRec->ltr_bank != "")
						{
						$datarec .= "<br><b>Bank detail:</b>".$LoanApplicantRec->ltr_bank;
						}
						//###Cheque and Bank details ends here
						if($LoanApplicantRec->ltr_status=="Cancelled")
						{
						$datarec .= "<br><button class='alert alert-danger'><b>Title:</b>". $LoanApplicantRec->ltr_cancellationtype ."<br><b>Note:</b>". $LoanApplicantRec->ltr_cancellationreason."</button>";
						}
					$datarec .= "</td>";
					//#######Transaction Note ends here #######
					if($LoanApplicantRec->ltr_transtype=="Principle" || $LoanApplicantRec->ltr_transtype=="Interest" || $LoanApplicantRec->ltr_transtype=="Cheque Bounce" || $LoanApplicantRec->ltr_transtype=="Case" || $LoanApplicantRec->ltr_transtype=="Delay payment" || $LoanApplicantRec->ltr_transtype=="Others")
					{
					$datarec .= "<td> $LoanApplicantRec->ltr_amt</td>";
					$balamt = $balamt + $LoanApplicantRec->ltr_amt;
					}
					else
					{
						$datarec .= "<td>0</td>";
					}
					if($LoanApplicantRec->ltr_transtype=="Payment")
					{
					$datarec .= "<td> $LoanApplicantRec->ltr_amt</td>";
					$balamt = $balamt - $LoanApplicantRec->ltr_amt;
					}
					else
					{
						$datarec .= "<td>0</td>";
					}
					$datarec .= "<td> $balamt</td>";
					$datarec .= "</tr>";
		}
		echo $datarec;
		?>
					</tbody>
					</table>
			</div>
		</div>

		<!-- END DATA EXPORT -->

		</form>					
	</div>
</div>

				<div class="widget">
					<div class="widget-header"><center> 
						<button class="btn btn-info btn-default"   id="btnPrint1" onclick="printDiv('printableArea')"><span class="fa fa-asterisk"></span> Print</button>
						<!--<input type="button" value="Print Div Contents" id="btnPrint" />-->
						</center>
					</div>
				</div>
<!-- /main -->

<script>
	$('.createMod').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	$('.edit').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href')); 
	});
</script>
<script>

function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

        $("#btnPrint").click(function(){
            var divContents = $("#printableArea").html();
            var printWindow = window.open('', '', 'height=400,width=800');
            printWindow.document.write('<html><head><title>NavChetana Transaction Report</title>');
            printWindow.document.write('<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css"><link href="assets/css/main.css" rel="stylesheet" type="text/css"><link href="assets/css/my-custom-styles.css" rel="stylesheet" type="text/css"><link href="css/jquery.toast.min.css" rel="stylesheet" type="text/css"><link rel="stylesheet" href="css/jquery-confirm.min.css"></head><body >');
            printWindow.document.write(divContents);
            printWindow.document.write('</body></html>');
            printWindow.document.close();
            printWindow.print();
        });
</script>
