From 18106b4977901ad00f8b430803d77a645fbd4396 Mon Sep 17 00:00:00 2001 From: Ravi Gulhane Date: Mon, 12 Oct 2026 16:00:38 +0530 Subject: [PATCH] Changes --- app/Http/Controllers/FormController.php | 12 ++++--- ...58a6-d509-4ac0-9b18-6d366a74965e.blade.php | 35 +++++++++++++++++++ ...8862-93e7-43b5-bf4e-7a29b30e3830.blade.php | 14 +++++++- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php index 664be233..68c6e802 100644 --- a/app/Http/Controllers/FormController.php +++ b/app/Http/Controllers/FormController.php @@ -121,13 +121,17 @@ class FormController extends Controller if ($invoice !== '' && !$hasInvoice) { return ['__error' => 'Upload an invoice as a JPG, JPEG, PNG, or PDF file.']; } - if (!$isExisting) { - $post['submission_status'] = 'Order Taken'; + $supplyYes = ($post['supply_status'] ?? '') === 'Yes'; + if (!$supplyYes) { + if (!$isExisting) { + $post['submission_status'] = 'Order Taken'; + } else { + unset($post['submission_status']); + } return $post; } if (!$hasInvoice) { - unset($post['submission_status']); - return $post; + return ['__error' => 'Upload an invoice as a JPG, JPEG, PNG, or PDF file.']; } $actualUnits = 0; $actualValue = 0; diff --git a/resources/views/form/rapport-team3/1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e.blade.php b/resources/views/form/rapport-team3/1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e.blade.php index d437cdaa..dacf6508 100644 --- a/resources/views/form/rapport-team3/1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e.blade.php +++ b/resources/views/form/rapport-team3/1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e.blade.php @@ -116,6 +116,7 @@ $(function () { dateInput.min = '2026-09-01'; dateInput.max = today.getFullYear() + '-' + month + '-' + day; var surveyContacts = []; + var submittedIdentities = []; var contactsReady = false; // Dev only: open every section. Set to false to lock later sections until the previous step is complete. var unlockAllSections = true; @@ -622,6 +623,39 @@ $(function () { return true; } return existingPin === String(pincode || '').trim(); + }) || submittedIdentities.some(function (item) { + if (item.type !== type) { + return false; + } + if (normalizedName(item.name) !== wantedName || contactPhone({ phone: item.phone }) !== wantedPhone) { + return false; + } + if (type !== 'ebt_chemist') { + return true; + } + var savedPin = String(item.pincode || '').trim(); + if (!savedPin) { + return true; + } + return savedPin === String(pincode || '').trim(); + }); + } + + function rememberSubmission(type) { + if (type === 'doctor') { + submittedIdentities.push({ + type: 'ebt_doctor', + name: $('#field-doctor_name').val(), + phone: $('#field-mobile_number').val(), + pincode: '' + }); + return; + } + submittedIdentities.push({ + type: 'ebt_chemist', + name: $('#field-chemist_name').val(), + phone: $('#field-chemist_mobile').val(), + pincode: $('#field-chemist_pincode').val() }); } @@ -794,6 +828,7 @@ $(function () { emptyFiles.prop('disabled', false); $('#pageloader').fadeOut(); if (data.status == 'success') { + rememberSubmission(type); Swal.fire({ title: 'Great!', text: 'Your data is successfully submitted!', icon: 'success' }); $('#report-form .saved-file').remove(); $('#report-form .photo-chosen').text(''); diff --git a/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php b/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php index dcd19812..125f9748 100644 --- a/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php +++ b/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php @@ -408,7 +408,7 @@ $('#report-form [name="actual_' + name + '"]').val(mode === 'upload' ? (actual || data[name] || 0) : (actual || 0)); }); recalc('.pob-units', '.pob-value', '#field-total_pob_units', '#field-total_pob_value'); - setActualVisible(mode === 'upload'); + setActualVisible($('#field-supply_status').val() === 'Yes'); openContactId = data.contact_id || ''; } @@ -510,6 +510,7 @@ return; } openContactId = $('#field-contact_id').val() || openContactId; + $('#report-form [name="submission_status"]').val($('#field-supply_status').val() === 'Yes' ? 'Invoice Uploaded' : 'Order Taken'); $('#pageloader').css('display', 'flex').hide().fadeIn(); $.ajax({ type: 'POST', @@ -541,6 +542,17 @@ $('#report-form').on('input', '.pob-units', function () { recalc('.pob-units', '.pob-value', '#field-total_pob_units', '#field-total_pob_value'); }); + $('#field-supply_status').on('change', function () { + if (this.value === 'Yes') { + unitFields.forEach(function (name) { + var actual = $('#report-form [name="actual_' + name + '"]'); + if (!actual.val() || actual.val() === '0') { + actual.val($('#report-form [name="' + name + '"]').val() || 0); + } + }); + } + setActualVisible(this.value === 'Yes'); + }); $('#report-form').on('input', '.actual-units', function () { recalc('.actual-units', '.actual-value', '#field-total_actual_pob_units', '#field-total_actual_pob_value'); });