Files
Fuchs_Intranet/Fuchs/js/intranet/modules/fis.rep.js
T

82 lines
3.7 KiB
JavaScript

function getMonday(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
return new Date(d.setDate(diff));
}
let $rep = {
init2: function (type, options) {
//console.debug('inv.init2');
type = type || 'inv';
options = options || {};
$ocms.getScript([
//{ script: 'web/jstree.min.js', css: 'web/jstree.min.css', condition: typeof $.fn.jstree !== 'function' }
//, { script: 'web/jquery.qtip.min.js', css: 'web/jquery.qtip.min.css', condition: typeof $.fn.qtip !== 'function' }
//, { script: 'web/typeahead.min.js', css: '', condition: typeof $.fn.typeahead !== 'function' }
//, { script: 'web/fullcalendar.min.js', module: 'FullCalendar', css: 'web/fullcalendar.min.css', condition: typeof FullCalendar !== 'object' }
], function () {
//FullCalendar = $vm.FullCalendar;
$rep.init3(type, options);
});
}, init3: async function (type, options) {
//console.debug('inv.init3');
let cf = $('#contentframe').empty(), cf2 = $$.dc('cfrm hd').appendTo(cf), frm = $$.dc('init_frm', cf);
let tbar = $('#topbar').ocmsmenu([]); //{ lbl: 'home', fnc: $rep.init3 }
$('#activemodule').text($ct.mdl);
let repfrm = $$.dc('repfrm', frm);
let td = new Date();
let pa = [(async () => {
if (await $fis.getAuth('fds_reports') > 0) {
frm.IN(function () { });
let lf = $('#listframe').empty().aC('fix').rC('hd');
let scp = function (rx) {
let itm = $(this);
if ((rx.params || []).length > 0) {
let ifrm = $$.dc('ipf', itm).click(function (ev) {
ev.stopPropagation();
});
$.each(rx.params, (pi, px) => {
let ig = $$.dc('ig', ifrm).append($$.lbl(px.name)), i;
if ((px.valuelist || '') === '') {
i = $$.i({ name: px.name, placeholder: px.placeholder }).appendTo(ig);
if ((px.default || '') !== '') {
i.val(px.default);
}
}
});
}
};
let scl = function (ev) {
//console.debug(ev);
let btn = $(this), rx = ev.data;
$ocms.postXT({
url: $ocms.url('rep/gct/' + rx.name), data: btn.serializeObject(), success: (response) => {
btn.addClass('selected').siblings().removeClass('selected');
$('#listframe').rC('fix').aC('hd');
repfrm.html(response);
}, datatype: 'html'
});
};
$ocms.postXT({
url: $ocms.url('rep/catalog'), data: {}, success: (response) => {
$.each(response.reports, (ri, rx) => {
let i = $$.dc('repitm', lf).text(rx.label).click(rx, scl);
scp.call(i, rx);
});
}
});
}
})(), new Promise((resolve, reject) => {
//$rep.123()
/*
let tgt = fdt(new Date(td.getFullYear(), (td.getMonth() - 1), 1), 'yy-MM-dd');
$rep.renderinv.call(invfrm, tgt, 'm');
*/
})];
await Promise.all(pa);
}
}
let $$rep = { init2: $rep.init2, auth: {} };
export default $$rep;