Change
This commit is contained in:
parent
3ff4547929
commit
a690e5e7a5
|
|
@ -0,0 +1,194 @@
|
|||
<!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="{{asset('assets/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
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_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}}" {{($question->code == 'total_pob_value')?'readonly':''}}>
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-total_pob_value" class="form-label">Total POB Value</label>
|
||||
<input type="number" min="0" max="9999999999" step="1" id="field-total_pob_value" name="total_pob_value" class="form-control" readonly value="">
|
||||
</div>
|
||||
<input type="hidden" id="field-metolar-xr-12-5-pob-value" name="metolar-xr-12-5-pob-value" value="0">
|
||||
<input type="hidden" id="field-metolar-xr-25-pob-value" name="metolar-xr-25-pob-value" value="0">
|
||||
<input type="hidden" id="field-metolar-xr-50-pob-value" name="metolar-xr-50-pob-value" value="0">
|
||||
<input type="hidden" id="field-metolar-xr-100-pob-value" name="metolar-xr-100-pob-value" value="0">
|
||||
<input type="hidden" id="field-metolar-tl-25-pob-value" name="metolar-tl-25-pob-value" value="0">
|
||||
<input type="hidden" id="field-metolar-tl-50-pob-value" name="metolar-tl-50-pob-value" value="0">
|
||||
<input type="hidden" id="field-dapasach-pob-value" name="dapasach-pob-value" value="0">
|
||||
<input type="hidden" id="field-dapasach-m-pob-value" name="dapasach-m-pob-value" value="0">
|
||||
|
||||
@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"> 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 type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#field-metolar-xr-12-5-pob, #field-metolar-xr-25-pob, #field-metolar-xr-50-pob, #field-metolar-xr-100-pob, #field-metolar-tl-25-pob, #field-metolar-tl-50-pob, #field-dapasach-pob, #field-dapasach-m-pob').change(function(){
|
||||
calculatetotals();
|
||||
});
|
||||
function calculatetotals() {
|
||||
$('#field-metolar-xr-12-5-pob-value').val((parseInt($('#field-metolar-xr-12-5-pob').val())||0) *46)
|
||||
$('#field-metolar-xr-25-pob-value').val((parseInt($('#field-metolar-xr-25-pob').val())||0) *44)
|
||||
$('#field-metolar-xr-50-pob-value').val((parseInt($('#field-metolar-xr-50-pob').val())||0) *62)
|
||||
$('#field-metolar-xr-100-pob-value').val((parseInt($('#field-metolar-xr-100-pob').val())||0) *119)
|
||||
|
||||
$('#field-metolar-tl-25-pob-value').val((parseInt($('#field-metolar-tl-25-pob').val())||0) *88)
|
||||
$('#field-metolar-tl-50-pob-value').val((parseInt($('#field-metolar-tl-50-pob').val())||0) *106)
|
||||
|
||||
$('#field-dapasach-pob-value').val((parseInt($('#field-dapasach-pob').val())||0) *115)
|
||||
$('#field-dapasach-m-pob-value').val((parseInt($('#field-dapasach-m-pob').val())||0) *115)
|
||||
|
||||
$('#field-total_pob_value').val( (parseInt($('#field-metolar-xr-12-5-pob').val())||0) *46 +
|
||||
(parseInt($('#field-metolar-xr-25-pob').val())*44||0) +
|
||||
(parseInt($('#field-metolar-xr-50-pob').val())*62||0) +
|
||||
(parseInt($('#field-metolar-xr-100-pob').val())*119||0) +
|
||||
(parseInt($('#field-metolar-tl-25-pob').val())*88||0) +
|
||||
(parseInt($('#field-metolar-tl-50-pob').val())*106||0) +
|
||||
(parseInt($('#field-dapasach-pob').val())*115||0) +
|
||||
(parseInt($('#field-dapasach-m-pob').val())*115||0)
|
||||
);
|
||||
}
|
||||
calculatetotals();
|
||||
});
|
||||
</script>
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#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'
|
||||
})
|
||||
@if($id)
|
||||
window.location.href = "/form/history";
|
||||
@else
|
||||
$('#report-form').trigger("reset");
|
||||
@endif
|
||||
} 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,160 @@
|
|||
<!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
|
||||
|
||||
@php
|
||||
$start = strtotime("1 May 2021");
|
||||
$till = strtotime("now");
|
||||
if( request()->get('record_date') ) {
|
||||
$target = strtotime(request()->get('record_date'));
|
||||
} else {
|
||||
$target = strtotime("now");
|
||||
}
|
||||
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id, date("m-01-Y", $target) , date("m-t-Y", $target) );
|
||||
$contacts = [];
|
||||
//echo '<pre>'; print_r($history); exit;
|
||||
if(sizeof($history->data->submissions) > 0) {
|
||||
foreach($history->data->submissions as $sub){
|
||||
$contacts[] = $sub->formdata->target;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
|
||||
<form method="POST" action="/form/submitmultiple" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="overwrite" value="yes">
|
||||
@csrf
|
||||
<div class="col-md-12 mb-2">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless table-hover table-nowrap table-centered m-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Is targeted</th>
|
||||
<th>Doctor</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($questions[0]->options as $doctor)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$doctor->value}}" name="{{$questions[0]->code}}[]" value="{{$doctor->value}}" {{in_array($doctor->display, $contacts) ? 'checked':'' }}>
|
||||
</div>
|
||||
</td>
|
||||
<td><label class="form-check-label" for="field-{{$doctor->value}}">{{$doctor->display}}</label></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
|
||||
</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($){
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmitmultiple',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
if(data.status == 'success') {
|
||||
Swal.fire({
|
||||
title: 'Great!',
|
||||
text: 'Your data is successfully submitted!',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Data not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$('#field-record_date').change(function(){
|
||||
window.location.href = window.location.href.split('?')[0] + '?record_date=' + $(this).val()
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
<!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
|
||||
|
||||
@php
|
||||
$start = strtotime("1 May 2021");
|
||||
$till = strtotime("now");
|
||||
if( request()->get('record_date') ) {
|
||||
$target = strtotime(request()->get('record_date'));
|
||||
} else {
|
||||
$target = strtotime("now");
|
||||
}
|
||||
$history = Formhelper::getMultiformData($form->partition, '1654684982-2df9cca9-b3e3-4dab-877a-992e6e2d8b72', $form->user_id, date("m-01-Y", $target) , date("m-t-Y", $target) );
|
||||
$contacts = [];
|
||||
if(sizeof($history->data->submissions) > 0) {
|
||||
foreach($history->data->submissions as $sub){
|
||||
if(sizeof($sub->contacts) > 0) {
|
||||
$contacts[] = $sub->contacts[0]->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
//echo '<pre>';print_r($contacts);echo '</pre>';
|
||||
@endphp
|
||||
|
||||
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_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':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
@if($question->code == 'contact_id' && in_array($option->value, $contacts))
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endif
|
||||
@if($question->code == 'other_contact_id' && !in_array($option->value, $contacts))
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endif
|
||||
@if($question->code != 'contact_id' && $question->code != 'other_contact_id')
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
@if($question->code == 'contact_id')
|
||||
<option value="other">Other</option>
|
||||
@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
|
||||
@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-other_contact_id').parent().hide()
|
||||
$('#field-contact_id').change(function(){
|
||||
if($(this).val() == 'other') {
|
||||
$('#field-other_contact_id').parent().show()
|
||||
$('#field-other_contact_id').prop('required',true);
|
||||
} else {
|
||||
$('#field-other_contact_id').parent().hide()
|
||||
$('#field-other_contact_id').removeAttr('required');
|
||||
}
|
||||
})
|
||||
|
||||
$('#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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
<!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
|
||||
|
||||
@php
|
||||
$history = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$histories = [];
|
||||
$date = '';
|
||||
foreach($history->data->submissions as $sub) {
|
||||
$sub->formdata->id = $sub->id;
|
||||
$histories[] = $sub->formdata;
|
||||
}
|
||||
@endphp
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover table-nowrap table-centered m-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Action</th>
|
||||
<th>Plan Date</th>
|
||||
<th>Team Name</th>
|
||||
<th>Type of meeting</th>
|
||||
<th>Execution Date</th>
|
||||
<th>Name of speaker</th>
|
||||
<th>MSL Code</th>
|
||||
<th>No. og Doctors/Paramedics attended</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($histories as $his)
|
||||
<tr>
|
||||
<td>
|
||||
<button class="btn btn-primary btn-xs edit-button" type="button" data="{{json_encode($his)}}">Edit</button>
|
||||
</td>
|
||||
<td>{{$his->record_date}}</td>
|
||||
<td>{{$his->team_name}}</td>
|
||||
<td>{{$his->type_of_meeting}}</td>
|
||||
<td>{{$his->execution_date}}</td>
|
||||
<td>{{$his->name_of_the_speaker}}</td>
|
||||
<td>{{$his->msl_code}}</td>
|
||||
<td>{{$his->attendence}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
<input type="hidden" name="id" id="field-id" value="{{$id?$id:''}}">
|
||||
@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>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$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
|
||||
@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($){
|
||||
$('#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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$('.edit-button').click(function(){
|
||||
let data = JSON.parse( $(this).attr('data') )
|
||||
for(let k of Object.keys(data)) {
|
||||
$('#field-' + k).val( data[k] )
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
<!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
|
||||
|
||||
@php
|
||||
$history = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$histories = [];
|
||||
$date = '';
|
||||
foreach($history->data->submissions as $sub) {
|
||||
$sub->formdata->id = $sub->id;
|
||||
$histories[] = $sub->formdata;
|
||||
}
|
||||
@endphp
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover table-nowrap table-centered m-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Action</th>
|
||||
<th>Tour</th>
|
||||
<th>Plan Date</th>
|
||||
<th>Execution Date</th>
|
||||
<th>Total POB</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($histories as $his)
|
||||
<tr>
|
||||
<td>
|
||||
<button class="btn btn-primary btn-xs edit-button" type="button" data="{{json_encode($his)}}">Edit</button>
|
||||
</td>
|
||||
<td>{{$his->tour}}</td>
|
||||
<td>{{$his->record_date}}</td>
|
||||
<td>{{$his->execution_date}}</td>
|
||||
<td>{{$his->total_pob}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
<input type="hidden" name="id" id="field-id" value="{{$id?$id:''}}">
|
||||
@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>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$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
|
||||
@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($){
|
||||
$('#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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$('.edit-button').click(function(){
|
||||
let data = JSON.parse( $(this).attr('data') )
|
||||
for(let k of Object.keys(data)) {
|
||||
$('#field-' + k).val( data[k] )
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,362 @@
|
|||
<!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
|
||||
|
||||
@php
|
||||
$start = strtotime("1 May 2021");
|
||||
$till = strtotime("now");
|
||||
if( request()->get('record_date') ) {
|
||||
$target = strtotime(request()->get('record_date'));
|
||||
} else {
|
||||
$target = strtotime("now");
|
||||
}
|
||||
$history = Formhelper::getMultiformData($form->partition, '1654684982-2df9cca9-b3e3-4dab-877a-992e6e2d8b72', $form->user_id, date("m-01-Y", $target) , date("m-t-Y", $target) );
|
||||
//echo '<pre>'; print_r($history); exit;
|
||||
$contacts = [];
|
||||
if(sizeof($history->data->submissions) > 0) {
|
||||
foreach($history->data->submissions as $sub){
|
||||
if(sizeof($sub->contacts) > 0) {
|
||||
$contacts[] = $sub->contacts[0]->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="launched_count" value="0">
|
||||
<input type="hidden" name="converted_count" value="0">
|
||||
@csrf
|
||||
<!-- <input type="hidden" name="id" id="field-id" value="{{$id?$id:''}}"> -->
|
||||
@foreach($questions as $question)
|
||||
@if ( in_array($question->code, ['chemist_name', 'dapasach_pob', 'dapasach_strips', 'dapasach_m_strips', 'total_pob', 'dapasach_units_made_available', 'dapasach_m_units_made_available', 'no_of_chemists_made_available'] ) )
|
||||
@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)
|
||||
@if($question->code != 'doctor_name' || in_array($option->value, $contacts))
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$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
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-no_of_dapasach_rx" class="form-label">No. of Dapasach Rx <span class="text-danger">*</span> </label>
|
||||
<input type="number" min="0" max="9999999999" step="1" id="field-no_of_dapasach_rx" name="no_of_dapasach_rx" class="form-control" required value="0">
|
||||
</div>
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-no_of_dapasach_m_rx" class="form-label">No. of Dapasach M Rx <span class="text-danger">*</span> </label>
|
||||
<input type="number" min="0" max="9999999999" step="1" id="field-no_of_dapasach_m_rx" name="no_of_dapasach_m_rx" class="form-control" required value="0">
|
||||
</div>
|
||||
|
||||
<div id="chemist-section" class="border-info border p-2 mb-3">
|
||||
<!-- <div class="chemist-wrapper col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-10 mb-2">
|
||||
<label class="form-label">Chemist Name <span class="text-danger">*</span> </label>
|
||||
<input type="text" name="chemist_name[]" class="form-control" required value="">
|
||||
</div>
|
||||
<div class="col-2 mb-2">
|
||||
<button class="btn btn-danger mt-3 remove_btn" type="button"> X </button>
|
||||
</div>
|
||||
<div class="col-12 mb-2">
|
||||
<label class="form-label">POB <span class="text-danger">*</span> </label>
|
||||
<input type="number" name="dapasach_pob[]" class="form-control" required value="0">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Dapasach (strips) <span class="text-danger">*</span> </label>
|
||||
<input type="number" name="dapasach_strips[]" class="form-control" required value="0">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Dapasach M (strips) <span class="text-danger">*</span> </label>
|
||||
<input type="number" name="dapasach_m_strips[]" class="form-control" required value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-total_pob" class="form-label">Total POB<span class="text-danger">*</span> </label>
|
||||
<input type="number" min="0" max="9999999999" step="1" id="field-total_pob" name="total_pob" class="form-control" value="0" readonly>
|
||||
</div>
|
||||
<input type="hidden" id="field-dapasach_units_made_available" name="dapasach_units_made_available" value="0">
|
||||
<input type="hidden" id="field-dapasach_m_units_made_available" name="dapasach_m_units_made_available" value="0">
|
||||
<input type="hidden" id="field-no_of_chemists_made_available" name="no_of_chemists_made_available" value="0">
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="col-md-12 mb-2">
|
||||
<div class="row">
|
||||
<div class="col-6 mb-2 text-center d-grid">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
<div class="col-6 mb-2 text-center d-grid">
|
||||
<button class="btn btn-info" type="button" id="add-chemist-btn"> Add Chemist </button>
|
||||
</div>
|
||||
</div>
|
||||
</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($){
|
||||
$('#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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@php
|
||||
$history = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$histories = [];
|
||||
$date = '';
|
||||
foreach($history->data->submissions as $sub) {
|
||||
$sub->formdata->id = $sub->id;
|
||||
$histories[] = $sub->formdata;
|
||||
}
|
||||
@endphp
|
||||
var histories = JSON.parse('{!!json_encode($histories)!!}')
|
||||
$('#field-doctor_name').change(function(){
|
||||
let history = histories.find(h => h.doctor_name == $('#field-doctor_name option:selected').text())
|
||||
if(history) {
|
||||
$('#report-form').append('<input type="hidden" name="id" id="field-id" value="'+history['id']+'">');
|
||||
for(let k of Object.keys(history)) {
|
||||
if(!(['doctor_name','no_of_dapasach_rx','no_of_dapasach_m_rx', 'total_pob', 'dapasach_units_made_available', 'dapasach_m_units_made_available', 'no_of_chemists_made_available'].includes(k) ))
|
||||
$('#field-' + k).val( history[k] )
|
||||
}
|
||||
// $('#chemist-section').html('')
|
||||
// for(let i in history.chemist_name ) {
|
||||
// $('#chemist-section').append(`<div class="chemist-wrapper col-md-12 mt-1"><hr />
|
||||
// <div class="row">
|
||||
// <div class="col-10 mb-2">
|
||||
// <label class="form-label">Chemist Name <span class="text-danger">*</span> </label>
|
||||
// <input type="text" name="chemist_name[]" class="form-control" required value="${history.chemist_name[i]}">
|
||||
// </div>
|
||||
// <div class="col-2 mb-2">
|
||||
// <button class="btn btn-danger mt-3 remove_btn" type="button"> X </button>
|
||||
// </div>
|
||||
// <div class="col-12 mb-2">
|
||||
// <label class="form-label">POB <span class="text-danger">*</span> </label>
|
||||
// <input type="number" name="dapasach_pob[]" class="form-control" required value="${history.dapasach_pob[i]}">
|
||||
// </div>
|
||||
// <div class="col-6">
|
||||
// <label class="form-label">Dapasach (strips) <span class="text-danger">*</span> </label>
|
||||
// <input type="number" name="dapasach_strips[]" class="form-control" required value="${history.dapasach_strips[i]}">
|
||||
// </div>
|
||||
// <div class="col-6">
|
||||
// <label class="form-label">Dapasach M (strips) <span class="text-danger">*</span> </label>
|
||||
// <input type="number" name="dapasach_m_strips[]" class="form-control" required value="${history.dapasach_m_strips[i]}">
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>`)
|
||||
// }
|
||||
// initiatechemistsection()
|
||||
} else {
|
||||
$("#field-id").remove();
|
||||
$('#field-launched').val('');
|
||||
$('#field-record_date').val('');
|
||||
$('#field-converted').val('');
|
||||
$('input[name="launched_count"]').val(0)
|
||||
$('input[name="converted_count"]').val(0)
|
||||
}
|
||||
if($('#field-launched').val() == 'Yes') {
|
||||
$('input[name="launched_count"]').val(1)
|
||||
} else {
|
||||
$('input[name="launched_count"]').val(0)
|
||||
}
|
||||
|
||||
if($('#field-converted').val() == 'Yes') {
|
||||
$('input[name="converted_count"]').val(1)
|
||||
} else {
|
||||
$('input[name="converted_count"]').val(0)
|
||||
}
|
||||
})
|
||||
|
||||
$('#field-launched').change(function(){
|
||||
if($(this).val() == 'Yes') {
|
||||
$('input[name="launched_count"]').val(1)
|
||||
} else {
|
||||
$('input[name="launched_count"]').val(0)
|
||||
}
|
||||
})
|
||||
$('#field-converted').change(function(){
|
||||
if($(this).val() == 'Yes') {
|
||||
$('input[name="converted_count"]').val(1)
|
||||
} else {
|
||||
$('input[name="converted_count"]').val(0)
|
||||
}
|
||||
})
|
||||
|
||||
$('#add-chemist-btn').click(function(){
|
||||
$('#chemist-section').append(`<div class="chemist-wrapper col-md-12 mt-1"><hr />
|
||||
<div class="row">
|
||||
<div class="col-10 mb-2">
|
||||
<label class="form-label">Chemist Name <span class="text-danger">*</span> </label>
|
||||
<input type="text" name="chemist_name[]" class="form-control" required value="">
|
||||
</div>
|
||||
<div class="col-2 mb-2">
|
||||
<button class="btn btn-danger mt-3 remove_btn" type="button"> X </button>
|
||||
</div>
|
||||
<div class="col-12 mb-2">
|
||||
<label class="form-label">POB <span class="text-danger">*</span> </label>
|
||||
<input type="number" name="dapasach_pob[]" class="form-control" required value="0">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Dapasach (strips) <span class="text-danger">*</span> </label>
|
||||
<input type="number" name="dapasach_strips[]" class="form-control" required value="0">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Dapasach M (strips) <span class="text-danger">*</span> </label>
|
||||
<input type="number" name="dapasach_m_strips[]" class="form-control" required value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>`)
|
||||
initiatechemistsection()
|
||||
})
|
||||
|
||||
function initiatechemistsection() {
|
||||
$('#chemist-section input[type=number]').unbind()
|
||||
$('#chemist-section input[type=number]').change(function(){
|
||||
$('#field-total_pob').val(0)
|
||||
$('#field-dapasach_units_made_available').val(0)
|
||||
$('#field-dapasach_m_units_made_available').val(0)
|
||||
$('#chemist-section input[type=number]').each(function(){
|
||||
console.log($(this).attr('name'))
|
||||
console.log($(this).val())
|
||||
if($(this).attr('name') == 'dapasach_pob[]') {
|
||||
$('#field-total_pob').val( parseInt($('#field-total_pob').val()) + parseInt($(this).val()) )
|
||||
} else if($(this).attr('name') == 'dapasach_strips[]') {
|
||||
$('#field-dapasach_units_made_available').val( parseInt($('#field-dapasach_units_made_available').val()) + parseInt($(this).val()) )
|
||||
} else if($(this).attr('name') == 'dapasach_m_strips[]') {
|
||||
$('#field-dapasach_m_units_made_available').val( parseInt($('#field-dapasach_m_units_made_available').val()) + parseInt($(this).val()) )
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.remove_btn').unbind()
|
||||
$('.remove_btn').click(function(){
|
||||
$(this).parent().parent().parent().remove()
|
||||
})
|
||||
$('#field-no_of_chemists_made_available').val($('.chemist-wrapper').length)
|
||||
}
|
||||
initiatechemistsection()
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
<!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
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@endif
|
||||
@foreach($questions as $question)
|
||||
<div class="col-md-12 mb-2" id="wrapper-{{$question->code}}">
|
||||
<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':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
<div id="field-{{$question->code}}"></div>
|
||||
@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
|
||||
@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($){
|
||||
var skus = [];
|
||||
$('#wrapper-sku input').each(function() {
|
||||
skus.push($(this).val());
|
||||
//$(this).parent().remove()
|
||||
});
|
||||
console.log(skus)
|
||||
$('#report-form input').parent().find('.col-md-12').hide()
|
||||
$('#field-customer_type').parent().show()
|
||||
|
||||
$('#field-customer_type').change(function(){
|
||||
$('#report-form input').parent().find('.col-md-12').hide()
|
||||
$('#field-customer_type').parent().show()
|
||||
if($(this).val() == 'Doctor') {
|
||||
$('#field-doctor_name').parent().show()
|
||||
$('#field-sku').parent().show()
|
||||
//$('#field-dr_recommendation_mtd').parent().show()
|
||||
$('#field-brand_selected').parent().show()
|
||||
$('#field-msl_code').parent().show()
|
||||
$('#field-doctor_name').prop('required',true)
|
||||
} else {
|
||||
$('#field-retailer_name').parent().show()
|
||||
$('#field-sku').parent().show()
|
||||
//$('#field-availability_commitment_mtd').parent().show()
|
||||
$('#field-brand_selected').parent().show()
|
||||
$('#field-pob_dapasach_franchise').parent().show()
|
||||
$('#field-pob_metolar_trio').parent().show()
|
||||
$('#field-pob_metolar_3d').parent().show()
|
||||
|
||||
$('#field-pob_dapasach').parent().show()
|
||||
$('#field-pob_dapasach_s').parent().show()
|
||||
$('#field-pob_dapasach_m').parent().show()
|
||||
$('#field-doctor_name').removeAttr('required')
|
||||
}
|
||||
$('#field-record_date').parent().show()
|
||||
$('#report-form input').removeAttr('required')
|
||||
$('#report-form input:visible').prop('required',true)
|
||||
$('#report-form input:checkbox').removeAttr('required')
|
||||
})
|
||||
|
||||
$('#field-brand_selected').change(function(){
|
||||
var newskus = []
|
||||
$('#wrapper-sku input').each(function() {
|
||||
$(this).parent().remove()
|
||||
});
|
||||
|
||||
|
||||
if($(this).val() == 'DAPASACH FRANCHISE') {
|
||||
newskus = skus.filter(s => s.includes('DapaSach') )
|
||||
if($('#field-customer_type').val() == 'Retailer' ) {
|
||||
$('#field-pob_dapasach').parent().show()
|
||||
$('#field-pob_dapasach_s').parent().show()
|
||||
$('#field-pob_dapasach_m').parent().show()
|
||||
$('#field-pob_metolar_trio').parent().hide()
|
||||
$('#field-pob_metolar_3d').parent().hide()
|
||||
}
|
||||
} else {
|
||||
newskus = skus.filter(s => s.includes('Metolar') )
|
||||
if($('#field-customer_type').val() == 'Retailer' ) {
|
||||
$('#field-pob_dapasach').parent().hide()
|
||||
$('#field-pob_dapasach_s').parent().hide()
|
||||
$('#field-pob_dapasach_m').parent().hide()
|
||||
$('#field-pob_metolar_trio').parent().show()
|
||||
$('#field-pob_metolar_3d').parent().show()
|
||||
}
|
||||
}
|
||||
$('#report-form input').removeAttr('required')
|
||||
$('#report-form input:visible').prop('required',true)
|
||||
for(let newsku of newskus) {
|
||||
$('#wrapper-sku').append(`<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-sku-${newsku}" name="sku[]" value="${newsku}" checked>
|
||||
<label class="form-check-label" for="field-sku-${newsku}">${newsku}</label>
|
||||
</div>`)
|
||||
}
|
||||
})
|
||||
|
||||
$('#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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
<!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
|
||||
<form method="POST" action="/form/submit" id="report-form">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@endif
|
||||
@foreach($questions as $question)
|
||||
<div class="col-md-12 mb-2" id="wrapper-{{$question->code}}">
|
||||
<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':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
<div id="field-{{$question->code}}"></div>
|
||||
@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
|
||||
@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($){
|
||||
var skus = [];
|
||||
$('#wrapper-sku input').each(function() {
|
||||
skus.push($(this).val());
|
||||
//$(this).parent().remove()
|
||||
});
|
||||
console.log(skus)
|
||||
$('#report-form input').parent().find('.col-md-12').hide()
|
||||
$('#field-customer_type').parent().show()
|
||||
|
||||
$('#field-customer_type').change(function(){
|
||||
$('#report-form input').parent().find('.col-md-12').hide()
|
||||
$('#field-customer_type').parent().show()
|
||||
if($(this).val() == 'Doctor') {
|
||||
$('#field-doctor_name').parent().show()
|
||||
$('#field-sku').parent().show()
|
||||
//$('#field-dr_recommendation_mtd').parent().show()
|
||||
$('#field-brand_selected').parent().show()
|
||||
$('#field-msl_code').parent().show()
|
||||
$('#field-doctor_name').prop('required',true)
|
||||
} else {
|
||||
$('#field-retailer_name').parent().show()
|
||||
$('#field-sku').parent().show()
|
||||
//$('#field-availability_commitment_mtd').parent().show()
|
||||
$('#field-brand_selected').parent().show()
|
||||
$('#field-pob_dapasach_franchise').parent().show()
|
||||
$('#field-pob_metolar_trio').parent().show()
|
||||
$('#field-pob_metolar_3d').parent().show()
|
||||
|
||||
$('#field-pob_dapasach').parent().show()
|
||||
$('#field-pob_dapasach_s').parent().show()
|
||||
$('#field-pob_dapasach_m').parent().show()
|
||||
$('#field-doctor_name').removeAttr('required')
|
||||
}
|
||||
$('#field-record_date').parent().show()
|
||||
$('#report-form input').removeAttr('required')
|
||||
$('#report-form input:visible').prop('required',true)
|
||||
$('#report-form input:checkbox').removeAttr('required')
|
||||
})
|
||||
|
||||
$('#field-brand_selected').change(function(){
|
||||
var newskus = []
|
||||
$('#wrapper-sku input').each(function() {
|
||||
$(this).parent().remove()
|
||||
});
|
||||
|
||||
|
||||
if($(this).val() == 'DAPASACH FRANCHISE') {
|
||||
newskus = skus.filter(s => s.includes('DapaSach') )
|
||||
if($('#field-customer_type').val() == 'Retailer' ) {
|
||||
$('#field-pob_dapasach').parent().show()
|
||||
$('#field-pob_dapasach_s').parent().show()
|
||||
$('#field-pob_dapasach_m').parent().show()
|
||||
$('#field-pob_metolar_trio').parent().hide()
|
||||
$('#field-pob_metolar_3d').parent().hide()
|
||||
}
|
||||
} else {
|
||||
newskus = skus.filter(s => s.includes('Metolar') )
|
||||
if($('#field-customer_type').val() == 'Retailer' ) {
|
||||
$('#field-pob_dapasach').parent().hide()
|
||||
$('#field-pob_dapasach_s').parent().hide()
|
||||
$('#field-pob_dapasach_m').parent().hide()
|
||||
$('#field-pob_metolar_trio').parent().show()
|
||||
$('#field-pob_metolar_3d').parent().show()
|
||||
}
|
||||
}
|
||||
$('#report-form input').removeAttr('required')
|
||||
$('#report-form input:visible').prop('required',true)
|
||||
for(let newsku of newskus) {
|
||||
$('#wrapper-sku').append(`<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-sku-${newsku}" name="sku[]" value="${newsku}" checked>
|
||||
<label class="form-check-label" for="field-sku-${newsku}">${newsku}</label>
|
||||
</div>`)
|
||||
}
|
||||
})
|
||||
|
||||
$('#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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue