296 lines
15 KiB
PHP
296 lines
15 KiB
PHP
@extends('layout.main')
|
|
|
|
@section('content')
|
|
<div class="container-xxl flex-grow-1 container-p-y">
|
|
<div class="card">
|
|
<div class="card-header border-bottom mb-4">
|
|
<h5 class="card-title mb-0">Lihat Data Tabel</h5>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<form id="addViewTabelForm" >
|
|
|
|
<h6 class="mb-3">Informasi Tabel</h6>
|
|
<div class="row">
|
|
<div class="col-md-3 mb-4 form-control-validation">
|
|
<label class="form-label" for="add-tabel-nama">Nama Tabel</label>
|
|
<input type="text" class="form-control" id="add-tabel-nama" name="tabel" placeholder="Cth: Tabel Pertanian" value="{{ $tabel->tabel }}" readonly />
|
|
</div>
|
|
<div class="col-md-3 mb-4 form-control-validation">
|
|
<label class="form-label" for="add-tabel-label">Label</label>
|
|
<input type="text" class="form-control" id="add-tabel-label" name="label" placeholder="Cth: budi@email.com" value="{{ $tabel->label }}" readonly />
|
|
</div>
|
|
<div class="col-md-3 mb-4 form-control-validation">
|
|
<label class="form-label" for="add-tabel-menu">Judul Menu</label>
|
|
<input type="text" class="form-control" id="add-tabel-menu" name="menu" placeholder="Cth: Pertanian" value="{{ $tabel->menu }}" readonly />
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12 mb-4 form-control-validation">
|
|
<label class="form-label" for="add-tabel-deskripsi">Deskripsi</label>
|
|
<input type="text" class="form-control" id="add-tabel-deskripsi" name="deskripsi" placeholder="Cth: Deskripsi tabel pertanian" value="{{ $tabel->deskripsi }}" readonly />
|
|
</div>
|
|
</div>
|
|
|
|
<h6 class="mb-3">Informasi Kolom-Kolom</h6>
|
|
|
|
<hr class="my-4 mx-n4" />
|
|
<div class="row mb-4">
|
|
<div class="col-md-auto d-flex gap-2">
|
|
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="offcanvas" data-bs-target="#offcanvasAddKolom" >
|
|
<i class="ti tabler-plus me-1"></i> Tambah
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-4">
|
|
<div class="col-md-12 mb-4 form-control-validation">
|
|
|
|
<div class="table-responsive text-nowrap mb-4">
|
|
<table class="table table-hover">
|
|
<thead class="border-top">
|
|
<tr>
|
|
<th>No</th>
|
|
<th>Nama Kolom</th>
|
|
<th>Label</th>
|
|
<th>Jenis Data</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse($tabel->kolom as $index => $kolom)
|
|
<tr>
|
|
<td>{{ $loop->iteration }}</td>
|
|
<td><span class="text-heading">{{ $kolom->kolom }}</span></td>
|
|
<td><span class="text-muted">{{ $kolom->label }}</span></td>
|
|
<td><span class="text-muted">{{ $kolom->tipe }}</span></td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
@if (!$loop->first)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-up"
|
|
data-id="{{ $kolom->id }}">
|
|
<i class="ti tabler-arrow-up"></i>
|
|
</button>
|
|
@endif
|
|
@if (!$loop->last)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-down"
|
|
data-id="{{ $kolom->id }}">
|
|
<i class="ti tabler-arrow-down"></i>
|
|
</button>
|
|
@endif
|
|
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill edit-record" data-id="{{ $kolom->id }}"><i class="ti tabler-edit ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $kolom->id }}" data-nama="{{ $kolom->nama }}"><i class="ti tabler-trash ti-md"></i></a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="5" class="text-center py-4">Tidak ada kolom ditemukan.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h6 class="mb-3">Informasi Ringkasan Tabel</h6>
|
|
|
|
<hr class="my-4 mx-n4" />
|
|
<div class="row mb-4">
|
|
<div class="col-md-auto d-flex gap-2">
|
|
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="offcanvas" data-bs-target="#offcanvasAddRingkasan" >
|
|
<i class="ti tabler-plus me-1"></i> Tambah
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-4">
|
|
<div class="col-md-12 mb-4 form-control-validation">
|
|
|
|
<div class="table-responsive text-nowrap mb-4">
|
|
<table class="table table-hover">
|
|
<thead class="border-top">
|
|
<tr>
|
|
<th>No</th>
|
|
<th>Heading / Subheading</th>
|
|
<th>Query</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse($tabel->ringkasan as $index => $ringkasan)
|
|
<tr>
|
|
<td>{{ $loop->iteration }}</td>
|
|
<td>
|
|
<span class="text-muted">{{ $ringkasan->heading }}</span><br>
|
|
<small class="text-muted">{{ $ringkasan->subheading }}</small>
|
|
</td>
|
|
<td><span class="text-muted">{{ $ringkasan->query_ringkasan }}</span></td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
@if (!$loop->first)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-up-ringkasan"
|
|
data-id="{{ $ringkasan->id }}">
|
|
<i class="ti tabler-arrow-up"></i>
|
|
</button>
|
|
@endif
|
|
@if (!$loop->last)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-down-ringkasan"
|
|
data-id="{{ $ringkasan->id }}">
|
|
<i class="ti tabler-arrow-down"></i>
|
|
</button>
|
|
@endif
|
|
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill edit-ringkasan" data-id="{{ $ringkasan->id }}"><i class="ti tabler-edit ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-ringkasan" data-id="{{ $ringkasan->id }}" data-nama="{{ $ringkasan->heading }}"><i class="ti tabler-trash ti-md"></i></a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="5" class="text-center py-4">Tidak ada ringkasan ditemukan.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4 text-end">
|
|
<a href="{{ route('tabel.index') }}" class="btn btn-label-secondary me-2">Kembali</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
@include('ekosistem.kolom-basis-data.add')
|
|
@include('ekosistem.kolom-basis-data.edit')
|
|
@include('ekosistem.ringkasan-basis-data.add')
|
|
@include('ekosistem.ringkasan-basis-data.edit')
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
'use strict';
|
|
$(document).ready(function () {
|
|
$(".move-up").click(function (e) {
|
|
e.preventDefault();
|
|
let id = $(this).data('id');
|
|
|
|
$.post("{{ route('tabel.kolom.move-up', [$tabel->id, ':id']) }}".replace(':id', id), {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'PUT'
|
|
}, function (res) {
|
|
if (res.status === 'success') {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".move-down").click(function (e) {
|
|
e.preventDefault();
|
|
let id = $(this).data('id');
|
|
|
|
$.post("{{ route('tabel.kolom.move-down', [$tabel->id, ':id']) }}".replace(':id', id), {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'PUT'
|
|
}, function (res) {
|
|
if (res.status === 'success') {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".delete-record").click(function (e) {
|
|
e.preventDefault();
|
|
const id = $(this).data('id');
|
|
const name = $(this).data('nama');
|
|
|
|
Swal.fire({
|
|
title: 'Hapus?',
|
|
text: `Kolom ${name} akan dihapus!`,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Hapus!',
|
|
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
|
buttonsStyling: false
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
$.ajax({
|
|
url: "{{ route('tabel.kolom.destroy', [$tabel->id, ':id']) }}".replace(':id', id),
|
|
type: 'DELETE',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function () {
|
|
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
|
|
.then(() => window.location.reload());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".move-up-ringkasan").click(function (e) {
|
|
e.preventDefault();
|
|
let id = $(this).data('id');
|
|
|
|
$.post("{{ route('tabel.ringkasan.move-up', [$tabel->id, ':id']) }}".replace(':id', id), {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'PUT'
|
|
}, function (res) {
|
|
if (res.status === 'success') {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".move-down-ringkasan").click(function (e) {
|
|
e.preventDefault();
|
|
let id = $(this).data('id');
|
|
|
|
$.post("{{ route('tabel.ringkasan.move-down', [$tabel->id, ':id']) }}".replace(':id', id), {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'PUT'
|
|
}, function (res) {
|
|
if (res.status === 'success') {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".delete-ringkasan").click(function (e) {
|
|
e.preventDefault();
|
|
const id = $(this).data('id');
|
|
const name = $(this).data('nama');
|
|
|
|
Swal.fire({
|
|
title: 'Hapus?',
|
|
text: `Ringkasan ${name} akan dihapus!`,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Hapus!',
|
|
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
|
buttonsStyling: false
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
$.ajax({
|
|
url: "{{ route('tabel.ringkasan.destroy', [$tabel->id, ':id']) }}".replace(':id', id),
|
|
type: 'DELETE',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function () {
|
|
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
|
|
.then(() => window.location.reload());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
@endpush |