Zenova new form changes2
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m40s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m40s
Details
This commit is contained in:
parent
cb88cd2cc1
commit
5fe093d7e1
|
|
@ -91,22 +91,22 @@
|
|||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
lead_recieved="{{ (isset($option->contact->sankalp_lead_received_penvial) ? $option->contact->sankalp_lead_received_penvial : '') }}"
|
||||
lead_enrolled="{{ (isset($option->contact->sankalp_lead_enrolled_penvial) ? $option->contact->sankalp_lead_enrolled_penvial : '') }}"
|
||||
pmos_dr="{{ (isset($option->contact->pmos_dr) ? $option->contact->pmos_dr : '') }}"
|
||||
qbs_dr="{{ (isset($option->contact->qbs_dr) ? $option->contact->qbs_dr : '') }}"
|
||||
adboard_dr="{{ (isset($option->contact->adboard_dr) ? $option->contact->adboard_dr : '') }}"
|
||||
fb_live_dr="{{ (isset($option->contact->fb_live_dr) ? $option->contact->fb_live_dr : '') }}"
|
||||
ecme_dr="{{ (isset($option->contact->ecme_dr) ? $option->contact->ecme_dr : '') }}"
|
||||
rtm_dr="{{ (isset($option->contact->rtm_dr) ? $option->contact->rtm_dr : '') }}"
|
||||
|
||||
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<option value="{{ $option->value }}"
|
||||
{{
|
||||
isset($question->value) &&
|
||||
(
|
||||
$question->value == $option->value ||
|
||||
($question->value == 1 && $option->value == 'Yes') ||
|
||||
($question->value == 0 && $option->value == 'No')
|
||||
)
|
||||
? 'selected'
|
||||
: ''
|
||||
}}>
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
|
@ -241,6 +241,41 @@
|
|||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-sankalp_lead_received_penvial').val($('option:selected', this).attr('lead_recieved'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-sankalp_lead_enrolled_penvial').val($('option:selected', this).attr('lead_enrolled'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-pmos_dr').val($('option:selected', this).attr('pmos_dr'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-qbs_dr').val($('option:selected', this).attr('qbs_dr'))
|
||||
})
|
||||
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-adboard_dr').val($('option:selected', this).attr('adboard_dr'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-fb_live_dr').val($('option:selected', this).attr('fb_live_dr'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-ecme_dr').val($('option:selected', this).attr('ecme_dr'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-rtm_dr').val($('option:selected', this).attr('rtm_dr'))
|
||||
})
|
||||
|
||||
|
||||
|
||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||
|
||||
/* $('#field-pen_rx_count,#field-vial_rx_count,#field-pen_pob_units,#field-vial_pob_units,#field-sankalp_lead_received_penvial,#field-pmos_dr,#field-qbs_dr,#field-adboard_dr,#field-fb_live_dr,#field-ecme_dr,#field-rtm_dr,#field-sankalp_lead_enrolled_penvial').parent().hide();
|
||||
|
|
@ -354,121 +389,263 @@ $('#field-select_brand').on('change', function () {
|
|||
$('#field-select_brand').trigger('change');
|
||||
});
|
||||
|
||||
// $('#field-sankalp_lead_received_penvial').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
/*$('#field-sankalp_lead_received_penvial').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="sankalp_recieved"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="sankalp_recieved"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="sankalp_recieved" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="sankalp_recieved" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// $('#field-sankalp_lead_enrolled_penvial').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-sankalp_lead_enrolled_penvial').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="sankalp_enrolled"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="sankalp_enrolled"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="sankalp_enrolled" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="sankalp_enrolled" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// $('#field-pmos_dr').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-pmos_dr').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="pmos_dr"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="pmos_dr"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="pmos_dr" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="pmos_dr" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// $('#field-qbs_dr').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-qbs_dr').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="qbs_dr"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="qbs_dr"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="qbs_dr" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="qbs_dr" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// $('#field-adboard_dr').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-adboard_dr').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="adboard_dr"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="adboard_dr"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="adboard_dr" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="adboard_dr" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// $('#field-fb_live_dr').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-fb_live_dr').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="fb_live_dr"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="fb_live_dr"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="fb_live_dr" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="fb_live_dr" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// $('#field-ecme_dr').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-ecme_dr').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="ecme_dr"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="ecme_dr"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="ecme_dr" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="ecme_dr" value="1">'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// $('#field-rtm_dr').on('change', function () {
|
||||
// let value = $(this).val();
|
||||
$('#field-rtm_dr').on('change', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// // Pehle existing hidden input hata do
|
||||
// $('input[name="rtm_dr"]').remove();
|
||||
// Pehle existing hidden input hata do
|
||||
$('input[name="rtm_dr"]').remove();
|
||||
|
||||
// // Sirf Yes pe value bhejo
|
||||
// if (value === 'Yes') {
|
||||
// $('#report-form').append(
|
||||
// '<input type="hidden" name="rtm_dr" value="1">'
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// Sirf Yes pe value bhejo
|
||||
if (value === 'Yes') {
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" name="rtm_dr" value="1">'
|
||||
);
|
||||
}
|
||||
});*/
|
||||
|
||||
|
||||
// =====================================================
|
||||
// FETCH PREVIOUS SUBMISSION FOR SELECTED DOCTOR
|
||||
// ONLY FOR THIS FORM
|
||||
// =====================================================
|
||||
|
||||
const targetFormId = '1788239728-6f7f3c27-c5dc-4e6e-a042-aefd5681af3a';
|
||||
|
||||
$('#field-contact_id').on('change.previousData', function () {
|
||||
|
||||
const currentFormId = $('input[name="form_id"]').val();
|
||||
|
||||
// Run only for this form
|
||||
if (currentFormId !== targetFormId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const doctorId = $(this).val();
|
||||
|
||||
if (!doctorId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userId = $('#field-user_id').val();
|
||||
const partition = '{{ $form->partition }}';
|
||||
|
||||
if (!userId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#pageloader").fadeIn();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/form/getformfielddata",
|
||||
|
||||
data: {
|
||||
_token: $('input[name="_token"]').val(),
|
||||
form_id: targetFormId,
|
||||
user_id: userId,
|
||||
partition: partition,
|
||||
|
||||
// We are NOT looking for a particular date.
|
||||
// We want all previous submissions.
|
||||
record_date: ''
|
||||
},
|
||||
|
||||
success: function (response) {
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
if (
|
||||
!response.submissions ||
|
||||
!Array.isArray(response.submissions)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// FIND PREVIOUS SUBMISSIONS FOR THIS DOCTOR
|
||||
// ==========================================
|
||||
|
||||
const doctorSubmissions = response.submissions.filter(function (submission) {
|
||||
|
||||
if (!submission.formdata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return String(submission.formdata.contact_id || '') === String(doctorId);
|
||||
});
|
||||
|
||||
if (doctorSubmissions.length === 0) {
|
||||
|
||||
// No previous data for this doctor
|
||||
return;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// GET LATEST SUBMISSION
|
||||
// ==========================================
|
||||
|
||||
doctorSubmissions.sort(function (a, b) {
|
||||
|
||||
const dateA = new Date(
|
||||
a.updatedAt || a.createdAt || 0
|
||||
);
|
||||
|
||||
const dateB = new Date(
|
||||
b.updatedAt || b.createdAt || 0
|
||||
);
|
||||
|
||||
return dateB - dateA;
|
||||
});
|
||||
|
||||
const previousData = doctorSubmissions[0].formdata;
|
||||
|
||||
// ==========================================
|
||||
// AUTO POPULATE ALL PREVIOUS FIELDS
|
||||
// ==========================================
|
||||
|
||||
Object.keys(previousData).forEach(function (fieldCode) {
|
||||
|
||||
const field = $('#field-' + fieldCode);
|
||||
|
||||
if (!field.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't change the selected doctor
|
||||
if (fieldCode === 'contact_id') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't populate file inputs
|
||||
if (field.attr('type') === 'file') {
|
||||
return;
|
||||
}
|
||||
|
||||
const value = previousData[fieldCode];
|
||||
|
||||
if (value === null || value === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
field.val(value);
|
||||
|
||||
// Important for dropdowns such as Select Brand
|
||||
field.trigger('change');
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
error: function (xhr) {
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
console.log(
|
||||
"Failed to fetch previous submission:",
|
||||
xhr.responseText
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
|
|
|
|||
Loading…
Reference in New Issue