@php $savingBalanceColspan = sizeof($data['savingProducts']); $savingProducts = $data['savingProducts']; $loans = $data['loans']; $loanArrayData = $data['loanArrayData']; $samitys = $data['samitys']; $member = $data['member']; $loanProducts = $data['loanProducts']; $loanCategories = $data['loanCategories']; $loanInfo = $data['loanInfo']; $savingsDeposits = $data['savingsDeposits']; $savingsWithdraws = $data['savingsWithdraws']; $primmaryProductIds = $data['primmaryProductIds']; $openingSavingsInfo = $data['openingSavingsInfo']; $savingProducts = $data['savingProducts']; $loanProductCategoryType = $data['loanProductCategoryType']; @endphp @php $cc = 0; // stotal $loanCategoryInfo = []; $loanProductInfo = []; $sToutstandingAmount = 0; $sTdueAmount = 0; foreach ($savingProducts as $singleItem) { ${'sT' . $singleItem->shortName} = 0; } $sTsavingsBalance = 0; $sTmemberClaim = 0; $sTorgClaim = 0; @endphp @foreach ($branchMapingDataWithType['data'] as $key => $cdata) @if($branchMapingDataWithType['type']== 'area' ) @foreach($cdata['child'] as $key1 => $childData ) @if(count($loanArrayData->where('branchIdFk',$childData)) > 0) @php $slNo = 0; $currentSamityId = isset($samitys[0]) ? $samitys[0]->id : null; $isSamityChanged = 0; $gToutstandingAmount = 0; $gTdueAmount = 0; $isv = 0; foreach($savingProducts as $singleItem){ ${"gT" . $singleItem->shortName} = 0; $subtotal['savingsBalance'][$isv]= 0; $isv++; } $gTsavingsBalance = 0; $gTmemberClaim = 0; $gTorgClaim = 0; // =========== subtotal ========== $subtotal['loanAmount']= 0; $subtotal['outstandingAmount']= 0; $subtotal['dueAmount']= 0; $subtotal['savingsBalance']['total']= 0; $subtotal['member']= 0; $subtotal['organization']= 0; @endphp @php $currentLoans = $loanArrayData->where('branchIdFk',$childData); @endphp @foreach ($currentLoans as $loan) @php $cc++; //subtoal $loan =(object)$loan; $subtotal['loanAmount'] += $loan->loanAmount; $subtotal['outstandingAmount'] += $loan->outstandingAmount; $subtotal['dueAmount'] += $loan->dueAmount; //grandtotal // $grandtotal['loanAmount'] += $subtotal['loanAmount']; // $grandtotal['outstandingAmount'] += $subtotal['outstandingAmount']; // $grandtotal['dueAmount'] += $subtotal['dueAmount']; @endphp {{ $cc }} @if($branchMapingDataWithType['type']== 'area' ) {{ $cdata['name'] }} @endif {{ $zoneareaList[$childData]}} {{$loan->creditOfficerName}} {{$loan->memberCode}} {{$loan->memberName}} {{$loan->productName}} {{$loan->loanCode}} {{date('d-m-Y',strtotime($loan->loanDisbursedDate))}} {{number_format($loan->loanAmount)}} {{number_format($loan->outstandingAmount)}} {{number_format($loan->dueAmount)}} @php $memberTotalSavings = 0; $sv = 0; @endphp @foreach ($loan->savingsBalances as $svkey => $svRow) {{$svRow}} @php $subtotal['savingsBalance'][$sv] += $svRow; $memberTotalSavings += $svRow; $sv++; @endphp @endforeach @php //subtotal $subtotal['savingsBalance']['total'] += $memberTotalSavings; $subtotal['member'] += $loan->memberClaim; $subtotal['organization'] +=$loan->organizationClaim; //grandtotal // $grandtotal['savingsBalance']['total'] += $subtotal['savingsBalance']['total']; // $grandtotal['member'] += $subtotal['member']; // $grandtotal['organization'] += $subtotal['organization']; @endphp {{ number_format($loan->savingsBalanceTotal) }} {{ number_format($loan->memberClaim) }} {{ number_format($loan->organizationClaim) }} @php $sToutstandingAmount = $sToutstandingAmount + $loan->outstandingAmount; $sTdueAmount = $sTdueAmount + $loan->dueAmount; $sTsavingsBalance = $sTsavingsBalance + $loan->savingsBalanceTotal; $sTmemberClaim = $sTmemberClaim + $loan->memberClaim; $sTorgClaim = $sTorgClaim + $loan->organizationClaim; // store information for loan product $categoryId = $loanProducts->where('id',$loan->primaryProductIdFk)->max('productCategoryId'); $data = array( 'loanCategoryId' => $categoryId, 'disbursementAmount' => $loan->loanAmount, 'outstandingAmount' =>$loan->outstandingAmount, 'dueAmount' => $loan->dueAmount, 'savingsBalance' => $loan->savingsBalanceTotal, 'memberClaim' => $loan->memberClaim, 'organizationClaim' =>$loan->organizationClaim, ); array_push($loanCategoryInfo,$data); // store information for loan product $pdata = array( 'loanProductId' => $loan->primaryProductIdFk, 'disbursementAmount' => $loan->loanAmount, 'outstandingAmount' =>$loan->outstandingAmount, 'dueAmount' => $loan->dueAmount, 'savingsBalance' => $loan->savingsBalanceTotal, 'memberClaim' => $loan->memberClaim, 'organizationClaim' => $loan->organizationClaim, ); array_push($loanProductInfo,$pdata); @endphp @endforeach Subtotal {{ number_format($subtotal['loanAmount']) }} {{ number_format($subtotal['outstandingAmount']) }} {{ number_format($subtotal['dueAmount']) }} @foreach ($savingProducts as $skey => $item) {{ number_format($subtotal['savingsBalance'][$skey]) }} @endforeach {{ number_format($subtotal['savingsBalance']['total']) }} {{ number_format($subtotal['member']) }} {{ number_format($subtotal['organization']) }} @endif @endforeach @endif @if($branchMapingDataWithType['type']== 'zone' ) @php // =========== subtotal ========== $subtotal['loanAmount']= 0; $subtotal['outstandingAmount']= 0; $subtotal['dueAmount']= 0; $isv = 0; foreach($savingProducts as $singleItem){ $subtotal['savingsBalance'][$isv]= 0; $isv++; } $subtotal['savingsBalance']['total']= 0; $subtotal['member']= 0; $subtotal['organization']= 0; @endphp @foreach($cdata['child'] as $key1 => $childData ) @if(isset($cdata['data']['area'][$childData])) @foreach($cdata['data']['area'][$childData]['child'] as $branchkey => $branchChildData ) @if( count($loanArrayData->where('branchIdFk',$branchChildData)) > 0) @php $slNo = 0; $currentSamityId = isset($samitys[0]) ? $samitys[0]->id : null; $isSamityChanged = 0; $gToutstandingAmount = 0; $gTdueAmount = 0; foreach($savingProducts as $singleItem){ ${"gT" . $singleItem->shortName} = 0; } $gTsavingsBalance = 0; $gTmemberClaim = 0; $gTorgClaim = 0; @endphp @php $currentLoans = $loanArrayData->where('branchIdFk',$branchChildData); @endphp @foreach ($currentLoans as $loan) @php $cc++; //subtoal $loan =(object)$loan; $subtotal['loanAmount'] += $loan->loanAmount; $subtotal['outstandingAmount'] += $loan->outstandingAmount; $subtotal['dueAmount'] += $loan->dueAmount; //grandtotal // $grandtotal['loanAmount'] += $subtotal['loanAmount']; // $grandtotal['outstandingAmount'] += $subtotal['outstandingAmount']; // $grandtotal['dueAmount'] += $subtotal['dueAmount']; @endphp {{ $cc }} @if($branchMapingDataWithType['type']== 'zone' ) {{$cdata['name']}} {{ $cdata['data']['area'][$childData]['name'] }} @endif {{ $zoneareaList[$branchChildData]}} {{$loan->creditOfficerName}} {{$loan->memberCode}} {{$loan->memberName}} {{$loan->productName}} {{$loan->loanCode}} {{date('d-m-Y',strtotime($loan->loanDisbursedDate))}} {{number_format($loan->loanAmount)}} {{number_format($loan->outstandingAmount)}} {{number_format($loan->dueAmount)}} @php $memberTotalSavings = 0; $sv = 0; @endphp @foreach ($loan->savingsBalances as $svkey => $svRow) {{$svRow}} @php $subtotal['savingsBalance'][$sv] += $svRow; $memberTotalSavings += $svRow; $sv++; @endphp @endforeach @php //subtotal $subtotal['savingsBalance']['total'] += $memberTotalSavings; $subtotal['member'] += $loan->memberClaim; $subtotal['organization'] +=$loan->organizationClaim; //grandtotal // $grandtotal['savingsBalance']['total'] += $subtotal['savingsBalance']['total']; // $grandtotal['member'] += $subtotal['member']; // $grandtotal['organization'] += $subtotal['organization']; @endphp {{ number_format($loan->savingsBalanceTotal) }} {{ number_format($loan->memberClaim) }} {{ number_format($loan->organizationClaim) }} @php $sToutstandingAmount = $sToutstandingAmount + $loan->outstandingAmount; $sTdueAmount = $sTdueAmount + $loan->dueAmount; $sTsavingsBalance = $sTsavingsBalance + $loan->savingsBalanceTotal; $sTmemberClaim = $sTmemberClaim + $loan->memberClaim; $sTorgClaim = $sTorgClaim + $loan->organizationClaim; // store information for loan product $categoryId = $loanProducts->where('id',$loan->primaryProductIdFk)->max('productCategoryId'); $data = array( 'loanCategoryId' => $categoryId, 'disbursementAmount' => $loan->loanAmount, 'outstandingAmount' =>$loan->outstandingAmount, 'dueAmount' => $loan->dueAmount, 'savingsBalance' => $loan->savingsBalanceTotal, 'memberClaim' => $loan->memberClaim, 'organizationClaim' =>$loan->organizationClaim, ); array_push($loanCategoryInfo,$data); // store information for loan product $pdata = array( 'loanProductId' => $loan->primaryProductIdFk, 'disbursementAmount' => $loan->loanAmount, 'outstandingAmount' =>$loan->outstandingAmount, 'dueAmount' => $loan->dueAmount, 'savingsBalance' => $loan->savingsBalanceTotal, 'memberClaim' => $loan->memberClaim, 'organizationClaim' => $loan->organizationClaim, ); array_push($loanProductInfo,$pdata); @endphp @endforeach Subtotal {{ number_format($subtotal['loanAmount']) }} {{ number_format($subtotal['outstandingAmount']) }} {{ number_format($subtotal['dueAmount']) }} @foreach ($savingProducts as $skey => $item) {{ number_format($subtotal['savingsBalance'][$skey]) }} @endforeach {{ number_format($subtotal['savingsBalance']['total']) }} {{ number_format($subtotal['member']) }} {{ number_format($subtotal['organization']) }} @endif @endforeach @endif @endforeach @endif @endforeach