akses persetujuan done
This commit is contained in:
parent
093a8f2b4d
commit
c7fc112c4f
196
app/Http/Controllers/masterPersetujuanController.php
Normal file
196
app/Http/Controllers/masterPersetujuanController.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\masterPersetujuan;
|
||||
use App\Models\masterPersetujuanDetail;
|
||||
use App\Models\UnitKerja;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class masterPersetujuanController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$data = [
|
||||
'title' => 'Master Persetujuan'
|
||||
];
|
||||
return view('masterPersetujuan.index', $data);
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
return masterPersetujuan::where('statusenabled', true)->with([
|
||||
'pegawai:id,namalengkap',
|
||||
'details.unitPegawai:id,name'
|
||||
])->get();
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$payloads = $request->input('data', []);
|
||||
if (!is_array($payloads) || empty($payloads)) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak boleh kosong'
|
||||
], 422);
|
||||
}
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
try {
|
||||
foreach ($payloads as $payload) {
|
||||
$pegawaiId = $payload['pegawai_id'] ?? null; // field name tetap, isi pegawai
|
||||
if (!$pegawaiId) {
|
||||
throw new \InvalidArgumentException('Pegawai wajib diisi.');
|
||||
}
|
||||
|
||||
$master = masterPersetujuan::create([
|
||||
'pegawai_id' => $pegawaiId,
|
||||
'statusenabled' => true,
|
||||
'entry_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
$detailUnits = collect($payload['unit_akses'] ?? [])
|
||||
->filter()
|
||||
->unique()
|
||||
->values();
|
||||
foreach ($detailUnits as $unitId) {
|
||||
masterPersetujuanDetail::create([
|
||||
'master_persetujuan_file_directory_id' => $master->id,
|
||||
'unit_pegawai_id' => $unitId,
|
||||
'statusenabled' => true,
|
||||
'entry_at' => Carbon::now()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data berhasil disimpan'
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
DB::connection('dbDirectory')->rollBack();
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $th->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function show(string $id)
|
||||
{
|
||||
$data = masterPersetujuan::with(['pegawai:id,nama', 'unitPegawai:id,name', 'details.unitPegawai:id,name'])
|
||||
->find($id);
|
||||
|
||||
if (!$data) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => [
|
||||
'id' => $data->id,
|
||||
'unit_pegawai_id' => $data->unit_pegawai_id,
|
||||
'unit_pegawai_nama' => $data->pegawai?->nama,
|
||||
'detail_units' => $data->details->map(function ($detail) {
|
||||
return [
|
||||
'id' => $detail->unit_pegawai_id,
|
||||
'text' => $detail->unitPegawai?->name,
|
||||
];
|
||||
})->values(),
|
||||
],
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
$data = masterPersetujuan::find($id);
|
||||
if (!$data) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$unitPegawaiId = $request->input('pegawai_id');
|
||||
if (!$unitPegawaiId) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Pegawai wajib diisi.'
|
||||
], 422);
|
||||
}
|
||||
|
||||
$detailUnits = collect($request->input('unit_akses', []))
|
||||
->filter()
|
||||
->unique()
|
||||
->values();
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
try {
|
||||
$data->update([
|
||||
'pegawai_id' => $unitPegawaiId,
|
||||
'modified_at' => Carbon::now()
|
||||
]);
|
||||
|
||||
masterPersetujuanDetail::where('master_persetujuan_file_directory_id', $data->id)->delete();
|
||||
|
||||
foreach ($detailUnits as $unitId) {
|
||||
masterPersetujuanDetail::create([
|
||||
'master_persetujuan_file_directory_id' => $data->id,
|
||||
'unit_pegawai_id' => $unitId,
|
||||
'entry_at' => Carbon::now(),
|
||||
'modified_at' => Carbon::now(),
|
||||
'statusenabled' => true
|
||||
]);
|
||||
}
|
||||
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data berhasil diperbarui'
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
DB::connection('dbDirectory')->rollBack();
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $th->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy(string $id)
|
||||
{
|
||||
$data = masterPersetujuan::find($id);
|
||||
if (!$data) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
try {
|
||||
masterPersetujuanDetail::where('master_persetujuan_file_directory_id', $data->id)->update([
|
||||
'statusenabled' => false,
|
||||
'modified_at' => Carbon::now(),
|
||||
]);
|
||||
$data->update([
|
||||
'statusenabled' => false,
|
||||
'modified_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data berhasil dihapus'
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
DB::connection('dbDirectory')->rollBack();
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $th->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
app/Models/masterPersetujuan.php
Normal file
32
app/Models/masterPersetujuan.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\UnitKerja;
|
||||
use App\Models\DataUser;
|
||||
use App\Models\masterPersetujuanDetail;
|
||||
|
||||
class masterPersetujuan extends Model
|
||||
{
|
||||
protected $connection = 'dbDirectory';
|
||||
protected $table = 'public.master_persetujuan_file_directory';
|
||||
public $timestamps = false;
|
||||
protected $primaryKey = 'id';
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function unitPegawai()
|
||||
{
|
||||
return $this->belongsTo(UnitKerja::class, 'unit_pegawai_id', 'id');
|
||||
}
|
||||
|
||||
public function pegawai()
|
||||
{
|
||||
return $this->belongsTo(DataUser::class, 'pegawai_id', 'id');
|
||||
}
|
||||
|
||||
public function details()
|
||||
{
|
||||
return $this->hasMany(masterPersetujuanDetail::class, 'master_persetujuan_file_directory_id', 'id')->where('statusenabled', true);
|
||||
}
|
||||
}
|
||||
26
app/Models/masterPersetujuanDetail.php
Normal file
26
app/Models/masterPersetujuanDetail.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\UnitKerja;
|
||||
use App\Models\masterPersetujuan;
|
||||
|
||||
class masterPersetujuanDetail extends Model
|
||||
{
|
||||
protected $connection = 'dbDirectory';
|
||||
protected $table = 'public.master_persetujuan_file_directory_detail';
|
||||
public $timestamps = false;
|
||||
protected $primaryKey = 'id';
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function master()
|
||||
{
|
||||
return $this->belongsTo(masterPersetujuan::class, 'master_persetujuan_file_directory_id', 'id');
|
||||
}
|
||||
|
||||
public function unitPegawai()
|
||||
{
|
||||
return $this->belongsTo(UnitKerja::class, 'unit_pegawai_id', 'id');
|
||||
}
|
||||
}
|
||||
7
public/js/masterPersetujuan/_init.js
Normal file
7
public/js/masterPersetujuan/_init.js
Normal file
@ -0,0 +1,7 @@
|
||||
const datatableMasterPersetujuan = $("#table_master_persetujuan")
|
||||
|
||||
const formCreateMasterPersetujuan = $("#formCreateMasterPersetujuan")
|
||||
const modalCreate = document.getElementById('modalMasterPersetujuan')
|
||||
|
||||
const modalEdit = document.getElementById('modalEditMasterPersetujuan')
|
||||
const formEditMasterPersetujuan = $("#formEditMasterPersetujuan")
|
||||
253
public/js/masterPersetujuan/action.js
Normal file
253
public/js/masterPersetujuan/action.js
Normal file
@ -0,0 +1,253 @@
|
||||
formCreateMasterPersetujuan.on('submit', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
const form = this;
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch(`/master-persetujuan`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector('input[name="_token"]').value,
|
||||
},
|
||||
body: formData
|
||||
}).then(async(res) => {
|
||||
const responseData = await res.json();
|
||||
if (responseData.status) {
|
||||
const handler = function () {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: responseData.message || 'Berhasil melakukan aksi!',
|
||||
timer: 2000,
|
||||
showConfirmButton: false,
|
||||
backdrop: true,
|
||||
});
|
||||
$("#col_add_master_persetujuan").html('');
|
||||
colCount = 1; // reset counter
|
||||
formCreateMasterPersetujuan.find('select').val(null).trigger('change');
|
||||
datatableMasterPersetujuan.bootstrapTable('refresh');
|
||||
modalCreate.removeEventListener('hidden.bs.modal', handler);
|
||||
};
|
||||
modalCreate.addEventListener('hidden.bs.modal', handler);
|
||||
bootstrap.Modal.getInstance(modalCreate).hide();
|
||||
} else {
|
||||
throw new Error(responseData.message || 'Terjadi kesalahan saat menyimpan data.');
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
if (err.message) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
text: err.message
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function deleteAkses(e){
|
||||
let id =$(e).data('id')
|
||||
Swal.fire({
|
||||
title: "Apakah kamu yakin ingin menghapus data master persetujuan?",
|
||||
text : $(e).data('name'),
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
backdrop: true,
|
||||
}).then((result) => {
|
||||
if(result.isConfirmed){
|
||||
fetch(`/master-persetujuan/${id}`, {
|
||||
method:'DELETE',
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": document.querySelector('input[name="_token"]').value,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}).then((response) => {
|
||||
if(!response.ok){
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
if(data.status){
|
||||
Swal.fire({
|
||||
title: "Success",
|
||||
text: "Data berhasil dihapus",
|
||||
icon:"success",
|
||||
showConfirmButton: false,
|
||||
timer: 1000
|
||||
}).then(() => {
|
||||
datatableMasterPersetujuan.bootstrapTable("refresh")
|
||||
})
|
||||
}else{
|
||||
Swal.fire({
|
||||
title: "Error!",
|
||||
text: data.message || "Failed to delete Item.",
|
||||
icon: "error"
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
title: "Error!",
|
||||
text: "Something went wrong. Please try again later.",
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function editAkses(e){
|
||||
const data = $(e).data();
|
||||
new bootstrap.Modal(modalEdit).show();
|
||||
formEditMasterPersetujuan.attr('action', `/master-persetujuan/${data.id}`)
|
||||
|
||||
selectOptionPegawaiEdit()
|
||||
selectOptionUnitKerjaEdit()
|
||||
if (data.pegawai_id) {
|
||||
setOldSelect2Value('#pegawai_id_edit', data.pegawai_id, data.pegawai_nama);
|
||||
}
|
||||
|
||||
fetch(`/master-persetujuan/${data.id}`)
|
||||
.then(async(res) => {
|
||||
const responseData = await res.json();
|
||||
if (!responseData.status) {
|
||||
throw new Error(responseData.message || 'Gagal memuat data akses.');
|
||||
}
|
||||
const detail = responseData.data;
|
||||
if (Array.isArray(detail.detail_units)) {
|
||||
setOldSelect2Values('#unit_akses_edit', detail.detail_units);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function selectOptionPegawaiEdit() {
|
||||
let selectPegawai = $(`#pegawai_id_edit`);
|
||||
// inisialisasi select2 untuk Unit Kerja
|
||||
selectPegawai.select2({
|
||||
placeholder: '-- Pilih Pegawai --',
|
||||
allowClear:true,
|
||||
width: '100%',
|
||||
dropdownParent: selectPegawai.parent(),
|
||||
ajax:{
|
||||
url : '/select-pegawai',
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function(params){
|
||||
return { q: params.term }
|
||||
},
|
||||
processResults: function(data){
|
||||
return {
|
||||
results : data?.data.map(item => ({
|
||||
id: item.id,
|
||||
text: item.nama,
|
||||
}))
|
||||
}
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
minimumInputLength: 1,
|
||||
});
|
||||
}
|
||||
|
||||
function selectOptionUnitKerjaEdit() {
|
||||
let selectUnit = $(`#unit_akses_edit`);
|
||||
if (selectUnit.data('select2')) return;
|
||||
selectUnit.select2({
|
||||
placeholder: '-- Pilih Unit Kerja --',
|
||||
allowClear:true,
|
||||
width: '100%',
|
||||
dropdownParent: selectUnit.parent(),
|
||||
ajax:{
|
||||
url : '/select-unit-kerja',
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function(params){
|
||||
return { q: params.term }
|
||||
},
|
||||
processResults: function(data){
|
||||
return {
|
||||
results : data?.data.map(item => ({
|
||||
id: item.id,
|
||||
text: item.name,
|
||||
}))
|
||||
}
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
minimumInputLength: 1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setOldSelect2Value(selector, id, text) {
|
||||
if (!id || !text) return;
|
||||
let option = new Option(text, id, true, true);
|
||||
$(selector).append(option).trigger('change')
|
||||
}
|
||||
|
||||
function setOldSelect2Values(selector, items) {
|
||||
if (!Array.isArray(items) || items.length === 0) return;
|
||||
items.forEach(item => {
|
||||
if (!item?.id || !item?.text) return;
|
||||
let option = new Option(item.text, item.id, true, true);
|
||||
$(selector).append(option);
|
||||
});
|
||||
$(selector).trigger('change')
|
||||
}
|
||||
|
||||
|
||||
formEditMasterPersetujuan.on('submit', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
const form = this;
|
||||
const actionUrl = formEditMasterPersetujuan.attr('action');
|
||||
const formData = new FormData(form);
|
||||
formData.append('_method', 'PUT')
|
||||
fetch(actionUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector('input[name="_token"]').value,
|
||||
},
|
||||
body: formData
|
||||
}).then(async(res) => {
|
||||
const responseData = await res.json();
|
||||
|
||||
if (responseData.status) {
|
||||
const handler = function () {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: responseData.message || 'Berhasil melakukan aksi!',
|
||||
timer: 2000,
|
||||
showConfirmButton: false,
|
||||
backdrop: true,
|
||||
});
|
||||
formCreateMasterPersetujuan.find('select').val(null).trigger('change');
|
||||
datatableMasterPersetujuan.bootstrapTable('refresh');
|
||||
modalEdit.removeEventListener('hidden.bs.modal', handler);
|
||||
};
|
||||
modalEdit.addEventListener('hidden.bs.modal', handler);
|
||||
bootstrap.Modal.getInstance(modalEdit).hide();
|
||||
} else {
|
||||
throw new Error(responseData.message || 'Terjadi kesalahan saat menyimpan data.');
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
if (err.message) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
text: err.message
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
63
public/js/masterPersetujuan/dt.js
Normal file
63
public/js/masterPersetujuan/dt.js
Normal file
@ -0,0 +1,63 @@
|
||||
datatableMasterPersetujuan.bootstrapTable({
|
||||
url: "/datatable/master-persetujuan",
|
||||
showRefresh: true,
|
||||
sortable: true,
|
||||
search: true,
|
||||
searchOnEnterKey: false,
|
||||
searchHighlight: true,
|
||||
pagination: true,
|
||||
serverSide:true,
|
||||
pageSize: 10,
|
||||
pageList: [10, 20, 30],
|
||||
cookie: true,
|
||||
cookieIdTable: "table_master_kategori",
|
||||
icons: {
|
||||
refresh: "fas fa-sync-alt",
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
title:"Action",
|
||||
formatter: function(value, row){
|
||||
console.log(row);
|
||||
|
||||
let buttons = '';
|
||||
buttons += `
|
||||
<button class="btn btn-sm btn-danger me-2" onclick="deleteAkses(this)"
|
||||
data-id="${row.id}" data-name="${row?.pegawai?.namalengkap}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
`
|
||||
buttons += `
|
||||
<button class="btn btn-sm btn-primary me-2" onclick="editAkses(this)"
|
||||
data-id="${row.id}"
|
||||
data-pegawai_id="${row?.pegawai_id}"
|
||||
data-pegawai_nama="${row?.pegawai?.namalengkap}"
|
||||
data-unit_id="${row?.unit_akses}"
|
||||
data-unit_nama="${row?.akses?.name}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</button>`
|
||||
return `
|
||||
<div class="d-flex space-x">
|
||||
${buttons}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"Nama",
|
||||
field:'pegawai.namalengkap'
|
||||
},
|
||||
{
|
||||
title:"Persetujuan",
|
||||
formatter:function(value, row){
|
||||
const units = (row?.details ?? [])
|
||||
.map(detail => detail?.unit_pegawai?.name)
|
||||
.filter(Boolean);
|
||||
|
||||
return units.length
|
||||
? units.join(', ')
|
||||
: '-';
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
102
public/js/masterPersetujuan/functions.js
Normal file
102
public/js/masterPersetujuan/functions.js
Normal file
@ -0,0 +1,102 @@
|
||||
$(document).ready(function() {
|
||||
selectOptionPegawai(0)
|
||||
selectOptionUnitKerja(0)
|
||||
});
|
||||
|
||||
function selectOptionPegawai(colCount) {
|
||||
let selectPegawai = $(`#pegawai_id_${colCount}`);
|
||||
// inisialisasi select2 untuk Unit Kerja
|
||||
selectPegawai.select2({
|
||||
placeholder: '-- Pilih Pegawai --',
|
||||
allowClear:true,
|
||||
width: '100%',
|
||||
dropdownParent: selectPegawai.parent(),
|
||||
ajax:{
|
||||
url : '/select-pegawai',
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function(params){
|
||||
return { q: params.term }
|
||||
},
|
||||
processResults: function(data){
|
||||
return {
|
||||
results : data?.data.map(item => ({
|
||||
id: item.id,
|
||||
text: item.nama,
|
||||
}))
|
||||
}
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
minimumInputLength: 1,
|
||||
});
|
||||
}
|
||||
|
||||
function selectOptionUnitKerja(colCount) {
|
||||
let selectUnit = $(`#unit_akses_${colCount}`);
|
||||
selectUnit.select2({
|
||||
placeholder: '-- Pilih Unit Kerja --',
|
||||
allowClear: true,
|
||||
width: '100%',
|
||||
dropdownParent: selectUnit.parent(),
|
||||
ajax:{
|
||||
url : '/select-unit-kerja',
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function(params){
|
||||
return { q: params.term }
|
||||
},
|
||||
processResults: function(data){
|
||||
return {
|
||||
results : data?.data.map(item => ({
|
||||
id: item.id,
|
||||
text: item.name,
|
||||
}))
|
||||
}
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
minimumInputLength: 1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
let colCount = 1;
|
||||
function addForm(){
|
||||
let col = $("#col_add_master_persetujuan")
|
||||
|
||||
let html = '';
|
||||
|
||||
html += `
|
||||
<div class="row mt-3" id="col-${colCount}">
|
||||
<hr/>
|
||||
<div class="col-md-4 mb-2">
|
||||
<label>Nama</label>
|
||||
<select class="form-control" name="data[${colCount}][pegawai_id]" id="pegawai_id_${colCount}" required>
|
||||
</select>
|
||||
<small class="text-muted">Cari nama pegawai.</small>
|
||||
</div>
|
||||
<div class="col-md-8 mb-2" id="unit_akses_wrapper_${colCount}">
|
||||
<label>Unit Kerja</label>
|
||||
<select class="form-control" name="data[${colCount}][unit_akses][]" id="unit_akses_${colCount}" multiple>
|
||||
</select>
|
||||
<small class="text-muted">Bisa pilih lebih dari satu.</small>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-danger mt-3 me-2" onclick="removeCol(${colCount})"><i class="fa-solid fa-trash"></i></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
`
|
||||
col.append(html)
|
||||
selectOptionPegawai(colCount)
|
||||
selectOptionUnitKerja(colCount)
|
||||
colCount++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function removeCol(count){
|
||||
$(`#col-${count}`).remove()
|
||||
}
|
||||
@ -105,6 +105,17 @@
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<a class="sidebar-link justify-content-between"
|
||||
href="/master-persetujuan" aria-expanded="false">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<span class="d-flex">
|
||||
<i class="ti ti-report-analytics"></i>
|
||||
</span>
|
||||
<span class="hide-menu">Master Persetujuan</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
30
resources/views/masterPersetujuan/index.blade.php
Normal file
30
resources/views/masterPersetujuan/index.blade.php
Normal file
@ -0,0 +1,30 @@
|
||||
@extends('layout.main')
|
||||
|
||||
@section('body_main')
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card w-100">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h4 class="mb-0">Master Persetujuan</h4>
|
||||
<button type="button" class="btn btn-primary" data-bs-target="#modalMasterPersetujuan" data-bs-toggle="modal">
|
||||
<i data-feather="plus" class="me-1"></i>
|
||||
Tambah Data
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table" id="table_master_persetujuan"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('masterPersetujuan.modal.add')
|
||||
@include('masterPersetujuan.modal.edit')
|
||||
<!-- Scripts -->
|
||||
<script src="{{ ver('/js/masterPersetujuan/_init.js') }}"></script>
|
||||
<script src="{{ ver('/js/masterPersetujuan/dt.js') }}"></script>
|
||||
<script src="{{ ver('/js/masterPersetujuan/functions.js') }}"></script>
|
||||
<script src="{{ ver('/js/masterPersetujuan/action.js') }}"></script>
|
||||
@endsection
|
||||
48
resources/views/masterPersetujuan/modal/add.blade.php
Normal file
48
resources/views/masterPersetujuan/modal/add.blade.php
Normal file
@ -0,0 +1,48 @@
|
||||
<div class="modal fade" id="modalMasterPersetujuan" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
|
||||
<!-- Modal Header -->
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5">Tambah Akses</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<!-- Modal Form -->
|
||||
<form enctype="multipart/form-data" method="POST" id="formCreateMasterPersetujuan">
|
||||
@csrf
|
||||
<div class="modal-body">
|
||||
<div class="container">
|
||||
<div class="border rounded-3 p-3 mb-2">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-4 mb-2">
|
||||
<label class="form-label">Nama</label>
|
||||
<select class="form-control" name="data[0][pegawai_id]" id="pegawai_id_0" required>
|
||||
</select>
|
||||
<small class="text-muted">Cari nama pegawai.</small>
|
||||
</div>
|
||||
<div class="col-md-8 mb-2" id="unit_akses_wrapper_0">
|
||||
<label class="form-label">Unit Kerja</label>
|
||||
<select class="form-control" name="data[0][unit_akses][]" id="unit_akses_0" multiple>
|
||||
</select>
|
||||
<small class="text-muted">Bisa pilih lebih dari satu.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div id="col_add_master_persetujuan"></div>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm mt-2" onclick="addForm()">
|
||||
+ Tambah Form
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
45
resources/views/masterPersetujuan/modal/edit.blade.php
Normal file
45
resources/views/masterPersetujuan/modal/edit.blade.php
Normal file
@ -0,0 +1,45 @@
|
||||
<div class="modal fade" id="modalEditMasterPersetujuan" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
|
||||
<!-- Modal Header -->
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5">Edit Data</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<!-- Modal Form -->
|
||||
<form enctype="multipart/form-data" method="POST" id="formEditMasterPersetujuan">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="modal-body">
|
||||
<div class="container">
|
||||
<div class="border rounded-3 p-3">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-4 mb-2">
|
||||
<label class="form-label">Nama</label>
|
||||
<select class="form-control" name="pegawai_id" id="pegawai_id_edit" required>
|
||||
</select>
|
||||
<small class="text-muted">Cari nama pegawai.</small>
|
||||
</div>
|
||||
<div class="col-12 col-md-8" id="unit_akses_wrapper_edit">
|
||||
<label class="form-label">Unit Kerja</label>
|
||||
<select class="form-control" name="unit_akses[]" id="unit_akses_edit" multiple>
|
||||
</select>
|
||||
<small class="text-muted">Bisa pilih lebih dari satu.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -6,6 +6,7 @@ use App\Http\Controllers\DashboardController;
|
||||
use App\Http\Controllers\MasterKategoriController;
|
||||
use App\Http\Controllers\MasterKlasifikasiController;
|
||||
use App\Http\Controllers\LogActivityController;
|
||||
use App\Http\Controllers\masterPersetujuanController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware(['auth'])->group(function(){
|
||||
@ -46,6 +47,9 @@ Route::middleware(['auth'])->group(function(){
|
||||
Route::post('/pending-file/{id}/approve', [DashboardController::class, 'approvePendingFile']);
|
||||
Route::post('/pending-file/{id}/reject', [DashboardController::class, 'rejectPendingFile']);
|
||||
Route::get('/data/count-pending', [DashboardController::class, 'countDataPending']);
|
||||
|
||||
Route::resource('/master-persetujuan', masterPersetujuanController::class)->only(['index','store','show','update','destroy']);
|
||||
Route::get('datatable/master-persetujuan', [masterPersetujuanController::class, 'datatable']);
|
||||
});
|
||||
|
||||
Route::get('/login', [AuthController::class, 'index'])->name('login');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user