fix lang bug

This commit is contained in:
decoder 2024-04-26 20:45:01 +05:00
parent a46ec03369
commit 157a5a1939
2 changed files with 165 additions and 142 deletions

View File

@ -16,7 +16,8 @@
visibility: hidden; visibility: hidden;
} }
#printSection, #printSection * { #printSection,
#printSection * {
visibility: visible; visibility: visible;
} }
@ -40,7 +41,7 @@
$date_format = config('constants.APP_DATE_FORMAT'); $date_format = config('constants.APP_DATE_FORMAT');
if (config('constants.APP_TIME_FORMAT') == '12') { if (config('constants.APP_TIME_FORMAT') == '12') {
$date_format .= ' h:i A'; $date_format .= ' h:i A';
} else if (config('constants.APP_TIME_FORMAT') == '24') { } elseif (config('constants.APP_TIME_FORMAT') == '24') {
$date_format .= ' H:i'; $date_format .= ' H:i';
} else { } else {
$date_format = 'm/d/Y h:i A'; $date_format = 'm/d/Y h:i A';
@ -48,16 +49,18 @@
@endphp @endphp
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
{{$form->name}} {{ $form->name }}
</div> </div>
<form action="{{ @route('form-data.show', ['id' => $form->id]) }}" class="form row mt-3 mx-2 mb-0"> <form action="{{ @route('form-data.show', ['id' => $form->id]) }}" class="form row mt-3 mx-2 mb-0">
<div class="form-group mb-0 col-1"> <div class="form-group mb-0 col-1">
<input type="date" class="form-control" name="start_date" value="{{ request()->get('start_date') ?? \Carbon\Carbon::now()->subDays(7)->toDateString() }}"> <input type="date" class="form-control" name="start_date"
value="{{ request()->get('start_date') ?? \Carbon\Carbon::now()->subDays(7)->toDateString() }}">
</div> </div>
<div class="form-group mb-0 col-1"> <div class="form-group mb-0 col-1">
<input type="date" class="form-control" name="end_date" value="{{ request()->get('end_date') ?? \Carbon\Carbon::now()->toDateString() }}"> <input type="date" class="form-control" name="end_date"
value="{{ request()->get('end_date') ?? \Carbon\Carbon::now()->toDateString() }}">
</div> </div>
<div class="form-group mb-0 col-2 d-flex"> <div class="form-group mb-0 col-2 d-flex">
@ -67,13 +70,16 @@
@php @php
$is_enabled_sub_ref_no = false; $is_enabled_sub_ref_no = false;
if(isset($form->schema['settings']['form_submision_ref']['is_enabled']) && $form->schema['settings']['form_submision_ref']['is_enabled']) { if (
isset($form->schema['settings']['form_submision_ref']['is_enabled']) &&
$form->schema['settings']['form_submision_ref']['is_enabled']
) {
$is_enabled_sub_ref_no = true; $is_enabled_sub_ref_no = true;
} }
@endphp @endphp
<div class="tab-content card-body table-responsive" role="tabpanel"> <div class="tab-content card-body table-responsive" role="tabpanel">
@if(!empty($form->schema)) @if (!empty($form->schema))
@php @php
$schema = $form->schema['form']; $schema = $form->schema['form'];
$col_visible = $form['schema']['settings']['form_data']['col_visible']; $col_visible = $form['schema']['settings']['form_data']['col_visible'];
@ -81,101 +87,108 @@
@endphp @endphp
<table class="table" id="submitted_data_table" style="width: 100%;"> <table class="table" id="submitted_data_table" style="width: 100%;">
<thead> <thead>
<tr> <tr>
@if(auth()->user()->hasRole([\App\Enums\User\RoleEnum::SUPERVISOR->value, \App\Enums\User\RoleEnum::ADMIN->value], 'web')) @if (auth()->user()->hasRole([\App\Enums\User\RoleEnum::SUPERVISOR->value, \App\Enums\User\RoleEnum::ADMIN->value], 'web'))
<th>@lang('messages.action')</th> <th>@lang('messages.action')</th>
@endif
@if($is_enabled_sub_ref_no)
<th>@lang('messages.submission_numbering')</th>
@endif
<th>@lang('messages.username')</th>
@foreach($schema as $element)
@if(in_array($element['name'], $col_visible))
<th>
{{$element['label']}}
</th>
@endif @endif
@endforeach
<th>@lang('messages.submitted_on')</th> @if ($is_enabled_sub_ref_no)
</tr> <th>@lang('messages.submission_numbering')</th>
@endif
<th>@lang('messages.username')</th>
@foreach ($schema as $element)
@if (in_array($element['name'], $col_visible))
<th>
{{-- $element['label'] --}}
@if (in_array(session()->get('locale'), ['ru', 'est']) && isset($element['label_' . session()->get('locale')]))
{{ $element['label_' . session()->get('locale')] }}
@else
{{ $element['label'] }}
@endif
</th>
@endif
@endforeach
<th>@lang('messages.submitted_on')</th>
</tr>
</thead> </thead>
<tbody> <tbody>
@foreach($data as $k => $row) @foreach ($data as $k => $row)
<tr> <tr>
@if(auth()->user()->hasRole([\App\Enums\User\RoleEnum::SUPERVISOR->value, \App\Enums\User\RoleEnum::ADMIN->value], 'web')) @if (auth()->user()->hasRole([\App\Enums\User\RoleEnum::SUPERVISOR->value, \App\Enums\User\RoleEnum::ADMIN->value], 'web'))
<td>
@if(in_array('view', $btn_enabled))
<button type="button" class="btn btn-info btn-sm view_form_data m-1"
data-href="{{action([\App\Http\Controllers\FormDataController::class, 'viewData'], [$row->id])}}"
data-toggle="modal">
<i class="fa fa-eye" aria-hidden="true"></i>
@lang('messages.view')
</button>
@endif
@if(in_array('delete', $btn_enabled))
<button type="button"
class="btn btn-danger btn-sm delete_form_data m-1"
data-href="{{action([\App\Http\Controllers\FormDataController::class, 'destroy'], [$row->id])}}">
<i class="fa fa-trash" aria-hidden="true"></i>
@lang('messages.delete')
</button>
@endif
@php
$form_id = !empty($form->slug) ? $form->slug : $form->id;
@endphp
<a class="btn btn-dark btn-sm m-1"
href="{{action([\App\Http\Controllers\FormDataController::class, 'getEditformData'], ['slug' => $form_id,'id' => $row->id])}}">
<i class="far fa-edit" aria-hidden="true"></i>
@lang('messages.edit')
</a>
</td>
@endif
@if($is_enabled_sub_ref_no)
<td>
{{$row['submission_ref']}}
</td>
@endif
<td>{{ $row->submittedBy?->name }}</td>
@foreach($schema as $row_element)
@if(in_array($row_element['name'], $col_visible))
<td> <td>
@isset($row->data[$row_element['name']]) @if (in_array('view', $btn_enabled))
@if($row_element['type'] == 'file_upload') <button type="button"
class="btn btn-info btn-sm view_form_data m-1"
@include('form_data.file_view', ['form_upload' => $row->data[$row_element['name']]]) data-href="{{ action([\App\Http\Controllers\FormDataController::class, 'viewData'], [$row->id]) }}"
@elseif($row_element['type'] == 'signature') data-toggle="modal">
@if(!empty($row->data[$row_element['name']])) <i class="fa fa-eye" aria-hidden="true"></i>
<a target="_blank" @lang('messages.view')
href="{{$row->data[$row_element['name']]}}" </button>
download="Signature"> @endif
<img src="{{$row->data[$row_element['name']]}}" @if (in_array('delete', $btn_enabled))
class="signature"> <button type="button"
</a> class="btn btn-danger btn-sm delete_form_data m-1"
@endif data-href="{{ action([\App\Http\Controllers\FormDataController::class, 'destroy'], [$row->id]) }}">
@elseif(is_array($row->data[$row_element['name']]) && $row_element['type'] != 'file_upload') <i class="fa fa-trash" aria-hidden="true"></i>
{{implode(', ', $row->data[$row_element['name']])}} @lang('messages.delete')
@else </button>
{!! nl2br($row->data[$row_element['name']]) !!} @endif
@endif @php
$form_id = !empty($form->slug) ? $form->slug : $form->id;
@endisset @endphp
<a class="btn btn-dark btn-sm m-1"
href="{{ action([\App\Http\Controllers\FormDataController::class, 'getEditformData'], ['slug' => $form_id, 'id' => $row->id]) }}">
<i class="far fa-edit" aria-hidden="true"></i>
@lang('messages.edit')
</a>
</td> </td>
@endif @endif
@endforeach
<td> @if ($is_enabled_sub_ref_no)
{{\Carbon\Carbon::createFromTimestamp(strtotime($row->updated_at))->format($date_format)}} <td>
<br/> {{ $row['submission_ref'] }}
<small> </td>
{{$row->updated_at->diffForHumans()}} @endif
</small>
</td> <td>{{ $row->submittedBy?->name }}</td>
</tr>
@endforeach @foreach ($schema as $row_element)
@if (in_array($row_element['name'], $col_visible))
<td>
@isset($row->data[$row_element['name']])
@if ($row_element['type'] == 'file_upload')
@include('form_data.file_view', [
'form_upload' =>
$row->data[$row_element['name']],
])
@elseif($row_element['type'] == 'signature')
@if (!empty($row->data[$row_element['name']]))
<a target="_blank"
href="{{ $row->data[$row_element['name']] }}"
download="Signature">
<img src="{{ $row->data[$row_element['name']] }}"
class="signature">
</a>
@endif
@elseif(is_array($row->data[$row_element['name']]) && $row_element['type'] != 'file_upload')
{{ implode(', ', $row->data[$row_element['name']]) }}
@else
{!! nl2br($row->data[$row_element['name']]) !!}
@endif
@endisset
</td>
@endif
@endforeach
<td>
{{ \Carbon\Carbon::createFromTimestamp(strtotime($row->updated_at))->format($date_format) }}
<br />
<small>
{{ $row->updated_at->diffForHumans() }}
</small>
</td>
</tr>
@endforeach
</tbody> </tbody>
</table> </table>
@else @else
@ -189,7 +202,7 @@
@endsection @endsection
@section('footer') @section('footer')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function() {
$('#submitted_data_table').DataTable({ $('#submitted_data_table').DataTable({
scrollY: "600px", scrollY: "600px",
scrollX: true, scrollX: true,
@ -200,20 +213,20 @@
} }
}); });
// view form data // view form data
$(document).on('click', '.view_form_data', function () { $(document).on('click', '.view_form_data', function() {
var url = $(this).data("href"); var url = $(this).data("href");
$.ajax({ $.ajax({
method: "GET", method: "GET",
dataType: "html", dataType: "html",
url: url, url: url,
success: function (result) { success: function(result) {
$("#modal_div").html(result).modal("show"); $("#modal_div").html(result).modal("show");
} }
}); });
}); });
//delete form data //delete form data
$(document).on('click', '.delete_form_data', function () { $(document).on('click', '.delete_form_data', function() {
var url = $(this).data("href"); var url = $(this).data("href");
var result = confirm('Are You Sure?'); var result = confirm('Are You Sure?');
if (result == true) { if (result == true) {
@ -221,10 +234,10 @@
method: "DELETE", method: "DELETE",
url: url, url: url,
dataType: "json", dataType: "json",
success: function (result) { success: function(result) {
if (result.success == true) { if (result.success == true) {
toastr.success(result.msg); toastr.success(result.msg);
setTimeout(function () { setTimeout(function() {
location.reload(); location.reload();
}, 1000); }, 1000);
} else { } else {
@ -236,17 +249,17 @@
}); });
//print form data on btn click //print form data on btn click
$(document).on('click', '.formDataPrintBtn', function () { $(document).on('click', '.formDataPrintBtn', function() {
printElement(document.getElementById("print_form_data")); printElement(document.getElementById("print_form_data"));
}); });
$("#modal_div").on('shown.bs.modal', function () { $("#modal_div").on('shown.bs.modal', function() {
if ($("form#add_comment_form").length) { if ($("form#add_comment_form").length) {
$("form#add_comment_form").validate(); $("form#add_comment_form").validate();
} }
}); });
$(document).on('submit', 'form#add_comment_form', function (e) { $(document).on('submit', 'form#add_comment_form', function(e) {
e.preventDefault(); e.preventDefault();
var data = $("form#add_comment_form").serialize(); var data = $("form#add_comment_form").serialize();
var url = $("form#add_comment_form").attr('action'); var url = $("form#add_comment_form").attr('action');
@ -257,7 +270,7 @@
url: url, url: url,
dataType: "json", dataType: "json",
data: data, data: data,
success: function (response) { success: function(response) {
ladda.stop(); ladda.stop();
if (response.success) { if (response.success) {
$("#comment").val(''); $("#comment").val('');
@ -270,7 +283,7 @@
}); });
}); });
$(document).on('click', '.delete-comment', function (e) { $(document).on('click', '.delete-comment', function(e) {
e.preventDefault(); e.preventDefault();
var element = $(this); var element = $(this);
var comment_id = $(this).data('comment_id'); var comment_id = $(this).data('comment_id');
@ -280,7 +293,7 @@
method: 'DELETE', method: 'DELETE',
dataType: 'json', dataType: 'json',
url: '/form-data-comment/' + comment_id + '?form_data_id=' + form_data_id, url: '/form-data-comment/' + comment_id + '?form_data_id=' + form_data_id,
success: function (response) { success: function(response) {
if (response.success) { if (response.success) {
toastr.success(response.msg); toastr.success(response.msg);
element.closest('.direct-chat-msg').remove(); element.closest('.direct-chat-msg').remove();

View File

@ -2,12 +2,12 @@
<div class="modal-content" id="print_form_data"> <div class="modal-content" id="print_form_data">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"> <h5 class="modal-title" id="exampleModalLabel">
{{ucFirst($form_data->form->name)}} {{ ucFirst($form_data->form->name) }}
@if(!empty($form_data->submittedBy)) @if (!empty($form_data->submittedBy))
<small> <small>
( (
<b>@lang('messages.submitted_by'): </b> <b>@lang('messages.submitted_by'): </b>
{{$form_data->submittedBy->name}} {{ $form_data->submittedBy->name }}
) )
</small> </small>
@endif @endif
@ -23,9 +23,11 @@
<div class="modal-body"> <div class="modal-body">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-md-6"> <div class="col-md-6">
@if(isset($form_data->form->schema['settings']['form_submision_ref']['is_enabled']) && $form_data->form->schema['settings']['form_submision_ref']['is_enabled'] && !empty($form_data->submission_ref)) @if (isset($form_data->form->schema['settings']['form_submision_ref']['is_enabled']) &&
<b>@lang('messages.submission_numbering'):</b> $form_data->form->schema['settings']['form_submision_ref']['is_enabled'] &&
{{$form_data->submission_ref}} !empty($form_data->submission_ref))
<b>@lang('messages.submission_numbering'):</b>
{{ $form_data->submission_ref }}
@endif @endif
</div> </div>
</div> </div>
@ -37,42 +39,49 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($form_data->form->schema['form'] as $element) @foreach ($form_data->form->schema['form'] as $element)
@isset($form_data->data[$element['name']]) @isset($form_data->data[$element['name']])
<tr> <tr>
<td> <td>
<strong>{{$element['label']}}</strong> <strong>
</td> @if (in_array(session()->get('locale'), ['ru', 'est']) && isset($element['label_' . session()->get('locale')]))
<td> {{ $element['label_' . session()->get('locale')] }}
@if($element['type'] == 'file_upload') @else
{{ $element['label'] }}
@include('form_data.file_view', ['form_upload' => $form_data->data[$element['name']]]) @endif
@elseif($element['type'] == 'signature') </strong>
@if(!empty($form_data->data[$element['name']])) </td>
<a target="_blank" href="{{$form_data->data[$element['name']]}}" <td>
download="Signature"> @if ($element['type'] == 'file_upload')
<img src="{{$form_data->data[$element['name']]}}" class="signature"> @include('form_data.file_view', [
</a> 'form_upload' => $form_data->data[$element['name']],
])
@elseif($element['type'] == 'signature')
@if (!empty($form_data->data[$element['name']]))
<a target="_blank" href="{{ $form_data->data[$element['name']] }}"
download="Signature">
<img src="{{ $form_data->data[$element['name']] }}" class="signature">
</a>
@endif
@elseif(is_array($form_data->data[$element['name']]) && $element['type'] != 'file_upload')
{{ implode(', ', $form_data->data[$element['name']]) }}
@else
{!! nl2br($form_data->data[$element['name']]) !!}
@endif @endif
@elseif(is_array($form_data->data[$element['name']]) && $element['type'] != 'file_upload') </td>
</tr>
{{implode(', ', $form_data->data[$element['name']])}}
@else
{!! nl2br($form_data->data[$element['name']]) !!}
@endif
</td>
</tr>
@endisset @endisset
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
<div class="no-print mt-4"> <div class="no-print mt-4">
<hr> <hr>
<form id="add_comment_form" action="{{action([\App\Http\Controllers\FormDataCommentController::class, 'store'])}}" method="POST"> <form id="add_comment_form"
action="{{ action([\App\Http\Controllers\FormDataCommentController::class, 'store']) }}"
method="POST">
{{ csrf_field() }} {{ csrf_field() }}
<!-- hiden fields --> <!-- hiden fields -->
<input type="hidden" name="form_data_id" id="form_data_id" value="{{$form_data->id}}"> <input type="hidden" name="form_data_id" id="form_data_id" value="{{ $form_data->id }}">
<div class="form-group"> <div class="form-group">
<label for="comment"> <label for="comment">
@lang('messages.comment'): @lang('messages.comment'):
@ -104,7 +113,8 @@
<i class="fas fa-print"></i> <i class="fas fa-print"></i>
@lang('messages.print') @lang('messages.print')
</button> </button>
<a class="btn float-right btn-primary btn-sm m-1" target="_blank" href="{{action([\App\Http\Controllers\FormDataController::class, 'downloadPdf'], [$form_data->id])}}"> <a class="btn float-right btn-primary btn-sm m-1" target="_blank"
href="{{ action([\App\Http\Controllers\FormDataController::class, 'downloadPdf'], [$form_data->id]) }}">
<i class="far fa-file-pdf" aria-hidden="true"></i> <i class="far fa-file-pdf" aria-hidden="true"></i>
@lang('messages.download_pdf') @lang('messages.download_pdf')
</a> </a>