193 lines
9.0 KiB
PHP
193 lines
9.0 KiB
PHP
@php
|
|
function decimalToDms($decimal, $type = 'lat')
|
|
{
|
|
if ($decimal === null || $decimal === '') {
|
|
return '';
|
|
}
|
|
|
|
$direction = $decimal >= 0 ? ($type === 'lat' ? 'N' : 'E') : ($type === 'lat' ? 'S' : 'W');
|
|
$decimal = abs($decimal);
|
|
|
|
$degree = floor($decimal);
|
|
$minuteFloat = ($decimal - $degree) * 60;
|
|
$minute = floor($minuteFloat);
|
|
$second = round(($minuteFloat - $minute) * 60, 2);
|
|
|
|
return "{$degree}°{$minute}'{$second}\"{$direction}";
|
|
}
|
|
@endphp
|
|
|
|
@extends('admin.template')
|
|
|
|
@section('title', 'Edit Data TPS')
|
|
|
|
@section('content')
|
|
<div class="content-wrapper">
|
|
<div class="row">
|
|
<div class="col-12 grid-margin stretch-card">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<h4 class="card-title">Edit Data TPS</h4>
|
|
<p class="card-description">Form edit data Tempat Pembuangan Sampah</p>
|
|
|
|
<form action="{{ route('admin.tps.update', $tps->id_tps) }}" method="POST"
|
|
enctype="multipart/form-data" class="forms-sample">
|
|
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
<div class="form-group">
|
|
<label>Nama TPS</label>
|
|
<input type="text" name="nama_tps"
|
|
class="form-control @error('nama_tps') is-invalid @enderror"
|
|
value="{{ old('nama_tps', $tps->nama_tps) }}">
|
|
|
|
@error('nama_tps')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Alamat</label>
|
|
<input type="text" name="alamat_tps"
|
|
class="form-control @error('alamat_tps') is-invalid @enderror"
|
|
value="{{ old('alamat_tps', $tps->alamat_tps) }}">
|
|
|
|
@error('alamat_tps')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Kategori TPS</label>
|
|
<select name="kategori_tps_id"
|
|
class="form-control @error('kategori_tps_id') is-invalid @enderror">
|
|
|
|
<option value="">-- Pilih Kategori --</option>
|
|
|
|
@foreach ($kategori as $item)
|
|
<option value="{{ $item->id_kategori_tps }}"
|
|
{{ old('kategori_tps_id', $tps->kategori_tps_id) == $item->id_kategori_tps ? 'selected' : '' }}>
|
|
{{ $item->nama_kategori }}
|
|
</option>
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
@error('kategori_tps_id')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Tahun Pembuatan</label>
|
|
<input type="number" name="tahun_pembuatan"
|
|
class="form-control @error('tahun_pembuatan') is-invalid @enderror"
|
|
value="{{ old('tahun_pembuatan', $tps->tahun_pembuatan) }}">
|
|
|
|
@error('tahun_pembuatan')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Kapasitas TPS</label>
|
|
<div class="input-group">
|
|
<input type="number" name="kapasitas_tps"
|
|
class="form-control @error('kapasitas_tps') is-invalid @enderror"
|
|
value="{{ old('kapasitas_tps', $tps->kapasitas_tps) }}">
|
|
<div class="input-group-append">
|
|
<span class="input-group-text">ton/hari</span>
|
|
</div>
|
|
</div>
|
|
|
|
@error('kapasitas_tps')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Status TPS</label>
|
|
<select name="status_tps" class="form-control @error('status_tps') is-invalid @enderror">
|
|
|
|
<option value="Aktif"
|
|
{{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>Aktif
|
|
</option>
|
|
<option value="Tidak Aktif"
|
|
{{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}>Tidak
|
|
Aktif</option>
|
|
<option value="Pembangunan"
|
|
{{ old('status_tps', $tps->status_tps) == 'Pembangunan' ? 'selected' : '' }}>
|
|
Pembangunan</option>
|
|
|
|
</select>
|
|
|
|
@error('status_tps')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Latitude</label>
|
|
<input type="text" name="latitude"
|
|
class="form-control @error('latitude') is-invalid @enderror"
|
|
value="{{ old('latitude', decimalToDms($tps->latitude, 'lat')) }}"
|
|
placeholder="Contoh: 7°35'17.25S">
|
|
|
|
@error('latitude')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Longitude</label>
|
|
<input type="text" name="longitude"
|
|
class="form-control @error('longitude') is-invalid @enderror"
|
|
value="{{ old('longitude', decimalToDms($tps->longitude, 'lng')) }}"
|
|
placeholder="Contoh: 111°55'0.97E">
|
|
|
|
@error('longitude')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Foto TPS</label>
|
|
|
|
<input type="file" name="foto_tps"
|
|
class="file-upload-default @error('foto_tps') is-invalid @enderror">
|
|
|
|
<div class="input-group col-xs-12">
|
|
<input type="text" class="form-control file-upload-info" disabled
|
|
placeholder="Upload Foto TPS">
|
|
<span class="input-group-append">
|
|
<button class="file-upload-browse btn btn-primary" type="button">Upload</button>
|
|
</span>
|
|
</div>
|
|
|
|
@error('foto_tps')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
|
|
@if ($tps->foto_tps)
|
|
<div class="mt-2">
|
|
<img src="{{ asset('storage/' . $tps->foto_tps) }}" width="250"
|
|
class="img-thumbnail">
|
|
</div>
|
|
@endif
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
|
<a href="{{ route('admin.tps.index') }}" class="btn btn-light">Batal</a>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|