Tripple impact changes
Specific Folder FTP Upload / ftp-deploy (push) Successful in 36s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 36s
Details
This commit is contained in:
parent
88adb91c31
commit
5a1dd0d5f5
|
|
@ -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>
|
||||
Loading…
Reference in New Issue