<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/repfunctions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
get_pagesecurity('27','views','R');    
$_SESSION['cuPages']='lon_loanidlist.php';   
$cuPage='lon_loanidlist.php';    
$aid=$_SESSION['uid'];
$brid=$_SESSION['abrid'];    
}else{
header('Location:../index.php');
exit;    
}
$mhead='loanins';
$menuh='Loan Setup';
$phead='loanidlist';
$page='Loan Id Record';
$print='print';
$dtnow = date("Y-m-d h:i:s", time());
?>
<?php
include('../layout/head.php');
include('../layout/header.php');
include('../layout/side_nav.php');
?>

<div class="content-wrapper">
<?php include('../layout/page_head.php'); ?>
<!-- Main content -->
<section class="content">
    
<div class="row">
<div class="col-md-8">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Loan Id Record</h3>
</div>
<div class="box-body">
<?php echo display_msg();?>    
<div class="col-md-12 table-responsive">
<table class="table table-bordered table-striped" id="datarec">
<thead>
<tr>
<th style="width:40px; text-align:center;">SN</th>
<th>Code</th>    
<th>Name</th>
<th>Number</th>
<th>Type</th>    
<th>Debit</th>    
<th>Credit</th>    
<th>Balance</th>  
<th>Action</th>  
</tr>
</thead>    
<tbody>
<?php
$sql="SELECT * FROM tbl_loanid ORDER BY name ASC";    
$query=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($row=mysqli_fetch_array($query)){
$id='LO'.$row['id'];    
$ldebit=get_ledgerval($id,'D','N');
$lcredit=get_ledgerval($id,'C','N');
$lnet=($ldebit-$lcredit);    
?>
<tr>
<td class="text-center"><?php echo count_id();?></td>
<td><?php echo $row['code'];?></td>
<td><?php echo $row['name'];?></td>
<?php if($row['type']==1){?>    
<td><?php echo $row['mobile'];?></td>
<?php }else{ ?>
<td><?php echo $row['acno'];?></td>    
<?php } ?>
<td><?php if($row['type']==1){echo 'Person';}else{echo 'Bank';}?></td>    
<td><?php echo numtolocal($ldebit,get_fild_data('tbl_currency','1','symbol'));?></td>
<td><?php echo numtolocal($lcredit,get_fild_data('tbl_currency','1','symbol'));?></td>
<td><?php echo numtolocal($lnet,get_fild_data('tbl_currency','1','symbol'));?></td>   
<td nowrap="">
<a class="btn btn-flat bg-purple details-invoice" href="#" id="stm_<?php echo $row['id']; ?>"><i class="fa fa-eye cat-child"></i></a>     
</td>    
</tr>    
<?php } ?>   
</tbody>   
</table>
</div>
<div class="clearfix" ></div>  
<div class="row"style="margin-top: 15px" >
<div class="col-md-12 table-responsive">    
<div class="col-md-8"></div>
<div class="col-md-4 text-right" >
<a href="acc_reccreate.php" class="btn btn-flat bg-purple">Create Received</a>
</div>
</div>    
</div>    
</div>
</div>
</div>
<div class="col-md-4">
<div class="row">
<div class="col-md-12">
<div class="box box-solid">
<div class="box-header">
<h3 class="box-title">History </h3>
</div>
<!-- /.box-header -->
<div class="box-body" >
<?php if($_SESSION['utype']=='1'){echo read_activity($aid,'REC','A');}else{echo read_activity($aid,'REC','U');}?>
</div>
</div>
</div>
</div>
</div>
</div>

<?php include('../layout/quick.php');?>    
</section>
<!-- /.main content -->
<?php include('../layout/print.php'); ?>    
</div>

<?php 
include('../layout/footer.php');
?>
<!-- page script -->
<script type="text/javascript">
$(document).ready(function() {
$('#datarec').DataTable({stateSave: true});
});

function edit_item(id) {
document.getElementById(id).submit(); 
}    
    
function remove_item(id) {
bootbox.confirm({
title: "Confirm",
message: "Are you sure to delete ?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-flat bg-purple'
},
cancel: {
label: 'Cancel',
className: 'btn-flat bg-gray'
}
},
callback: function (result) {
if (result == true) {
document.getElementById(id).submit();
}
}
});
}
    
$(".details-invoice").click(function (e) {
id_arr = $(this).attr('id');
id = id_arr.split("_");

$.ajax({
url: 'lon_viewlist.php',
method: "POST",
data:{ 
invid: id[1]
},
success: function(data){
$('#listitem').html(data);
pagelist();    
}
});    
    
$.ajax({
url: 'lon_viewstm.php',
method: "POST",
data:{ 
print: id[1]
},
success: function(data){
$('#invhold').html(data);
sethead();    
}
});
    
$('.right-side').toggle('slide', { direction: 'right' }, 300);    

e.preventDefault();
});

$(document).on('click', '#closepop', function() {
if($('.right-side').is(':visible')) { $('.right-side').toggle('slide', { direction: 'right' }, 300); }   
});    

$('#listitem').on('click','li', function(){
   $(this).addClass('active').siblings().removeClass('active');
});
    
$(document).on('click', '.invrecv', function() {
id_arr = $(this).attr('id');
id = id_arr.split("_");
var ids = id[1];
$.ajax({
url: 'lon_viewstm.php',
method: "POST",
data:{ 
print: ids
},
beforeSend: function() {
$("#invhold").fadeOut('slow');
},    
success: function(data){    
$('#invhold').html(data);
$("#invhold").fadeIn('slow');    
sethead();    
}
});     
});    
</script>    
<!-- /page script -->
</html>