375 lines
24 KiB
PHP
375 lines
24 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => "Form"])
|
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
|
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
|
</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 class="col-md-12 mb-2">
|
|
<label for="field-no_of_dapasach_s_rx" class="form-label">No. of Dapasach S Rx <span class="text-danger">*</span> </label>
|
|
<input type="number" min="0" max="9999999999" step="1" id="field-no_of_dapasach_s_rx" name="no_of_dapasach_s_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','no_of_dapasach_s_rx', 'total_pob', 'dapasach_units_made_available', 'dapasach_m_units_made_available', 'dapasach_s_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-6 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 class="col-6">
|
|
<label class="form-label">Dapasach S Rx (strips) <span class="text-danger">*</span> </label>
|
|
<input type="number" name="dapasach_s_rx_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)
|
|
$('#field-dapasach_s_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()) )
|
|
} else if($(this).attr('name') == 'dapasach_s_strips[]') {
|
|
$('#field-dapasach_s_units_made_available').val( parseInt($('#field-dapasach_s_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> |