@extends('layouts/acc_layout') @section('title', '| Register Report') @section('content') @php $projectSelected = isset($_GET['searchProject']) ? $_GET['searchProject'] : null; $projectTypeSelected = isset($_GET['searchProjectType']) ? $_GET['searchProjectType'] : null; $donorTypeSelected = isset($_GET['searchDonorType']) ? $_GET['searchDonorType'] : null; $dateSelected = isset($_GET['searchDate']) ? $_GET['searchDate'] : null; $firstRequest = isset($_GET['firstRequest']) ? '1' : '0'; @endphp

Loan Register Installment Report

{{--
kxghixd
--}}
{!! Form::open(['url' => 'loanRegisterInstallmentReport','method' => 'get']) !!} {!! Form::hidden('firstRequest',1) !!}
{!! Form::label('', 'Project:', ['class' => 'control-label pull-left']) !!}
@php $acticeProjectforSearch = DB::table('acc_loan_register_account')->pluck('projectId_fk')->toArray(); $searchProjects = DB::table('gnr_project')->whereIn('id',$acticeProjectforSearch)->select('id','name','projectCode')->get(); @endphp
{!! Form::label('', 'Project Type:', ['class' => 'control-label pull-left']) !!}
@php $acticeProjectTypesforSearch = DB::table('acc_loan_register_account')->distinct()->pluck('projectTypeId_fk')->toArray(); $searchProjectTypes = DB::table('gnr_project_type')->whereIn('id',$acticeProjectTypesforSearch); if($projectSelected!=null){ $searchProjectTypes = $searchProjectTypes->where('projectId',$projectSelected); } $searchProjectTypes = $searchProjectTypes->select('id','name','projectTypeCode')->get(); @endphp
{!! Form::label('', 'Donor Type:', ['class' => 'control-label pull-left']) !!}
{!! Form::select('searchDonorType',[''=>'All','0'=>'Bank','1'=>'Donor'],$donorTypeSelected,['class'=>'form-control']) !!}
{!! Form::label('', 'Month:', ['class' => 'control-label pull-left']) !!}
{!! Form::text('searchDateReplica',null,['id'=>'searchDateReplica','placeholder'=>'From','class'=>'form-control input-sm','readonly','style'=>'cursor:pointer']) !!} {!! Form::hidden('searchDate',null,['id'=>'searchDate']) !!}
{!! Form::submit('Search',['id'=>'search','class'=>'btn btn-primary btn-xs','style'=>'font-size:15px;']) !!}
{!! Form::close() !!}
{{-- End Filtering Group --}} @if($firstRequest)

@php $gTloanAmount = 0; $gTinstallmentSize = 0; $gTloanAmount = 0; $gTcurrentMonthPayment = 0; $gTcurrentMonthDue = 0; @endphp @foreach($projectTypes as $projectType) @php $index = 0; $sTloanAmount = 0; $sTinstallmentSize = 0; $sTcurrentMonthPayment = 0; $sTcurrentMonthDue = 0; @endphp @foreach($accounts as $key => $account) @if($account->projectTypeId_fk==$projectType->id) @php $bankName = DB::table('gnr_bank')->where('id',$account->bankId_fk)->value('name'); if ($account->phase>0) { $accNoPhaseCycleValue = "- / ".str_pad($account->phase,3,'0',STR_PAD_LEFT)." / ".str_pad($account->cycle,3,'0',STR_PAD_LEFT); } else{ $accNoPhaseCycleValue = $account->accNo." / - / -"; } $startDate = date("Y-m-d", strtotime($dateSelected)); $endDate = date("Y-m-t", strtotime($startDate)); $installmentSize = (float) DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->value('totalAmount'); $installmentDate = DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->value('paymentDate'); if ($installmentDate==null) { $installmentDate = "-"; } else{ $installmentDate = date('d-m-Y',strtotime($installmentDate)); } $paymentDateInThisMonth = DB::table('acc_loan_register_payments')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->orderBy('id','desc')->value('paymentDate'); if ($paymentDateInThisMonth==null) { $paymentDateInThisMonth = "-"; } else{ $paymentDateInThisMonth = date('d-m-Y',strtotime($paymentDateInThisMonth)); } $paymentAmountInThisMonth = (float) DB::table('acc_loan_register_payments')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('totalAmount'); $thisMonthDue = $installmentSize - $paymentAmountInThisMonth; @endphp @php $count = 1; $isChanged = 0; if ($key>0) { if ($accounts[$key-1]->bankId_fk!=$account->bankId_fk) { $isChanged = 1; } } if ($key == 0 || $isChanged == 1) { $count = DB::table('acc_loan_register_account')->whereIn('bankId_fk',$bankIds)->whereIn('id',$accountListHavingInstallment); if ($projectSelected!=null) { $count = $count->where('projectId_fk',$projectSelected); } if ($projectTypeSelected!=null) { $count = $count->where('projectTypeId_fk',$projectTypeSelected); } $count = $count->where('bankId_fk',$account->bankId_fk)->count(); } @endphp @if($isChanged==1 || $key==0) @endif {{-- --}} @php $sTloanAmount = $sTloanAmount + $account->loanAmount; $sTinstallmentSize = $sTinstallmentSize + $installmentSize; $sTcurrentMonthPayment = $sTcurrentMonthPayment + $paymentAmountInThisMonth; $sTcurrentMonthDue = $sTcurrentMonthDue + $thisMonthDue; @endphp @endif @endforeach {{-- Account --}} @php $gTloanAmount = $gTloanAmount + $sTloanAmount; $gTinstallmentSize = $gTinstallmentSize + $sTinstallmentSize; $gTcurrentMonthPayment = $gTcurrentMonthPayment + $sTcurrentMonthPayment; $gTcurrentMonthDue = $gTcurrentMonthDue + $sTcurrentMonthDue; @endphp @endforeach {{-- Project Type --}}
SL# Bank/Donar Account No / Phase/ Cycle Loan Amount Installment Size Current Month Loan Installment Current Month Loan Installment Re-Payment Current Month Loan
Installment Due (Tk)
Date Amount (Tk) Date Amount (Tk)
{{$projectType->name}}
{{++$index}}{{$bankName}}{{$bankName}}{{$accNoPhaseCycleValue}} {{number_format($account->loanAmount,2,'.',',')}} {{number_format($installmentSize,2,'.',',')}} {{$installmentDate}} {{number_format($installmentSize,2,'.',',')}} {{$paymentDateInThisMonth}} {{number_format($paymentAmountInThisMonth,2,'.',',')}} {{number_format($thisMonthDue,2,'.',',')}}
Sub Total {{number_format($sTloanAmount,2,'.',',')}} {{number_format($sTinstallmentSize,2,'.',',')}} {{number_format($sTinstallmentSize,2,'.',',')}} {{number_format($sTcurrentMonthPayment,2,'.',',')}} {{number_format($sTcurrentMonthDue,2,'.',',')}}
Total {{number_format($gTloanAmount,2,'.',',')}} {{number_format($gTinstallmentSize,2,'.',',')}} {{number_format($gTinstallmentSize,2,'.',',')}} {{number_format($gTcurrentMonthPayment,2,'.',',')}} {{number_format($gTcurrentMonthDue,2,'.',',')}}
@endif