pembuatan basic data surveyor
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
@endpush
|
||||
|
||||
|
||||
<form action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('debitur.store') }}" method="POST"
|
||||
<form id="debiturForm" action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('debitur.store') }}" method="POST"
|
||||
class="grid gap-5">
|
||||
@if (isset($debitur->id))
|
||||
<input type="hidden" name="id" value="{{ $debitur->id }}">
|
||||
@@ -478,6 +478,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
||||
<button type="submit" class="btn btn-success">
|
||||
Save
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
@@ -521,4 +530,71 @@
|
||||
window.onload = getUserLocation;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Fungsi untuk menyimpan data ke localStorage saat ada perubahan input
|
||||
|
||||
|
||||
const formElement = document.getElementById('debiturForm');
|
||||
|
||||
// Mengambil nilai dari localStorage saat halaman dimuat
|
||||
window.onload = () => {
|
||||
const storedData = localStorage.getItem('debiturData');
|
||||
if (storedData) {
|
||||
const formData = JSON.parse(storedData);
|
||||
// Mengisi nilai untuk elemen select
|
||||
for (const [key, value] of Object.entries(formData)) {
|
||||
const inputElement = formElement.querySelector(`[name="${key}"]`);
|
||||
if (inputElement) {
|
||||
if (inputElement.tagName === 'SELECT') {
|
||||
inputElement.value = value; // Atur nilai select
|
||||
} else if (inputElement.type === 'radio') {
|
||||
const radioButton = document.getElementById(`${key}${value.charAt(0).toUpperCase() + value.slice(1)}`);
|
||||
if (radioButton) {
|
||||
radioButton.checked = true; // Atur radio button yang sesuai sebagai checked
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Simpan data ke localStorage dalam bentuk JSON
|
||||
formElement.addEventListener('change', () => {
|
||||
const formData = {};
|
||||
const inputs = formElement.querySelectorAll('input, select');
|
||||
|
||||
inputs.forEach(input => {
|
||||
if (input.type === 'radio' && input.checked) {
|
||||
formData[input.name] = input.value; // Hanya ambil nilai radio yang terpilih
|
||||
} else if (input.type !== 'radio') {
|
||||
formData[input.name] = input.value; // Ambil nilai dari elemen lain
|
||||
}
|
||||
});
|
||||
|
||||
localStorage.setItem('debiturData', JSON.stringify(formData)); // Simpan objek sebagai JSON
|
||||
});
|
||||
|
||||
// Opsi: Reset localStorage saat form disubmit
|
||||
formElement.onsubmit = () => {
|
||||
localStorage.removeItem('debiturData'); // Menghapus data spesifik dari localStorage
|
||||
};
|
||||
|
||||
|
||||
// Opsi: Reset localStorage saat form disubmit
|
||||
document.getElementById('debiturForm').onsubmit = (event) => {
|
||||
event.preventDefault(); // Mencegah pengiriman form
|
||||
|
||||
// Menyimpan semua input ke localStorage
|
||||
inputs.forEach(input => {
|
||||
localStorage.setItem(input.name, input.value);
|
||||
});
|
||||
|
||||
// Opsional: Tampilkan pesan bahwa data telah disimpan
|
||||
alert('Data telah disimpan ke localStorage!');
|
||||
|
||||
// Jika ingin menghapus localStorage, uncomment baris di bawah
|
||||
// localStorage.clear();
|
||||
};
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<option value="">Select Hadap Mata Angin</option>
|
||||
@if (isset($arahMataAngin))
|
||||
@foreach ($arahMataAngin as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -56,7 +56,7 @@
|
||||
<option value="">Select Bentuk Tanah</option>
|
||||
@if (isset($bentukTanah))
|
||||
@foreach ($bentukTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -76,7 +76,7 @@
|
||||
<option value="">Select Kontur Tanah</option>
|
||||
@if (isset($konturTanah))
|
||||
@foreach ($konturTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -98,7 +98,7 @@
|
||||
<option value="">Select Ketinggian Dengan Jalan</option>
|
||||
@if (isset($ketinggianTanah))
|
||||
@foreach ($ketinggianTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -142,7 +142,7 @@
|
||||
<option value="">Select Posisi Kavling</option>
|
||||
@if (isset($posisiKavling))
|
||||
@foreach ($posisiKavling as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -207,7 +207,7 @@
|
||||
<option value="">Select Posisi Kavling</option>
|
||||
@if (isset($kondisiFisikTanah))
|
||||
@foreach ($kondisiFisikTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -258,7 +258,7 @@
|
||||
<option value="">Select Jenis Bangunan</option>
|
||||
@if (isset($jenisBangunan))
|
||||
@foreach ($jenisBangunan as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -279,7 +279,7 @@
|
||||
<option value="">Select Kondisi Bangunan</option>
|
||||
@if (isset($kondisiBangunan))
|
||||
@foreach ($kondisiBangunan as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -300,7 +300,7 @@
|
||||
<option value="">Select Sifat Bangunan</option>
|
||||
@if (isset($sifatBangunan))
|
||||
@foreach ($sifatBangunan as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -330,7 +330,7 @@
|
||||
@if (isset($spekBangunan))
|
||||
@foreach ($spekBangunan as $spek)
|
||||
@if ($spek->spek_kategori_bagunan_id == $item->id)
|
||||
<option value="{{ $spek->id }}">{{ $spek->name }}
|
||||
<option value="{{ $spek->name }}">{{ $spek->name }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
63
resources/views/surveyor/data/form.blade.php
Normal file
63
resources/views/surveyor/data/form.blade.php
Normal file
@@ -0,0 +1,63 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
{{-- @section('breadcrumbs')
|
||||
{{ Breadcrumbs::render(request()->route()->getName()) }}
|
||||
@endsection --}}
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
@if (isset($model->id))
|
||||
<form action="{{ route('basicdata.updateData', ['type' => $header[1], 'id' => $model->id]) }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ $model->id ?? '' }}">
|
||||
@method('PUT')
|
||||
@else
|
||||
<form method="POST" action="{{ route('basicdata.storeData', ['type' => $header[1]]) }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<input type="hidden" name="action" value="{{ $header[1] }}">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($jenisAset->id) ? 'Edit' : 'Tambah' }} {{ $header[0] }}
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.' . $header[1] . '.index') }}" class="btn btn-xs btn-info">
|
||||
<i class="ki-filled ki-exit-left"></i> Back
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Code
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('code') border-danger bg-danger-light @enderror" type="text"
|
||||
name="code" value="{{ $model->code ?? '' }}" >
|
||||
@error('code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Name
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger bg-danger-light @enderror" type="text"
|
||||
name="name" value="{{ $model->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
153
resources/views/surveyor/data/index.blade.php
Normal file
153
resources/views/surveyor/data/index.blade.php
Normal file
@@ -0,0 +1,153 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
{{-- @section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('surveyor.bentuk-tanah') }}
|
||||
@endsection --}}
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="false" id="data-table" data-api-url="{{ route('basicdata.datatablesSurveyory', ['type' => $header[0] ]) }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar {{$header[0]}}
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||
<div class="flex">
|
||||
<label class="input input-sm"> <i class="ki-filled ki-magnifier"> </i>
|
||||
<input placeholder="Search {{$header[0]}}" id="search" type="text" value="">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href=""> Export to Excel </a>
|
||||
|
||||
@php
|
||||
$href = route('basicdata.createData', ['type' => $header[1]]);
|
||||
@endphp
|
||||
|
||||
<a class="btn btn-sm btn-primary" href="{{$href}}"> Tambah {{$header[0]}} </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm" data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="code">
|
||||
<span class="sort"> <span class="sort-label"> Code </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="name">
|
||||
<span class="sort"> <span class="sort-label"> Jenis Aset </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
||||
<div class="flex items-center gap-2">
|
||||
Show
|
||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<span data-datatable-info="true"> </span>
|
||||
<div class="pagination" data-datatable-pagination="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
function deleteData(data) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax(`basic-data/deleteData/${data}/{{$header[1]}}`, {
|
||||
type: 'DELETE'
|
||||
}).then((response) => {
|
||||
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the file.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#data-table');
|
||||
const searchInput = document.getElementById('search');
|
||||
|
||||
const header = '{{$header[1]}}';
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
columns: {
|
||||
select: {
|
||||
render: (item, data, context) => {
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.className = 'checkbox checkbox-sm';
|
||||
checkbox.type = 'checkbox';
|
||||
checkbox.value = data.id.toString();
|
||||
checkbox.setAttribute('data-datatable-row-check', 'true');
|
||||
return checkbox.outerHTML.trim();
|
||||
},
|
||||
},
|
||||
code: {
|
||||
title: 'Code',
|
||||
},
|
||||
name: {
|
||||
title: 'Jenis Aset',
|
||||
},
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="basic-data/${header}/${data.id}">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -176,14 +176,7 @@
|
||||
@include('lpj::surveyor.components.data-pembanding')
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
||||
<button type="submit" class="btn btn-success">
|
||||
Save
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user