223 lines
10 KiB
PHP
223 lines
10 KiB
PHP
@php
|
|
$isEdit = !empty($id);
|
|
$qMap = [];
|
|
foreach ($questions as $question) {
|
|
$qMap[$question->code] = $question;
|
|
}
|
|
$val = function ($code) use ($qMap) {
|
|
return isset($qMap[$code]) && isset($qMap[$code]->value) ? $qMap[$code]->value : '';
|
|
};
|
|
$isBlank = function ($value) {
|
|
if ($value === null) {
|
|
return true;
|
|
}
|
|
if (is_array($value) || is_object($value)) {
|
|
return count((array) $value) === 0;
|
|
}
|
|
return trim((string) $value) === '';
|
|
};
|
|
@endphp
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => $form->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="{{ $isEdit ? 'col-md-8 col-lg-6 col-xl-5' : 'col-12' }} 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="{{ $isEdit ? 'col-8' : 'col-12' }}">
|
|
<h4 class="page-title">{{$form->title}}</h4>
|
|
</div>
|
|
@if($isEdit)
|
|
<div class="col-4">
|
|
<a href="/form/show" class="float-end pt-1">Back</a>
|
|
</div>
|
|
@endif
|
|
|
|
@if(!$isEdit)
|
|
<div class="col-12">
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-bordered align-middle mb-0" id="validation-list">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Edit</th>
|
|
<th>Doctor Name</th>
|
|
<th>MSL Code</th>
|
|
<th>Mobile</th>
|
|
<th>Email</th>
|
|
<th>Contact Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse(($submissions ?? []) as $submission)
|
|
@php
|
|
$fd = $submission->formdata ?? (object)[];
|
|
$mobile = $fd->mobile_no ?? '';
|
|
$email = $fd->email_id ?? '';
|
|
$missing = $isBlank($mobile) || $isBlank($email);
|
|
@endphp
|
|
<tr class="{{ $missing ? 'table-danger' : '' }}">
|
|
<td>
|
|
<a href="/form/show?form_id={{ $form_id }}&id={{ $submission->id }}" class="btn btn-primary btn-xs">Edit</a>
|
|
</td>
|
|
<td>{{ $fd->contact_id ?? '' }}</td>
|
|
<td>{{ $fd->msl_code ?? '' }}</td>
|
|
<td>{{ $mobile }}</td>
|
|
<td>{{ $email }}</td>
|
|
<td>{{ $fd->contact_status ?? '' }}</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="6" class="text-center text-muted">No submissions found.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@else
|
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
|
<input type="hidden" name="form_id" value="{{$form_id}}">
|
|
@csrf
|
|
<input type="hidden" name="id" value="{{$id}}">
|
|
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-contact_id" class="form-label">Doctor Name</label>
|
|
<input type="text" id="field-contact_id" name="contact_id" class="form-control" value="{{ $val('contact_id') }}" readonly>
|
|
</div>
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-msl_code" class="form-label">MSL Code</label>
|
|
<input type="text" id="field-msl_code" name="msl_code" class="form-control" value="{{ $val('msl_code') }}" readonly>
|
|
</div>
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-mobile_no" class="form-label">Mobile <span class="text-danger">*</span></label>
|
|
<input
|
|
type="tel"
|
|
id="field-mobile_no"
|
|
name="mobile_no"
|
|
class="form-control"
|
|
inputmode="numeric"
|
|
pattern="[6-9][0-9]{9}"
|
|
minlength="10"
|
|
maxlength="10"
|
|
title="Enter a valid 10-digit mobile number starting with 6, 7, 8, or 9."
|
|
required
|
|
value="{{ $val('mobile_no') }}"
|
|
>
|
|
</div>
|
|
<div class="col-md-12 mb-2">
|
|
<label for="field-email_id" class="form-label">Email <span class="text-danger">*</span></label>
|
|
<input
|
|
type="email"
|
|
id="field-email_id"
|
|
name="email_id"
|
|
class="form-control"
|
|
maxlength="254"
|
|
pattern="^[a-zA-Z0-9_+%-]+(\.[a-zA-Z0-9_+%-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$"
|
|
title="Enter a valid email address, e.g. name@example.com"
|
|
required
|
|
value="{{ $val('email_id') }}"
|
|
>
|
|
</div>
|
|
|
|
<div class="text-center d-grid mt-3">
|
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Update </button>
|
|
</div>
|
|
</form>
|
|
@endif
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<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%;
|
|
}
|
|
.form-label {
|
|
font-weight:bold;
|
|
font-size:16px;
|
|
}
|
|
#validation-list td, #validation-list th {
|
|
white-space: nowrap;
|
|
}
|
|
</style>
|
|
@include('layouts.shared/footer-script')
|
|
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
@if($isEdit)
|
|
$('#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 updated!',
|
|
icon: 'success'
|
|
}).then(function(){
|
|
window.location.href = '/form/show';
|
|
});
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: data.hasOwnProperty('message') ? 'Update failed' : 'Data not submitted',
|
|
text: data.hasOwnProperty('message') ? data.message : 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
error: function() {
|
|
$("#pageloader").fadeOut();
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
});
|
|
}
|
|
});
|
|
});
|
|
@endif
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|