Team 3 (TOBA TITANS Reporting)
Specific Folder FTP Upload / ftp-deploy (push) Successful in 28s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 28s
Details
This commit is contained in:
parent
5f84b45375
commit
b4368976a5
|
|
@ -4,6 +4,7 @@
|
|||
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
<link href="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
|
|
@ -40,6 +41,8 @@
|
|||
@endif
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
|
|
@ -56,6 +59,7 @@
|
|||
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@foreach($questions as $question)
|
||||
<div class="col-md-12 mb-2">
|
||||
|
|
@ -65,137 +69,48 @@
|
|||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
<input
|
||||
type="text"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}"
|
||||
@if($form_id == '1793766025-480d8dde-07b3-497d-b55c-4f34a08ad5d1')
|
||||
@if(in_array($question->code, ['msl_code', 'pcode', 'speciality']))
|
||||
readonly
|
||||
@endif
|
||||
@if(in_array($question->question, ['Hospital/Clinic Name', 'City', 'Current NEB 1 Brand Prescribers']))
|
||||
oninput="this.value = this.value.replace(/[^a-zA-Z .'-]/g, '')"
|
||||
@endif
|
||||
@endif
|
||||
>
|
||||
@break
|
||||
|
||||
@case('email')
|
||||
<input type="email"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@break
|
||||
|
||||
@case('tel')
|
||||
<input type="tel"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@break
|
||||
|
||||
@case('date')
|
||||
<input type="date"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}"
|
||||
@if($form_id == '1793766025-480d8dde-07b3-497d-b55c-4f34a08ad5d1' && $question->code == 'record_date')
|
||||
min="2026-11-01"
|
||||
max="{{date('Y-m-d')}}"
|
||||
@endif>
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('number')
|
||||
<input
|
||||
type="text"
|
||||
inputmode="numeric"
|
||||
pattern="[0-9]*"
|
||||
min="0"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}"
|
||||
@if($form_id == '1793766025-480d8dde-07b3-497d-b55c-4f34a08ad5d1')
|
||||
oninput="this.value = this.value.replace(/[^0-9]/g, '')"
|
||||
@endif
|
||||
>
|
||||
<input type="{{$question->type}}" min="0" max="9999999999" step="1" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@case('radio')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-success">
|
||||
<input class="form-check-input" type="radio" name="{{$question->code}}" id="field-{{$question->code}}_{{$option->value}}" value="{{$option->value}}">
|
||||
<label class="form-check-label" for="field-{{$question->code}}_{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('radiometrix')
|
||||
@php
|
||||
// Decode the first option's value to use as heading labels
|
||||
$headings =
|
||||
count($question->options) > 0
|
||||
? json_decode($question->options[0]->value)
|
||||
: [];
|
||||
@endphp
|
||||
|
||||
{{-- Matrix Wrapper with Horizontal Scroll on Small Screens --}}
|
||||
<div class="table-responsive">
|
||||
<div class="d-table w-100">
|
||||
{{-- Table Headers --}}
|
||||
<div class="d-table-row font-weight-bold">
|
||||
<div class="d-table-cell p-2" style="width: 150px;"></div>
|
||||
{{-- Placeholder for row labels --}}
|
||||
@foreach ($headings as $head)
|
||||
<div class="d-table-cell text-center p-2">{{ $head }}
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
{{-- Table Rows --}}
|
||||
@foreach ($question->options as $option)
|
||||
@php $nn = json_decode($option->value); @endphp
|
||||
<div class="d-table-row align-middle">
|
||||
<div class="d-table-cell font-weight-bold p-2"
|
||||
style="width: 150px;">
|
||||
<select class="form-control" {!!($question->code
|
||||
== 'contact_id')?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' && isset($option->contact->toba_titans_drs) && $option->contact->toba_titans_drs == 'Yes' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
||||
pcode="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<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 }}
|
||||
</div>
|
||||
|
||||
@foreach ($nn as $value)
|
||||
<div class="d-table-cell text-center p-2">
|
||||
<input type="radio"
|
||||
id="field-{{ $option->display }}-{{ $value }}"
|
||||
name="{{ $question->code }}[{{$option->display}}]" value="{{$value}}" class="form-check-input"
|
||||
{{ isset($question->display) && $option->display != $option->display ? 'checked' : '' }}>
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@break
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary ms-2">
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
|
|
@ -218,7 +133,17 @@
|
|||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@break
|
||||
@break
|
||||
|
||||
@case('time')
|
||||
<input type="time"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@break
|
||||
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
|
|
@ -259,85 +184,106 @@
|
|||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
.form-label {
|
||||
font-weight:bold;
|
||||
font-size:16px;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#field-user_id').on('change', function () {
|
||||
|
||||
let hierarchy = $(this).find('option:selected').attr('hierarchy');
|
||||
|
||||
$('#field-hierarchy_id').val(hierarchy || '');
|
||||
|
||||
if (!hierarchy) return;
|
||||
|
||||
$('#pageloader').fadeIn();
|
||||
|
||||
$('[data-toggle="select2"]').select2();
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
$('#field-hierarchy_id').val(hierarchy)
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/form/getdoctorlist',
|
||||
data: {
|
||||
partition: @json($form->partition),
|
||||
hierarchy: hierarchy,
|
||||
@if($form_id == '1793766025-480d8dde-07b3-497d-b55c-4f34a08ad5d1')
|
||||
attribute: 'toba_titans_drs',
|
||||
attribute_value: 'Yes'
|
||||
@endif
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for (let itm of data) {
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality));
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
},
|
||||
|
||||
success: function (data) {
|
||||
|
||||
$('#pageloader').fadeOut();
|
||||
|
||||
console.log('Doctor API response:', data);
|
||||
|
||||
let doctorDropdown = $('#field-contact_id');
|
||||
|
||||
doctorDropdown.empty();
|
||||
doctorDropdown.append('<option value=""> -- Select -- </option>');
|
||||
|
||||
$.each(data, function (index, itm) {
|
||||
|
||||
let contact = itm.contact || itm;
|
||||
|
||||
let option = $('<option></option>')
|
||||
.val(itm.value)
|
||||
.text(itm.display)
|
||||
.attr('msl_code', contact.legacy_code || '')
|
||||
.attr('pcode', contact.msl_code || '')
|
||||
.attr('speciality', contact.speciality || '');
|
||||
|
||||
console.log('Creating doctor option:', {
|
||||
name: itm.display,
|
||||
legacy_code: contact.legacy_code,
|
||||
msl_code: contact.msl_code,
|
||||
speciality: contact.speciality
|
||||
});
|
||||
|
||||
doctorDropdown.append(option);
|
||||
});
|
||||
|
||||
$('#field-msl_code, #field-pcode, #field-speciality').val('');
|
||||
|
||||
// Trigger only AFTER options are populated
|
||||
$('#field-contact_id').trigger('change');
|
||||
|
||||
},
|
||||
|
||||
error: function (xhr) {
|
||||
$('#pageloader').fadeOut();
|
||||
console.error('Doctor list request failed:', xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-pcode').val($('option:selected', this).attr('pcode'))
|
||||
})
|
||||
|
||||
$('#field-msl_code,#field-pcode,#field-speciality').attr('readonly',true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// $('#field-contact_id').append('<option value="others">Others</option>');
|
||||
|
||||
|
||||
|
||||
$('#field-file_upload').on('change', function () {
|
||||
let file = this.files[0];
|
||||
|
||||
if (file) {
|
||||
let allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
|
||||
let maxSize = 10 * 1024 * 1024; // 10 MB
|
||||
|
||||
// Type validation
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
alert('Only PNG, JPG, and JPEG files are allowed.');
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// Size validation
|
||||
if (file.size > maxSize) {
|
||||
alert('File size should not exceed 10 MB.');
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#field-contact_id').trigger('change');
|
||||
});
|
||||
|
||||
$('#field-city,#field-hospitalclinic_name,#field-current_neb_1_brand_prescribers').on('input', function () {
|
||||
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||
});
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
// Log form data to console
|
||||
for (let [key, value] of formData.entries()) {
|
||||
console.log(key, value);
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
|
@ -352,13 +298,15 @@
|
|||
title: 'Great!',
|
||||
text: 'Your data is successfully submitted!',
|
||||
icon: 'success'
|
||||
})
|
||||
}).then(() => {
|
||||
location.reload(); // 🔥 page refresh here
|
||||
});
|
||||
$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: data.hasOwnProperty('message') ? 'You are not mapped to any position code' : 'Data not submitted',
|
||||
text: data.hasOwnProperty('message') ? 'for resolution please email Position code, L1 Manager and L2 Manager details to support1@stratawiz.com':'Something went wrong, please try again after some time!'
|
||||
title: 'Data not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
@ -373,38 +321,7 @@
|
|||
|
||||
var plandateField = document.getElementById('field-record_date');
|
||||
|
||||
if (plandateField && @json($form_id) === '1793766025-480d8dde-07b3-497d-b55c-4f34a08ad5d1') {
|
||||
plandateField.min = '2026-11-01';
|
||||
plandateField.max = today;
|
||||
}
|
||||
|
||||
// Make fields readonly
|
||||
$('#field-msl_code, #field-pcode, #field-speciality')
|
||||
.prop('readonly', true);
|
||||
|
||||
|
||||
$(document).on('change', '#field-contact_id', function () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
|
||||
let legacyCode = selectedOption.attr('msl_code') || '';
|
||||
let mslCode = selectedOption.attr('pcode') || '';
|
||||
let speciality = selectedOption.attr('speciality') || '';
|
||||
|
||||
$('#field-msl_code').val(legacyCode);
|
||||
$('#field-pcode').val(mslCode);
|
||||
$('#field-speciality').val(speciality);
|
||||
|
||||
console.log('Doctor selected:', selectedOption.text());
|
||||
console.log('Populated fields:', {
|
||||
legacyCode: legacyCode,
|
||||
mslCode: mslCode,
|
||||
speciality: speciality
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in New Issue