@extends('backend.layouts.app') @section('title') {{ __($module_title) }} @endsection @section('content')
@php $id = $appointment ? $appointment->id : 0; $status = $appointment ? $appointment->status : null; $pay_status = $appointment ? optional($appointment->appointmenttransaction)->payment_status : 0; @endphp @if ($pay_status == 1 && $status == 'checkout') @endif
{{ __('appointment.lbl_patient_name') }}
avatar
{{ optional($appointment->user)->full_name ?? default_user_name() }}
{{ optional($appointment->user)->email ?? '--' }}
{{ __('clinic.lbl_clinic_name') }}
avatar {{ $appointment->cliniccenter ? optional($appointment->cliniccenter)->name : '--' }}
{{ __('appointment.lbl_status') }}
{{ ucwords(str_replace('_', ' ', $appointment->status === 'checkout' ? 'complete' : $appointment->status)) }}
@if($appointment->status === 'cancelled' && $appointment->reason)
{{ __('messages.lbl_reason_for_cancellation') }}

{{ $appointment->reason }}

@endif
{{ __('appointment.lbl_appointment_date') }}
{{ date($dateformate, strtotime($appointment->appointment_date ?? '--')) }}
{{ __('appointment.lbl_appointment_time') }}
At {{ $appointment->appointment_time ? \Carbon\Carbon::createFromFormat('H:i:s', $appointment->appointment_time)->format('h:i A') : '--' }}
{{ __('appointment.lbl_doctor') }} {{ __('appointment.lbl_name') }} @if ($appointment->doctor === null)
--
@else
avatar
{{ optional($appointment->doctor)->first_name . ' ' . optional($appointment->doctor)->last_name }}
{{ optional($appointment->doctor)->email ?? '--' }}
@endif
{{ __('appointment.lbl_payment_status') }} @if (isset($appointment->appointmenttransaction->payment_status)) @if ($appointment->status === 'cancelled' && optional($appointment->appointmenttransaction)->payment_status == 1)
{{ __('appointment.refunded') }}
@elseif (optional($appointment->appointmenttransaction)->payment_status == 1)
{{ __('appointment.paid') }}
@elseif($appointment->status == 'cancelled' && $appointment->advance_paid_amount != 0)
{{ __('appointment.advance_refund') }}
@elseif(optional($appointment->appointmenttransaction)->payment_status == 0 && optional($appointment->appointmenttransaction)->advance_payment_status == 1)
{{ __('appointment.advance_paid') }}
@else
{{ __('appointment.pending') }}
{{ __('appointment.lbl_payment_method') }}
Paid with {{ ucfirst(optional($appointment->appointmenttransaction)->transaction_type) }}
@endif @else
{{ __('appointment.failed') }}
@endif
{{ __('appointment.lbl_contact_number') }}
{{ optional($appointment->user)->mobile ?? '--' }}
{{ __('appointment.lbl_duration') }}
{{ $appointment->duration ?? '--' }} min
@if($appointment->otherPatient) {{ __('appointment.booked_for') }}
otherPatient->profile_image}} class="img-fluid rounded-circle me-2" style="width: 40px; height: 40px;" /> {{ $appointment->otherPatient->first_name }} {{ $appointment->otherPatient->last_name }}
@endif
@if ($appointment->media->isNotEmpty())
{{ __('appointment.lbl_medical_report') }}
@endif
@if ($appointment->appointment_extra_info != '')
{{ __('appointment.lbl_addition_information') }}
{{ $appointment->appointment_extra_info }}
@endif
{{ __('appointment.price') }} {{ __('appointment.detail') }}
@if ($appointment->patientEncounter == null)
avatar
{{ optional($appointment->clinicservice)->name }} {{ optional($appointment->clinicservice)->description ?? ' ' }}
@php if ( optional($appointment->appointmenttransaction)->discount_type === 'percentage' ) { $payable_Amount = $appointment->service_price - $appointment->service_price * (optional($appointment->appointmenttransaction)->discount_value / 100) ; } else { $payable_Amount = $appointment->service_price - optional($appointment->appointmenttransaction)->discount_value ; } $total_tax = 0; $sub_total = $payable_Amount + $appointment->appointmenttransaction->inclusive_tax_price; $inclusive_tax_data = json_decode($appointment->appointmenttransaction->inclusive_tax, true); // decode tax details @endphp @if (optional($appointment->appointmenttransaction)->discount_value > 0)
{{ Currency::format($sub_total) }} @if (optional($appointment->appointmenttransaction)->discount_type === 'percentage') ({{ optional($appointment->appointmenttransaction)->discount_value ?? '--' }}% off) @else ({{ Currency::format(optional($appointment->appointmenttransaction)->discount_value) ?? '--' }} off) @endif
{{ Currency::format($appointment->service_price ) }} @else
{{ Currency::format($appointment->service_amount ) }}
@endif @if($appointment->appointmenttransaction->inclusive_tax_price != null && $appointment->patientEncounter == null) {{ __('messages.lbl_with_inclusive_tax') }} @endif
@endif @if ( $appointment->patientEncounter !== null && optional(optional($appointment->patientEncounter)->billingrecord)->billingItem != null) @foreach (optional(optional($appointment->patientEncounter)->billingrecord)->billingItem as $billingItem)
avatar
{{ optional($billingItem->clinicservice)->name }} {{ optional($billingItem->clinicservice)->description ?? ' ' }}
@php if ($billingItem->discount_type === 'percentage') { $payable_Amount = $billingItem->service_amount - $billingItem->service_amount * ($billingItem->discount_value / 100); } else { $payable_Amount = $billingItem->service_amount - $billingItem->discount_value; } @endphp @if ($billingItem->discount_value > 0)
{{ Currency::format($billingItem->total_amount) }} * {{ $billingItem->quantity }} = {{ Currency::format($billingItem->total_amount * $billingItem->quantity) }} @if ($billingItem->discount_type === 'percentage') ({{ $billingItem->discount_value ?? '--' }}% off) @else ({{ Currency::format($billingItem->discount_value) ?? '--' }} off) @endif @if($billingItem->inclusive_tax_amount > 0) {{ __('messages.lbl_with_inclusive_tax') }} @endif
{{ Currency::format($billingItem->service_amount * $billingItem->quantity ) }} @else
{{ Currency::format($billingItem->total_amount ) }} * {{ $billingItem->quantity }} = {{ Currency::format($billingItem->total_amount * $billingItem->quantity) }} @if($billingItem->inclusive_tax_amount > 0) {{ __('messages.lbl_with_inclusive_tax') }} @endif
@endif {{-- @if (!empty($billingItem->clinicservice->inclusive_tax_price)) @php $quantity = $billingItem->quantity; $inclusive_tax_price_per_unit = $billingItem->clinicservice->inclusive_tax_price; $inclusive_tax_price = $inclusive_tax_price_per_unit * $quantity; $inclusive_tax_data = json_decode($billingItem->clinicservice->inclusive_tax, true); $service_total = $payable_Amount * $quantity; $item_subtotal = ($payable_Amount + $inclusive_tax_price_per_unit) * $quantity; // dd($inclusive_tax_price_per_unit); $total_item_tax = 0; @endphp
  • {{ __('appointment.service_price') }} {{ Currency::format($service_total) }}
  • @if (!empty($inclusive_tax_data)) @foreach ($inclusive_tax_data as $t) @if ($t['type'] == 'percent') @php $tax_per_unit = $payable_Amount * $t['value'] / 100 ; $tax_total = $tax_per_unit * $quantity; $total_item_tax += $tax_total; @endphp
  • {{ $t['title'] }} ({{ $t['value'] }}% of {{ Currency::format($payable_Amount) }} × {{ $quantity }}) {{ Currency::format($tax_total) }}
  • @elseif ($t['type'] == 'fixed') @php $tax_total = $t['value'] * $quantity; $total_item_tax += $tax_total; @endphp
  • {{ $t['title'] }} ({{ Currency::format($t['value']) }} × {{ $quantity }}) {{ Currency::format($tax_total) }}
  • @endif @endforeach
  • {{ __('appointment.sub_total') }} {{ Currency::format($item_subtotal) }}
  • @endif
@endif --}}
@endforeach @endif @php $service_total_amount = 0; // Initialize outside the loop $total_tax = 0; @endphp @if ($appointment->patientEncounter !== null) {{-- @php dd($appointment->patientEncounter->billingrecord->billingItem); @endphp --}} @foreach (optional(optional($appointment->patientEncounter)->billingrecord)->billingItem as $item) @php $quantity = $item->quantity ?? 1; // if (isset($item->inclusive_tax_amount) && $item->inclusive_tax_amount > 0) { // $service_total_amount += $item->inclusive_tax_amount * $quantity; // } // if (!empty($item->discount_type)) { // if ($item->discount_type === 'fixed') { // $service_total_amount -= $item->discount_value * $quantity; // } elseif ($item->discount_type === 'percentage') { // $service_total_amount -= ($item->total_amount * $item->discount_value / 100); // } // } $service_total_amount += $item->total_amount; @endphp @endforeach @endif {{-- @if(optional($appointment->appointmenttransaction)->inclusive_tax_price != null && $appointment->patientEncounter == null) @php $sub_total = $payable_Amount + $appointment->appointmenttransaction->inclusive_tax_price; $inclusive_tax_data = json_decode($appointment->appointmenttransaction->inclusive_tax, true); // decode tax details @endphp
  • {{ __('appointment.service_price') }} {{ Currency::format($payable_Amount) }}
  • @if(!empty($inclusive_tax_data)) @foreach ($inclusive_tax_data as $t) @if ($t['type'] == 'percent') @php $tax_amount = $payable_Amount * $t['value'] / 100 ; // for inclusive, this is reverse calculated $total_tax += $tax_amount; @endphp
  • {{ $t['title'] }} ({{ $t['value'] }}%) {{ Currency::format($tax_amount) }}
  • @elseif($t['type'] == 'fixed') @php $tax_amount = $t['value']; $total_tax += $tax_amount; @endphp
  • {{ $t['title'] }} {{ Currency::format($tax_amount) }}
  • @endif @endforeach
  • {{ __('appointment.sub_total') }} {{ Currency::format($sub_total) }}
  • @endif @endif --}}