You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

871 lines
20 KiB
JavaScript

let form1 = [
{
title: 'Kode',
type: 'text',
name: 'kode',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Gaji',
type: 'text',
name: 'gaji',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'NIP',
type: 'text',
name: 'nip',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Status',
type: 'select',
name: 'status',
line: 80,
row: 4,
data: [{ id: '0', text: "Aktif" }, { id: '1', text: "Keluar" }],
readonly: false,
action: function () {
},
}
, {
title: 'Instansi',
type: 'radio',
name: 'dept',
line: 80,
row: 4,
readonly: false,
data: JSON.parse(_id('datainternal').innerHTML),
action: function () {
},
}
, {
title: 'Unit Kerja',
type: 'select',
name: 'unitkerja',
line: 80,
row: 4,
readonly: false,
data: JSON.parse(_id('munit').innerHTML),
action: function () {
},
}
, {
title: 'Nama',
type: 'text',
name: 'nama',
line: 80,
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'Alamat',
type: 'text',
name: 'alamat',
line: 80,
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'Tgl. Gabung',
type: 'date',
name: 'masuk',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Tgl. Lahir',
type: 'date',
name: 'tgllahir',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Jenis Kelamin',
type: 'select',
name: 'jk',
line: 80,
row: 4,
data: [{ id: 'L', text: "Laki-laki" }, { id: 'P', text: "Perempuan" }],
readonly: false,
action: function () {
},
}
, {
title: 'Kota',
type: 'text',
name: 'kota',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Kode Pos',
type: 'text',
name: 'kdpos',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'No. Telp/Hp',
type: 'text',
name: 'telp',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'No. KTP',
type: 'text',
name: 'ktp',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Juru Bayar',
type: 'select',
name: 'jurubayar',
line: 80,
row: 4,
data: window._master('jurubayar', 'jurubayar'),
readonly: false,
action: function () {
},
}
, {
title: 'Rekap Golongan',
type: 'select',
name: 'rekapgol',
line: 80,
row: 4,
data: window._master('rekapgol', 'rekapgol'),
readonly: false,
action: function () {
},
}
, {
title: 'Pokok',
type: 'number',
name: 'pokok',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Wajib',
type: 'number',
name: 'wajib',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Manasuka',
type: 'number',
name: 'manasuka',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Belanja Wajib',
type: 'number',
name: 'bw',
line: 120,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Simpanan Wajib Pinjam',
type: 'number',
name: 'swp',
line: 170,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Tabungan Khusus',
type: 'number',
name: 'tk',
line: 170,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Laporan Partisipasi',
type: 'radio',
name: 'laporan',
line: 170,
row: 4,
data: [
{
id: '1',
text: 'Ditampilkan'
}
,{
id: '0',
text: 'Tidak ditampilkan'
}
],
readonly: false,
action: function () {
},
}
, {
title: 'SHU BUKU',
type: 'radio',
name: 'shubuku',
line: 170,
row: 4,
data: [
{
id: '1',
text: 'Ditampilkan'
}
,{
id: '0',
text: 'Tidak ditampilkan'
}
],
readonly: false,
action: function () {
},
}
]
let form2 = [
{
title: 'Kode',
type: 'text',
name: 'kode',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Gaji',
type: 'text',
name: 'gaji',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'NIP',
type: 'text',
name: 'nip',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Status',
type: 'select',
name: 'status',
line: 80,
row: 4,
data: [{ id: '0', text: "Aktif" }, { id: '1', text: "Keluar" }],
readonly: false,
action: function () {
},
}
, {
title: 'Instansi',
type: 'radio',
name: 'dept',
line: 80,
row: 4,
readonly: false,
data: JSON.parse(_id('datainternal').innerHTML),
action: function () {
},
}
, {
title: 'Unit Kerja',
type: 'select',
name: 'unitkerja',
line: 80,
row: 4,
readonly: false,
data: JSON.parse(_id('munit').innerHTML),
action: function () {
},
}
, {
title: 'Nama',
type: 'text',
name: 'nama',
line: 80,
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'Alamat',
type: 'text',
name: 'alamat',
line: 80,
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'Tgl. Gabung',
type: 'date',
name: 'masuk',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Tgl. Lahir',
type: 'date',
name: 'tgllahir',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Jenis Kelamin',
type: 'select',
name: 'jk',
line: 80,
row: 4,
data: [{ id: 'L', text: "Laki-laki" }, { id: 'P', text: "Perempuan" }],
readonly: false,
action: function () {
},
}
, {
title: 'Kota',
type: 'text',
name: 'kota',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Kode Pos',
type: 'text',
name: 'kdpos',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'No. Telp/Hp',
type: 'text',
name: 'telp',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'No. KTP',
type: 'text',
name: 'ktp',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Juru Bayar',
type: 'select',
name: 'jurubayar',
line: 80,
row: 4,
data: window._master('jurubayar', 'jurubayar'),
readonly: false,
action: function () {
},
}
, {
title: 'Rekap Golongan',
type: 'select',
name: 'rekapgol',
line: 80,
row: 4,
data: window._master('rekapgol', 'rekapgol'),
readonly: false,
action: function () {
},
}
, {
title: 'Pokok',
type: 'number',
name: 'pokok',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Wajib',
type: 'number',
name: 'wajib',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Manasuka',
type: 'number',
name: 'manasuka',
line: 80,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Belanja Wajib',
type: 'number',
name: 'bw',
line: 120,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Simpanan Wajib Pinjam',
type: 'number',
name: 'swp',
line: 170,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Tabungan Khusus',
type: 'number',
name: 'tk',
line: 170,
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'Tanggal Keluar',
type: 'date',
name: 'keluar',
line: 170,
row: 4,
readonly: false,
action: function () {
},
}
]
const objectForm = {
title: function () {
return 'Anggota ';
},
custQuery: function(status = true){
if( typeof status === 'boolean'){
let statusCode = "IS NULL";
if(status === true){
statusCode = "IS NOT NULL";
}
this.queryTemp = `
SELECT {select} FROM anggota WHERE keluar ${statusCode} || ORDER BY kode DESC
`;
}
return this;
},
serverSide: true,
table: "anggota",
orientation:'l',
idform: "containerforms",
newkode: `
SELECT
LPAD(
(
ifnull(
(
SELECT kode FROM anggota ORDER BY kode DESC LIMIT 1
),0
) + 1
), 10,0
)
kode`,
columnsExport: [1, 2, 3, 4, 5,6,7,8,9,10],
kode: 'kode',
connection: [
{
table: "mags",
kode: "kode",
}
,{
table: "msimpan",
kode: "kode",
}
,{
table: "mpinjam",
kode: "kode",
}
],
custome: {
keluar: function(a, b){
if(a === null){
return `<button onclick="window.updateStatus('${b.kode}', 'u')" class="btn btn-clear">Set Anggota Keluar</button>`;
}
return `
<button onclick="window.updateStatus('${b.kode}', 'r')" class="btn btn-clear">Set Anggota Aktif</button>
`;
},
sk: function(a, b){
if(!a){
return ` aktif `
}
return tanggal(a).sekarang;
},
masuk: function(a, b){
if(!a){
return ` - `
}
return tanggal(a).sekarang;
},
nip: function (a) {
if (a == '') {
return '-';
} else {
return a;
}
},
alamat: function (a) {
if (a == '') {
return '-';
} else {
return a;
}
},
jurubayar: function(a){
return a;
},
unitkerja: function (a) {
if (JSON.parse(_id('munit').innerHTML).cond(a, 'id').length > 0 ){
return JSON.parse(_id('munit').innerHTML).cond(a, 'id')[0].text;
}else{
return a;
}
}
},
dataSelect: ["*, keluar sk"],
queryTemp: "SELECT {select} FROM anggota WHERE keluar IS NULL || ORDER BY kode DESC",
view: ['keluar', 'kode', 'nama', 'tgllahir', 'masuk', 'nip', 'jurubayar', 'unitkerja', 'alamat', 'sk'],
validasiForm: ['kode', 'nama', 'jurubayar', 'unitkerja', 'rekapgol'],
oncreate: function () {
globalThis['kode'].parent.removeAttribute('readonly');
globalThis['kode'].parent.value = '';
$('#unitkerja').val('').trigger('change');
$('#jk').val('').trigger('change');
_setval('masuk', tanggal().normal);
_setval('tgllahir', tanggal().normal);
},
onupdate: function (dt) {
globalThis['kode'].parent.setAttribute('readonly', true);
$('#unitkerja').val(dt.unitkerja).trigger('change');
console.log(dt.laporan)
_setval('laporan', dt.laporan)
},
data: form1
};
window._kta = function () {
AuditDevQuery(`SELECT * FROM anggota`, function (p) {
_pdfMakeKTA(p);
});
};
window._pushbb = function (kode, status){
}
window.updateStatus = function(kode, status){
let update = 'NULL'
let statuss = '0'
if(status === 'u'){
update = '"'+tanggal().normal+'"';
statuss = '1';
}
let query = `
UPDATE anggota SET keluar = ${update}, status = "${statuss}" WHERE kode = '${kode}'
`;
confirmation({
title: 'Peringatan !',
text: 'Apa anda yakin ingin mengeluarkan anggota ?',
callback: function(){
AuditDevQuery(query, function(response){
if (typeof _load != 'undefined') {
_load();
}
});
}
})
}
Array.from(document.querySelectorAll("[data-kode]")).forEach(function(s){
s.onclick = function(){
var kode = this.dataset.kode;
if(kode === 'true'){
objectForm.custQuery(true);
objectForm.data = form2;
__forms()
if(typeof _load != 'undefined'){
_load()
};
typeof _setHTML == 'function'? _setHTML('.keluar', 'Tgl. Keluar',1) : null;
}else{
console.log('ss')
objectForm.data = form1;
__forms()
objectForm.custQuery(false);
if(typeof _load != 'undefined'){
_load()
};
typeof _setHTML == 'function' ? _setHTML('.keluar', 'Status', 1) : null;
}
}
});
const potongTeks = function (teks, panjangMaks) {
if (teks.length <= panjangMaks) {
return teks;
} else {
return teks.slice(0, panjangMaks) + "...";
}
}
const checkData = function (a, b) {
if (typeof a === 'object') {
if (a[b] != undefined) {
return potongTeks(a[b], 38);
}
return '-';
}
return '-';
}
const jk = function (a, b) {
if (typeof a === 'object') {
if (a[b] != undefined) {
if (a[b] === 'L') {
return 'Laki laki'
}
return 'Perempuan';
}
return '-';
}
return '-';
}
window._pdfMakeKTA = function (a) {
var col = [];
let ln = Math.ceil(a.length / 3);
let numStart = 0;
for (let i = 0; i < ln; i++) {
let nd = [];
let data = {};
if (a[numStart] != undefined) {
data = a[numStart];
}
numStart++;
for (let q = 0; q < 3; q++) {
nd.push([
{
table: {
widths: ['*'],
body: [
[
[
{ text: 'BIODATA ANGGOTA', style: ['center', 's2', 'bold'] }
, {
layout: 'lightHorizontalLines'
, table: {
widths: [69, 3, '*']
, body: [
[{ text: 'NO.INDUK', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: '', style: ['s1'] }]
, [{ text: 'NAMA', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data, 'nama'), style: ['s1'] }]
, [{ text: 'TGL. LAHIR', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: tanggal(checkData(data, 'tgllahir')).sekarang, style: ['s1'] }]
, [{ text: 'JENIS KELAMIN', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: jk(data, 'jk'), style: ['s1'] }]
, [{ text: 'TELP', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data, 'telp'), style: ['s1'] }]
, [{ text: 'UNIT KERJA', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data, 'unitkerja'), style: ['s1'] }]
, [{ text: 'ALAMAT RUMAH', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data, 'alamat'), style: ['s1'] }]
, [{ text: 'TAHUN MASUK', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: tanggal(checkData(data, 'masuk')).sekarang, style: ['s1'] }]
]
}
}
, { text: 'Keterangan', style: ['s2', 'bold'] }
, {
layout: 'noBorders'
, table: {
widths: [3, '*']
, body: [
[{ text: '-', style: ['s1'] }, { text: 'Mohon dikoreksi ulang untuk kejelasan data.', style: ['s1'] }]
, [{ text: '-', style: ['s1'] }, { text: 'Untuk unit kerja Guru TK/SD/SMP/SMA, harap ditulis lengkap nama sekolahannya.', style: ['s1'] }]
, [{ text: '-', style: ['s1'] }, { text: 'Apabila terdapat kesalahan data, maka bisa di konfirmasi ke nomor Warpeka ( 085 748 055 474 ).', style: ['s1'] }]
]
}
}
]
],
]
}
}
])
}
col.push({
columns: nd,
columnGap: 5
})
}
var docDefinition = {
pageOrientation: 'landscape',
pageMargins: [5, 5, 5, 5],
content: col
, styles: {
s1: {
margin: [5, 0],
fontSize: 7.5,
},
s2: {
margin: [5, 0],
fontSize: 8,
},
bold: {
bold: true
},
center: {
alignment: 'center'
}
}
};
pdfMake.createPdf(docDefinition).open()
};