<style>
.paymentmodal {
    width: 75%;
    margin: 30px auto;
}
</style>
<script src="assets/js/king-table.js"></script>
<script src="assets/js/popper.min.js"></script>
<div class="loadreport">
<?php
$LoanTotalPaid=0;
?>
<!-- MAIN CONTENT WRAPPER -->
<div class="content">	
	<div class="main-content">
		<!-- DATA EXPORT -->
<div id="divprint">		
		<div class="widget widget-table">
			<div class="widget-content">
				<center><h3><img src="img/navachethana-logo.png" >Navachethana Finance Company (R)</h3><br>
				<p>"Beauty Plaza" Building, Ground Floor, Balmatta Road, mangalore-575001<br>
				<b>Phone : 0824 - 4255640 Mobile No. 7760833500</b>
				</p></center>
				<hr> 

				<table  class="table table-striped table-bordered" border="1">
					<?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>Loan Account No.</th><td><b><?php echo $loanacc = $LoanApplicantRec->lacc_no; ?></b></td>	
							<th>Loan Account Date</th><td><b><?php echo  date("d-m-Y",strtotime($LoanApplicantRec->lacc_opendt)); ?></b></td>								
						</tr>						
						<tr>
							<th>Customer Name</th><td><b><?php echo e($LoanApplicantRec->lacc_custname); ?></b></td>	
					<th>EMI Start Date</th><td><b><?php 
//echo  date("d-m-Y",strtotime($LoanApplicantRec->lacc_opendt));
echo $effectiveDate = date('d-M-Y', strtotime("+1 month", strtotime($LoanApplicantRec->lacc_opendt)));
					?></b></td>								
						</tr>
						<tr>
							<th rowspan="3">Customer Address</th><td rowspan="3"><b><?php 
							$addr=unserialize($LoanApplicantRec->lacc_resaddr); 
							//print_r($addr);
							echo $addr[0]."<br>";
							echo $addr[1]."<br>";
							echo $addr[2]."<br>";
							echo $addr[3]."," . $addr[4]."<br>";
							?></b></td>	
							<th>EMI Close Date</th><td><b> <?php 
