541 lines
28 KiB
PHP
541 lines
28 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
@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="{{ URL::asset('assets/libs/dropify/dropify.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..." />
|
|
</div>
|
|
|
|
<body class="loading">
|
|
<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">
|
|
<div class="card-body p-3 row">
|
|
|
|
@if (Session::has('error'))
|
|
<div class="alert alert-danger">{{ Session::get('error') }}</div>
|
|
<br>
|
|
@endif
|
|
@if (session('success'))
|
|
<div class=" alert alert-success">{{ session('success') }}
|
|
</div>
|
|
<br>
|
|
@endif
|
|
<div class="col-8">
|
|
<h4 class="page-title">{{ $form->title }}</h4>
|
|
</div>
|
|
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'))
|
|
<div class="col-4">
|
|
@if ($form->link_type == 'form')
|
|
<a href="/form/history" class="float-end pt-1">View History</a>
|
|
@else
|
|
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
@if (isset($form->user_info))
|
|
<div class="col-12">
|
|
<h6>Submitted By: {{ $form->user_info->name }}</h6>
|
|
</div>
|
|
@endif
|
|
<input type="hidden" name="expert_forum_gfb_clinics_zvt_camp"
|
|
id="expert_forum_gfb_clinics_zvt_camp" value="0">
|
|
<input type="hidden" name="expert_forum_gfb_clinics_zvt" id="expert_forum_gfb_clinics_zvt"
|
|
value="0">
|
|
<input type="hidden" name="gfb_clinics_zvt" id="gfb_clinics_zvt" value="0">
|
|
|
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
|
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
|
@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 }}"
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
|
{{ $option->display }}</option>
|
|
@endforeach
|
|
</select>
|
|
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id"
|
|
value="">
|
|
</div>
|
|
@endif
|
|
|
|
@foreach ($questions as $question)
|
|
@if (
|
|
$question->type == 'file' &&
|
|
strpos($question->code, 'upload_rx_file') == 0 &&
|
|
$question->code != 'upload_rx_file_1')
|
|
@continue;
|
|
@endif
|
|
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-{{ $question->code }}"
|
|
class="form-label">{{ $question->question }} {!! $question->required == 'yes' ? '<span class="text-danger">*</span>' : '' !!}
|
|
{{ strpos($question->code, 'upload_rx_file') }}
|
|
</label>
|
|
@switch($question->type)
|
|
@case('hidden')
|
|
<input type="{{ $question->type }}" id="field-{{ $question->code }}"
|
|
name="{{ $question->code }}"
|
|
value="{{ isset($question->value) ? $question->value : '' }}">
|
|
@break
|
|
|
|
@case('text')
|
|
@case('email')
|
|
|
|
@case('tel')
|
|
@case('date')
|
|
<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="{{ $question->type }}" min="0" max="9999999999"
|
|
step="1" id="field-{{ $question->code }}"
|
|
name="{{ $question->code }}" class="form-control"
|
|
{{ $question->code == 'no_of_rx_count' || $question->code == 'no_of_attachments' ? 'readonly' : '' }}
|
|
{{ $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)
|
|
@if ($question->code == 'contact_id')
|
|
@if (isset($option->contact->gfb_mdi) && $option->contact->gfb_mdi == 'Yes')
|
|
<option value="{{ $option->value }}"
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
|
{{ $question->code == 'contact_id' ? ' msl_code=' . $option->contact->msl_code : '' }}>
|
|
{{ $option->display }}</option>
|
|
@endif
|
|
@elseif($question->code == 'other_doctor_name')
|
|
<option value="{{ $option->value }}"
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
|
{{ $question->code == 'other_doctor_name' ? ' msl_code=' . $option->contact->msl_code : '' }}>
|
|
{{ $option->display }}</option>
|
|
@else
|
|
<option value="{{ $option->value }}"
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
|
{{ $option->display }}</option>
|
|
@endif
|
|
@endforeach
|
|
@if ($question->code == 'contact_id')
|
|
<option value="other">other</option>
|
|
@else
|
|
@endif
|
|
</select>
|
|
@break
|
|
|
|
@case('checkbox')
|
|
@foreach ($question->options as $option)
|
|
<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>
|
|
@endforeach
|
|
@break
|
|
|
|
@case('file')
|
|
<div class="row">
|
|
<div class="col-9 mt-2">
|
|
<input type="file" id="field-{{ $question->code }}"
|
|
name="{{ $question->code }}" class="form-control dropify"
|
|
value="" accept="image/jpg, image/jpeg, image/png">
|
|
</div>
|
|
<div class="col-3">
|
|
<button type="button" id="btn-add-file"
|
|
class="btn btn-xs btn-success waves-effect waves-light">Add
|
|
Attachment</button>
|
|
|
|
</div>
|
|
<div class="image-block">
|
|
|
|
</div>
|
|
</div>
|
|
@break
|
|
|
|
@case('multitextbox')
|
|
<div class="row">
|
|
@foreach ($question->options as $option)
|
|
<div class="col-6">{{ $option->display }}</div>
|
|
<div class="col-6 mb-1">
|
|
<input type="number" id="field-{{ $option->value }}"
|
|
name="{{ $option->value }}" class="form-control dropify" required
|
|
value="{{ isset($option->val) ? $option->val : 0 }}">
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@break
|
|
@endswitch
|
|
</div>
|
|
@endforeach
|
|
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'))
|
|
<div class="text-center d-grid mt-3">
|
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
|
</button>
|
|
</div>
|
|
@endif
|
|
</form>
|
|
|
|
</div> <!-- end card-body -->
|
|
</div>
|
|
<!-- end card -->
|
|
|
|
<!-- end row -->
|
|
|
|
</div> <!-- end col -->
|
|
</div>
|
|
<!-- end row -->
|
|
</div>
|
|
<!-- end container -->
|
|
</div>
|
|
<!-- end page -->
|
|
<style type="text/css">
|
|
#pageloader {
|
|
background: rgba(255, 255, 255, 0.8);
|
|
display: none;
|
|
height: 100%;
|
|
position: fixed;
|
|
width: 100%;
|
|
z-index: 9999;
|
|
}
|
|
|
|
#pageloader img {
|
|
left: 50%;
|
|
margin-left: -32px;
|
|
margin-top: -32px;
|
|
position: absolute;
|
|
top: 50%;
|
|
}
|
|
</style>
|
|
@include('layouts.shared/footer-script')
|
|
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
|
<script src="{{ URL::asset('assets/libs/dropify/dropify.min.js')}}"></script>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($) {
|
|
$('.dropify').dropify({
|
|
messages: {
|
|
'default': 'Drag and drop a file here or click',
|
|
'replace': 'Drag and drop or click to replace',
|
|
'remove': 'Remove',
|
|
'error': 'Ooops, something wrong appended.'
|
|
},
|
|
error: {
|
|
'fileSize': 'The file size is too big (500MB max).'
|
|
}
|
|
});
|
|
|
|
|
|
$('#report-form').trigger("reset");
|
|
$('#field-user_id').change(function() {
|
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
|
$('#field-hierarchy_id').val(hierarchy)
|
|
event.preventDefault();
|
|
$.ajax({
|
|
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));
|
|
}
|
|
},
|
|
});
|
|
|
|
console.log(hierarchy)
|
|
})
|
|
|
|
function delay(time) {
|
|
return new Promise(resolve => setTimeout(resolve, time));
|
|
}
|
|
|
|
$('#report-form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
$("#pageloader").fadeIn();
|
|
|
|
let attachcount = 0;
|
|
$('input[type=file]').each(function(index) {
|
|
if ($(this).val()) {
|
|
attachcount++
|
|
}
|
|
})
|
|
|
|
|
|
delay(1000).then(() => {
|
|
$('#field-no_of_rx_count').val(attachcount)
|
|
$('#field-no_of_attachments').val(attachcount)
|
|
var formData = new FormData($('#report-form')[0]);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/form/ajaxsubmit',
|
|
data: formData,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
// resetval();
|
|
$("#pageloader").fadeOut();
|
|
if (data.status == 'success') {
|
|
Swal.fire({
|
|
title: 'Great!',
|
|
text: 'Your data is successfully submitted!',
|
|
icon: 'success'
|
|
})
|
|
$('#report-form').trigger("reset");
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
// result();
|
|
|
|
|
|
// formData.append('expert_forum_gfb_clinics_zvt_camp', $('#expert_forum_gfb_clinics_zvt_camp')
|
|
// .val());
|
|
// formData.append('expert_forum_gfb_clinics_zvt', $('#expert_forum_gfb_clinics_zvt').val());
|
|
// formData.append('gfb_clinics_zvt', $('#gfb_clinics_zvt').val());
|
|
|
|
|
|
});
|
|
|
|
// $('#field-engagement_commitment_1').on('change', function() {
|
|
// var engagement_commitment_1_val = $('#field-engagement_commitment_1 option:selected').val();
|
|
// $('#engagement_1').val(engagement_commitment_1_val)
|
|
// });
|
|
|
|
// $('#field-engagement_commitment_2').on('change', function() {
|
|
// var engagement_commitment_2_val = $('#field-engagement_commitment_2 option:selected').val();
|
|
// $('#engagement_2').val(engagement_commitment_2_val)
|
|
// });
|
|
|
|
// $('#field-engagement_commitment_3').on('change', function() {
|
|
// var engagement_commitment_3_val = $('#field-engagement_commitment_3 option:selected').val();
|
|
// $('#engagement_3').val(engagement_commitment_3_val)
|
|
// });
|
|
|
|
// function result() {
|
|
// var valueCounts = {};
|
|
// for (var i = 1; i <= 3; i++) {
|
|
// var engagementValue = $('#engagement_' + i).val();
|
|
// if (!(engagementValue in valueCounts)) {
|
|
// valueCounts[engagementValue] = 0;
|
|
// }
|
|
// valueCounts[engagementValue]++;
|
|
// }
|
|
|
|
// for (var value in valueCounts) {
|
|
// if (valueCounts.hasOwnProperty(value)) {
|
|
// console.log('Value: ' + value + ', Count: ' + valueCounts[value]);
|
|
// $('#' + value).val(valueCounts[value])
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
$('#field-gfb_mdi_clinics_execution_date').hide();
|
|
$('label[for="field-gfb_mdi_clinics_execution_date"]').hide();
|
|
$('#field-gfb_mdi_clinic_execution').on('change', function() {
|
|
if ($(this).val() == 'Yes') {
|
|
$('#field-gfb_mdi_clinics_execution_date').show();
|
|
$('label[for="field-gfb_mdi_clinics_execution_date"]').show();
|
|
} else {
|
|
$('#field-gfb_mdi_clinics_execution_date').hide();
|
|
$('label[for="field-gfb_mdi_clinics_execution_date"]').hide();
|
|
|
|
}
|
|
});
|
|
|
|
$('#field-msl_code').prop('readonly', true)
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
|
})
|
|
|
|
$('#field-other_doctor_name').change(function() {
|
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
|
})
|
|
|
|
$('#field-other_doctor_name').hide();
|
|
$('label[for="field-other_doctor_name"]').hide();
|
|
|
|
$('#field-contact_id').on('change', function() {
|
|
if ($(this).val() == 'other') {
|
|
$('#field-other_doctor_name').show();
|
|
$('label[for="field-other_doctor_name"]').show();
|
|
$('#field-msl_code').prop('readonly', false)
|
|
|
|
} else {
|
|
$('#field-other_doctor_name').hide();
|
|
$('label[for="field-other_doctor_name"]').hide();
|
|
$('#field-msl_code').prop('readonly', true)
|
|
|
|
}
|
|
});
|
|
|
|
$('#field-chemist_1_pob_unit, #field-chemist_2_pob_unit, #field-chemist_3_pob_unit, #field-chemist_4_pob_unit, #field-chemist_5_pob_unit')
|
|
.on('keyup', function() {
|
|
var val1 = Number($('#field-chemist_1_pob_unit').val());
|
|
var val2 = Number($('#field-chemist_2_pob_unit').val());
|
|
var val3 = Number($('#field-chemist_3_pob_unit').val());
|
|
var val4 = Number($('#field-chemist_4_pob_unit').val());
|
|
var val5 = Number($('#field-chemist_5_pob_unit').val());
|
|
$('#field-total_pob_unit').val(val1 + val2 + val3 + val4 + val5);
|
|
});
|
|
|
|
|
|
|
|
var today = new Date();
|
|
var dd = String(today.getDate()).padStart(2, '0');
|
|
var mm = String(today.getMonth() + 1).padStart(2, '0');
|
|
var yyyy = today.getFullYear();
|
|
today = yyyy + '-' + mm + '-' + dd;
|
|
|
|
var plandateField = document.getElementById('field-record_date');
|
|
|
|
plandateField.setAttribute('max', today);
|
|
|
|
|
|
// function result() {
|
|
// var selectedVal = $('#field-engagement_commitment').find(":selected").val();
|
|
// var unit = $('#field-pob_received_no_inhaler_unit').val();
|
|
|
|
// if (selectedVal == 'expert_forum_gfb_clinics_zvt_camp') {
|
|
// $('#expert_forum_gfb_clinics_zvt_camp').val(unit);
|
|
// } else if (selectedVal == 'expert_forum_gfb_clinics_zvt') {
|
|
// $('#expert_forum_gfb_clinics_zvt').val(unit);
|
|
// } else if (selectedVal == 'gfb_clinics_zvt') {
|
|
// $('#gfb_clinics_zvt').val(unit);
|
|
// } else {
|
|
|
|
// }
|
|
// }
|
|
|
|
// function resetval() {
|
|
// $('#expert_forum_gfb_clinics_zvt_camp').val('0');
|
|
// $('#expert_forum_gfb_clinics_zvt').val('0');
|
|
// $('#gfb_clinics_zvt').val('0');
|
|
// }
|
|
});
|
|
|
|
var fileInputCount = 1;
|
|
var attachmentcount = 0;
|
|
var addedFiles = [];
|
|
|
|
$('#field-no_of_rx_count').text(attachmentcount)
|
|
$('#field-no_of_attachments').val(attachmentcount)
|
|
$('#btn-add-file').click(function() {
|
|
|
|
if (fileInputCount > 9) {
|
|
$("#btn-add-file").prop('disabled', true);
|
|
return
|
|
}
|
|
|
|
fileInputCount++;
|
|
attachmentcount++;
|
|
|
|
var fileInputId = 'field-upload_rx_' + fileInputCount;
|
|
|
|
$('.image-block').append(
|
|
'<div class="row"><div class="col-9 mt-2"><input type="file" name="upload_rx_file_' +
|
|
fileInputCount + '" id="field-upload_rx_file_' + fileInputCount +
|
|
'" class="form-control dropify" required></div><div class="col-3 mt-2"><button type="button" class="btn btn-danger waves-effect waves-light btn-remove">Remove</button></div></div>'
|
|
);
|
|
|
|
addedFiles.push(fileInputId);
|
|
console.log(addedFiles);
|
|
|
|
$('.btn-remove').unbind();
|
|
$('.btn-remove').click(function() {
|
|
$(this).parent().parent().remove();
|
|
attachmentcount--;
|
|
$('#field-no_of_rx_count').val(attachmentcount)
|
|
$('#field-no_of_attachments').val(attachmentcount)
|
|
});
|
|
$('#field-no_of_rx_count').val(attachmentcount)
|
|
$('#field-no_of_attachments').val(attachmentcount)
|
|
|
|
$('.dropify').unbind()
|
|
$('.dropify').dropify({
|
|
messages: {
|
|
'default': 'Drag and drop a file here or click',
|
|
'replace': 'Drag and drop or click to replace',
|
|
'remove': 'Remove',
|
|
'error': 'Ooops, something wrong appended.'
|
|
},
|
|
error: {
|
|
'fileSize': 'The file size is too big (500MB max).'
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
$('#field-upload_rx_file_1')
|
|
.change(function() {
|
|
if ($(this)[0].files.length > 0) {
|
|
attachmentcount++;
|
|
} else {
|
|
attachmentcount--;
|
|
}
|
|
$('#field-no_of_rx_count').val(attachmentcount)
|
|
$('#field-no_of_attachments').val(attachmentcount)
|
|
});
|
|
|
|
|
|
// var fileCount = 0;
|
|
// $('#execution-upload_rx_file_1, #execution-upload_rx_file_2, #execution-upload_rx_file_3, #execution-upload_rx_file_4, #execution-upload_rx_file_5, #execution-upload_rx_file_6, #execution-upload_rx_file_7, #execution-upload_rx_file_8, #execution-upload_rx_file_9, #execution-upload_rx_file_10')
|
|
// .change(function() {
|
|
// if ($(this)[0].files.length > 0) {
|
|
// fileCount++;
|
|
// }else{
|
|
// fileCount--;
|
|
// }
|
|
// $("#field-no_of_rx_count").val(fileCount);
|
|
// $("#field-no_of_attachments").val(fileCount);
|
|
// });
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|