@foreach ($savingsProducts as $savingsProduct) @endforeach @php $totalmember =0; $a=1; $i=1; // $grandTotal = 0; $TotaladitionalFree = 0; $totaldisbursmentNosum = 0; $disbursmenamounttsum = 0; $tCfullyPaidNo = 0; $cumexperidedTAmount = 0; $totalCurrentLoanNumber = 0; $totalCurrentLoanAmount = 0; $savingsTotal = 0; $grandtotal = array(); $totalCuExpiredAmount =0; $totaloutstanding = 0; @endphp @foreach($allsamity as $value => $samity) @php $TotalLoanSecurity = 0; // $countRow = $sumLoanProduct; //Sub Total $subtotal =array(); $savingsDepositeSubTotal =array(); $interestSavingSubTotal =array(); $savingsRefundSubTotal =array(); $advanceSubtotal = 0; $insClimeSubTotal = 0; $samityKey = 0; $total = 0; $grandTotal= 0; $sum = 0; @endphp @php // $samityCount = $samityCount + $samity->id; $memberinfo = DB::table('mfn_member_information') ->where('samityId',$samity->id) ->where('softDel',0) ->count(); $memberids = DB::table('mfn_member_information') ->pluck('id') ->toArray(); // dd($memberids); $monthLastDate = $monthLastDate; $firstDate = $monthFirstDate; $totaldisbursmentNo = DB::table('mfn_loan') ->where('samityIdFk',$samity->id) ->where('disbursementDate','>=',$monthFirstDate->format('Y-m-d')) ->where('disbursementDate','<=',$monthLastDate) ->where('softDel',0) // ->whereIn('memberIdFk',$memberids) ->count(); // print_r($totaldisbursmentNo); $totaldisbursmentNosum = $totaldisbursmentNosum + $totaldisbursmentNo; $disbusmentAmount = DB::table('mfn_loan') ->where('samityIdFk',$samity->id) ->where('disbursementDate','>=',$monthFirstDate->format('Y-m-d')) ->where('disbursementDate','<=',$monthLastDate) ->where('softDel',0) ->sum('loanAmount'); $disbursmenamounttsum = $disbursmenamounttsum + $disbusmentAmount; $cumexperidedNumber = DB::select("SELECT `loanIdFk` FROM `mfn_loan_schedule` as t1 WHERE (SELECT MAX(`scheduleDate`) FROM mfn_loan_schedule as t2 WHERE t1.`loanIdFk`=t2.`loanIdFk`) < ? AND `isCompleted` = ? GROUP BY `loanIdFk`",[$monthFirstDate->format('Y-m-d'),0]); $tCfullyPaidNo = $tCfullyPaidNo + count($cumexperidedNumber); // echo $tCfullyPaidNo; $cumexperidedAmount = DB::table('mfn_loan_collection') ->select('amount') ->where('samityIdFk', $samity->id) ->whereIn('memberIdFk', $memberids) ->where('softDel',0) // ->whereIn('loanIdFk', $cumexperidedNumber) ->sum('amount'); $cumexperidedTAmount = $cumexperidedTAmount + $cumexperidedAmount; $totalCuExpiredAmount = $totalCuExpiredAmount + $cumexperidedTAmount; // echo $cumexperidedTAmount; $aditionalFree = DB::table('mfn_loan') ->where('samityIdFk',$samity->id) // ->where('productIdFk',$loanProduct) ->where('disbursementDate','>=',$monthFirstDate->format('Y-m-d')) ->where('disbursementDate','<=',$monthLastDate) ->where('softDel',0) ->sum('additionalFee'); $CurrentLoanAmount = $disbusmentAmount - $disbusmentAmount- $cumexperidedAmount; $TotaladitionalFree = $TotaladitionalFree + $aditionalFree; // echo $TotaladitionalFree; $sum = $sum + $a; $totalmember = $totalmember + $memberinfo; $CurrentLoanNo = $totaldisbursmentNo - $totaldisbursmentNo - count($cumexperidedNumber); // Total Current Loan Number $totalCurrentLoanNumber = $totalCurrentLoanNumber + $CurrentLoanNo ; // Current Loan Amount $totalCurrentLoanAmount = $totalCurrentLoanAmount + $CurrentLoanAmount ; @endphp @php $savingsProducts = DB::table('mfn_saving_product') ->select('id','shortName') ->get(); // $outstanding1 = DB::table('mfn_loan') // ->where('disbursementDate','>=',$monthFirstDate->format('Y-m-d')) // ->where('disbursementDate','<=',$monthLastDate) // ->sum('totalRepayAmount'); // $loanId = DB::select("SELECT t1.id FROM `mfn_loan` as t1 // JOIN mfn_loan_schedule as t2 ON t1.id = t2.loanIdFk // WHERE t1.loanCompletedDate >=? // AND t2.scheduleDate = (SELECT MAX(scheduleDate) FROM mfn_loan_schedule WHERE loanIdFk = t2.loanIdFk) // AND t1.softDel = ?",[$monthFirstDate->format('Y-m-d'),0]); // $loanId =collect($loanId) // ->pluck('id') // ->toArray(); $outstanding1 = DB::table('mfn_loan') ->where('samityIdFk',$samity->id) // ->where('productIdFk',$loanProduct) ->where('disbursementDate','<',$monthFirstDate->format('Y-m-d')) ->where('softDel',0) ->sum('totalRepayAmount'); $outstanding2 = DB::table('mfn_loan_collection') ->where('samityIdFk',$samity->id) // ->whereIn('loanIdFk',$loanId) ->where('collectionDate','<',$monthFirstDate->format('Y-m-d')) ->where('softDel',0) ->sum('amount'); $outstandingamount = $outstanding1 - $outstanding2; $totaloutstanding = $totaloutstanding + $outstandingamount; // echo $outstandingamount; @endphp @foreach($savingsProducts as $key=>$savingsProduct) @php $productId = DB::table('mfn_saving_product') ->select('id') ->where('softDel',0) ->get(); $insuranceAmount = DB::table('mfn_loan') ->where('samityIdFk',$samity->id) ->where('productIdFk',$savingsProduct->id) ->where('disbursementDate','>=',$monthFirstDate ->format('Y-m-d')) ->where('disbursementDate','<=',$monthLastDate) ->where('softDel',0) ->sum('insuranceAmount'); $TotalLoanSecurity = $TotalLoanSecurity + $insuranceAmount; $savingsdeposit = DB::table('mfn_savings_deposit') ->where('samityIdFk',$samity->id) ->where('productIdFk',$savingsProduct->id) ->where('depositDate','>=',$monthFirstDate->format('Y-m-d')) ->where('depositDate','<=',$monthLastDate) ->where('softDel',0) ->sum('amount'); // echo $savingsdeposit; if(isset($grandtotal[$key])) { $grandtotal[$key] = $grandtotal[$key] + $savingsdeposit; // echo $grandtotal[$key]; } else{ $grandtotal[$key] = $savingsdeposit; } $total = $total + $savingsdeposit; $savingsTotal += $savingsdeposit; $InterestSaving = DB::table('mfn_savings_interest') ->where('samityIdFk',$samity->id) ->where('date','>=',$year) ->where('date','<=',$week) ->sum('interestAmount'); @endphp @endforeach @endforeach {{-- Total Amount --}} @if (isset($sum)) @endif @if (isset($totalmember)) @endif @foreach($savingsProducts as $key=>$savingsProduct) @php $savingsdeposit = DB::table('mfn_savings_deposit') ->where('samityIdFk',$samity->id) ->where('productIdFk',$savingsProduct->id) ->where('depositDate','>=',$monthFirstDate ->format('Y-m-d')) ->where('depositDate','<=',$monthLastDate) ->where('softDel',0) ->sum('amount'); @endphp @if(isset($grandtotal[$key])) @else @endif @endforeach @if(isset($savingsTotal)) @else @endif @if (isset($totaldisbursmentNosum)) @endif @if (isset($disbursmenamounttsum)) @endif @if (isset($totaldisbursmentNosum)) @endif @if (isset($disbursmenamounttsum)) @endif @if (isset($tCfullyPaidNo)) @endif @if (isset($cumexperidedTAmount)) @endif @if (isset( $totalCurrentLoanNumber)) @endif @if (isset( $totalCurrentLoanAmount)) @endif @if (isset($totaloutstanding)) @else @endif @if (isset($TotalLoanSecurity)) @endif
Field Officer ID : @if (isset($fieldofficer->emp_id)) {{$fieldofficer->emp_id}} @endif
Field Officer Name : @if (isset($fieldofficer->emp_id)) {{$fieldofficer->emp_name_english}} @endif
SL. No.
Samity Code
Samity Name
Beginning of The Week
Member
Savings
Total Cum. Disburse No
Total Cum. Disbursement
Cum. Fully Paid No
Cum. Fully Paid Amount
Cum. Expired Loan No
Cum. Expired Loan Amount
Current Loan No
Current Loan Amount
Total Due
Outstanding
Loan security
Additional Fee Collection
{{$savingsProduct->shortName}}
Total
Current
Expired
No.
Amount
No
Amount
{{$a++}} {{$samity->code}} {{$samity->name}} {{$memberinfo}} {{number_format($savingsdeposit,2)}}
** {{number_format($InterestSaving ,2)}}
{{ number_format($total,2)}} {{ $totaldisbursmentNo }} {{ number_format($disbusmentAmount,2)}} {{ $totaldisbursmentNo }} {{ number_format($disbusmentAmount,2)}} {{ count($cumexperidedNumber)}} {{$cumexperidedAmount}} {{$CurrentLoanNo}} {{ number_format($CurrentLoanAmount,2)}} {{$CurrentLoanNo}} {{ number_format($CurrentLoanAmount,2)}} {{ count($cumexperidedNumber)}} {{number_format($cumexperidedAmount,2)}} {{ number_format( $outstandingamount,2)}} {{ number_format( $insuranceAmount,2)}} {{ number_format($aditionalFree,2) }}
Total {{ $sum}} {{ $totalmember}} {{number_format($grandtotal[$key],2)}} {{number_format(0,2)}} {{number_format($savingsTotal,2)}} {{number_format(0,2)}} {{ $totaldisbursmentNosum }} {{ number_format($disbursmenamounttsum,2)}} {{ $totaldisbursmentNosum}} {{ number_format($disbursmenamounttsum,2)}} {{$tCfullyPaidNo}} {{ $cumexperidedTAmount}} {{ $totalCurrentLoanNumber }} {{ $totalCurrentLoanAmount }} {{number_format($totaloutstanding,2)}} {{number_format(0,2)}} {{ $TotalLoanSecurity }} {{ number_format($TotaladitionalFree,2) }}
{{-- Part B --}}