181 lines
9.6 KiB
PHP
181 lines
9.6 KiB
PHP
@extends('layouts.master')
|
|
@section('title', 'Item Datas')
|
|
@section('styles')
|
|
<!-- DataTables -->
|
|
<link href="{{ asset('assets/libs/datatables.net-bs5/css/dataTables.bootstrap5.min.css') }}" rel="stylesheet" type="text/css" />
|
|
|
|
<!-- Responsive datatable examples -->
|
|
<link href="{{ asset('assets/libs/datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css') }}" rel="stylesheet" type="text/css" />
|
|
<link href="{{ asset('assets/libs/datatables.net-rowgroup-bs5/css/rowGroup.bootstrap5.min.css') }}" rel="stylesheet" type="text/css" />
|
|
@endsection
|
|
@section('content')
|
|
<div class="page-content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box d-flex align-items-center justify-content-between">
|
|
<h4 class="mb-sm-0">Item</h4>
|
|
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Master</a></li>
|
|
<li class="breadcrumb-item active">Item</li>
|
|
</ol>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Item Data</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<a href="{{ route('admin.items.create') }}" class="btn btn-primary mb-3">Create Item</a>
|
|
<table id="datatable" class="table table-hover align-middle table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
|
|
<thead>
|
|
<tr>
|
|
<th width="10px" class="text-center">#</th>
|
|
<th>Factor</th>
|
|
<th>Item</th>
|
|
<th>Item Content</th>
|
|
<th>Value</th>
|
|
<th class="text-center">Status</th>
|
|
<th width="10px" class="text-center">#</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($items as $factorName => $groupedItems)
|
|
@foreach ($groupedItems as $index => $item)
|
|
<tr>
|
|
<td>{{ $loop->iteration }}</td>
|
|
<td><strong>{{ $factorName }}</strong></td>
|
|
<td>{{ $item->code }}</td>
|
|
<td>{{ $item->content }}</td>
|
|
<td>{{ $item->value }}</td>
|
|
<td class="text-center">
|
|
@if ($item->status == 'active')
|
|
<span class="badge badge-success">{{ ucwords($item->status) }}</span>
|
|
@else
|
|
<span class="badge badge-danger">{{ ucwords($item->status) }}</span>
|
|
@endif
|
|
</td>
|
|
<td class="text-center">
|
|
<div class="dropdown d-inline-block">
|
|
<button class="btn btn-flat-secondary btn-sm dropdown" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="fas fa-ellipsis-h align-middle"></i>
|
|
</button>
|
|
<ul class="dropdown-menu dropdown-menu-end">
|
|
<li><a class="dropdown-item" href="{{ route('admin.items.edit', $item->id) }}"><i class="mdi mdi-square-edit-outline align-bottom me-2 text-muted"></i> Edit</a></li>
|
|
<li><a class="dropdown-item" href="{{ route('admin.items.show', $item->id) }}"><i class="mdi mdi-eye-outline align-bottom me-2 text-muted"></i> Detail</a></li>
|
|
<li>
|
|
<a href="javascript:void(0);" class="dropdown-item delete" data-id="{{ $item->id }}">
|
|
<i class="mdi mdi-delete-outline align-bottom me-2 text-muted"></i> Delete
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div> <!-- end col -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
@section('scripts')
|
|
<!-- Required datatable js -->
|
|
<script src="{{ asset('assets/libs/datatables.net/js/jquery.dataTables.min.js') }}"></script>
|
|
<script src="{{ asset('assets/libs/datatables.net-bs5/js/dataTables.bootstrap5.min.js') }}"></script>
|
|
|
|
<!-- Responsive examples -->
|
|
<script src="{{ asset('assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js') }}"></script>
|
|
<script src="{{ asset('assets/libs/datatables.net-responsive-bs5/js/responsive.bootstrap5.min.js') }}"></script>
|
|
|
|
<script src="{{ asset('assets/libs/datatables.net-rowgroup/js/dataTables.rowGroup.min.js') }}"></script>
|
|
<script src="{{ asset('assets/libs/datatables.net-rowgroup-bs5/js/rowGroup.bootstrap5.min.js') }}"></script>
|
|
<script>
|
|
$(function () {
|
|
$(document).ready(function () {
|
|
$('#datatable').DataTable({
|
|
rowGroup: {
|
|
dataSrc: 1,
|
|
},
|
|
columnDefs: [
|
|
{ targets: 1, visible: false }
|
|
],
|
|
responsive: true,
|
|
order: [[1, 'asc']],
|
|
});
|
|
});
|
|
|
|
$('.delete').click(function (e) {
|
|
var id = $(this).data('id');
|
|
e.preventDefault();
|
|
n.fire({
|
|
title:"Are you sure?",
|
|
text:"You won't be able to revert this!",
|
|
icon:"warning",
|
|
showCancelButton:!0,
|
|
confirmButtonColor:"#3085d6",
|
|
cancelButtonColor:"#d33",
|
|
confirmButtonText:"Yes, delete it!"
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
var data = {
|
|
_token: "{{ csrf_token() }}",
|
|
_method:'delete'
|
|
};
|
|
|
|
$.ajax({
|
|
url: `{{ url('admin/items')}}/${id}`,
|
|
dataType: 'json',
|
|
data: data,
|
|
type: 'POST',
|
|
}).done(function(response) {
|
|
if (response.status) {
|
|
n.fire({
|
|
title: "Success!",
|
|
text: response.message,
|
|
icon: "success",
|
|
confirmButtonClass: "btn btn-primary w-xs mt-2",
|
|
buttonsStyling: !1
|
|
})
|
|
setTimeout(
|
|
function() {
|
|
window.location.reload(true);
|
|
}, 1000
|
|
);
|
|
} else {
|
|
n.fire({
|
|
title: "Error!",
|
|
text: response.message,
|
|
icon: "error",
|
|
confirmButtonClass: "btn btn-primary w-xs mt-2",
|
|
buttonsStyling: !1
|
|
})
|
|
}
|
|
}).fail(function(response) {
|
|
var response = response.responseJSON;
|
|
n.fire({
|
|
title: "Error!",
|
|
text: response.message,
|
|
icon: "error",
|
|
confirmButtonClass: "btn btn-primary w-xs mt-2",
|
|
buttonsStyling: !1
|
|
})
|
|
})
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|