diff --git a/resources/views/form/rapport-team3/partials/survey-preview-helpers.blade.php b/resources/views/form/rapport-team3/partials/survey-preview-helpers.blade.php new file mode 100644 index 00000000..5249a75b --- /dev/null +++ b/resources/views/form/rapport-team3/partials/survey-preview-helpers.blade.php @@ -0,0 +1,39 @@ +@php + $byCode = []; + foreach ($questions ?? [] as $question) { + if (isset($question->code)) { + $byCode[$question->code] = $question; + } + } + $submitted = $submitted_formdata ?? null; + $val = function ($code) use ($byCode, $submitted) { + if (is_object($submitted) && isset($submitted->{$code}) && $submitted->{$code} !== '' && $submitted->{$code} !== null) { + return $submitted->{$code}; + } + if (is_array($submitted) && isset($submitted[$code]) && $submitted[$code] !== '' && $submitted[$code] !== null) { + return $submitted[$code]; + } + if (isset($byCode[$code]->value) && $byCode[$code]->value !== '' && $byCode[$code]->value !== null) { + return $byCode[$code]->value; + } + return ''; + }; + $show = function ($code) use ($val) { + $value = $val($code); + return $value !== '' && $value !== null ? $value : '—'; + }; + $fileUrl = function ($url) { + $url = trim((string) $url); + if ($url === '') { + return ''; + } + if (!preg_match('#^https?://#i', $url)) { + return rtrim((string) env('AWS_URL'), '/') . '/' . ltrim($url, '/'); + } + return $url; + }; + $isImageUrl = function ($url) { + $ext = strtolower(pathinfo((string) parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION)); + return in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'], true); + }; +@endphp diff --git a/resources/views/form/rapport-team3/partials/survey-preview-styles.blade.php b/resources/views/form/rapport-team3/partials/survey-preview-styles.blade.php new file mode 100644 index 00000000..f8c0c73f --- /dev/null +++ b/resources/views/form/rapport-team3/partials/survey-preview-styles.blade.php @@ -0,0 +1,65 @@ +
Review the submitted chemist survey before you approve or reject
+ @if(isset($form->user_info->name) && $form->user_info->name !== '') +Submitted by: {{ $form->user_info->name }}
+ @endif +No chemist board uploaded.
+ @else + @if($isImageUrl($boardUrl)) +Review the submitted doctor survey before you approve or reject
+ @if(isset($form->user_info->name) && $form->user_info->name !== '') +Submitted by: {{ $form->user_info->name }}
+ @endif +| Product | +Prescribed | +Units / Month | +
|---|---|---|
| {{ $label }} | +{{ $show($code) }} | +{{ $val($code.'_units') !== '' ? $val($code.'_units') : '—' }} | +
No photos uploaded.
+ @endif +