474 lines
14 KiB
PHP
Executable File
474 lines
14 KiB
PHP
Executable File
|
|
<script src="<?php echo base_url()?>public/assets/tabletoexport/jquery.tableexport.v2.js"></script>
|
|
|
|
|
|
|
|
<?php
|
|
// print_r($loanrecords);
|
|
date_default_timezone_set("Asia/Kolkata");
|
|
$dateflag=0;
|
|
$statusflag =0;
|
|
$overdueflag = 0;
|
|
$source = array('company'=>'ALL');
|
|
$historytableflag = 0;
|
|
if(!empty($childdata) )
|
|
{
|
|
if(count($childdata) > 0 ){
|
|
$historytableflag = 1; }
|
|
//echo "child";
|
|
}
|
|
if(!empty($loanrecords))
|
|
{
|
|
|
|
foreach($loanrecords as $r)
|
|
{
|
|
//print_r($r);
|
|
if(!empty($r->Loan_Issued_Date))
|
|
{
|
|
$dateflag=1;
|
|
$statusflag=1;
|
|
|
|
}
|
|
|
|
if(!empty($r->Due_Start_Date) && !empty($r->No_of_Dues))
|
|
{
|
|
// echo date('Y-m-d h:m:s');
|
|
// echo $r->Due_Start_Date;
|
|
$rdues = $r->No_of_Dues;
|
|
$time=strtotime($r->Due_Start_Date);
|
|
// echo date('Y-m-d',$time).'</br>';
|
|
//echo 'NO of Dues -' .$rdues.'<br>';
|
|
$dueendyear=date("Y",$time);
|
|
$dueendmonth=date("m",$time);
|
|
$dueenddate=date("d",$time);
|
|
//echo 'end month -' .$dueendmonth.'<br>';
|
|
$dueendmonth = $dueendmonth + ($rdues - 1);
|
|
//echo 'afetr end month -' .$dueendmonth.'<br>';
|
|
//echo $dueendyear.'-'.$dueendmonth.'-'.$dueenddate.'<br>';
|
|
if($dueendmonth > 12){
|
|
$dueendmonth = ($dueendmonth - 12);
|
|
}
|
|
|
|
if($dueendmonth < 10){
|
|
$dueendmonth = '0'.$dueendmonth;
|
|
}
|
|
if($dueendyear < date('Y'))
|
|
{
|
|
$dueendyear = date('Y');
|
|
|
|
}
|
|
|
|
//echo $dueendmonth.'</br>';
|
|
$finaldueenddate = $dueendyear.'-'.$dueendmonth.'-'.$dueenddate;
|
|
$curdate = date('Y-m-d');
|
|
//echo $curdate.'-'.$finaldueenddate;
|
|
if($curdate > $finaldueenddate)
|
|
{
|
|
|
|
$overdueflag =1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if(!empty($loanemployees))
|
|
{
|
|
foreach($loanemployees as $l)
|
|
{
|
|
$source[$l->EmpID] = $l->EmpID.'-'.$l->FName.'-'.$l->Lname;
|
|
}
|
|
|
|
}
|
|
$monthsoptions = array("01" => "Jan", "02" => "Feb","03" => "Mar","04" => "Apr","05" => "May","06" => "June","07"=> "July","08"=> "Aug","09" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec");
|
|
|
|
?>
|
|
<style>
|
|
.ui-datepicker-trigger{
|
|
border:none;
|
|
background:none;
|
|
}
|
|
|
|
|
|
</style>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
|
|
<script src="<?php echo base_url()?>public/assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
|
|
<script src="<?php echo base_url()?>public/assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
|
|
<script>
|
|
$(function()
|
|
{
|
|
|
|
$("#finyear").datepicker(
|
|
{
|
|
|
|
minViewMode: 1,
|
|
|
|
|
|
//format: 'M-yyyy',
|
|
|
|
});
|
|
|
|
$("#finyear").change(function(){
|
|
$("#finyearttext").val('');
|
|
var date = $('#finyear').datepicker('getDate');
|
|
$("#finyear").val("Year");
|
|
var month = date.getMonth();
|
|
var year = date.getFullYear();
|
|
month++;
|
|
if (month >= 4)
|
|
{
|
|
$("#finyear").val("Year");
|
|
$("#finyearttext").val(year + '-' + (year+1));
|
|
}
|
|
else
|
|
{
|
|
$("#finyear").val("Year");
|
|
$("#finyearttext").val((year-1) + '-' + year);
|
|
}
|
|
|
|
});
|
|
|
|
//alert($('#source').find(":selected").text());
|
|
$("#finyear").val("Year");
|
|
var sw = <?php echo $historytableflag;?>;
|
|
if(sw == 1)
|
|
{
|
|
$('#parenttable').hide();
|
|
$('#historyarea').show();
|
|
}
|
|
else
|
|
{
|
|
$('#parenttable').show();
|
|
$('#historyarea').hide();
|
|
}
|
|
|
|
// $("#finyear").datepicker({}).onmouseleave({
|
|
// alert("sdds");
|
|
// });
|
|
|
|
});
|
|
</script>
|
|
<style type="text/css">
|
|
.num {
|
|
text-align:right;
|
|
}
|
|
</style>
|
|
<div class="content-wrapper">
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1>
|
|
<center>Company/Employee Loan Reports</center>
|
|
</h1>
|
|
</section>
|
|
<section class="content">
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-xs-12">
|
|
<div class="box">
|
|
<div class="box-header">
|
|
<!--<center><h3 class="box-title">-->
|
|
<div class="box-tools">
|
|
|
|
<form action="<?php echo base_url() ?>loanreports" method="POST" id="searchList">
|
|
|
|
|
|
</div><!--</h3></center>-->
|
|
|
|
</div><!-- /.box-header -->
|
|
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<?php echo form_dropdown('source',set_value('monthyear',$source),'id="source"' ,'class="form-control select2"');?>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<?php echo form_input('finyear',set_value('finyearttext'),'id="finyearttext"' ,'class="form-control"');?>
|
|
<input type="button" id="finyear" value="Year">
|
|
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
|
|
<input type="button" value="View Report" class="btn btn-success" id="report">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="box-body">
|
|
<div id="parenttable">
|
|
<div> <center><strong><h2> <?php if(empty($fyear)){$fyear = "Overall";} echo $fyear; ?></h2><strong><center></div>
|
|
<table id="monthlylistings" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
|
|
<thead >
|
|
<tr>
|
|
|
|
<th>S.No</th>
|
|
<th>Employee Name</th>
|
|
<th>Loan Given ₹</th>
|
|
<?php if($dateflag == 1) {?>
|
|
<th>Loan Issue Date</th>
|
|
<?php }?>
|
|
<th>Loan Recovered ₹ </th>
|
|
<?php if($statusflag == 1) {?>
|
|
<th>No Of Dues</th>
|
|
<th>Due Amount</th>
|
|
<th>Loan Status</th>
|
|
<?php }?>
|
|
<th>Loan Balance ₹</th>
|
|
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$index = 0;
|
|
$totalloangiven = 0;
|
|
$totalrecovered = 0;
|
|
$totalbalance = 0;
|
|
//$overdue = 0;
|
|
$base=base_url();
|
|
if(!empty($loanrecords))
|
|
{
|
|
foreach($loanrecords as $rec)
|
|
{
|
|
$index++;
|
|
|
|
?>
|
|
<tr> <td><?php echo $index;?></td>
|
|
<?php if($dateflag != 1) {?>
|
|
<td><?php echo '<a href="'.$base.'loanreports/'.$rec->EmpID.'/'.$fyear.'">'.$rec->EmpID.'-'.$rec->FName.'-'.$rec->Lname.'</a>';?></td>
|
|
<?php }else{?>
|
|
<td><?php echo '<a href="'.$base.'loanreports/'.$rec->Loan_ID.'">'.$rec->EmpID.'-'.$rec->FName.'-'.$rec->Lname.'</a>';?></td>
|
|
<?php }?>
|
|
<td style="text-align:right;"><?php if(!empty($rec->Loan_Amount)){$totalloangiven+=$rec->Loan_Amount; echo $rec->Loan_Amount;}else{echo "0.00";}?></td>
|
|
<?php if($dateflag == 1) {?>
|
|
<td style="text-align:right;"><?php if(!empty($rec->Loan_Issued_Date)){echo date_format(date_create($rec->Loan_Issued_Date),'d-m-Y');}else{echo "-";}?></td>
|
|
<?php }?>
|
|
<td style="text-align:right;"><?php if(!empty($rec->Paid_Amount)){$totalrecovered+=$rec->Paid_Amount ;echo $rec->Paid_Amount;}else{echo "0.00";} ?></td>
|
|
<?php if($statusflag == 1) {
|
|
// if(!empty($rec->Due_Start_Date) && !empty($rec->No_of_Dues))
|
|
// {
|
|
|
|
// // echo $rec->Due_Start_Date;
|
|
// $noofdus = $rec->No_of_Dues;
|
|
// $time=strtotime($rec->Due_Start_Date);
|
|
// $month=date("m",$time);
|
|
// $finalmonth = $month+$noofdus;
|
|
// // echo $finalmonth;
|
|
// $curmonth = date('m');
|
|
// if($curmonth > $finalmonth)
|
|
// {
|
|
// //echo 'overdue';
|
|
// //echo ($curmonth > $finalmonth);
|
|
// $overdueflag = 1;
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
?>
|
|
<td style="text-align:right;"><?php if(!empty($rec->No_of_Dues)){echo $rec->No_of_Dues;}else{echo "0.00";} ?></td>
|
|
<td style="text-align:right;"><?php if(!empty($rec->Monthly_Due)){echo $rec->Monthly_Due;}else{echo "0.00";} ?></td>
|
|
<td style="text-align:center;" ><?php $final = ''; if($rec->is_Active == 1){$final = "<font color='blue'>Pending</font>"; }else{$final = "<font color='green'>Completed</font>";} if($overdueflag == 1 and $rec->is_Active == 1){$final.=",<font color='red'>Over Due</font>";} echo $final;?></td>
|
|
<?php }?>
|
|
<td style="text-align:right;"><?php if(!empty(($rec->Loan_Amount) and ($rec->Paid_Amount))){ $totalbalance+= ($rec->Loan_Amount - $rec->Paid_Amount);echo number_format(($rec->Loan_Amount - $rec->Paid_Amount),2,'.','');}else {echo "0.00";}?></td>
|
|
</tr>
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
$overdueflag == 0;
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
<tr>
|
|
<td></td>
|
|
<td style="text-align:right;"><strong>Total</strong></td>
|
|
<td style="text-align:right;"><strong><?php echo number_format($totalloangiven,2,'.','');?></strong></td>
|
|
|
|
<?php if($dateflag == 1) {?>
|
|
<td></td>
|
|
<?php }?>
|
|
|
|
<td style="text-align:right;"><strong><?php echo number_format($totalrecovered,2,'.','');?></strong></td>
|
|
|
|
<?php if($statusflag == 1) {?>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<?php }?>
|
|
|
|
<td style="text-align:right;"><strong><?php echo number_format( $totalbalance,2,'.','');?></strong></td>
|
|
<tr>
|
|
</table>
|
|
</div>
|
|
<p> </p>
|
|
|
|
<?php if($historytableflag == 1){?>
|
|
<div id="historyarea">
|
|
<div>
|
|
<?php
|
|
$Name = '';
|
|
$Loan = 0;
|
|
$Issue_date = 0;
|
|
|
|
if(!empty($childdata))
|
|
{
|
|
foreach($childdata as $c)
|
|
{
|
|
$Loan_ID = $c->Loan_ID;
|
|
$Name = $c->EmpID.'-'.$c->FirstName.'-'.$c->LastName;
|
|
$Loan = $c->Loan_Amount;
|
|
$Issue_date = $c->Loan_Issued_Date;
|
|
$dis = 'Loan ID:-'.$Loan_ID.'-Name:-'.$Name.'- Amount:-'. $Loan;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<span><center><h3> <?php echo $Name.' Loan Amount:'.$Loan.' Loan Issued Date:'.$Issue_date;?></h3></center></span>
|
|
</div>
|
|
<table id="historytable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
|
|
<thead >
|
|
|
|
<tr><th>Date </th> <th>Due_Month </th> <th>Due Amount ₹</th> <th>Balance Amount ₹</th> </tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if(!empty($childdata))
|
|
{
|
|
foreach($childdata as $child)
|
|
{
|
|
|
|
$monthno = substr($child->Due_Date,0,2);
|
|
$yr = substr($child->Due_Date,3,4);
|
|
$final = $monthsoptions[$monthno].'-'.$yr;
|
|
|
|
?>
|
|
<tr> <td style="text-align:left;"><?php echo format_date($child->Entry_Date, 0, 'd-m-Y');?></td> <td style="text-align:right;"><?php echo $final;?></td> <td style="text-align:right;"><?php echo $child->Due_Amount ;?></td> <td style="text-align:right;"><?php echo $child->Balance_Amount;?></td> </tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php }?>
|
|
<div class="row">
|
|
|
|
</div>
|
|
</div><!-- /.box-body -->
|
|
<!-- <div class="box-footer clearfix">
|
|
|
|
</div> -->
|
|
</div><!-- /.box -->
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
|
|
$('#monthlylistings').DataTable({
|
|
"paging": true,
|
|
"lengthChange": true,
|
|
"searching": true,
|
|
"ordering": true,
|
|
"aaSorting": [[ 0, "asc" ]],
|
|
"info": true,
|
|
"autoWidth": true
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
$(function () {
|
|
|
|
$('#historytable').DataTable({
|
|
"paging": true,
|
|
"lengthChange": true,
|
|
"searching": true,
|
|
"ordering": false,
|
|
"aaSorting": [[ 0, "asc" ]],
|
|
"info": true,
|
|
"autoWidth": true
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
$('#report').click(function(){
|
|
|
|
// var finyear = $('#finyearttext').val();
|
|
// var source = $('#source').val();
|
|
// $("#form").submit( function(eventObj) {
|
|
// $('#searchList').attr('method', 'post')
|
|
// .attr('action', "payslip/loadLoanReport")
|
|
// .attr('value', "something")
|
|
// .appendTo('#form');
|
|
// return true;
|
|
// });
|
|
|
|
$("#searchList").submit();
|
|
});
|
|
|
|
|
|
var name2="<?php if(!empty($dis)){echo $dis;}?>";
|
|
$("#historytable").tableExport({
|
|
bootstrap: true,
|
|
separator: ",",
|
|
headings: true,
|
|
buttonContent: "Export",
|
|
addClass: "",
|
|
defaultClass: "btn",
|
|
defaultTheme: "btn-default",
|
|
type: "csv",
|
|
fileName: name2,
|
|
position: "bottom",
|
|
stripQuotes: true
|
|
});
|
|
|
|
var name = "<?php echo 'Loan Report - ' . $selsource . ' for ' . $fyear;?>";
|
|
$("#monthlylistings").tableExport({
|
|
bootstrap: true,
|
|
separator: ",",
|
|
headings: true,
|
|
buttonContent: "Export",
|
|
addClass: "",
|
|
defaultClass: "btn",
|
|
defaultTheme: "btn-default",
|
|
type: "csv",
|
|
fileName: name,
|
|
position: "bottom",
|
|
stripQuotes: true
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|