//echo  date("d-m-Y",strtotime($LoanApplicantRec->lacc_opendt));
echo $effectiveDate = date('d-M-Y', strtotime("+$LoanApplicantRec->lacc_tenor months", strtotime($LoanApplicantRec->lacc_opendt)));
					?></b></td>
						</tr>
						
						<tr>
							<th>Interest rate.</th><td><b><?php echo $loanacc = $LoanApplicantRec->lacc_intrate; ?>%</b></td>
						</tr>
						
						<tr>
							<th>Loan Tenure.</th><td><b><?php echo e($LoanApplicantRec->lacc_tenor); ?> months</b></td>
						</tr>
						
						<tr>
							<th>Mobile No.</th><td><b><?php echo $addr[5]; ?></b></td>
							<th>Monthly EMI.</th><td><b><?php 
							echo $data['monthlyEMI']; ?></b></td>
						</tr>
						<tr>
							<th>Tel.</th><td><b><?php echo $addr[6]; ?></b></td>
							<th>Outstanding Principal.</th><td><b><?php echo $LoanApplicantRec->lacc_loanamt - $data['LoanTotalPaid']; ?></b></td>
						</tr>
						<tr>
							<th>Branch</th><td><b><?php echo  $LoanApplicantRec->br_name; ?></b></td>	
							<th>No. of EMI Arrears</th>
							<td><b>0</b></td>
						</tr>
						
						<tr>
							<th>Loan Amount</th><td><b> <?php echo e($LoanApplicantRec->lacc_loanamt); ?></b></td>	
							<th>Adv/Arrear Bal Amt</th>
							<td><b>0.00</b></td>
						</tr>
						
						<tr>
							<th rowspan="3">Loan Paid details</th><td rowspan="3"><b></b></td>	
							<th>Arrear EMI</th><td><b></b></td>
						</tr>
						
						<tr>
							<th>Total Arrear's.</th><td><b></b></td>
						</tr>
						
						<tr>
							<th>Arrear Penalty.</th><td><b></b></td>
						</tr>
							
						<tr>
							<th>Chit Reference No.</th><td><b><?php echo e($LoanApplicantRec->lacc_chitrefno); ?></b></td>	
							<th>Current installment</th>
							<td><b><?php 
							echo $data['monthlyEMI']; ?></b></td>
						</tr>
							
						<tr>
							<th>Branch name.</th><td><b></b></td>	
							<th>Legal/Other charges</th>
							<td><b></b></td>
						</tr>	
						<tr>
							<th>Paid up amount.</th><td><b></b></td>	
							<th>Total Amt pending</th>
							<td><b><?php 
							echo $data['monthlyEMI']; ?></b></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-striped table-bordered" id="tabloan">
				<thead>
					<tr>
						<th>SLNo.</th>
						<th>Receipt No.</th>					
						<th>Month</th>							
						<th>Date of <br>Repayment</th>
						<th>Principal</th>							
						<th>Interest</th>					
						<th>Bank charges</th>						
						<th>Late fee</th>							
						<th>Case/Other charges</th>
						<th>Mode of Payment</th>
						<th>Cheque No. & Bank</th>
					</tr>
				</thead>
				<tbody>	
				<?php
				$i=1;
				$linsamt= 0;
				$intamt = 0;
				?>
					<?php $__currentLoopData = $data['LoanRpt']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $LoanInstallmentRec): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<tr>
						<td><?php echo $i; $i=$i+1; ?></td>
						<td><?php echo $LoanInstallmentRec->ltr_billno; ?></td>
						<td><?php echo date("M",strtotime($LoanInstallmentRec->ltr_transdt)); ?></td>
						<td><?php echo date("d-m-Y",strtotime($LoanInstallmentRec->lins_date)); ?></td>
						<td><?php echo $LoanInstallmentRec->lins_amt; ?></td>
						<td><?php echo $LoanInstallmentRec->lins_iamt; ?></td>
						<td><?php echo $LoanInstallmentRec->bankcharges; ?></td>
						<td><?php echo $LoanInstallmentRec->latefee; ?></td>
						<td><?php echo $LoanInstallmentRec->caseotherchrge; ?></td>
						<td><?php echo $LoanInstallmentRec->ltr_paymenttype; ?></td>
						<td><?php echo $LoanInstallmentRec->ltr_chqno; ?></td>
					</tr>
					<?php
					$linsamt = $linsamt + $LoanInstallmentRec->lins_amt;
					$intamt  = $intamt + $LoanInstallmentRec->lins_iamt;
					?>
					<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
				</tbody>
				
				<tfoot>
						<th></th>
						<th></th>					
						<th></th>							
						<th>Total</th>
						<th><?php echo $linsamt; ?></th>							
						<th><?php echo $intamt; ?></th>					
						<th></th>						
						<th></th>							
						<th></th>
						<th></th>
						<th></th>
				</tfoot>
				
				</table>
			</div>
		</div>
		
		<?php /* Cancelled Receipt transaction */ ?>
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> Cheque return / Cancelled Receipt Transactions </h3>
			</div>
			<div class="widget-content">
				<table  class="table table-striped table-bordered" >
					<thead>
						<tr>
							<th>Install No.</th>
							<th>Receipt No.</th>					
							<th>Date</th>					
							<th>Principal</th>							
							<th>Interest</th>					
							<th>Bank charges</th>						
							<th>Late fee</th>							
							<th>Case/Other charges</th>
							<th>Mode of Payment</th>
							<th>Cheque No. & Bank</th>
						</tr>
					</thead>
					<tbody>	
					<?php
					/*
						@foreach($data['LoanRpt'] as $LoanInstallmentRec)
						<tr>
							<td><?php echo $i; $i=$i+1; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_billno; ?></td>
							<td><?php echo date("M",strtotime($LoanInstallmentRec->ltr_transdt)); ?></td>
							<td><?php echo date("d-m-Y",strtotime($LoanInstallmentRec->lins_date)); ?></td>
							<td><?php echo $LoanInstallmentRec->lins_amt; ?></td>
							<td><?php echo $LoanInstallmentRec->lins_iamt; ?></td>
							<td><?php echo $LoanInstallmentRec->bankcharges; ?></td>
							<td><?php echo $LoanInstallmentRec->latefee; ?></td>
							<td><?php echo $LoanInstallmentRec->caseotherchrge; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_paymenttype; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_chqno; ?></td>
						</tr>
						@endforeach
					*/
					?>	
					</tbody>
				</table>
			</div>
		</div>
		
		
				<?php /* Balance Amount */ ?>
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> Balance amount Details </h3>
			</div>
			<div class="widget-content">
				<table  class="table table-striped table-bordered" >
					<thead>
						<tr>
							<th>Installment No.</th>
							<th>Amount</th>					
							<th>Paid Date</th>					
							<th>Status</th>		
						</tr>
					</thead>
					<tbody>	
					<?php
					/*
						@foreach($data['LoanRpt'] as $LoanInstallmentRec)
						<tr>
							<td><?php echo $i; $i=$i+1; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_billno; ?></td>
							<td><?php echo date("M",strtotime($LoanInstallmentRec->ltr_transdt)); ?></td>
							<td><?php echo date("d-m-Y",strtotime($LoanInstallmentRec->lins_date)); ?></td>
							<td><?php echo $LoanInstallmentRec->lins_amt; ?></td>
							<td><?php echo $LoanInstallmentRec->lins_iamt; ?></td>
							<td><?php echo $LoanInstallmentRec->bankcharges; ?></td>
							<td><?php echo $LoanInstallmentRec->latefee; ?></td>
							<td><?php echo $LoanInstallmentRec->caseotherchrge; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_paymenttype; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_chqno; ?></td>
						</tr>
						@endforeach
					*/
					?>	
					</tbody>
				</table>
			</div>
		</div>
		
						<?php /* Balance Amount */ ?>
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> Expense Details </h3>
			</div>
			<div class="widget-content">
				<table  class="table table-striped table-bordered" >
					<thead>
						<tr>
							<th>SL. No.</th>
							<th>Reason</th>					
							<th>Paid Date</th>					
							<th>Paid Amount</th>					
							<th>note</th>		
						</tr>
					</thead>
					<tbody>	
					
					<?php
					/*
						@foreach($data['LoanRpt'] as $LoanInstallmentRec)
						<tr>
							<td><?php echo $i; $i=$i+1; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_billno; ?></td>
							<td><?php echo date("M",strtotime($LoanInstallmentRec->ltr_transdt)); ?></td>
							<td><?php echo date("d-m-Y",strtotime($LoanInstallmentRec->lins_date)); ?></td>
							<td><?php echo $LoanInstallmentRec->lins_amt; ?></td>
							<td><?php echo $LoanInstallmentRec->lins_iamt; ?></td>
							<td><?php echo $LoanInstallmentRec->bankcharges; ?></td>
							<td><?php echo $LoanInstallmentRec->latefee; ?></td>
							<td><?php echo $LoanInstallmentRec->caseotherchrge; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_paymenttype; ?></td>
							<td><?php echo $LoanInstallmentRec->ltr_chqno; ?></td>
						</tr>
						@endforeach
					*/
					?>	
					</tbody>
					<tfoot>
						<tr>
							<th></th>
							<th></th>					
							<th></th>					
							<th></th>					
							<th></th>		
						</tr>
					</tfoot>
				</table>
			</div>
		</div>
		
		<?php /* Balance Amount */ ?>
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> Security Entry </h3>
			</div>
			<div class="widget-content">
				<table  class="table table-striped table-bordered" >
					<thead>
						<tr>
							<td><?php echo e($LoanApplicantRec->lacc_securityentry); ?></td>		
						</tr>
					</thead>
				</table>
			</div>
		</div>

