Team4 : form changes : MONTAIR LC KID 5 - Chemist & Dr Tagging
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m44s Details

This commit is contained in:
Farhan Pathan 2026-08-31 09:44:59 +05:30
parent 952b314041
commit 02ddfb1b0a
1 changed files with 35 additions and 18 deletions

View File

@ -93,8 +93,19 @@
echo "</pre>"; */
$existingCount = count($submissions);
$targetLimit = 20; // नवीन लिमिट २०
$historyDoctorIds = [];
foreach ($submissions as $sub) {
if (isset($sub->formdata->cont_id) && $sub->formdata->cont_id != '') {
$historyDoctorIds[] = (string) $sub->formdata->cont_id;
}
}
$historyDoctorIds = array_unique($historyDoctorIds);
@endphp
@if($existingCount<20 || $id)
@ -339,6 +350,8 @@
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
const historyDoctors = @json($historyDoctorIds);
console.log("History IDs:", historyDoctors);
// Allow only today's date
const today = new Date().toISOString().split('T')[0];
@ -537,7 +550,7 @@ $(document).on(
function preventDuplicateDoctors() {
let selectedValues = [];
let selectedValues = [...historyDoctors];
// Collect selected values
$('select[id^="field-contact_id"]').each(function () {
@ -563,24 +576,28 @@ $(document).on(
if (!optionValue) return;
// remove previous label
let cleanText = option.text().replace(' (Already Added)', '');
let cleanText = option.text()
.replace(' (Already Added)', '')
.replace(' (Already Submitted)', '');
// IMPORTANT:
// keep currently selected option enabled
if (
selectedValues.includes(optionValue) &&
optionValue !== currentValue
) {
option.prop('disabled', true);
option.text(cleanText + ' (Already Added)');
} else {
option.prop('disabled', false);
option.text(cleanText);
}
if (
historyDoctors.includes(optionValue) &&
optionValue !== currentValue
) {
option.prop('disabled', true);
option.text(cleanText + ' (Already Submitted)');
}
else if (
selectedValues.includes(optionValue) &&
optionValue !== currentValue
) {
option.prop('disabled', true);
option.text(cleanText + ' (Already Added)');
}
else {
option.prop('disabled', false);
option.text(cleanText);
}
});