ultimatepos/Modules/Maintenance/Resources/views/failure_reports/index.blade.php

89 lines
3.9 KiB
PHP

@extends('layouts.app')
@section('title', __('maintenance::lang.failure_reports'))
@section('content')
@include('maintenance::layouts.nav')
<section class="content no-print mt-page">
<div class="mt-page-header">
<h1><i class="fas fa-exclamation-triangle" style="color:#14b8a6;margin-left:8px;"></i> @lang('maintenance::lang.failure_reports')</h1>
@can('maintenance.failures.create')
<a href="{{ action([\Modules\Maintenance\Http\Controllers\FailureReportController::class, 'create']) }}" class="mt-btn-primary btn">
<i class="fa fa-plus"></i> @lang('maintenance::lang.add')
</a>
@endcan
</div>
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('maintenance::lang.all_failures')</h3></div>
<div class="mt-card-body">
@include('maintenance::partials.scope_filters', ['projects' => $projects, 'equipment' => $equipment])
<div class="table-responsive">
<table class="table table-bordered table-striped" id="mm_failures_table" style="width:100%">
<thead>
<tr>
<th>@lang('maintenance::lang.equipment')</th>
<th>@lang('maintenance::lang.failure_type')</th>
<th>@lang('maintenance::lang.reporter')</th>
<th>@lang('maintenance::lang.reported_at')</th>
<th>@lang('maintenance::lang.downtime_hours')</th>
<th>@lang('maintenance::lang.cost')</th>
<th>@lang('maintenance::lang.action')</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</section>
<div class="modal fade maintenance_failure_report_modal" tabindex="-1" role="dialog"></div>
@endsection
@section('javascript')
<script type="text/javascript">
$(document).ready(function() {
$('.select2').select2();
var table = $('#mm_failures_table').DataTable({
processing: true, serverSide: true,
ajax: {
url: '{{ action([\Modules\Maintenance\Http\Controllers\FailureReportController::class, "index"]) }}',
data: function(d) {
d.project_id = $('.mm-filter-project').val();
d.equipment_id = $('.mm-filter-equipment').val();
}
},
columns: [
{ data: 'equipment_name', name: 'equipment_name', orderable: false },
{ data: 'failure_type', name: 'failure_type' },
{ data: 'reporter_name', name: 'reporter_name', orderable: false },
{ data: 'reported_at', name: 'reported_at' },
{ data: 'downtime_hours', name: 'downtime_hours' },
{ data: 'cost', name: 'cost' },
{ data: 'action', name: 'action', orderable: false, searchable: false }
]
});
$('.mm-apply-filters').on('click', function() { table.ajax.reload(); });
$(document).on('submit', 'form#mm_failure_report_form', function(e) {
e.preventDefault();
var form = $(this);
$.ajax({
method: 'PUT', url: form.attr('action'), dataType: 'json', data: form.serialize(),
success: function(r) {
if (r.success) { $('.maintenance_failure_report_modal').modal('hide'); toastr.success(r.msg); table.ajax.reload(); }
else { toastr.error(r.msg); }
}
});
});
$(document).on('click', '.delete_maintenance_failure_report', function() {
var url = $(this).data('href');
swal({ title: LANG.sure, icon: 'warning', buttons: true, dangerMode: true }).then(function(ok) {
if (!ok) return;
$.ajax({ method: 'DELETE', url: url, dataType: 'json', success: function(r) {
if (r.success) { toastr.success(r.msg); table.ajax.reload(); } else { toastr.error(r.msg); }
}});
});
});
});
</script>
@endsection