VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/keeview_app/html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/keeview_app/html/bsc_approval_values.js
hr.bsc_approval_values.makeLockData = function(host){
    var today = contentModule.getDateFrom1970(new Date());
    host.database.bsc_input_queues.items.forEach(function(item){
        item.locked = true;
        var expireddate;
        switch (systemconfig.bsc_locked_by) {
            case "day":
                expireddate = item.idate + systemconfig.locked_after + 1;
                break;
            case "week":
                expireddate = contentModule.getDateFrom1970(absol.datetime.nextWeek(new Date(item.idate*86400000))) + systemconfig.bsc_locked_on_day;
                break;
            case "month":
                expireddate = contentModule.getDateFrom1970(absol.datetime.nextMonth(new Date(item.idate*86400000))) + systemconfig.bsc_locked_on_day;
                break;
            default:
                expireddate = 0;
        }
        if (expireddate > today) item.locked = false;
        else {
            var uItem;
            for (var i = 0; i < host.database.bsc_unlock_values.items.length; i++){
                uItem = host.database.bsc_unlock_values.items[i];
                if ((item.idate >= uItem.startdate) && (item.idate <= uItem.enddate)){
                    if ((uItem.criterias.indexOf(0) >= 0) || (uItem.criterias.indexOf(item.criteriaid) >= 0)){
                        item.locked = false;
                        break;
                    }
                }
            }
        }
    });
};

hr.bsc_approval_values.denyvalue = function(host, idList, comment){
    ModalElement.show_loading();
    FormClass.api_call({
        url: "bsc_approval_values_deny.php",
        params: [
            {name: "idList", value: EncodingClass.string.fromVariable(idList)},
            {name: "deny_reason", value: comment}
        ],
        func: function(success, message){
            ModalElement.close(-1);
            if (success){
                if (message.substr(0, 2) == "ok"){
                    var p;
                    for (var i = 0; i < idList.length; i++){
                        host.checkbox_input[idList[i]].remove();
                        delete host.checkbox_input[idList[i]];
                        p = host.statusEltList[idList[i]].parentElement;
                        DOMElement.removeAllChildren(p);
                        DOMElement.removeAllChildren(host.cmdEltList[idList[i]]);
                        p.appendChild(DOMElement.span({
                            attrs: {style: {color: "red"}},
                            text: LanguageModule.text("txt_deny")
                        }));
                    }
                    host.approvalBtnCtn.style.display = "none";
                    host.denyBtnCtn.style.display = "none";
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
            else {
                ModalElement.alert({message: message});
            }
        }
    });
};

hr.bsc_approval_values.denyValueConfirm = function(host, id){
    var idList;
    if (id == 0){
        idList = [];
        for (var queueid in host.checkbox_input){
            if (host.checkbox_input[queueid].checked) idList.push(queueid);
        }
    }
    else {
        idList = [id];
    }
    if (idList.length == 0) return;
    var comment_input = DOMElement.textarea({
        attrs: {
            className: "cardSimpleTextarea",
            style: {
                minWidth: "250px",
                width: "100%",
                height: "100px"
            }
        }
    });
    ModalElement.showWindow({
        title: LanguageModule.text("txt_deny_value"),
        bodycontent: DOMElement.div({
            children: [
                DOMElement.div({
                    attrs: {
                        style: {
                            height: "var(--control-height)",
                            lineHeight: "var(--control-height)",
                            width: "300px"
                        }
                    },
                    text: LanguageModule.text("txt_reason_deny")
                }),
                comment_input
            ]
        }),
        buttonlist: [
            {
                text: LanguageModule.text("txt_save"),
                onclick: function(){
                    ModalElement.close();
                    var comment = comment_input.value.trim();
                    hr.bsc_approval_values.denyvalue(host, idList, comment);
                }
            },
            {
                text: LanguageModule.text("txt_cancel"),
                onclick: function(){
                    ModalElement.close();
                }
            }
        ]
    });
    comment_input.focus();
};

hr.bsc_approval_values.approvalValue = function(host, id){
    var idList;
    if (id == 0){
        idList = [];
        for (var queueid in host.checkbox_input){
            if (host.checkbox_input[queueid].checked) idList.push(queueid);
        }
    }
    else {
        idList = [id];
    }
    if (idList.length == 0) return;
    ModalElement.show_loading();
    FormClass.api_call({
        url: "bsc_approval_values_approval.php",
        params: [{name: "idList", value: EncodingClass.string.fromVariable(idList)}],
        func: function(success, message){
            ModalElement.close(-1);
            if (success){
                if (message.substr(0, 2) == "ok"){
                    var p;
                    for (var i = 0; i < idList.length; i++){
                        host.checkbox_input[idList[i]].remove();
                        delete host.checkbox_input[idList[i]];
                        p = host.statusEltList[idList[i]].parentElement;
                        DOMElement.removeAllChildren(p);
                        DOMElement.removeAllChildren(host.cmdEltList[idList[i]]);
                        p.appendChild(DOMElement.span({
                            attrs: {style: {color: "blue"}},
                            text: LanguageModule.text("txt_approved")
                        }));
                    }
                    host.approvalBtnCtn.style.display = "none";
                    host.denyBtnCtn.style.display = "none";
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
            else {
                ModalElement.alert({message: message});
            }
        }
    });
};

hr.bsc_approval_values.time_org_change_func = function(host){
    var timestart, timeend;
    switch (host.period_select.value){
        case "month":
            timestart = contentModule.getDateFrom1970(absol.datetime.beginOfMonth(host.month_select.value));
            timeend = contentModule.getDateFrom1970(absol.datetime.nextMonth(host.month_select.value));
            break;
        case "quarter":
            timestart = contentModule.getDateFrom1970(absol.datetime.beginOfQuarter(host.quarter_select.value));
            timeend = contentModule.getDateFrom1970(absol.datetime.nextQuarter(host.quarter_select.value));
            break;
        case "year":
            timestart = contentModule.getDateFrom1970(absol.datetime.beginOfYear(host.year_select.value));
            timeend = contentModule.getDateFrom1970(absol.datetime.nextYear(host.year_select.value));
            break;
        default:
            timestart = 0;
            timeend = 0;
    }
    host.orgid = host.org_emp_select.value;
    if (host.orgid == 0){
        DOMElement.removeAllChildren(host.table_ctn);
        host.criteria_select.items = [];
        host.criteria_select.values = [];
        return;
    }
    if (systemconfig.privSystem < 2 && !data_module.admin_rights_of_me.functional_matrixs_scorecards){
        if (!host.privilegesDic[host.orgid] || !host.privilegesDic[host.orgid].approval_values){
            DOMElement.removeAllChildren(host.table_ctn);
            host.criteria_select.items = [];
            host.criteria_select.values = [];
            return;
        }
    }
    var rfirstid;
    if (host.orgid > 0){
        var oIndex = host.database.orgs.getIndex(host.orgid);
        rfirstid = host.database.orgs.items[oIndex].firstid;
    }
    else {
        var eIndex = host.database.employees.getIndex(-host.orgid);
        rfirstid = - host.database.employees.items[eIndex].firstid;
    }
    ModalElement.show_loading();
    FormClass.api_call({
        url: "database_load.php",
        params: [
            {name: "task", value: "bsc_approval_values_load_kpi_has_input_values_by_orgid_and_time"},
            {name: "rfirstid", value: rfirstid},
            {name: "timestart", value: timestart},
            {name: "timeend", value: timeend},
            {name: "today", value: contentModule.getDateFrom1970(new Date())}
        ],
        func: function(success, message){
            ModalElement.close(-1);
            if (success){
                if (message.substr(0, 2) == "ok"){
                    var st = EncodingClass.string.toVariable(message.substr(2));
                    contentModule.makeDatabaseContent(host, st);
                    host.database.bsc_unlock_values.items.forEach(function(item){
                        item.criterias = [];
                    });
                    var dic = contentModule.makeDictionaryIndex(host.database.bsc_unlock_values.items);
                    host.database.bsc_unlock_value_criterias.items.forEach(function(item){
                        var k = dic[item.uid];
                        if (k >= 0) host.database.bsc_unlock_values.items[k].criterias.push(item.criteriaid);
                    });
                    dic = {};
                    for (var i = 0; i < host.database.bsc_strategies_criteria_links.items.length; i++){
                        dic[host.database.bsc_strategies_criteria_links.items[i].criteriaid] = true;
                    }
                    host.kpiItems = [];
                    for (var i = 0; i < host.database.bsc_criteriadefinitions.items.length; i++){
                        if (dic[host.database.bsc_criteriadefinitions.items[i].id]){
                            host.kpiItems.push({
                                value: host.database.bsc_criteriadefinitions.items[i].id,
                                text: host.database.bsc_criteriadefinitions.items[i].name
                            });
                        }
                    }
                    host.criteria_select.items = host.kpiItems;
                    if (host.criteriaidList){
                        var criteriaidList = [];
                        for (var i = 0; i < host.criteriaidList.length; i++){
                            if (dic[host.criteriaidList[i]]) criteriaidList.push(host.criteriaidList[i]);
                        }
                        host.criteria_select.values = criteriaidList;
                    }
                    else {
                        host.criteria_select.values = [];
                    }
                    hr.bsc_approval_values.drawTable(host);
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
            else {
                ModalElement.alert({message: message});
            }
        }
    });
};

hr.bsc_approval_values.toggleBtn = function(host){
    var ex = 0;
    for (var queueid in host.checkbox_input){
        if (host.checkbox_input[queueid].checked){
            ex = 1;
            break;
        }
    }
    if (ex == 0){
        host.approvalBtnCtn.style.display = "none";
        host.denyBtnCtn.style.display = "none";
    }
    else {
        host.approvalBtnCtn.style.display = "";
        host.denyBtnCtn.style.display = "";
    }
};

hr.bsc_approval_values.getRow = function(host, content){
    var row = [];
    if (!content.locked && content.status == 0){
        host.checkbox_input[content.id] = absol.buildDom({
            tag: "checkbox",
            on: {
                change: function(){
                    hr.bsc_approval_values.toggleBtn(host);
                }
            }
        });
        row.push({
            attrs: {align: "center"},
            children: [host.checkbox_input[content.id]]
        });
    }
    else {
        row.push({});
    }
    row.push({
        attrs: {align: "center"},
        text: contentModule.getDateTimeViewFromDate1970(content.idate)
    });
    var cIndex = host.criteriasDic[content.criteriaid];
    if (host.hasWeight){
        if (host.database.bsc_criteriadefinitions.items[cIndex].weight_requirement){
            row.push({
                attrs: {align: "right"},
                text: contentModule.moneyFormat2(content.value, 0, host.database.bsc_criteriadefinitions.items[cIndex].decpre)
            });
            row.push({
                attrs: {align: "right"},
                text: contentModule.moneyFormat2(content.weight, 0, host.database.bsc_criteriadefinitions.items[cIndex].decpre)
            });
        }
        else {
            row.push({
                attrs: {style: {backgroundColor: "var(--disabled-backgroudcolor)"}}
            });
            row.push({
                attrs: {style: {backgroundColor: "var(--disabled-backgroudcolor)"}}
            });
        }
    }
    var method_details = [];
    if (host.database.bsc_criteriadefinitions.items[cIndex].result_input_method != 0){
        var k = host.database.bsc_result_input_methods.getIndex(host.database.bsc_criteriadefinitions.items[cIndex].result_input_method);
        method_details = host.database.bsc_result_input_methods.items[k].content.details;
        method_details.forEach(function(item1){
            row.push({
                attrs: {align: "right"},
                text: content.details_result[item1.code.toLowerCase()]? contentModule.moneyFormat2(content.details_result[item1.code.toLowerCase()], 0, content.decpre) : ""
            });
        });
        for (var i = method_details.length; i < host.headerExtra; i++){
            row.push({
                attrs: {style: {backgroundColor: "var(--disabled-backgroudcolor)"}}
            });
        }
    }
    else {
        for (var i = 0; i < host.headerExtra; i++){
            row.push({
                attrs: {style: {backgroundColor: "var(--disabled-backgroudcolor)"}}
            });
        }
    }
    row.push({
        attrs: {align: "right"},
        text: contentModule.moneyFormat2(host.database.bsc_criteriadefinitions.items[cIndex].average_unit_as_percentage? content.result*100 : content.result, 0, host.database.bsc_criteriadefinitions.items[cIndex].decpre)
    });
    var accumulateValuesToText = "";
    if (host.criteriaRlinksDic[content.criteriaid]){
        host.criteriaRlinksDic[content.criteriaid].forEach(function(rItem){
            if ((rItem.startdate <= content.idate) && ((rItem.expireddate > content.idate) || (rItem.expireddate == 0))){
                var k;
                if (rItem.rtofirstid > 0){
                    k = host.orgsFirstidDic[rItem.rtofirstid];
                    if (k >= 0) accumulateValuesToText += ", " + host.database.orgs.items[k].name;
                }
                else {
                    k = host.employeesFirstidDic[-rItem.rtofirstid];
                    if (k >= 0) accumulateValuesToText += ", " + host.database.employees.items[k].fullname;
                }
            }
        });
    }
    if (accumulateValuesToText.length > 0) accumulateValuesToText = accumulateValuesToText.substr(2);
    row.push({
        text: accumulateValuesToText
    });
    if (!content.locked && content.status == 0){
        host.cmdEltList[content.id] = DOMElement.div({
            attrs: {style: {whiteSpace: "nowrap"}},
            children: [
                DOMElement.div({
                    attrs: {
                        className: "card-icon-cover",
                        onclick: function(){
                            hr.bsc_approval_values.approvalValue(host, content.id);
                        }
                    },
                    children: [DOMElement.i({
                        attrs: {
                            className: "mdi mdi-checkbox-marked-circle hr-icon-approval"
                        }
                    })]
                }),
                DOMElement.div({
                    attrs: {
                        className: "card-icon-cover",
                        onclick: function(){
                            hr.bsc_approval_values.denyValueConfirm(host, content.id);
                        }
                    },
                    children: [DOMElement.i({
                        attrs: {
                            className: "mdi mdi-close-circle hr-icon-deny"
                        }
                    })]
                })
            ]
        });
        row.push({
            attrs: {align: "center"},
            children: [host.cmdEltList[content.id]]
        });
    }
    else {
        row.push({});
    }
    if (content.locked){
        row.push({
            attrs: {align: "center"},
            children: [DOMElement.div({
                attrs: {
                    className: "card-icon-cover"
                },
                children: [DOMElement.i({
                    attrs: {
                        className: "mdi mdi-lock",
                        style: {
                            color: "red",
                            fontSize: "var(--icon-fontsize)"
                        }
                    }
                })]
            })]
        });
    }
    else {
        row.push({});
    }
    var statusElt;
    switch (content.status) {
        case 0:
            statusElt = DOMElement.span({
                attrs: {style: {
                    color: "green"
                }},
                text: LanguageModule.text("txt_waiting_approval")
            });
            break;
        case 1:
            statusElt = DOMElement.span({
                attrs: {style: {
                    color: "blue"
                }},
                text: LanguageModule.text("txt_approved")
            });
            break;
        case 2:
            statusElt = DOMElement.span({
                attrs: {style: {
                    color: "red"
                }},
                text: LanguageModule.text("txt_deny")
            });
            break;
        default:

    }
    host.statusEltList[content.id] = statusElt;
    row.push(statusElt);
    return row;
};

hr.bsc_approval_values.makeCriteriaRlinksData = function(host){
    var res = {};
    host.database.bsc_criteria_rlinks.items.forEach(function(item){
        if (!res[item.criteriaid]) res[item.criteriaid] = [];
        res[item.criteriaid].push(item);
    });
    return res;
};

hr.bsc_approval_values.getKpiRow = function(host, criteriaid){
    var cIndex = host.criteriasDic[criteriaid];
    var colSpan = 7;
    if (host.hasWeight) colSpan += 2;
    colSpan += host.headerExtra;
    var row = [
        {
            attrs: {colSpan: colSpan, style: {fontWeight: "bold"}},
            text: host.database.bsc_criteriadefinitions.items[cIndex].name + " (" + host.database.bsc_criteriadefinitions.items[cIndex].unit + ")"
        }
    ];
    return row;
};

hr.bsc_approval_values.drawTable = function(host){
    host.checkbox_input = {};
    host.statusEltList = {};
    host.cmdEltList = {};
    DOMElement.removeAllChildren(host.table_ctn);
    host.orgid = host.org_emp_select.value;
    host.criteriaidList = host.criteria_select.values;
    if (host.orgid == 0 || host.criteriaidList.length == 0) return;
    var rfirstid;
    if (host.orgid > 0){
        var oIndex = host.database.orgs.getIndex(host.orgid);
        rfirstid = host.database.orgs.items[oIndex].firstid;
    }
    else {
        var eIndex = host.database.employees.getIndex(-host.orgid);
        rfirstid = - host.database.employees.items[eIndex].firstid;
    }
    var timestart, timeend;
    switch (host.period_select.value){
        case "month":
            timestart = contentModule.getDateFrom1970(absol.datetime.beginOfMonth(host.month_select.value));
            timeend = contentModule.getDateFrom1970(absol.datetime.nextMonth(host.month_select.value));
            break;
        case "quarter":
            timestart = contentModule.getDateFrom1970(absol.datetime.beginOfQuarter(host.quarter_select.value));
            timeend = contentModule.getDateFrom1970(absol.datetime.nextQuarter(host.quarter_select.value));
            break;
        case "year":
            timestart = contentModule.getDateFrom1970(absol.datetime.beginOfYear(host.year_select.value));
            timeend = contentModule.getDateFrom1970(absol.datetime.nextYear(host.year_select.value));
            break;
        default:
            timestart = 0;
            timeend = 0;
    }
    ModalElement.show_loading();
    FormClass.api_call({
        url: "database_load.php",
        params: [
            {name: "task", value: "bsc_approval_values_load_input_queues_by_rfirstid_and_criteriaidList_and_time"},
            {name: "rfirstid", value: rfirstid},
            {name: "criteriaidList", value: EncodingClass.string.fromVariable(host.criteriaidList)},
            {name: "timestart", value: timestart},
            {name: "timeend", value: timeend}
        ],
        func: function(success, message){
            ModalElement.close(-1);
            if (success){
                if (message.substr(0, 2) == "ok"){
                    var st = EncodingClass.string.toVariable(message.substr(2));
                    contentModule.makeDatabaseContent(host, st);
                    hr.bsc_approval_values.makeLockData(host);
                    host.criteriaRlinksDic = hr.bsc_approval_values.makeCriteriaRlinksData(host);
                    var data = [];
                    var iDic = {};
                    for (var i = 0; i < host.database.bsc_input_queues.items.length; i++){
                        data.push(host.database.bsc_input_queues.items[i]);
                        iDic[host.database.bsc_input_queues.items[i].inputid] = true;
                    }
                    for (var i = 0; i < host.database.bsc_inputs.items.length; i++){
                        if (!iDic[host.database.bsc_inputs.items[i].id]){
                            host.database.bsc_inputs.items[i].status = 1;
                            data.push(host.database.bsc_inputs.items[i]);
                        }
                    }
                    data.sort(function(a, b){
                         return a.idate - b.idate;
                    });
                    var criteriasDic = contentModule.makeDictionaryIndex(host.database.bsc_criteriadefinitions.items);
                    var criteriaidList = [];
                    var list = {}, k, k1, k2;
                    var listMethod = [];
                    var methodDic = {};
                    for (var i = 0; i < data.length; i++){
                        k = host.criteriasDic[data[i].criteriaid];
                        if (k >= 0){
                            if (!list[data[i].criteriaid]){
                                list[data[i].criteriaid] = [];
                                criteriaidList.push(data[i].criteriaid);
                                k1 = criteriasDic[data[i].criteriaid];
                                if (host.database.bsc_criteriadefinitions.items[k1].result_input_method != 0){
                                    if (!methodDic[host.database.bsc_criteriadefinitions.items[k1].result_input_method]){
                                        k2 = host.database.bsc_result_input_methods.getIndex(host.database.bsc_criteriadefinitions.items[k1].result_input_method);
                                        listMethod.push(host.database.bsc_result_input_methods.items[k2]);
                                        methodDic[host.database.bsc_criteriadefinitions.items[k1].result_input_method] = true;
                                    }
                                }
                            }
                            list[data[i].criteriaid].push(data[i]);
                        }
                    }
                    host.hasWeight = false;
                    var dataTable = [];
                    var cIndex, value_name, weight_name;
                    criteriaidList.forEach(function(criteriaid){
                        if (list[criteriaid].length > 0){
                            cIndex = host.criteriasDic[criteriaid];
                            if (host.database.bsc_criteriadefinitions.items[cIndex].weight_requirement){
                                host.hasWeight = true;
                            }
                        }
                    });
                    var header = [
                        {},
                        {
                            attrs: {style: {whiteSpace: "nowrap"}},
                            text: LanguageModule.text("txt_day")
                        }
                    ];
                    if (host.hasWeight){
                        header.push(
                            {
                                attrs: {style: {whiteSpace: "nowrap"}},
                                text: LanguageModule.text("txt_bsc_first_value")
                            },
                            {
                                attrs: {style: {whiteSpace: "nowrap"}},
                                text: LanguageModule.text("txt_weight")
                            }
                        );
                    }
                    host.headerExtra = 0;
                    if (listMethod.length >= 1){
                        if (listMethod.length == 1){
                           listMethod[0].content.details.forEach(function(item){
                                header.push({
                                    style: {
                                        whiteSpace: "nowrap"
                                    },
                                    child: DOMElement.span({text: item.name})
                                });
                            });
                            host.headerExtra = listMethod[0].content.details.length;
                        }
                        else {
                            var max = 0;
                            listMethod.forEach(function(item){
                                if (max < item.content.details.length) max = item.content.details.length;
                            });
                            for (var i = 0; i < max; i++){
                                header.push({});
                            }
                            host.headerExtra = max;
                        }
                    }
                    header.push(
                        {
                            attrs: {style: {whiteSpace: "nowrap"}},
                            text: LanguageModule.text("txt_value_bsc")
                        },
                        {
                            attrs: {style: {whiteSpace: "nowrap"}},
                            text: LanguageModule.text("txt_accumulate_values_to")
                        },
                        {

                        },
                        {},
                        {
                            attrs: {style: {whiteSpace: "nowrap"}},
                            text: LanguageModule.text("txt_status")
                        }
                    );
                    for (var criteriaid in list){
                        if (list[criteriaid].length > 0){
                            dataTable.push(hr.bsc_approval_values.getKpiRow(host, criteriaid));
                            cIndex = host.criteriasDic[criteriaid];
                            if (host.database.bsc_criteriadefinitions.items[cIndex].weight_requirement){
                                value_name = host.database.bsc_criteriadefinitions.items[cIndex].value_name;
                                weight_name = host.database.bsc_criteriadefinitions.items[cIndex].weight_name;
                                if (value_name != "" && weight_name != ""){
                                    var row = [
                                        {},
                                        {},
                                        {
                                            attrs: {align: "center", fontWeight: "bold"},
                                            text: value_name
                                        },
                                        {
                                            attrs: {align: "center", fontWeight: "bold"},
                                            text: weight_name
                                        },
                                        {},
                                        {},
                                        {},
                                        {},
                                        {}
                                    ];
                                    for (var k = 0; k < host.headerExtra; k++){
                                        cells.push({});
                                    }
                                    dataTable.push(row);
                                }
                            }
                            else if (listMethod.length > 0 && host.database.bsc_criteriadefinitions.items[cIndex].result_input_method != 0){
                                var k = host.database.bsc_result_input_methods.getIndex(host.database.bsc_criteriadefinitions.items[cIndex].result_input_method);
                                if (listMethod.length > 1){
                                    var cells = [{}];
                                    if (host.hasWeight){
                                        cells.push({}, {});
                                    }
                                    host.database.bsc_result_input_methods.items[k].content.details.forEach(function(detail){
                                        cells.push({
                                            style: {textAlign: "center", fontWeight: "bold"},
                                            child: DOMElement.span({text: detail.name})
                                        });
                                    });
                                    for (var k = host.database.bsc_result_input_methods.items[k].content.details.length; k < host.headerExtra; k++){
                                        cells.push({});
                                    }
                                    row = {
                                        cells: cells
                                    };
                                    dataTable.push(row);
                                }
                            }
                            for (var i = 0; i < list[criteriaid].length; i++){
                                dataTable.push(hr.bsc_approval_values.getRow(host, list[criteriaid][i]));
                            }
                        }
                    }
                    host.table_ctn.appendChild(DOMElement.div({
                        children: [
                            DOMElement.span({
                                attrs: {
                                    style: {
                                        lineHeight: "var(--control-height)",
                                        height: "var(--control-height)",
                                        color: "var(--a-color)",
                                        cursor: "pointer"
                                    },
                                    onclick: function(){
                                        for (var queueid in host.checkbox_input){
                                            host.checkbox_input[queueid].checked = true;
                                        }
                                        hr.bsc_approval_values.toggleBtn(host);
                                    }
                                },
                                text: LanguageModule.text("txt_select_all")
                            }),
                            DOMElement.span({
                                attrs: {
                                    style: {
                                        lineHeight: "var(--control-height)",
                                        height: "var(--control-height)",
                                        color: "var(--a-color)",
                                        cursor: "pointer",
                                        marginLeft: "var(--control-horizontal-distance-2)"
                                    },
                                    onclick: function(){
                                        for (var queueid in host.checkbox_input){
                                            host.checkbox_input[queueid].checked = false;
                                        }
                                        hr.bsc_approval_values.toggleBtn(host);
                                    }
                                },
                                text: LanguageModule.text("txt_unselect_all")
                            }),
                        ]
                    }));
                    host.table_ctn.appendChild(DOMElement.div({
                        attrs: {className: "cardsimpletableclass"},
                        children: [DOMElement.table({
                            attrs: {style: {width: "100%"}},
                            header: header,
                            data: dataTable
                        })]
                    }));
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
            else {
                ModalElement.alert({message: message});
            }
        }
    })
};

hr.bsc_approval_values.redraw = function(host){
    var buttonlist = [
        DOMElement.div({
            attrs: {className: "single-button-header"},
            children: [theme.closeButton({
                onclick: function(){
                    if (hr.isMobile){
                        host.holder.selfRemove();
                        hr.menu.loadPage(1000);
                    }
                    else {
                        hr.menu.tabPanel.removeTab(host.holder.id);
                    }
                }
            })]
        })
    ];
    host.approvalBtnCtn = DOMElement.div({
        attrs: {className: "single-button-header", style: {display: "none"}},
        children: [theme.approvalButton({
            text: LanguageModule.text("txt_approve"),
            onclick: function(){
                hr.bsc_approval_values.approvalValue(host, 0);
            }
        })]
    });
    host.denyBtnCtn = DOMElement.div({
        attrs: {className: "single-button-header", style: {display: "none"}},
        children: [theme.denyButton({
            onclick: function(){
                hr.bsc_approval_values.denyValueConfirm(host, 0);
            }
        })]
    });
    buttonlist.push(
        host.approvalBtnCtn,
        host.denyBtnCtn
    );
    var buttonPanel = DOMElement.div({
        attrs: {
            className: "button-panel-header"
        },
        children: buttonlist
    });
    host.period_select = absol.buildDom({
        tag: "selectmenu",
        props: {
            items: [
                {value: "all", text: LanguageModule.text("txt_all")},
                {value: "month", text: LanguageModule.text("txt_month")},
                {value: "quarter", text: LanguageModule.text("txt_quarter")},
                {value: "year", text: LanguageModule.text("txt_year")}
            ],
            value: "month"
        },
        on: {
            change: function(){
                switch (this.value) {
                    case "all":
                        host.month_select.style.display = "none";
                        host.quarter_select.style.display = "none";
                        host.year_select.style.display = "none";
                        break;
                    case "month":
                        host.month_select.style.display = "";
                        host.quarter_select.style.display = "none";
                        host.year_select.style.display = "none";
                        break;
                    case "quarter":
                        host.month_select.style.display = "none";
                        host.quarter_select.style.display = "";
                        host.year_select.style.display = "none";
                        break;
                    case "year":
                        host.month_select.style.display = "none";
                        host.quarter_select.style.display = "none";
                        host.year_select.style.display = "";
                        break;
                    default:
                }
                hr.bsc_approval_values.time_org_change_func(host);
            }
        }
    });
    host.month_select = absol.buildDom({
        tag: "dateinput",
        style: {
            marginLeft: "var(--control-horizontal-distance-1)"
        },
        props: {
            format: LanguageModule.text("txt_month") + " MM, yyyy",
            notNull: true
        },
        on: {
            change: function(){
                hr.bsc_approval_values.time_org_change_func(host);
            }
        }
    });
    host.quarter_select = absol.buildDom({
        tag: "dateinput",
        style: {
            marginLeft: "var(--control-horizontal-distance-1)"
        },
        props: {
            format: LanguageModule.text("txt_quarter") + " QQ, yyyy",
            notNull: true
        },
        on: {
            change: function(){
                hr.bsc_approval_values.time_org_change_func(host);
            }
        }
    });
    host.year_select = absol.buildDom({
        tag: "dateinput",
        style: {
            marginLeft: "var(--control-horizontal-distance-1)"
        },
        props: {
            format: "yyyy",
            notNull: true
        },
        on: {
            change: function(){
                hr.bsc_approval_values.time_org_change_func(host);
            }
        }
    });
    host.orgEmpItems = contentModule.getOrgsAndEmployeesListSelectTreeMenu(host);
    host.org_emp_select = absol.buildDom({
        tag: "selecttreemenu",
        props: {
            items: host.orgEmpItems,
            enableSearch: true
        },
        on: {
            change: function(){
                hr.bsc_approval_values.time_org_change_func(host);
            }
        }
    });
    host.kpiItems = [];
    host.criteria_select = absol.buildDom({
        tag: "multicheckmenu",
        style: {
            maxWidth: "600px"
        },
        props: {
            items: [{value: 0, text: LanguageModule.text("txt_select_value")}],
            enableSearch: true
        },
        on: {
            change: function(){
                hr.bsc_approval_values.drawTable(host);
            }
        }
    });
    host.period_select.emit("change");
    var filterPanel = DOMElement.div({
        attrs: {
            className: "button-panel-header"
        },
        children: [
            DOMElement.div({
                attrs: {
                    className: "single-button-header",
                    style: {
                        whiteSpace: "nowrap"
                    }
                },
                children: [
                    DOMElement.span({
                        attrs: {
                            style: {
                                marginRight: "var(--control-horizontal-distance-1)",
                                verticalAlign: "middle",
                                display: "inline-block"
                            }
                        },
                        text: LanguageModule.text("txt_period")
                    }),
                    host.period_select,
                    host.month_select,
                    host.quarter_select,
                    host.year_select
                ]
            }),
            DOMElement.div({
                attrs: {
                    className: "single-button-header",
                    style: {
                        whiteSpace: "nowrap"
                    }
                },
                children: [
                    DOMElement.span({
                        attrs: {
                            style: {
                                marginRight: "var(--control-horizontal-distance-1)",
                                verticalAlign: "middle",
                                display: "inline-block"
                            }
                        },
                        text: LanguageModule.text("txt_department_employee")
                    }),
                    host.org_emp_select
                ]
            }),
            DOMElement.div({
                attrs: {
                    className: "single-button-header",
                    style: {
                        whiteSpace: "nowrap"
                    }
                },
                children: [
                    DOMElement.span({
                        attrs: {
                            style: {
                                marginRight: "var(--control-horizontal-distance-1)",
                                verticalAlign: "middle",
                                display: "inline-block"
                            }
                        },
                        text: LanguageModule.text("txt_kpi")
                    }),
                    host.criteria_select
                ]
            })
        ]
    });
    host.table_ctn = DOMElement.div({attrs: {className: "cardsimpletableclass", paddingBottom: "var(--control-verticle-distance-2)"}});
    var singlePage = absol.buildDom({
        tag: "singlepage",
        child: [
            DOMElement.div({
                attrs: {
                    className: "absol-single-page-header"
                },
                children: [
                    buttonPanel,
                    DOMElement.div({
                        attrs: {
                            className: "button-panel-header"
                        },
                        text: LanguageModule.text("txt_value_approval_to_report")
                    }),
                    filterPanel
                ]
            }),
            host.table_ctn
        ]
    });
    host.frameList.addChild(singlePage);
    singlePage.requestActive();
};

hr.bsc_approval_values.init = function(host){
    return new Promise(function(resolveMn, rejectMn){
        hr.menu.changeCurrentUrlTab(host, "bsc_approval_values");
        host.database = {};
        ModalElement.show_loading();
        data_module.loadBscApprovalValuesInit().then(function(content){
            ModalElement.close(-1);
            host.employeeOfMe = content.employeeOfMe;
            delete content.employeeOfMe;
            contentModule.makeDatabaseContent(host, content);
            if (host.database.bsc_result_input_methods.items.length > 0){
                var sample = contentModule.getJsMathNewSampleGeneral();
                var mathExpression = sample.build();
                host.database.bsc_result_input_methods.items.forEach(function(item){
                    item.content = EncodingClass.string.toVariable(item.content);
                    var formula = contentModule.convertPaysheetFormula(item.content.formula);
                    item.parsedContent = mathExpression.parse(formula);
                });
            }
            contentModule.makeOrgsIndex(host);
            contentModule.makeEmployeeData(host);
            contentModule.makeEmployeesIndex(host);
            var orgEmployeeItems = contentModule.getOrgsAndEmployeesListSelectTreeMenu(host);
            orgEmployeeItems.splice(0, 1);
            if (content.configs_privileges){
                contentModule.makeEmployeeGroupMemberIndex(host);
                contentModule.makeConfigPrivileges(host);
            }
            host.criteriasDic = contentModule.makeDictionaryIndex(host.database.bsc_criteriadefinitions.items);
            host.orgsFirstidDic = {};
            for (var i = 0; i < host.database.orgs.items.length; i++){
                host.orgsFirstidDic[host.database.orgs.items[i].firstid] = i;
            }
            host.employeesFirstidDic = {};
            for (var i = 0; i < host.database.employees.items.length; i++){
                host.employeesFirstidDic[host.database.employees.items[i].firstid] = i;
            }
            host.holder.addChild(host.frameList);
            hr.bsc_approval_values.redraw(host);
            resolveMn(host);
        });
    });
};

VaKeR 2022