Files
database-pertani-web/resources/views/koperasi/profil/index.blade.php
T
2026-09-03 13:17:16 +07:00

160 lines
7.2 KiB
PHP

@extends('layout.main')
@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
<div class="d-flex flex-row gap-3 mb-4">
<div class="w-25">
<x-summary-card
title="Pengurus Koperasi"
count="{{ $totalPengurus ?? 0 }}"
subtitle="Total responden terdata"
icon="user-check"
color="primary"
/>
</div>
<div class="w-25">
<x-summary-card
title="Koperasi Terdata"
count="{{ $totalKoperasi ?? 0 }}"
subtitle="Unit Koperasi yang terdata"
icon="map-pin"
color="success"
/>
</div>
<div class="w-25">
<x-summary-card
title="Jabatan/Peran"
count="{{ $totalJabatan ?? 0 }}"
subtitle="Jenis jabatan/peran terdata"
icon="briefcase"
color="info"
/>
</div>
</div>
<div class="card">
<div class="card-header border-bottom">
<h5 class="card-title mb-0">Data Pengurus Koperasi</h5>
</div>
<div class="card-body border-bottom pt-4">
<form method="GET" action="{{ route('koperasi.pengurus.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>
</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..." value="{{ request('search') }}">
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
</div>
<a href="{{ route('koperasi.pengurus.create') }}" class="btn btn-sm btn-primary">
<i class="ti tabler-plus me-1"></i> Tambah
</a>
</div>
</form>
</div>
<div class="table-responsive text-nowrap">
<table class="table table-hover">
<thead class="border-top">
<tr>
<th>No</th>
<th>Nama Pengurus</th>
<th>Posisi</th>
<th>Nama Koperasi</th>
<th>Jenis Koperasi</th>
<th>Skala Operasi</th>
@if($showEnumerator ?? true)
<th>Nama Enumerator</th>
@endif
<th>Aksi</th>
</tr>
</thead>
<tbody>
@forelse($pengurus ?? [] as $item)
<tr>
<td>{{ (($pengurus->firstItem() ?? 1) - 1) + $loop->iteration }}</td>
<td><span class="text-heading">{{ $item->nama_lengkap }}</span></td>
<td><span class="text-muted">{{ $item->posisi_dalam_koperasi }}</span></td>
<td><span class="text-muted">{{ $item->nama_koperasi }}</span></td>
<td><span class="text-muted">{{ $item->jenis_koperasi }}</span></td>
<td><span class="text-muted">{{ $item->skala_operasi }}</span></td>
@if($showEnumerator ?? true)
<td><span class="text-muted">{{ $item->creator?->name ?? '-' }}</span></td>
@endif
<td>
<div class="d-flex align-items-center">
<a href="{{ route('koperasi.pengurus.edit', $item->id) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record">
<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="{{ $item->id }}" data-nama="{{ $item->nama_lengkap }}">
<i class="ti tabler-trash ti-md"></i>
</a>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="{{ ($showEnumerator ?? true) ? 8 : 7 }}" 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">
@if(isset($pengurus) && $pengurus instanceof \Illuminate\Pagination\LengthAwarePaginator && $pengurus->hasPages())
{{ $pengurus->appends(request()->query())->links('pagination::bootstrap-5') }}
@endif
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
'use strict';
const csrfToken = "{{ csrf_token() }}";
$(document).ready(function () {
$(document).on('click', '.delete-record', function () {
const id = $(this).data('id');
const name = $(this).data('nama');
Swal.fire({
title: 'Apakah Anda yakin?',
text: `Profil "${name}" akan dihapus secara permanen!`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal',
customClass: { confirmButton: 'btn btn-primary me-3', cancelButton: 'btn btn-label-secondary' },
buttonsStyling: false
}).then(function (result) {
if (result.value) {
$.ajax({
url: '{{ route('koperasi.pengurus.destroy', ':id') }}'.replace(':id', id),
type: 'DELETE' ,
headers: { 'X-CSRF-TOKEN': csrfToken },
success: function (res) {
Swal.fire({ icon: 'success', title: 'Terhapus!', text: res.message, showConfirmButton: false, timer: 1500 })
.then(() => window.location.reload());
},
error: () => Swal.fire({ icon: 'error', title: 'Gagal!', text: 'Terjadi kesalahan sistem.' })
});
}
});
});
});
</script>
@endpush