@extends('Reports.template') @section('title') {{__('Pharmacy User Wise Collection Report')}} @endsection @section('ExternalCss') @parent @endsection @section('Content') @php $currentTime = \Carbon\Carbon::now(); $columnCount = count($paymentModeData); @endphp @php $sr = 1; $grandTotalAmount = 0; $maxLength = 0; $billTotals = []; /* Find maximum formatted length */ foreach($billData as $bill){ $amount = ($bill->trn_type == 'I' || $bill->trn_type == 'PR') ? $bill->amount_received_b : $bill->amount_received_b * (-1); $formatted = \Helper::customAmountFormat($amount); $maxLength = max($maxLength, strlen($formatted)); } foreach($receiptData as $receipt){ $formatted = \Helper::customAmountFormat($receipt->receipt_amount); $maxLength = max($maxLength, strlen($formatted)); } /* Calculate totals per bill */ foreach($billData as $bill){ $billKey = $bill->trn_type.'/'.$bill->trn_fyear.'/'.$bill->trn_id; $amount = ($bill->trn_type == 'I' || $bill->trn_type == 'PR') ? $bill->amount_received_b : $bill->amount_received_b * (-1); if(!isset($billTotals[$billKey])){ $billTotals[$billKey] = 0; } $billTotals[$billKey] += $amount; } @endphp @foreach($billData as $index => $bill) @php if ($bill->patient_name != '') { $patOrCustName = $bill->patient_id . " / " . $bill->patient_name; } else if ($bill->ph_cust_name != '') { $patOrCustName = '*' . $bill->ph_cust_id . " / " . $bill->ph_cust_name; } else { $patOrCustName = $bill->supplier_name . "( " . $bill->purchase_bill_no . " )"; } $amount = ($bill->trn_type == 'I' || $bill->trn_type == 'PR') ? $bill->amount_received_b : $bill->amount_received_b * (-1); $billKey = $bill->trn_type.'/'.$bill->trn_fyear.'/'.$bill->trn_id; $nextBillKey = isset($billData[$index+1]) ? $billData[$index+1]->trn_type.'/'.$billData[$index+1]->trn_fyear.'/'.$billData[$index+1]->trn_id : null; $isLastRow = ($billKey != $nextBillKey); $grandTotalAmount += $amount; if (strtoupper($bill->payment_number_b) != '') { $message = $bill->gm_description . "," . strtoupper($bill->payment_agency_b) . "," . strtoupper($bill->payment_number_b); } else { $message = ''; } @endphp @endforeach @foreach($receiptData as $receipt) @php $patOrCustName = ($receipt->patient_name != '') ? $receipt->patient_id." / ".$receipt->patient_name : '*'.$receipt->ph_cust_id." / ".$receipt->ph_cust_name; $receiptAmount = $receipt->receipt_amount; $totalReceiptAmount = $receiptAmount; $grandTotalAmount += $receiptAmount; if(strtoupper($receipt->payment_agency != '')){ $message = $receipt->gm_description . "," . strtoupper($receipt->payment_agency) . "," . strtoupper($receipt->payment_number) . " towards Bills " . $receipt->bill_no ; }else{ $message = $receipt->gm_description . " towards Bills " . $receipt->bill_no; } @endphp @endforeach
@if($businessEntityMasterData[0]->logo != null) Pharmacy Logologo )}}"/> @endif
{{ $businessEntityMasterData[0]->name }}
{{$businessEntityMasterData[0]->add1. " " .$businessEntityMasterData[0]->add2 ." ".$businessEntityMasterData[0]->city." : " .$businessEntityMasterData[0]->pincode }}
{{"Phone : ".$businessEntityMasterData[0]->tel1}}
{{__('Pharmacy User Wise Collection Report')}} @if($fromTime != "" && $toTime != "") {{__('Period')}} : {{\Helper::getDisplayDateTime($fromDate." ".$fromTime)}} {{__('TO')}} {{\Helper::getDisplayDateTime($toDate." ".$toTime)}} @else {{__('Period')}} : {{\Helper::getDisplayDate($fromDate)}} {{__('TO')}} {{\Helper::getDisplayDate($toDate)}} @endif
{{__('Sr No')}}   {{__('Bill/Receipt No')}}        {{__('Bill/Receipt Date Time')}}      {{__('Patient / Supplier Name')}} {{__('Payment Remark')}}  {{__('Payment Mode')}}  {{__('Amount')}}    {{__('User Id')}}
{{ $sr++ }} {{ $bill->trn_type }}/{{ $bill->trn_fyear }}/{{ $bill->trn_id }}      {{ \Helper::getDisplayDateTime($bill->trn_date ." ". $bill->ph_created_time) }}      {{ $patOrCustName }} {{ $message }} {{ $bill->gm_description }} @php $val = \Helper::customAmountFormat($amount); $spaces = $maxLength - strlen($val); @endphp {!! str_repeat(' ', $spaces) !!}{{ $val }} @if($isLastRow && $billTotals[$billKey] != $amount)                    Total - {{ \Helper::customAmountFormat($billTotals[$billKey]) }} @endif          {{ $bill->created_by }}
{{ $sr++ }} {{ $receipt->trn_receipt_no }}       {{ \Helper::getDisplayDateTime($receipt->trn_receipt_date ." ". $receipt->created_time) }}      {{ $patOrCustName }} {{ $message }}  {{ $receipt->gm_description }} @php $val = \Helper::customAmountFormat($totalReceiptAmount); $spaces = $maxLength - strlen($val); @endphp {!! str_repeat(' ', $spaces) !!}{{ $val }}   {{ $receipt->created_by }}
{{__('Grand Total')}} : {{ \Helper::customAmountFormat($grandTotalAmount) }}
{{__(Config::get('constants.asterisk.WALK_CUST'))}} {{ strtoupper(Session::get('userId'))." # ".$currentTime->format('d/m/Y H:i:s ')}}


@php $paymentModeSummary = []; $grandSummaryTotal = 0; /* Bill Data */ foreach($billData as $bill){ $mode = $bill->gm_description; $amount = ($bill->trn_type == 'I' || $bill->trn_type == 'PR') ? $bill->amount_received_b : $bill->amount_received_b * (-1); if(!isset($paymentModeSummary[$mode])){ $paymentModeSummary[$mode] = 0; } $paymentModeSummary[$mode] += $amount; } /* Receipt Data */ foreach($receiptData as $receipt){ $mode = $receipt->gm_description; if(!isset($paymentModeSummary[$mode])){ $paymentModeSummary[$mode] = 0; } $paymentModeSummary[$mode] += $receipt->receipt_amount; } /* Calculate Grand Total */ foreach($paymentModeSummary as $amt){ $grandSummaryTotal += $amt; } @endphp
@foreach($paymentModeSummary as $mode => $amount) @endforeach
{{__('Payment Mode Wise Summary')}}
{{__('Payment Mode')}} {{__('Amount')}}
{{ $mode }} {{ \Helper::customAmountFormat($amount) }}
{{__('Grand Total')}} : {{ \Helper::customAmountFormat($grandSummaryTotal) }}
{{__('Back')}}
@endsection @section('BootstrapModals') @endsection @section('ExternalJs') @endsection