</div>
		<?php /* Print */ ?>
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> Print </h3>
			</div>
			<div class="widget-content">
				<table  class="table table-striped table-bordered" >
					<thead>
						<tr>
							<td>
							<center><button class="form-control" style="width: 250px;"  onclick="printDiv('divprint')">Print</button></center>
							</td>		
						</tr>
					</thead>
				</table>
			</div>
		</div>
<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;
}
</script>
		<!-- END DATA EXPORT -->
<?php
/*
				<div class="widget">
					<div class="widget-header"><center> 
						<button class="btn btn-info btn-default" onclick="funLoanPreClosure('<?php echo $lacc_id; ?>','<?php echo $loanacc; ?>')" ><span class="fa fa-asterisk"></span> Update</button>
						 | 
						
						<button class="btn btn-info btn-default" onclick="funSingleTransactionRPT('<?php echo $lacc_id; ?>','<?php echo $loanacc; ?>')" ><span class="fa fa-flag"></span> Transaction Report</button>
						</center>
					</div>
				</div>
		</form>					
	</div>
</div>
<!-- /main -->

<!-- Modal starts here -->		
<div class="container">

  <!-- The Modal Other amount starts here-->
  <div class="modal" id="myotheramt">
    <div class="modal-dialog">
      <div class="modal-content">
      
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Other Charges</h4>
        </div>
        
        <!-- Modal body -->
        <div class="modal-body">
			<form id="frmothercharges" name="frmothercharges" data-parsley-validate novalidate>
					<input type="hidden" name="_token2" id="_token2" value="{{ csrf_token() }}">
					<input type="hidden" name="lacc_id2" id="lacc_id2">
					<input type="hidden" name="lins_id2" id="lins_id2">
				<div class="row">
					<div class="col-md-12">
						<div class="form-group">
							<label for="multiselect1">Select type*</label>
							<br/>
							<select name="penaltytype" id="penaltytype" class="form-control" required> 
								<option value=""> -- Select -- </option>
								<?php
								$arr = array("Cheque Bounce", "Case", "Delay payment", "Others");
								foreach($arr as $val)
								{
									echo "<option value='$val'>$val</option>";
								}
								?>
							</select>
							<small class="text-danger" id="err_penaltytype"></small>
						</div>
						<div class="form-group">
							<label for="text-input1">Date</label>
							<input type="date" name="penaltydate" id="penaltydate" class="form-control" value="<?php echo date("Y-m-d"); ?>" >					
							<small class="text-danger" id="err_penaltydate"></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Amount.</label>
							<input type="text" name="penaltyamt" id="penaltyamt" class="form-control" >					
							<small class="text-danger" id="err_penaltyamt"></small>
						</div>
						<div class="form-group">
							<label for="text-input1">Any note</label>
							<input type="text" name="penaltynote" id="penaltynote" class="form-control" >					
							<small class="text-danger" id="err_penaltynote"></small>
						</div>
					</div>
				</div>
			</form>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
		  <button type="button" class="btn btn-primary btnloanpenalty">Submit</button>
        </div>
        
      </div>
    </div>
  </div>
  <!-- The Modal Other amount ends here -->
  
  <!-- ###### The Modal payment amount starts here ###### -->
  <div class="modal" id="mypayment">
    <div class="modal-dialog paymentmodal">
      <div class="modal-content">
      
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Make Payment</h4>
        </div>
        
        <!-- Modal body -->
        <div class="modal-body">
			<form id="frmpayment" name="frmpayment" data-parsley-validate novalidate>
					<input type="hidden" name="_token" value="{{ csrf_token() }}">
					<input type="hidden" name="lacc_id1" id="lacc_id1">
					<input type="hidden" name="lins_id1" id="lins_id1">
				<div class="row">
					<div class="col-md-4">
						<div class="form-group">
							<label for="text-input1">Current Balance</label>
							<input type="text" name="currentpayable" id="currentpayable" class="form-control" readonly >					
							<small class="text-danger" id="err_currentpayable"></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Previous Balance</label>
							<input type="text" name="previousbalance" id="previousbalance" class="form-control" readonly>					
							<small class="text-danger" id="err_previousbalance"></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Total payable</label>
							<input type="text" name="totalpayable" id="totalpayable" class="form-control" readonly >					
							<small class="text-danger" id="err_totalpayable"></small>
						</div>
					</div>
					<div class="col-md-4">
						<div class="form-group">
							<label for="text-input1">Transaction No.*</label>
							<input type="text" name="ltr_billno" id="ltr_billno" class="form-control" >					
							<small class="text-danger" id="err_ltr_billno"></small>
						</div>
						
						<div class="form-group">
							<label for="text-input1">Transaction Date.*</label>
							<input type="date" name="ltr_transdt" id="ltr_transdt" class="form-control" value="<?php echo  date("Y-m-d"); ?>" >					
							<small class="text-danger" id="err_ltr_transdt"></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Paid Amount.</label>
							<input type="text" name="ltr_amt" id="ltr_amt" class="form-control" onkeyup="calculatebal()" >					
							<small class="text-danger" id="err_ltr_amt"></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Balance Amount.</label>
							<input type="text" name="balanceamt" id="balanceamt" class="form-control" readonly>					
							<small class="text-danger" id="err_balanceamt"></small>
						</div>
						
					</div>
					<div class="col-md-4">
						<div class="form-group">
							<label for="multiselect1">Payment type*</label>
							<br/>
							<select name="ltr_paymenttype" id="ltr_paymenttype" class="form-control" required> 
								<option value=""> -- Select -- </option>
								<?php
								$arr = array("Cash", "Cheque", "NEFT", "Others");
								foreach($arr as $val)
								{
									echo "<option value='$val'>$val</option>";
								}
								?>
							</select>
							<small class="text-danger" id="err_ltr_paymenttype"></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Cheque No.</label>
							<input type="text" name="ltr_chqno" id="ltr_chqno" class="form-control" >					
							<small class="text-danger" id="err_ltr_chqno"></small>
						</div>
						<div class="form-group">
							<label for="text-input1">Bank Name</label>
							<input type="text" name="ltr_bank" id="ltr_bank" class="form-control" >					
							<small class="text-danger" id="err_ltr_bank"></small>
						</div>	
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<div class="form-group">
							<label for="text-input1">Any other note</label>
							<input type="text" name="ltr_note" id="ltr_note" class="form-control" >					
							<small class="text-danger" id="err_ltr_note"></small>
						</div>
					</div>
				</div>
			</form>
        </div>
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> 
		  <button type="button" class="btn btn-primary btnloanpayment">Make Payment</button>
        </div>
        
      </div>
    </div>
  </div>
  <!-- ###### The Modal payment amount ends here ###### -->
  
  <!-- ###### The Modal payment amount starts here ###### -->
  <div class="modal" id="viewreport">
    <div class="modal-dialog paymentmodal">
      <div class="modal-content">
      
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">View Report</h4>
        </div>
        
        <!-- Modal body -->
        <div class="modal-body" id="rptsingle">
			
		</div>
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> 
        </div>
        
      </div>
    </div>
  </div>
  <!-- ###### The Modal payment amount ends here ###### -->
  
  <!-- ###### The Modal Cancellation starts here ###### -->
  <div class="modal" id="modcancellation">
    <div class="modal-dialog paymentmodal">
      <div class="modal-content">
      
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Cancellation card</h4>
        </div>
        
        <!-- Modal body -->
        <div class="modal-body">
			<form id="frmcancellation" name="frmcancellation" data-parsley-validate novalidate>
			<input type="hidden" name="_token" value="{{ csrf_token() }}">
			<div id="rptCancellation"></div>
				<div class="row">
					<div class="col-md-12">
						<div class="form-group">
							<label for="text-input1">Title</label>
							<input type="text" name="ltr_cancellationtype" id="ltr_cancellationtype" class="form-control" >					
							<small class="text-danger" id="err_ltr_cancellationtype"></small>
						</div>
						<div class="form-group">
							<label for="ltr_cancellationreason">Note</label>
							<textarea  name="ltr_cancellationreason" id="ltr_cancellationreason" class="form-control" ></textarea>
							<small class="text-danger" id="err_ltr_cancellationreason"></small>
						</div>
					</div>
				</div>
			</form>
		</div>
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
		  <button type="button" class="btn btn-primary btncancel">Confirm Cancellation</button>		  
        </div>
        
      </div>
    </div>
  </div>
  <!-- ###### The Modal Cancellation amount ends here ###### -->
  
</div>
<!-- Modal ends here -->
</div>
<script>
	$('.createMod').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	$('.edit').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href')); 
	});
	
	$('#mypayment').on('show.bs.modal', function(e) {
        var $modal = $(this),
            lins_id = e.relatedTarget.id;
        $.ajax({
            cache: false,
            type: 'GET',
            url: 'loanpaymentcalculation',
            data: 'lins_id=' + lins_id,
            success: function(data) {
				var Obj=JSON.parse(data);	
				$('#lacc_id1').val($("input[name='lacc_id']").val());
				$('#lins_id1').val(lins_id);
				var CurrentPayableAmt =Obj.CurrentPayableAmt;
				var PreviousPayableAmt =Obj.PreviousPayableAmt;
				var TotalPayableAmt =Obj.TotalPayableAmt;
				$('#currentpayable').val(CurrentPayableAmt);
				$('#previousbalance').val(PreviousPayableAmt);
				$('#totalpayable').val(TotalPayableAmt);
            }
        });
    })
	
	$('#myotheramt').on('show.bs.modal', function(e) {
        var $modal = $(this),
            lins_id = e.relatedTarget.id;
        $.ajax({
            cache: false,
            type: 'GET',
            url: 'loanpaymentcalculation',
            data: 'lins_id=' + lins_id,
            success: function(data) {
				var Obj=JSON.parse(data);	
				$('#lacc_id2').val($("input[name='lacc_id']").val());
				$('#lins_id2').val(lins_id);
            }
        });
    })
	
	function calculatebal() 
	{
		balanceamt = parseFloat($('#totalpayable').val()) - parseFloat($('#ltr_amt').val());
		$('#balanceamt').val(balanceamt);
		if($('#balanceamt').val() == "NaN")
		{
			$('#balanceamt').val(0);
		}
	}
	
	//### Payment submission entry code starts here
	flag=0;
	$('.btnloanpayment').click(function(e)
	{
		e.preventDefault();
		_token = $("input[name='_token']").val();		           
		var lacc_id1 = $("input[name='lacc_id1']").val();
		var lins_id1 = $("input[name='lins_id1']").val();
		var ltr_transdt = $("input[name='ltr_transdt']").val();
		var currentpayable = $("input[name='currentpayable']").val();
		var previousbalance = $("input[name='previousbalance']").val();
		var totalpayable = $("input[name='totalpayable']").val();
		var ltr_amt = $("input[name='ltr_amt']").val();
		var balanceamt = $("input[name='balanceamt']").val();
		var ltr_billno = $("input[name='ltr_billno']").val();
		var ltr_chqno = $("input[name='ltr_chqno']").val();
		var ltr_paymenttype = $('#ltr_paymenttype').val();
		var ltr_bank = $("input[name='ltr_bank']").val();
		var ltr_note = $("input[name='ltr_note']").val();
		if(ltr_billno == "" )
		{
			alert("Transaction No. Should not be empty...");
		}
		else if(ltr_transdt == "" )
		{
			alert("Transaction Date Should not be empty...");
		}
		else if(ltr_amt == "" )
		{
			alert("Paid Amount. Should not be empty...");
		}
		else if(parseFloat(ltr_amt) < parseFloat(previousbalance) )
		{
			alert("Paid amount should be greater than Previous balance...");
		}
		else if(ltr_paymenttype == "" )
		{
			alert("Payment type should not be empty...");
		}
		else
		{
			$.ajax({
				url: "loaninstallmentpayment",
				type:'POST',
				dataType: 'json',
				//cache : false,
				//processData: false,
				data: {_token:_token,lacc_id:lacc_id1, lins_id:lins_id1, ltr_transdt:ltr_transdt, ltr_transtype:"Payment", ltr_billno:ltr_billno, ltr_amt:ltr_amt, ltr_paymenttype:ltr_paymenttype, ltr_chqno:ltr_chqno, ltr_bank:ltr_bank, ltr_note:ltr_note, ltr_status:"Active"},
				success: function(data)
				{
					if(data.status == "Success")
					{
						alert("Loan payment done successfully..");
						//$('#sideMenu').load('viewloanaccount');
						LoadLoanApplication(lacc_id1,lins_id1);
						$('#mypayment').modal('toggle');
					}
					else
					{
						alert("Failed to Generate Purchase Bill..");
						//printErrorMsg(data.message)
					}
				}
			});
		}
	});
	//### Payment submission entry code ends here
	
	function LoadLoanApplication(b,acno)
	{
		$.ajax({
			url: 'LoanAcPanel',
			type: 'GET',
			data:'&lacc_id='+b+'&acno='+acno,
			success: function(data)
			{
				$('#sideMenu').html(data);
			}
		});
	}
	
	//### Penalty submission entry code starts here
	$('.btnloanpenalty').click(function(e)
	{
		//_token2 lacc_id2 lins_id2 penaltydate penaltytype  penaltyamt penaltynote
		e.preventDefault();
		_token = $("input[name='_token2']").val();		           
		var lacc_id1 = $("input[name='lacc_id2']").val();
		var lins_id1 = $("input[name='lins_id2']").val();
		var ltr_transdt = $("input[name='penaltydate']").val();
		var penaltytype = $('#penaltytype').val();
		var currentpayable = 0;
		var previousbalance = 0;
		var totalpayable = 0;
		var ltr_amt = $("input[name='penaltyamt']").val();
		var balanceamt =0;
		var ltr_billno = 0;
		var ltr_chqno = '';
		var ltr_paymenttype = '';
		var ltr_bank = '';
		var ltr_note = $("input[name='penaltynote']").val();
		if(penaltytype == "" )
		{
			alert("Type Should not be empty...");
		}
		else if(ltr_transdt == "" )
		{
			alert("Date Should not be empty...");
		}
		else if(ltr_amt == "" )
		{
			alert("Amount should not be empty...");
		}
		else
		{
			$.ajax({
				url: "loaninstallmentpayment",
				type:'POST',
				dataType: 'json',
				//cache : false,
				//processData: false,
				data: {_token:_token,lacc_id:lacc_id1, lins_id:lins_id1, ltr_transdt:ltr_transdt, ltr_transtype:penaltytype, ltr_billno:ltr_billno, ltr_amt:ltr_amt, ltr_paymenttype:ltr_paymenttype, ltr_chqno:ltr_chqno, ltr_bank:ltr_bank, ltr_note:ltr_note, ltr_status:"Active"},
				success: function(data)
				{
					if(data.status == "Success")
					{
						alert("Other charges added successfully..");
						LoadLoanApplication(lacc_id1,lins_id1);
						$('#myotheramt').modal('toggle');
					}
					else
					{
						alert("Failed to Generate Purchase Bill..");
						//printErrorMsg(data.message)
					}
				}
			});
		}
	});
	//### Penalty submission entry code ends here
	
	//Preclosure starts here
	function funLoanPreClosure(lacc_id,lacc_no)
	{
		$.ajax({
			url: 'loanAccountPreclosure',
			type: 'GET',
			data:'&lacc_id='+lacc_id+'&lacc_no='+lacc_no,
			success: function(data)
			{
				$('#sideMenu').html(data);
			}
		});
	}
	//Preclosure ends here
	
	//View Report starts here
	$('#viewreport').on('show.bs.modal', function(e) {
        var $modal = $(this),
            lins_id = e.relatedTarget.id;
        $.ajax({
            cache: false,
            type: 'GET',
            url: 'loanrptsingle',
            data: 'lins_id=' + lins_id,
            success: function(data) {
				$('#rptsingle').html(data);
            }
        });
    })
	//View Report ends here
	
	//Load Loan Cancellation Starts here
	$('#modcancellation').on('show.bs.modal', function(e) {
        var $modal = $(this),
            ltr_id = e.relatedTarget.id;
        $.ajax({
            cache: false,
            type: 'GET',
            url: 'loanCancellationLoad',
            data: 'ltr_id=' + ltr_id,
            success: function(data) {
				$('#rptCancellation').html(data);
            }
        });
    })
	//Load Loan Cancellation Ends here
	//loanCancellation insert
	flag=0;
	$('.btncancel').click(function(e)
	{
		e.preventDefault();
		_token = $("input[name='_token']").val();	           
		var ltr_id = $("input[name='ltr_id']").val();
		var lacc_id = $("input[name='lacc_id']").val();
		var lins_id = $("input[name='lins_id']").val();
		var ltr_cancellationtype = $("input[name='ltr_cancellationtype']").val();
		var ltr_cancellationreason = $('#ltr_cancellationreason').val();
		if(ltr_cancellationtype == "" )
		{
			alert("Cancellation type Should not be empty...");
		}
		else
		{
			$.ajax({
				url: "loaninstallmentcancellationins",
				type:'POST',
				dataType: 'json',
				//cache : false,
				//processData: false,
				data: {_token:_token,ltr_id:ltr_id, lacc_id:lacc_id, lins_id:lins_id, ltr_cancellationtype:ltr_cancellationtype, ltr_cancellationreason:ltr_cancellationreason},
				success: function(data)
				{
					if(data.status == "Success")
					{
						alert("Loan Cancellation done successfully..");
						$('#modcancellation').modal('toggle');
						//############
						reloadcancelmodal(lins_id,lacc_id);
						//############
					}
					else
					{
						alert("Failed to Generate Purchase Bill..");
						//printErrorMsg(data.message)
					}
				}
			});
		}
	});
	
	function reloadcancelmodal(lins_id,lacc_id)
	{
		var $modal = $(this),
            lins_id = lins_id;
        $.ajax({
            cache: false,
            type: 'GET',
            url: 'loanrptsingle',
            data: 'lins_id=' + lins_id,
            success: function(data) {
				$('#rptsingle').html(data);
            }
        });		
	}
	
	$('#viewreport').on('hidden.bs.modal', function () {	           
		var lacc_id = $("input[name='lacc_id']").val();
		var lacc_no = $("input[name='lacc_no']").val();		 
			LoadLoanApplication(lacc_id,lacc_no);
	})
	
</script>
*/
?>