<script src="assets/js/king-table.js"></script>
<div class="content">	
	<div class="main-content">
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> View Loan Applicantions</h3>
			</div>
			<div class="widget-content">
				<table id="datatable-data-export" class="table table-sorting table-striped table-hover table-bordered datatable">
					<thead>
						<tr>
							<th>[]</th>
							<th>Account No.</th>
							<th>Name</th>
							<th>Date</th>
							<th>Loan amt</th>
							<th>Tenor</th>	
							<th>Total</th>		
							<th>Paid</th>	
							<th>Balance</th>			
							<th>Action</th>					
						</tr>
					</thead>
					<tbody>
						<?php  $i=1;?>
						<?php $__currentLoopData = $data['LoanApplicantRecords']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $LoanApplicantRec): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
						<tr>
							<td> <?php echo $i++;?></td>
							<td><b><font color="green"><?php echo e($LoanApplicantRec->lacc_no); ?></font></b><br>
							(<?php echo e($LoanApplicantRec->br_name); ?>)
							</td>
							<td><?php echo e($LoanApplicantRec->lacc_custname); ?> <br>
							<b>Mob - </b> <?php
$resaddr = unserialize($LoanApplicantRec->lacc_resaddr);
echo $resaddr[5];
							?></td>
							<td><?php echo date("d-m-Y",strtotime($LoanApplicantRec->lacc_opendt)); ?></td>  
							<td> <?php echo e($LoanApplicantRec->lacc_loanamt); ?></td> 
							<td><?php echo e($LoanApplicantRec->lacc_tenor); ?> mon</td> 
							<td> <?php echo e($LoanApplicantRec->totalamt); ?></td>
							<td><font color="green"> <?php echo e($LoanApplicantRec->paidamt); ?></font></td>
							<td> <?php echo $bal =  $LoanApplicantRec->totalamt - $LoanApplicantRec->paidamt; ?></td>
							<td>

	<?php
	if($bal > 0)
	{
	?>
		<button class="btn btn-info btn-xs" onclick="EditloanApp(<?php echo e($LoanApplicantRec->lacc_id); ?>,'<?php echo e($LoanApplicantRec->lacc_no); ?>')" ><span class="fa fa-edit"></span></button> | <button class="btn btn-info btn-xs" onclick="LoadLoanApplication(<?php echo e($LoanApplicantRec->lacc_id); ?>,'<?php echo e($LoanApplicantRec->lacc_no); ?>')" ><span class="fa fa-eye"></span></button>
	<?php
	}
	else
	{
	?>
		<button class="btn btn-success btn-xs" onclick="EditloanApp(<?php echo e($LoanApplicantRec->lacc_id); ?>,'<?php echo e($LoanApplicantRec->lacc_no); ?>')" data-toggle="tooltip"  title="Edit Profile"><span class="fa fa-edit"></span></button> | <button class="btn btn-success btn-xs" onclick="LoadLoanApplication(<?php echo e($LoanApplicantRec->lacc_id); ?>,'<?php echo e($LoanApplicantRec->lacc_no); ?>')"  ><span class="fa fa-eye"></span> </button>
	<?php
	}
	?>
							</td>  
						</tr>
						<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>	
					</tbody>
				</table>
			</div>
		</div>
		<!-- END DATA EXPORT -->
		
	</div>
</div>
<!-- /main -->
<script>
	$('.createMod').click(function(e)
	{   
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	function loadloanrecord(id)
	{
		$.ajax({
			url: 'loadcreateloanapplication',
			type: 'GET',
			data:'&lacc_id='+id,
			success: function(data)
			{
				$('.content').html(data);
				//$('.loadcreateloanapplication').html(data);
				//$('#sideMenu').load('loadcreateloanapplication');
			}
		});
	}
	
	$('.edit').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href')); 
	});
	
	function DeleteloanApp(a)
	{
		$.confirm({
			title: 'Confirm!',
			content: 'Are you confirm Delete!',
			buttons: {
				confirm: function () {
					sureDeleteloanApp(a);
				},
				cancel: function () {
					$.alert('Canceled!');
				}
				
			}
		});
	}
	
	function sureDeleteloanApp(a)
	{
		$.ajax({
			url: 'sureDeleteloanApp',
			type: 'GET',
			data:'&lacc_id='+a,
			success: function(data)
			{
				$.toast({
					heading: 'Delete!',
					text: 'Sucessfully Deleted.',
					showHideTransition: 'slide',
					icon: 'success',
					loaderBg: '#d9534f'
				});
				$('#sideMenu').load('/LoadViewLoanApplicantion');
			}
		});
	}
	
	function LoadLoanApplication(b,acno)
	{
		$.ajax({
			url: 'LoanAcPanel',
			type: 'GET',
			data:'&lacc_id='+b+'&acno='+acno,
			success: function(data)
			{
				$('#sideMenu').html(data);
			}
		});
	}
	
</script>
