Rapport-Laravel/resources/views/form/rapport-team3/1790230856-a5ff58a6-d509-4a...

118 lines
6.1 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => 'History'])
@include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
<style>
.survey-history h5 { margin-bottom: 0.5rem; }
.survey-history .table-responsive {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.survey-history .table {
width: max-content;
min-width: 100%;
margin-bottom: 0;
}
.survey-history .table th,
.survey-history .table td {
white-space: nowrap;
}
</style>
</head>
<body class="loading">
<div class="account-pages">
<div class="container">
<div class="row">
<div class="col-8 p-2">
<h4 class="page-title">Doctor & Chemist Survey</h4>
</div>
<div class="col-4 p-2">
<a href="/form/show?form_id={{ $doctor_form_id }}" class="float-end pt-1">New Submission</a>
</div>
</div>
@if(session()->has('message'))
<div class="alert alert-success">{{ session()->get('message') }}</div>
@endif
@if(session()->has('error'))
<div class="alert alert-danger">{{ session()->get('error') }}</div>
@endif
@foreach([
['title' => 'Doctor Survey', 'form_id' => $doctor_form_id, 'questions' => $doctor_questions, 'submissions' => $doctor_submissions],
['title' => 'Chemist Survey', 'form_id' => $chemist_form_id, 'questions' => $chemist_questions, 'submissions' => $chemist_submissions],
] as $section)
<div class="row">
<div class="col-12 p-0">
<div class="card survey-history">
<div class="card-body">
<h5>{{ $section['title'] }}</h5>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Submission Date</th>
<th>Submitted By</th>
<th>Workflow Status</th>
@foreach($section['questions'] as $code => $question)
@if(($question->type ?? '') === 'hidden')
@continue
@endif
<th>{{ $question->label ?? $code }}</th>
@endforeach
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse($section['submissions'] as $submission)
<tr>
<td>{{ date('d M Y', strtotime($submission->updatedAt ?? $submission->createdAt)) }}</td>
<td>{{ $submission->user_info->name ?? '' }}</td>
<td>{{ $submission->workflow_status ?? '' }}</td>
@foreach($section['questions'] as $code => $question)
@if(($question->type ?? '') === 'hidden')
@continue
@endif
@php
$cell = $submission->formdata->{$code} ?? '';
if (is_array($cell)) {
$cell = implode(', ', $cell);
} elseif (is_object($cell)) {
$cell = collect((array) $cell)->map(function ($val, $key) {
return $key.': '.$val;
})->implode(', ');
}
@endphp
<td>
@if(($question->type ?? '') === 'file' && $cell)
<a href="{{ $cell }}" target="_blank" rel="noopener">View</a>
@else
{{ $cell }}
@endif
</td>
@endforeach
<td>
@if(strtolower((string) ($submission->workflow_status ?? '')) === 'rejected')
<a href="/form/show?form_id={{ $section['form_id'] }}&id={{ $submission->id }}" class="btn btn-primary btn-xs">Edit / Re-upload</a>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="4">No submissions</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
@include('layouts.shared/footer-script')
</body>
</html>