List Changes
Specific Folder FTP Upload / ftp-deploy (push) Successful in 38s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 38s
Details
This commit is contained in:
commit
6f185a8835
|
|
@ -209,8 +209,12 @@
|
|||
@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>
|
||||
class="form-label">{{$question->question}} @if($question->code=='contact_id')
|
||||
{{ $i + 1 }}
|
||||
@endif{!!$question->required == 'yes' ?
|
||||
'<span class="text-danger">*</span>':''!!}
|
||||
|
||||
</label>
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}-{{$i}}"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,131 @@
|
|||
<!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
|
||||
@if($question->type == 'multitextbox')
|
||||
@foreach($question->options as $k => $v)
|
||||
<th data-priority="1">{{ is_object($v) ? ($v->display ?? $v->label ?? $k) : $v }} ({{$question->label}})</th>
|
||||
@endforeach
|
||||
@else
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endif
|
||||
@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($question->type == 'multitextbox')
|
||||
@foreach($question->options as $k => $v)
|
||||
@php
|
||||
$optKey = is_object($v) ? ($v->value ?? $k) : $k;
|
||||
$optVal = '';
|
||||
if (isset($submission->formdata->{$optKey})) {
|
||||
$raw = $submission->formdata->{$optKey};
|
||||
$optVal = is_array($raw) ? implode(', ', $raw) : (is_object($raw) ? json_encode($raw) : $raw);
|
||||
} elseif (isset($submission->formdata->{$code}) && (is_object($submission->formdata->{$code}) || is_array($submission->formdata->{$code}))) {
|
||||
$box = (array) $submission->formdata->{$code};
|
||||
if (array_key_exists($optKey, $box)) {
|
||||
$raw = $box[$optKey];
|
||||
$optVal = is_array($raw) ? implode(', ', $raw) : (is_object($raw) ? json_encode($raw) : $raw);
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
<td>{{ $optVal }}</td>
|
||||
@endforeach
|
||||
|
||||
@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}) : (is_object($submission->formdata->{$code}) ? collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') : $submission->formdata->{$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>
|
||||
|
|
@ -0,0 +1,966 @@
|
|||
<!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;
|
||||
$submittedDoctors = collect($submissions)->map(function ($item) {
|
||||
return $item->formdata->cont_id ?? null;
|
||||
})->filter()->unique()->values()->toArray();
|
||||
|
||||
|
||||
@endphp
|
||||
|
||||
{{-- @if(count($submissions)===0 || $id) --}}
|
||||
<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"] ) )
|
||||
@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' ? 'legacy_code= ' . $option->contact->legacy_code . ' ' : '' }} {{ $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">
|
||||
<h4 class="doctor-title mb-3 text-primary">
|
||||
Doctor 1
|
||||
</h4>
|
||||
|
||||
|
||||
|
||||
@foreach($questions as $question)
|
||||
@if( in_array($question->code,
|
||||
["record_date","select_rxber_type"] ) )
|
||||
@continue;
|
||||
@endif
|
||||
<div class="col-md-12 mb-2">
|
||||
<label
|
||||
for="field-{{$question->code}}"
|
||||
class="form-label @if($question->code=='contact_id') doctor-name-label @endif">
|
||||
|
||||
{{$question->question}}
|
||||
|
||||
@if($question->code=='contact_id')
|
||||
{{1}}
|
||||
@endif
|
||||
|
||||
{!! $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')
|
||||
legacy_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
||||
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>
|
||||
{{-- Added this Heading/label for brands --}}
|
||||
@if($question->code == 'speciality')
|
||||
<h5 class="mt-3">Enter Monthly Rx of Competition Brand</h5>
|
||||
@endif
|
||||
@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>
|
||||
{{-- @elseif(!$id)
|
||||
<h4>
|
||||
You have already submitted Voltido RCPA data for <strong>{{ count($submissions) }}</strong> Doctor(s).
|
||||
|
||||
</h4>
|
||||
@endif --}}
|
||||
</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($) {
|
||||
function updateDoctorLabels() {
|
||||
|
||||
$('.doctor-wrapper').each(function(index) {
|
||||
|
||||
// Doctor Heading
|
||||
$(this).find('.doctor-title')
|
||||
.text('Doctor ' + (index + 1));
|
||||
|
||||
// Doctor Name Label
|
||||
$(this).find('.doctor-name-label').each(function () {
|
||||
|
||||
let required = $(this).find('.text-danger').length
|
||||
? ' <span class="text-danger">*</span>'
|
||||
: '';
|
||||
|
||||
$(this).html('Doctor Name ' + (index + 1) + required);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
$('#field-record_date').attr(
|
||||
'max',
|
||||
new Date().toISOString().split('T')[0]
|
||||
);
|
||||
const MIN_DOCTORS = 5;
|
||||
const MAX_DOCTORS = 15;
|
||||
const numberFields = [
|
||||
'voltido_rx',
|
||||
'vilor_f_glenmark_rx',
|
||||
'vilfuro_lupin_rx',
|
||||
'besvil_sun_rx',
|
||||
'others_rx'
|
||||
];
|
||||
|
||||
// Only positive integers
|
||||
$(document).on('input', numberFields.map(f => `input[id^="field-${f}"]`).join(','), function () {
|
||||
|
||||
// Remove everything except digits
|
||||
this.value = this.value.replace(/\D/g, '');
|
||||
|
||||
});
|
||||
|
||||
// Prevent typing -, +, ., e
|
||||
$(document).on('keydown', numberFields.map(f => `input[id^="field-${f}"]`).join(','), function (e) {
|
||||
|
||||
if (['-', '+', '.', 'e', 'E'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-legacy_code').val($(this).find(":selected").attr("legacy_code"));
|
||||
})
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||
})
|
||||
|
||||
$('#field-legacy_code,#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%'
|
||||
});
|
||||
}
|
||||
|
||||
window.submittedDoctors = @json($submittedDoctors);
|
||||
|
||||
@if($id)
|
||||
let currentDoctor = $('#field-contact_id').val();
|
||||
|
||||
window.submittedDoctors =
|
||||
window.submittedDoctors.filter(
|
||||
doctor => doctor != currentDoctor
|
||||
);
|
||||
@endif
|
||||
|
||||
initializeSelect2();
|
||||
preventDuplicateDoctors(window.submittedDoctors);
|
||||
updateDoctorLabels();
|
||||
|
||||
|
||||
|
||||
/* 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');
|
||||
|
||||
});
|
||||
|
||||
}*/
|
||||
|
||||
function preventDuplicateDoctors(submittedDoctors = []) {
|
||||
|
||||
let selectedDoctors = [];
|
||||
|
||||
// Get currently selected doctors from form
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value) {
|
||||
selectedDoctors.push(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Merge current + submitted doctors
|
||||
let blockedDoctors = [
|
||||
...new Set([
|
||||
...selectedDoctors,
|
||||
...submittedDoctors
|
||||
])
|
||||
];
|
||||
|
||||
$('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 labels
|
||||
let cleanText = option.text()
|
||||
.replace(' (Already Added)', '')
|
||||
.replace(' (Already Submitted)', '');
|
||||
|
||||
// Keep currently selected option enabled
|
||||
if (
|
||||
blockedDoctors.includes(optionValue) &&
|
||||
optionValue !== currentValue
|
||||
) {
|
||||
|
||||
option.prop('disabled', true);
|
||||
|
||||
/*if (submittedDoctors.includes(optionValue)) {
|
||||
|
||||
option.text(cleanText + ' (Already Submitted)');
|
||||
|
||||
} else {
|
||||
|
||||
option.text(cleanText + ' (Already Added)');
|
||||
|
||||
}*/
|
||||
if (
|
||||
submittedDoctors.includes(optionValue) &&
|
||||
!selectedDoctors.includes(optionValue)
|
||||
) {
|
||||
|
||||
option.text(cleanText + ' (Already Submitted)');
|
||||
|
||||
} else {
|
||||
|
||||
option.text(cleanText + ' (Already Added)');
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(cleanText);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Refresh Select2
|
||||
if (currentSelect.hasClass('select2-hidden-accessible')) {
|
||||
currentSelect.select2('destroy');
|
||||
}
|
||||
|
||||
currentSelect.select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
currentSelect.val(currentValue).trigger('change.select2');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(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-legacy_code-' + id).val(selectedOption.attr('legacy_code'));
|
||||
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
||||
|
||||
let activeSelections = [];
|
||||
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let val = $(this).val();
|
||||
|
||||
if (val) {
|
||||
activeSelections.push(val);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
let filteredSubmittedDoctors =
|
||||
window.submittedDoctors.filter(
|
||||
doctor => !activeSelections.includes(doctor)
|
||||
);
|
||||
|
||||
preventDuplicateDoctors(filteredSubmittedDoctors);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var doctor_count = 0
|
||||
let uniqueDoctorId = 0;
|
||||
|
||||
let numberOfSubmission=0;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
$('#adddoctor-btn').click(function() {
|
||||
if ($('.doctor-wrapper').length >= MAX_DOCTORS) {
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Maximum Limit',
|
||||
text: 'You can add maximum 15 doctors.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
let doctorName=$('#field-contact_id').html();
|
||||
|
||||
console.log("Doctor Name : ",doctorName);
|
||||
doctor_count++;
|
||||
uniqueDoctorId++;
|
||||
numberOfSubmission++;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
|
||||
|
||||
|
||||
/*<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> ye Remove Button <div class="doctor-wrapper"> ke nich tha...but abhi ke liye remove option nikal diya h */
|
||||
|
||||
let empty_doctor = `
|
||||
|
||||
<div class="doctor-wrapper">
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="doctor-title mb-3 text-primary">
|
||||
Doctor ${doctor_count + 1}
|
||||
</h4>
|
||||
|
||||
@foreach($questions as $question)
|
||||
|
||||
@if( in_array($question->code,
|
||||
["record_date","select_rxber_type"] ) )
|
||||
@continue;
|
||||
@endif
|
||||
|
||||
<div class="col-md-12 mb-2">
|
||||
<label
|
||||
for="field-{{$question->code}}-${uniqueDoctorId}"
|
||||
class="form-label @if($question->code=='contact_id') doctor-name-label @endif">
|
||||
|
||||
{{$question->question}}
|
||||
|
||||
@if($question->code=='contact_id')
|
||||
${doctor_count + 1}
|
||||
@endif
|
||||
|
||||
{!! $question->required == 'yes' ? '<span class="text-danger">*</span>' : '' !!}
|
||||
</label>
|
||||
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}-${uniqueDoctorId}" name="{{$question->code}}[${uniqueDoctorId}]" 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}}-${uniqueDoctorId}" name="{{$question->code}}[${uniqueDoctorId}]" 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}}-${uniqueDoctorId}" name="{{$question->code}}[${uniqueDoctorId}]" 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}}-${uniqueDoctorId}" name="{{$question->code}}[${uniqueDoctorId}]" {{$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' ? 'legacy_code= ' . $option->contact->legacy_code . ' ' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@if($question->code == 'speciality')
|
||||
<h5 class="mt-3">Enter Monthly Rx of Competition Brand</h5>
|
||||
@endif
|
||||
|
||||
|
||||
@endforeach </div>`;
|
||||
|
||||
|
||||
$('#doctor-group-wrapper').append(empty_doctor)
|
||||
updateDoctorLabels();
|
||||
$('#field-contact_id-'+uniqueDoctorId).select2({
|
||||
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
/* preventDuplicateDoctors(); */
|
||||
|
||||
// ===== NEW CODE =====
|
||||
let activeSelections = [];
|
||||
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
let val = $(this).val();
|
||||
if (val) {
|
||||
activeSelections.push(val);
|
||||
}
|
||||
});
|
||||
|
||||
let filteredSubmittedDoctors =
|
||||
window.submittedDoctors.filter(
|
||||
doctor => !activeSelections.includes(doctor)
|
||||
);
|
||||
|
||||
preventDuplicateDoctors(filteredSubmittedDoctors);
|
||||
// ===== END NEW CODE =====
|
||||
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
$('#field-legacy_code-' + uniqueDoctorId).prop('readonly', true);
|
||||
$('#field-speciality-' + uniqueDoctorId).prop('readonly', true);
|
||||
}, 100);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($('.doctor-wrapper').length >= MAX_DOCTORS) {
|
||||
$('#adddoctor-btn').hide();
|
||||
} else {
|
||||
if ($('.doctor-wrapper').length < MAX_DOCTORS) {
|
||||
$('#adddoctor-btn').show();
|
||||
}}
|
||||
/*if ($('.doctor-wrapper').length >= MAX_DOCTORS) {
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Maximum Limit',
|
||||
text: 'You can add maximum 15 doctors.'
|
||||
});
|
||||
return;
|
||||
}*/
|
||||
|
||||
$('.btn-remove').unbind();
|
||||
$('.btn-remove').click(function() {
|
||||
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
||||
$(this).closest('.doctor-wrapper').remove();
|
||||
numberOfSubmission--;
|
||||
preventDuplicateDoctors();
|
||||
updateDoctorLabels();
|
||||
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("legacy_code", itm.contact.legacy_code).attr("speciality", itm.contact.speciality));
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-legacy_code').val($('option:selected', this).attr('legacy_code'))
|
||||
})
|
||||
|
||||
$('#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(!$id)
|
||||
let totalDoctors = $('.doctor-wrapper').length;
|
||||
|
||||
if (totalDoctors < MIN_DOCTORS || totalDoctors > MAX_DOCTORS) {
|
||||
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Doctor Limit',
|
||||
text: `Minimum ${MIN_DOCTORS} and Maximum ${MAX_DOCTORS} doctors are required to submit. Currently added: ${totalDoctors}.`
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
@endif */
|
||||
|
||||
$("#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>
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
<!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="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</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}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_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':'' }} 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" {!!($question->code
|
||||
== 'contact_id')?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
@endforeach
|
||||
@if($question->code=='contact_id')
|
||||
<option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>Others</option>
|
||||
@endif
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('[data-toggle="select2"]').select2();
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
$('#field-hierarchy_id').val(hierarchy)
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for (let itm of data) {
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality));
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||
|
||||
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').prop({"required":false});
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').parent().hide();
|
||||
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
let dropDown=$('#field-contact_id').val();
|
||||
if(dropDown==='others'){
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').parent().show();
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').prop({"required":true});
|
||||
$('#field-speciality,#field-msl_code').parent().hide();
|
||||
$('#field-speciality,#field-msl_code').prop({"required":false});
|
||||
}
|
||||
else{
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').parent().hide();
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').prop({"required":false});
|
||||
$('#field-speciality,#field-msl_code').parent().show();
|
||||
$('#field-speciality,#field-msl_code').prop({"required":true});
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
// $('#field-contact_id').append('<option value="others">Others</option>');
|
||||
|
||||
$('#field-sitazit_d_rx,#field-sitazit_dm_rx,#field-ziten_m_rx').on('input', function() {
|
||||
var total=(
|
||||
(parseInt($('#execution-sitazit_d_rx').val())*15 ||0)+
|
||||
(parseInt($('#execution-sitazit_dm_rx').val())*25 ||0)+
|
||||
(parseInt($('#execution-ziten_m_rx').val())*35 ||0)
|
||||
);
|
||||
|
||||
$('#execution-total_camp_rx').val(total)
|
||||
})
|
||||
|
||||
$('#field-file_upload').on('change', function () {
|
||||
let file = this.files[0];
|
||||
|
||||
if (file) {
|
||||
let allowedTypes = ['image/png', 'image/jpg', 'image/jpeg','application/pdf'];
|
||||
let maxSize = 10 * 1024 * 1024; // 10 MB
|
||||
|
||||
// Type validation
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
alert('Only PNG, JPG, PDF and JPEG files are allowed.');
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// Size validation
|
||||
if (file.size > maxSize) {
|
||||
alert('File size should not exceed 10 MB.');
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#field-contact_id').trigger('change');
|
||||
});
|
||||
|
||||
$('#field-enter_chemist_name').on('input', function () {
|
||||
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||
});
|
||||
|
||||
$('#field-voltido_trio_strip_pack_pob_units').on('input', function () {
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
|
||||
$('label[for="field-voltido_trio_strip_pack_pob_units"]').html('Voltido Trio Strip Pack POB Units<span class="text-danger">*</span><br><small><i>(A Monocarton with 3 Strips)</i></small>');
|
||||
|
||||
|
||||
$('#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); */
|
||||
|
||||
|
||||
var recordDateField = document.getElementById('field-record_date');
|
||||
|
||||
var today = new Date();
|
||||
var tomorrow = new Date();
|
||||
tomorrow.setDate(today.getDate() + 1);
|
||||
|
||||
function formatDate(date) {
|
||||
return date.getFullYear() + '-' +
|
||||
String(date.getMonth() + 1).padStart(2, '0') + '-' +
|
||||
String(date.getDate()).padStart(2, '0');
|
||||
}
|
||||
|
||||
var todayDate = formatDate(today);
|
||||
var tomorrowDate = formatDate(tomorrow);
|
||||
|
||||
// 13 August ला फक्त 13 August
|
||||
recordDateField.setAttribute('min', tomorrowDate);
|
||||
recordDateField.setAttribute('max', tomorrowDate);
|
||||
|
||||
// 14 August पासून:
|
||||
// min = 13 August
|
||||
// max = today
|
||||
if (today.getDate() >= tomorrow.getDate()) {
|
||||
recordDateField.setAttribute('min', tomorrowDate);
|
||||
recordDateField.setAttribute('max', todayDate);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -453,7 +453,7 @@
|
|||
// console.log("day = ",day)
|
||||
// console.log("month = ",month)
|
||||
// console.log("year = ",year)
|
||||
let minDateStr = year + '/' + month + '/' + day;
|
||||
/* let minDateStr = year + '/' + month + '/' + day;
|
||||
let maxDateStr = year + '/' + month + '/' + day;
|
||||
|
||||
// console.log("minDateStr = ",minDateStr)
|
||||
|
|
@ -461,12 +461,22 @@
|
|||
|
||||
// let minDate = new Date(new Date(minDate).getTime()+(9*24*60*60*1000))
|
||||
let minDate = new Date (today - (30*24*60*60*1000));
|
||||
minDateStr = minDate.getFullYear() + '/' + String(minDate.getMonth() + 1).padStart(2, '0') + '/' + String(minDate.getDate()).padStart(2, '0');
|
||||
minDateStr = minDate.getFullYear() + '/' + String(minDate.getMonth() + 1).padStart(2, '0') + '/' + String(minDate.getDate()).padStart(2, '0'); */
|
||||
|
||||
// console.log("minDate = ",minDate)
|
||||
// console.log("minDateStr = ",minDateStr)
|
||||
|
||||
//Setting min, max dates and value to Datepicker...
|
||||
|
||||
// Minimum date = 1 April of current year
|
||||
let minDateStr = year + '/04/01';
|
||||
|
||||
// Maximum date = Today
|
||||
let maxDateStr = year + '/' + month + '/' + day;
|
||||
|
||||
console.log("minDateStr =", minDateStr);
|
||||
console.log("maxDateStr =", maxDateStr);
|
||||
|
||||
$('#field-record_date').flatpickr({
|
||||
minDate: minDateStr,
|
||||
maxDate: maxDateStr,
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@
|
|||
$('#field-pob_units').on('input', function() {
|
||||
var total=(
|
||||
(parseInt($('#field-pob_units').val())*11.4 ||0)
|
||||
);
|
||||
).toFixed(2);
|
||||
|
||||
$('#field-pob_value').val(total)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,544 @@
|
|||
<!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="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
@php
|
||||
$brandData = [
|
||||
|
||||
//['brand'=>'Pulmosmart G', 'slug'=>'pulmosmart_g_units','pseudoId'=>'pulmosmart_g_value'],
|
||||
['brand'=>"200 PULMICAPS (30'S)", 'slug'=>'200_pulmicaps_30s_units','pseudoId'=>'200_pulmicaps_30s_value'],
|
||||
['brand'=>"400 PULMICAPS (30'S)", 'slug'=>'400_pulmicaps_30s_units','pseudoId'=>'400_pulmicaps_30s_value'],
|
||||
['brand'=>'DOSE COUNTER MDI 200 INHALER', 'slug'=>'dose_counter_mdi_200_inhaler_units','pseudoId'=>'dose_counter_mdi_200_inhaler_value'],
|
||||
['brand'=>'DOSE COUNTER MDI 400 INHALER', 'slug'=>'dose_counter_mdi_400_inhaler_units','pseudoId'=>'dose_counter_mdi_400_inhaler_value'],
|
||||
['brand'=>'PULMULES (2 ML)', 'slug'=>'pulmules_2_ml_units','pseudoId'=>'pulmules_2_ml_value'],
|
||||
['brand'=>'1MG PULMULES (2 ML)', 'slug'=>'1mg_pulmules_2_ml_units','pseudoId'=>'1mg_pulmules_2_ml_value']
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@endphp
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id);
|
||||
|
||||
|
||||
$formdata = null;
|
||||
|
||||
if (!empty($submissions->data->submissions)) {
|
||||
foreach ($submissions->data->submissions as $submission) {
|
||||
if ($submission->id == $id) {
|
||||
$formdata = $submission->formdata ?? null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
<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}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@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':'' }} 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' : '' }} data-selected="{{ isset($question->value) ? $question->value : '' }}">
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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">
|
||||
<div style="width: auto; overflow-y: auto; overflow-x: auto;">
|
||||
<table class="table tableclass table-bordered">
|
||||
<thead id="heading">
|
||||
<tr>
|
||||
<th style="width:70%">Brand</th>
|
||||
<th style="width:30%">Units</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($brandData as $brand)
|
||||
<tr>
|
||||
|
||||
<td>{{ $brand['brand'] }}</td>
|
||||
<td>
|
||||
<input type="number" id="field-{{ $brand['slug'] }}"
|
||||
name="{{ $brand['slug'] }}"
|
||||
class="form-control form-control-large" value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}" >
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- @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
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('[data-toggle="select2"]').select2();
|
||||
var hierarcies = [];
|
||||
var contacts = [];
|
||||
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
@foreach($form->users as $option)
|
||||
hierarcies.push('{{$option->hierarchy_id}}');
|
||||
@endforeach
|
||||
$("#pageloader").fadeIn();
|
||||
Promise.all(
|
||||
hierarcies.map(hierarchy => {
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).then(data => {
|
||||
console.log(data);
|
||||
contacts = contacts.concat(data);
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
).then(function() {
|
||||
// All contacts loaded for each hierarchy
|
||||
// Example usage: console.log(contacts);
|
||||
// Filter out contacts where value == 'sample'
|
||||
contacts = contacts.filter(function(itm) { return itm.value !== 'sample' && itm.contact && itm.contact.speciality; });
|
||||
contacts.sort((a, b) =>
|
||||
a.display.localeCompare(b.display, undefined, { sensitivity: 'base' })
|
||||
);
|
||||
|
||||
// Remove duplicate by Doctor Name
|
||||
contacts = Array.from(
|
||||
new Map(
|
||||
contacts.map(item => [item.display.trim().toLowerCase(), item])
|
||||
).values()
|
||||
);
|
||||
console.log(contacts);
|
||||
|
||||
// Loop through contacts and append options to select elements whose id starts with 'field-contact_id'
|
||||
// We assume contact_id fields may be suffixed, e.g. field-contact_id_1, field-contact_id, etc.
|
||||
function applySelect2ToDoctorDropdowns() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
// Avoid re-initializing select2
|
||||
if (select.data("select2")) return;
|
||||
select.select2({
|
||||
width: "100%",
|
||||
placeholder: "-- Select --",
|
||||
allowClear: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("[id^='field-contact_id']").trigger('change');
|
||||
|
||||
function enforceUniqueDoctorSelections() {
|
||||
var selectedValues = [];
|
||||
|
||||
// Collect selected values (ignore empty)
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var v = $(this).val();
|
||||
if (v) selectedValues.push(String(v));
|
||||
});
|
||||
|
||||
// Reset all option disabled states, then disable duplicates across selects
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var currentSelect = $(this);
|
||||
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
|
||||
|
||||
currentSelect.find("option").prop("disabled", false);
|
||||
|
||||
// Disable values selected in OTHER selects (keep current selection enabled)
|
||||
selectedValues.forEach(function (v) {
|
||||
if (v && v !== currentVal) {
|
||||
currentSelect
|
||||
.find("option[value=\"" + v.replace(/"/g, '\\"') + "\"]")
|
||||
.prop("disabled", true);
|
||||
}
|
||||
});
|
||||
|
||||
// Refresh select2 UI if present
|
||||
if (currentSelect.data("select2")) {
|
||||
currentSelect.trigger("change.select2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("[id^='field-contact_id']").each(function() {
|
||||
var select = $(this);
|
||||
// Clear previous options
|
||||
select.html('');
|
||||
// Add a default 'Select' option
|
||||
select.append(
|
||||
$("<option></option>")
|
||||
.attr("value", '')
|
||||
.text('-- Select --')
|
||||
);
|
||||
// Append options from contacts
|
||||
contacts.forEach(function(itm) {
|
||||
var option = $("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display);
|
||||
// If doctor options have extra attributes
|
||||
if (itm.contact && itm.contact.msl_code) {
|
||||
option.attr("msl_code", itm.contact.msl_code);
|
||||
}
|
||||
if (itm.contact && itm.contact.speciality) {
|
||||
option.attr("speciality", itm.contact.speciality);
|
||||
}
|
||||
select.append(option);
|
||||
});
|
||||
|
||||
var selectedValue = select.data('selected');
|
||||
if (selectedValue) {
|
||||
select.val(selectedValue);
|
||||
}
|
||||
|
||||
// For each select element, add a change event handler to populate `msl_code` and `speciality`
|
||||
// We assume dropdowns and targets follow the pattern:
|
||||
// - select: field-contact_id_1, field-contact_id_2, ..., field-contact_id
|
||||
// - result: field-msl_code_1, field-speciality_1, etc.
|
||||
|
||||
// Remove any old event handlers first to prevent duplicate bindings
|
||||
select.off('change').on('change', function () {
|
||||
var selected = $(this).find(':selected');
|
||||
|
||||
var selectId = $(this).attr('id'); // e.g., field-contact_id_1
|
||||
// Extract the suffix (e.g., _1 or empty)
|
||||
var match = selectId.match(/^field-contact_id(_\d+)?$/);
|
||||
var suffix = match && match[1] ? match[1] : '';
|
||||
|
||||
// Build the target msl_code and speciality field ids
|
||||
var mslCodeField = $('#field-msl_code' + suffix);
|
||||
var specialityField = $('#field-speciality' + suffix);
|
||||
|
||||
if (mslCodeField.length) {
|
||||
mslCodeField.val(selected.attr('msl_code') || '');
|
||||
}
|
||||
if (specialityField.length) {
|
||||
specialityField.val(selected.attr('speciality') || '');
|
||||
}
|
||||
|
||||
// Prevent selecting the same doctor across multiple dropdowns
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
|
||||
// Ensure unique selection is enforced after initial render
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
|
||||
// Enable search on doctor dropdowns
|
||||
applySelect2ToDoctorDropdowns();
|
||||
$("#pageloader").fadeOut();
|
||||
});
|
||||
@endif
|
||||
|
||||
const products = {
|
||||
"pulmosmart_g": 154.63,
|
||||
"200_pulmicaps_30s": 165.61,
|
||||
"400_pulmicaps_30s": 39.20,
|
||||
"dose_counter_mdi_200_inhaler": 39.20,
|
||||
"dose_counter_mdi_400_inhaler": 73.19,
|
||||
"pulmules_2_ml": 73.19,
|
||||
"1mg_pulmules_2_ml": 50.67
|
||||
|
||||
|
||||
|
||||
|
||||
// 👉 Continue adding all products same way
|
||||
};
|
||||
|
||||
|
||||
$(document).on('input', '[id$="_units"]', function () {
|
||||
|
||||
let totalValue = 0;
|
||||
let totalUnits = 0;
|
||||
|
||||
$.each(products, function (key, price) {
|
||||
|
||||
let unitField = $(`#field-${key}_units`);
|
||||
let valueField = $(`#field-${key}_value`);
|
||||
|
||||
let units = parseFloat(unitField.val()) || 0;
|
||||
let value = units * price;
|
||||
|
||||
// Set individual value
|
||||
valueField.val(value.toFixed(1));
|
||||
|
||||
totalValue += value;
|
||||
totalUnits += units;
|
||||
});
|
||||
|
||||
|
||||
$('#field-total_pob_units').val(totalUnits);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#field-total_pob_units,#field-msl_code').attr('readonly',true);
|
||||
|
||||
// Restrict all number fields to positive integers only
|
||||
$(document).on('keydown', 'input[type="number"]', function (e) {
|
||||
// Block: e, E, +, -, .
|
||||
if (['e', 'E', '+', '-', '.'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('input', 'input[type="number"]', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// Keep only digits
|
||||
value = value.replace(/\D/g, '');
|
||||
|
||||
// Prevent negative values
|
||||
if (value === '' || parseInt(value, 10) < 0) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
$(this).val(value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// for (let i = 1; i <= 10; i++) {
|
||||
|
||||
// $('#field-msl_code_' + i).attr('readonly',true);
|
||||
// $('#field-speciality_' + i).attr('readonly',true);
|
||||
// }
|
||||
|
||||
$('#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');
|
||||
var plandateField = document.getElementById('field-record_date');
|
||||
if (plandateField) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
plandateField.min = `${currentYear}-06-01`;
|
||||
}
|
||||
|
||||
plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,399 @@
|
|||
<!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="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
@php
|
||||
$brandData = [
|
||||
|
||||
//['brand'=>'Pulmosmart G', 'slug'=>'pulmosmart_g_units','pseudoId'=>'pulmosmart_g_value'],
|
||||
['brand'=>"200 PULMICAPS (30'S)", 'slug'=>'200_pulmicaps_30s_units','pseudoId'=>'200_pulmicaps_30s_value'],
|
||||
['brand'=>"400 PULMICAPS (30'S)", 'slug'=>'400_pulmicaps_30s_units','pseudoId'=>'400_pulmicaps_30s_value'],
|
||||
['brand'=>'DOSE COUNTER MDI 200 INHALER', 'slug'=>'dose_counter_mdi_200_inhaler_units','pseudoId'=>'dose_counter_mdi_200_inhaler_value'],
|
||||
['brand'=>'DOSE COUNTER MDI 400 INHALER', 'slug'=>'dose_counter_mdi_400_inhaler_units','pseudoId'=>'dose_counter_mdi_400_inhaler_value'],
|
||||
['brand'=>'PULMULES (2 ML)', 'slug'=>'pulmules_2_ml_units','pseudoId'=>'pulmules_2_ml_value'],
|
||||
['brand'=>'1MG PULMULES (2 ML)', 'slug'=>'1mg_pulmules_2_ml_units','pseudoId'=>'1mg_pulmules_2_ml_value']
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@endphp
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id);
|
||||
|
||||
|
||||
$formdata = null;
|
||||
|
||||
if (!empty($submissions->data->submissions)) {
|
||||
foreach ($submissions->data->submissions as $submission) {
|
||||
if ($submission->id == $id) {
|
||||
$formdata = $submission->formdata ?? null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
<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}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@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':'' }} 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" {!!($question->code
|
||||
== 'contact_id')?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
@endforeach
|
||||
@if($question->code=='contact_id')
|
||||
<option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>Others</option>
|
||||
@endif
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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">
|
||||
<div style="width: auto; overflow-y: auto; overflow-x: auto;">
|
||||
<table class="table tableclass table-bordered">
|
||||
<thead id="heading">
|
||||
<tr>
|
||||
<th style="width:70%">Brand</th>
|
||||
<th style="width:30%">Units</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($brandData as $brand)
|
||||
<tr>
|
||||
|
||||
<td>{{ $brand['brand'] }}</td>
|
||||
<td>
|
||||
<input type="number" id="field-{{ $brand['slug'] }}"
|
||||
name="{{ $brand['slug'] }}"
|
||||
class="form-control form-control-large" value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}" >
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- @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
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('[data-toggle="select2"]').select2();
|
||||
var hierarcies = [];
|
||||
var contacts = [];
|
||||
|
||||
|
||||
|
||||
const products = {
|
||||
"pulmosmart_g": 154.63,
|
||||
"200_pulmicaps_30s": 165.61,
|
||||
"400_pulmicaps_30s": 39.20,
|
||||
"dose_counter_mdi_200_inhaler": 39.20,
|
||||
"dose_counter_mdi_400_inhaler": 73.19,
|
||||
"pulmules_2_ml": 73.19,
|
||||
"1mg_pulmules_2_ml": 50.67
|
||||
|
||||
|
||||
|
||||
|
||||
// 👉 Continue adding all products same way
|
||||
};
|
||||
|
||||
|
||||
$(document).on('input', '[id$="_units"]', function () {
|
||||
|
||||
let totalValue = 0;
|
||||
let totalUnits = 0;
|
||||
|
||||
$.each(products, function (key, price) {
|
||||
|
||||
let unitField = $(`#field-${key}_units`);
|
||||
let valueField = $(`#field-${key}_value`);
|
||||
|
||||
let units = parseFloat(unitField.val()) || 0;
|
||||
let value = units * price;
|
||||
|
||||
// Set individual value
|
||||
valueField.val(value.toFixed(1));
|
||||
|
||||
totalValue += value;
|
||||
totalUnits += units;
|
||||
});
|
||||
|
||||
|
||||
$('#field-total_pob_units').val(totalUnits);
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
|
||||
|
||||
$('#field-total_pob_units,#field-msl_code').attr('readonly',true);
|
||||
|
||||
// Restrict all number fields to positive integers only
|
||||
$(document).on('keydown', 'input[type="number"]', function (e) {
|
||||
// Block: e, E, +, -, .
|
||||
if (['e', 'E', '+', '-', '.'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('input', 'input[type="number"]', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// Keep only digits
|
||||
value = value.replace(/\D/g, '');
|
||||
|
||||
// Prevent negative values
|
||||
if (value === '' || parseInt(value, 10) < 0) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
$(this).val(value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#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');
|
||||
if (plandateField) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
plandateField.min = `${currentYear}-06-01`;
|
||||
}
|
||||
|
||||
plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,544 @@
|
|||
<!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="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
@php
|
||||
$brandData = [
|
||||
|
||||
//['brand'=>'Pulmosmart G', 'slug'=>'pulmosmart_g_units','pseudoId'=>'pulmosmart_g_value'],
|
||||
['brand'=>"200 PULMICAPS (30'S)", 'slug'=>'200_pulmicaps_30s_units','pseudoId'=>'200_pulmicaps_30s_value'],
|
||||
['brand'=>"400 PULMICAPS (30'S)", 'slug'=>'400_pulmicaps_30s_units','pseudoId'=>'400_pulmicaps_30s_value'],
|
||||
['brand'=>'DOSE COUNTER MDI 200 INHALER', 'slug'=>'dose_counter_mdi_200_inhaler_units','pseudoId'=>'dose_counter_mdi_200_inhaler_value'],
|
||||
['brand'=>'DOSE COUNTER MDI 400 INHALER', 'slug'=>'dose_counter_mdi_400_inhaler_units','pseudoId'=>'dose_counter_mdi_400_inhaler_value'],
|
||||
['brand'=>'PULMULES (2 ML)', 'slug'=>'pulmules_2_ml_units','pseudoId'=>'pulmules_2_ml_value'],
|
||||
['brand'=>'1MG PULMULES (2 ML)', 'slug'=>'1mg_pulmules_2_ml_units','pseudoId'=>'1mg_pulmules_2_ml_value']
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@endphp
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id);
|
||||
|
||||
|
||||
$formdata = null;
|
||||
|
||||
if (!empty($submissions->data->submissions)) {
|
||||
foreach ($submissions->data->submissions as $submission) {
|
||||
if ($submission->id == $id) {
|
||||
$formdata = $submission->formdata ?? null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
<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}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@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':'' }} 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' : '' }} data-selected="{{ isset($question->value) ? $question->value : '' }}">
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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">
|
||||
<div style="width: auto; overflow-y: auto; overflow-x: auto;">
|
||||
<table class="table tableclass table-bordered">
|
||||
<thead id="heading">
|
||||
<tr>
|
||||
<th style="width:70%">Brand</th>
|
||||
<th style="width:30%">Units</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($brandData as $brand)
|
||||
<tr>
|
||||
|
||||
<td>{{ $brand['brand'] }}</td>
|
||||
<td>
|
||||
<input type="number" id="field-{{ $brand['slug'] }}"
|
||||
name="{{ $brand['slug'] }}"
|
||||
class="form-control form-control-large" value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}" >
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- @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
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('[data-toggle="select2"]').select2();
|
||||
var hierarcies = [];
|
||||
var contacts = [];
|
||||
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
@foreach($form->users as $option)
|
||||
hierarcies.push('{{$option->hierarchy_id}}');
|
||||
@endforeach
|
||||
$("#pageloader").fadeIn();
|
||||
Promise.all(
|
||||
hierarcies.map(hierarchy => {
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).then(data => {
|
||||
console.log(data);
|
||||
contacts = contacts.concat(data);
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
).then(function() {
|
||||
// All contacts loaded for each hierarchy
|
||||
// Example usage: console.log(contacts);
|
||||
// Filter out contacts where value == 'sample'
|
||||
contacts = contacts.filter(function(itm) { return itm.value !== 'sample' && itm.contact && itm.contact.speciality; });
|
||||
contacts.sort((a, b) =>
|
||||
a.display.localeCompare(b.display, undefined, { sensitivity: 'base' })
|
||||
);
|
||||
|
||||
// Remove duplicate by Doctor Name
|
||||
contacts = Array.from(
|
||||
new Map(
|
||||
contacts.map(item => [item.display.trim().toLowerCase(), item])
|
||||
).values()
|
||||
);
|
||||
console.log(contacts);
|
||||
|
||||
// Loop through contacts and append options to select elements whose id starts with 'field-contact_id'
|
||||
// We assume contact_id fields may be suffixed, e.g. field-contact_id_1, field-contact_id, etc.
|
||||
function applySelect2ToDoctorDropdowns() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
// Avoid re-initializing select2
|
||||
if (select.data("select2")) return;
|
||||
select.select2({
|
||||
width: "100%",
|
||||
placeholder: "-- Select --",
|
||||
allowClear: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("[id^='field-contact_id']").trigger('change');
|
||||
|
||||
function enforceUniqueDoctorSelections() {
|
||||
var selectedValues = [];
|
||||
|
||||
// Collect selected values (ignore empty)
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var v = $(this).val();
|
||||
if (v) selectedValues.push(String(v));
|
||||
});
|
||||
|
||||
// Reset all option disabled states, then disable duplicates across selects
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var currentSelect = $(this);
|
||||
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
|
||||
|
||||
currentSelect.find("option").prop("disabled", false);
|
||||
|
||||
// Disable values selected in OTHER selects (keep current selection enabled)
|
||||
selectedValues.forEach(function (v) {
|
||||
if (v && v !== currentVal) {
|
||||
currentSelect
|
||||
.find("option[value=\"" + v.replace(/"/g, '\\"') + "\"]")
|
||||
.prop("disabled", true);
|
||||
}
|
||||
});
|
||||
|
||||
// Refresh select2 UI if present
|
||||
if (currentSelect.data("select2")) {
|
||||
currentSelect.trigger("change.select2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("[id^='field-contact_id']").each(function() {
|
||||
var select = $(this);
|
||||
// Clear previous options
|
||||
select.html('');
|
||||
// Add a default 'Select' option
|
||||
select.append(
|
||||
$("<option></option>")
|
||||
.attr("value", '')
|
||||
.text('-- Select --')
|
||||
);
|
||||
// Append options from contacts
|
||||
contacts.forEach(function(itm) {
|
||||
var option = $("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display);
|
||||
// If doctor options have extra attributes
|
||||
if (itm.contact && itm.contact.msl_code) {
|
||||
option.attr("msl_code", itm.contact.msl_code);
|
||||
}
|
||||
if (itm.contact && itm.contact.speciality) {
|
||||
option.attr("speciality", itm.contact.speciality);
|
||||
}
|
||||
select.append(option);
|
||||
});
|
||||
|
||||
var selectedValue = select.data('selected');
|
||||
if (selectedValue) {
|
||||
select.val(selectedValue);
|
||||
}
|
||||
|
||||
// For each select element, add a change event handler to populate `msl_code` and `speciality`
|
||||
// We assume dropdowns and targets follow the pattern:
|
||||
// - select: field-contact_id_1, field-contact_id_2, ..., field-contact_id
|
||||
// - result: field-msl_code_1, field-speciality_1, etc.
|
||||
|
||||
// Remove any old event handlers first to prevent duplicate bindings
|
||||
select.off('change').on('change', function () {
|
||||
var selected = $(this).find(':selected');
|
||||
|
||||
var selectId = $(this).attr('id'); // e.g., field-contact_id_1
|
||||
// Extract the suffix (e.g., _1 or empty)
|
||||
var match = selectId.match(/^field-contact_id(_\d+)?$/);
|
||||
var suffix = match && match[1] ? match[1] : '';
|
||||
|
||||
// Build the target msl_code and speciality field ids
|
||||
var mslCodeField = $('#field-msl_code' + suffix);
|
||||
var specialityField = $('#field-speciality' + suffix);
|
||||
|
||||
if (mslCodeField.length) {
|
||||
mslCodeField.val(selected.attr('msl_code') || '');
|
||||
}
|
||||
if (specialityField.length) {
|
||||
specialityField.val(selected.attr('speciality') || '');
|
||||
}
|
||||
|
||||
// Prevent selecting the same doctor across multiple dropdowns
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
|
||||
// Ensure unique selection is enforced after initial render
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
|
||||
// Enable search on doctor dropdowns
|
||||
applySelect2ToDoctorDropdowns();
|
||||
$("#pageloader").fadeOut();
|
||||
});
|
||||
@endif
|
||||
|
||||
const products = {
|
||||
"pulmosmart_g": 154.63,
|
||||
"200_pulmicaps_30s": 165.61,
|
||||
"400_pulmicaps_30s": 39.20,
|
||||
"dose_counter_mdi_200_inhaler": 39.20,
|
||||
"dose_counter_mdi_400_inhaler": 73.19,
|
||||
"pulmules_2_ml": 73.19,
|
||||
"1mg_pulmules_2_ml": 50.67
|
||||
|
||||
|
||||
|
||||
|
||||
// 👉 Continue adding all products same way
|
||||
};
|
||||
|
||||
|
||||
$(document).on('input', '[id$="_units"]', function () {
|
||||
|
||||
let totalValue = 0;
|
||||
let totalUnits = 0;
|
||||
|
||||
$.each(products, function (key, price) {
|
||||
|
||||
let unitField = $(`#field-${key}_units`);
|
||||
let valueField = $(`#field-${key}_value`);
|
||||
|
||||
let units = parseFloat(unitField.val()) || 0;
|
||||
let value = units * price;
|
||||
|
||||
// Set individual value
|
||||
valueField.val(value.toFixed(1));
|
||||
|
||||
totalValue += value;
|
||||
totalUnits += units;
|
||||
});
|
||||
|
||||
|
||||
$('#field-total_pob_units').val(totalUnits);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#field-total_pob_units,#field-msl_code').attr('readonly',true);
|
||||
|
||||
// Restrict all number fields to positive integers only
|
||||
$(document).on('keydown', 'input[type="number"]', function (e) {
|
||||
// Block: e, E, +, -, .
|
||||
if (['e', 'E', '+', '-', '.'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('input', 'input[type="number"]', function () {
|
||||
let value = $(this).val();
|
||||
|
||||
// Keep only digits
|
||||
value = value.replace(/\D/g, '');
|
||||
|
||||
// Prevent negative values
|
||||
if (value === '' || parseInt(value, 10) < 0) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
$(this).val(value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// for (let i = 1; i <= 10; i++) {
|
||||
|
||||
// $('#field-msl_code_' + i).attr('readonly',true);
|
||||
// $('#field-speciality_' + i).attr('readonly',true);
|
||||
// }
|
||||
|
||||
$('#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');
|
||||
var plandateField = document.getElementById('field-record_date');
|
||||
if (plandateField) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
plandateField.min = `${currentYear}-07-01`;
|
||||
}
|
||||
|
||||
plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -77,8 +77,8 @@
|
|||
<button type="button"
|
||||
class="btn btn-xs btn-info edit-btn"
|
||||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||||
class="mdi mdi-pencil"></i> Edit</button>
|
||||
<button type="button" class="btn btn-danger btn-xs mt-1 delete-btn" data-form-id="{{ $sub->formdata->form_id }}" data-id="{{ $sub->id }}">Delete</button>
|
||||
class="mdi mdi-pencil"></i> Execute</button>
|
||||
<button type="button" class="btn btn-danger btn-xs delete-btn" data-form-id="{{ $sub->formdata->form_id }}" data-id="{{ $sub->id }}">Delete</button>
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->record_date) && $sub->formdata->record_date > 0 ? 'Yes' : 'No' }}
|
||||
</td>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||||
@csrf
|
||||
@foreach ($questions as $question)
|
||||
@if (in_array($question->code, ['record_date', 'name_of_the_speaker', 'msl_code', 'attendence','speciality']))
|
||||
@if (in_array($question->code, ['record_date', 'name_of_the_speaker', 'msl_code', 'attendence','speciality','honorarium_amount','other_expenses','total_eas','no_of_patients_on_duolin','no_of_units_duolin_respules']))
|
||||
@continue
|
||||
@endif
|
||||
<div class="col-md-12 mb-2">
|
||||
|
|
@ -364,6 +364,40 @@
|
|||
$('#form-wrapper').hide()
|
||||
$('#execution-form-wrapper').show()
|
||||
$('#table-wrapper').hide()
|
||||
$('#execution-no_of_patients_on_duolin').attr('max',10);
|
||||
|
||||
$('#execution-type_of_meeting').on('change',function(){
|
||||
let type_of_meet=$('#execution-type_of_meeting').val();
|
||||
console.log("Type of Meet",type_of_meet);
|
||||
|
||||
if(type_of_meet==='Asthma camp'){
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
||||
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker (Pedia or GP only) ');
|
||||
|
||||
}
|
||||
else{
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
||||
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
||||
}
|
||||
})
|
||||
|
||||
let type_of_meet=$('#execution-type_of_meeting').val();
|
||||
console.log("Type of Meet without change",type_of_meet);
|
||||
|
||||
if(type_of_meet==='Asthma camp'){
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
||||
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker (Pedia or GP only) ');
|
||||
|
||||
}
|
||||
else{
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
||||
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
|
@ -438,20 +472,20 @@
|
|||
var recordDateField = document.getElementById('field-plan_date');
|
||||
recordDateField.setAttribute('min', today);
|
||||
|
||||
var executionDateField = document.getElementById('execution-plan_date');
|
||||
// executionDateField.setAttribute('min', today);
|
||||
/* var executionDateField = document.getElementById('execution-plan_date');
|
||||
executionDateField.setAttribute('min', today); */
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
executionexeField.setAttribute('max', today);
|
||||
});
|
||||
|
||||
executionDateField.addEventListener('change', function() {
|
||||
/* executionDateField.addEventListener('change', function() {
|
||||
console.log('gg');
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@
|
|||
<input type="hidden" name="planning" value="yes">
|
||||
@csrf
|
||||
@foreach ($questions as $question)
|
||||
@if (in_array($question->code, ['record_date','attendence','new_continue','lta_regional','physical_virtual','yearly_honorarium','venue_av_food_etc_cost','total_eas_required']))
|
||||
@if (in_array($question->code, ['record_date','attendence','new_continue','lta_regional','physical_virtual','yearly_honorarium','venue_av_food_etc_cost','total_eas_required','no_of_patients_on_duolin','no_of_units_duolin_respules']))
|
||||
@continue
|
||||
@endif
|
||||
<div class="col-md-12 mb-2">
|
||||
|
|
@ -411,6 +411,35 @@
|
|||
$('#execution-form-wrapper').show()
|
||||
$('#table-wrapper').hide()
|
||||
$('#execution-attendence').attr({min:"1"});
|
||||
$('#execution-no_of_patients_on_duolin').attr('max',10);
|
||||
|
||||
let type_of_meet=$('#execution-type_of_meeting').val();
|
||||
console.log("type of meet",type_of_meet);
|
||||
|
||||
if(type_of_meet==='Asthma Camp'){
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
||||
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker (Pedia or GP only) ');
|
||||
}
|
||||
else{
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
||||
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
||||
|
||||
}
|
||||
|
||||
$('#execution-type_of_meeting').on('change',function(){
|
||||
let type_of_meet=$('##execution-type_of_meeting').val();
|
||||
if(type_of_meet==='Asthma Camp'){
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
||||
}
|
||||
else{
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
||||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -529,18 +558,18 @@
|
|||
// recordDateField.setAttribute('max', today);
|
||||
|
||||
var executionDateField = document.getElementById('execution-plan_date');
|
||||
// executionDateField.setAttribute('min', today);
|
||||
executionDateField.setAttribute('min', today);
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
executionexeField.setAttribute('max', today);
|
||||
});
|
||||
|
||||
executionDateField.addEventListener('change', function() {
|
||||
/* executionDateField.addEventListener('change', function() {
|
||||
console.log('gg');
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
}); */
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
<th>Execution Date</th>
|
||||
<th>Name of speaker</th>
|
||||
<th>MSL Code</th>
|
||||
<th>No. og Doctors/Paramedics attended</th>
|
||||
<th>No of Attendees</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -65,7 +65,15 @@
|
|||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs btn-info edit-btn" plan_details="{{json_encode($sub->formdata)}}"><i class="mdi mdi-pencil"></i> Edit</button>
|
||||
@if(isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes') Executed
|
||||
|
||||
@else
|
||||
<button type="button" class="btn btn-xs btn-info edit-btn"
|
||||
plan_details="{{ json_encode($sub->formdata) }}">
|
||||
<i class="mdi mdi-pencil"></i> Execute
|
||||
</button>
|
||||
@endif
|
||||
|
||||
</td>
|
||||
<td>{{(isset($sub->formdata->record_date) && $sub->formdata->record_date > 0) ?'Yes':'No' }}</td>
|
||||
<td>{{$sub->formdata->plan_date}}</td>
|
||||
|
|
@ -143,6 +151,7 @@
|
|||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
<input type="hidden" name="id" value="" id="execution-id">
|
||||
<input type="hidden" name="execution_done" value="yes">
|
||||
@foreach($questions as $question)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="execution-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
|
||||
|
|
@ -245,6 +254,11 @@
|
|||
})
|
||||
|
||||
$('.edit-btn').click(function(){
|
||||
$('#execution-plan_date').attr('readonly',true);
|
||||
let contacts = document.getElementById('execution-type_of_meeting');
|
||||
contacts.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
let selected = JSON.parse($(this).attr('plan_details'))
|
||||
for(let k of Object.keys(selected)) {
|
||||
if(selected[k] != '')
|
||||
|
|
@ -333,14 +347,14 @@
|
|||
|
||||
$('.edit-btn').click(function() {
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
executionexeField.setAttribute('max', today);
|
||||
});
|
||||
|
||||
executionDateField.addEventListener('change', function() {
|
||||
/* executionDateField.addEventListener('change', function() {
|
||||
console.log('gg');
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
}); */
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,321 @@
|
|||
<!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="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</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}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_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':'' }} 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" {!!($question->code
|
||||
== 'contact_id')?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@elseif($question->code != 'contact_id')
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('[data-toggle="select2"]').select2();
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
$('#field-hierarchy_id').val(hierarchy)
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for (let itm of data) {
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality));
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
/* $('#field-msl_code,#field-speciality').attr('readonly',true); */
|
||||
|
||||
|
||||
/* $('#field-type_of_nebulizer').on('change',function(){
|
||||
$('#report-form input.dynamic-hidden').remove();
|
||||
$('#report-form').append('<input type="hidden" class="dynamic-hidden" name="'+ $('#field-type_of_nebulizer').val().toLowerCase() +'" value="1">')
|
||||
}) */
|
||||
|
||||
|
||||
$('#field-file_upload').on('change', function () {
|
||||
let file = this.files[0];
|
||||
|
||||
if (file) {
|
||||
let allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
|
||||
let maxSize = 10 * 1024 * 1024; // 10 MB
|
||||
|
||||
// Type validation
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
alert('Only PNG, JPG, and JPEG files are allowed.');
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// Size validation
|
||||
if (file.size > maxSize) {
|
||||
alert('File size should not exceed 10 MB.');
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#field-contact_id').on('input', function () {
|
||||
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||
});
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
$('#report-form').append('<input type="hidden" name="'+ $('#field-type_of_nebulizer').val().toLowerCase() +'" value="'+$('#field-no_of_nebulizer').val()+'" />');
|
||||
// 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);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -73,130 +73,130 @@
|
|||
}
|
||||
@endphp
|
||||
|
||||
@if(count($submissions) < 1)
|
||||
@if(count($submissions) < 3 )
|
||||
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@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)
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@endif
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
<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')
|
||||
@if ($question->code == 'contact_id')
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@php $spec = $option->contact->speciality ?? ''; @endphp
|
||||
@if (in_array($spec, ['ANAESTHETIST','CARDIOLOGIST','Chemist','Chemist/Pharmacy','CHEST PHYSICIAN','Consultant Physician','Consulting Physician','CVTS','DENTIST','DERMATOLOGIST','DIABETOLOGIST','ENT SURGEON','GASTROENTEROLOGIST','GENERAL PHYSICIAN','GP NON MBBS','GYNAECOLOGIST','INTENSIVE CARE','Intensivist','Nephrologist','NEUROLOGIST','ONCOLOGIST','OPHTHALMOLOGIST','ORTHOPEDICIAN','OTHERS SPECIALITIES','PAEDIATRICIAN','PEAD CARDIOLOGIST','PEDIATRICIAN','Physician Consulting','POST GRADUATE','PRACTICING DIABETOLOGIST','PSYCHIATRIST','PULMONOLOGIST','RHEUMATOLOGIST','SURGEON','Test DIABETOLOGIST','UROLOGIST']))
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
legacy_code="{{ $option->contact->legacy_code ?? '' }}"
|
||||
speciality="{{ $spec }}">
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
{{ $option->display }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@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>
|
||||
<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
|
||||
@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">
|
||||
</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':'' }} 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')
|
||||
@if ($question->code == 'contact_id')
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@php $spec = $option->contact->speciality ?? ''; @endphp
|
||||
@if (in_array($spec, ['ANAESTHETIST','CARDIOLOGIST','Chemist','Chemist/Pharmacy','CHEST PHYSICIAN','Consultant Physician','Consulting Physician','CVTS','DENTIST','DERMATOLOGIST','DIABETOLOGIST','ENT SURGEON','GASTROENTEROLOGIST','GENERAL PHYSICIAN','GP NON MBBS','GYNAECOLOGIST','INTENSIVE CARE','Intensivist','Nephrologist','NEUROLOGIST','ONCOLOGIST','OPHTHALMOLOGIST','ORTHOPEDICIAN','OTHERS SPECIALITIES','PAEDIATRICIAN','PEAD CARDIOLOGIST','PEDIATRICIAN','Physician Consulting','POST GRADUATE','PRACTICING DIABETOLOGIST','PSYCHIATRIST','PULMONOLOGIST','RHEUMATOLOGIST','SURGEON','Test DIABETOLOGIST','UROLOGIST']))
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
legacy_code="{{ $option->contact->legacy_code ?? '' }}"
|
||||
speciality="{{ $spec }}">
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
{{ $option->display }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
@break
|
||||
@case('checkbox')
|
||||
@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 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
|
||||
@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
|
||||
|
||||
@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
|
||||
|
||||
|
||||
@if(!$alreadySubmitted && (!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>
|
||||
{{-- @else
|
||||
<div class="alert alert-warning text-center mt-3">
|
||||
You have already submitted this form for this month.
|
||||
</div> --}}
|
||||
@endif
|
||||
</form>
|
||||
@if((!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>
|
||||
{{-- @else
|
||||
<div class="alert alert-warning text-center mt-3">
|
||||
You have already submitted this form for this month.
|
||||
</div> --}}
|
||||
@endif
|
||||
</form>
|
||||
|
||||
@elseif($submissions[0]->workflow_status=='rejected')
|
||||
@if(!request()->has('edit'))
|
||||
|
|
@ -212,125 +212,125 @@
|
|||
@endif
|
||||
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@endif
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@endif
|
||||
|
||||
{{-- TM Contact: common field, outside doctor wrappers --}}
|
||||
<div class="col-md-12 mb-2">
|
||||
<label class="form-label">TM Contact Number <span class="text-danger">*</span></label>
|
||||
<input type="tel" id="field-tm_contact" name="tm_contact" class="form-control"
|
||||
value="{{ $submissions[0]->formdata->tm_contact ?? '' }}">
|
||||
</div>
|
||||
{{-- TM Contact: common field, outside doctor wrappers --}}
|
||||
<div class="col-md-12 mb-2">
|
||||
<label class="form-label">TM Contact Number <span class="text-danger">*</span></label>
|
||||
<input type="tel" id="field-tm_contact" name="tm_contact" class="form-control"
|
||||
value="{{ $submissions[0]->formdata->tm_contact ?? '' }}">
|
||||
</div>
|
||||
|
||||
{{-- Manager select if applicable --}}
|
||||
@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
|
||||
{{-- Manager select if applicable --}}
|
||||
@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
|
||||
|
||||
{{-- Doctor Wrappers --}}
|
||||
@for($i = 1; $i <= 3; $i++)
|
||||
<div class="doctor-wrapper mb-4 p-2 border" data-index="{{$i}}">
|
||||
<h5>Doctor {{$i}}</h5>
|
||||
{{-- Doctor Wrappers --}}
|
||||
@for($i = 1; $i <= 3; $i++)
|
||||
<div class="doctor-wrapper mb-4 p-2 border" data-index="{{$i}}">
|
||||
<h5>Doctor {{$i}}</h5>
|
||||
|
||||
@foreach($questions as $question)
|
||||
@foreach($questions as $question)
|
||||
|
||||
@php
|
||||
$fieldName = $question->code;
|
||||
if($i > 1){
|
||||
$fieldName = $question->code . '_' . $i;
|
||||
}
|
||||
@php
|
||||
$fieldName = $question->code;
|
||||
if($i > 1){
|
||||
$fieldName = $question->code . '_' . $i;
|
||||
}
|
||||
|
||||
// Special case: first wrapper contact_id is stored as cont_id in formdata
|
||||
$lookupName = $fieldName;
|
||||
if($i == 1 && $question->code == 'contact_id'){
|
||||
$lookupName = 'cont_id';
|
||||
}
|
||||
// Special case: first wrapper contact_id is stored as cont_id in formdata
|
||||
$lookupName = $fieldName;
|
||||
if($i == 1 && $question->code == 'contact_id'){
|
||||
$lookupName = 'cont_id';
|
||||
}
|
||||
|
||||
// Skip tm_contact because it's outside
|
||||
if($question->code == 'tm_contact') continue;
|
||||
// Skip tm_contact because it's outside
|
||||
if($question->code == 'tm_contact') continue;
|
||||
|
||||
$value = isset($submissions[0]->formdata->{$lookupName})
|
||||
? $submissions[0]->formdata->{$lookupName}
|
||||
: '';
|
||||
@endphp
|
||||
$value = isset($submissions[0]->formdata->{$lookupName})
|
||||
? $submissions[0]->formdata->{$lookupName}
|
||||
: '';
|
||||
@endphp
|
||||
|
||||
<div class="col-md-12 mb-2">
|
||||
<label class="form-label">{{$question->question}}</label>
|
||||
<div class="col-md-12 mb-2">
|
||||
<label class="form-label">{{$question->question}}</label>
|
||||
|
||||
@switch($question->type)
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
@case('time')
|
||||
@case('number')
|
||||
<input type="{{$question->type}}"
|
||||
id="field-{{$fieldName}}"
|
||||
name="{{$fieldName}}"
|
||||
class="form-control"
|
||||
value="{{$value}}">
|
||||
@break
|
||||
@switch($question->type)
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
@case('time')
|
||||
@case('number')
|
||||
<input type="{{$question->type}}"
|
||||
id="field-{{$fieldName}}"
|
||||
name="{{$fieldName}}"
|
||||
class="form-control"
|
||||
value="{{$value}}">
|
||||
@break
|
||||
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$fieldName}}"
|
||||
name="{{$fieldName}}"
|
||||
class="form-control">{{$value}}</textarea>
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$fieldName}}"
|
||||
name="{{$fieldName}}"
|
||||
class="form-control">{{$value}}</textarea>
|
||||
@break
|
||||
|
||||
@case('dropdown')
|
||||
<select id="field-{{$fieldName}}" name="{{$fieldName}}" class="form-control">
|
||||
<option value="">-- Select --</option>
|
||||
@foreach ($question->options as $option)
|
||||
@php
|
||||
$optionValue = $option->value; // default ID
|
||||
if($i > 1 && $question->code == 'contact_id') {
|
||||
$optionValue = $option->display; // use name for wrapper 2 & 3
|
||||
}
|
||||
@endphp
|
||||
@case('dropdown')
|
||||
<select id="field-{{$fieldName}}" name="{{$fieldName}}" class="form-control">
|
||||
<option value="">-- Select --</option>
|
||||
@foreach ($question->options as $option)
|
||||
@php
|
||||
$optionValue = $option->value; // default ID
|
||||
if($i > 1 && $question->code == 'contact_id') {
|
||||
$optionValue = $option->display; // use name for wrapper 2 & 3
|
||||
}
|
||||
@endphp
|
||||
|
||||
<option value="{{ $optionValue }}"
|
||||
{{ $value == $optionValue ? 'selected' : '' }}
|
||||
legacy_code="{{ $option->contact->legacy_code ?? '' }}"
|
||||
speciality="{{ $option->contact->speciality ?? '' }}">
|
||||
{{$option->display}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
<option value="{{ $optionValue }}"
|
||||
{{ $value == $optionValue ? 'selected' : '' }}
|
||||
legacy_code="{{ $option->contact->legacy_code ?? '' }}"
|
||||
speciality="{{ $option->contact->speciality ?? '' }}">
|
||||
{{$option->display}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
</div>
|
||||
@endfor
|
||||
@endforeach
|
||||
</div>
|
||||
@endfor
|
||||
|
||||
{{-- Submit button --}}
|
||||
{{-- @if(!$alreadySubmitted && (!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>
|
||||
{{-- Submit button --}}
|
||||
{{-- @if(!$alreadySubmitted && (!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>
|
||||
|
||||
@else
|
||||
<div class="alert alert-warning text-center mt-3">
|
||||
You have already submitted this form
|
||||
You have already submitted this forms
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
|
@ -431,6 +431,10 @@
|
|||
|
||||
}
|
||||
})
|
||||
$('#field-month').val('August');
|
||||
|
||||
|
||||
$('#field-month').css({'pointer-events': 'none','background-color': '#e9ecef'}).attr('tabindex', '-1');
|
||||
|
||||
// $('#field-contact_id').append('<option value="others">Others</option>');
|
||||
|
||||
|
|
@ -455,19 +459,19 @@
|
|||
$('#field-expecteed_value_total').val(total)
|
||||
})
|
||||
|
||||
$('#field-tm_contact').on('input', function () {
|
||||
let mobile = $(this).val();
|
||||
$('#field-tm_contact').on('input', function () {
|
||||
let mobile = $(this).val();
|
||||
|
||||
// Allow only digits
|
||||
mobile = mobile.replace(/\D/g, '');
|
||||
// Allow only digits
|
||||
mobile = mobile.replace(/\D/g, '');
|
||||
|
||||
// Limit to 10 digits
|
||||
if (mobile.length > 10) {
|
||||
mobile = mobile.slice(0, 10);
|
||||
}
|
||||
// Limit to 10 digits
|
||||
if (mobile.length > 10) {
|
||||
mobile = mobile.slice(0, 10);
|
||||
}
|
||||
|
||||
$(this).val(mobile);
|
||||
});
|
||||
$(this).val(mobile);
|
||||
});
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
|
|
@ -483,19 +487,19 @@
|
|||
return;
|
||||
}
|
||||
|
||||
let totalWrappers = $('.doctor-wrapper').length;
|
||||
let totalWrappers = $('.doctor-wrapper').length;
|
||||
|
||||
if (totalWrappers < 3) {
|
||||
event.preventDefault();
|
||||
if (totalWrappers < 3) {
|
||||
event.preventDefault();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Incomplete Form',
|
||||
text: 'Please add all 3 doctors before submitting.'
|
||||
});
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Incomplete Form',
|
||||
text: 'Please add all 3 doctors before submitting.'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
// Log form data to console
|
||||
|
|
@ -539,7 +543,7 @@
|
|||
|
||||
var plandateField = document.getElementById('field-record_date');
|
||||
|
||||
plandateField.setAttribute('max', today);
|
||||
//plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
@if(!$id)
|
||||
|
|
@ -629,6 +633,11 @@ for (let i = 2; i <= 3; i++) { // numbering starts at 2
|
|||
|
||||
// 👉 Append clone
|
||||
$clone.insertAfter($('.doctor-wrapper').last());
|
||||
|
||||
$('#field-month_2').val('August');
|
||||
$('#field-month_3').val('August');
|
||||
|
||||
$('#field-month_2, #field-month_3').css({'pointer-events': 'none','background-color': '#e9ecef'}).attr('tabindex', '-1');
|
||||
}
|
||||
|
||||
// 👉 Remove add button completely
|
||||
|
|
@ -667,7 +676,7 @@ $(document).on('input', '[id^=field-expected_value_kid_tab], [id^=field-expected
|
|||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
{{-- <script>
|
||||
// 👉 Prevent duplicate doctor selection
|
||||
$(document).on('change', '[id^=field-contact_id]', function () {
|
||||
|
||||
|
|
@ -703,7 +712,84 @@ $(document).on('change', '[id^=field-contact_id]', function () {
|
|||
$wrapper.find('[id^=field-legacy_code]').val('');
|
||||
}
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
<script>
|
||||
// =========================================================
|
||||
// New CODE: DUPLICATE DOCTOR CHECK & '(Already Added)' TEXT
|
||||
// =========================================================
|
||||
|
||||
// 1. Function: All dropdowns options dynamic update
|
||||
function updateDoctorDropdownOptions() {
|
||||
let selectedDoctors = [];
|
||||
|
||||
// Currently selected doctors shodha
|
||||
$('[id^=field-contact_id]').each(function () {
|
||||
let val = $(this).val();
|
||||
let text = $(this).find('option:selected').text().replace(' (Already Added)', '').trim();
|
||||
|
||||
if (val && text !== '-- Select --') {
|
||||
selectedDoctors.push({ val: val, text: text });
|
||||
}
|
||||
});
|
||||
|
||||
// Update status in every wrappers dropdown
|
||||
$('[id^=field-contact_id]').each(function () {
|
||||
let $currentSelect = $(this);
|
||||
let currentVal = $currentSelect.val();
|
||||
|
||||
$currentSelect.find('option').each(function () {
|
||||
let $opt = $(this);
|
||||
let optVal = $opt.val();
|
||||
let cleanText = $opt.text().replace(' (Already Added)', '').trim();
|
||||
|
||||
if (!optVal || optVal === '') return;
|
||||
|
||||
// Check in other wheter this doctor is selected in previous wrapper
|
||||
let isSelectedElsewhere = selectedDoctors.some(d =>
|
||||
(d.val === optVal || d.text === cleanText) && d.val !== currentVal
|
||||
);
|
||||
|
||||
if (isSelectedElsewhere) {
|
||||
$opt.text(cleanText + ' (Already Added)');
|
||||
} else {
|
||||
$opt.text(cleanText);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 2. Change Event: Selection change after validate & update
|
||||
$(document).on('change', '[id^=field-contact_id]', function () {
|
||||
let currentSelect = $(this);
|
||||
let currentWrapper = currentSelect.closest('.doctor-wrapper');
|
||||
let selectedOption = currentSelect.find('option:selected');
|
||||
let currentText = selectedOption.text();
|
||||
|
||||
if (currentText.includes('(Already Added)')) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Duplicate Doctor',
|
||||
text: 'Ha doctor aadhich dusrya wrapper madhye add kela aahe.'
|
||||
});
|
||||
|
||||
currentSelect.val('');
|
||||
currentWrapper.find('[id^=field-speciality]').val('');
|
||||
currentWrapper.find('[id^=field-legacy_code]').val('');
|
||||
}
|
||||
|
||||
// Update in eevry dropdown
|
||||
updateDoctorDropdownOptions();
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
updateDoctorDropdownOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@endif
|
||||
|
||||
@if($id)
|
||||
|
|
@ -885,6 +971,10 @@ $(document).on('change', '[id^=field-contact_id]', function () {
|
|||
$wrapper.find('[id^=field-legacy_code]').val('');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@endif
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,314 @@
|
|||
<!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..." />
|
||||
</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':'' }} 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>
|
||||
@if ($question->code == 'contact_id')
|
||||
@foreach ($question->options as $option)
|
||||
@if( isset($option->contact->montair_lc_kid_nebulizer_drs) && $option->contact->montair_lc_kid_nebulizer_drs == 'Yes' )
|
||||
<option value="{{ $option->value }}" pcode="{{isset($option->contact->pcode)?$option->contact->pcode:''}}" msl_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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%;
|
||||
}
|
||||
</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();
|
||||
$.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) {
|
||||
if(itm.contact.hasOwnProperty('zita_d_dm_pmos') && itm.contact.zita_d_dm_pmos.toLowerCase() == 'yes') {
|
||||
console.log(itm)
|
||||
$('#field-contact_id').append($("<option></option>").attr("msl_code", itm.contact.msl_code).attr("value", itm.value).text(itm.display));
|
||||
}
|
||||
}
|
||||
|
||||
$('#field-contact_id').unbind()
|
||||
$('#field-contact_id').change(function(){
|
||||
$('#field-msl_code').val( $('option:selected', this).attr('sbu_code') );
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// for(let itm of data) {
|
||||
// if(itm.contact.hasOwnProperty('zita_d_dm_pmos') && itm.contact.zita_d_dm_pmos.toLowerCase() == 'yes') {
|
||||
// console.log(itm)
|
||||
// $('#field-contact_id').append($("<option></option>").attr("msl_code", itm.contact.msl_code).attr("value", itm.value).text(itm.display));
|
||||
// }
|
||||
// }
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr(
|
||||
'speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr,#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').parent().hide();
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr,#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').attr('required',false);
|
||||
|
||||
|
||||
|
||||
$('#field-nebulizer_given').on('change',function(){
|
||||
|
||||
$('#report-form input.dynamic-hidden').remove();
|
||||
let value=$('#field-nebulizer_given').val();
|
||||
if(value==='Yes'){
|
||||
$('#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').parent().hide();
|
||||
$('#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').attr('required',false);
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr').parent().show();
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr').attr('required',true);
|
||||
$('#report-form').append('<input type="hidden" class="dynamic-hidden" name="nebulizer_given" value="1">');
|
||||
}
|
||||
else if(value==='No'){
|
||||
$('#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').parent().show();
|
||||
$('#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').attr('required',true);
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr').parent().hide();
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr').attr('required',false);
|
||||
}
|
||||
else{
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr,#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').parent().hide();
|
||||
$('#field-date_of_nenulizer,#field-no_of_nebulizer_given_to_dr,#field-planned_date,#field-no_of_nebulizer_planned_to_be_given_to_dr').attr('required',false);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#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 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');
|
||||
|
||||
|
||||
|
||||
|
||||
const minDate = '2026-07-01'; // 1 July 2026
|
||||
|
||||
plandateField.setAttribute('min', minDate);
|
||||
|
||||
var nebGiven=document.getElementById('field-date_of_nenulizer');
|
||||
nebGiven.setAttribute('min',minDate);
|
||||
|
||||
let planDate=document.getElementById('field-planned_date');
|
||||
|
||||
let tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
||||
planDate.setAttribute('min', tomorrow.toISOString().split('T')[0]);
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
$isTaggingComplete = ($taggedDoctorCount == 20);
|
||||
$isTaggingComplete = ($taggedDoctorCount > 0);
|
||||
@endphp
|
||||
@if($isTaggingComplete)
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
$isTaggingComplete = ($taggedDoctorCount == 20);
|
||||
$isTaggingComplete = ($taggedDoctorCount > 0);
|
||||
@endphp
|
||||
@if($isTaggingComplete)
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
|
|
|
|||
|
|
@ -117,6 +117,19 @@
|
|||
@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="manager_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, ['execution_date','actual_no_of_attendees' ,'hcp_name','pcode_of_wrapper_doctor','speaker_name','venue','time','eas_id']))
|
||||
@continue
|
||||
|
|
@ -401,6 +414,53 @@
|
|||
$('#field-eas_amt').on('input', function () {
|
||||
this.value = this.value.replace(/\D/g, '');
|
||||
});
|
||||
$('#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));
|
||||
}
|
||||
|
||||
/* New Code */
|
||||
let $doctorSelects = $('[id^="field-hcp_name"]');
|
||||
$doctorSelects.each(function() {
|
||||
let $select = $(this);
|
||||
$select.empty().append($("<option></option>").attr("value", "").text("-- Select --"));
|
||||
for (let itm of data) {
|
||||
$select.append(
|
||||
$("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display)
|
||||
.attr("msl_code", itm.contact ? itm.contact.msl_code : "")
|
||||
.attr("speciality", itm.contact ? itm.contact.speciality : "")
|
||||
);
|
||||
}
|
||||
});
|
||||
/* End of New Code */
|
||||
|
||||
$('#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)
|
||||
})
|
||||
$('#form-wrapper').hide()
|
||||
$('#execution-form-wrapper').hide()
|
||||
var count = 1
|
||||
|
|
@ -648,6 +708,9 @@
|
|||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
$('#execution-form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
|
|
@ -720,10 +783,109 @@
|
|||
el.readOnly = true;
|
||||
});
|
||||
|
||||
let hierarchy = selected['hierarchy_id'] || $('#field-hierarchy_id').val();
|
||||
|
||||
console.log("Execution Hierarchy:", hierarchy);
|
||||
console.log("Selected Doctor:", selected['contact_id']);
|
||||
|
||||
if (hierarchy) {
|
||||
|
||||
$("#pageloader").fadeIn();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||
|
||||
success: function(data) {
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
let $executionContact = $('#execution-contact_id');
|
||||
|
||||
$executionContact.empty();
|
||||
|
||||
$executionContact.append(
|
||||
$("<option></option>")
|
||||
.attr("value", "")
|
||||
.text("-- Select --")
|
||||
);
|
||||
|
||||
for (let itm of data) {
|
||||
|
||||
$executionContact.append(
|
||||
$("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display)
|
||||
.attr("msl_code", itm.contact ? itm.contact.msl_code : "")
|
||||
.attr("speciality", itm.contact ? itm.contact.speciality : "")
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// NEW CODE START: Populate Add Attendee / Speaker dropdowns for Manager Execution
|
||||
// =========================================================
|
||||
let $doctorSelects = $('[id^="field-hcp_name"]');
|
||||
$doctorSelects.each(function() {
|
||||
let $select = $(this);
|
||||
let currentVal = $select.val();
|
||||
$select.empty().append($("<option></option>").attr("value", "").text("-- Select --"));
|
||||
for (let itm of data) {
|
||||
$select.append(
|
||||
$("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display)
|
||||
.attr("msl_code", itm.contact ? itm.contact.msl_code : "")
|
||||
.attr("speciality", itm.contact ? itm.contact.speciality : "")
|
||||
);
|
||||
}
|
||||
if (currentVal) {
|
||||
$select.val(currentVal);
|
||||
}
|
||||
});
|
||||
// =========================================================
|
||||
// NEW CODE END
|
||||
// =========================================================
|
||||
|
||||
|
||||
|
||||
// Selected doctor select करा
|
||||
if (selected['contact_id']) {
|
||||
|
||||
let contactId = selected['contact_id'].trim();
|
||||
|
||||
let $option = $executionContact.find('option').filter(function() {
|
||||
return $(this).text().trim() === contactId ||
|
||||
$(this).val() === contactId;
|
||||
}).first();
|
||||
|
||||
if ($option.length) {
|
||||
$executionContact.val($option.val()).trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
error: function(xhr) {
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
console.error(
|
||||
"Doctor loading failed:",
|
||||
xhr.responseText
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,550 @@
|
|||
<!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="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
@php
|
||||
$brandData = [
|
||||
|
||||
['brand'=>"Foracort G 400 Ciphaler 60 Blisters", 'slug'=>'foracort_g_400_ciphaler_60_blisters_units','pseudoId'=>'foracort_g_400_ciphaler_60_blisters_value'],
|
||||
['brand'=>"Foracort G 400 Rotacaps", 'slug'=>'foracort_g_400_rotacaps_units','pseudoId'=>'foracort_g_400_rotacaps_value'],
|
||||
['brand'=>"Foracort G Inhaler", 'slug'=>'foracort_g_inhaler_units','pseudoId'=>'foracort_g_inhaler_value'],
|
||||
['brand'=>"Foracort G Synchrobreathe", 'slug'=>'foracort_g_synchrobreathe_units','pseudoId'=>'foracort_g_synchrobreathe_value'],
|
||||
['brand'=>"Glycohale F", 'slug'=>'glycohale_f_units','pseudoId'=>'glycohale_f_value'],
|
||||
['brand'=>"Glycohale F Inhaler", 'slug'=>'glycohale_f_inhaler_units','pseudoId'=>'glycohale_f_inhaler_value'],
|
||||
['brand'=>"Glycohale F Synchrobreathe", 'slug'=>'glycohale_f_synchrobreathe_units','pseudoId'=>'glycohale_f_synchrobreathe_value'],
|
||||
['brand'=>"Glycohale FB", 'slug'=>'glycohale_fb_units','pseudoId'=>'glycohale_fb_value'],
|
||||
['brand'=>'Glycohale FB Ciphaler', 'slug'=>'glycohale_fb_ciphaler_units','pseudoId'=>'glycohale_fb_ciphaler_value'],
|
||||
['brand'=>'Glycohale FB Inhaler', 'slug'=>'glycohale_fb_inhaler_units','pseudoId'=>'glycohale_fb_inhaler_value'],
|
||||
['brand'=>'Glycohale FB Synchrobreathe', 'slug'=>'glycohale_fb_synchrobreathe_units','pseudoId'=>'glycohale_fb_synchrobreathe_value'],
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@endphp
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id);
|
||||
// $submission = null;
|
||||
// if(isset($submissions->data->submissions) && count($submissions->data->submissions) > 0) {
|
||||
// $submission = $submissions->data->submissions[0];
|
||||
// $formdata = $submission->formdata ?? (object)[];
|
||||
// } else {
|
||||
// $formdata = [];
|
||||
// }
|
||||
|
||||
$formdata = null;
|
||||
|
||||
if (!empty($submissions->data->submissions)) {
|
||||
foreach ($submissions->data->submissions as $submission) {
|
||||
if ($submission->id == $id) {
|
||||
$formdata = $submission->formdata ?? null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@endphp
|
||||
|
||||
|
||||
<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}}">
|
||||
<input type="hidden" name="record_date" value="" id="field-record_date">
|
||||
@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':'' }}
|
||||
value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('number')
|
||||
<input type="{{$question->type}}" min="0" max="9999999999" step="0.01"
|
||||
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)
|
||||
@php $spec = $option->contact->speciality ?? ''; @endphp
|
||||
<option value="{{ $option->value }}"
|
||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
msl_code="{{ $option->contact->msl_code ?? '' }}"
|
||||
speciality="{{ $spec }}">
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
id="field-{{$question->code}}-{{$option->value}}"
|
||||
name="{{$question->code}}[]" value="{{$option->value}}"
|
||||
{{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label"
|
||||
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@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">
|
||||
<div style="width: auto; overflow-y: auto; overflow-x: auto;">
|
||||
<table class="table tableclass">
|
||||
<thead id="heading">
|
||||
<tr>
|
||||
<th>Brand</th>
|
||||
<th>Units</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($brandData as $brand)
|
||||
<tr>
|
||||
|
||||
<td>{{ $brand['brand'] }}</td>
|
||||
<td>
|
||||
<input type="number" id="field-{{ $brand['slug'] }}"
|
||||
name="{{ $brand['slug'] }}"
|
||||
class="form-control form-control-large" value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}" >
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" id="field-{{ $brand['pseudoId'] }}"
|
||||
name="{{ $brand['pseudoId'] }}"
|
||||
class="form-control form-control-large" readonly="true" value="{{ $id && isset($formdata) && isset($formdata->{$brand['pseudoId']}) ? $formdata->{$brand['pseudoId']} : 0 }}">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- @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%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('[data-toggle="select2"]').select2();
|
||||
let selected_user_id = ''
|
||||
$('#field-user_id').change(function() {
|
||||
$("#pageloader").fadeIn();
|
||||
selected_user_id = $(this).val()
|
||||
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) {
|
||||
if(itm.contact.c2c == 'Yes') {
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",
|
||||
itm.value).text(itm.display).attr("speciality", itm
|
||||
.contact.speciality));
|
||||
}
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr(
|
||||
'speciality'))
|
||||
})
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
});
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$('#field-speciality,#field-msl_code').attr('readonly',true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const products = {
|
||||
"foracort_g_400_ciphaler_60_blisters": 783.73,
|
||||
"foracort_g_400_rotacaps": 389.59,
|
||||
"foracort_g_inhaler": 594.16,
|
||||
"foracort_g_synchrobreathe": 637.79,
|
||||
"glycohale_f": 300.66,
|
||||
"glycohale_f_inhaler": 314.88,
|
||||
"glycohale_f_synchrobreathe": 352.51,
|
||||
"glycohale_fb": 404.54,
|
||||
"glycohale_fb_ciphaler": 783.73,
|
||||
"glycohale_fb_inhaler": 593.79,
|
||||
|
||||
"glycohale_fb_synchrobreathe": 638.41
|
||||
|
||||
|
||||
// 👉 Continue adding all products same way
|
||||
};
|
||||
|
||||
$(document).on('change', '[id$="_units"]', function () {
|
||||
|
||||
let totalValue = 0;
|
||||
let totalUnits = 0;
|
||||
|
||||
$.each(products, function (key, price) {
|
||||
|
||||
let unitField = $(`#field-${key}_units`);
|
||||
let valueField = $(`#field-${key}_value`);
|
||||
|
||||
let units = parseFloat(unitField.val()) || 0;
|
||||
let value = units * price;
|
||||
|
||||
// Set individual value
|
||||
valueField.val(value.toFixed(2));
|
||||
|
||||
totalValue += value;
|
||||
totalUnits += units;
|
||||
});
|
||||
|
||||
$('#field-total_pob_value').val(totalValue.toFixed(2));
|
||||
$('#field-total_pob_units').val(totalUnits);
|
||||
|
||||
|
||||
$.each(productGroups, function(groupName, keys) {
|
||||
calculateGroupTotals(groupName, keys);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#field-total_pob_value,#field-total_pob_units').attr('readonly',true);
|
||||
|
||||
$('#field-pob_type').trigger('change');
|
||||
|
||||
$(document).on('input', '[id$="_units"]', function () {
|
||||
// Remove anything that is not a digit
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
|
||||
$('#field-upload_supporting_document').on('change', function () {
|
||||
let file = this.files[0];
|
||||
if (file) {
|
||||
let allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
|
||||
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
alert('Only PNG, JPG, and JPEG files are allowed.');
|
||||
$(this).val(''); // reset input
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const productGroups = {
|
||||
emeset: ["emeset_4_odtindia1_x_10s","emeset_4mg_10s","emeset_8mg_10s","emeset_syrup","emeset_syrup_strawberry_30_ml"],
|
||||
oflox: [
|
||||
"oflox_100mg_rediuse_60ml",
|
||||
"oflox_200_tab_10s",
|
||||
"oflox_400_10s",
|
||||
"oflox_50mg_rediuse_60ml",
|
||||
"oflox_eye_drops",
|
||||
"oflox_oz_tablets_ip",
|
||||
"oflox_rediuse",
|
||||
"oflox_200_mg_10s_tablets_ip",
|
||||
"oflox_400_mg_10s_tablets_ip",
|
||||
"oflox_m_suspension"
|
||||
],
|
||||
cefoprox: ["cefoprox_100_30ml60","cefoprox_100dt","cefoprox_200_10s","cefoprox_50_30ml","cefoprox_cv_325_tab"],
|
||||
cheston: ["cheston_duo_100ml_syrup","cheston_ls_junior_100_ml","cheston_d_cough_syrup_100_ml","cheston_d_plus_1_x_10s","cheston_ls_cough_syrup_100_ml","cheston_ls_junior_60_ml"],
|
||||
|
||||
dalacin:["dalacin_c_150mg_caps_10s","dalacin_c_300mg_caps_10s"],
|
||||
dolonex:["dolonex_disp_20mg_tabs_ip","dolonex_im_20mg1ml_inj","dolonex_im_40mg_2ml_inj_hosp_ip","dolonex_im_40mg2ml_inj_ip"],
|
||||
duonase:["duonase_f_70_md","duonase_nasal_spray"],
|
||||
ibugesic:["ibugesic_plus_susp","ibugesic_plus_susp_1","ibugesic_plus_suspension_100ml_orange"],
|
||||
mucinac:["mucinac_200_tablet_1_x_10s","mucinac_600_tablets","mucinac_ab_1_x_10_tablets","mucinac_ab_tablet","mucinac_c_tablets_1_x_15s","mucinac_oral_solution_100ml"],
|
||||
novamox:["novamox_500","novamox_125_rediuse_30_ml","novamox_125_rediuse_60_ml","novamox_250_dt_15s","novamox_250_ru_30","novamox_250_rediuse","novamox_30ml","novamox_60ml","novamox_cv_1000_mg","novamox_cv_2285_dt_tablets","novamox_cv_2285_mg_syrup","novamox_cv_375_tab_10s","novamox_cv_457_dt_10s","novamox_cv_625_tablets_10","novamox_cv_drops","novamox_cv_dry_syrup_30_ml","novamox_cv_ds","novamox_cv_forte_syp","novamox_cv_forte_syp_60_ml","novamox_drops","novamox_lb_500","novamox_rdu_drops","novamox_125_dt_15s","novamox_250_15s"],
|
||||
|
||||
tedispan:["tedispan_200_tablets_6s"],
|
||||
bilafav:["bilafav_m","bilafav_m_odt_adult_tablets_1x10s_2010","bilafav_m_odt_pedia_tablets_1x10s_104","bilafav_m_oral_suspension"],
|
||||
neksium:["neksium_20mg_tab_ip","neksium_40mg_tab","neksium_d_2030mg_caps_15s_ip","neksium_d_4030mg_caps_15s_ip"],
|
||||
tasiron:["tasiron_15_chew_tabs_3x10s_b12","tasiron_30_chew_tabs","tasiron_drops_30ml_with_external_dropper","tasiron_sachet1x15s","tasiron_suspension_150ml"],
|
||||
pansec:["pansec_80_mg_tablets","pansec_d_sr_capsules_15s","pansec_tablets_15s","pansec_l_capsules"],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
function calculateGroupTotals(groupName, keys) {
|
||||
let totalUnits = 0;
|
||||
let totalValue = 0;
|
||||
|
||||
keys.forEach(key => {
|
||||
totalUnits += parseInt($(`#field-${key}_units`).val()) || 0;
|
||||
totalValue += parseFloat($(`#field-${key}_value`).val()) || 0;
|
||||
});
|
||||
|
||||
$(`#field-${groupName}_units`).val(totalUnits);
|
||||
$(`#field-${groupName}_value`).val(totalValue.toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-emeset_units" name="emeset_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-emeset_value" name="emeset_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-oflox_units" name="oflox_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-oflox_value" name="oflox_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-cefoprox_units" name="cefoprox_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-cefoprox_value" name="cefoprox_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-cheston_units" name="cheston_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-cheston_value" name="cheston_value" />');
|
||||
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-dalacin_units" name="dalacin_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-dalacin_value" name="dalacin_value" />');
|
||||
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-dolonex_units" name="dolonex_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-dolonex_value" name="dolonex_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-duonase_units" name="duonase_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-duonase_value" name="duonase_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-ibugesic_units" name="ibugesic_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-ibugesic_value" name="ibugesic_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-mucinac_units" name="mucinac_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-mucinac_value" name="mucinac_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-novamox_units" name="novamox_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-novamox_value" name="novamox_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-tedispan_units" name="tedispan_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-tedispan_value" name="tedispan_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-bilafav_units" name="bilafav_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-bilafav_value" name="bilafav_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-tasiron_units" name="tasiron_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-tasiron_value" name="tasiron_value" />');
|
||||
|
||||
$('#report-form').append('<input type="hidden" id="field-pansec_units" name="pansec_units" />');
|
||||
$('#report-form').append('<input type="hidden" id="field-pansec_value" name="pansec_value" />');
|
||||
|
||||
|
||||
|
||||
|
||||
$('#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");
|
||||
$('#field-user_id').val(selected_user_id)
|
||||
$('#field-user_id').trigger("change");
|
||||
} 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');
|
||||
console.log("Today :",today);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue