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

76 lines
3.2 KiB
PHP

@extends('layouts.app')
@section('title', __('maintenance::lang.part_replacements'))
@section('content')
@include('maintenance::layouts.nav')
<section class="content no-print mt-page">
<div class="mt-page-header">
<h1><i class="fas fa-exchange-alt" style="color:#14b8a6;margin-left:8px;"></i> @lang('maintenance::lang.part_replacements')</h1>
@can('maintenance.spare_parts.create')
<a href="{{ action([\Modules\Maintenance\Http\Controllers\PartReplacementController::class, 'create']) }}" class="btn btn-primary">
<i class="fa fa-plus"></i> @lang('maintenance::lang.add')
</a>
@endcan
</div>
<div class="mt-card">
<div class="mt-card-body">
<div class="row" style="margin-bottom:12px;">
<div class="col-md-4">
<select id="mm_pr_equipment_filter" class="form-control select2" style="width:100%">
<option value="">@lang('maintenance::lang.all_equipment')</option>
@foreach($equipment as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@endforeach
</select>
</div>
</div>
<table class="table table-bordered table-striped" id="mm_part_replacements_table" style="width:100%">
<thead>
<tr>
<th>@lang('maintenance::lang.equipment')</th>
<th>@lang('maintenance::lang.part_name')</th>
<th>@lang('maintenance::lang.replaced_at')</th>
<th>@lang('maintenance::lang.quantity')</th>
<th>@lang('maintenance::lang.action')</th>
</tr>
</thead>
</table>
</div>
</div>
</section>
@endsection
@section('javascript')
<script>
$(function() {
$('.select2').select2();
var table = $('#mm_part_replacements_table').DataTable({
processing: true, serverSide: true,
ajax: {
url: '{{ action([\Modules\Maintenance\Http\Controllers\PartReplacementController::class, "index"]) }}',
data: function(d) { d.equipment_id = $('#mm_pr_equipment_filter').val(); }
},
columns: [
{ data: 'equipment_name', name: 'equipment_name', orderable: false },
{ data: 'part_name', name: 'part_name', orderable: false },
{ data: 'replaced_at', name: 'replaced_at' },
{ data: 'quantity', name: 'quantity' },
{ data: 'action', name: 'action', orderable: false, searchable: false }
]
});
$('#mm_pr_equipment_filter').on('change', function() { table.ajax.reload(); });
$(document).on('click', '.delete_mm_part_replacement', 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, data: { _token: '{{ csrf_token() }}' } })
.done(function(r) { if (r.success) { toastr.success(r.msg); table.ajax.reload(); } });
});
});
});
</script>
@endsection