<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 Pending 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>SL.No.</th>
							<th>Account No.</th>
							<th>Name</th>
							<th>Contact No.</th>
							<th>Branch</th>
							<th>Loan amt</th>
							<th>Tenor</th>		
							<th>Interest</th>	
							<th>Delay</th>		
							<th>Action</th>					
						</tr>
					</thead>
					<tbody>
						<?php  $i=1;?>
						@foreach($data['LoanApplicantRecords'] as $LoanApplicantRec)
						<?php
						$resaddr = unserialize($LoanApplicantRec->lacc_resaddr);
						?>
						<tr>
							<td> <?php echo $i++;?></td>
							<td><a style="cursor: pointer;" onclick="loadloanrecord(<?php echo $LoanApplicantRec->lacc_id; ?>)"><i class="fa fa-plus-square" aria-hidden="true"></i> <b>{{$LoanApplicantRec->lacc_no}}</b></a></td>
							<td>{{$LoanApplicantRec->lacc_custname}} </td>
							<td><?php echo $resaddr[5]; ?></td>
							<td>{{$LoanApplicantRec->br_name }}</td>
							<td> {{round($LoanApplicantRec->lacc_loanamt) }}</td>  
							<td>{{$LoanApplicantRec->lacc_tenor }} monts</td>  
							<td>{{$LoanApplicantRec->lacc_intrate }}%</td>  
							<td>{{$LoanApplicantRec->dpmt_charge }}%</td>  
							<td>
								<button class="btn btn-info btn-xs" onclick="EditloanApp({{$LoanApplicantRec->lacc_id}},'{{$LoanApplicantRec->lacc_no}}')"><span class="fa fa-edit"></span></button>
								<button class="btn btn-danger btn-xs" onclick="DeleteloanApp({{$LoanApplicantRec->lacc_id}})"><span class="fa fa-trash"></span></button>
							</td>  
						</tr>
						@endforeach	
					</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 EditloanApp(b,acno)
	{
		$.ajax({
			url: 'EditloanApp',
			type: 'GET',
			data:'&lacc_id='+b+'&acno='+acno,
			success: function(data)
			{
				$('#sideMenu').html(data);
			}
		});
	}
</script>