ultimatepos/Modules/ManagementTools/Resources/views/daily_reports/employees.blade.php

150 lines
8.0 KiB
PHP

@extends('layouts.app')
@section('title', __('managementtools::lang.employee_reports'))
@section('content')
@include('managementtools::layouts.nav')
@php $reportUtil = app(\Modules\ManagementTools\Utils\DailyReportUtil::class); @endphp
<section class="content no-print mt-page">
<div class="mt-page-header">
<h1><i class="fas fa-users" style="color:#2563eb;margin-left:8px;"></i> @lang('managementtools::lang.employee_reports')</h1>
</div>
<div class="mt-card">
<div class="mt-card-body">
<ul class="list-inline text-center" style="margin-bottom:16px;">
@foreach($days as $day)
<li class="list-inline-item">
<a href="{{ action([\Modules\ManagementTools\Http\Controllers\DailyReportController::class, 'employees'], ['day' => $day]) }}"
class="btn btn-sm {{ $selected_day == $day ? 'btn-primary' : 'btn-default' }}">
{{ $mtUtil->formatDate($day) }}
</a>
</li>
@endforeach
</ul>
@if($users_without_report->count())
<div class="alert alert-warning">
<strong>@lang('managementtools::lang.no_report_today'):</strong>
{{ $users_without_report->map(fn($u) => trim($u->surname.' '.$u->first_name.' '.$u->last_name))->implode('، ') }}
</div>
@endif
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>@lang('managementtools::lang.view')</th>
<th>@lang('managementtools::lang.user')</th>
<th>#</th>
</tr>
</thead>
<tbody>
@forelse($grouped as $user_id => $reports)
@php $user = $reports->first()->user; @endphp
<tr>
<td>
<button class="btn btn-info btn-xs" data-toggle="collapse" data-target="#emp_reports_{{ $user_id }}">
@lang('managementtools::lang.view_reports')
</button>
</td>
<td>{{ trim(($user->surname ?? '').' '.($user->first_name ?? '').' '.($user->last_name ?? '')) }}</td>
<td>{{ $loop->iteration }}</td>
</tr>
<tr>
<td colspan="3" class="p-0">
<div class="collapse" id="emp_reports_{{ $user_id }}">
<table class="table table-striped" style="margin:0;">
<thead>
<tr>
<th>@lang('managementtools::lang.report_body')</th>
<th>@lang('managementtools::lang.manager_score')</th>
<th>@lang('managementtools::lang.user_status')</th>
<th>@lang('managementtools::lang.repeat_count')</th>
<th>@lang('managementtools::lang.slot_time')</th>
<th>@lang('managementtools::lang.comments')</th>
<th>#</th>
</tr>
</thead>
<tbody>
@foreach($reports as $report)
<tr>
<td>{{ $report->body }}</td>
<td>
<form class="mt-feedback-form" style="display:flex;gap:4px;">
<select name="score" class="form-control input-sm">
<option value=""></option>
@for($s = 5; $s >= 1; $s--)
<option value="{{ $s }}" {{ $report->score == $s ? 'selected' : '' }}>{{ $reportUtil->scoreLabel($s) }}</option>
@endfor
</select>
<button type="button" class="btn btn-primary btn-xs mt-send-feedback" data-id="{{ $report->id }}">@lang('managementtools::lang.save')</button>
</form>
</td>
<td>{{ $reportUtil->userStatusLabel($report->user_status) }}</td>
<td>{{ $report->body_count }}</td>
<td>{{ $mtUtil->formatDateTime($report->first_slot) }} {{ $mtUtil->formatDateTime($report->last_slot) }}</td>
<td>
<button type="button" class="btn btn-warning btn-xs btn-modal"
data-href="{{ action([\Modules\ManagementTools\Http\Controllers\DailyReportController::class, 'comments'], [$report->id]) }}"
data-container=".mt_comment_modal">
@lang('managementtools::lang.comments') ({{ $report->comments->count() }})
</button>
</td>
<td>{{ $loop->iteration }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</td>
</tr>
@empty
<tr><td colspan="3" class="text-center">@lang('managementtools::lang.no_data')</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</section>
<div class="modal fade mt_comment_modal" tabindex="-1" role="dialog"></div>
@endsection
@section('javascript')
<script type="text/javascript">
$(document).ready(function() {
$(document).on('click', '.mt-send-feedback', function() {
var form = $(this).closest('form');
var id = $(this).data('id');
$.post('{{ url("management-tools/daily-reports") }}/' + id + '/feedback', form.serialize(), function(r) {
if (r.success) toastr.success(r.msg);
else toastr.error(r.msg);
});
});
$(document).on('submit', 'form#mt_comment_form', function(e) {
e.preventDefault();
var form = $(this);
$.ajax({
method: 'POST',
url: form.attr('action'),
dataType: 'json',
data: form.serialize(),
success: function(r) {
if (r.success) {
toastr.success(r.msg);
$('.mt_comment_modal').modal('hide');
} else {
toastr.error(r.msg);
}
}
});
});
});
</script>
@endsection