177 lines
5.7 KiB
PHP
177 lines
5.7 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => $form->title ?? 'TGICS'])
|
|
@include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
|
|
</head>
|
|
<body class="preview-approval-body">
|
|
@php
|
|
$skipCodes = [
|
|
'tgics_contact_id',
|
|
'user_id',
|
|
'hierarchy_id',
|
|
'id',
|
|
'execution_done',
|
|
'execution_date',
|
|
'no_of_attendees',
|
|
'total_amount_spent_in_rs',
|
|
'upload_photo_1',
|
|
'upload_photo_2',
|
|
'ziten_m_rx',
|
|
'total_camp_rx',
|
|
'no_of_strips_left_with_fso',
|
|
];
|
|
|
|
$qualification = '';
|
|
foreach ($questions ?? [] as $question) {
|
|
if (($question->code ?? '') === 'qualification') {
|
|
$qualification = trim((string) ($question->value ?? ''));
|
|
break;
|
|
}
|
|
}
|
|
$showOtherQualification = strcasecmp($qualification, 'Others') === 0;
|
|
|
|
$displayValue = function ($question) {
|
|
$value = $question->value ?? '';
|
|
$options = $question->options ?? [];
|
|
$labelFor = function ($raw) use ($options) {
|
|
$raw = trim((string) $raw);
|
|
if ($raw === '') {
|
|
return '';
|
|
}
|
|
foreach ($options as $option) {
|
|
if ((string) ($option->value ?? '') === $raw) {
|
|
$display = trim((string) ($option->display ?? ''));
|
|
return $display !== '' ? $display : $raw;
|
|
}
|
|
}
|
|
return $raw;
|
|
};
|
|
|
|
if (is_array($value)) {
|
|
$labels = [];
|
|
foreach ($value as $item) {
|
|
$label = $labelFor($item);
|
|
if ($label !== '') {
|
|
$labels[] = $label;
|
|
}
|
|
}
|
|
return implode(', ', $labels);
|
|
}
|
|
|
|
return $labelFor($value);
|
|
};
|
|
|
|
$isImage = function ($url) {
|
|
$path = (string) parse_url($url, PHP_URL_PATH);
|
|
return in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg', 'png', 'gif', 'webp'], true);
|
|
};
|
|
@endphp
|
|
|
|
<div class="approval-container">
|
|
<div class="approval-header">
|
|
<h1 class="approval-title">{{ $form->title ?? 'TGICS enrolment' }}</h1>
|
|
<p class="approval-subtitle">Submitted enrolment details</p>
|
|
@if(isset($form->user_info->name) && $form->user_info->name !== '')
|
|
<p class="text-muted mb-0">Submitted by: {{ $form->user_info->name }}</p>
|
|
@endif
|
|
</div>
|
|
|
|
<div class="detail-list">
|
|
@foreach($questions ?? [] as $question)
|
|
@php
|
|
$code = (string) ($question->code ?? '');
|
|
$type = (string) ($question->type ?? '');
|
|
if ($code === '' || $type === 'hidden' || in_array($code, $skipCodes, true)) {
|
|
continue;
|
|
}
|
|
if ($code === 'other_qualification' && !$showOtherQualification) {
|
|
continue;
|
|
}
|
|
$shown = $displayValue($question);
|
|
if ($shown === '') {
|
|
continue;
|
|
}
|
|
@endphp
|
|
<div class="detail-row">
|
|
<span class="detail-label">{{ $question->question }}</span>
|
|
<span class="detail-value">
|
|
@if($type === 'file' && $shown !== '')
|
|
@if($isImage($shown))
|
|
<a href="{{ $shown }}" target="_blank" rel="noopener">
|
|
<img src="{{ $shown }}" alt="{{ $question->question }}" class="preview-image">
|
|
</a>
|
|
@else
|
|
<a href="{{ $shown }}" target="_blank" rel="noopener">Open file</a>
|
|
@endif
|
|
@else
|
|
{{ $shown }}
|
|
@endif
|
|
</span>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
html, body.preview-approval-body {
|
|
background: #fff;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.approval-container {
|
|
max-width: 720px;
|
|
margin: 0 auto;
|
|
padding: 16px 16px 32px;
|
|
background: #fff;
|
|
}
|
|
.approval-header {
|
|
text-align: center;
|
|
margin-bottom: 16px;
|
|
padding-bottom: 12px;
|
|
border-bottom: 1px solid #e9ecef;
|
|
}
|
|
.approval-title {
|
|
font-size: 1.35rem;
|
|
font-weight: 600;
|
|
margin-bottom: 4px;
|
|
}
|
|
.approval-subtitle {
|
|
color: #6c757d;
|
|
margin-bottom: 4px;
|
|
}
|
|
.detail-list {
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
}
|
|
.detail-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
gap: 16px;
|
|
padding: 10px 14px;
|
|
border-bottom: 1px solid #f1f3f4;
|
|
}
|
|
.detail-row:last-child { border-bottom: none; }
|
|
.detail-label {
|
|
font-weight: 600;
|
|
color: #495057;
|
|
min-width: 140px;
|
|
}
|
|
.detail-value {
|
|
color: #212529;
|
|
flex: 1;
|
|
text-align: right;
|
|
word-break: break-word;
|
|
}
|
|
.preview-image {
|
|
max-width: 180px;
|
|
max-height: 140px;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 6px;
|
|
}
|
|
</style>
|
|
</body>
|
|
</html>
|