Regulations support

This commit is contained in:
nugroho 2025-07-02 00:20:32 +07:00
parent ceb447594a
commit 165e224d03
13 changed files with 228 additions and 16 deletions

View File

@ -166,6 +166,9 @@ nav
<div class="item" data-path="agen"> <div class="item" data-path="agen">
<m-inline>manage_accounts</m-inline> Manajemen Agen & User <m-inline>manage_accounts</m-inline> Manajemen Agen & User
</div> </div>
<div class="item" data-path="regulasi">
<m-inline>balance</m-inline> Dokumen Regulasi
</div>
<div class="item" data-path="laporan"> <div class="item" data-path="laporan">
<m-inline>quick_references</m-inline> Laporan <m-inline>quick_references</m-inline> Laporan
</div> </div>

View File

@ -142,9 +142,6 @@
const tomonth = new Date(today.getFullYear(),today.getMonth(),1); const tomonth = new Date(today.getFullYear(),today.getMonth(),1);
const tomonthl = new Date(today.getFullYear(),today.getMonth()+1,0); const tomonthl = new Date(today.getFullYear(),today.getMonth()+1,0);
const firstDay = tomonth.getDay(); const firstDay = tomonth.getDay();
console.log("today", today);
console.log("tomonth", tomonth);
console.log("firstday", firstDay);
const lastDate = tomonthl.getDate(); const lastDate = tomonthl.getDate();
const todayDate = today.getDate() const todayDate = today.getDate()
let x = 0; let x = 0;

View File

@ -142,9 +142,6 @@
const tomonth = new Date(today.getFullYear(),today.getMonth(),1); const tomonth = new Date(today.getFullYear(),today.getMonth(),1);
const tomonthl = new Date(today.getFullYear(),today.getMonth()+1,0); const tomonthl = new Date(today.getFullYear(),today.getMonth()+1,0);
const firstDay = tomonth.getDay(); const firstDay = tomonth.getDay();
console.log("today", today);
console.log("tomonth", tomonth);
console.log("firstday", firstDay);
const lastDate = tomonthl.getDate(); const lastDate = tomonthl.getDate();
const todayDate = today.getDate() const todayDate = today.getDate()
let x = 0; let x = 0;

View File

@ -142,9 +142,6 @@
const tomonth = new Date(today.getFullYear(),today.getMonth(),1); const tomonth = new Date(today.getFullYear(),today.getMonth(),1);
const tomonthl = new Date(today.getFullYear(),today.getMonth()+1,0); const tomonthl = new Date(today.getFullYear(),today.getMonth()+1,0);
const firstDay = tomonth.getDay(); const firstDay = tomonth.getDay();
console.log("today", today);
console.log("tomonth", tomonth);
console.log("firstday", firstDay);
const lastDate = tomonthl.getDate(); const lastDate = tomonthl.getDate();
const todayDate = today.getDate() const todayDate = today.getDate()
let x = 0; let x = 0;

View File

@ -66,6 +66,7 @@
moly.loadScreen.close(loadid); moly.loadScreen.close(loadid);
return; return;
} }
thisDialog.resolve(true);
moly.loadScreen.close(loadid); moly.loadScreen.close(loadid);
}); });
//["prokerid", "notes", "evidence"] //["prokerid", "notes", "evidence"]

View File

@ -50,6 +50,7 @@
<script type="module"> <script type="module">
const thisDialog = moly.lastDialog(); const thisDialog = moly.lastDialog();
const data = thisDialog.data; const data = thisDialog.data;
console.log(data);
function µ(selector) function µ(selector)
{ {
if (selector) return $(thisDialog.box).find(selector); if (selector) return $(thisDialog.box).find(selector);
@ -69,7 +70,7 @@
const proker = const proker =
{ {
prokerid: gen16BytesID(), prokerid: gen16BytesID(),
agentID: data.agentID, agentID: data.info.agentID,
kegiatan: Number(µ('#kegiatan').val()), kegiatan: Number(µ('#kegiatan').val()),
sasaran: µ('#sasaran').val(), sasaran: µ('#sasaran').val(),
startDay, startDay,
@ -85,12 +86,10 @@
|| proker.entTarget.length < 1 || proker.indicator.length < 1 || proker.action.length < 1) || proker.entTarget.length < 1 || proker.indicator.length < 1 || proker.action.length < 1)
{ {
moly.alert.show("Data Belum Lengkap","Harap isi data dengan lengkap. Setiap kolom yang ditampilkan wajib diisi."); moly.alert.show("Data Belum Lengkap","Harap isi data dengan lengkap. Setiap kolom yang ditampilkan wajib diisi.");
console.log(proker);
moly.loadScreen.close(loadid); moly.loadScreen.close(loadid);
return; return;
} }
const mkproker = await postJson('/api/mkproker',proker); const mkproker = await postJson('/api/mkproker',proker);
console.log(mkproker)
if (mkproker.status != 201) if (mkproker.status != 201)
{ {
moly.alert.show("Simpan Program Kerja Gagal","Program kerja tidak dapat disimpan. Silakan coba kembali beberapa saat lagi."); moly.alert.show("Simpan Program Kerja Gagal","Program kerja tidak dapat disimpan. Silakan coba kembali beberapa saat lagi.");

View File

@ -184,7 +184,26 @@
const deadline = new Date((v.isInMonth ? new Date(v.year, v.startMonth + v.timeTarget, 0) : new Date(v.year, v.startMonth -1, v.startDay + v.timeTarget)).setHours(23,59,59)); const deadline = new Date((v.isInMonth ? new Date(v.year, v.startMonth + v.timeTarget, 0) : new Date(v.year, v.startMonth -1, v.startDay + v.timeTarget)).setHours(23,59,59));
const neardeadline = new Date((new Date(deadline)).setDate(deadline.getDate() - 15)).setHours(0,0,0,0); const neardeadline = new Date((new Date(deadline)).setDate(deadline.getDate() - 15)).setHours(0,0,0,0);
// v.status = v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3; // v.status = v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3;
v.status = v.journal.at(-1).status == 8 ? (v.journal.at(-2).status == 4 && doneline < lifeline ? 4 : v.journal.at(-2).status == 4 && doneline <= deadline ? 5 : v.journal.at(-2).status == 4 && doneline > deadline ? 6 : v.journal.at(-2).status == 3 && v.year < Now.getFullYear() ? 7 : 3) : (v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3); v.status = v.journal.at(-1).status == 8 ?
(v.journal.at(-2).status == 4 && doneline < lifeline ? 4
: v.journal.at(-2).status == 4 && doneline <= deadline ? 5
: v.journal.at(-2).status == 4 && doneline > deadline ? 6
: v.journal.at(-2).status == 3 && v.year < Now.getFullYear() ? 7
: v.journal.at(-2).status)
: (v.journal.at(-1).status == 4 && doneline < lifeline ? 4
: v.journal.at(-1).status == 4 && doneline <= deadline ? 5
: v.journal.at(-1).status == 4 && doneline > deadline ? 6
: v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7
: v.journal.at(-1).status);
// "Draft",
// "Ditolak",
// "Diajukan",
// "Berjalan",
// "Lebih Awal",
// "Tepat Waktu",
// "Terlambat",
// "Tidak Terlaksana"
st.append(statusName[v.status]); st.append(statusName[v.status]);
ev.append(v.journal.at(-1).status == 8 ? "Sudah" : v.journal.at(-1).status < 4 ? "---" : "Belum"); ev.append(v.journal.at(-1).status == 8 ? "Sudah" : v.journal.at(-1).status < 4 ? "---" : "Belum");
ev.style.textAlign = "center"; ev.style.textAlign = "center";
@ -209,7 +228,8 @@
} }
else if (data.journal.at(-1).status > 2) else if (data.journal.at(-1).status > 2)
{ {
await moly.dialog.show({title: "Upload Eviden Akhir Aksi Perubahan", content: "/modules/kegiatan-proker-finish.html", fetching: true, data}) const ev = await moly.dialog.show({title: "Upload Eviden Akhir Aksi Perubahan", content: "/modules/kegiatan-proker-finish.html", fetching: true, data});
if (ev) populateProker();
} }
}) })
$('#proker #pkContent').append(ro); $('#proker #pkContent').append(ro);

View File

@ -0,0 +1,3 @@
<div style="text-align: center;">
Belum Cukup Data
</div>

View File

@ -216,7 +216,7 @@
const lifeline = (v.isInMonth ? new Date(v.year, v.startMonth -1, 1) : new Date(v.year, v.startMonth -1, v.startDay)).setHours(0,0,0,0); const lifeline = (v.isInMonth ? new Date(v.year, v.startMonth -1, 1) : new Date(v.year, v.startMonth -1, v.startDay)).setHours(0,0,0,0);
const deadline = new Date((v.isInMonth ? new Date(v.year, v.startMonth + v.timeTarget, 0) : new Date(v.year, v.startMonth -1, v.startDay + v.timeTarget)).setHours(23,59,59)); const deadline = new Date((v.isInMonth ? new Date(v.year, v.startMonth + v.timeTarget, 0) : new Date(v.year, v.startMonth -1, v.startDay + v.timeTarget)).setHours(23,59,59));
const neardeadline = new Date((new Date(deadline)).setDate(deadline.getDate() - 15)).setHours(0,0,0,0); const neardeadline = new Date((new Date(deadline)).setDate(deadline.getDate() - 15)).setHours(0,0,0,0);
v.status = v.journal.at(-1).status == 8 ? (v.journal.at(-2).status == 4 && doneline < lifeline ? 4 : v.journal.at(-2).status == 4 && doneline <= deadline ? 5 : v.journal.at(-2).status == 4 && doneline > deadline ? 6 : v.journal.at(-2).status == 3 && v.year < Now.getFullYear() ? 7 : 3) : (v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3); v.status = v.journal.at(-1).status == 8 ? (v.journal.at(-2).status == 4 && doneline < lifeline ? 4 : v.journal.at(-2).status == 4 && doneline <= deadline ? 5 : v.journal.at(-2).status == 4 && doneline > deadline ? 6 : v.journal.at(-2).status == 3 && v.year < Now.getFullYear() ? 7 : v.journal.at(-2).status) : (v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : v.journal.at(-1).status);
st.append(statusName[v.status]); st.append(statusName[v.status]);
v.styleCode = v.status != 3 ? v.status : Now < lifeline ? 8 : Now < neardeadline ? 9 : Now >= neardeadline && Now < deadline ? 10 : 11; v.styleCode = v.status != 3 ? v.status : Now < lifeline ? 8 : Now < neardeadline ? 9 : Now >= neardeadline && Now < deadline ? 10 : 11;
// $(st).text(v.status != 3 ? $(st).text() : Now < lifeline ? "Belum Jadwalnya" : Now < neardeadline ? "Berjalan" : Now >= neardeadline && Now <= deadline ? "Hampir Deadline" : "Lewat Deadline"); // $(st).text(v.status != 3 ? $(st).text() : Now < lifeline ? "Belum Jadwalnya" : Now < neardeadline ? "Berjalan" : Now >= neardeadline && Now <= deadline ? "Hampir Deadline" : "Lewat Deadline");

74
modules/regulasi-new.html Normal file
View File

@ -0,0 +1,74 @@
<div style="display: grid; grid-template-columns: auto 1fr; column-gap: 1ch; padding: 1ch">
<div>
Nomor/Judul Dokumen:<br>
<input type="text"id="judul" style="width: 50ch;" maxlength="126"><br>
Abstrak:<br>
<textarea id="abstrak" style="width: 50ch; height: 8em; resize: none;" maxlength="1148" placeholder="Ringkasan isi dokumen untuh kemudahan"></textarea><br>
<file-input id="pdf" accept="application/pdf" style="width: 50ch;"></file-input><br>
<div style="margin-top: .5em; display: grid; grid-template-columns: 1fr auto;">
<span id="warn" style="color: var(--negative-accent); white-space: nowrap; text-overflow: ellipsis; overflow: hidden;"></span>
<a-button id="sub">Simpan</a-button>
</div>
</div>
<div>
<iframe style="width: calc(85vw - 52ch); height: 80vh; background-color: dimgray; border: none;"></iframe>
</div>
</div>
<script type="module">
const thisDialog = moly.lastDialog();
const data = thisDialog.data;
const frm = µ('iframe')[0];
let file = null;
function µ(selector)
{
if (selector) return $(thisDialog.box).find(selector);
return $(thisDialog.box);
}
µ('#sub').click(async()=>
{
if(!file) return;
const loadid = moly.loadScreen.show("Memroses berkas...","bar","#"+µ('div[id^="db"]')[0].id);
const data ={
judul: µ('#judul').val(),
abstrak: µ('#abstrak').val(),
pdf: file?.data
}
if (data.judul.length < 1 || data.abstrak.length < 1|| data.pdf?.length < 1)
{
moly.alert.show("Detil Regulasi Belum Lengkap","Harap isikan seluruh kilom yang ditampilkan.")
moly.loadScreen.close(loadid);
return;
}
const rg = await postJson("/api/addreg",data);
if (rg.status != 201)
{
moly.alert.show("Gagal Menambah Entri Regulasi","Entri Dokumen Regulasi tidak berhasil ditambahkan. Silakan ulangi kembali beberapa saat lagi.");
moly.loadScreen.close(loadid);
return;
}
moly.loadScreen.close(loadid);
thisDialog.resolve(true);
})
µ('#pdf').change(async()=>
{
µ('#sub').prop("disabled",false);
µ('#warn').text("");
if(µ('#pdf')[0]._input.files.length < 1)
{
file = null;
return;
}
const loadid = moly.loadScreen.show("Memroses berkas...","bar","#"+µ('div[id^="db"]')[0].id);
file = await moly.file.serialise(µ('#pdf')[0]._input.files[0]);
frm.src = "data:application/pdf;base64," + file.data;
const exist = thisDialog.data.find(r=>r.id.includes(file.crc32))
if (exist)
{
µ('#warn').text("Sudah ada dengan Judul: "+ exist.judul);
µ('#sub').prop("disabled",true);
}
moly.loadScreen.close(loadid);
})
</script>

View File

@ -0,0 +1,50 @@
<div style="display: grid; grid-template-columns: auto 1fr; column-gap: 1ch; padding: 1ch">
<div>
<div style="padding-bottom: 1em; margin-bottom: 1em; border-bottom: 1px solid var(--secondary-foreground);">
Diupload oleh <span id="ag"></span><br>
Pada <span id="ts"></span>
</div>
Nomor/Judul Dokumen:<br>
<input type="text"id="judul" style="width: 50ch;" maxlength="126" readonly><br>
Abstrak:<br>
<textarea id="abstrak" style="width: 50ch; height: 8em; resize: none;" maxlength="1148" placeholder="(Abstrak tidak diisi)" readonly></textarea>
<div style="padding-top: 1em; margin-top: 1em; border-top: 1px solid var(--secondary-foreground);" id="uploaderMenu" hidden>
<a-button id="remove" type="negative">Hapus Entri Regulasi</a-button>
</div>
</div>
<div>
<iframe style="width: calc(85vw - 52ch); height: 80vh;"></iframe>
</div>
</div>
<script type="module">
const thisDialog = moly.lastDialog();
const data = thisDialog.data;
const frm = µ('iframe')[0];
console.log(data);
µ('#judul').val(data.judul);
µ('#abstrak').val(data.abstrak);
µ('#ag').text(data.uploader);
µ('#ts').text(data.timeStamp);
frm.src = "/uploads/regulasi/" + data.id;
µ('#uploaderMenu').prop("hidden", userDetails.info.agentID != data.agentID);
µ('#remove').click(async()=>{
const conf = await moly.confirm.show("Hapus Entri Regulasi","Lanjutkan menghapus entri? Entri terhapus tidak dapat dikembalikan.", "Hapus", "Batal", false, null);
if(!conf) return;
const loadid = moly.loadScreen.show("Menghapus entri...","bar","#"+µ('div[id^="db"]')[0].id);
const rem = await postJson("/api/remreg",{id:data.id});
if (rem.status != 200)
{
moly.alert.show("Entri Tidak Terhapus","Entri Regulasi tidak berhasi dihapus. Silakan ulangi kembali beberapa saat lagi.");
moly.loadScreen.close(loadid);
return;
}
moly.loadScreen.close(loadid);
thisDialog.resolve(true);
});
function µ(selector)
{
if (selector) return $(thisDialog.box).find(selector);
return $(thisDialog.box);
}
</script>

71
modules/regulasi.html Normal file
View File

