Files
database-pertani-web/resources/views/core/program-komoditas/index.blade.php
T

113 lines
5.3 KiB
PHP

@extends('layout.main')
@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
<div class="card">
<div class="card-body border-bottom">
<form method="GET" action="{{ route('program.index') }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
<div class="col-md-auto">
<div class="d-flex align-items-center">
<label class="me-2 text-nowrap">Show</label>
<select name="per_page" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
<option value="10" {{ request('per_page') == 10 ? 'selected' : '' }}>10</option>
<option value="25" {{ request('per_page') == 25 ? 'selected' : '' }}>25</option>
<option value="50" {{ request('per_page') == 50 ? 'selected' : '' }}>50</option>
</select>
<label class="ms-2 text-nowrap">entries</label>
</div>
</div>
<div class="col-md-auto d-flex gap-2">
<div class="input-group input-group-sm w-auto">
<input type="text" name="search" class="form-control" placeholder="Cari Nama Program..." value="{{ request('search') }}">
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
</div>
<button type="button" class="btn btn-sm btn-primary add-new" data-bs-toggle="offcanvas" data-bs-target="#offcanvasAddProgram">
<i class="ti tabler-plus me-1"></i> Tambah
</button>
</div>
</form>
</div>
<div class="table-responsive text-nowrap">
<table class="table table-hover">
<thead class="border-top">
<tr>
<th>No</th>
<th>Nama Program</th>
<th>Subdomain</th>
<th>Tahun</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@forelse($program as $index => $prg)
<tr>
<td>{{ $program->firstItem() + $index }}</td>
<td><span class="text-heading">{{ $prg->nama }}</span></td>
<td><span class="text-muted">{{ $prg->sub_domain }}</span></td>
<td><span class="text-muted">{{ $prg->tahun }}</span></td>
<td>
<div class="d-flex align-items-center">
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill edit-record" data-id="{{ $prg->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="{{ $prg->id }}" data-nama="{{ $prg->nama }}"><i class="ti tabler-trash ti-md"></i></a>
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill view-record" data-id="{{ $prg->id }}"><i class="ti tabler-eye ti-md"></i></a>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="text-center py-4">Tidak ada data ditemukan.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="card-footer d-flex justify-content-center justify-content-md-end border-top">
{{ $program->appends(request()->query())->links('pagination::bootstrap-5') }}
</div>
</div>
@include('core.program.add')
@include('core.program.view')
@include('core.program.edit')
</div>
@endsection
@push('scripts')
<script>
'use strict';
const csrfToken = "{{ csrf_token() }}";
$(document).ready(function () {
$('.delete-record').on('click', function (e) {
e.preventDefault();
const id = $(this).data('id');
const name = $(this).data('nama');
Swal.fire({
title: 'Hapus?',
text: `Provinsi ${name} akan dihapus!`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Ya, Hapus!',
customClass: { confirmButton: 'btn btn-primary me-3', cancelButton: 'btn btn-label-secondary' },
buttonsStyling: false
}).then(function (result) {
if (result.value) {
$.ajax({
url: `/provinsi/${id}`,
type: 'DELETE',
headers: { 'X-CSRF-TOKEN': csrfToken },
success: function () {
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
.then(() => window.location.reload());
}
});
}
});
});
});
</script>
@endpush