diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php index e28553b3..584cde81 100644 --- a/app/Http/Controllers/FormController.php +++ b/app/Http/Controllers/FormController.php @@ -12963,13 +12963,12 @@ class FormController extends Controller } /** - * Selected user attribute codes when the form is configured to show them. - * Uses the saved attribute list as the source of truth so columns still render - * if Show User Attributes was left off after attributes were selected. + * Selected user attribute codes when Show User Attributes is Yes. + * A saved attribute list is ignored while that setting is No. */ protected function userAttributeCodes($form): array { - if (!$form) { + if (!$form || ($form->show_user_attributes ?? 'no') !== 'yes') { return []; } $raw = $form->user_attributes ?? []; diff --git a/app/Http/Controllers/FormentityController.php b/app/Http/Controllers/FormentityController.php index f9a5ce7e..7b7eb08e 100644 --- a/app/Http/Controllers/FormentityController.php +++ b/app/Http/Controllers/FormentityController.php @@ -158,9 +158,6 @@ class FormentityController extends Controller $values->show_manager_details = $values->show_manager_details ?? 'no'; $values->show_user_attributes = (($values->show_user_attributes ?? 'no') === 'yes') ? 'yes' : 'no'; $values->user_attributes = $this->normalizeAttributeCodes($values->user_attributes ?? []); - if (!empty($values->user_attributes)) { - $values->show_user_attributes = 'yes'; - } } //echo '
'; print_r($values); exit;
return $values;
@@ -254,9 +251,6 @@ class FormentityController extends Controller
$data['roles_info'] = ($data['roles_info'] ?? 'no') === 'yes' ? 'yes' : 'no';
$data['show_user_attributes'] = ($data['show_user_attributes'] ?? 'no') === 'yes' ? 'yes' : 'no';
$data['user_attributes'] = $this->normalizeAttributeCodes($data['user_attributes'] ?? []);
- if (!empty($data['user_attributes'])) {
- $data['show_user_attributes'] = 'yes';
- }
if ($data['email_notification'] === 'no') {
$data['email_notification_rules'] = [];
} else {
diff --git a/resources/views/form/rapport-team3/preview-1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php b/resources/views/form/rapport-team3/preview-1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php
new file mode 100644
index 00000000..1c9b8d7f
--- /dev/null
+++ b/resources/views/form/rapport-team3/preview-1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php
@@ -0,0 +1,309 @@
+
+
+
+ @include('layouts.shared/title-meta', ['title' => $form->title ?? 'POB'])
+ @include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
+
+
+
+@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 '';
+ };
+ $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;
+ };
+ $contactType = strtolower((string) $val('contact_type'));
+ $isChemist = $contactType === 'ebt_chemist';
+ $contactLabel = $isChemist ? 'Chemist' : 'Doctor';
+ $skus = [
+ ['Asthalin Inhaler', 'asthalin_inhaler'],
+ ['Asthalin Rotacap', 'asthalin_rotacap'],
+ ['Aerocort Inhaler', 'aerocort_inhaler'],
+ ['Aerocort Rotacap', 'aerocort_rotacap'],
+ ['Aerocort Forte Rotacap', 'aerocort_forte_rotacap'],
+ ];
+ $supplyStatus = (string) $val('supply_status');
+ $invoiceUrl = $fileUrl($val('upload_invoice'));
+ $invoiceExt = strtolower(pathinfo((string) parse_url($invoiceUrl, PHP_URL_PATH), PATHINFO_EXTENSION));
+ $invoiceIsImage = in_array($invoiceExt, ['jpg', 'jpeg', 'png', 'gif', 'webp'], true);
+ $invoiceIsPdf = $invoiceExt === 'pdf';
+@endphp
+
+
+
+ POB Review
+ Review the actual POB and invoice before you approve or reject
+ @if(isset($form->user_info->name) && $form->user_info->name !== '')
+ Submitted by: {{ $form->user_info->name }}
+ @endif
+
+
+
+
+ {{ $contactLabel }} details
+
+
+ Date
+ {{ $val('record_date') !== '' ? $val('record_date') : '—' }}
+
+
+ {{ $contactLabel }}
+ {{ $val('contact_name') !== '' ? $val('contact_name') : '—' }}
+
+ @if(!$isChemist)
+
+ Speciality
+ {{ $val('speciality') !== '' ? $val('speciality') : '—' }}
+
+
+ Doctor Address
+ {{ $val('doctor_location') !== '' ? $val('doctor_location') : '—' }}
+
+ @else
+
+ Chemist Address
+ {{ $val('chemist_location') !== '' ? $val('chemist_location') : '—' }}
+
+ @endif
+
+ MSL Code
+ {{ $val('msl_code') !== '' ? $val('msl_code') : '—' }}
+
+
+ Supply Status
+ {{ $supplyStatus !== '' ? $supplyStatus : '—' }}
+
+
+ Submission Status
+ {{ $val('submission_status') !== '' ? $val('submission_status') : '—' }}
+
+
+
+
+
+ Actual POB
+
+
+
+
+ SKU
+ Actual Units
+ Actual Value
+
+
+
+ @foreach($skus as [$label, $code])
+
+ {{ $label }}
+ {{ $val('actual_'.$code.'_units') !== '' ? $val('actual_'.$code.'_units') : '0' }}
+ {{ $val('actual_'.$code.'_value') !== '' ? $val('actual_'.$code.'_value') : '0' }}
+
+ @endforeach
+
+ Total
+ {{ $val('total_actual_pob_units') !== '' ? $val('total_actual_pob_units') : '0' }}
+ {{ $val('total_actual_pob_value') !== '' ? $val('total_actual_pob_value') : '0' }}
+
+
+
+
+
+
+
+ Invoice
+
+ @if($invoiceUrl === '')
+ No invoice uploaded.
+ @elseif($invoiceIsImage)
+
+
+
+
+ @elseif($invoiceIsPdf)
+
+
+ @else
+
+ @endif
+
+
+
+
+
+
+
+
+
+
+
+
+