586 lines
25 KiB
PHP
586 lines
25 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => "Doctor & Chemist Survey"])
|
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
|
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
|
<style>
|
|
.quick-action-form-card .form-control { font-size: 16px; }
|
|
.survey-section { border: 1px solid #d9d9d9; border-radius: 0.25rem; margin-bottom: 0.75rem; }
|
|
.survey-section > .section-head {
|
|
display: flex; width: 100%; text-align: left; background: #e5eef7; color: var(--bs-secondary);
|
|
border: 0; padding: 0.85rem 1rem; font-weight: 600;
|
|
}
|
|
.survey-section.locked > .section-head { opacity: 0.55; }
|
|
.survey-section .section-body { padding: 0.75rem 1rem 0.25rem; }
|
|
.rcpa-doctors { width: 100%; table-layout: fixed; border: 0; }
|
|
.table.rcpa-doctors > :not(caption) > * > * { vertical-align: middle; padding: 0.15rem; border: 0; width: 25%; box-shadow: none; }
|
|
.rcpa-doctors .form-control { font-size: 16px; min-width: 0; padding: 0.2rem 0.3rem; }
|
|
.survey-section.locked .section-body { display: none; }
|
|
#pageloader {
|
|
display: none;
|
|
position: fixed;
|
|
inset: 0;
|
|
z-index: 9999;
|
|
background: rgba(255, 255, 255, 0.8);
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="loading">
|
|
<div id="pageloader">Loading</div>
|
|
<div class="account-pages">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
|
<div class="card bg-pattern quick-action-form-card">
|
|
<div class="card-body p-3">
|
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
<h4 class="page-title mb-0">Doctor & Chemist Survey</h4>
|
|
<a href="/form/history" class="pt-1">View History</a>
|
|
</div>
|
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
|
@csrf
|
|
<input type="hidden" name="form_id" id="field-form_id" value="{{ $form_id ?? $form->form_id }}">
|
|
<input type="hidden" name="id" id="field-submission_id" value="{{ $id ?: '' }}">
|
|
|
|
<div class="mb-2">
|
|
<label class="form-label" for="field-record_date">Date <span class="text-danger">*</span></label>
|
|
<input type="date" class="form-control" id="field-record_date" name="record_date" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label" for="field-visit_type">Survey for <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="field-visit_type" required>
|
|
<option value="doctor">Doctor</option>
|
|
<option value="chemist">Chemist</option>
|
|
</select>
|
|
</div>
|
|
|
|
<fieldset id="doctor-fields">
|
|
@include('form.rapport-team3.partials.doctor-chemist-doctor')
|
|
</fieldset>
|
|
<fieldset id="chemist-fields" disabled style="display:none">
|
|
@include('form.rapport-team3.partials.doctor-chemist-chemist')
|
|
</fieldset>
|
|
|
|
<button type="submit" class="btn btn-primary w-100 mt-2">Submit</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@include('layouts.shared/footer-script')
|
|
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
|
@php
|
|
$savedAnswers = [];
|
|
$savedSource = null;
|
|
if (!empty($id)) {
|
|
if (isset($formdata) && (is_object($formdata) || is_array($formdata))) {
|
|
$savedSource = $formdata;
|
|
} elseif (isset($form->formdata)) {
|
|
$savedSource = $form->formdata;
|
|
}
|
|
}
|
|
if (is_object($savedSource) || is_array($savedSource)) {
|
|
foreach ((array) $savedSource as $savedKey => $savedValue) {
|
|
if ($savedKey === 'title' || is_array($savedValue) || is_object($savedValue) || $savedValue === null || $savedValue === '') {
|
|
continue;
|
|
}
|
|
$savedAnswers[$savedKey] = $savedValue;
|
|
}
|
|
}
|
|
foreach (($questions ?? []) as $savedQuestion) {
|
|
if (!is_object($savedQuestion) || empty($savedQuestion->code)) {
|
|
continue;
|
|
}
|
|
if (!isset($savedAnswers[$savedQuestion->code]) && isset($savedQuestion->value) && $savedQuestion->value !== '' && !is_array($savedQuestion->value) && !is_object($savedQuestion->value)) {
|
|
$savedAnswers[$savedQuestion->code] = $savedQuestion->value;
|
|
}
|
|
}
|
|
@endphp
|
|
<script>
|
|
$(function () {
|
|
var doctorFormId = '1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e';
|
|
var chemistFormId = '1790230856-704c97b6-61f7-4eda-901a-2cb4ff6f293d';
|
|
var dateInput = document.getElementById('field-record_date');
|
|
var today = new Date();
|
|
var month = String(today.getMonth() + 1).padStart(2, '0');
|
|
var day = String(today.getDate()).padStart(2, '0');
|
|
dateInput.min = '2026-09-01';
|
|
dateInput.max = today.getFullYear() + '-' + month + '-' + day;
|
|
var surveyContacts = [];
|
|
var contactsReady = false;
|
|
// Dev only: open every section. Set to false to lock later sections until the previous step is complete.
|
|
var unlockAllSections = true;
|
|
var savedAnswers = @json($savedAnswers);
|
|
var photoFields = ['visiting_card', 'rx_pad', 'doctor_board', 'chemist_board'];
|
|
|
|
function activeRoot() {
|
|
return $('#field-visit_type').val() === 'chemist' ? '#chemist-fields' : '#doctor-fields';
|
|
}
|
|
|
|
function contactPhone(contact) {
|
|
var digits = String((contact && contact.phone) || '').replace(/\D/g, '');
|
|
return digits.length > 10 ? digits.slice(-10) : digits;
|
|
}
|
|
|
|
function refreshSections() {
|
|
var root = $(activeRoot());
|
|
var open = true;
|
|
root.find('.survey-section').each(function () {
|
|
var section = $(this);
|
|
section.toggleClass('locked', !open);
|
|
section.find(':input').prop('disabled', !open);
|
|
if (!open || unlockAllSections) {
|
|
return;
|
|
}
|
|
var gates = section.find('[data-gate]');
|
|
if (gates.length && gates.filter(function () { return !$(this).val(); }).length) {
|
|
open = false;
|
|
}
|
|
});
|
|
syncOtherFields();
|
|
syncServiceFields();
|
|
}
|
|
|
|
function syncOtherFields() {
|
|
var pairs = [
|
|
['#field-degree', '#wrap-other_degree', '#field-other_degree'],
|
|
['#field-specialty', '#wrap-other_specialty', '#field-other_specialty']
|
|
];
|
|
pairs.forEach(function (pair) {
|
|
var show = /^others?$/i.test($(pair[0]).val() || '');
|
|
$(pair[1]).toggle(show);
|
|
var input = $(pair[2]);
|
|
input.prop('required', show);
|
|
if (!show) {
|
|
input.val('').prop('disabled', true);
|
|
} else if (!input.closest('.survey-section').hasClass('locked') && !$('#doctor-fields').prop('disabled')) {
|
|
input.prop('disabled', false);
|
|
}
|
|
});
|
|
}
|
|
|
|
function syncServiceFields() {
|
|
$('#chemist-fields .service-row').each(function () {
|
|
var row = $(this);
|
|
var show = row.find('.service-choice').val() === 'Yes' && !row.closest('.survey-section').hasClass('locked') && !$('#chemist-fields').prop('disabled');
|
|
var charge = row.find('.service-charge');
|
|
charge.toggle(show);
|
|
var select = charge.find('select');
|
|
select.prop('required', show).prop('disabled', !show);
|
|
if (!show) {
|
|
select.val('');
|
|
}
|
|
});
|
|
}
|
|
|
|
function fillSelect(select, contacts) {
|
|
var current = select.value;
|
|
select.innerHTML = '<option value="">-- Select --</option>';
|
|
contacts.forEach(function (item) {
|
|
var contact = item.contact || {};
|
|
var option = document.createElement('option');
|
|
option.value = item.value;
|
|
option.textContent = item.display || contact.name || '';
|
|
option.setAttribute('data-phone', contact.phone || '');
|
|
option.setAttribute('data-speciality', contact.speciality || '');
|
|
option.setAttribute('data-code', contact.msl_code || '');
|
|
option.setAttribute('data-location', contact.stockist_location || contact.location || '');
|
|
option.setAttribute('data-stockist-id', contact.stockist_id || '');
|
|
select.appendChild(option);
|
|
});
|
|
if (current) {
|
|
select.value = current;
|
|
}
|
|
}
|
|
|
|
function loadContacts() {
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/form/getdoctorlist?partition={{ $form->partition ?? '' }}&hierarchy={{ $form->hierarchy_id ?? ($form->hierarchy ?? '') }}',
|
|
success: function (data) {
|
|
surveyContacts = Array.isArray(data) ? data : [];
|
|
contactsReady = true;
|
|
var doctors = surveyContacts.filter(function (item) {
|
|
return item.contact && String(item.contact.type || '').toLowerCase() === 'ebt_doctor';
|
|
});
|
|
var stockists = surveyContacts.filter(function (item) {
|
|
return item.contact && String(item.contact.type || '').toLowerCase() === 'ebt_stockist';
|
|
});
|
|
document.querySelectorAll('#chemist-fields .rcpa-doctor').forEach(function (select) {
|
|
fillSelect(select, doctors);
|
|
});
|
|
document.querySelectorAll('#chemist-fields .stockist-pick').forEach(function (select) {
|
|
fillSelect(select, stockists);
|
|
});
|
|
matchSavedContacts();
|
|
},
|
|
error: function () {
|
|
contactsReady = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
function applyDoctor(select) {
|
|
var row = $(select).closest('tr');
|
|
var option = select.options[select.selectedIndex];
|
|
var chosen = select.value;
|
|
if (chosen) {
|
|
var duplicate = false;
|
|
$('#chemist-fields .rcpa-doctor[data-product="' + select.getAttribute('data-product') + '"]').each(function () {
|
|
if (this !== select && this.value === chosen) {
|
|
duplicate = true;
|
|
}
|
|
});
|
|
if (duplicate) {
|
|
select.value = '';
|
|
option = select.options[0];
|
|
fail('This doctor is already selected for this product.');
|
|
}
|
|
}
|
|
row.find('.rcpa-name').val(select.value ? option.textContent : '');
|
|
row.find('.rcpa-mobile').val(select.value ? (option.getAttribute('data-phone') || '') : '');
|
|
row.find('.rcpa-speciality').val(select.value ? (option.getAttribute('data-speciality') || '') : '');
|
|
row.find('.rcpa-code').val(select.value ? (option.getAttribute('data-code') || '') : '');
|
|
}
|
|
|
|
function applyStockist(select) {
|
|
var block = $(select).closest('.stockist-block');
|
|
var option = select.options[select.selectedIndex];
|
|
var chosen = select.value;
|
|
if (chosen) {
|
|
var duplicate = false;
|
|
$('#chemist-fields .stockist-pick').each(function () {
|
|
if (this !== select && this.value === chosen) {
|
|
duplicate = true;
|
|
}
|
|
});
|
|
if (duplicate) {
|
|
select.value = '';
|
|
option = select.options[0];
|
|
fail('This stockist is already selected.');
|
|
}
|
|
}
|
|
block.find('.stockist-name').val(select.value ? option.textContent : '');
|
|
block.find('.stockist-location').val(select.value ? (option.getAttribute('data-location') || '') : '');
|
|
block.find('.stockist-id').val(select.value ? (option.getAttribute('data-stockist-id') || '') : '');
|
|
}
|
|
|
|
function setVisit(type) {
|
|
var doctor = type !== 'chemist';
|
|
$('#doctor-fields').prop('disabled', !doctor).toggle(doctor);
|
|
$('#chemist-fields').prop('disabled', doctor).toggle(!doctor);
|
|
$('#field-form_id').val(doctor ? doctorFormId : chemistFormId);
|
|
if (doctor && !$('#field-doctor_name').val()) {
|
|
$('#field-doctor_name').val('Dr. ');
|
|
}
|
|
if (doctor) {
|
|
lockDoctorPrefix();
|
|
}
|
|
refreshSections();
|
|
}
|
|
|
|
function lockDoctorPrefix() {
|
|
var input = document.getElementById('field-doctor_name');
|
|
if (!input || input.value.indexOf('Dr. ') === 0) {
|
|
return;
|
|
}
|
|
var rest = input.value.replace(/^Dr\.\s*/i, '');
|
|
var caret = input.selectionStart || 0;
|
|
input.value = 'Dr. ' + rest;
|
|
var next = Math.max(4, caret);
|
|
if (document.activeElement === input) {
|
|
input.setSelectionRange(next, next);
|
|
}
|
|
}
|
|
|
|
function showSavedPhoto(field, url) {
|
|
var link = document.createElement('a');
|
|
link.href = url;
|
|
link.target = '_blank';
|
|
link.rel = 'noopener';
|
|
link.className = 'd-block mt-1';
|
|
link.textContent = 'View current photo';
|
|
field.parentNode.appendChild(link);
|
|
field.removeAttribute('required');
|
|
if (!field.parentNode.querySelector('input.saved-file[name="' + field.name + '"]')) {
|
|
var hidden = document.createElement('input');
|
|
hidden.type = 'hidden';
|
|
hidden.name = field.name;
|
|
hidden.value = url;
|
|
hidden.className = 'saved-file';
|
|
field.parentNode.appendChild(hidden);
|
|
}
|
|
}
|
|
|
|
function applySaved() {
|
|
if (!$('#field-submission_id').val()) {
|
|
return;
|
|
}
|
|
var root = $(activeRoot());
|
|
Object.keys(savedAnswers).forEach(function (code) {
|
|
if (photoFields.indexOf(code) !== -1 || /_charge$/.test(code)) {
|
|
return;
|
|
}
|
|
var fields = root.find('[name="' + code + '"]');
|
|
if (!fields.length && code === 'record_date') {
|
|
fields = $('#field-record_date');
|
|
}
|
|
fields.each(function () {
|
|
if (this.type === 'file') {
|
|
return;
|
|
}
|
|
if (this.type === 'radio' || this.type === 'checkbox') {
|
|
this.checked = this.value === String(savedAnswers[code]);
|
|
} else {
|
|
this.value = savedAnswers[code];
|
|
}
|
|
});
|
|
});
|
|
if ($('#field-visit_type').val() !== 'chemist') {
|
|
lockDoctorPrefix();
|
|
}
|
|
refreshSections();
|
|
Object.keys(savedAnswers).forEach(function (code) {
|
|
if (!/_charge$/.test(code)) {
|
|
return;
|
|
}
|
|
root.find('[name="' + code + '"]').val(savedAnswers[code]);
|
|
});
|
|
photoFields.forEach(function (code) {
|
|
if (!savedAnswers[code]) {
|
|
return;
|
|
}
|
|
var field = document.getElementById('field-' + code);
|
|
if (!field || !root.find(field).length) {
|
|
return;
|
|
}
|
|
showSavedPhoto(field, savedAnswers[code]);
|
|
});
|
|
}
|
|
|
|
function selectSavedOption(select, label) {
|
|
if (!label) {
|
|
return;
|
|
}
|
|
for (var i = 0; i < select.options.length; i++) {
|
|
if (select.options[i].textContent === label) {
|
|
select.value = select.options[i].value;
|
|
return;
|
|
}
|
|
}
|
|
var option = document.createElement('option');
|
|
option.value = label;
|
|
option.textContent = label;
|
|
select.appendChild(option);
|
|
select.value = label;
|
|
}
|
|
|
|
function matchSavedContacts() {
|
|
if (!$('#field-submission_id').val() || $('#field-visit_type').val() !== 'chemist') {
|
|
return;
|
|
}
|
|
document.querySelectorAll('#chemist-fields .rcpa-doctor').forEach(function (select) {
|
|
selectSavedOption(select, $(select).closest('tr').find('.rcpa-name').val());
|
|
});
|
|
document.querySelectorAll('#chemist-fields .stockist-pick').forEach(function (select) {
|
|
selectSavedOption(select, $(select).closest('.stockist-block').find('.stockist-name').val());
|
|
});
|
|
}
|
|
|
|
$('#field-doctor_name').on('input', lockDoctorPrefix);
|
|
$('#field-visit_type').on('change', function () { setVisit(this.value); });
|
|
$('#report-form').on('input change', '.survey-section :input', refreshSections);
|
|
$('#chemist-fields').on('change', '.rcpa-doctor', function () { applyDoctor(this); refreshSections(); });
|
|
$('#chemist-fields').on('change', '.stockist-pick', function () { applyStockist(this); });
|
|
$('#chemist-fields').on('change', '.service-choice', syncServiceFields);
|
|
|
|
$('#field-degree, #field-specialty').on('change', syncOtherFields);
|
|
|
|
function fail(text) {
|
|
Swal.fire({ icon: 'error', title: 'Please check the form', text: text });
|
|
}
|
|
|
|
function alphaOk(value) {
|
|
return /^[A-Za-z][A-Za-z .]*$/.test(value);
|
|
}
|
|
|
|
function alnumOk(value) {
|
|
return /^[A-Za-z0-9]+$/.test(value);
|
|
}
|
|
|
|
function mobileTaken(type, mobile) {
|
|
return surveyContacts.some(function (item) {
|
|
var contact = item.contact || {};
|
|
return String(contact.type || '').toLowerCase() === type && contactPhone(contact) === mobile;
|
|
});
|
|
}
|
|
|
|
$('#report-form').on('submit', function (event) {
|
|
event.preventDefault();
|
|
var type = $('#field-visit_type').val();
|
|
var recordDate = $('#field-record_date').val();
|
|
if (!recordDate || recordDate < dateInput.min || recordDate > dateInput.max) {
|
|
fail('Date must be from 1 Sep 2026 through today.');
|
|
return;
|
|
}
|
|
if (type === 'doctor') {
|
|
var doctorName = $('#field-doctor_name').val().trim();
|
|
if (!alphaOk(doctorName)) {
|
|
fail('Doctor name can contain letters, spaces and periods only.');
|
|
return;
|
|
}
|
|
if (!/^[6-9][0-9]{9}$/.test($('#field-mobile_number').val())) {
|
|
fail('Mobile number must be 10 digits and start with 6, 7, 8 or 9.');
|
|
return;
|
|
}
|
|
var registration = $('#field-doctor_registration_number').val().trim();
|
|
if (registration && !alnumOk(registration)) {
|
|
fail('Registration number must be alphanumeric with no special characters.');
|
|
return;
|
|
}
|
|
var legacy = $('#field-legacy_code').val().trim();
|
|
if (legacy && !alnumOk(legacy)) {
|
|
fail('Legacy code must be alphanumeric with no special characters.');
|
|
return;
|
|
}
|
|
if (!contactsReady) {
|
|
fail('Contact list is still loading. Please try again.');
|
|
return;
|
|
}
|
|
if (!$('#field-submission_id').val() && mobileTaken('ebt_doctor', $('#field-mobile_number').val())) {
|
|
fail('A doctor with this mobile number already exists.');
|
|
return;
|
|
}
|
|
if (!alphaOk($('#field-doctor_location').val().trim())) {
|
|
fail('Doctor location can contain letters, spaces and periods only.');
|
|
return;
|
|
}
|
|
if (!/^[1-9][0-9]{5}$/.test($('#field-doctor_pincode').val())) {
|
|
fail('Doctor pincode must be 6 digits and must not start with 0.');
|
|
return;
|
|
}
|
|
if ($('#field-degree').val() === 'Other' && !alphaOk($('#field-other_degree').val().trim())) {
|
|
fail('Enter the other degree in letters only.');
|
|
return;
|
|
}
|
|
if ($('#field-specialty').val() === 'Other' && !alphaOk($('#field-other_specialty').val().trim())) {
|
|
fail('Enter the other specialty in letters only.');
|
|
return;
|
|
}
|
|
var photos = ['visiting_card', 'rx_pad', 'doctor_board'];
|
|
var hasPhoto = false;
|
|
for (var i = 0; i < photos.length; i++) {
|
|
var file = document.getElementById('field-' + photos[i]).files[0];
|
|
if (!file) continue;
|
|
hasPhoto = true;
|
|
if (!/\.(jpe?g|png)$/i.test(file.name) || file.size > 10 * 1024 * 1024) {
|
|
fail('Photos must be JPG, JPEG or PNG and no larger than 10 MB.');
|
|
return;
|
|
}
|
|
}
|
|
var savedDoctorPhoto = $('#field-submission_id').val() && photoFields.slice(0, 3).some(function (code) { return savedAnswers[code]; });
|
|
if (!hasPhoto && !savedDoctorPhoto) {
|
|
fail('Upload at least one of visiting card, Rx pad or doctor board.');
|
|
return;
|
|
}
|
|
} else {
|
|
if (!alphaOk($('#field-chemist_name').val().trim()) || !alphaOk($('#field-chemist_location').val().trim())) {
|
|
fail('Chemist name and location can contain letters, spaces and periods only.');
|
|
return;
|
|
}
|
|
if (!/^[6-9][0-9]{9}$/.test($('#field-chemist_mobile').val())) {
|
|
fail('Mobile number must be 10 digits and start with 6, 7, 8 or 9.');
|
|
return;
|
|
}
|
|
if (!contactsReady) {
|
|
fail('Contact list is still loading. Please try again.');
|
|
return;
|
|
}
|
|
if (!$('#field-submission_id').val() && mobileTaken('ebt_chemist', $('#field-chemist_mobile').val())) {
|
|
fail('A chemist with this mobile number already exists.');
|
|
return;
|
|
}
|
|
var missingDoctor = false;
|
|
$('#chemist-fields .rcpa-doctor[data-slot="1"]').each(function () {
|
|
if (!this.value) {
|
|
missingDoctor = true;
|
|
}
|
|
});
|
|
if (missingDoctor) {
|
|
fail('Select doctor 1 for each product.');
|
|
return;
|
|
}
|
|
var missingCharge = false;
|
|
$('#chemist-fields .service-choice').each(function () {
|
|
if ($(this).val() === 'Yes' && !$(this).closest('.service-row').find('.service-charge select').val()) {
|
|
missingCharge = true;
|
|
}
|
|
});
|
|
if (missingCharge) {
|
|
fail('Select Free or Chargeable for each service marked Yes.');
|
|
return;
|
|
}
|
|
if (!/^[1-9][0-9]{5}$/.test($('#field-chemist_pincode').val())) {
|
|
fail('Chemist pincode must be 6 digits and must not start with 0.');
|
|
return;
|
|
}
|
|
var board = document.getElementById('field-chemist_board').files[0];
|
|
if (board && (!/\.(jpe?g|png)$/i.test(board.name) || board.size > 10 * 1024 * 1024)) {
|
|
fail('Chemist board must be a JPG, JPEG or PNG no larger than 10 MB.');
|
|
return;
|
|
}
|
|
if (!board && !($('#field-submission_id').val() && savedAnswers.chemist_board)) {
|
|
fail('Chemist board must be a JPG, JPEG or PNG no larger than 10 MB.');
|
|
return;
|
|
}
|
|
}
|
|
|
|
var emptyFiles = $('#report-form input[type="file"]').filter(function () {
|
|
return !this.files || !this.files.length;
|
|
});
|
|
emptyFiles.prop('disabled', true);
|
|
$('#pageloader').css('display', 'flex').hide().fadeIn();
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/form/ajaxsubmit',
|
|
data: new FormData($('#report-form')[0]),
|
|
processData: false,
|
|
contentType: false,
|
|
success: function (data) {
|
|
emptyFiles.prop('disabled', false);
|
|
$('#pageloader').fadeOut();
|
|
if (data.status == 'success') {
|
|
Swal.fire({ title: 'Great!', text: 'Your data is successfully submitted!', icon: 'success' });
|
|
$('#report-form .saved-file').remove();
|
|
$('#report-form a').filter(function () { return $(this).text() === 'View current photo'; }).remove();
|
|
$('#report-form')[0].reset();
|
|
$('#field-submission_id').val('').attr('value', '');
|
|
$('#field-visit_type').val('doctor');
|
|
setVisit('doctor');
|
|
} else {
|
|
Swal.fire({ icon: 'error', title: 'Data not submitted', text: 'Please try again.' });
|
|
}
|
|
},
|
|
error: function () {
|
|
emptyFiles.prop('disabled', false);
|
|
$('#pageloader').fadeOut();
|
|
Swal.fire({ icon: 'error', title: 'Data not submitted', text: 'Please try again.' });
|
|
}
|
|
});
|
|
});
|
|
|
|
var openingType = ($('#field-form_id').val() === chemistFormId || @json($form->form_id ?? '') === chemistFormId) ? 'chemist' : 'doctor';
|
|
$('#field-visit_type').val(openingType);
|
|
setVisit(openingType);
|
|
applySaved();
|
|
loadContacts();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|