<script src="assets/js/king-table.js"></script>
<!-- MAIN CONTENT WRAPPER -->

<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> Update Loan Processing Fee</h3>
			</div>
			<div class="widget-content">
				<table class="table table-sorting table-striped table-hover table-bordered datatable">
					<thead>
						<tr>
							<th>Amount from</th>
							<th>Amount to</th>
							<th>Amount</th>
							<th>Status</th>	
							<th></th>	
						</tr>
					</thead>
					<tbody>
						<?php $i=1;?>
						<?php $__currentLoopData = $data['loanprocessingfee']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
						<tr class="abc<?Php echo $i;?>">
							<?Php  $i++;?>
							<td><input type='text' class="form-control" name='lpf_famt<?Php echo $i;?>1' id='lpf_famt<?Php echo $i;?>1' value="<?php echo e($lp->lpf_famt); ?>" ></td>
							<td><input type='text' class="form-control" name='lpf_famt<?Php echo $i;?>2' id='lpf_famt<?Php echo $i;?>2' value="<?php echo e($lp->lpf_tamt); ?>" ></td>
							<td>
								<div class="col-md-6">
									<input type='text' class="form-control" name='lpf_famt<?Php echo $i;?>3' id='lpf_famt<?Php echo $i;?>3' value="<?php echo e($lp->lpf_amt); ?>" >
								</div>
								<div class="col-md-6">
									
									<div class="form-group">
										<label class="control-inline fancy-radio custom-color-green"><input type="radio" name="lacc_type<?Php echo $i;?>4" id="lacc_type<?Php echo $i;?>4" value="Amount" <?php if (isset($lp->lpf_amttype) && $lp->lpf_amttype=="Amount") echo "checked"; ?>><span><i></i>Amount</span></label>
										<label class="control-inline fancy-radio custom-color-green"><input type="radio" name="lacc_type<?Php echo $i;?>4" id="lacc_type<?Php echo $i;?>4" value="Percentage"  <?php if (isset($lp->lpf_amttype) && $lp->lpf_amttype=="Percentage") echo "checked"; ?>><span><i></i>Percentage</span></label><br>
										
									</div>		
								</div>
							</td>
							<td>
								<div class="control-inline onoffswitch">
									<input type="checkbox" name="onoffswitch<?Php echo $i;?>5" class="onoffswitch-checkbox" id="switch<?Php echo $i;?>5" <?php if (isset($lp->lpf_status) && $lp->lpf_status=="Active") echo "checked"; ?> >
									<label class="onoffswitch-label" for="switch<?Php echo $i;?>5">
										<span class="onoffswitch-inner"></span>
										<span class="onoffswitch-switch"></span>
									</label>
								</div>
								
							</td>
							<td>
								<div class="loadDelete<?Php echo $i;?>">
									<button class="btn btn-info btn-xs" onclick="updateloan(<?php echo e($lp->lpf_id); ?>,<?php echo e($i); ?>)">Update</button>
								</div>
							</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'));
	});
	
	
	$('.edit').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href')); 
	});
	
	function Delete(id)
	{
		//alert(id);
		k = 0;
		if(k == 0)
		{
			k++;
			$.ajax({
				type: "GET",
				url:"/deluser",
				dataType: "json",
				data: {
					'_token': $('input[name=_token]').val(),
					'id': id
				},
				success: function (sdata) {
					if(sdata.status == 1)
					{
						//printSuccessMsg(sdata.message);
						$('#sideMenu').load('viewuser');
					}
					else
					{
						//printErrorMsg(sdata.message)
					}
				}
			});
		}
		
	}	
	
	function updateloan(loanid,Count)
	{
		$('.loadDelete'+Count).html('<button type="button" class="btn btn-primary btn-xs"><i class="fa fa-spinner fa-spin"></i> Loading.</button>');
		subb1=$("#lpf_famt"+Count+"1").val();
		subb2=$("#lpf_famt"+Count+"2").val();
		subb3=$("#lpf_famt"+Count+"3").val();
		subb4 =$("input[name='lacc_type"+Count+"4']:checked").val();
		subb5=$("#switch"+Count+"5").prop('checked');
		$.ajax({
			type: "GET",
			url:"/updateMasterLoan",
			data:"&loanid="+loanid+"&subb1="+subb1+"&subb2="+subb2+"&subb3="+subb3+"&subb4="+subb4+"&subb5="+subb5,
			success: function (data) 
			{
				$('.loadDelete'+Count).html('<button type="button" class="btn btn-success btn-xs"><i class="fa fa-check-circle"></i> Saved</button>');
				$('#sideMenu').load('loanprocessingfeesettings');
			}
		});
	}
</script>				