@extends('layouts.job_order_pdf')
@section('title')
{{'job_order_'.$invoice['barcode'].'_'.date('d-m-Y_H-i',strtotime($invoice['created_at'])).'.pdf'}}
@endsection
@section('content')
@php
$categoryIds = \App\Models\InvoiceSampleTest::query()
->where('invoice_id', $invoice['id'])
->distinct()
->pluck('category_id');
$categories = \App\Models\Category::query()
->whereIn('id', $categoryIds)
->with(['invoice_sample_tests' => function ($q) use ($invoice) {
$q->with('testable','sample.sample_type')->where('invoice_id', $invoice['id']);
}])
->get();
@endphp
@php
$count_category=0;
@endphp
@foreach($categories as $category)
@php
// group by sample id (change key name to your actual FK)
$bySample = $category->invoice_sample_tests->groupBy('invoice_sample_id');
@endphp
|
{{$category['name']}}
|
|
| {{__('Sample ID')}} |
{{__('Test')}} |
{{__('Result Date')}} |
{{__('Sample')}} |
@foreach($bySample as $invoiceSampleId => $rows)
@php
$sample = optional($rows->first())->sample; // sample model
@endphp
@foreach($rows as $row)
|
{{$sample['sample_id']}}
|
{{$row['testable']['name']}}
|
{{$row['invoiceable']['deadline_date']}}
|
{{$sample['sample_type']['name']}}
|
@endforeach
@endforeach
@if(isset($invoice['note']))
{{__('Note')}} : {!! str_replace(["\n"], [' '], $invoice['note']) !!}
|
@endif
|
{{__('This is the visit No.')}} :
{{\App\Models\Invoice::where('patient_id',$invoice['patient_id'])->where('id','<=',$invoice['id'])->count()}}
|
@for ($i = 0; $i < count($invoice['questions_arr']); $i += 2)
{{-- First question --}}
|
{{ $invoice['questions_arr'][$i]['question'] }}
|
: |
@if ($invoice['questions_arr'][$i]['type'] == 'checkbox')
{{ __('Yes') }}
@else
{{ $invoice['questions_arr'][$i]['value'] }}
@endif
|
{{-- Second question (if exists) --}}
@if (isset($invoice['questions_arr'][$i + 1]))
{{ $invoice['questions_arr'][$i + 1]['question'] }}
|
: |
@if ($invoice['questions_arr'][$i + 1]['type'] == 'checkbox')
{{ __('Yes') }}
@else
{{ $invoice['questions_arr'][$i + 1]['value'] }}
@endif
|
@else
{{-- Fill empty cells if no second question --}}
|
|
|
@endif
@endfor
@php
$count_category++;
@endphp
@if(count($categories)>$count_category)
@endif
@endforeach
@endsection