Merge branch 'main' of http://192.168.1.200:3000/Stratawiz/Rapport-Laravel
Specific Folder FTP Upload / ftp-deploy (push) Successful in 37s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 37s
Details
This commit is contained in:
commit
5ffd78eb9e
|
|
@ -9,7 +9,7 @@
|
|||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
||||
<!-- start page title -->
|
||||
<!-- start page title -->`
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,188 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "History"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
</head>
|
||||
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
</div>
|
||||
<div class="col-4 p-2">
|
||||
<a href="/form/show" class="float-end pt-1">New Submission</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
@if(session()->has('message'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('message') }}
|
||||
</div>
|
||||
@endif
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
<div class="col-12 p-0">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="responsive-table-plugin">
|
||||
<div class="table-rep-plugin">
|
||||
<div class="table-responsive" data-pattern="priority-columns">
|
||||
<table id="tech-companies-1" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="1">Submission Date</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endforeach
|
||||
<th data-priority="1">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($submissions as $submission)
|
||||
<tr>
|
||||
<th>{{date("d M Y", strtotime($submission->updatedAt))}}</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
@if($question->type == 'file')
|
||||
<td><a target="_blank" href="{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :(is_string($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' ) : $code }}" download="{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) : (is_string($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' ) : $code }}" class="btn btn-dark btn-xs"><i class="mdi mdi-cloud-download me-1"></i> Download</a></td>
|
||||
|
||||
@elseif($question->type == 'radiometrix' && isset($submission->formdata->{$code}) && is_object($submission->formdata->{$code}))
|
||||
<td>
|
||||
{{ collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') }}
|
||||
</td>
|
||||
|
||||
@elseif(count((array)$question->options) > 0 && 1==2 )
|
||||
<td>{{ $question->options->{ $submission->formdata->{$code} } }}</td>
|
||||
@else
|
||||
<td>{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :$submission->formdata->{$code} : $code }}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<th>
|
||||
|
||||
@if($question->can_edit == 'yes' || sizeof($submission->workflow_approvals) == 0 )
|
||||
|
||||
@if($submission->workflow == 'yes' && $submission->workflow_status == 'approved')
|
||||
|
||||
<p>Approved</p>
|
||||
|
||||
@else
|
||||
|
||||
{{-- EDIT BUTTON COMMENTED --}}
|
||||
{{--
|
||||
<a href="/form/show?form_id={{$submission->formdata->form_id}}&id={{$submission->id}}"
|
||||
class="btn btn-primary btn-xs">
|
||||
Edit
|
||||
</a>
|
||||
--}}
|
||||
|
||||
@if(true)
|
||||
|
||||
<!-- <a href="/form/delete?form_id={{$submission->formdata->form_id}}&id={{$submission->id}}"
|
||||
class="btn btn-danger btn-xs mt-1">
|
||||
|
||||
Delete
|
||||
|
||||
</a> -->
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger btn-xs mt-1 delete-submission"
|
||||
data-id="{{$submission->id}}"
|
||||
data-form="{{$submission->formdata->form_id}}">
|
||||
|
||||
Delete
|
||||
|
||||
</button>
|
||||
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end .table-responsive -->
|
||||
|
||||
</div> <!-- end .table-rep-plugin-->
|
||||
</div> <!-- end .responsive-table-plugin-->
|
||||
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
<!-- end row-->
|
||||
</div> <!-- container -->
|
||||
|
||||
</div>
|
||||
<!-- end page -->
|
||||
@include('layouts.shared/footer-script')
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
$(document).on(
|
||||
'click',
|
||||
'.delete-submission',
|
||||
function(){
|
||||
|
||||
let formId =
|
||||
$(this).data('form');
|
||||
|
||||
let submissionId =
|
||||
$(this).data('id');
|
||||
|
||||
$.ajax({
|
||||
|
||||
url:
|
||||
'/form/delete?form_id='
|
||||
+ formId
|
||||
+ '&id='
|
||||
+ submissionId,
|
||||
|
||||
type: 'GET',
|
||||
|
||||
success: function(response){
|
||||
|
||||
// reopen form page
|
||||
window.location.href =
|
||||
'/form/show?form_id='
|
||||
+ formId;
|
||||
alert('Deleted successfully');
|
||||
},
|
||||
|
||||
error: function(){
|
||||
|
||||
alert('Delete failed');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -58,6 +58,21 @@
|
|||
@endif
|
||||
|
||||
@foreach($questions as $question)
|
||||
@php
|
||||
|
||||
$hideFields = [
|
||||
'date',
|
||||
'contact_id',
|
||||
'converted'
|
||||
];
|
||||
|
||||
@endphp
|
||||
|
||||
@if(in_array($question->code, $hideFields))
|
||||
|
||||
@continue
|
||||
|
||||
@endif
|
||||
<div class="{{ in_array($question->code, ['upload-supporting-doc1', 'upload-supporting-doc2']) ? 'upload-doc-fields' : '' }} col-md-12 mb-2">
|
||||
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
|
||||
@switch($question->type)
|
||||
|
|
@ -97,8 +112,12 @@
|
|||
// Decode the first option's value to use as heading labels
|
||||
$headings =
|
||||
count($question->options) > 0
|
||||
? json_decode($question->options[0]->value)
|
||||
? json_decode($question->options[0]->value, true)
|
||||
: [];
|
||||
|
||||
if(!is_array($headings)){
|
||||
$headings = [];
|
||||
}
|
||||
@endphp
|
||||
|
||||
{{-- Matrix Wrapper with Horizontal Scroll on Small Screens --}}
|
||||
|
|
@ -116,7 +135,14 @@
|
|||
|
||||
{{-- Table Rows --}}
|
||||
@foreach ($question->options as $option)
|
||||
@php $nn = json_decode($option->value); @endphp
|
||||
@php
|
||||
$nn = json_decode($option->value, true);
|
||||
|
||||
// fallback if invalid json
|
||||
if(!is_array($nn)){
|
||||
$nn = [];
|
||||
}
|
||||
@endphp
|
||||
<div class="d-table-row align-middle">
|
||||
<div class="d-table-cell font-weight-bold p-2"
|
||||
style="width: 150px;">
|
||||
|
|
@ -181,10 +207,173 @@
|
|||
@endforeach
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<div class="col-md-12 mt-3">
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Tagged Doctors</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-0">
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
<table class="table table-bordered mb-0">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th>Doctor Name</th>
|
||||
<th>Speciality</th>
|
||||
<th>Number of Rx</th>
|
||||
<th>MSL Code</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody id="doctor-table-body">
|
||||
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </div>
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
</div> -->
|
||||
@endif
|
||||
</form>
|
||||
<!-- SAMPLE FORM MODAL -->
|
||||
|
||||
<div class="modal fade"
|
||||
id="sampleFormModal"
|
||||
tabindex="-1"
|
||||
aria-hidden="true">
|
||||
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
|
||||
<h5 class="modal-title">
|
||||
Add RX
|
||||
</h5>
|
||||
|
||||
<button type="button"
|
||||
class="btn-close"
|
||||
data-bs-dismiss="modal">
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<form id="sample-form" enctype="multipart/form-data">
|
||||
|
||||
@csrf
|
||||
|
||||
<input type="hidden"
|
||||
name="form_id"
|
||||
value="1779187275-848fd8f3-6ea2-4521-9d85-85ec424fa8d5">
|
||||
|
||||
<!-- hidden category -->
|
||||
<input type="hidden"
|
||||
id="sample-category"
|
||||
name="select-category">
|
||||
|
||||
<!-- hidden doctor -->
|
||||
<input type="hidden"
|
||||
id="sample-doctor-id"
|
||||
name="contact_id">
|
||||
|
||||
<input type="hidden"
|
||||
id="sample-converted"
|
||||
name="converted">
|
||||
|
||||
<input type="hidden"
|
||||
id="sample-category-metric"
|
||||
name="">
|
||||
|
||||
<div class="mb-3 d-none">
|
||||
|
||||
<input type="text"
|
||||
id="sample-doctor-name"
|
||||
class="form-control"
|
||||
readonly>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-3 d-none">
|
||||
|
||||
<input type="text"
|
||||
id="sample-category-display"
|
||||
class="form-control"
|
||||
readonly>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- DATE FIELD -->
|
||||
|
||||
<div class="mb-3">
|
||||
|
||||
<label class="form-label">
|
||||
Date
|
||||
</label>
|
||||
|
||||
<input type="date"
|
||||
id="sample-date"
|
||||
class="form-control"
|
||||
name="date"
|
||||
max="{{ date('Y-m-d') }}"
|
||||
required>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
||||
<label class="form-label">
|
||||
Number of RX
|
||||
</label>
|
||||
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="sample-count"
|
||||
name="sample_count"
|
||||
inputmode="numeric"
|
||||
pattern="[0-9]*"
|
||||
autocomplete="off"
|
||||
required>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="btn btn-primary">
|
||||
|
||||
Submit
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
|
|
@ -230,14 +419,98 @@
|
|||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
@php
|
||||
|
||||
// KEEP ORIGINAL DOCTOR LOGIC
|
||||
|
||||
$doctors = [];
|
||||
foreach($questions as $question) {
|
||||
if($question->code == 'contact_id') {
|
||||
|
||||
foreach($questions as $question){
|
||||
|
||||
if($question->code == 'contact_id'){
|
||||
|
||||
$doctors = $question->options;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// RX HISTORY DATA ONLY
|
||||
|
||||
$history = Formhelper::getMultiformData(
|
||||
$form->partition,
|
||||
$form_id,
|
||||
$form->user_id
|
||||
);
|
||||
|
||||
$doctorRxCounts = [];
|
||||
|
||||
if(isset($history->data->submissions)){
|
||||
|
||||
foreach($history->data->submissions as $sub){
|
||||
|
||||
// only RX entries
|
||||
if(
|
||||
!isset($sub->formdata->sample_count)
|
||||
){
|
||||
continue;
|
||||
}
|
||||
|
||||
$category =
|
||||
strtolower(
|
||||
trim(
|
||||
$sub->formdata->{'select-category'} ?? ''
|
||||
)
|
||||
);
|
||||
|
||||
$doctorName =
|
||||
trim(
|
||||
$sub->formdata->contact_id ?? ''
|
||||
);
|
||||
|
||||
$rxValue =
|
||||
intval(
|
||||
$sub->formdata->sample_count ?? 0
|
||||
);
|
||||
|
||||
if(!$doctorName){
|
||||
continue;
|
||||
}
|
||||
|
||||
// category wise grouping
|
||||
if(!isset($doctorRxCounts[$category])){
|
||||
|
||||
$doctorRxCounts[$category] = [];
|
||||
|
||||
}
|
||||
|
||||
// doctor initialize
|
||||
if(
|
||||
!isset(
|
||||
$doctorRxCounts[$category][$doctorName]
|
||||
)
|
||||
){
|
||||
|
||||
$doctorRxCounts[$category][$doctorName] = 0;
|
||||
|
||||
}
|
||||
|
||||
// add RX
|
||||
$doctorRxCounts[$category][$doctorName]
|
||||
+= $rxValue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@endphp
|
||||
var allDoctors = {!! json_encode($doctors) !!};
|
||||
var doctorRxCounts =
|
||||
{!! json_encode($doctorRxCounts) !!};
|
||||
|
||||
console.log(
|
||||
"DOCTOR RX COUNTS",
|
||||
doctorRxCounts
|
||||
);
|
||||
console.log("INITIAL DOCTORS FROM BACKEND", allDoctors);
|
||||
|
||||
// $.ajax({
|
||||
|
|
@ -303,19 +576,59 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
// convert category slug
|
||||
let categoryKey = selectedCategory
|
||||
.replace(/-/g, '_');
|
||||
const categoryMap = {
|
||||
|
||||
console.log("Checking:", categoryKey, doc.contact[categoryKey]);
|
||||
"foracort-ciphaler": "foracort_ciphaler",
|
||||
|
||||
return doc.contact[categoryKey] === 'yes';
|
||||
"duolin-synchrobreathe": "duolin_synchrobreathe",
|
||||
|
||||
"foracort-g": "foracort_g",
|
||||
|
||||
"pedia": "pedia",
|
||||
|
||||
"triple-combination-voltido-trio-indaflo-g":
|
||||
"triple_combination_voltido_trio_indaflo_g",
|
||||
|
||||
"ics-laba-seroflo-maxiflo-voltido":
|
||||
"ics_laba_seroflo_maxiflo_voltido",
|
||||
|
||||
"competition-dr":
|
||||
"competition_dr"
|
||||
|
||||
};
|
||||
|
||||
let categoryKey = categoryMap[selectedCategory];
|
||||
|
||||
let categoryValue = doc.contact[categoryKey];
|
||||
|
||||
console.log(
|
||||
"Doctor:",
|
||||
doc.display,
|
||||
"Category:",
|
||||
categoryKey,
|
||||
"Value:",
|
||||
categoryValue
|
||||
);
|
||||
|
||||
// normalize value
|
||||
categoryValue = String(categoryValue)
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
|
||||
return (
|
||||
categoryValue === 'yes' ||
|
||||
categoryValue === '1' ||
|
||||
categoryValue === 'true'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
console.log("Filtered Doctors:", filteredDoctors);
|
||||
|
||||
console.log(filteredDoctors);
|
||||
let requiredCount = mandatoryDoctorCount[selectedCategory] || 0;
|
||||
|
||||
let requiredCount =
|
||||
mandatoryDoctorCount[selectedCategory] || 0;
|
||||
if(filteredDoctors.length < requiredCount){
|
||||
|
||||
let categoryName = $('#field-select-category option:selected').text();
|
||||
|
|
@ -337,9 +650,27 @@
|
|||
.attr("value",'')
|
||||
.text('-- Select --')
|
||||
);
|
||||
|
||||
// reset doctor table
|
||||
$('#doctor-table-body').html(`
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
// limit doctors to required count
|
||||
filteredDoctors =
|
||||
filteredDoctors.slice(0, requiredCount);
|
||||
|
||||
console.log(
|
||||
"Final Allowed Doctors:",
|
||||
filteredDoctors.length
|
||||
);
|
||||
|
||||
// NOW render limited doctors
|
||||
renderDoctorTable(filteredDoctors);
|
||||
filteredDoctors.forEach(function(itm){
|
||||
|
||||
$('#field-contact_id').append(
|
||||
|
|
@ -418,73 +749,133 @@
|
|||
|
||||
|
||||
|
||||
function appendConvertedField() {
|
||||
|
||||
// remove old hidden fields
|
||||
$('#report-form input.converted-hidden').remove();
|
||||
|
||||
let convertedValue = $('#field-converted').val();
|
||||
const categoryThresholds = {
|
||||
|
||||
let selectedCategory = $('#field-select-category').val();
|
||||
"foracort-ciphaler": 10,
|
||||
"duolin-synchrobreathe": 10,
|
||||
"foracort-g": 10,
|
||||
"pedia": 5,
|
||||
"triple-combination-voltido-trio-indaflo-g": 10,
|
||||
"ics-laba-seroflo-maxiflo-voltido": 10,
|
||||
"competition-dr": 20
|
||||
|
||||
};
|
||||
|
||||
const conversionMetricFields = {
|
||||
|
||||
"foracort-ciphaler":
|
||||
"foracort_ciphaler",
|
||||
|
||||
"duolin-synchrobreathe":
|
||||
"duolin_synchrobreathe",
|
||||
|
||||
"foracort-g":
|
||||
"foracort_g",
|
||||
|
||||
"pedia":
|
||||
"pedia",
|
||||
|
||||
"triple-combination-voltido-trio-indaflo-g":
|
||||
"triple_combination_voltido_trio_indaflo_g",
|
||||
|
||||
"ics-laba-seroflo-maxiflo-voltido":
|
||||
"ics_laba_seroflo_maxiflo_voltido",
|
||||
|
||||
"competition-dr":
|
||||
"competition_dr"
|
||||
|
||||
};
|
||||
function renderDoctorTable(filteredDoctors){
|
||||
|
||||
let tbody = $('#doctor-table-body');
|
||||
|
||||
tbody.html('');
|
||||
|
||||
if(filteredDoctors.length === 0){
|
||||
|
||||
tbody.html(`
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
`);
|
||||
|
||||
if(!convertedValue || !selectedCategory){
|
||||
return;
|
||||
}
|
||||
|
||||
// category mapping
|
||||
let categoryMap = {
|
||||
filteredDoctors.forEach(function(doc){
|
||||
|
||||
"foracort-ciphaler": "foracort_ciphaler",
|
||||
"duolin-synchrobreathe": "duolin_synchrobreathe",
|
||||
"foracort-g": "foracort_g",
|
||||
"pedia": "pedia",
|
||||
"triple-combination-voltido-trio-indaflo-g": "triple_combination_voltido_trio_indaflo_g",
|
||||
"ics-laba-seroflo-maxiflo-voltido": "ics_laba_seroflo_maxiflo_voltido",
|
||||
"competition-dr": "competition_dr"
|
||||
let doctorName = doc.display || '-';
|
||||
|
||||
};
|
||||
let speciality = doc.contact?.speciality || '-';
|
||||
|
||||
let categoryKey = categoryMap[selectedCategory];
|
||||
let selectedCategory =
|
||||
$('#field-select-category').val();
|
||||
|
||||
if(!categoryKey){
|
||||
return;
|
||||
}
|
||||
let doctorNameKey =
|
||||
(doctorName || '').trim();
|
||||
|
||||
// category data
|
||||
let categoryValue = (convertedValue === 'Yes') ? '1' : '0';
|
||||
let rxCount = 0;
|
||||
|
||||
// append original category field
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="converted-hidden" name="' + categoryKey + '" value="' + categoryValue + '">'
|
||||
);
|
||||
if(
|
||||
doctorRxCounts[selectedCategory] &&
|
||||
doctorRxCounts[selectedCategory][doctorNameKey]
|
||||
){
|
||||
|
||||
// extra metric fields
|
||||
if(convertedValue === 'Yes'){
|
||||
rxCount =
|
||||
doctorRxCounts[selectedCategory][doctorNameKey];
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="converted-hidden" name="conversion_yes" value="1">'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
let mslCode = doc.contact?.msl_code || '-';
|
||||
|
||||
if(convertedValue === 'No'){
|
||||
let doctorId = doc.value || '';
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="converted-hidden" name="conversion_no" value="1">'
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
tbody.append(`
|
||||
|
||||
console.log("Category:", categoryKey, categoryValue);
|
||||
<tr>
|
||||
|
||||
<td>${doctorName}</td>
|
||||
|
||||
<td>${speciality}</td>
|
||||
|
||||
<td>${rxCount}</td>
|
||||
|
||||
<td>${mslCode}</td>
|
||||
|
||||
<td>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-primary open-sample-modal"
|
||||
|
||||
data-doctor-id="${doctorId}"
|
||||
|
||||
data-doctor-name="${doctorName}"
|
||||
|
||||
data-category="${$('#field-select-category').val()}"
|
||||
|
||||
data-category-display="${$('#field-select-category option:selected').text()}">
|
||||
|
||||
Add
|
||||
|
||||
</button>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
`);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$('#field-converted').on('change', appendConvertedField);
|
||||
|
||||
$('#field-select-category').on('change', appendConvertedField);
|
||||
|
||||
|
||||
|
||||
function toggleUploadFields() {
|
||||
|
||||
let value = $('#field-converted').val();
|
||||
|
|
@ -585,41 +976,349 @@ $(document).on('change', '#field-converted', function () {
|
|||
$('#field-select-category').trigger('change');
|
||||
}, 300);
|
||||
@endif
|
||||
$('#report-form').on('submit', function(event){
|
||||
// OPEN SAMPLE MODAL
|
||||
|
||||
$(document).on(
|
||||
'click',
|
||||
'.open-sample-modal',
|
||||
function(){
|
||||
|
||||
let doctorId =
|
||||
$(this).data('doctor-id');
|
||||
|
||||
let doctorName =
|
||||
$(this).data('doctor-name');
|
||||
|
||||
let category =
|
||||
$(this).data('category');
|
||||
|
||||
let categoryDisplay =
|
||||
$(this).data('category-display');
|
||||
|
||||
// set hidden values
|
||||
|
||||
$('#sample-doctor-id').val(doctorId);
|
||||
|
||||
$('#sample-category').val(category);
|
||||
|
||||
// display values
|
||||
|
||||
$('#sample-doctor-name').val(doctorName);
|
||||
|
||||
$('#sample-category-display')
|
||||
.val(categoryDisplay);
|
||||
|
||||
// open modal
|
||||
|
||||
$('#sampleFormModal').modal('show');
|
||||
// set today's date by default
|
||||
$('#sample-date').val(
|
||||
new Date().toISOString().split('T')[0]
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
function appendConvertedField(
|
||||
selectedCategory,
|
||||
convertedValue
|
||||
){
|
||||
|
||||
const categoryMap = {
|
||||
|
||||
"foracort-ciphaler":
|
||||
"foracort_ciphaler",
|
||||
|
||||
"duolin-synchrobreathe":
|
||||
"duolin_synchrobreathe",
|
||||
|
||||
"foracort-g":
|
||||
"foracort_g",
|
||||
|
||||
"pedia":
|
||||
"pedia",
|
||||
|
||||
"triple-combination-voltido-trio-indaflo-g":
|
||||
"triple_combination_voltido_trio_indaflo_g",
|
||||
|
||||
"ics-laba-seroflo-maxiflo-voltido":
|
||||
"ics_laba_seroflo_maxiflo_voltido",
|
||||
|
||||
"competition-dr":
|
||||
"competition_dr"
|
||||
|
||||
};
|
||||
|
||||
let categoryKey =
|
||||
categoryMap[selectedCategory];
|
||||
|
||||
// converted field
|
||||
$('#sample-converted')
|
||||
.val(convertedValue);
|
||||
|
||||
// category metric field
|
||||
$('#sample-category-metric')
|
||||
.attr('name', categoryKey)
|
||||
.val(
|
||||
convertedValue === 'Yes'
|
||||
? 1
|
||||
: 0
|
||||
);
|
||||
|
||||
console.log(
|
||||
"CATEGORY KEY",
|
||||
categoryKey
|
||||
);
|
||||
|
||||
console.log(
|
||||
"CONVERTED",
|
||||
convertedValue
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$('#sample-form').on('submit', function(event){
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
$("#pageloader").fadeIn();
|
||||
// CATEGORY
|
||||
let selectedCategory =
|
||||
$('#sample-category').val().trim();
|
||||
|
||||
// CURRENT RX
|
||||
let rxValue =
|
||||
parseInt(
|
||||
$('#sample-count').val()
|
||||
) || 0;
|
||||
|
||||
// DOCTOR NAME
|
||||
let doctorName =
|
||||
$('#sample-doctor-name').val().trim();
|
||||
|
||||
// thresholds
|
||||
const rxThresholds = {
|
||||
|
||||
"foracort-ciphaler": 10,
|
||||
"duolin-synchrobreathe": 10,
|
||||
"foracort-g": 10,
|
||||
"pedia": 5,
|
||||
"triple-combination-voltido-trio-indaflo-g": 10,
|
||||
"ics-laba-seroflo-maxiflo-voltido": 10,
|
||||
"competition-dr": 20
|
||||
|
||||
};
|
||||
|
||||
// initialize category
|
||||
if(!doctorRxCounts[selectedCategory]){
|
||||
|
||||
doctorRxCounts[selectedCategory] = {};
|
||||
|
||||
}
|
||||
|
||||
// initialize doctor
|
||||
if(
|
||||
!doctorRxCounts[selectedCategory][doctorName]
|
||||
){
|
||||
|
||||
doctorRxCounts[selectedCategory][doctorName] = 0;
|
||||
|
||||
}
|
||||
|
||||
// add rx
|
||||
doctorRxCounts[selectedCategory][doctorName]
|
||||
+= rxValue;
|
||||
|
||||
// total rx
|
||||
let totalRx =
|
||||
doctorRxCounts[selectedCategory][doctorName];
|
||||
|
||||
// threshold
|
||||
let requiredRx =
|
||||
rxThresholds[selectedCategory] || 0;
|
||||
|
||||
// converted
|
||||
let convertedValue = 'No';
|
||||
|
||||
if(totalRx >= requiredRx){
|
||||
|
||||
convertedValue = 'Yes';
|
||||
|
||||
}
|
||||
|
||||
// append hidden fields
|
||||
appendConvertedField(
|
||||
selectedCategory,
|
||||
convertedValue
|
||||
);
|
||||
|
||||
console.log(
|
||||
$('#sample-form').serialize()
|
||||
);
|
||||
|
||||
$.ajax({
|
||||
|
||||
type: "POST",
|
||||
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
|
||||
data: new FormData($('#sample-form')[0]),
|
||||
|
||||
processData: false,
|
||||
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
console.log(allDoctors);
|
||||
console.log(data);
|
||||
|
||||
success: function(data){
|
||||
|
||||
$("#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.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!'
|
||||
})
|
||||
|
||||
console.log("SAMPLE FORM RESPONSE", data);
|
||||
|
||||
if(data.status == 'success'){
|
||||
|
||||
// let selectedCategory =
|
||||
// $('#sample-category').val();
|
||||
|
||||
// let rxValue =
|
||||
// parseInt($('#sample-count').val()) || 0;
|
||||
|
||||
// // initialize category
|
||||
// if(!doctorRxCounts[selectedCategory]){
|
||||
|
||||
// doctorRxCounts[selectedCategory] = {};
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// let doctorName =
|
||||
// $('#sample-doctor-name').val().trim();
|
||||
|
||||
// // initialize doctor
|
||||
// if(
|
||||
// !doctorRxCounts[selectedCategory][doctorName]
|
||||
// ){
|
||||
|
||||
// doctorRxCounts[selectedCategory][doctorName] = 0;
|
||||
|
||||
// }
|
||||
|
||||
// // add rx
|
||||
// doctorRxCounts[selectedCategory][doctorName]
|
||||
// += rxValue;
|
||||
|
||||
// let totalRx =
|
||||
// doctorRxCounts[selectedCategory][doctorName];
|
||||
|
||||
// CATEGORY TARGET
|
||||
|
||||
let requiredRx =
|
||||
categoryThresholds[selectedCategory] || 0;
|
||||
|
||||
// AUTO CONVERSION
|
||||
let convertedValue = 'No';
|
||||
|
||||
if(totalRx >= requiredRx){
|
||||
|
||||
convertedValue = 'Yes';
|
||||
|
||||
}
|
||||
appendConvertedField(
|
||||
selectedCategory,
|
||||
convertedValue
|
||||
);
|
||||
|
||||
console.log(
|
||||
"TOTAL RX",
|
||||
totalRx
|
||||
);
|
||||
|
||||
console.log(
|
||||
"REQUIRED RX",
|
||||
requiredRx
|
||||
);
|
||||
|
||||
console.log(
|
||||
"CONVERTED",
|
||||
convertedValue
|
||||
);
|
||||
|
||||
console.log(
|
||||
"UPDATED RX COUNTS",
|
||||
doctorRxCounts
|
||||
);
|
||||
|
||||
$('#sampleFormModal').modal('hide');
|
||||
|
||||
$('#sample-form')[0].reset();
|
||||
|
||||
$('#field-select-category').trigger('change');
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
error: function(){
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
Swal.fire({
|
||||
|
||||
icon: 'error',
|
||||
|
||||
title: 'Error',
|
||||
|
||||
text: 'Something went wrong'
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
// allow only whole numbers in sample count
|
||||
|
||||
$(document).on('keypress', '#sample-count', function(e){
|
||||
|
||||
// allow only 0-9
|
||||
|
||||
if(
|
||||
e.which < 48 ||
|
||||
e.which > 57
|
||||
){
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).on('paste', '#sample-count', function(e){
|
||||
|
||||
let pastedData =
|
||||
(e.originalEvent || e)
|
||||
.clipboardData
|
||||
.getData('text');
|
||||
|
||||
if(!/^\d+$/.test(pastedData)){
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).on('input', '#sample-count', function(){
|
||||
|
||||
this.value =
|
||||
this.value.replace(/[^0-9]/g, '');
|
||||
|
||||
});
|
||||
$('input[type="date"]').attr(
|
||||
'max',
|
||||
new Date().toISOString().split("T")[0]
|
||||
);
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ $brandData = [
|
|||
{{$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' : '' }}>
|
||||
<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' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . $option->contact->speciality . ' ' : '' }} >
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
|
|
@ -96,7 +97,7 @@
|
|||
<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':'' }}>
|
||||
<select class="form-control select2" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}"
|
||||
|
|
@ -234,8 +235,14 @@
|
|||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('.select2').select2({
|
||||
placeholder: '-- Select Doctor --',
|
||||
allowClear: true,
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
|
|
@ -87,7 +88,7 @@
|
|||
<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':'' }}>
|
||||
<select class="form-control select2" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}"
|
||||
|
|
@ -228,8 +229,15 @@
|
|||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
$('.select2').select2({
|
||||
placeholder: '-- Select Doctor --',
|
||||
allowClear: true,
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
$(document).on(
|
||||
|
|
|
|||
|
|
@ -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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
|
|
@ -80,7 +81,7 @@
|
|||
<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' : '' }}>
|
||||
<select class="form-control 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' )
|
||||
|
|
@ -186,8 +187,14 @@
|
|||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('.select2').select2({
|
||||
placeholder: '-- Select Doctor --',
|
||||
allowClear: true,
|
||||
width: '100%'
|
||||
});
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
$('#field-hierarchy_id').val(hierarchy)
|
||||
|
|
|
|||
|
|
@ -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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
|
|
@ -80,7 +81,7 @@
|
|||
<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' : '' }}>
|
||||
<select class="form-control 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' )
|
||||
|
|
@ -186,8 +187,14 @@
|
|||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('.select2').select2({
|
||||
placeholder: '-- Select Doctor --',
|
||||
allowClear: true,
|
||||
width: '100%'
|
||||
});
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
$('#field-hierarchy_id').val(hierarchy)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,656 @@
|
|||
<!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" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
</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
|
||||
<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)
|
||||
<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>':''!!} </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':'' }}
|
||||
{{ in_array($question->code, ['msl_code', 'speciality']) ? 'readonly' : '' }}
|
||||
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->required == 'yes'?'required':'' }}
|
||||
value="{{isset($question->value)?$question->value:0}}"
|
||||
{{ $question->code == 'total_lobg_rx' ? 'readonly' : '' }}>
|
||||
@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 select2" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}"
|
||||
msl_code="{{isset($option->contact->msl_code) ? $option->contact->msl_code : ''}}"
|
||||
speciality="{{isset($option->contact->speciality) ? $option->contact->speciality : ''}}"
|
||||
{{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;">
|
||||
{{ $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
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary ms-2">
|
||||
<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')
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" {{$question->required == 'yes'?'required':'' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
@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" 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%;
|
||||
}
|
||||
.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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('.select2').select2({
|
||||
placeholder: '-- Select Doctor --',
|
||||
allowClear: true,
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Hide All Fields Initially
|
||||
|
||||
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').prop({"required":false});
|
||||
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').parent().hide();
|
||||
|
||||
|
||||
// Reset Total Fields Immediately
|
||||
$('#field-total_pob_units').val(0);
|
||||
$('#field-total_pob_value').val(0);
|
||||
|
||||
// Reset all fields
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').prop({"required":false});
|
||||
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').parent().hide();
|
||||
|
||||
// Reset Total Immediately
|
||||
$('#field-total_pob_units').val(0);
|
||||
$('#field-total_pob_value').val(0);
|
||||
|
||||
|
||||
|
||||
|
||||
// Make Value & Total Fields Readonly
|
||||
|
||||
|
||||
$('#field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').prop('readonly', true);
|
||||
|
||||
|
||||
|
||||
// Brand Dropdown Change
|
||||
|
||||
|
||||
$('#field-select_brand').on('change',function(){
|
||||
// Reset all unit/value field values
|
||||
$('input[id*="_units"], input[id*="_value"]').val('');
|
||||
$('#field-total_pob_units').val(0);
|
||||
$('#field-total_pob_value').val(0);
|
||||
|
||||
let dropDown = $('#field-select_brand').val();
|
||||
|
||||
// Reset all fields
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').prop({"required":false});
|
||||
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value, #field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value, #field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value, #field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value, #field-total_pob_units, #field-total_pob_value').parent().hide();
|
||||
|
||||
|
||||
|
||||
// Sitazit
|
||||
|
||||
if(dropDown === 'Sitazit'){
|
||||
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value').prop({"required":true});
|
||||
|
||||
$('#field-sitazit_d_10100_pob_units, #field-sitazit_d_550_pob_units, #field-sitazit_dm_er_100010_pob_units, #field-sitazit_dm_er_50010_pob_units, #field-sitazit_d_10100_pob_value, #field-sitazit_d_550_pob_value, #field-sitazit_dm_er_100010_pob_value, #field-sitazit_dm_er_50010_pob_value').parent().show();
|
||||
|
||||
$('#field-total_pob_units, #field-total_pob_value').prop({"required":true});
|
||||
$('#field-total_pob_units, #field-total_pob_value').parent().show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Eptus
|
||||
|
||||
else if(dropDown === 'Eptus'){
|
||||
|
||||
$('#field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value').prop({"required":true});
|
||||
|
||||
$('#field-eptus_25mg_units, #field-eptus_50_mg_units, #field-eptus_t_10_kit_units, #field-eptus_t_20_kit_units, #field-eptus_25mg_value, #field-eptus_50_mg_value, #field-eptus_t_10_kit_value, #field-eptus_t_20_kit_value').parent().show();
|
||||
|
||||
$('#field-total_pob_units, #field-total_pob_value').prop({"required":true});
|
||||
$('#field-total_pob_units, #field-total_pob_value').parent().show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// LOBG
|
||||
|
||||
else if(dropDown === 'LOBG'){
|
||||
|
||||
$('#field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value').prop({"required":true});
|
||||
|
||||
$('#field-lo_bg_05_mg_units, #field-lo_bg_05_mg_value').parent().show();
|
||||
|
||||
$('#field-total_pob_units, #field-total_pob_value').prop({"required":true});
|
||||
$('#field-total_pob_units, #field-total_pob_value').parent().show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ziten
|
||||
|
||||
else if(dropDown === 'Ziten'){
|
||||
|
||||
$('#field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value').prop({"required":true});
|
||||
|
||||
$('#field-ziten_m_20_mg_1000_mg_units, #field-ziten_m_20_mg_500_mg_units, #field-ziten_units, #field-ziten_m_20_mg_1000_mg_value, #field-ziten_m_20_mg_500_mg_value, #field-ziten_value').parent().show();
|
||||
|
||||
$('#field-total_pob_units, #field-total_pob_value').prop({"required":true});
|
||||
$('#field-total_pob_units, #field-total_pob_value').parent().show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Auto Calculation Function
|
||||
// Formula = Units * 100
|
||||
|
||||
|
||||
// Auto Calculation Function
|
||||
|
||||
function calculateField(unitField, valueField, ptsValue){
|
||||
|
||||
$(unitField).on('input', function(){
|
||||
|
||||
let units = parseInt($(this).val()) || 0;
|
||||
|
||||
// Formula = Units × PTS
|
||||
let value = units * ptsValue;
|
||||
|
||||
// Round to 2 decimal
|
||||
value = value.toFixed(2);
|
||||
|
||||
$(valueField).val(value);
|
||||
|
||||
calculateTotals();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Total Calculation
|
||||
|
||||
|
||||
// function calculateTotals(){
|
||||
|
||||
// let totalUnits = 0;
|
||||
// let totalValue = 0;
|
||||
|
||||
|
||||
// // Total Units (Visible Only)
|
||||
|
||||
// $('input[id*="_units"]:visible').each(function(){
|
||||
|
||||
// if($(this).attr('id') !== 'field-total_pob_units'){
|
||||
|
||||
// totalUnits += parseFloat($(this).val()) || 0;
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// // Total Value (Visible Only)
|
||||
|
||||
// $('input[id*="_value"]:visible').each(function(){
|
||||
|
||||
// if($(this).attr('id') !== 'field-total_pob_value'){
|
||||
|
||||
// totalValue += parseFloat($(this).val()) || 0;
|
||||
// }
|
||||
// });
|
||||
|
||||
// $('#field-total_pob_units').val(totalUnits);
|
||||
// $('#field-total_pob_value').val(totalValue);
|
||||
// }
|
||||
function calculateTotals(){
|
||||
|
||||
let totalUnits = 0;
|
||||
let totalValue = 0;
|
||||
|
||||
// Total Units
|
||||
$('input[id*="_units"]:visible').each(function(){
|
||||
|
||||
if($(this).attr('id') !== 'field-total_pob_units'){
|
||||
|
||||
totalUnits += parseInt($(this).val()) || 0;
|
||||
}
|
||||
});
|
||||
|
||||
// Total Value
|
||||
$('input[id*="_value"]:visible').each(function(){
|
||||
|
||||
if($(this).attr('id') !== 'field-total_pob_value'){
|
||||
|
||||
totalValue += parseFloat($(this).val()) || 0;
|
||||
}
|
||||
});
|
||||
|
||||
$('#field-total_pob_units').val(totalUnits);
|
||||
|
||||
// Round total value
|
||||
$('#field-total_pob_value').val(totalValue.toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Bind Calculations
|
||||
|
||||
|
||||
|
||||
// Sitazit
|
||||
|
||||
|
||||
calculateField(
|
||||
'#field-sitazit_d_10100_pob_units',
|
||||
'#field-sitazit_d_10100_pob_value',
|
||||
160.71
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-sitazit_d_550_pob_units',
|
||||
'#field-sitazit_d_550_pob_value',
|
||||
114.75
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-sitazit_dm_er_100010_pob_units',
|
||||
'#field-sitazit_dm_er_100010_pob_value',
|
||||
182.25
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-sitazit_dm_er_50010_pob_units',
|
||||
'#field-sitazit_dm_er_50010_pob_value',
|
||||
168.10
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Eptus
|
||||
|
||||
|
||||
calculateField(
|
||||
'#field-eptus_25mg_units',
|
||||
'#field-eptus_25mg_value',
|
||||
207.96
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-eptus_50_mg_units',
|
||||
'#field-eptus_50_mg_value',
|
||||
326.25
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-eptus_t_10_kit_units',
|
||||
'#field-eptus_t_10_kit_value',
|
||||
225
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-eptus_t_20_kit_units',
|
||||
'#field-eptus_t_20_kit_value',
|
||||
242.36
|
||||
);
|
||||
|
||||
|
||||
|
||||
// LOBG
|
||||
|
||||
|
||||
calculateField(
|
||||
'#field-lo_bg_05_mg_units',
|
||||
'#field-lo_bg_05_mg_value',
|
||||
73.93
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Ziten
|
||||
|
||||
|
||||
calculateField(
|
||||
'#field-ziten_m_20_mg_1000_mg_units',
|
||||
'#field-ziten_m_20_mg_1000_mg_value',
|
||||
78.64
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-ziten_m_20_mg_500_mg_units',
|
||||
'#field-ziten_m_20_mg_500_mg_value',
|
||||
82.29
|
||||
);
|
||||
|
||||
calculateField(
|
||||
'#field-ziten_units',
|
||||
'#field-ziten_value',
|
||||
63.64
|
||||
);
|
||||
|
||||
// Allow Only Positive Whole Numbers
|
||||
// No Decimal & No Negative
|
||||
|
||||
$('input[id*="_units"]').on('input', function () {
|
||||
|
||||
// Remove non-numeric characters
|
||||
let value = $(this).val().replace(/[^0-9]/g, '');
|
||||
|
||||
// Prevent leading zeros like 0005
|
||||
value = value.replace(/^0+(?=\d)/, '');
|
||||
|
||||
$(this).val(value);
|
||||
});
|
||||
|
||||
|
||||
// Block Special Keys
|
||||
|
||||
$('input[id*="_units"]').on('keydown', function (e) {
|
||||
|
||||
// Block decimal, minus, plus
|
||||
if (
|
||||
e.key === '.' ||
|
||||
e.key === '-' ||
|
||||
e.key === '+' ||
|
||||
e.key === 'e'
|
||||
) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// $('#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)
|
||||
// })
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#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.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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#field-contact_id").change(function(){
|
||||
|
||||
let selected = $('option:selected', this);
|
||||
|
||||
console.log(selected.attr('msl_code'));
|
||||
console.log(selected.attr('speciality'));
|
||||
|
||||
$('#field-msl_code').val(selected.attr('msl_code'));
|
||||
$('#field-speciality').val(selected.attr('speciality'));
|
||||
|
||||
});
|
||||
|
||||
// Auto populate Total LOBG Rx from LO-BG 0.5 mg Rx
|
||||
|
||||
function calculateTotalLOBGRx() {
|
||||
|
||||
let loBgRx = parseFloat($('#field-lo_bg_05_mg_rx').val()) || 0;
|
||||
|
||||
$('#field-total_lobg_rx').val(loBgRx);
|
||||
}
|
||||
|
||||
// Trigger on typing/change
|
||||
$('#field-lo_bg_05_mg_rx').on('keyup change', function () {
|
||||
calculateTotalLOBGRx();
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -1,13 +1,42 @@
|
|||
<!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" />
|
||||
@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" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
@php
|
||||
$data = DB::table('team3_tripleimpact')->where('hierarchy_id', $form->hierarchy_id)->get();
|
||||
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id);
|
||||
$existingCounts = [
|
||||
'chest' => 0,
|
||||
'pedia' => 0,
|
||||
'gp' => 0,
|
||||
];
|
||||
|
||||
if (!empty($history->data->submissions)) {
|
||||
foreach ($history->data->submissions as $sub) {
|
||||
$spec = strtolower($sub->formdata->speciality ?? '');
|
||||
|
||||
if ($spec === 'chest') {
|
||||
$existingCounts['chest']++;
|
||||
}
|
||||
if ($spec === 'pedia') {
|
||||
$existingCounts['pedia']++;
|
||||
}
|
||||
if ($spec === 'gp') {
|
||||
$existingCounts['gp']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
|
@ -16,139 +45,202 @@
|
|||
<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>
|
||||
@if (Session::has('error'))
|
||||
<div class="alert alert-danger">{{ Session::get('error') }}</div>
|
||||
<br>
|
||||
@endif
|
||||
@if(isset($form->user_info))
|
||||
<div class="col-12">
|
||||
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
||||
@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
|
||||
<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}}">
|
||||
|
||||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||||
<input type="hidden" name="user_id" value="{{ $form->user_id }}">
|
||||
|
||||
@csrf
|
||||
@php
|
||||
$editmode = false;
|
||||
@endphp
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@php
|
||||
$editmode = true;
|
||||
@endphp
|
||||
@if ($id)
|
||||
<input type="hidden" name="id" value="{{ $id }}">
|
||||
@php
|
||||
$editmode = true;
|
||||
@endphp
|
||||
@endif
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@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>
|
||||
@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->code == 'msl_code') && !$editmode)
|
||||
|
||||
@foreach ($questions as $question)
|
||||
@if ($question->code == 'msl_code' && !$editmode)
|
||||
@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>':''!!} </label>
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
||||
<label for="field-{{ $question->code }}"
|
||||
class="form-label">{{ $question->question }} {!! $question->required == 'yes' ? '<span class="text-danger">*</span>' : '' !!}
|
||||
</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->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>--Select--</option>
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->display }}" {{ isset($question->display) && $question->display == $option->display ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@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('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
|
||||
|
||||
@case('number')
|
||||
<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('file')
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" {{$question->required == 'yes'?'required':'' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
|
||||
@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('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" required value="{{isset($option->val)?$option->val:0}}">
|
||||
</div>
|
||||
|
||||
@case('dropdown')
|
||||
@if ($question->code == 'contact_id')
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" disabled
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option>--Select--</option>
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
{{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }}
|
||||
{{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality : '') . ' ' : '' }}>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option>--Select--</option>
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
{{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }}
|
||||
{{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality : '') . ' ' : '' }}>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
@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
|
||||
</div>
|
||||
@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
|
||||
@break
|
||||
|
||||
@case('file')
|
||||
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'))
|
||||
<input type="file" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{ $question->value }}" class="img-fluid">
|
||||
@endif
|
||||
@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" required
|
||||
value="{{ isset($option->val) ? $option->val : 0 }}">
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@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
|
||||
<div class=" mb-2" id="doctor_msl_wrapper">
|
||||
|
||||
<div
|
||||
class="d-flex flex-column flex-md-row align-items-start align-items-md-center gap-2 mt-2">
|
||||
|
||||
<button type="button" id="add_row" class="btn btn-primary">
|
||||
Add Doctor
|
||||
</button>
|
||||
|
||||
<span id="doctor_limit_info" class="text-muted fw-semibold"></span>
|
||||
|
||||
</div>
|
||||
@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>
|
||||
|
||||
<div class="mb-2" id="doctor_msl_wrapper"></div>
|
||||
@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>
|
||||
|
||||
|
|
@ -165,262 +257,323 @@
|
|||
<!-- 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;
|
||||
}
|
||||
<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>
|
||||
let specialityData = @json($data[0]);
|
||||
let existingCounts = @json($existingCounts);
|
||||
let history = @json($history ?? null);
|
||||
</script>
|
||||
|
||||
#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 type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#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?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));
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
// =========================
|
||||
// HISTORY SETUP
|
||||
// =========================
|
||||
let submittedMSL = new Set();
|
||||
let submittedIDs = new Set();
|
||||
|
||||
if (history && history.data && history.data.submissions) {
|
||||
history.data.submissions.forEach(sub => {
|
||||
if (sub.contacts && sub.contacts.length) {
|
||||
sub.contacts.forEach(doc => {
|
||||
if (doc.msl_code) submittedMSL.add(String(doc.msl_code));
|
||||
if (doc.id) submittedIDs.add(String(doc.id));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// =========================
|
||||
// GLOBAL TRACKING (NEW FIX)
|
||||
// =========================
|
||||
function getAllSelectedDoctors() {
|
||||
let arr = [];
|
||||
$('.field-contact').each(function() {
|
||||
let v = $(this).val();
|
||||
if (v) arr.push(v);
|
||||
});
|
||||
return arr;
|
||||
}
|
||||
|
||||
function isDuplicate(value) {
|
||||
return getAllSelectedDoctors().filter(v => v === value).length > 1;
|
||||
}
|
||||
|
||||
function isAlreadySubmitted(value) {
|
||||
return submittedIDs.has(String(value));
|
||||
}
|
||||
|
||||
// =========================
|
||||
// USER CHANGE → LOAD DOCTORS
|
||||
// =========================
|
||||
$('#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?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) {
|
||||
|
||||
let id = String(itm.value);
|
||||
|
||||
let isDisabled = isAlreadySubmitted(id);
|
||||
|
||||
let option = $("<option></option>")
|
||||
.attr("value", id)
|
||||
.text(itm.display)
|
||||
.attr("msl_code", itm.contact.msl_code)
|
||||
.attr("speciality", itm.contact.speciality);
|
||||
|
||||
if (isDisabled) {
|
||||
option.prop('disabled', true)
|
||||
.text(itm.display + " (Already Submitted)");
|
||||
}
|
||||
|
||||
$('#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'))
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
|
||||
const pediaMaterials = [
|
||||
'Pedia Hight Chart',
|
||||
'Pedia Weighing Scale',
|
||||
'Examination bedsheet',
|
||||
'Torch'
|
||||
];
|
||||
|
||||
const chestMaterials=[
|
||||
'X-ray Screen',
|
||||
'BP Appratus Digital',
|
||||
'Adult Weighing Scale'
|
||||
];
|
||||
|
||||
const gpMaterials=[
|
||||
'X-ray Screen - H1',
|
||||
'Pulse Oximeter - H1',
|
||||
'BP Appratus Analog - H1',
|
||||
'Torch - H1',
|
||||
'Adult Weighing Scale - H1',
|
||||
'Sthetoscope - H1'
|
||||
];
|
||||
|
||||
$('#field-speciality').on('change', function () {
|
||||
let speciality = $(this).val();
|
||||
|
||||
$('#field-material_name option').each(function () {
|
||||
let text = $(this).text().trim();
|
||||
|
||||
if (speciality === 'Pedia') {
|
||||
if (!pediaMaterials.includes(text) && text !== '-- Select --') {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
else if (speciality === 'Chest') {
|
||||
if (!chestMaterials.includes(text) && text !== '-- Select --') {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
|
||||
else if (speciality === 'GP') {
|
||||
if (!gpMaterials.includes(text) && text !== '-- Select --') {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
else {
|
||||
$(this).show(); // show all for other specialities
|
||||
$('#field-contact_id').append(option);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Reset dropdown value
|
||||
$('#field-material_name').val('');
|
||||
// =========================
|
||||
// MATERIAL FILTER (UNCHANGED)
|
||||
// =========================
|
||||
const pediaMaterials = ['Pedia Hight Chart','Pedia Weighing Scale','Examination bedsheet','Torch'];
|
||||
const chestMaterials = ['X-ray Screen','BP Appratus Digital','Adult Weighing Scale'];
|
||||
const gpMaterials = ['X-ray Screen - H1','Pulse Oximeter - H1','BP Appratus Analog - H1','Torch - H1','Adult Weighing Scale - H1','Sthetoscope - H1'];
|
||||
|
||||
$('#field-speciality').on('change', function() {
|
||||
|
||||
let speciality = $(this).val();
|
||||
|
||||
$('#field-material_name option').each(function() {
|
||||
|
||||
let text = $(this).text().trim();
|
||||
|
||||
if (speciality === 'Pedia') {
|
||||
$(this).toggle(pediaMaterials.includes(text) || text === '-- Select --');
|
||||
} else if (speciality === 'Chest') {
|
||||
$(this).toggle(chestMaterials.includes(text) || text === '-- Select --');
|
||||
} else if (speciality === 'GP') {
|
||||
$(this).toggle(gpMaterials.includes(text) || text === '-- Select --');
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#field-material_name').val('');
|
||||
});
|
||||
|
||||
$('#field-contact_id').parent().hide();
|
||||
$('#field-contact_id').prop('required',false);
|
||||
|
||||
@if(!$editmode)
|
||||
$('#field-input_qty').on('change',function(){
|
||||
let doctorName=$('#field-contact_id').html();
|
||||
|
||||
console.log(doctorName);
|
||||
let qtyValue=parseInt($(this).val());
|
||||
$('#doctor_msl_wrapper').html('')
|
||||
for(let i = 1; i <= qtyValue; i++) {
|
||||
$('#doctor_msl_wrapper').append(`<div class="col-md-12 mb-2">
|
||||
<label for="field-doctor_name_${i}" class="form-label">Doctor Name ${i}<span class="text-danger">*</span> </label>
|
||||
<select class="form-control" id="field-contact_id_${i}" name="contact_id_${i}" required>
|
||||
${doctorName}
|
||||
$('#field-contact_id').parent().hide();
|
||||
$('#field-contact_id').prop('required', false);
|
||||
|
||||
// =========================
|
||||
// DOCTOR CONFIG
|
||||
// =========================
|
||||
let maxCount = 0;
|
||||
let currentCount = 0;
|
||||
let batchSize = 5;
|
||||
let doctorName = $('#field-contact_id').html();
|
||||
|
||||
// =========================
|
||||
// SPECIALITY LOGIC
|
||||
// =========================
|
||||
$('#field-speciality').on('change', function() {
|
||||
|
||||
let selected = $(this).val().toLowerCase();
|
||||
|
||||
let totalAllowed =
|
||||
selected === 'chest' ? specialityData.chest :
|
||||
selected === 'pedia' ? specialityData.pedia :
|
||||
selected === 'gp' ? specialityData.gp : 0;
|
||||
|
||||
let alreadyAdded = existingCounts[selected] || 0;
|
||||
|
||||
maxCount = totalAllowed - alreadyAdded;
|
||||
if (maxCount < 0) maxCount = 0;
|
||||
|
||||
$('#doctor_msl_wrapper').html('');
|
||||
currentCount = 0;
|
||||
|
||||
if (maxCount === 0) {
|
||||
$('#submit-btn').prop('disabled', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#submit-btn').prop('disabled', false);
|
||||
|
||||
$('#doctor_limit_info')
|
||||
.removeClass('text-danger text-success')
|
||||
.addClass('text-success')
|
||||
.html(`You can add up to ${maxCount} doctors (in multiples of 5).`);
|
||||
|
||||
addDoctorBatch(5);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// ADD DOCTOR BATCH
|
||||
// =========================
|
||||
function addDoctorBatch(count) {
|
||||
|
||||
if (maxCount === 0) return;
|
||||
|
||||
let nextBatch = count;
|
||||
|
||||
if (currentCount + nextBatch > maxCount) {
|
||||
nextBatch = maxCount - currentCount;
|
||||
}
|
||||
|
||||
if (nextBatch <= 0) return;
|
||||
|
||||
for (let i = 1; i <= nextBatch; i++) {
|
||||
|
||||
let index = currentCount + i;
|
||||
|
||||
$('#doctor_msl_wrapper').append(`
|
||||
<div class="doctor-row card shadow-sm border-0 mb-3" data-index="${index}">
|
||||
<div class="card-body p-3">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="mb-0 fw-semibold text-primary">Doctor ${index}</h6>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger remove_row">Remove</button>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label mb-1">Doctor Name</label>
|
||||
<select class="form-control field-contact" name="contact_id[]" required>
|
||||
${doctorName}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-msl_code_${i}" class="form-label">MSL Code ${i}<span class="text-danger">*</span> </label>
|
||||
<input type="text" id="field-msl_code_${i}" name="msl_code_${i}" class="form-control" value="" required>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label mb-1">MSL Code</label>
|
||||
<input type="text" class="form-control field-msl" name="msl_code[]" readonly required>
|
||||
</div>
|
||||
`)
|
||||
|
||||
setTimeout(() => {
|
||||
</div>
|
||||
|
||||
$(`#field-contact_id_${i}`).on('change',function(){
|
||||
$(`#field-msl_code_${i}`).val($(this).find(":selected").attr("msl_code"));
|
||||
})
|
||||
|
||||
$(`#field-msl_code_${i}`).attr('readonly',true);
|
||||
|
||||
}, 500);
|
||||
|
||||
}
|
||||
})
|
||||
@else
|
||||
$('#field-input_qty').prop('readonly', true)
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id_"]', function () {
|
||||
currentCount += nextBatch;
|
||||
}
|
||||
|
||||
let selectedValues = [];
|
||||
|
||||
// Collect all selected doctor values
|
||||
$('select[id^="field-contact_id_"]').each(function () {
|
||||
let val = $(this).val();
|
||||
if (val) {
|
||||
selectedValues.push(val);
|
||||
}
|
||||
});
|
||||
|
||||
// Loop again to disable already selected options
|
||||
$('select[id^="field-contact_id_"]').each(function () {
|
||||
let currentDropdown = $(this);
|
||||
|
||||
currentDropdown.find('option').each(function () {
|
||||
let optionVal = $(this).val();
|
||||
let originalText = $(this).data('original-text');
|
||||
|
||||
// Store original text once
|
||||
if (!originalText) {
|
||||
$(this).data('original-text', $(this).text());
|
||||
originalText = $(this).text();
|
||||
}
|
||||
|
||||
if (optionVal === '') return; // skip "-- Select --"
|
||||
|
||||
// Enable all first & reset text
|
||||
$(this).prop('disabled', false).text(originalText);
|
||||
|
||||
// Disable if already selected in another dropdown
|
||||
if (selectedValues.includes(optionVal) && optionVal !== currentDropdown.val()) {
|
||||
$(this)
|
||||
.prop('disabled', true)
|
||||
.text(originalText + ' (Already added)');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#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",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
if(data.status == 'success') {
|
||||
Swal.fire({
|
||||
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 not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
// =========================
|
||||
// ADD BUTTON
|
||||
// =========================
|
||||
$('#add_row').on('click', function() {
|
||||
if (maxCount === 0) return;
|
||||
if (currentCount >= maxCount) return;
|
||||
addDoctorBatch(batchSize);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// REMOVE ROW
|
||||
// =========================
|
||||
$(document).on('click', '.remove_row', function() {
|
||||
$(this).closest('.doctor-row').remove();
|
||||
currentCount = Math.max(0, currentCount - 1);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// AUTO MSL FILL + DUPLICATE FIX (IMPORTANT CHANGE)
|
||||
// =========================
|
||||
$(document).on('change', '.field-contact', function() {
|
||||
|
||||
let val = $(this).val();
|
||||
let row = $(this).closest('.doctor-row');
|
||||
|
||||
// ❌ prevent already submitted doctor
|
||||
if (isAlreadySubmitted(val)) {
|
||||
$(this).val('');
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Already submitted doctor cannot be selected again'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// ❌ prevent duplicate in current UI
|
||||
if (isDuplicate(val)) {
|
||||
$(this).val('');
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Duplicate Doctor'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let msl = $(this).find(':selected').attr('msl_code');
|
||||
row.find('.field-msl').val(msl);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// SUBMIT AJAX
|
||||
// =========================
|
||||
$('#report-form').on('submit', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmitmultiple',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
if (data.status == 'success') {
|
||||
Swal.fire('Success', 'Submitted!', 'success')
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire('Error', 'Failed', 'error');
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "History"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
</head>
|
||||
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
</div>
|
||||
<div class="col-4 p-2">
|
||||
<a href="/form/show" class="float-end pt-1">New Submission</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
@if(session()->has('message'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('message') }}
|
||||
</div>
|
||||
@endif
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
<div class="col-12 p-0">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="responsive-table-plugin">
|
||||
<div class="table-rep-plugin">
|
||||
<div class="table-responsive" data-pattern="priority-columns">
|
||||
<table id="tech-companies-1" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="1">Submission Date</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endforeach
|
||||
<th data-priority="1">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($submissions as $submission)
|
||||
<tr>
|
||||
<th>{{date("d M Y", strtotime($submission->updatedAt))}}</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
@if($question->type == 'file')
|
||||
<td><a target="_blank" href="{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :(is_string($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' ) : $code }}" download="{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) : (is_string($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' ) : $code }}" class="btn btn-dark btn-xs"><i class="mdi mdi-cloud-download me-1"></i> Download</a></td>
|
||||
|
||||
@elseif($question->type == 'radiometrix' && isset($submission->formdata->{$code}) && is_object($submission->formdata->{$code}))
|
||||
<td>
|
||||
{{ collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') }}
|
||||
</td>
|
||||
|
||||
@elseif(count((array)$question->options) > 0 && 1==2 )
|
||||
<td>{{ $question->options->{ $submission->formdata->{$code} } }}</td>
|
||||
@else
|
||||
<td>{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :$submission->formdata->{$code} : $code }}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<th>
|
||||
@if($question->can_edit == 'yes' || sizeof($submission->workflow_approvals) == 0 )
|
||||
@if($submission->workflow == 'yes' && $submission->workflow_status == 'approved' )
|
||||
<p>Approved</p>
|
||||
@else
|
||||
<!-- <a href="/form/show?form_id={{$submission->formdata->form_id}}&id={{$submission->id}}" class="btn btn-primary btn-xs">Edit
|
||||
|
||||
</button> -->
|
||||
@if(isset($form->allow_delete_by_user) && $form->allow_delete_by_user == 'yes')
|
||||
<a href="/form/delete?form_id={{$submission->formdata->form_id}}&id={{$submission->id}}" onclick="return confirm('Are you sure you want to delete this submission? This is not recoverable!');" class="btn btn-danger btn-xs mt-1">Delete</button>
|
||||
@endif
|
||||
@endif
|
||||
@endif
|
||||
</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end .table-responsive -->
|
||||
|
||||
</div> <!-- end .table-rep-plugin-->
|
||||
</div> <!-- end .responsive-table-plugin-->
|
||||
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
<!-- end row-->
|
||||
</div> <!-- container -->
|
||||
|
||||
</div>
|
||||
<!-- end page -->
|
||||
@include('layouts.shared/footer-script')
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -518,7 +518,12 @@
|
|||
"brand": "Sylate T",
|
||||
"sku": "Sylate 250",
|
||||
"pts": 175.85
|
||||
}
|
||||
},
|
||||
{
|
||||
"brand": "Emvicure",
|
||||
"sku": "Emvicure",
|
||||
"pts": 365.83
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
@php
|
||||
$brandData = [
|
||||
|
||||
/*['brand'=>'CELOL', 'slug'=>'celol_units','pseudoId'=>'celol_value','slug2'=>'celol2'],
|
||||
/*
|
||||
['brand'=>'CELOL', 'slug'=>'celol_units','pseudoId'=>'celol_value','slug2'=>'celol2'],
|
||||
['brand'=>'Denmab', 'slug'=>'denmab_units','pseudoId'=>'denmab_value','slug2'=>'denmab2'],
|
||||
['brand'=>'Emanzen', 'slug'=>'emanzen_units','pseudoId'=>'emanzen_value','slug2'=>'emanzen2'],
|
||||
['brand'=>'Ferium XT', 'slug'=>'ferium_xt_units','pseudoId'=>'ferium_xt_value','slug2'=>'ferium_xt2'],
|
||||
|
|
@ -23,7 +24,6 @@ $brandData = [
|
|||
['brand'=>'Proxym', 'slug'=>'proxym_units','pseudoId'=>'proxym_value','slug2'=>'proxym2'],
|
||||
['brand'=>'Ferium Injection', 'slug'=>'ferium_injection_units','pseudoId'=>'ferium_injection_value','slug2'=>'ferium_injection2'],
|
||||
|
||||
|
||||
*/
|
||||
['brand'=>'Galact Granules', 'slug'=>'galact_granules_units','pseudoId'=>'galact_granules_value','slug2'=>'galact_granules2'],
|
||||
['brand'=>'Sylate', 'slug'=>'sylate_units','pseudoId'=>'sylate_value','slug2'=>'sylate2'],
|
||||
|
|
@ -37,6 +37,7 @@ $brandData = [
|
|||
['brand'=>'Sylate T 500', 'slug'=>'sylate_t_500_units','pseudoId'=>'sylate_t_500_value','slug2'=>'sylate_t_500_2'],
|
||||
['brand'=>'Sylate 500', 'slug'=>'sylate_500_units','pseudoId'=>'sylate_500_value','slug2'=>'sylate_500_2'],
|
||||
['brand'=>'Sylate 250', 'slug'=>'sylate_250_units','pseudoId'=>'sylate_250_value','slug2'=>'sylate_250_2'],
|
||||
['brand'=>'Emvicure', 'slug'=>'emvicure_units','pseudoId'=>'emvicure_value','slug2'=>'emvicure2'],
|
||||
|
||||
|
||||
|
||||
|
|
@ -387,6 +388,8 @@ $brandData = [
|
|||
let productOfP = (p * priceOfP).toFixed(2);
|
||||
$('#field-femzact_value').val(productOfP);
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -522,6 +525,11 @@ $brandData = [
|
|||
unit: '#field-sylate_250_units',
|
||||
value: '#field-sylate_250_value',
|
||||
price: 175.85
|
||||
},
|
||||
{
|
||||
unit: '#field-emvicure_units',
|
||||
value: '#field-emvicure_value',
|
||||
price: 365.83
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,786 @@
|
|||
<!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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
|
||||
/* =========================
|
||||
SELECT2 CUSTOM HIGHLIGHT
|
||||
========================= */
|
||||
|
||||
.select2-container .select2-selection--single{
|
||||
height: 38px !important;
|
||||
border: 1px solid #ced4da !important;
|
||||
border-radius: 6px !important;
|
||||
padding-top: 4px !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 28px !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
height: 36px !important;
|
||||
}
|
||||
|
||||
/* Dropdown option hover */
|
||||
.select2-results__option--highlighted{
|
||||
background-color: #0d6efd !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* Selected option */
|
||||
.select2-results__option[aria-selected=true]{
|
||||
background-color: #dbe9ff !important;
|
||||
color: black !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Search box */
|
||||
.select2-search__field{
|
||||
border-radius: 5px !important;
|
||||
padding: 6px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
</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
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$submissions = $submissions->data->submissions;
|
||||
|
||||
|
||||
@endphp
|
||||
|
||||
<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[0]" 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( !in_array($question->code,
|
||||
["record_date","select_week","select_month"] ) )
|
||||
@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>':''!!}
|
||||
</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->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' : '' }} {{ $question->code == 'contact_id' ? 'uid_number= ' . $option->contact->uid_number . ' ' : '' }} {{ $question->code == 'doctor_name' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="doctor-wrapper">
|
||||
|
||||
@foreach($questions as $question)
|
||||
@if( in_array($question->code,
|
||||
["record_date","select_week","select_month"] ) )
|
||||
@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>':''!!} </label>
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||
name="{{$question->code}}[0]"
|
||||
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}}[0]" 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}}[0]"
|
||||
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}}[0]"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
@case('dropdown')
|
||||
@if ($question->code == 'contact_id')
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}[0]"
|
||||
{{ $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' : '' }}
|
||||
@if($question->code == 'contact_id')
|
||||
uid_number="{{ (isset($option->contact->uid_number) ? $option->contact->uid_number : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<select class="form-control" id="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}[0]"
|
||||
{{ $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>
|
||||
@endif
|
||||
@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}}[0]" 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')
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) &&
|
||||
$form->is_approval != 'yes' ) )
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}"
|
||||
class="form-control" value=""
|
||||
{{$question->required == 'yes'?'required':'' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
@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" required
|
||||
value="{{isset($option->val)?$option->val:0}}">
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<div id="doctor-group-wrapper">
|
||||
|
||||
</div>
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
|
||||
'yes' ) )
|
||||
<div class="text-center button-list">
|
||||
@if(!$id)
|
||||
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
||||
@endif
|
||||
<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%;
|
||||
}
|
||||
|
||||
.doctor-wrapper {
|
||||
border: 1px solid #ccc;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#field-record_date').attr(
|
||||
'max',
|
||||
new Date().toISOString().split('T')[0]
|
||||
);
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-uid_number').val($(this).find(":selected").attr("uid_number"));
|
||||
})
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||
})
|
||||
|
||||
$('#field-uid_number,#field-speciality').attr('readonly',true);
|
||||
|
||||
function initializeSelect2() {
|
||||
|
||||
$('select[id^="field-contact_id"]').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
$('#field-user_id').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select User / Territory --'
|
||||
});
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
}
|
||||
|
||||
initializeSelect2();
|
||||
preventDuplicateDoctors();
|
||||
|
||||
|
||||
|
||||
/* function preventDuplicateDoctors() {
|
||||
|
||||
let selectedValues = [];
|
||||
|
||||
// Get all selected doctor values
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value) {
|
||||
selectedValues.push(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Apply duplicate prevention
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let currentSelect = $(this);
|
||||
let currentValue = currentSelect.val();
|
||||
|
||||
currentSelect.find('option').each(function () {
|
||||
|
||||
let option = $(this);
|
||||
let optionValue = option.val();
|
||||
|
||||
if (!optionValue) return;
|
||||
|
||||
// Remove old text
|
||||
let cleanText = option.text().replace(' (Already Added)', '');
|
||||
|
||||
if (
|
||||
selectedValues.includes(optionValue) &&
|
||||
optionValue !== currentValue
|
||||
) {
|
||||
|
||||
option.prop('disabled', true);
|
||||
option.text(cleanText + ' (Already Added)');
|
||||
|
||||
} else {
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(cleanText);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 🔥 IMPORTANT
|
||||
currentSelect.select2('destroy');
|
||||
|
||||
currentSelect.select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} */
|
||||
|
||||
function preventDuplicateDoctors() {
|
||||
|
||||
let selectedValues = [];
|
||||
|
||||
// Collect selected values
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value) {
|
||||
selectedValues.push(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let currentSelect = $(this);
|
||||
let currentValue = currentSelect.val();
|
||||
|
||||
currentSelect.find('option').each(function () {
|
||||
|
||||
let option = $(this);
|
||||
let optionValue = option.val();
|
||||
|
||||
if (!optionValue) return;
|
||||
|
||||
// remove previous label
|
||||
let cleanText = option.text().replace(' (Already Added)', '');
|
||||
|
||||
// IMPORTANT:
|
||||
// keep currently selected option enabled
|
||||
if (
|
||||
selectedValues.includes(optionValue) &&
|
||||
optionValue !== currentValue
|
||||
) {
|
||||
|
||||
option.prop('disabled', true);
|
||||
option.text(cleanText + ' (Already Added)');
|
||||
|
||||
} else {
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(cleanText);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// refresh select2 safely
|
||||
if (currentSelect.hasClass("select2-hidden-accessible")) {
|
||||
currentSelect.select2('destroy');
|
||||
}
|
||||
|
||||
currentSelect.select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
// VERY IMPORTANT FOR EDIT MODE
|
||||
currentSelect.val(currentValue).trigger('change.select2');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Hide fields initially
|
||||
$('#field-no_of_rx,#field-no_of_strips,#field-total_value').parent().hide();
|
||||
|
||||
$('#field-no_of_rx,#field-no_of_strips,#field-total_value')
|
||||
.attr('required', false);
|
||||
|
||||
// Show when dr_converted = Yes
|
||||
$('#execution-dr_converted').on('change', function(){
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if(value === 'Yes'){
|
||||
|
||||
$('#field-no_of_rx,#field-no_of_strips,#field-total_value')
|
||||
.parent().show();
|
||||
|
||||
$('#field-no_of_rx,#field-no_of_strips,#field-total_value')
|
||||
.attr('required', true);
|
||||
|
||||
}else{
|
||||
|
||||
$('#field-no_of_rx,#field-no_of_strips,#field-total_value')
|
||||
.parent().hide();
|
||||
|
||||
$('#field-no_of_rx,#field-no_of_strips,#field-total_value')
|
||||
.attr('required', false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#field-total_value').attr('readonly', true);
|
||||
|
||||
$('#field-no_of_strips').on('change keyup', function(){
|
||||
|
||||
let strips = parseFloat($('#field-no_of_strips').val() || 0);
|
||||
|
||||
let ptsValue = 365.83;
|
||||
|
||||
let total = strips * ptsValue;
|
||||
|
||||
$('#field-total_value').val(total.toFixed(2));
|
||||
|
||||
});
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
|
||||
let id = $(this).attr('id').split('-').pop(); // get doctor_count dynamically
|
||||
|
||||
$('#field-uid_number-' + id).val(selectedOption.attr('uid_number'));
|
||||
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
||||
|
||||
preventDuplicateDoctors();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var doctor_count = 0
|
||||
let numberOfSubmission=0;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
$('#adddoctor-btn').click(function() {
|
||||
let doctorName=$('#field-contact_id').html();
|
||||
|
||||
console.log("Doctor Name : ",doctorName);
|
||||
doctor_count++;
|
||||
numberOfSubmission=numberOfSubmission+1;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
|
||||
let empty_doctor = `
|
||||
|
||||
<div class="doctor-wrapper"><button type="button" class="btn btn-danger btn-remove float-end" style="margin-top:-25px; margin-right:-25px"><i class="mdi mdi-close"></i></button>
|
||||
@foreach($questions as $question)
|
||||
@if( in_array($question->code,
|
||||
["record_date","select_week","select_month"] ) )
|
||||
@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>':''!!} </label>
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('file')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" 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}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" {{$question->required == 'yes'?'required':'' }}>
|
||||
@if($question->code=='contact_id')
|
||||
${doctorName}
|
||||
@else
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'uid_number= ' . $option->contact->uid_number . ' ' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach </div>`;
|
||||
|
||||
|
||||
$('#doctor-group-wrapper').append(empty_doctor)
|
||||
|
||||
$('#field-contact_id-'+doctor_count).select2({
|
||||
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
preventDuplicateDoctors();
|
||||
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
$('#field-uid_number-'+doctor_count).attr('readonly',true);
|
||||
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
||||
let fields =
|
||||
$('#field-no_of_rx-' + doctor_count +
|
||||
',#field-no_of_strips-' + doctor_count +
|
||||
',#field-total_value-' + doctor_count);
|
||||
|
||||
fields.parent().hide();
|
||||
|
||||
fields.attr('required', false);
|
||||
$('#field-dr_converted-' + doctor_count).on('change', function(){
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if(value === 'Yes'){
|
||||
|
||||
fields.parent().show();
|
||||
|
||||
fields.attr('required', true);
|
||||
|
||||
}else{
|
||||
|
||||
fields.parent().hide();
|
||||
|
||||
fields.attr('required', false);
|
||||
}
|
||||
|
||||
});
|
||||
$('#field-total_value-' + doctor_count).attr('readonly', true);
|
||||
|
||||
$('#field-no_of_strips-' + doctor_count)
|
||||
.on('change keyup', function(){
|
||||
|
||||
let strips =
|
||||
parseFloat($('#field-no_of_strips-' + doctor_count).val() || 0);
|
||||
|
||||
let ptsValue = 365.83;
|
||||
|
||||
let total = strips * ptsValue;
|
||||
|
||||
$('#field-total_value-' + doctor_count)
|
||||
.val(total.toFixed(2));
|
||||
|
||||
});
|
||||
|
||||
|
||||
}, 500);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($('.doctor-wrapper').length >= 10) {
|
||||
$('#adddoctor-btn').hide();
|
||||
} else {
|
||||
$('#adddoctor-btn').show();
|
||||
}
|
||||
|
||||
|
||||
$('.btn-remove').unbind();
|
||||
$('.btn-remove').click(function() {
|
||||
// $(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
||||
$(this).closest('.doctor-wrapper').find('select').each(function () {
|
||||
|
||||
if ($(this).hasClass('select2-hidden-accessible')) {
|
||||
$(this).select2('destroy');
|
||||
}
|
||||
|
||||
});
|
||||
$(this).closest('.doctor-wrapper').remove();
|
||||
numberOfSubmission--;
|
||||
doctor_count--
|
||||
preventDuplicateDoctors();
|
||||
console.log("New Number of Submission : ",numberOfSubmission);
|
||||
console.log("Number of doctors : ",doctor_count);
|
||||
$('#adddoctor-btn').show();
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
$('#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?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("uid_number", itm.contact.uid_number).attr("speciality", itm.contact.speciality));
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-uid_number').val($('option:selected', this).attr('uid_number'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
// if (numberOfSubmission !=10) {
|
||||
// alert(`You must submit 10 Doctors for Ciphaler , Current Doctors : ${numberOfSubmission+1}`);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmitmultiple',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$("#pageloader").fadeOut();
|
||||
if (data.status == 'success') {
|
||||
Swal.fire({
|
||||
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 not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue