prgress di akses
@ -15,23 +15,52 @@ use Illuminate\Support\Str;
|
|||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
public function index(){
|
public function index(){
|
||||||
dd(auth()->user());
|
|
||||||
$unitKerja = UnitKerja::where('statusenabled', true)->select('id', 'name')->get();
|
|
||||||
$subUnitKerja = SubUnitKerja::where('statusenabled', true)->select('id', 'name')->get();
|
|
||||||
$katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
|
$katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
|
||||||
$klasifikasiDok = MasterKlasifikasi::where('statusenabled', true)->select('master_klasifikasi_directory_id', 'nama_klasifikasi_directory')->get();
|
$klasifikasiDok = MasterKlasifikasi::where('statusenabled', true)->select('master_klasifikasi_directory_id', 'nama_klasifikasi_directory')->get();
|
||||||
|
|
||||||
|
$authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai[0];
|
||||||
|
$authUnitKerja = $authMapping->objectunitkerjapegawaifk;
|
||||||
|
$authSubUnitKerja = $authMapping->objectsubunitkerjapegawaifk;
|
||||||
$payload = [
|
$payload = [
|
||||||
'title' => 'Dashboard',
|
'title' => 'Dashboard',
|
||||||
'unitKerja' => $unitKerja,
|
|
||||||
'subUnitKerja' => $subUnitKerja,
|
|
||||||
'katDok' => $katDok,
|
'katDok' => $katDok,
|
||||||
'klasifikasiDok' => $klasifikasiDok,
|
'klasifikasiDok' => $klasifikasiDok,
|
||||||
|
'authUnitKerja' => $authUnitKerja,
|
||||||
|
'authSubUnitKerja' => $authSubUnitKerja,
|
||||||
];
|
];
|
||||||
return view('dashboard.index', $payload);
|
return view('dashboard.index', $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataUnitKerja(){
|
public function dataUnitKerja(){
|
||||||
$unitKerja = UnitKerja::where('statusenabled', true)->select('id', 'name')->get();
|
$authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai[0];
|
||||||
|
$authUnitKerja = $authMapping->objectunitkerjapegawaifk;
|
||||||
|
$authSubUnitKerja = $authMapping->objectsubunitkerjapegawaifk;
|
||||||
|
$kategori = request('kategori');
|
||||||
|
$filterUnit = request('unitKerja');
|
||||||
|
$subUnit = request('subUnit');
|
||||||
|
$klasifikasi = request('klasifikasi');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$unitKerja = UnitKerja::where('statusenabled', true)
|
||||||
|
->where('id', $authUnitKerja)
|
||||||
|
->with(['subUnitKerja' => function ($query) use ($authSubUnitKerja, $kategori, $filterUnit, $subUnit, $klasifikasi) {
|
||||||
|
$query->where('id', $authSubUnitKerja)
|
||||||
|
->with(['fileDirectory' => function ($q) use ($kategori, $filterUnit, $subUnit, $klasifikasi) {
|
||||||
|
$q->when($filterUnit, function ($subQ) use ($filterUnit) {
|
||||||
|
$subQ->where('id_unit_kerja', $filterUnit);
|
||||||
|
})->when($subUnit, function ($subQ) use ($subUnit) {
|
||||||
|
$subQ->where('id_sub_unit_kerja', $subUnit);
|
||||||
|
})->when($kategori, function ($subQ) use ($kategori) {
|
||||||
|
$subQ->where('master_kategori_directory_id', $kategori);
|
||||||
|
})->when($klasifikasi, function ($subQ) use ($klasifikasi) {
|
||||||
|
$subQ->where('master_klasifikasi_directory_id', $klasifikasi);
|
||||||
|
});
|
||||||
|
}]);
|
||||||
|
}])
|
||||||
|
->select('id', 'name')
|
||||||
|
->get();
|
||||||
|
|
||||||
$katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
|
$katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
|
||||||
$data = [
|
$data = [
|
||||||
'unitKerja' => $unitKerja,
|
'unitKerja' => $unitKerja,
|
||||||
@ -51,9 +80,9 @@ class DashboardController extends Controller
|
|||||||
$file = request()->file("data.$index.file");
|
$file = request()->file("data.$index.file");
|
||||||
$payload = [
|
$payload = [
|
||||||
'master_klasifikasi_directory_id' => $value['klasifikasi'],
|
'master_klasifikasi_directory_id' => $value['klasifikasi'],
|
||||||
'id_unit_kerja' => request('id_unit_kerja') ?? null,
|
'id_unit_kerja' => $value['id_unit_kerja'],
|
||||||
'id_sub_unit_kerja' => request('id_sub_unit_kerja') ?? null,
|
'id_sub_unit_kerja' => $value['id_sub_unit_kerja'],
|
||||||
'master_kategori_directory_id' => request('master_kategori_directory_id') ?? null,
|
'master_kategori_directory_id' => $value['master_kategori_directory_id'],
|
||||||
'pegawai_id_entry' => auth()->user()->id ?? 1,
|
'pegawai_id_entry' => auth()->user()->id ?? 1,
|
||||||
'pegawai_nama_entry' => auth()->user()->namalengkap ?? 'tes',
|
'pegawai_nama_entry' => auth()->user()->namalengkap ?? 'tes',
|
||||||
];
|
];
|
||||||
@ -77,4 +106,37 @@ class DashboardController extends Controller
|
|||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function OptionUnitKerja(){
|
||||||
|
$q = request()->get('q');
|
||||||
|
$authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai[0];
|
||||||
|
$authUnitKerja = $authMapping?->objectunitkerjapegawaifk;
|
||||||
|
$authSubUnitKerja = $authMapping?->objectsubunitkerjapegawaifk;
|
||||||
|
$akses = false;
|
||||||
|
|
||||||
|
$query = UnitKerja::query();
|
||||||
|
if(!$akses){
|
||||||
|
$query->where(['statusenabled' => true, 'id' => $authUnitKerja])
|
||||||
|
->with(['subUnitKerja' => function($query) use($authSubUnitKerja){
|
||||||
|
$query->where('id', $authSubUnitKerja);
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
$data = $query->when($q, function ($query, $q){
|
||||||
|
$query->where('name', 'ILIKE', '%' .$q . '%');
|
||||||
|
})
|
||||||
|
->select('id', 'name')->get();
|
||||||
|
return response()->json([
|
||||||
|
'status' => true,
|
||||||
|
'data' => $data
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteFile(string $id){
|
||||||
|
$data = FileDirectory::where('file_directory_id', $id)->first();
|
||||||
|
$data->update(['statusenabled' => false]);
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Berhasil menghapus data'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/Models/DataUser.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DataUser extends Model
|
||||||
|
{
|
||||||
|
protected $connection = 'dbDirectory';
|
||||||
|
protected $table = 'public.pegawai_m';
|
||||||
|
public $timestamps = false;
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
|
public function mappingUnitKerjaPegawai(){
|
||||||
|
return $this->hasMany(MappingUnitKerjaPegawai::class, 'objectpegawaifk', 'id')->select('id', 'objectsubunitkerjapegawaifk', 'objectunitkerjapegawaifk');
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Models/MappingUnitKerjaPegawai.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class MappingUnitKerjaPegawai extends Model
|
||||||
|
{
|
||||||
|
protected $connection = 'dbDirectory';
|
||||||
|
protected $table = 'public.mappegawaijabatantounitkerja_m';
|
||||||
|
public $timestamps = false;
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
protected $with = ['unitKerja', 'subUnitKerja'];
|
||||||
|
|
||||||
|
public function unitKerja(){
|
||||||
|
return $this->belongsTo(UnitKerja::class, 'objectunitkerjapegawaifk', 'id');
|
||||||
|
}
|
||||||
|
public function subUnitKerja(){
|
||||||
|
return $this->belongsTo(SubUnitKerja::class, 'objectsubunitkerjapegawaifk', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -45,4 +45,8 @@ class User extends Authenticatable
|
|||||||
'katasandi' => 'hashed',
|
'katasandi' => 'hashed',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
protected $with = ['dataUser'];
|
||||||
|
public function dataUser(){
|
||||||
|
return $this->belongsTo(DataUser::class, 'objectpegawaifk', 'id')->select('id', 'namalengkap');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
public/file/6mxSTn10NBcE0TDgaXLJIhNx2dORcZRMZaQuUxuc.pdf
Normal file
BIN
public/file/ChatGPT Image Aug 26, 2025, 08_47_44 AM.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
public/file/Jooocode (1).png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
public/file/Jooocode.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 168 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 150 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 132 KiB |
BIN
public/file/W4hGD1Br5INRp1SItxATO89kXQTd93hvBb4KfOUe.pdf
Normal file
BIN
public/file/WhatsApp Image 2025-08-20 at 07.44.39_7b5b4fcb.jpg
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
public/file/WhatsApp Image 2025-08-26 at 09.00.22_d2384700.jpg
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
public/file/laporan-pesanan-20250819-143732.xlsx
Normal file
BIN
public/file/pesanan-selesai20250813-142653.xlsx
Normal file
BIN
public/file/pesanan-selesai20250819-142335.xlsx
Normal file
BIN
public/file/pesanan-selesai20250825-144604.xlsx
Normal file
BIN
public/file/qRzWz72H1Sbf6CsbqmA4l8d9nYNmoExiLNqUWy0c.pdf
Normal file
BIN
public/file/semua-pesanan20250819-143713.xlsx
Normal file
@ -1,2 +1,2 @@
|
|||||||
const modalCreate = document.getElementById('modalFileCreate')
|
const modalCreate = document.getElementById('modalCreateFile')
|
||||||
const formCreate = $("#formFile")
|
const formCreate = $("#formFile")
|
||||||
|
|||||||
@ -26,8 +26,10 @@ formCreate.on('submit', function(e){
|
|||||||
|
|
||||||
}).showToast();
|
}).showToast();
|
||||||
$("#col_add_file").html('');
|
$("#col_add_file").html('');
|
||||||
colCount = 0; // reset counter
|
colCount = 1; // reset counter
|
||||||
formCreate[0].reset();
|
formCreate.find('input[type="text"], input[type="file"]').val('');
|
||||||
|
formCreate.find('select').val(null).trigger('change');
|
||||||
|
|
||||||
index()
|
index()
|
||||||
modalCreate.removeEventListener('hidden.bs.modal', handler);
|
modalCreate.removeEventListener('hidden.bs.modal', handler);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,24 +1,89 @@
|
|||||||
|
let colCount = 1;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.unit_kerja').select2();
|
$('.unit_kerja').select2({
|
||||||
$('.sub_unit_kerja').select2();
|
placeholder: '-- Pilih Unit Kerja --',
|
||||||
|
allowClear:true,
|
||||||
|
width: '100%',
|
||||||
|
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,
|
||||||
|
sub_units: item?.sub_unit_kerja
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cache: true,
|
||||||
|
},
|
||||||
|
minimumInputLength: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.sub_unit_kerja').select2({
|
||||||
|
placeholder: '-- Pilih Sub Unit Kerja ',
|
||||||
|
allowClear:true,
|
||||||
|
width: '100%',
|
||||||
|
})
|
||||||
|
|
||||||
|
$('.unit_kerja').on('select2:select', function(e){
|
||||||
|
let data = e.params.data;
|
||||||
|
$('.sub_unit_kerja').empty().append('<option value="" disable>-- Pilih Sub Unit Kerja --</option>')
|
||||||
|
|
||||||
|
if(data.sub_units && data.sub_units.length > 0){
|
||||||
|
data.sub_units.forEach(sub => {
|
||||||
|
$('.sub_unit_kerja').append(`<option value="${sub.id}">${sub.name}</option>`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$('.klasifikasi_dok').select2();
|
$('.klasifikasi_dok').select2();
|
||||||
$('.kategori_dok').select2();
|
$('.kategori_dok').select2();
|
||||||
|
|
||||||
|
selectOptionUnitKerja(0)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let colCount = 1;
|
|
||||||
function addForm(){
|
function addForm(){
|
||||||
let col = $("#col_add_file")
|
let col = $("#col_add_file")
|
||||||
|
|
||||||
let html = '';
|
let html = '';
|
||||||
|
|
||||||
html += ` <div class="col mt-2 d-flex align-items-start gap-2" id="col-${colCount}">
|
html += ` <div class="row mt-3" id="col-${colCount}">
|
||||||
<div class="col-md-6">
|
<hr />
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<label>Unit</label>
|
||||||
|
<select class="form-control" name="data[${colCount}][id_unit_kerja]" id="select_id_unit_kerja_${colCount}" required>
|
||||||
|
<option value="" disable>Select Choose</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<label>Sub Unit</label>
|
||||||
|
<select class="form-control" name="data[${colCount}][id_sub_unit_kerja]" id="select_id_sub_unit_kerja_${colCount}" required>
|
||||||
|
<option value="" disable>Select Choose</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label>Kategori Dokumen</label>
|
||||||
|
<select class="form-control" name="data[${colCount}][master_kategori_directory_id]" id="select_kategori_${colCount}" required>
|
||||||
|
<option value="" disable>Select Choose</option>
|
||||||
|
${katDok.map(dok => `
|
||||||
|
<option value="${dok?.master_kategori_directory_id}">${dok?.nama_kategori_directory}</option>
|
||||||
|
`).join('')}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
<label>File</label>
|
<label>File</label>
|
||||||
<input type="file" class="form-control" name="data[${colCount}][file]" placeholder="exp : Juknis" required>
|
<input type="file" class="form-control" name="data[${colCount}][file]" placeholder="exp : Juknis" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-3">
|
||||||
<label>Klasifikasi File</label>
|
<label>Klasifikasi Dokumen</label>
|
||||||
<select class="form-select" name="data[${colCount}][klasifikasi]">
|
<select class="form-select" name="data[${colCount}][klasifikasi]">
|
||||||
<option value="" disable >Select Choose</option>
|
<option value="" disable >Select Choose</option>
|
||||||
${klasifikasiDok.map(kla => `
|
${klasifikasiDok.map(kla => `
|
||||||
@ -30,10 +95,9 @@ function addForm(){
|
|||||||
<button type="button" class="btn btn-danger mt-4 me-2" onclick="removeCol(${colCount})"><i class="fa-solid fa-trash"></i></button>
|
<button type="button" class="btn btn-danger mt-4 me-2" onclick="removeCol(${colCount})"><i class="fa-solid fa-trash"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
col.append(html)
|
col.append(html)
|
||||||
|
selectOptionUnitKerja(colCount)
|
||||||
colCount++;
|
colCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -43,3 +107,57 @@ function removeCol(count){
|
|||||||
$(`#col-${count}`).remove()
|
$(`#col-${count}`).remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function selectOptionUnitKerja(colCount) {
|
||||||
|
let selectUnit = $(`#select_id_unit_kerja_${colCount}`);
|
||||||
|
let selectSubUnit = $(`#select_id_sub_unit_kerja_${colCount}`);
|
||||||
|
|
||||||
|
// inisialisasi select2 untuk Unit Kerja
|
||||||
|
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,
|
||||||
|
sub_units: item.sub_unit_kerja // kirim ke front
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cache: true,
|
||||||
|
},
|
||||||
|
minimumInputLength: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
selectSubUnit.select2({
|
||||||
|
placeholder: '-- Pilih Sub Unit Kerja --',
|
||||||
|
allowClear: true,
|
||||||
|
width: '100%',
|
||||||
|
dropdownParent: selectSubUnit.parent()
|
||||||
|
});
|
||||||
|
|
||||||
|
// event ketika unit kerja dipilih
|
||||||
|
selectUnit.on('select2:select', function (e) {
|
||||||
|
let data = e.params.data; // data unit kerja terpilih
|
||||||
|
selectSubUnit.empty().append('<option value="" disabled selected>-- Pilih Sub Unit Kerja --</option>');
|
||||||
|
|
||||||
|
if (data.sub_units && data.sub_units.length > 0) {
|
||||||
|
data.sub_units.forEach(sub => {
|
||||||
|
selectSubUnit.append(`<option value="${sub.id}">${sub.name}</option>`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// aktifkan select2 untuk sub unit
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ function renderTree(units, katDok) {
|
|||||||
if (!Array.isArray(units)) return '';
|
if (!Array.isArray(units)) return '';
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<ul class="file-tree-ul">
|
<ul class="file-tree-ul mt-3">
|
||||||
${units.map(el => `
|
${units.map(el => `
|
||||||
<li class="file-tree-li folder">
|
<li class="file-tree-li folder">
|
||||||
<span class="fw-bolder">📂 ${el.name}</span>
|
<span class="fw-bolder">📂 ${el.name}</span>
|
||||||
@ -14,36 +14,30 @@ function renderTree(units, katDok) {
|
|||||||
<span class="fw-semibold">📂 ${sub.name}</span>
|
<span class="fw-semibold">📂 ${sub.name}</span>
|
||||||
|
|
||||||
${Array.isArray(katDok) && katDok.length > 0 ? `
|
${Array.isArray(katDok) && katDok.length > 0 ? `
|
||||||
<ul class="file-tree-ul">
|
<ul class="file-tree-ul ms-2">
|
||||||
${katDok.map(kat => `
|
${katDok.map(kat => {
|
||||||
<li class="folder file-tree-li">
|
// filter file sesuai kategori
|
||||||
<span>📂 ${kat.nama_kategori_directory}</span>
|
const files = (sub.file_directory || []).filter(
|
||||||
<ul class="file-tree-ul">
|
file => file.master_kategori_directory_id === kat.master_kategori_directory_id
|
||||||
${Array.isArray(sub.file_directory) && sub.file_directory.length > 0 ? `
|
);
|
||||||
${sub.file_directory.map(file => `
|
|
||||||
${kat.master_kategori_directory_id === file.master_kategori_directory_id ? `
|
|
||||||
<li class="file-tree-li ms-2">
|
|
||||||
📄 <a href="/file/${file.file}" target="_blank" rel="noopener noreferrer">${file.file}</a>
|
|
||||||
</li>
|
|
||||||
` : ''}
|
|
||||||
|
|
||||||
`).join('')}
|
if (!files.length) return '';
|
||||||
` : ''}
|
|
||||||
<li class="file-tree-li ms-2">
|
return `
|
||||||
<button class="add-file-btn btn btn-sm btn-primary ms-2 btn-transaparent"
|
<li class="file-tree-li folder">
|
||||||
onclick="addFile(this)"
|
<span>📂 ${kat.nama_kategori_directory}</span>
|
||||||
data-id_unit_kerja="${el.id}"
|
<ul class="file-tree-ul ms-2">
|
||||||
data-nama_unit_kerja="${el.name || 'tidak_ada'}"
|
${files.map(file => `
|
||||||
data-id_sub_unit_kerja="${sub?.id}"
|
<li class="file-tree-li">
|
||||||
data-nama_sub_unit_kerja="${sub?.name || 'tidak_ada'}"
|
📄 <a href="#" class="file-link" data-file="${file.file}" data-id="${file?.file_directory_id}">
|
||||||
data-id_kategori="${kat?.master_kategori_directory_id}"
|
${file.file}
|
||||||
data-nama_kategori="${kat?.nama_kategori_directory}">
|
</a>
|
||||||
➕ Add File
|
|
||||||
</button>
|
|
||||||
</li>
|
</li>
|
||||||
|
`).join('')}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
`).join('')}
|
`;
|
||||||
|
}).join('')}
|
||||||
</ul>
|
</ul>
|
||||||
` : ''}
|
` : ''}
|
||||||
</li>
|
</li>
|
||||||
@ -54,10 +48,17 @@ function renderTree(units, katDok) {
|
|||||||
`).join('')}
|
`).join('')}
|
||||||
</ul>
|
</ul>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function index() {
|
function index(kategori_dok = null, unitKerja = null, subUnitKerja = null, klasifikasi_id = null) {
|
||||||
fetch('/data-unit-kerja')
|
const params = new URLSearchParams();
|
||||||
|
if (kategori_dok) params.append("kategori", kategori_dok);
|
||||||
|
if (unitKerja) params.append("unitKerja", unitKerja);
|
||||||
|
if (subUnitKerja) params.append("subUnit", subUnitKerja);
|
||||||
|
if (klasifikasi_id) params.append("klasifikasi", klasifikasi_id);
|
||||||
|
|
||||||
|
fetch(`/data-unit-kerja?${params.toString()}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
let file_tree = document.getElementById("file_tree");
|
let file_tree = document.getElementById("file_tree");
|
||||||
@ -65,7 +66,6 @@ function index() {
|
|||||||
|
|
||||||
if (Array.isArray(data?.data?.unitKerja)) {
|
if (Array.isArray(data?.data?.unitKerja)) {
|
||||||
file_tree.innerHTML = renderTree(data.data.unitKerja, data.data.katDok);
|
file_tree.innerHTML = renderTree(data.data.unitKerja, data.data.katDok);
|
||||||
|
|
||||||
// Toggle buka/tutup folder
|
// Toggle buka/tutup folder
|
||||||
file_tree.querySelectorAll(".folder > span").forEach(span => {
|
file_tree.querySelectorAll(".folder > span").forEach(span => {
|
||||||
span.addEventListener("click", () => {
|
span.addEventListener("click", () => {
|
||||||
@ -88,19 +88,17 @@ function index() {
|
|||||||
|
|
||||||
index();
|
index();
|
||||||
|
|
||||||
function addFile(el){
|
function searchData(){
|
||||||
let id_unit_kerja =$(el).data('id_unit_kerja')
|
let klasifikasi_id = $("#klasifikasi_dok").val()
|
||||||
let nama_unit_kerja =$(el).data('nama_unit_kerja')
|
let kategori_dok = $("#kategori_dok").val()
|
||||||
let id_sub_unit_kerja =$(el).data('id_sub_unit_kerja')
|
let unitKerja = $("#unit_kerja").val()
|
||||||
let nama_sub_unit_kerja =$(el).data('nama_sub_unit_kerja')
|
let subUnitKerja = $("#sub_unit_kerja").val()
|
||||||
let id_kategori =$(el).data('id_kategori')
|
if(!klasifikasi_id || !kategori_dok || !unitKerja || !subUnitKerja){
|
||||||
let nama_kategori =$(el).data('nama_kategori')
|
Swal.fire({
|
||||||
|
text: 'Lengkapi Isi form pencarian',
|
||||||
$("#id_unit_kerja").val(id_unit_kerja)
|
icon: 'warning'
|
||||||
$("#id_sub_unit_kerja").val(id_sub_unit_kerja)
|
})
|
||||||
$("#master_kategori_directory_id").val(id_kategori)
|
return
|
||||||
$("#confirm_location_file").html(`Unit Kerja : <b>${nama_unit_kerja}</b> / Sub Unit Kerja : <b>${nama_sub_unit_kerja}</b> / Kategori : <b>${nama_kategori}</b>`)
|
}
|
||||||
new bootstrap.Modal(modalCreate).show();
|
index(kategori_dok, unitKerja, subUnitKerja, klasifikasi_id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,54 +62,195 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body p-3">
|
<div class="card-body p-3">
|
||||||
<div class="row mb-3 mt-3">
|
<div class="row mb-3 mt-3">
|
||||||
<div class="col-md-3">
|
<!-- Unit Kerja -->
|
||||||
<label for="exampleFormControlInput1" class="form-label">Unit Kerja</label>
|
|
||||||
<select class="unit_kerja form-control" id="unit_kerja">
|
|
||||||
<option value="" disable >Select Choose</option>
|
|
||||||
@foreach ($unitKerja as $unit)
|
|
||||||
<option value="{{ $unit->id }}">{{ $unit->name }}</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="exampleFormControlInput1" class="form-label">Sub Unit Kerja</label>
|
|
||||||
<select class="sub_unit_kerja form-control" id="sub_unit_kerja">
|
|
||||||
<option value="" disable >Select Choose</option>
|
|
||||||
@foreach ($subUnitKerja as $sub)
|
|
||||||
<option value="{{ $sub->id }}">{{ $sub->name }}</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<label for="exampleFormControlInput1" class="form-label">Kategori Dok.</label>
|
<label for="unit_kerja" class="form-label">Unit Kerja</label>
|
||||||
<select class="kategori_dok form-control" id="kategori_dok">
|
<select class="form-control unit_kerja" id="unit_kerja">
|
||||||
<option value="" disable >Select Choose</option>
|
<option value="" disabled selected>Select Choose</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sub Unit Kerja -->
|
||||||
|
<div class="col-md-2">
|
||||||
|
<label for="sub_unit_kerja" class="form-label">Sub Unit Kerja</label>
|
||||||
|
<select class="form-control sub_unit_kerja" id="sub_unit_kerja">
|
||||||
|
<option value="" disabled selected>Select Choose</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Kategori Dokumen -->
|
||||||
|
<div class="col-md-2">
|
||||||
|
<label for="kategori_dok" class="form-label">Kategori Dok.</label>
|
||||||
|
<select class="form-control kategori_dok" id="kategori_dok">
|
||||||
|
<option value="" disabled selected>Select Choose</option>
|
||||||
@foreach ($katDok as $kat)
|
@foreach ($katDok as $kat)
|
||||||
<option value="{{ $kat->id }}">{{ $kat->nama_kategori_directory }}</option>
|
<option value="{{ $kat->master_kategori_directory_id }}">{{ $kat->nama_kategori_directory }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Klasifikasi Dokumen -->
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<label for="exampleFormControlInput1" class="form-label">Klasifikasi Dok.</label>
|
<label for="klasifikasi_dok" class="form-label">Klasifikasi Dok.</label>
|
||||||
<select class="klasifikasi_dok form-control" id="klasifikasi_dok">
|
<select class="form-control klasifikasi_dok" id="klasifikasi_dok">
|
||||||
<option value="" disable >Select Choose</option>
|
<option value="" disabled selected>Select Choose</option>
|
||||||
@foreach ($klasifikasiDok as $kla)
|
@foreach ($klasifikasiDok as $kla)
|
||||||
<option value="{{ $kla->id }}">{{ $kla->nama_klasifikasi_directory }}</option>
|
<option value="{{ $kla->master_klasifikasi_directory_id }}">{{ $kla->nama_klasifikasi_directory }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
|
||||||
<button type="button" class="btn btn-primary mt-3">Cari</button>
|
<!-- Button Cari -->
|
||||||
|
<div class="col-md-2 d-flex align-items-end">
|
||||||
|
<button type="button" class="btn btn-primary w-100" onclick="searchData()">Cari</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Button Tambah File -->
|
||||||
|
<div class="col-md-2 d-flex align-items-end">
|
||||||
|
<button type="button" class="btn btn-success w-100" data-bs-target="#modalCreateFile" data-bs-toggle="modal">
|
||||||
|
<i data-feather="plus" class="me-1"></i>
|
||||||
|
Tambah File</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div id="tree-wrapper" class="col-12 col-md-6 mb-3">
|
||||||
<div id="file_tree"></div>
|
<div id="file_tree"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="preview-wrapper" class="col-md-6 d-none">
|
||||||
|
<div class="card shadow-sm h-100">
|
||||||
|
<div class="card-header d-flex justify-content-between align-items-center py-2">
|
||||||
|
<h6 class="mb-0">📄 Preview</h6>
|
||||||
|
<button class="btn btn-sm btn-outline-danger" id="close-preview">✕</button>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-2" style="min-height:250px; max-height:80vh; overflow:auto;">
|
||||||
|
<div id="file-preview" class="text-center text-muted d-flex justify-content-center align-items-center" style="height:100%;">
|
||||||
|
<p>📂 Pilih file untuk melihat preview</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer p-2 d-flex justify-content-end">
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-danger" id="delete-file">Hapus</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@include('dashboard.modal.create')
|
@include('dashboard.modal.create')
|
||||||
<script>
|
<script>
|
||||||
const klasifikasiDok = @json($klasifikasiDok);
|
const klasifikasiDok = @json($klasifikasiDok);
|
||||||
|
const katDok = @json($katDok);
|
||||||
|
let currentFile = null;
|
||||||
|
let idDirectory = null;
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (e.target.matches('.file-link')) {
|
||||||
|
e.preventDefault();
|
||||||
|
let fileUrl = e.target.getAttribute('data-file');
|
||||||
|
currentFile = fileUrl
|
||||||
|
idDirectory = e.target.getAttribute('data-id');
|
||||||
|
let ext = fileUrl.split('.').pop().toLowerCase();
|
||||||
|
|
||||||
|
// ubah layout
|
||||||
|
document.getElementById('tree-wrapper').classList.remove('col-12');
|
||||||
|
document.getElementById('tree-wrapper').classList.add('col-md-6');
|
||||||
|
document.getElementById('preview-wrapper').classList.remove('d-none');
|
||||||
|
|
||||||
|
let previewBox = document.getElementById('file-preview');
|
||||||
|
|
||||||
|
if (['jpg','jpeg','png','gif','webp'].includes(ext)) {
|
||||||
|
previewBox.innerHTML = `<img src="/file/${fileUrl}" class="img-fluid rounded shadow-sm" alt="preview">`;
|
||||||
|
} else if (ext === 'pdf') {
|
||||||
|
previewBox.innerHTML = `<iframe src="/file/${fileUrl}" width="100%" height="600px" style="border:none;"></iframe>`;
|
||||||
|
} else {
|
||||||
|
previewBox.innerHTML = `
|
||||||
|
<p class="text-muted">Tidak bisa preview file ini. Silakan download:</p>
|
||||||
|
<a href="/file/${fileUrl}" target="_blank" class="btn btn-sm btn-primary">⬇️ Download</a>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.target.id === 'delete-file') {
|
||||||
|
if (!currentFile) {
|
||||||
|
Swal.fire({
|
||||||
|
text: "Tidak ada file yang dipilih!",
|
||||||
|
icon: "warning",
|
||||||
|
confirmButtonText: "OK"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Yakin ingin menghapus file ini?',
|
||||||
|
text: "File akan dihapus",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#d33',
|
||||||
|
cancelButtonColor: '#6c757d',
|
||||||
|
confirmButtonText: 'Ya, hapus',
|
||||||
|
cancelButtonText: 'Batal'
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
fetch(`/delete-file/${idDirectory}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ file: currentFile })
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
Swal.fire({
|
||||||
|
text: 'File berhasil dihapus',
|
||||||
|
icon: 'success',
|
||||||
|
timer: 2000,
|
||||||
|
showConfirmButton: false
|
||||||
|
});
|
||||||
|
|
||||||
|
// reset preview
|
||||||
|
document.getElementById('file-preview').innerHTML =
|
||||||
|
`<p>📂 Pilih file untuk melihat preview</p>`;
|
||||||
|
|
||||||
|
document.getElementById('preview-wrapper').classList.add('d-none');
|
||||||
|
document.getElementById('tree-wrapper').classList.remove('col-md-6');
|
||||||
|
document.getElementById('tree-wrapper').classList.add('col-12');
|
||||||
|
index()
|
||||||
|
currentFile = null; // reset
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
text: 'Gagal menghapus file',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
Swal.fire({
|
||||||
|
text: 'Terjadi error saat menghapus file',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// tombol close
|
||||||
|
document.getElementById('close-preview').addEventListener('click', function() {
|
||||||
|
document.getElementById('tree-wrapper').classList.remove('col-md-6');
|
||||||
|
document.getElementById('tree-wrapper').classList.add('col-12');
|
||||||
|
document.getElementById('preview-wrapper').classList.add('d-none');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ ver('/js/dashboard/_init.js') }}"></script>
|
<script src="{{ ver('/js/dashboard/_init.js') }}"></script>
|
||||||
<script src="{{ ver('/js/dashboard/index.js') }}"></script>
|
<script src="{{ ver('/js/dashboard/index.js') }}"></script>
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<div class="modal fade" id="modalFileCreate" tabindex="-1" aria-hidden="true">
|
<div class="modal fade" id="modalCreateFile" tabindex="-1" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-lg modal-dialog-centered">
|
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|
||||||
<!-- Modal Header -->
|
<!-- Modal Header -->
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h1 class="modal-title fs-5">Aksi <strong id="confirm_location_file"></strong></h1>
|
<h1 class="modal-title fs-5">Aksi </h1>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -13,26 +13,47 @@
|
|||||||
@csrf
|
@csrf
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="container" id="container_create">
|
<div class="container" id="container_create">
|
||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6 mb-2">
|
||||||
|
<label>Unit</label>
|
||||||
|
<select class="form-control" name="data[0][id_unit_kerja]" id="select_id_unit_kerja_0" required>
|
||||||
|
<option value="" disable>Select Choose</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<label>Sub Unit</label>
|
||||||
|
<select class="form-control" name="data[0][id_sub_unit_kerja]" id="select_id_sub_unit_kerja_0" required>
|
||||||
|
<option value="" disable>Select Choose</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label>Kategori Dokumen</label>
|
||||||
|
<select class="form-control" name="data[0][master_kategori_directory_id]" id="select_kategori_0" required>
|
||||||
|
<option value="" disable>Select Choose</option>
|
||||||
|
@foreach ($katDok as $kat)
|
||||||
|
<option value="{{ $kat->master_kategori_directory_id }}">{{ $kat->nama_kategori_directory }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
<label>File</label>
|
<label>File</label>
|
||||||
<input type="file" class="form-control" name="data[0][file]" placeholder="exp : Juknis" required>
|
<input type="file" class="form-control" name="data[0][file]" placeholder="exp : Juknis" required>
|
||||||
<input type="hidden" class="form-control" name="id_sub_unit_kerja" id="id_sub_unit_kerja" placeholder="exp : Juknis">
|
<input type="hidden" class="form-control" name="id_unit_kerja" id="id_unit_kerja" value="{{ $authUnitKerja }}" placeholder="exp : Juknis">
|
||||||
<input type="hidden" class="form-control" name="id_unit_kerja" id="id_unit_kerja" placeholder="exp : Juknis">
|
<input type="hidden" class="form-control" name="id_sub_unit_kerja" id="id_sub_unit_kerja" placeholder="exp : Juknis" value="{{ $authSubUnitKerja }}">
|
||||||
<input type="hidden" class="form-control" name="master_kategori_directory_id" id="master_kategori_directory_id" placeholder="exp : Juknis">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-4">
|
||||||
<label>Klasifikasi File</label>
|
<label>Klasifikasi File</label>
|
||||||
<select class="form-select" name="data[0][klasifikasi]" required>
|
<select class="form-select" name="data[0][klasifikasi]" required>
|
||||||
<option value="" disable >Select Choose</option>
|
<option value="" disable>Select Choose</option>
|
||||||
@foreach ($klasifikasiDok as $klasifikasi)
|
@foreach ($klasifikasiDok as $klasifikasi)
|
||||||
<option value="{{ $klasifikasi->master_klasifikasi_directory_id }}">{{ $klasifikasi->nama_klasifikasi_directory }}</option>
|
<option value="{{ $klasifikasi->master_klasifikasi_directory_id }}">{{ $klasifikasi->nama_klasifikasi_directory }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="col_add_file"></div>
|
<div id="col_add_file"></div>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-outline-primary btn-sm mt-2" onclick="addForm()">
|
<button type="button" class="btn btn-outline-primary btn-sm mt-3" onclick="addForm()">
|
||||||
+ Tambah Form
|
+ Tambah Form
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -16,6 +16,9 @@ Route::middleware(['auth'])->group(function(){
|
|||||||
Route::get('datatable/master-kategori', [MasterKategoriController::class, 'datatable']);
|
Route::get('datatable/master-kategori', [MasterKategoriController::class, 'datatable']);
|
||||||
Route::resource('/master-klasifikasi', MasterKlasifikasiController::class);
|
Route::resource('/master-klasifikasi', MasterKlasifikasiController::class);
|
||||||
Route::get('datatable/master-klasifikasi', [MasterKlasifikasiController::class, 'datatable']);
|
Route::get('datatable/master-klasifikasi', [MasterKlasifikasiController::class, 'datatable']);
|
||||||
|
|
||||||
|
Route::get('/select-unit-kerja', [DashboardController::class, 'OptionUnitKerja']);
|
||||||
|
Route::delete('/delete-file/{id}', [DashboardController::class, 'deleteFile']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/login', [AuthController::class, 'index'])->name('login');
|
Route::get('/login', [AuthController::class, 'index'])->name('login');
|
||||||
|
|||||||