Merge branch 'main' of http://192.168.1.200:3000/Stratawiz/Rapport-Laravel
Specific Folder FTP Upload / ftp-deploy (push) Successful in 46s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 46s
Details
This commit is contained in:
commit
3251732fac
|
|
@ -9,7 +9,7 @@
|
|||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
||||
<!-- start page title -->`
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
|
|
@ -44,7 +44,13 @@
|
|||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
@if($question->type == 'multitextbox')
|
||||
@foreach($question->options as $k => $v)
|
||||
<th data-priority="1">{{ is_object($v) ? ($v->display ?? $v->label ?? $k) : $v }} ({{$question->label}})</th>
|
||||
@endforeach
|
||||
@else
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
<th data-priority="1">Action</th>
|
||||
</tr>
|
||||
|
|
@ -64,11 +70,30 @@
|
|||
<td>
|
||||
{{ collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') }}
|
||||
</td>
|
||||
|
||||
@elseif($question->type == 'multitextbox')
|
||||
@foreach($question->options as $k => $v)
|
||||
@php
|
||||
$optKey = is_object($v) ? ($v->value ?? $k) : $k;
|
||||
$optVal = '';
|
||||
if (isset($submission->formdata->{$optKey})) {
|
||||
$raw = $submission->formdata->{$optKey};
|
||||
$optVal = is_array($raw) ? implode(', ', $raw) : (is_object($raw) ? json_encode($raw) : $raw);
|
||||
} elseif (isset($submission->formdata->{$code}) && (is_object($submission->formdata->{$code}) || is_array($submission->formdata->{$code}))) {
|
||||
$box = (array) $submission->formdata->{$code};
|
||||
if (array_key_exists($optKey, $box)) {
|
||||
$raw = $box[$optKey];
|
||||
$optVal = is_array($raw) ? implode(', ', $raw) : (is_object($raw) ? json_encode($raw) : $raw);
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
<td>{{ $optVal }}</td>
|
||||
@endforeach
|
||||
|
||||
@elseif(count((array)$question->options) > 0 && 1==2 )
|
||||
<td>{{ $question->options->{ $submission->formdata->{$code} } }}</td>
|
||||
@else
|
||||
<td>{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :$submission->formdata->{$code} : $code }}</td>
|
||||
<td>{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) : (is_object($submission->formdata->{$code}) ? collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') : $submission->formdata->{$code}) : '' }}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<th>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,480 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "History"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
<link href="{{ URL::asset('assets/libs/datatables/datatables.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
<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">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
</div>
|
||||
<div class="col-4 p-2">
|
||||
<a href="/form/downloaddata?form_id={{$form_id}}" id="download-btn" class="btn btn-info btn-xs float-end">Download</a>
|
||||
<button type="button" id="emailme" class="btn btn-warning btn-xs float-end me-2">Email</button>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<p>Showing data for last 30 days, please use above button "Download" to download all submissions</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
@if(session()->has('message'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('message') }}
|
||||
</div>
|
||||
@endif
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div id="notifications"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 p-0">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form class="row row-cols-lg-auto g-2 align-items-center mb-3" id="date-range-form" onsubmit="return false;">
|
||||
<div class="col-4">
|
||||
<label for="startdate" class="form-label mb-0 me-2">Start Date:</label>
|
||||
<input type="date" class="form-control form-control-sm d-inline-block w-auto" id="startdate" name="startdate" value="{{ request()->input('startdate') }}">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<label for="enddate" class="form-label mb-0 me-2">End Date:</label>
|
||||
<input type="date" class="form-control form-control-sm d-inline-block w-auto" id="enddate" name="enddate" value="{{ request()->input('enddate') }}">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button type="button" class="btn btn-primary btn-sm" id="apply-date-range">Apply</button>
|
||||
</div>
|
||||
<input type="hidden" name="form_id" id="form_id" value="{{ $form_id }}">
|
||||
</form>
|
||||
|
||||
<div class="responsive-table-plugin">
|
||||
<div class="table-rep-plugin">
|
||||
<div class="table-responsive" data-pattern="priority-columns">
|
||||
<table id="basic-datatable" class="table dt-responsive nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="1">Action</th>
|
||||
<th data-priority="1">Submission Date</th>
|
||||
<th data-priority="1">Submitted By</th>
|
||||
<th data-priority="1">Employee Code</th>
|
||||
<th data-priority="1">Approval Status</th>
|
||||
<th data-priority="1">Generated Image</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue
|
||||
@endif
|
||||
@if($question->type == 'multitextbox')
|
||||
@foreach( $question->options as $k => $v )
|
||||
<th data-priority="1">{{$v}} ({{$question->label}})</th>
|
||||
@endforeach
|
||||
@else
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if($lastkey)
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-info" type="button" id="load-btn"> Load More ... </button>
|
||||
</div>
|
||||
@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%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{ URL::asset('assets/libs/datatables/datatables.min.js')}}"></script>
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$.fn.dataTable.ext.errMode = 'none';
|
||||
|
||||
const loggedInUser = @json($formdata->user_id ?? "");
|
||||
const allAccess = @json(isset($formdata->all_data_access) ? $formdata->all_data_access : 0);
|
||||
const formId = @json($form_id);
|
||||
const partition = @json($formdata->partition ?? '');
|
||||
|
||||
function buildGeneratedImageDownloadHtml(row, iconOnly) {
|
||||
const status = String(row.workflow_status || '').toLowerCase().trim();
|
||||
if (status !== 'approved' || !row.submission_id) {
|
||||
return '-';
|
||||
}
|
||||
let url = '/form/downloadpersonalization?id=' + encodeURIComponent(row.submission_id)
|
||||
+ '&form_id=' + encodeURIComponent(formId);
|
||||
if (partition) {
|
||||
url += '&partition=' + encodeURIComponent(partition);
|
||||
}
|
||||
if (iconOnly) {
|
||||
return '<a title="Download" class="btn btn-primary btn-xs" href="' + url + '" target="_blank"><i class="mdi mdi-cloud-download"></i></a>';
|
||||
}
|
||||
return '<a class="btn btn-primary btn-xs" href="' + url + '" target="_blank"><i class="mdi mdi-cloud-download me-1"></i>Download</a>';
|
||||
}
|
||||
|
||||
let table = $('#basic-datatable').DataTable({
|
||||
"responsive": false,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"previous": "<i class='mdi mdi-chevron-left'>",
|
||||
"next": "<i class='mdi mdi-chevron-right'>"
|
||||
}
|
||||
},
|
||||
fixedHeader: true,
|
||||
"paging": false,
|
||||
"pageLength": -1,
|
||||
"lengthMenu": [[-1], ["All"]],
|
||||
'processing': false,
|
||||
'serverSide': false,
|
||||
"order": [[1, "desc"]],
|
||||
'searching': true,
|
||||
'info': true,
|
||||
data: [],
|
||||
columns: [
|
||||
{ data: null,
|
||||
render: function ( data, type, row ) {
|
||||
let buttons = '';
|
||||
if (row.actions && Array.isArray(row.actions)) {
|
||||
if (row.actions.includes('edit')) {
|
||||
buttons += ` <button title="Edit" class="btn btn-warning btn-xs waves-effect waves-light btn-edit" submission="${row.submission_id}"><i class="mdi mdi-pencil-outline"></i></button>`;
|
||||
}
|
||||
if (row.actions.includes('delete') {{ isset($formdata->all_data_access) && $formdata->all_data_access ? ' || true' : '' }} ) {
|
||||
buttons += ` <button title="Delete" class="btn btn-danger btn-xs waves-effect waves-light btn-delete" submission="${row.submission_id}"><i class="mdi mdi-delete-outline"></i></button>`;
|
||||
}
|
||||
|
||||
if (row.actions.includes('approve') || row.actions.includes('reject')) {
|
||||
const nextApprover = row.workflow_next_approver ?? "";
|
||||
|
||||
if (allAccess == 1) {
|
||||
if (row.actions.includes('approve')) {
|
||||
buttons += `<button title="Approve" class="btn btn-success btn-xs waves-effect waves-light btn-approve" submission="${row.submission_id}"><i class="mdi mdi-check-outline"></i></button>`;
|
||||
}
|
||||
if (row.actions.includes('reject')) {
|
||||
buttons += `<button title="Reject" class="btn btn-danger btn-xs waves-effect waves-light btn-reject" submission="${row.submission_id}"><i class="mdi mdi-close-outline"></i></button>`;
|
||||
}
|
||||
} else if (loggedInUser === nextApprover) {
|
||||
if (row.actions.includes('approve')) {
|
||||
buttons += `<button title="Approve" class="btn btn-success btn-xs waves-effect waves-light btn-approve" submission="${row.submission_id}"><i class="mdi mdi-check-outline"></i></button>`;
|
||||
}
|
||||
if (row.actions.includes('reject')) {
|
||||
buttons += `<button title="Reject" class="btn btn-danger btn-xs waves-effect waves-light btn-reject" submission="${row.submission_id}"><i class="mdi mdi-close-outline"></i></button>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also surface download in Action for approved rows (works for load-more rows)
|
||||
const downloadHtml = buildGeneratedImageDownloadHtml(row, true);
|
||||
if (downloadHtml && downloadHtml !== '-') {
|
||||
buttons += ' ' + downloadHtml;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
},
|
||||
{ "data": "date" },
|
||||
{ "data": "name" },
|
||||
{ "data": "employee_code" },
|
||||
{ "data": "workflow_status" },
|
||||
{
|
||||
"data": null,
|
||||
"orderable": false,
|
||||
"searchable": false,
|
||||
"defaultContent": "-",
|
||||
render: function(data, type, row) {
|
||||
return buildGeneratedImageDownloadHtml(row);
|
||||
}
|
||||
},
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue
|
||||
@endif
|
||||
@if($question->type == 'multitextbox')
|
||||
@foreach($question->options as $k => $v)
|
||||
{ "data": "{{$k}}" },
|
||||
@endforeach
|
||||
@elseif($question->type == 'image')
|
||||
{
|
||||
"data": "{{$code}}",
|
||||
render: function(data, type, row) {
|
||||
data = row.{{$code.'_file'}};
|
||||
if (data && !/^https?:\/\//.test(data)) {
|
||||
data = '{{ env('AWS_URL') }}' + (data.startsWith('/') ? '' : '/') + data;
|
||||
}
|
||||
if (data && data !== '') {
|
||||
return '<button class="btn btn-info btn-xs" onclick="window.open(\'' + data + '\', \'_blank\')">View Image</button>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
@elseif($question->type == 'file')
|
||||
{
|
||||
"data": "{{$code}}",
|
||||
render: function(data, type, row) {
|
||||
data = row.{{$code.'_file'}};
|
||||
if (data && !/^https?:\/\//.test(data)) {
|
||||
data = '{{ env('AWS_URL') }}' + (data.startsWith('/') ? '' : '/') + data;
|
||||
}
|
||||
if (data && data !== '') {
|
||||
return '<a class="btn btn-primary btn-xs" target="_blank" href="' + data + '" download>Download File</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
@else
|
||||
{ "data": "{{$code}}" },
|
||||
@endif
|
||||
@endforeach
|
||||
],
|
||||
"initComplete": function(settings, json) {
|
||||
var api = this.api();
|
||||
var textBox = $('.dataTables_filter label input');
|
||||
textBox.unbind();
|
||||
textBox.bind('keyup input', function(e) {
|
||||
if(e.keyCode == 8 && !textBox.val() || e.keyCode == 46 && !textBox.val()) {
|
||||
// do nothing
|
||||
} else if(e.keyCode == 13 || !textBox.val()) {
|
||||
api.search(this.value).draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let lastkey = '{{$lastkey}}';
|
||||
|
||||
function bindRowActions() {
|
||||
$('.btn-edit').off('click').on('click', function(){
|
||||
window.location.href = '/form/edit?id=' + $(this).attr('submission');
|
||||
});
|
||||
|
||||
$('.btn-delete').off('click').on('click', function(){
|
||||
const btn = $(this);
|
||||
const submissionId = btn.attr('submission');
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "Do you really want to delete this submission?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
url: '/form/delete',
|
||||
type: 'GET',
|
||||
data: {
|
||||
id: submissionId,
|
||||
form_id: formId,
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
$("#pageloader").fadeOut();
|
||||
if (response.success) {
|
||||
Swal.fire('Deleted!', 'Submission has been deleted.', 'success');
|
||||
table.rows(function(idx, data) {
|
||||
return data.submission_id === submissionId;
|
||||
}).remove().draw();
|
||||
} else {
|
||||
Swal.fire('Error!', response.message || 'Could not delete submission.', 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', xhr.responseJSON?.message || 'Could not delete submission.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-approve').off('click').on('click', function(){
|
||||
$("#pageloader").fadeIn();
|
||||
let that = $(this);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/approvereject?action=approve&id=' + that.attr('submission') + '&form_id=' + formId + '&user_id={{ $formdata->user_id ?? '' }}&partition={{ $formdata->partition ?? '' }}',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
that.parent().html('');
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not approve submission.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-reject').off('click').on('click', function(){
|
||||
$("#pageloader").fadeIn();
|
||||
let that = $(this);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/approvereject?action=reject&id=' + that.attr('submission') + '&form_id=' + formId + '&user_id={{ $formdata->user_id ?? '' }}&partition={{ $formdata->partition ?? '' }}',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
that.parent().html('');
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not reject submission.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function loadRows(lastkeyVal, append = true, extraParams = {}) {
|
||||
$("#pageloader").fadeIn();
|
||||
|
||||
let params = {
|
||||
lastkey: lastkeyVal,
|
||||
partition: '{{ $formdata->partition ?? '' }}',
|
||||
form_id: formId,
|
||||
limit: 50
|
||||
};
|
||||
@if(isset($formdata->all_data_access) && $formdata->all_data_access == 1)
|
||||
params['alldata'] = 1;
|
||||
@else
|
||||
params['user_id'] = '{{ $formdata->user_id ?? '' }}';
|
||||
params['team_report'] = 1;
|
||||
@endif
|
||||
|
||||
params = Object.assign(params, extraParams);
|
||||
// Ensure form_id is never dropped by filters / load-more
|
||||
params.form_id = formId;
|
||||
|
||||
$.get('/form/loadmore?' + $.param(params), function(data) {
|
||||
$("#pageloader").fadeOut();
|
||||
if (data && data.rows && data.rows.length > 0) {
|
||||
if (append) {
|
||||
table.rows.add(data.rows).draw(false);
|
||||
} else {
|
||||
table.clear().rows.add(data.rows).draw();
|
||||
}
|
||||
lastkey = data.lastkey;
|
||||
if (data.lastkey === false || data.lastkey === null || data.lastkey === '' || data.lastkey === undefined) {
|
||||
$('#load-btn').hide();
|
||||
} else {
|
||||
$('#load-btn').show();
|
||||
}
|
||||
} else if (!append) {
|
||||
table.clear().draw();
|
||||
$('#load-btn').hide();
|
||||
} else {
|
||||
$('#load-btn').hide();
|
||||
}
|
||||
|
||||
bindRowActions();
|
||||
}).fail(function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not load submissions.', 'error');
|
||||
});
|
||||
}
|
||||
|
||||
let currentFilterParams = {};
|
||||
|
||||
$('#apply-date-range').on('click', function() {
|
||||
currentFilterParams = {
|
||||
form_id: $('#form_id').val(),
|
||||
startdate: $('#startdate').val(),
|
||||
enddate: $('#enddate').val()
|
||||
};
|
||||
lastkey = 1;
|
||||
loadRows(lastkey, false, currentFilterParams);
|
||||
});
|
||||
|
||||
currentFilterParams = {
|
||||
form_id: $('#form_id').val(),
|
||||
startdate: $('#startdate').val(),
|
||||
enddate: $('#enddate').val()
|
||||
};
|
||||
loadRows(1, false, currentFilterParams);
|
||||
|
||||
$('#load-btn').off('click').on('click', function() {
|
||||
if (lastkey) {
|
||||
loadRows(lastkey, true, currentFilterParams);
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-primary').click(function(){
|
||||
$("#pageloader").fadeIn();
|
||||
});
|
||||
|
||||
$('#emailme').click(function(){
|
||||
$("#pageloader").fadeIn();
|
||||
var startdate = $('#startdate').val() || '';
|
||||
var enddate = $('#enddate').val() || '';
|
||||
var url = '/form/downloaddata?email=1&form_id=' + encodeURIComponent(formId);
|
||||
if (startdate) url += '&startdate=' + encodeURIComponent(startdate);
|
||||
if (enddate) url += '&enddate=' + encodeURIComponent(enddate);
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
success: function() {
|
||||
$('#notifications').append('<div class="alert alert-success">Email Sent Successfully</div>');
|
||||
$("#pageloader").fadeOut();
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not send email.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#startdate, #enddate').on('change', function(){
|
||||
var startdate = $('#startdate').val() || '';
|
||||
var enddate = $('#enddate').val() || '';
|
||||
var url = '/form/downloaddata?form_id=' + encodeURIComponent(formId);
|
||||
if (startdate) url += '&startdate=' + encodeURIComponent(startdate);
|
||||
if (enddate) url += '&enddate=' + encodeURIComponent(enddate);
|
||||
$('#download-btn').attr('href', url);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,480 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "History"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
<link href="{{ URL::asset('assets/libs/datatables/datatables.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
<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">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
</div>
|
||||
<div class="col-4 p-2">
|
||||
<a href="/form/downloaddata?form_id={{$form_id}}" id="download-btn" class="btn btn-info btn-xs float-end">Download</a>
|
||||
<button type="button" id="emailme" class="btn btn-warning btn-xs float-end me-2">Email</button>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<p>Showing data for last 30 days, please use above button "Download" to download all submissions</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
@if(session()->has('message'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('message') }}
|
||||
</div>
|
||||
@endif
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div id="notifications"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 p-0">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form class="row row-cols-lg-auto g-2 align-items-center mb-3" id="date-range-form" onsubmit="return false;">
|
||||
<div class="col-4">
|
||||
<label for="startdate" class="form-label mb-0 me-2">Start Date:</label>
|
||||
<input type="date" class="form-control form-control-sm d-inline-block w-auto" id="startdate" name="startdate" value="{{ request()->input('startdate') }}">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<label for="enddate" class="form-label mb-0 me-2">End Date:</label>
|
||||
<input type="date" class="form-control form-control-sm d-inline-block w-auto" id="enddate" name="enddate" value="{{ request()->input('enddate') }}">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button type="button" class="btn btn-primary btn-sm" id="apply-date-range">Apply</button>
|
||||
</div>
|
||||
<input type="hidden" name="form_id" id="form_id" value="{{ $form_id }}">
|
||||
</form>
|
||||
|
||||
<div class="responsive-table-plugin">
|
||||
<div class="table-rep-plugin">
|
||||
<div class="table-responsive" data-pattern="priority-columns">
|
||||
<table id="basic-datatable" class="table dt-responsive nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="1">Action</th>
|
||||
<th data-priority="1">Submission Date</th>
|
||||
<th data-priority="1">Submitted By</th>
|
||||
<th data-priority="1">Employee Code</th>
|
||||
<th data-priority="1">Approval Status</th>
|
||||
<th data-priority="1">Generated Image</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue
|
||||
@endif
|
||||
@if($question->type == 'multitextbox')
|
||||
@foreach( $question->options as $k => $v )
|
||||
<th data-priority="1">{{$v}} ({{$question->label}})</th>
|
||||
@endforeach
|
||||
@else
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if($lastkey)
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-info" type="button" id="load-btn"> Load More ... </button>
|
||||
</div>
|
||||
@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%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{ URL::asset('assets/libs/datatables/datatables.min.js')}}"></script>
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$.fn.dataTable.ext.errMode = 'none';
|
||||
|
||||
const loggedInUser = @json($formdata->user_id ?? "");
|
||||
const allAccess = @json(isset($formdata->all_data_access) ? $formdata->all_data_access : 0);
|
||||
const formId = @json($form_id);
|
||||
const partition = @json($formdata->partition ?? '');
|
||||
|
||||
function buildGeneratedImageDownloadHtml(row, iconOnly) {
|
||||
const status = String(row.workflow_status || '').toLowerCase().trim();
|
||||
if (status !== 'approved' || !row.submission_id) {
|
||||
return '-';
|
||||
}
|
||||
let url = '/form/downloadpersonalization?id=' + encodeURIComponent(row.submission_id)
|
||||
+ '&form_id=' + encodeURIComponent(formId);
|
||||
if (partition) {
|
||||
url += '&partition=' + encodeURIComponent(partition);
|
||||
}
|
||||
if (iconOnly) {
|
||||
return '<a title="Download" class="btn btn-primary btn-xs" href="' + url + '" target="_blank"><i class="mdi mdi-cloud-download"></i></a>';
|
||||
}
|
||||
return '<a class="btn btn-primary btn-xs" href="' + url + '" target="_blank"><i class="mdi mdi-cloud-download me-1"></i>Download</a>';
|
||||
}
|
||||
|
||||
let table = $('#basic-datatable').DataTable({
|
||||
"responsive": false,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"previous": "<i class='mdi mdi-chevron-left'>",
|
||||
"next": "<i class='mdi mdi-chevron-right'>"
|
||||
}
|
||||
},
|
||||
fixedHeader: true,
|
||||
"paging": false,
|
||||
"pageLength": -1,
|
||||
"lengthMenu": [[-1], ["All"]],
|
||||
'processing': false,
|
||||
'serverSide': false,
|
||||
"order": [[1, "desc"]],
|
||||
'searching': true,
|
||||
'info': true,
|
||||
data: [],
|
||||
columns: [
|
||||
{ data: null,
|
||||
render: function ( data, type, row ) {
|
||||
let buttons = '';
|
||||
if (row.actions && Array.isArray(row.actions)) {
|
||||
if (row.actions.includes('edit')) {
|
||||
buttons += ` <button title="Edit" class="btn btn-warning btn-xs waves-effect waves-light btn-edit" submission="${row.submission_id}"><i class="mdi mdi-pencil-outline"></i></button>`;
|
||||
}
|
||||
if (row.actions.includes('delete') {{ isset($formdata->all_data_access) && $formdata->all_data_access ? ' || true' : '' }} ) {
|
||||
buttons += ` <button title="Delete" class="btn btn-danger btn-xs waves-effect waves-light btn-delete" submission="${row.submission_id}"><i class="mdi mdi-delete-outline"></i></button>`;
|
||||
}
|
||||
|
||||
if (row.actions.includes('approve') || row.actions.includes('reject')) {
|
||||
const nextApprover = row.workflow_next_approver ?? "";
|
||||
|
||||
if (allAccess == 1) {
|
||||
if (row.actions.includes('approve')) {
|
||||
buttons += `<button title="Approve" class="btn btn-success btn-xs waves-effect waves-light btn-approve" submission="${row.submission_id}"><i class="mdi mdi-check-outline"></i></button>`;
|
||||
}
|
||||
if (row.actions.includes('reject')) {
|
||||
buttons += `<button title="Reject" class="btn btn-danger btn-xs waves-effect waves-light btn-reject" submission="${row.submission_id}"><i class="mdi mdi-close-outline"></i></button>`;
|
||||
}
|
||||
} else if (loggedInUser === nextApprover) {
|
||||
if (row.actions.includes('approve')) {
|
||||
buttons += `<button title="Approve" class="btn btn-success btn-xs waves-effect waves-light btn-approve" submission="${row.submission_id}"><i class="mdi mdi-check-outline"></i></button>`;
|
||||
}
|
||||
if (row.actions.includes('reject')) {
|
||||
buttons += `<button title="Reject" class="btn btn-danger btn-xs waves-effect waves-light btn-reject" submission="${row.submission_id}"><i class="mdi mdi-close-outline"></i></button>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also surface download in Action for approved rows (works for load-more rows)
|
||||
const downloadHtml = buildGeneratedImageDownloadHtml(row, true);
|
||||
if (downloadHtml && downloadHtml !== '-') {
|
||||
buttons += ' ' + downloadHtml;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
},
|
||||
{ "data": "date" },
|
||||
{ "data": "name" },
|
||||
{ "data": "employee_code" },
|
||||
{ "data": "workflow_status" },
|
||||
{
|
||||
"data": null,
|
||||
"orderable": false,
|
||||
"searchable": false,
|
||||
"defaultContent": "-",
|
||||
render: function(data, type, row) {
|
||||
return buildGeneratedImageDownloadHtml(row);
|
||||
}
|
||||
},
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue
|
||||
@endif
|
||||
@if($question->type == 'multitextbox')
|
||||
@foreach($question->options as $k => $v)
|
||||
{ "data": "{{$k}}" },
|
||||
@endforeach
|
||||
@elseif($question->type == 'image')
|
||||
{
|
||||
"data": "{{$code}}",
|
||||
render: function(data, type, row) {
|
||||
data = row.{{$code.'_file'}};
|
||||
if (data && !/^https?:\/\//.test(data)) {
|
||||
data = '{{ env('AWS_URL') }}' + (data.startsWith('/') ? '' : '/') + data;
|
||||
}
|
||||
if (data && data !== '') {
|
||||
return '<button class="btn btn-info btn-xs" onclick="window.open(\'' + data + '\', \'_blank\')">View Image</button>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
@elseif($question->type == 'file')
|
||||
{
|
||||
"data": "{{$code}}",
|
||||
render: function(data, type, row) {
|
||||
data = row.{{$code.'_file'}};
|
||||
if (data && !/^https?:\/\//.test(data)) {
|
||||
data = '{{ env('AWS_URL') }}' + (data.startsWith('/') ? '' : '/') + data;
|
||||
}
|
||||
if (data && data !== '') {
|
||||
return '<a class="btn btn-primary btn-xs" target="_blank" href="' + data + '" download>Download File</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
@else
|
||||
{ "data": "{{$code}}" },
|
||||
@endif
|
||||
@endforeach
|
||||
],
|
||||
"initComplete": function(settings, json) {
|
||||
var api = this.api();
|
||||
var textBox = $('.dataTables_filter label input');
|
||||
textBox.unbind();
|
||||
textBox.bind('keyup input', function(e) {
|
||||
if(e.keyCode == 8 && !textBox.val() || e.keyCode == 46 && !textBox.val()) {
|
||||
// do nothing
|
||||
} else if(e.keyCode == 13 || !textBox.val()) {
|
||||
api.search(this.value).draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let lastkey = '{{$lastkey}}';
|
||||
|
||||
function bindRowActions() {
|
||||
$('.btn-edit').off('click').on('click', function(){
|
||||
window.location.href = '/form/edit?id=' + $(this).attr('submission');
|
||||
});
|
||||
|
||||
$('.btn-delete').off('click').on('click', function(){
|
||||
const btn = $(this);
|
||||
const submissionId = btn.attr('submission');
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "Do you really want to delete this submission?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
url: '/form/delete',
|
||||
type: 'GET',
|
||||
data: {
|
||||
id: submissionId,
|
||||
form_id: formId,
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
$("#pageloader").fadeOut();
|
||||
if (response.success) {
|
||||
Swal.fire('Deleted!', 'Submission has been deleted.', 'success');
|
||||
table.rows(function(idx, data) {
|
||||
return data.submission_id === submissionId;
|
||||
}).remove().draw();
|
||||
} else {
|
||||
Swal.fire('Error!', response.message || 'Could not delete submission.', 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', xhr.responseJSON?.message || 'Could not delete submission.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-approve').off('click').on('click', function(){
|
||||
$("#pageloader").fadeIn();
|
||||
let that = $(this);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/approvereject?action=approve&id=' + that.attr('submission') + '&form_id=' + formId + '&user_id={{ $formdata->user_id ?? '' }}&partition={{ $formdata->partition ?? '' }}',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
that.parent().html('');
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not approve submission.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-reject').off('click').on('click', function(){
|
||||
$("#pageloader").fadeIn();
|
||||
let that = $(this);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/approvereject?action=reject&id=' + that.attr('submission') + '&form_id=' + formId + '&user_id={{ $formdata->user_id ?? '' }}&partition={{ $formdata->partition ?? '' }}',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
that.parent().html('');
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not reject submission.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function loadRows(lastkeyVal, append = true, extraParams = {}) {
|
||||
$("#pageloader").fadeIn();
|
||||
|
||||
let params = {
|
||||
lastkey: lastkeyVal,
|
||||
partition: '{{ $formdata->partition ?? '' }}',
|
||||
form_id: formId,
|
||||
limit: 50
|
||||
};
|
||||
@if(isset($formdata->all_data_access) && $formdata->all_data_access == 1)
|
||||
params['alldata'] = 1;
|
||||
@else
|
||||
params['user_id'] = '{{ $formdata->user_id ?? '' }}';
|
||||
params['team_report'] = 1;
|
||||
@endif
|
||||
|
||||
params = Object.assign(params, extraParams);
|
||||
// Ensure form_id is never dropped by filters / load-more
|
||||
params.form_id = formId;
|
||||
|
||||
$.get('/form/loadmore?' + $.param(params), function(data) {
|
||||
$("#pageloader").fadeOut();
|
||||
if (data && data.rows && data.rows.length > 0) {
|
||||
if (append) {
|
||||
table.rows.add(data.rows).draw(false);
|
||||
} else {
|
||||
table.clear().rows.add(data.rows).draw();
|
||||
}
|
||||
lastkey = data.lastkey;
|
||||
if (data.lastkey === false || data.lastkey === null || data.lastkey === '' || data.lastkey === undefined) {
|
||||
$('#load-btn').hide();
|
||||
} else {
|
||||
$('#load-btn').show();
|
||||
}
|
||||
} else if (!append) {
|
||||
table.clear().draw();
|
||||
$('#load-btn').hide();
|
||||
} else {
|
||||
$('#load-btn').hide();
|
||||
}
|
||||
|
||||
bindRowActions();
|
||||
}).fail(function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not load submissions.', 'error');
|
||||
});
|
||||
}
|
||||
|
||||
let currentFilterParams = {};
|
||||
|
||||
$('#apply-date-range').on('click', function() {
|
||||
currentFilterParams = {
|
||||
form_id: $('#form_id').val(),
|
||||
startdate: $('#startdate').val(),
|
||||
enddate: $('#enddate').val()
|
||||
};
|
||||
lastkey = 1;
|
||||
loadRows(lastkey, false, currentFilterParams);
|
||||
});
|
||||
|
||||
currentFilterParams = {
|
||||
form_id: $('#form_id').val(),
|
||||
startdate: $('#startdate').val(),
|
||||
enddate: $('#enddate').val()
|
||||
};
|
||||
loadRows(1, false, currentFilterParams);
|
||||
|
||||
$('#load-btn').off('click').on('click', function() {
|
||||
if (lastkey) {
|
||||
loadRows(lastkey, true, currentFilterParams);
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-primary').click(function(){
|
||||
$("#pageloader").fadeIn();
|
||||
});
|
||||
|
||||
$('#emailme').click(function(){
|
||||
$("#pageloader").fadeIn();
|
||||
var startdate = $('#startdate').val() || '';
|
||||
var enddate = $('#enddate').val() || '';
|
||||
var url = '/form/downloaddata?email=1&form_id=' + encodeURIComponent(formId);
|
||||
if (startdate) url += '&startdate=' + encodeURIComponent(startdate);
|
||||
if (enddate) url += '&enddate=' + encodeURIComponent(enddate);
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
success: function() {
|
||||
$('#notifications').append('<div class="alert alert-success">Email Sent Successfully</div>');
|
||||
$("#pageloader").fadeOut();
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire('Error!', 'Could not send email.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#startdate, #enddate').on('change', function(){
|
||||
var startdate = $('#startdate').val() || '';
|
||||
var enddate = $('#enddate').val() || '';
|
||||
var url = '/form/downloaddata?form_id=' + encodeURIComponent(formId);
|
||||
if (startdate) url += '&startdate=' + encodeURIComponent(startdate);
|
||||
if (enddate) url += '&enddate=' + encodeURIComponent(enddate);
|
||||
$('#download-btn').attr('href', url);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue