Vitalis form changes Ek Nayii Shuruaat A1c Camp
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m35s Details

This commit is contained in:
Tanuja Pansare 2026-12-03 11:23:22 +05:30
parent d0d3451f68
commit bb6ba0d5a0
1 changed files with 62 additions and 86 deletions

View File

@ -48,26 +48,12 @@
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
<input type="hidden" name="form_id" value="{{$form_id}}">
@if(!(isset($form->manager_can_submit) && $form->manager_can_submit == true))
<input type="hidden" name="user_id" value="{{$form->user_id}}">
@endif
@csrf
@if($id)
<input type="hidden" name="id" value="{{$id}}">
@endif
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
<div class="col-md-12 mb-2">
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
<select class="form-control" id="field-user_id" name="user_id" required>
<option value=""> -- Select -- </option>
@foreach($form->users as $option)
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}">{{$option->display}}</option>
@endforeach
</select>
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
</div>
@endif
@foreach($questions as $question)
<div class="col-md-12 mb-2">
@ -183,7 +169,10 @@
<script type="text/javascript">
jQuery(document).ready(function($){
$('[data-toggle="select2"]').select2();
var hierarcies = [];
var contacts = [];
var allSubmissions = @json($submissions ?? []);
var currentEditId = '{{ $id ?? '' }}';
var submittedDoctors = [];
@ -205,65 +194,80 @@
}
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
function applySelect2ToDoctorDropdowns() {
$("[id^='field-contact_id']").each(function () {
var select = $(this);
if (select.data("select2")) return;
select.select2({
width: "100%",
placeholder: "-- Select --",
allowClear: true
@foreach($form->users as $option)
hierarcies.push('{{$option->hierarchy_id}}');
@endforeach
$("#pageloader").fadeIn();
Promise.all(
hierarcies.map(hierarchy => {
return $.ajax({
type: "GET",
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
processData: false,
contentType: false
}).then(data => {
contacts = contacts.concat(data);
}).catch(function(err) {
console.log(err);
});
});
}
})
).then(function() {
contacts = contacts.filter(function(itm) { return itm && itm.value !== 'sample'; });
function enforceUniqueDoctorSelections() {
var selectedValues = [];
function applySelect2ToDoctorDropdowns() {
$("[id^='field-contact_id']").each(function () {
var select = $(this);
if (select.data("select2")) return;
select.select2({
width: "100%",
placeholder: "-- Select --",
allowClear: true
});
});
}
$("[id^='field-contact_id']").each(function () {
var v = $(this).val();
if (v) selectedValues.push(String(v));
});
function enforceUniqueDoctorSelections() {
var selectedValues = [];
$("[id^='field-contact_id']").each(function () {
var currentSelect = $(this);
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
$("[id^='field-contact_id']").each(function () {
var v = $(this).val();
if (v) selectedValues.push(String(v));
});
currentSelect.find("option").each(function () {
var opt = $(this);
var optVal = String(opt.val() || '');
var optText = opt.text();
$("[id^='field-contact_id']").each(function () {
var currentSelect = $(this);
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
if (optText.indexOf("Already Added") !== -1) {
opt.prop("disabled", true);
} else if (optVal && selectedValues.includes(optVal) && optVal !== currentVal) {
opt.prop("disabled", true);
} else {
opt.prop("disabled", false);
currentSelect.find("option").each(function () {
var opt = $(this);
var optVal = String(opt.val() || '');
var optText = opt.text();
if (optText.indexOf("Already Added") !== -1) {
opt.prop("disabled", true);
} else if (optVal && selectedValues.includes(optVal) && optVal !== currentVal) {
opt.prop("disabled", true);
} else {
opt.prop("disabled", false);
}
});
if (currentSelect.data("select2")) {
currentSelect.trigger("change.select2");
}
});
}
if (currentSelect.data("select2")) {
currentSelect.trigger("change.select2");
}
});
}
function fillDoctorDropdowns(contactList) {
$("[id^='field-contact_id']").each(function() {
var select = $(this);
var existingVal = select.attr('data-preselected') !== undefined && select.attr('data-preselected') !== ''
? String(select.attr('data-preselected'))
var existingVal = select.attr('data-preselected') !== undefined && select.attr('data-preselected') !== ''
? String(select.attr('data-preselected'))
: (select.val() ? String(select.val()) : '');
if (select.data("select2")) {
select.select2("destroy");
}
select.empty();
select.append($("<option></option>").attr("value", '').text('-- Select --'));
contactList.forEach(function(itm) {
contacts.forEach(function(itm) {
var itmVal = String(itm.value);
var itmText = String(itm.display);
@ -335,35 +339,7 @@
});
enforceUniqueDoctorSelections();
}
$('#field-user_id').on('change', function(event) {
event.preventDefault();
var hierarchy = $('option:selected', this).attr('hierarchy') || '';
$('#field-hierarchy_id').val(hierarchy);
if (!hierarchy) {
fillDoctorDropdowns([]);
return;
}
$("#pageloader").fadeIn();
$.ajax({
type: "GET",
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
processData: false,
contentType: false,
success: function(data) {
var list = Array.isArray(data) ? data : [];
list = list.filter(function(itm) { return itm && itm.value !== 'sample'; });
fillDoctorDropdowns(list);
$("#pageloader").fadeOut();
},
error: function(err) {
console.log(err);
$("#pageloader").fadeOut();
}
});
$("#pageloader").fadeOut();
});
@endif