diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php index d5269226..dfa672ad 100644 --- a/app/Http/Controllers/FormController.php +++ b/app/Http/Controllers/FormController.php @@ -158,6 +158,33 @@ class FormController extends Controller $data['additional'] = $additional_info; } + // Data to be Validated (team2): list logged-in user submissions when not editing + if ($formdata->form_id === '1793786953-f43d04cb-856d-4cfe-abcc-358042ecb98b' && empty($id)) { + $history = LambdaRequest::postrequest('form', 'formentity/getformhistory', [ + 'form_id' => $formdata->form_id, + 'user_id' => $formdata->user_id, + 'partition' => $formdata->partition, + 'limit' => 10000, + ]); + $submissions = (isset($history->data) && isset($history->data->submissions) && is_array($history->data->submissions)) + ? $history->data->submissions + : []; + $isBlank = function ($value) { + return $this->isBlankFormValue($value); + }; + usort($submissions, function ($a, $b) use ($isBlank) { + $aMissing = $isBlank($a->formdata->mobile_no ?? null) + || $isBlank($a->formdata->email_id ?? null); + $bMissing = $isBlank($b->formdata->mobile_no ?? null) + || $isBlank($b->formdata->email_id ?? null); + if ($aMissing === $bMissing) { + return 0; + } + return $aMissing ? -1 : 1; + }); + $data['submissions'] = $submissions; + } + // if ($formdata->form_id == '1731413373-65062594-7136-45b2-a846-b34be9afe3b9') { // // For debug: print $data // echo '
' . print_r($data, true) . ''; exit; @@ -194,6 +221,17 @@ class FormController extends Controller } } + protected function isBlankFormValue($value): bool + { + if ($value === null) { + return true; + } + if (is_array($value) || is_object($value)) { + return count((array) $value) === 0; + } + return trim((string) $value) === ''; + } + protected function muscle_questions($formdata) { switch($formdata->form_id) { case '63c2ff17-a69c-4b47-af33-1d9909c608b6': @@ -9013,6 +9051,10 @@ class FormController extends Controller $form_id = $request->input('form_id', $formdata->form_id); $formdata->form_id = $form_id; $request->session()->put('formdata', $formdata); + // Data to be Validated: list lives on the form itself (no separate history / new entry) + if ($form_id === '1793786953-f43d04cb-856d-4cfe-abcc-358042ecb98b') { + return redirect('/form/show'); + } //echo '
'; print_r($formdata); exit;
$history = LambdaRequest::postrequest('form', 'formentity/getformhistory', ['form_id' => $form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]);
//echo ''; print_r($history); print_r($formdata); exit;
diff --git a/resources/views/form/rapport-team2/1793786953-f43d04cb-856d-4cfe-abcc-358042ecb98b.blade.php b/resources/views/form/rapport-team2/1793786953-f43d04cb-856d-4cfe-abcc-358042ecb98b.blade.php
index e4d8662c..d66c3bb9 100644
--- a/resources/views/form/rapport-team2/1793786953-f43d04cb-856d-4cfe-abcc-358042ecb98b.blade.php
+++ b/resources/views/form/rapport-team2/1793786953-f43d04cb-856d-4cfe-abcc-358042ecb98b.blade.php
@@ -1,7 +1,26 @@
+@php
+ $isEdit = !empty($id);
+ $qMap = [];
+ foreach ($questions as $question) {
+ $qMap[$question->code] = $question;
+ }
+ $val = function ($code) use ($qMap) {
+ return isset($qMap[$code]) && isset($qMap[$code]->value) ? $qMap[$code]->value : '';
+ };
+ $isBlank = function ($value) {
+ if ($value === null) {
+ return true;
+ }
+ if (is_array($value) || is_object($value)) {
+ return count((array) $value) === 0;
+ }
+ return trim((string) $value) === '';
+ };
+@endphp
- @include('layouts.shared/title-meta', ['title' => "Form"])
+ @include('layouts.shared/title-meta', ['title' => $form->title ?? 'Form'])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
@@ -12,7 +31,7 @@
-
+
@@ -21,246 +40,113 @@
@if(session('success')){{ session('success') }}
@endif
-
+
{{$form->title}}
- @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
+ @if($isEdit)
@endif
- @if(isset($form->user_info))
+
+ @if(!$isEdit)
- Submitted By: {{$form->user_info->name}}
+
+
+
+
+ Edit
+ Doctor Name
+ MSL Code
+ Mobile
+ Email
+ Contact Status
+
+
+
+ @forelse(($submissions ?? []) as $submission)
+ @php
+ $fd = $submission->formdata ?? (object)[];
+ $mobile = $fd->mobile_no ?? '';
+ $email = $fd->email_id ?? '';
+ $missing = $isBlank($mobile) || $isBlank($email);
+ @endphp
+
+
+ Edit
+
+ {{ $fd->contact_id ?? '' }}
+ {{ $fd->msl_code ?? '' }}
+ {{ $mobile }}
+ {{ $email }}
+ {{ $fd->contact_status ?? '' }}
+
+ @empty
+
+ No submissions found.
+
+ @endforelse
+
+
+
- @endif
+ @else
+ @endif
-
+
-
-
-
-
-
+
-
-
-
@include('layouts.shared/footer-script')
-