@extends('Reports.template') @section('title') @if($reportType == "D") @php $reportTitle = "Pharmacy Outstanding Report ( Detail ) "; @endphp @else @php $reportTitle = "Pharmacy Outstanding Report ( Summary ) "; @endphp @endif {{$reportTitle}} @endsection @section('ExternalCss') @parent @endsection @section('Content') @php $currentTime = \Carbon\Carbon::now(); if ($reportFor == "U") { $reportForTitle = "Unsettled Bill / Receipt"; } else { $reportForTitle = "All Bill / Receipt"; } @endphp @if($reportFor == "U") @else @endif @if($reportType == "D") @else @endif @if($reportType == "D") @endif @php $lastPatOrCustName = ''; $lastPatRateCard = 0; $lastPtrApplicable = ''; $srHeader = 1; $checkPatOrCustID = ''; $oldPatOrCustID = ''; $balance = 0; $totalBillAmount = 0; $totalReceiptAmount = 0; $totalOutstanding = 0; @endphp @foreach($billData as $bill) @php $opOrIpID = ''; if($bill->patient_name != ''){ $patOrCustName = " ".$bill->patient_id." / ".$bill->patient_name; if($bill->visit_type == "O"){ $opOrIpID = "OP - ".$bill->opd_reg_id; }else{ $opOrIpID = "IP - ".$bill->ipd_reg_id; } $patOrCustID = $bill->patient_id; $checkPatOrCustID = "P" . $bill->patient_id; }else{ $patOrCustName = '*'.$bill->ph_cust_id." / ".$bill->ph_cust_name; $patOrCustID = $bill->ph_cust_id; $checkPatOrCustID = "C" . $bill->ph_cust_id; } @endphp @if(array_key_exists($checkPatOrCustID, $patientWiseBalance)) @if($checkPatOrCustID != $oldPatOrCustID) @if($balance != 0 || ($balance == 0 && $oldPatOrCustID != '')) @if($reportType == "D") @else @if($lastPatRateCard > 0) @else @endif @if($lastPtrApplicable == 'Y') @else @endif @endif @endif @php $sr = 1; $balance = 0; $totalBillAmount = 0; $totalReceiptAmount = 0; @endphp @if($reportType == "D") @if($bill->patient_rate_card > 0) @else @endif @if($bill->is_ptr_applicable == 'Y') @else @endif @endif @if($bill->patient_id != '') @foreach ($receiptData as $receipt) @if($receipt->patient_id == $bill->patient_id) @php if($receipt->patient_id != ''){ if($receipt->visit_type == "O"){ $opOrIpID = "OP - ".$receipt->opd_reg_id; }else{ $opOrIpID = "IP - ".$receipt->ipd_reg_id; } } if($receipt->balance_type == "C"){ $amount = $receipt->amount_received; $balance += $receipt->amount_received; $totalReceiptAmount += $receipt->amount_received; $totalOutstanding += $receipt->amount_received; }else{ $amount = -1 * $receipt->amount_received; $balance -= $receipt->amount_received; $totalReceiptAmount -= $receipt->amount_received; $totalOutstanding -= $receipt->amount_received; } @endphp @if($reportType == "D") @endif @endif @endforeach @elseif($bill->ph_cust_id != '') @foreach ($receiptData as $receipt) @if($receipt->ph_cust_id == $bill->ph_cust_id) @php $opOrIpID = ''; if($receipt->balance_type == "C"){ $amount = $receipt->amount_received; $balance += $receipt->amount_received; $totalReceiptAmount += $receipt->amount_received; $totalOutstanding += $receipt->amount_received; }else{ $amount = -1 * $receipt->amount_received; $balance -= $receipt->amount_received; $totalReceiptAmount -= $receipt->amount_received; $totalOutstanding -= $receipt->amount_received; } @endphp @if($reportType == "D") @endif @endif @endforeach @endif @endif @php if($bill->trn_type == "I"){ $amount = $bill->total; $balance += (-1 * $bill->total); $totalBillAmount += $bill->total; $totalOutstanding += (-1 * $bill->total); }else{ $amount = -1 * $bill->total; $balance += $bill->total; $totalBillAmount -= $bill->total; $totalOutstanding += $bill->total; } $opOrIpID = ''; if($bill->ph_cust_id == ''){ if($bill->visit_type == "O"){ $opOrIpID = "OP - ".$bill->opd_reg_id; }else{ $opOrIpID = "IP - ".$bill->ipd_reg_id; } } @endphp @if($reportType == "D") @endif @php $oldPatOrCustID = $checkPatOrCustID; $lastPatOrCustName = $patOrCustName; $lastPatRateCard = $bill->patient_rate_card; $lastPtrApplicable = $bill->is_ptr_applicable; @endphp @endif @endforeach @if(!empty($onlyReceiptData)) @if($reportType == "D") @else @if($lastPatRateCard > 0) @else @endif @if($lastPtrApplicable == 'Y') @else @endif @endif @if($reportType == "D") @else @endif @if($reportType == "D") @endif @php $srHeader = 1; $totalOutstanding = 0; $lastPatOrCustName = ''; $lastPatRateCard = 0; $lastPtrApplicable = ''; $checkPatOrCustID = ''; $oldPatOrCustID = ''; $balance = 0; $totalBillAmount = 0; $totalReceiptAmount = 0; @endphp @foreach($onlyReceiptData as $onlyReceipt) @php $checkPatOrCustID = $onlyReceipt; $patOrCustID = substr($onlyReceipt, 1); $opOrIpID = ''; @endphp @if(array_key_exists($checkPatOrCustID, $patientWiseBalance)) @if(substr($onlyReceipt, 0, 1) == "P") @foreach ($receiptData as $receipt) @if($patOrCustID != $oldPatOrCustID) @if($balance != 0 || ($balance == 0 && $oldPatOrCustID != '')) @if($reportType == "D") @else @if($lastPatRateCard > 0) @else @endif @if($lastPtrApplicable == 'Y') @else @endif @endif @endif @php $sr = 1; $balance = 0; $totalBillAmount = 0; $totalReceiptAmount = 0; $patOrCustName = ''; @endphp @endif @if($receipt->patient_id == $patOrCustID) @php $patOrCustName = " ".$receipt->patient_id." / ".$receipt->patient_name; if($receipt->patient_id != ''){ if($receipt->visit_type == "O"){ $opOrIpID = "OP - ".$receipt->opd_reg_id; }else{ $opOrIpID = "IP - ".$receipt->ipd_reg_id; } } if($receipt->balance_type == "C"){ $amount = $receipt->amount_received; $balance += $receipt->amount_received; $totalReceiptAmount += $receipt->amount_received; $totalOutstanding += $receipt->amount_received; }else{ $amount = -1 * $receipt->amount_received; $balance -= $receipt->amount_received; $totalReceiptAmount -= $receipt->amount_received; $totalOutstanding -= $receipt->amount_received; } @endphp @if($reportType == "D" && $sr == 1) @if($receipt->patient_rate_card > 0) @else @endif @endif @if($reportType == "D") @endif @endif @php $oldPatOrCustID = $patOrCustID; $lastPatOrCustName = $patOrCustName; $lastPatRateCard = $receipt->patient_rate_card; $lastPtrApplicable = "N"; @endphp @endforeach @else @foreach ($receiptData as $receipt) @if($patOrCustID != $oldPatOrCustID) @if($balance != 0 || ($balance == 0 && $oldPatOrCustID != '')) @if($reportType == "D") @else @if($lastPatRateCard > 0) @else @endif @if($lastPtrApplicable == 'Y') @else @endif @endif @endif @php $sr = 1; $balance = 0; $totalBillAmount = 0; $totalReceiptAmount = 0; $patOrCustName = ''; @endphp @endif @if($receipt->ph_cust_id == $patOrCustID) @php $opOrIpID = ''; $patOrCustName = '*'.$receipt->ph_cust_id." / ".$receipt->ph_cust_name; if($receipt->balance_type == "C"){ $amount = $receipt->amount_received; $balance += $receipt->amount_received; $totalReceiptAmount += $receipt->amount_received; $totalOutstanding += $receipt->amount_received; }else{ $amount = -1 * $receipt->amount_received; $balance -= $receipt->amount_received; $totalReceiptAmount -= $receipt->amount_received; $totalOutstanding -= $receipt->amount_received; } @endphp @if($reportType == "D" && $sr == 1) @if($receipt->patient_rate_card > 0) @else @endif @endif @if($reportType == "D") @endif @endif @php $oldPatOrCustID = $patOrCustID; $lastPatOrCustName = $patOrCustName; $lastPatRateCard = 0; $lastPtrApplicable = "N"; @endphp @endforeach @endif @endif @endforeach @endif @if($reportType == "D") @else @if($lastPatRateCard > 0) @else @endif @if($lastPtrApplicable == 'Y') @else @endif @endif @if(!empty($onlyReceiptData)) @else @endif
@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}}
{{$reportTitle}} ( Report For : {{$reportForTitle}} )As On : {{\Helper::getDisplayDate($toDate)}}Period : {{\Helper::getDisplayDate($fromDate)}} TO {{\Helper::getDisplayDate($toDate)}}
Sr.    Patient / Customer Details Patient Type
Sr.    Patient / Customer Details Patient Type Receipt Amount Bill Amount Balance
Sr.    Receipt / Bill No  Receipt / Bill Date  IP / OP ID Remarks Created By Receipt Amount Bill Amount Balance
Total : {{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$lastPatOrCustName}}{{$rate[$lastPatRateCard]}}{{$companyName}}{{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$patOrCustName}}{{$rate[$bill->patient_rate_card]}}{{$companyName}}
{{$sr++}}    {{$receipt->trn_receipt_type.$receipt->trn_receipt_no}}  {{\Helper::getDisplayDate($receipt->trn_receipt_date)}}  {{$opOrIpID}} {{$receipt->remarks}} {{$receipt->created_by}} {{\Helper::customAmountFormat($amount)}} {{\Helper::customAmountFormat($balance)}}
{{$sr++}}    {{$receipt->trn_receipt_type.$receipt->trn_receipt_no}}  {{\Helper::getDisplayDate($receipt->trn_receipt_date)}}  {{$opOrIpID}} {{$receipt->remarks}} {{$receipt->created_by}} {{\Helper::customAmountFormat($amount)}} {{\Helper::customAmountFormat($balance)}}
{{$sr++}}    {{$bill->trn_type."/".$bill->trn_fyear."/".$bill->trn_id}}  {{\Helper::getDisplayDate($bill->trn_date)}}  {{$opOrIpID}} {{$bill->remarks}} {{$bill->created_by}} {{\Helper::customAmountFormat($amount)}} {{\Helper::customAmountFormat($balance)}}
Total : {{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$lastPatOrCustName}}{{$rate[$lastPatRateCard]}}{{$companyName}}{{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
Total Outstanding : {{\Helper::customAmountFormat($totalOutstanding)}}
List of Patient / Customer having Only Receipt
Sr.    Patient / Customer Details Patient Type
Sr.    Patient / Customer Details Patient Type Receipt Amount Bill Amount Balance
Sr.    Receipt / Bill No  Receipt / Bill Date  IP / OP ID Remarks Created By Receipt Amount Bill Amount Balance
Total : {{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$lastPatOrCustName}}{{$rate[$lastPatRateCard]}}{{$companyName}}{{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$patOrCustName}}{{$rate[$receipt->patient_rate_card]}}
{{$sr++}}    {{$receipt->trn_receipt_type.$receipt->trn_receipt_no}}  {{\Helper::getDisplayDate($receipt->trn_receipt_date)}}  {{$opOrIpID}} {{$receipt->remarks}} {{$receipt->created_by}} {{\Helper::customAmountFormat($amount)}} {{\Helper::customAmountFormat($balance)}}
Total : {{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$lastPatOrCustName}}{{$rate[$lastPatRateCard]}}{{$companyName}}{{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$patOrCustName}}{{$rate[$receipt->patient_rate_card]}}
{{$sr++}}    {{$receipt->trn_receipt_type.$receipt->trn_receipt_no}}  {{\Helper::getDisplayDate($receipt->trn_receipt_date)}}  {{$opOrIpID}} {{$receipt->remarks}} {{$receipt->created_by}} {{\Helper::customAmountFormat($amount)}} {{\Helper::customAmountFormat($balance)}}
Total : {{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
{{$srHeader++}}    {{$lastPatOrCustName}}{{$rate[$lastPatRateCard]}}{{$companyName}}{{\Helper::customAmountFormat($totalReceiptAmount)}} {{\Helper::customAmountFormat($totalBillAmount)}} {{\Helper::customAmountFormat($balance)}}
Total Receipt Amount : Total Outstanding : {{\Helper::customAmountFormat($totalOutstanding)}}
{{Config::get('constants.asterisk.WALK_CUST')}} {{ strtoupper(Session::get('userId'))." # ".$currentTime->format('d/m/Y H:i:s ')}}


Back
@endsection @section('BootstrapModals') @endsection @section('ExternalJs') @endsection