241 lines
12 KiB
PHP
241 lines
12 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" />
|
|
<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-6">
|
|
<h4 class="page-title">{{$form->title}}</h4>
|
|
</div>
|
|
<div class="col-6">
|
|
<button class="btn btn-success float-end btn-xs" id="add-doctor">Add Doctor</button>
|
|
</div>
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'
|
|
) )
|
|
|
|
@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;
|
|
$distributed = [];
|
|
$sub_ids = [];
|
|
$no_of_coupons =[];
|
|
foreach($submissions as $sub) {
|
|
$sub_ids[$sub->formdata->msl_code] = $sub->id;
|
|
if($sub->formdata->distributed_the_coupons == 'Yes') {
|
|
$distributed[] = $sub->formdata->msl_code;
|
|
$no_of_coupons[$sub->formdata->msl_code] = isset($sub->formdata->no_of_coupons) ? $sub->formdata->no_of_coupons : 0;
|
|
}
|
|
}
|
|
@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
|
|
|
|
@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
|
|
|
|
<div class="col-md-12 mb-2">
|
|
<div class="table-responsive sticky-table">
|
|
<table id="doctor_table" class="table table-borderless table-hover table-nowrap table-centered m-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Doctor Name</th>
|
|
<!-- <th>MSL Code</th> -->
|
|
<th>Distributed<br /> the coupons</th>
|
|
<th>Coupons<br />Utilised</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($submissions as $sub)
|
|
<tr>
|
|
<input type="hidden" name="id[]" value="{{$sub->id}}">
|
|
<input type="hidden" name="msl_code[]" value="{{$sub->formdata->msl_code}}" /></th>
|
|
<th>{{$sub->contacts[0]->name}}<input type="hidden" name="contact_id[]" value="{{$sub->contacts[0]->id}}" />
|
|
<th><select name="distributed_the_coupons[]" class="form-control distributed_the_coupons">
|
|
<option value="No"> No </option>
|
|
<option value="Yes" {{ $sub->formdata->distributed_the_coupons == 'Yes' ? 'selected' : ''}}> Yes </option>
|
|
</select><input type="hidden" name="distributed_coupon_count[]" class="distributed_coupon_count" value="{{isset($sub->formdata->distributed_coupon_count)?$sub->formdata->distributed_coupon_count:''}}" /></th>
|
|
<th><select name="no_of_coupons[]" class="form-control">
|
|
@for($i = 0; $i <= 20; $i++)
|
|
<option value="{{$i}}" {{ isset($sub->formdata->no_of_coupons) && $sub->formdata->no_of_coupons == $i ? 'selected' : ''}}> {{$i}} </option>
|
|
@endfor
|
|
</select></th>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
|
|
'yes' ) )
|
|
|
|
<div class="text-center d-grid mt-3">
|
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
|
</div>
|
|
@endif
|
|
</form>
|
|
|
|
</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%;
|
|
}
|
|
small {
|
|
font-size:10px;
|
|
}
|
|
div.sticky-table {
|
|
position: relative;
|
|
height: 100%;
|
|
max-height: 500px;
|
|
}
|
|
div.sticky-table table thead {
|
|
position: sticky;
|
|
top: 0;
|
|
}
|
|
</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($) {
|
|
$('#field-distributed_the_coupons').attr({
|
|
type:"hidden"
|
|
})
|
|
|
|
$('.distributed_the_coupons').change(function(){
|
|
if($(this).val() == 'Yes') {
|
|
$(this).parent().find('.distributed_coupon_count').first().val("1")
|
|
} else {
|
|
$(this).parent().find('.distributed_coupon_count').first().val("0")
|
|
}
|
|
})
|
|
|
|
let count = 0
|
|
$("#add-doctor").click(function(){
|
|
$('#doctor_table tbody').append(`<tr>
|
|
<th><input type="text" class="form-control" name="doctor_name[${count}]" value="" placeholder="Doctor Name"/>
|
|
<input type="text" class="form-control" name="doctor_msl[${count}]" value="" placeholder="MSL Code" /></th>
|
|
<th><select name="doctor_distributed[${count}]" class="form-control"><option value="No"> No </option><option value="Yes"> Yes </option></select></th>
|
|
<th><button class="btn btn-danger btn-xs remove-doctor" type="button"><i class="mdi mdi-close"></i></button></th>
|
|
</tr>`)
|
|
$('.remove-doctor').unbind()
|
|
$('.remove-doctor').click(function(){
|
|
$(this).parent().parent()[0].remove()
|
|
})
|
|
count++;
|
|
});
|
|
|
|
$('#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) {
|
|
console.log('data = ',data)
|
|
$("#pageloader").fadeOut();
|
|
if (data.status == 'success') {
|
|
Swal.fire({
|
|
title: 'Great!',
|
|
text: 'Your data is successfully submitted!',
|
|
icon: 'success'
|
|
})
|
|
// $('#report-form').trigger("reset");
|
|
// $('#doctor_table tbody').html('')
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |