{{-- div for Company --}} @php $company = DB::table('gnr_company')->where('id', Auth::user()->company_id_fk)->select('name','address')->first(); @endphp {{$company->name}}
{{$company->address}}
District and Upazila Wise Cumulative Loan Disbursement Report
{{--

Ambala Foundation

House # 67, Block # Ka, Piciculture Housing Society, Shyamoli, Dhaka- 1207

--}} {{--

Member Ledger Report

--}}
District Name : @if ($requestedDistrict != 'All') @foreach ($districtInfos as $key => $districtInfo) {{$districtInfo->name}} @endforeach @else All @endif
Thana Name : All
Reporting Date
: {{-- {{$startDate}} - {{$endDate}} --}} {{$endDate}}
Print Date
: 2026-07-22

@php // FOR THE PURPOSE OF UPDATING THE UPAZILA TABLE FOR UPAZILA CODE // $totalInfos = array(); // $upazilaCount = 0; // foreach ($districtInfos as $key => $districtInfo) { // $countUpazila = DB::table('gnr_upzilla') // ->where('districtId', $districtInfo->id) // ->count('id'); // $upazilaInfos = DB::table('gnr_upzilla') // ->where('districtId', $districtInfo->id) // ->pluck('id') // ->toArray(); // foreach ($upazilaInfos as $key => $upazilaInfo) { // ++$upazilaCount; // if ($districtInfo->id >= 1 and $districtInfo->id <= 9) { // $districtInfoId = '0'.$districtInfo->id; // if ($upazilaCount >= 1 and $upazilaCount <= 9) { // DB::table('gnr_upzilla') // ->where('id', $upazilaInfo) // ->update( // [ // 'code' => $districtInfoId.'0'.$upazilaCount // ] // ); // } // else { // DB::table('gnr_upzilla') // ->where('id', $upazilaInfo) // ->update( // [ // 'code' => $districtInfoId.$upazilaCount // ] // ); // } // } // else { // $districtInfoId = $districtInfo->id; // if ($upazilaCount >= 1 and $upazilaCount <= 9) { // DB::table('gnr_upzilla') // ->where('id', $upazilaInfo) // ->update( // [ // 'code' => $districtInfoId.'0'.$upazilaCount // ] // ); // } // else { // DB::table('gnr_upzilla') // ->where('id', $upazilaInfo) // ->update( // [ // 'code' => $districtInfoId.$upazilaCount // ] // ); // } // } // } // $upazilaCount = 0; // } @endphp @php // // dd('Wait'); // // branch id minimum is 2 and maximum is 83 // $branchStart = 71; // $branchEnd = 83; // $getAllBranchIds = DB::table('gnr_branch') // ->where('id', '>=', $branchStart) // ->where('id', '<=', $branchEnd) // ->pluck('id') // ->toArray(); // $allProCatIds = DB::table('mfn_loans_product_category') // ->pluck('id') // ->toArray(); // $allBranchCumulativeOpeningLoanAmount = array(); // $branchWiseSamitIds = array(); // $allkindOfInfos = array(); // $dataMigrationDate = '2018-10-31'; // foreach ($getAllBranchIds as $key => $getAllBranchId) { // $allBranchCumulativeOpeningLoanAmount[$getAllBranchId] = DB::table('mfn_opening_info_loan') // ->where('branchIdFk', $getAllBranchId) // ->sum('disbursedAmount'); // } // foreach ($allBranchCumulativeOpeningLoanAmount as $branchId => $singleBranchCumulativeOpeningLoanAmount) { // $distinctSamityId = DB::table('mfn_samity') // ->where([['openingDate', '<=', $dataMigrationDate]]) // ->where(function ($query) use ($dataMigrationDate) { // $query->where([['softDel', '=', 0], ['closingDate', '>=', $dataMigrationDate]]) // ->orWhere([['softDel', '=', 0], ['closingDate', '=', '0000-00-00']]) // ->orWhere([['softDel', '=', 0], ['closingDate', '=', null]]); // }) // ->where('branchId', $branchId) // ->groupBy('id') // ->pluck('id') // ->toArray(); // $toalMultiplicationNumber = sizeof($distinctSamityId) * sizeof($allProCatIds); // $dividedValuesForCumLoanAmount = $singleBranchCumulativeOpeningLoanAmount/$toalMultiplicationNumber; // foreach ($distinctSamityId as $key => $samityId) { // foreach ($allProCatIds as $key => $proCateId) { // $allkindOfInfos[$branchId.'-'.$samityId.'-'.$proCateId] = $dividedValuesForCumLoanAmount; // } // } // } // foreach ($allkindOfInfos as $branchSamityProCatIds => $allkindOfInfo) { // list($uniqueBranchId, $uniqueSamityId, $uniqueProCatId) = explode('-', $branchSamityProCatIds); // DB::table('mfn_opening_loan_info_samity_wise') // ->insert( // [ // 'branchIdFk' => $uniqueBranchId, // 'samityIdFk' => $uniqueSamityId, // 'proCatIdFk' => $uniqueProCatId, // 'cumLoanAmount' => $allkindOfInfo // ] // ); // } // dd('Success!!', 'Total data :', sizeof($allkindOfInfos), 'Branch Started From :', $branchStart, 'Branch Ended At :', $branchEnd); @endphp
{{--
--}} {{-- --}} {{-- --}} @foreach ($LoanProCatInfos as $key => $LoanProCatInfo) @if ($LoanProCatInfo->id == 1 || $LoanProCatInfo->id == 2 || $LoanProCatInfo->id == 3 || $LoanProCatInfo->id == 4) @php $totalInfos[$LoanProCatInfo->id]['loanAmount'] = 0; $totalInfos[$LoanProCatInfo->id]['currentMember'] = 0; $totalInfos[$LoanProCatInfo->id]['currentBorrower'] = 0; $totalInfos[$LoanProCatInfo->id]['curentFiscalYearloanAmount'] = 0; $totalInfos[$LoanProCatInfo->id]['curentFiscalYearBorrower'] = 0; @endphp @else @php $totalInfos[$LoanProCatInfo->id]['loanAmount'] = 0; $totalInfos[$LoanProCatInfo->id]['currentMember'] = 0; $totalInfos[$LoanProCatInfo->id]['currentBorrower'] = 0; $totalInfos[$LoanProCatInfo->id]['curentFiscalYearloanAmount'] = 0; $totalInfos[$LoanProCatInfo->id]['curentFiscalYearBorrower'] = 0; @endphp @endif @endforeach @php @endphp {{-- @foreach ($LoanProCatInfos as $key => $LoanProCatInfo) @endforeach --}} @php $serialNumber = 0; $TotalBranch = 0; $TotalAmountByRow = 0; $TotalBorrowerByRow = 0; $TotalLoanAmount = 0; $TotalCurrentBorrower = 0; $TotalAmountByColumn = array(); $TotalBorrowerByColumn = array(); $branchIN = array(); $districtCounter = 0; $cumulativeLoanDisbursementOthers = 0; $currentMemberOthers = 0; $currentBorrowerOthers = 0; $LoanDisbursedInCurrentFYothers = 0; $NumberOfBorrowersRevealedLoanInCurrentFYothers = 0; $totalCumulativeLoanDisbursement= 0; $totalCurrentMember= 0; $totalCurrentBorrower= 0; $totalLoanDisbursedInCurrentFY= 0; $totalNumberOfBorrowersRevealedLoanInCurrentFY= 0; $poCounter = 0; $totalCounter = 0; // dd($districtInfos, $ThanaOrupazilaInfos, $branchInfos); $totalLoanAmountCount = 0; @endphp @foreach ($ThanaOrupazilaInfos as $districtIdKey => $ThanaOrupazilaInfo) @php $districtCounter = 0; @endphp @foreach ($ThanaOrupazilaInfo as $key => $ThanaOrupazila) @if ($poCounter == 0) @php $poCounter = 1; @endphp @endif @foreach ($districtInfos as $districtInfo) @if ($districtInfo->id == $districtIdKey and $districtCounter == 0) @php $districtCounter = 1; @endphp @endif @endforeach @php $upzilaName = DB::table('gnr_upzilla')->where('id', $ThanaOrupazila->upazilaId)->value('name'); $upzilaCode = DB::table('gnr_upzilla')->where('id', $ThanaOrupazila->upazilaId)->value('code'); @endphp @foreach ($branchInfos as $upazilaIdKey => $branchInfo) @if ($upazilaIdKey == $ThanaOrupazila->upazilaId) @foreach ($branchInfo as $proCatKey => $branchValue) @php $totalLoanAmountCount += $branchValue['loanAmount']; @endphp @if ($proCatKey == 1 || $proCatKey == 2 || $proCatKey == 3 || $proCatKey == 4) @else @php $cumulativeLoanDisbursementOthers = $cumulativeLoanDisbursementOthers + $branchValue['loanAmount']; $currentMemberOthers = $currentMemberOthers + $branchValue['currentMember']; $currentBorrowerOthers = $currentBorrowerOthers + $branchValue['currentBorrower']; $LoanDisbursedInCurrentFYothers = $LoanDisbursedInCurrentFYothers + $branchValue['curentFiscalYearloanAmount']; $NumberOfBorrowersRevealedLoanInCurrentFYothers = $NumberOfBorrowersRevealedLoanInCurrentFYothers + $branchValue['curentFiscalYearBorrower']; @endphp @endif @php $totalCumulativeLoanDisbursement= $totalCumulativeLoanDisbursement + $branchValue['loanAmount']; $totalCurrentMember= $totalCurrentMember + $branchValue['currentMember']; $totalCurrentBorrower= $totalCurrentBorrower + $branchValue['currentBorrower']; $totalLoanDisbursedInCurrentFY= $totalLoanDisbursedInCurrentFY + $branchValue['curentFiscalYearloanAmount']; $totalNumberOfBorrowersRevealedLoanInCurrentFY= $totalNumberOfBorrowersRevealedLoanInCurrentFY + $branchValue['curentFiscalYearBorrower']; $totalInfos[$proCatKey]['loanAmount'] = $totalInfos[$proCatKey]['loanAmount'] + $branchValue['loanAmount']; $totalInfos[$proCatKey]['currentMember'] = $totalInfos[$proCatKey]['currentMember'] + $branchValue['currentMember'];; $totalInfos[$proCatKey]['currentBorrower'] = $totalInfos[$proCatKey]['currentBorrower'] + $branchValue['currentBorrower']; $totalInfos[$proCatKey]['curentFiscalYearloanAmount'] = $totalInfos[$proCatKey]['curentFiscalYearloanAmount'] + $branchValue['curentFiscalYearloanAmount']; $totalInfos[$proCatKey]['curentFiscalYearBorrower'] = $totalInfos[$proCatKey]['curentFiscalYearBorrower'] + $branchValue['curentFiscalYearBorrower']; @endphp @endforeach @endif @endforeach @php $cumulativeLoanDisbursementOthers = 0; $currentMemberOthers = 0; $currentBorrowerOthers = 0; $LoanDisbursedInCurrentFYothers = 0; $NumberOfBorrowersRevealedLoanInCurrentFYothers = 0; $totalCumulativeLoanDisbursement= 0; $totalCurrentMember= 0; $totalCurrentBorrower= 0; $totalLoanDisbursedInCurrentFY= 0; $totalNumberOfBorrowersRevealedLoanInCurrentFY= 0; @endphp @endforeach @endforeach @php $othersTotalLoanAmount = 0; $othersTotalCurrentMember = 0; $othersTotalCurrentBorrower = 0; $othersTotalCurentFiscalYearloanAmount = 0; $othersTotalCurentFiscalYearBorrower = 0; $cummulativeTotalLoanAmount = 0; $cummulativeTotalCurrentMember = 0; $cummulativeTotalCurrentBorrower = 0; $cummulativeTotalCurentFiscalYearloanAmount = 0; $cummulativeTotalCurentFiscalYearBorrower = 0; @endphp @foreach ($totalInfos as $productKey => $totalInfo) @if ($productKey == 1 || $productKey == 2 || $productKey == 3 || $productKey == 4) @else @php $othersTotalLoanAmount = $othersTotalLoanAmount + $totalInfo['loanAmount']; $othersTotalCurrentMember = $othersTotalCurrentMember + $totalInfo['currentMember']; $othersTotalCurrentBorrower = $othersTotalCurrentBorrower + $totalInfo['currentBorrower']; $othersTotalCurentFiscalYearloanAmount = $othersTotalCurentFiscalYearloanAmount + $totalInfo['curentFiscalYearloanAmount']; $othersTotalCurentFiscalYearBorrower = $othersTotalCurentFiscalYearBorrower + $totalInfo['curentFiscalYearBorrower']; @endphp @endif @php $cummulativeTotalLoanAmount = $cummulativeTotalLoanAmount + $totalInfo['loanAmount']; $cummulativeTotalCurrentMember = $cummulativeTotalCurrentMember + $totalInfo['currentMember']; $cummulativeTotalCurrentBorrower = $cummulativeTotalCurrentBorrower + $totalInfo['currentBorrower']; $cummulativeTotalCurentFiscalYearloanAmount = $cummulativeTotalCurentFiscalYearloanAmount + $totalInfo['curentFiscalYearloanAmount']; $cummulativeTotalCurentFiscalYearBorrower = $cummulativeTotalCurentFiscalYearBorrower + $totalInfo['curentFiscalYearBorrower']; @endphp @endforeach
PO
District
No. Of Branch
Thana/Upozilla
Component
{{$LoanProCatInfo->shortName}}
Others
Total
PO Code PO Name District Code District Name Upazilla/ Ward Code Upazilla/ Ward Name
{{$LoanProCatInfo->shortName}}
Cumulative Loan Disbursement Current Member Current Borrower Loan Disbursed in current FY Number of Borrowers Revealed Loan in Current FY Cumulative Loan Disbursement Current Member Current Borrower Loan Disbursed in current FY Number of Borrowers Revealed Loan in Current FY Cumulative Loan Disbursement Current Member Current Borrower Loan Disbursed in current FY Number of Borrowers Revealed Loan in Current FY Cumulative Loan Disbursement Current Member Current Borrower Loan Disbursed in current FY Number of Borrowers Revealed Loan in Current FY Cumulative Loan Disbursement Current Member Current Borrower Loan Disbursed in Current FY Number of Borrowers Revealed Loan in Current FY Cumulative Loan Disbursement Current Member Current Borrower Loan Disbursed in Current FY Number of Borrowers Revealed Loan in Current FY
{{DB::table('gnr_company')->value('poCode')}} {{DB::table('gnr_company')->value('name')}}{{str_pad($districtInfo->code,2,0,STR_PAD_LEFT)}} {{$districtInfo->name}} {{str_pad($upzilaCode,4,0,STR_PAD_LEFT)}} {{$upzilaName}}{{number_format($branchValue['loanAmount'], 2)}} {{$branchValue['currentMember']}} {{$branchValue['currentBorrower']}} {{number_format($branchValue['curentFiscalYearloanAmount'], 2)}} {{$branchValue['curentFiscalYearBorrower']}}{{number_format($cumulativeLoanDisbursementOthers, 2)}} {{$currentMemberOthers}} {{$currentBorrowerOthers}} {{number_format($LoanDisbursedInCurrentFYothers, 2)}} {{$NumberOfBorrowersRevealedLoanInCurrentFYothers}} {{number_format($totalCumulativeLoanDisbursement, 2)}} {{$totalCurrentMember}} {{$totalCurrentBorrower}} {{number_format($totalLoanDisbursedInCurrentFY, 2)}} {{$totalNumberOfBorrowersRevealedLoanInCurrentFY}}
Total{{number_format($totalInfo['loanAmount'], 2)}} {{$totalInfo['currentMember']}} {{$totalInfo['currentBorrower']}} {{number_format($totalInfo['curentFiscalYearloanAmount'], 2)}} {{$totalInfo['curentFiscalYearBorrower']}}{{number_format($othersTotalLoanAmount, 2)}} {{$othersTotalCurrentMember}} {{$othersTotalCurrentBorrower}} {{number_format($othersTotalCurentFiscalYearloanAmount, 2)}} {{$othersTotalCurentFiscalYearBorrower}} {{number_format($cummulativeTotalLoanAmount, 2)}} {{$cummulativeTotalCurrentMember}} {{$cummulativeTotalCurrentBorrower}} {{number_format($cummulativeTotalCurentFiscalYearloanAmount, 2)}} {{$cummulativeTotalCurentFiscalYearBorrower}}

* Double counting is avoided in all cases no of branches.
@php // dd($branchIN); echo 'Total Loan Amount : '.$totalLoanAmountCount; @endphp
Prepared By :
Signature :
Designation :
Verified By :
Signature :
Designation :
Approved By :
Signature :
Designation: :