update
parent
cc00af9ed3
commit
0f0fe74f1a
|
|
@ -15,6 +15,7 @@ use App\Models\LogUserActivity;
|
||||||
use App\Models\ReferenceUnit;
|
use App\Models\ReferenceUnit;
|
||||||
use App\Models\SettingForm;
|
use App\Models\SettingForm;
|
||||||
use App\Models\SettingFormDetail;
|
use App\Models\SettingFormDetail;
|
||||||
|
use App\Models\ActivityFormDetail;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Services\Activity\FormService;
|
use App\Services\Activity\FormService;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
@ -161,6 +162,64 @@ class FormController implements HasMiddleware
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saveSingle(Request $request, $sector, $code)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
// 'data' => 'required|array',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Filter by Year
|
||||||
|
$inventoryYear = $request->input('inventoryYear') ?? date('Y');
|
||||||
|
$instansi = request('instansi') ?? null;
|
||||||
|
if ($instansi && $instansi != 'all' && $instansi != 'none') {
|
||||||
|
$agency = Agency::where('name', $instansi)->rowActive()->first();
|
||||||
|
$instansi = $agency ? $agency->id : null;
|
||||||
|
} else {
|
||||||
|
$instansi = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->input('data');
|
||||||
|
$unitCodes = $request->input('unit_code');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$form = ActivityForm::where('agency_id',$instansi)->first();
|
||||||
|
if(!@$form){
|
||||||
|
$Saveform = new ActivityForm;
|
||||||
|
$Saveform->sector = $sector;
|
||||||
|
$Saveform->form_code = $code;
|
||||||
|
$Saveform->inventory_year = $request->inventoryYear;
|
||||||
|
$Saveform->verification_status = 'unverified';
|
||||||
|
$Saveform->validation_status = 'unvalidated';
|
||||||
|
$Saveform->lock_status = 'open';
|
||||||
|
$Saveform->agency_id = $instansi;
|
||||||
|
$Saveform->save();
|
||||||
|
}
|
||||||
|
foreach($request->unit_code as $k => $valCode){
|
||||||
|
// dd($request->value[$k]);
|
||||||
|
$detail = ActivityFormDetail::updateOrCreate([
|
||||||
|
|
||||||
|
'form_id' => @$form ? @$form->id : @$Saveform->id,
|
||||||
|
'activity_year' => $request->inventoryYear,
|
||||||
|
'activity_code' => $k,
|
||||||
|
'activity_unit_code' => $valCode,
|
||||||
|
],[
|
||||||
|
'activity_value' => $request->value[$k],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($detail);
|
||||||
|
|
||||||
|
|
||||||
|
// $this->formService->save($sector, $code, $inventoryYear, $data, $unitCodes, $instansi);
|
||||||
|
return redirect()->back()->with('success', 'Data berhasil disimpan.');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return redirect()->back()->withErrors(['error' => 'Data gagal disimpan. Mohon dicoba kembali.' . $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function convertUnit(Request $request)
|
public function convertUnit(Request $request)
|
||||||
{
|
{
|
||||||
$fromUnit = $request->get('from');
|
$fromUnit = $request->get('from');
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,7 @@ namespace App\Models;
|
||||||
class ActivityForm extends SigdModel
|
class ActivityForm extends SigdModel
|
||||||
{
|
{
|
||||||
protected $table = 'form';
|
protected $table = 'form';
|
||||||
protected $fillable = [
|
protected $guarded = [];
|
||||||
'id', 'sector', 'form_code', 'inventory_year', 'verification_status', 'verified_at', 'verified_by',
|
|
||||||
'validation_status', 'validated_at', 'validated_by', 'lock_status',
|
|
||||||
'row_status', 'created_by', 'updated_by',
|
|
||||||
'agency_id',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function form()
|
public function form()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,19 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||||
|
|
||||||
|
|
||||||
class ActivityFormDetail extends SigdModel
|
class ActivityFormDetail extends SigdModel
|
||||||
{
|
{
|
||||||
|
use HasUuids;
|
||||||
|
|
||||||
protected $table = 'form_detail';
|
protected $table = 'form_detail';
|
||||||
protected $fillable = [
|
|
||||||
'id', 'form_id', 'activity_year', 'activity_code', 'activity_value', 'activity_value_str',
|
public $incrementing = false;
|
||||||
'activity_unit_code', 'row_status', 'created_by', 'updated_by',
|
protected $keyType = 'string';
|
||||||
];
|
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
public function activity()
|
public function activity()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class FormService extends SigdCrudService
|
||||||
{
|
{
|
||||||
$query = ActivityForm::where('sector', $sector)
|
$query = ActivityForm::where('sector', $sector)
|
||||||
->where('form_code', $code)
|
->where('form_code', $code)
|
||||||
->where('inventory_year', $inventoryYear)
|
// ->where('inventory_year', $inventoryYear)
|
||||||
->rowActive()
|
->rowActive()
|
||||||
->orderBy('inventory_year', 'desc');
|
->orderBy('inventory_year', 'desc');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -444,13 +444,13 @@ File: Main Js File
|
||||||
document.body.setAttribute("data-topbar", "dark");
|
document.body.setAttribute("data-topbar", "dark");
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('sidebar-setting').style.display = "none";
|
// $('#sidebar-setting').style.display = "none";
|
||||||
document.body.removeAttribute("data-sidebar");
|
document.body.removeAttribute("data-sidebar");
|
||||||
|
|
||||||
// (body.hasAttribute("data-topbar") ? body.removeAttribute("data-topbar") : body.setAttribute("data-topbar", ""));
|
// (body.hasAttribute("data-topbar") ? body.removeAttribute("data-topbar") : body.setAttribute("data-topbar", ""));
|
||||||
} else {
|
} else {
|
||||||
updateRadio('layout-vertical');
|
updateRadio('layout-vertical');
|
||||||
document.getElementById('sidebar-setting').style.display = "block";
|
// $('#sidebar-setting').style.display = "block";
|
||||||
}
|
}
|
||||||
(body.hasAttribute("data-bs-theme") && body.getAttribute("data-bs-theme") == "dark") ? updateRadio('layout-mode-dark') : updateRadio('layout-mode-light');
|
(body.hasAttribute("data-bs-theme") && body.getAttribute("data-bs-theme") == "dark") ? updateRadio('layout-mode-dark') : updateRadio('layout-mode-light');
|
||||||
(body.hasAttribute("data-layout-size") && body.getAttribute("data-layout-size") == "boxed") ? updateRadio('layout-width-boxed') : updateRadio('layout-width-fluid');
|
(body.hasAttribute("data-layout-size") && body.getAttribute("data-layout-size") == "boxed") ? updateRadio('layout-width-boxed') : updateRadio('layout-width-fluid');
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="text-sm-end d-none d-sm-block">
|
<div class="text-sm-end d-none d-sm-block">
|
||||||
<a href="https://Themesdesign.com/" target="_blank" class="text-reset">Dinas Lingkungan Hidup Provinsi DKI Jakarta</a>
|
<a href="#" target="_blank" class="text-reset">Dinas Lingkungan Hidup Provinsi DKI Jakarta</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -67,8 +67,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- END layout-wrapper -->
|
<!-- END layout-wrapper -->
|
||||||
|
{{-- @include('include.rightbar') --}}
|
||||||
<?php //include 'partials/right-sidebar.php'; ?>
|
|
||||||
|
|
||||||
<!-- JAVASCRIPT -->
|
<!-- JAVASCRIPT -->
|
||||||
<script src="{{asset('assets/libs/bootstrap/js/bootstrap.bundle.min.js')}}"></script>
|
<script src="{{asset('assets/libs/bootstrap/js/bootstrap.bundle.min.js')}}"></script>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
@include('modules.form.approve')
|
@include('modules.form.approve')
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group mb-0 mr-2">
|
<div class="form-group mb-0 mr-2">
|
||||||
<button type="button" title="Tambah Data" class="btn btn-primary mb-2 mb-md-0" onclick="showCreateModal()"
|
<button type="button" title="Tambah Data" class="btn btn-primary mb-2 mb-md-0" onclick="return showCreateModal()"
|
||||||
{{ !$activityForm || $instansi === 'all' || $limitInternal ? 'disabled' : '' }}>
|
{{ !$activityForm || $instansi === 'all' || $limitInternal ? 'disabled' : '' }}>
|
||||||
<i class="bx bx-plus"></i>
|
<i class="bx bx-plus"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
aria-hidden="true">
|
aria-hidden="true">
|
||||||
<div class="modal-dialog modal-lg" role="document" style="width:90%; max-width: 90%;">
|
<div class="modal-dialog modal-lg" role="document" style="width:90%; max-width: 90%;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
<form action="{{ route('modules.form.saveSingle', ['sector' => $form->sector, 'code' => $form->code]) }}" method="POST">
|
||||||
|
@csrf
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<div class="modal-title" id="formModalLabel">
|
<div class="modal-title" id="formModalLabel">
|
||||||
<b>Form Tambah Data Baru</b>
|
<b>Form Tambah Data Baru</b>
|
||||||
|
|
@ -14,14 +16,25 @@
|
||||||
|
|
||||||
<!-- Right Column - Metadata Form -->
|
<!-- Right Column - Metadata Form -->
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<form id="FormSubmit" method="POST" enctype="multipart/form-data">
|
|
||||||
@csrf
|
|
||||||
<input type="hidden" name="id" id="metadataId">
|
<input type="hidden" name="id" id="metadataId">
|
||||||
<input type="hidden" name="code_id" value="{{ $activityForm->id ?? 0 }}">
|
<input type="hidden" name="code_id" value="{{ $activityForm->id ?? 0 }}">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<x-inventory-year-select :selected-year="$inventoryYear" />
|
<div class="form-group">
|
||||||
|
<label for="inventoryYear">Tahun Inventory:</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<select name="inventoryYear" class="form-control">
|
||||||
|
@for ($year = date('Y'); $year >= 2000; $year--)
|
||||||
|
<option value="{{ $year }}" {{ $inventoryYear == $year ? 'selected' : '' }}>
|
||||||
|
{{ $year }}
|
||||||
|
</option>
|
||||||
|
@endfor
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -57,16 +70,18 @@
|
||||||
<b>{{ $detail->activity ? $detail->activity->name : 'N/A' }}</b>
|
<b>{{ $detail->activity ? $detail->activity->name : 'N/A' }}</b>
|
||||||
@if ($unitCategory)
|
@if ($unitCategory)
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control w-50 text-right" oninput="numberFormat(this)">
|
<input type="text" class="form-control w-50 text-right" name="value[{{ $detail->activity_code }}]" oninput="numberFormat(this)">
|
||||||
<div class="input-group-text p-0" style="width: 200px!important;">
|
<div class="input-group-text p-0" style="width: 200px!important;">
|
||||||
<select name="unit_code[{{ $detail->activity_code }}]" class="form-control unit-code"
|
<select name="unit_code[{{ $detail->activity_code }}]" class="form-control unit-code"
|
||||||
data-activity-code="{{ $detail->activity_code }}"
|
data-activity-code="{{ $detail->activity_code }}"
|
||||||
data-current-unit="{{ $unitCode }}">
|
data-current-unit="{{ $unitCode }}">
|
||||||
@foreach ($unitsByCategory[$unitCategory] as $unit)
|
@foreach ($unitsByCategory[$unitCategory] as $unit)
|
||||||
|
@if($unit->code == $unitCode)
|
||||||
<option value="{{ $unit->code }}"
|
<option value="{{ $unit->code }}"
|
||||||
{{ $unit->code == $unitCode ? 'selected' : '' }}>
|
{{ $unit->code == $unitCode ? 'selected' : '' }}>
|
||||||
{{ $unit->code }}
|
{{ $unit->code }}
|
||||||
</option>
|
</option>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -79,13 +94,14 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary">Simpan Data</button>
|
<button class="btn btn-primary">Simpan Data</button>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
$unitCode = $detail->unit_code;
|
$unitCode = $detail->unit_code;
|
||||||
$unitCategory = $unitsMap[$unitCode]->category ?? null;
|
$unitCategory = $unitsMap[$unitCode]->category ?? null;
|
||||||
@endphp
|
@endphp
|
||||||
<th style="min-width: 150px;">
|
<th style="min-width: 150px; text-decoration:normal">
|
||||||
{{ $detail->activity ? $detail->activity->name : 'N/A' }}
|
{{ $detail->activity ? $detail->activity->name : 'N/A' }} - ({{ $detail->unit_code }})
|
||||||
|
|
||||||
@if ($unitCategory)
|
@if ($unitCategory)
|
||||||
{{-- <select name="unit_code[{{ $detail->activity_code }}]" class="form-control unit-code"
|
{{-- <select name="unit_code[{{ $detail->activity_code }}]" class="form-control unit-code"
|
||||||
|
|
@ -60,9 +60,9 @@
|
||||||
value="{{ getFormattedValue($activity_value) ?? '' }}"
|
value="{{ getFormattedValue($activity_value) ?? '' }}"
|
||||||
class="form-control text-right" oninput="numberFormat(this)"
|
class="form-control text-right" oninput="numberFormat(this)"
|
||||||
style="min-width: 80px;" {{ $isLocked || $instansi === 'all' || $limitInternal ? 'readonly' : '' }}>
|
style="min-width: 80px;" {{ $isLocked || $instansi === 'all' || $limitInternal ? 'readonly' : '' }}>
|
||||||
<div class="input-group-text">
|
{{-- <div class="input-group-text">
|
||||||
{{ $detail->unit_code }}
|
{{ $detail->unit_code }}
|
||||||
</div>
|
</div> --}}
|
||||||
</div>
|
</div>
|
||||||
{{-- <input type="hidden"
|
{{-- <input type="hidden"
|
||||||
name="data[{{ $year }}][{{ $detail->activity_code }}-{{ $detail->unit_code }}]"
|
name="data[{{ $year }}][{{ $detail->activity_code }}-{{ $detail->unit_code }}]"
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,7 @@ Route::name('management.')->prefix('management')->group(function () {
|
||||||
Route::prefix('{sector}/{code}')->group(function () {
|
Route::prefix('{sector}/{code}')->group(function () {
|
||||||
Route::get('/', [FormController::class, 'show'])->name('form.show');
|
Route::get('/', [FormController::class, 'show'])->name('form.show');
|
||||||
Route::post('save', [FormController::class, 'save'])->name('form.save');
|
Route::post('save', [FormController::class, 'save'])->name('form.save');
|
||||||
|
Route::post('saveSingle', [FormController::class, 'saveSingle'])->name('form.saveSingle');
|
||||||
Route::get('conversion', [FormController::class, 'convertUnit'])->name('form.conversion');
|
Route::get('conversion', [FormController::class, 'convertUnit'])->name('form.conversion');
|
||||||
Route::post('{inventoryYear}/import/{instansi?}', [FormController::class, 'import'])->name('form.import');
|
Route::post('{inventoryYear}/import/{instansi?}', [FormController::class, 'import'])->name('form.import');
|
||||||
Route::get('{inventoryYear}/export/{instansi?}', [FormController::class, 'export'])->name('form.export');
|
Route::get('{inventoryYear}/export/{instansi?}', [FormController::class, 'export'])->name('form.export');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue