Merge branch 'main' of https://git.probindo.com/Probindo/database-pertani-web
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
<option value="datetime">Datetime</option>
|
||||
<option value="text">Text</option>
|
||||
<option value="foreign_key">Relasi</option>
|
||||
<option value="enum">Enum</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation" id="relasi-form-tabel" style="display: none;">
|
||||
@@ -49,6 +50,11 @@
|
||||
<label class="form-label" for="add-kolom-relasi-kolom-label">Kolom Relasi (Label)<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="add-kolom-relasi-kolom-label" name="relasi_kolom_label" placeholder="Cth: Nama Petani" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation" id="enum-form-opsi" style="display: none;">
|
||||
<label class="form-label" for="add-kolom-enum-opsi" >Opsi Enum<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="add-kolom-enum-opsi" name="enum_opsi" value="1"
|
||||
placeholder='Cth: [{"label": "Satu Pilihan", "value": "satu"}, {"label": "Dua Saja", "value": "dua"}]'></textarea>
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="add-kolom-validasi">Validasi<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="add-kolom-validasi" name="validasi" value="1" placeholder="Cth: required"></textarea>
|
||||
@@ -78,8 +84,14 @@
|
||||
$('#relasi-form-kolom').hide();
|
||||
$('#relasi-form-kolom-label').hide();
|
||||
}
|
||||
if ($(this).val() === 'enum') {
|
||||
$('#enum-form-opsi').show();
|
||||
} else {
|
||||
$('#enum-form-opsi').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$.validator.addMethod("snakecase", function(value, element) {
|
||||
return this.optional(element) || /^[a-z0-9]+(_[a-z0-9]+)*$/.test(value);
|
||||
}, "Gunakan format snake_case (huruf kecil dan underscore)");
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form id="addNewPetaniForm" action="{{ route('petani-cpm.store') }}" method="POST" >
|
||||
<form id="addNewPetaniForm" action="{{ route('petani-cpm.store', ['program_id' => $program->id]) }}" method="POST" >
|
||||
@csrf
|
||||
|
||||
@if ($errors->any())
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form id="addNewPetaniForm" action="{{ route('petani-cpm.update', $petani->id) }}" method="POST" >
|
||||
<form id="addNewPetaniForm" action="{{ route('petani-cpm.update', [$petani->id, 'program_id' => $program->id]) }}" method="POST" >
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body border-bottom pt-4">
|
||||
<form method="GET" action="{{ route('tabel.index') }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
|
||||
<form method="GET" action="{{ route('petani-cpm.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>
|
||||
@@ -84,11 +84,26 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-auto d-flex gap-2">
|
||||
@if (app()->has('SystemProgram'))
|
||||
@else
|
||||
<div class="col-md-auto">
|
||||
<div class="d-flex align-items-center">
|
||||
<label class="me-2 text-nowrap">Program</label>
|
||||
<select name="program_id" class="form-select form-select-sm w-auto" onchange="this.form.submit()" id="select-program">
|
||||
<option value="">Pilih Program</option>
|
||||
@foreach($programList as $prog)
|
||||
<option value="{{ $prog->id }}" {{ request('program_id') == $prog->id ? 'selected' : '' }}>{{ $prog->nama }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="input-group input-group-sm w-auto">
|
||||
<input type="text" name="search" class="form-control" placeholder="Cari Nama Petani..." value="{{ request('search') }}">
|
||||
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
|
||||
</div>
|
||||
<a href="{{ route('petani-cpm.create') }}" class="btn btn-sm btn-primary">
|
||||
<a href="{{ route('petani-cpm.create', ['program_id' => request('program_id')]) }}" class="btn btn-sm btn-primary"
|
||||
style="display: {{ request('program_id') ? 'flex' : 'none' }};">
|
||||
<i class="ti tabler-plus me-1"></i> Tambah
|
||||
</a>
|
||||
</div>
|
||||
@@ -117,7 +132,7 @@
|
||||
<td><span class="text-muted">{{ $p->desaKelurahan?->nama }}, {{ $p->desaKelurahan?->kecamatan?->nama }}, {{ $p->desaKelurahan?->kecamatan?->kabupatenKota?->nama }}, {{ $p->desaKelurahan?->kecamatan?->kabupatenKota?->provinsi?->nama }}</span></td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<a href="{{ route('petani-cpm.edit', $p->id) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
|
||||
<a href="{{ route('petani-cpm.edit', [$p->id, 'program_id' => $p->program_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="{{ $p->id }}" data-nama="{{ $p->nama }}"><i class="ti tabler-trash ti-md"></i></a>
|
||||
<a href="{{ route('petani-cpm.show', $p->id) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
|
||||
</div>
|
||||
|
||||
@@ -47,6 +47,12 @@
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@elseif($k->tipe == 'enum')
|
||||
<select class="form-select tipe-fk @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
|
||||
@foreach($k->enum_opsi as $opsi)
|
||||
<option value="{{ $opsi['value'] }}" {{ old($k->kolom) == $opsi['value'] ? 'selected' : '' }}>{{ $opsi['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}"
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) }}" />
|
||||
|
||||
@@ -64,6 +64,12 @@
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@elseif($k->tipe == 'enum')
|
||||
<select class="form-select tipe-fk @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
|
||||
@foreach($k->enum_opsi as $opsi)
|
||||
<option value="{{ $opsi['value'] }}" {{ old($k->kolom) ?? $value['value_'.$k->tipe] == $opsi['value'] ? 'selected' : '' }}>{{ $opsi['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}"
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
@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->label }}</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form id="addUpdateDataForm" action="{{ route('tabel.data.update', [$tabel->id, $value_id, 'program_id' => $program->id]) }}" method="POST" >
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<h6 class="mb-3">Informasi {{ $tabel->label }}</h6>
|
||||
@if (!$program)
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<label class="form-label" for="add-data-program">Program<span class="text-danger">*</span></label>
|
||||
<select name="program_id" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
|
||||
<option value="">Pilih Program</option>
|
||||
@foreach($programList as $prog)
|
||||
<option value="{{ $prog->id }}" {{ request('program_id') == $prog->id ? 'selected' : '' }}>{{ $prog->nama }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
@foreach($kolom as $k)
|
||||
<?php
|
||||
$value = $values->where('kolom_id', $k->id)->first();
|
||||
?>
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<label class="form-label" for="add-data-{{ $k->kolom }}">{{ $k->label }}<span class="text-danger">*</span></label>
|
||||
@if($k->tipe == 'varchar')
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
|
||||
@elseif($k->tipe == 'text')
|
||||
<textarea class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}">{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}</textarea>
|
||||
@elseif($k->tipe == 'integer')
|
||||
<input type="number" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" step="1" />
|
||||
@elseif($k->tipe == 'float')
|
||||
<input type="number" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" step="any" />
|
||||
@elseif($k->tipe == 'date')
|
||||
<input type="date" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
|
||||
@elseif($k->tipe == 'datetime')
|
||||
<input type="datetime-local" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
|
||||
@elseif($k->tipe == 'boolean')
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ (old($k->kolom) ?? $value['value_'.$k->tipe]) == 1 ? 'Ya' : 'Tidak' }}" />
|
||||
@elseif($k->tipe == 'foreign_key')
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ (old($k->kolom) ?? $value['value_relasi_label']) }}" />
|
||||
@elseif($k->tipe == 'enum')
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ (old($k->kolom) ?? $value['value_enum_label']) }}" />
|
||||
@else
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" readonly
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
|
||||
@endif
|
||||
@error($k->kolom)<div class="error invalid-feedback">{{ $message }}</div>@enderror
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<a href="{{ route('tabel.data.index', [$tabel->id, 'program_id' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
'use strict';
|
||||
$(document).ready(function () {
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user