@ -0,0 +1,71 @@
<div style="max-height: calc(50vh - 6em); overflow-y: scroll; margin: 0 0 1em 0; padding: 0 2ch 2ch 2ch;" id="rgWrapper">
<table id="regs" class="bordered selectable">
<colgroup>
<col style="width: 25ch;">
<col>
<col style="width: 20ch;">
<col style="width: 19ch;">
</colgroup>
<thead>
<tr>
<th>Nomor/Judul</th>
<th>Abstrak</th>
<th>Diupload Oleh</th>
<th>Pada</th>
</tr>
</thead>
<tbody id="empty">
<tr>
<td colspan="4" style="text-align: center;">Data Kosong</td>
</tr>
</tbody>
<tbody id="rgContent" hidden>
</tbody>
</table>
</div>
<a-button id="newReg">Entri Regulasi</a-button>
<script type="module">
let regulations = [];
async function getRegs()
{
regulations = [];
const regs = await getJson("/api/regs");
if (regs.status != 200) return;
regulations = regs.data;
µ('#empty').prop("hidden",!(regulations.length < 1));
µ('#rgContent').prop("hidden",(regulations.length < 1));
µ('#rgContent').empty();
$.each(regulations,(_,v)=>{
v.timeStamp = v.timeStamp.replace("T"," ")
const ro = moly.newElement("tr");
const jd = moly.newElement("td");
const ab = moly.newElement("td");
const ag = moly.newElement("td");
const ts = moly.newElement("td");
ro.append(jd);
ro.append(ab);
ro.append(ag);
ro.append(ts);
jd.append(v.judul);
ab.append(v.abstrak);
v.uploader = agents.find(a=>a.agentID == v.agentID).name;
ag.append(v.uploader);
ts.append(v.timeStamp);
$(ro).click(async()=>{
const rem = await moly.dialog.show({title: "Lihat Regulasi", content: "/modules/regulasi-view.html", fetching: true, data: v});
if (rem) getRegs();
});
µ('#rgContent').append(ro);
})
}
function µ(selector)
{
if (selector) return $('body>#main>#content').find(selector);
return $('body>#main>#content');
}
µ('#newReg').click(async()=>{
const rg = await moly.dialog.show({title: "Entri Dokumen Regulasi", content:"/modules/regulasi-new.html",fetching: true, data: regulations})
if(rg) getRegs();
});
getRegs();
</script>

View File

@ -213,7 +213,7 @@
const deadline = new Date((v.isInMonth ? new Date(v.year, v.startMonth + v.timeTarget, 0) : new Date(v.year, v.startMonth -1, v.startDay + v.timeTarget)).setHours(23,59,59)); const deadline = new Date((v.isInMonth ? new Date(v.year, v.startMonth + v.timeTarget, 0) : new Date(v.year, v.startMonth -1, v.startDay + v.timeTarget)).setHours(23,59,59));
const neardeadline = new Date((new Date(deadline)).setDate(deadline.getDate() - 15)).setHours(0,0,0,0); const neardeadline = new Date((new Date(deadline)).setDate(deadline.getDate() - 15)).setHours(0,0,0,0);
// v.status = v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3; // v.status = v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3;
v.status = v.journal.at(-1).status == 8 ? (v.journal.at(-2).status == 4 && doneline < lifeline ? 4 : v.journal.at(-2).status == 4 && doneline <= deadline ? 5 : v.journal.at(-2).status == 4 && doneline > deadline ? 6 : v.journal.at(-2).status == 3 && v.year < Now.getFullYear() ? 7 : 3) : (v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : 3); v.status = v.journal.at(-1).status == 8 ? (v.journal.at(-2).status == 4 && doneline < lifeline ? 4 : v.journal.at(-2).status == 4 && doneline <= deadline ? 5 : v.journal.at(-2).status == 4 && doneline > deadline ? 6 : v.journal.at(-2).status == 3 && v.year < Now.getFullYear() ? 7 : v.journal.at(-2).status) : (v.journal.at(-1).status == 4 && doneline < lifeline ? 4 : v.journal.at(-1).status == 4 && doneline <= deadline ? 5 : v.journal.at(-1).status == 4 && doneline > deadline ? 6 : v.journal.at(-1).status == 3 && v.year < Now.getFullYear() ? 7 : v.journal.at(-1).status);
st.append(statusName[v.status]); st.append(statusName[v.status]);
v.styleCode = v.status != 3 ? v.status : Now < lifeline ? 8 : Now < neardeadline ? 9 : Now >= neardeadline && Now < deadline ? 10 : 11; v.styleCode = v.status != 3 ? v.status : Now < lifeline ? 8 : Now < neardeadline ? 9 : Now >= neardeadline && Now < deadline ? 10 : 11;
$(st).text(v.status != 3 ? $(st).text() : Now < lifeline ? "Belum Jadwalnya" : Now < neardeadline ? "Berjalan" : Now >= neardeadline && Now.getDate() == deadline.getDate() && Now.getMonth() == deadline.getMonth() ? "Deadline!" : Now >= neardeadline && Now <= deadline ? "Hampir Deadline" : "Lewat Deadline"); $(st).text(v.status != 3 ? $(st).text() : Now < lifeline ? "Belum Jadwalnya" : Now < neardeadline ? "Berjalan" : Now >= neardeadline && Now.getDate() == deadline.getDate() && Now.getMonth() == deadline.getMonth() ? "Deadline!" : Now >= neardeadline && Now <= deadline ? "Hampir Deadline" : "Lewat Deadline");