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/tech_preview/hr/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/tech_preview/hr/content_module.js
 'use strict';

 systemconfig.bsc_performance_threshold = [70, 85, 100];
 systemconfig.bsc_thresholdcolor =  ['#ff0000', '#ffee58', '#66bb6a', '#29b6f6'];
 systemconfig.bsc_locked_by = "month";
 systemconfig.bsc_locked_on_day = 3;

FormClass.readFileAsync = function(file){
    return new Promise(function(resolve, reject){
        FormClass.readFile(file, function (result) {
            resolve(result[0]);//tại sao lại trả về mảng nhỉ, kì lạ thật
        });
    });
};
///

window.contentModule = {};

contentModule.performanceView = function (score) {
    var i, s, is, k, k2, x;
    var thlen = systemconfig.bsc_performance_threshold.length;
    var tlen = systemconfig.bsc_performance_threshold[thlen - 1] + 20;
    if (!isNaN(score)) {
        s = score + "";
    } else {
        s = "-";
    }
    if ((s != "NaN") && (s != "-") && (s != "") && (s != "N/A")) {
        k = k2 = parseInt(score.toFixed(0), 10);
        if (k2 < 2) k2 = 2;
        if (k2 > systemconfig.bsc_performance_threshold[thlen - 1]) k2 = systemconfig.bsc_performance_threshold[thlen - 1];
        is = systemconfig.bsc_thresholdcolor[0];
        for (i = thlen; i > 0; i--) {
            if (k2 >= systemconfig.bsc_performance_threshold[i - 1]) {
                is = systemconfig.bsc_thresholdcolor[i];
                break;
            }
        }
        s = DOMElement.div({
            attrs: {
                style: {
                    width: (tlen + 100) + "px"
                },
            },
            children: [DOMElement.div({
                attrs: {style: {whiteSpace: "nowrap"}},
                children: [
                    DOMElement.div({
                        attrs: {
                            align: "right",
                            title: contentModule.moneyFormat2(score, 0, 8) + "%",
                            style: {
                                width: "80px",
                                verticalAlign: "middle",
                                display: "inline-block"
                            }
                        },
                        text: contentModule.moneyFormat2(score, 0, 2) + "%"
                    }),
                    DOMElement.div({
                        attrs: {
                            style: {
                                width: tlen + "px",
                                marginLeft: "5px",
                                verticalAlign: "middle",
                                display: "inline-block"
                            }
                        },
                        children: [
                            absol._('div')
                                .attr('style', 'background-color: '+ is + '!important')
                                .addStyle({
                                        width: k2 + "px",
                                        height: "10px",
                                        fontSize: "4px"
                                    }
                                )
                        ]
                    })
                ]
            })]
        });
        x = DOMElement.div({
            attrs: {
                align: "left",
                style: {
                    width: (tlen + 120) + "px",
                    paddingTop: "0px",
                    paddingBottom: "0px"
                }
            },
            children: [s]
        });
    } else {
        x = DOMElement.div({
            attrs: {
                align: "center",
                style: {
                    width: (tlen + 120) + "px",
                    paddingTop: "0px",
                    paddingBottom: "0px"
                }
            },
            text: s
        });
    }
    return x;
};

contentModule.generateRandom = function () {
    var res = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    for (var i = 0; i < 20; i++){
        res += possible.charAt(Math.floor(Math.random() * possible.length));
    }
    return res;
};

contentModule.getListApprovalMethod = function(){
    return [
        {value: "sequence", text: LanguageModule.text("txt_sequence")},
        {value: "parallel", text: LanguageModule.text("txt_parallel")},
        {value: "one_approver", text: LanguageModule.text("txt_one_approver")}
    ];
};

contentModule.getBscFormulasSystem = function(){
    return [
        {id: -1, name: LanguageModule.text("txt_formulation_name1"), description: "", content: "KEggPSBHKSAmIChWID49IEcpCjEKViA+PSBHCjEgKyAoVi1HKS8oSC1HKQoxCihWLUwpLyhHLUwpCg==", func: null},
        {id: -2, name: LanguageModule.text("txt_formulation_name2"), description: "", content: "KEggPSBHKSAmIChWID49IEcpCjEKViA+PSBICjIKViA+PSBHCjEgKyAoVi1HKS8oSC1HKQpWIDw9IEwKMAoxCihWLUwpLyhHLUwpCg==", func: null},
        {id: -3, name: LanguageModule.text("txt_formulation_name3"), description: "", content: "KEwgPSBHKSAmIChWIDw9IEcpCjEKViA8PSBHCjEgKyAoRy1WKS8oRy1MKQoxCihILVYpLyhILUcpCg==", func: null},
        {id: -4, name: LanguageModule.text("txt_formulation_name4"), description: "", content: "KEwgPSBHKSAmIChWIDw9IEcpCjEKViA8PSBMCjIKViA8PSBHCjEgKyAoRy1WKS8oRy1MKQpWID49IEgKMAoxCihILVYpLyhILUcpCg==", func: null},
        {id: -5, name: LanguageModule.text("txt_formulation_name5"), description: "", content: "ViA+PSBHCjEKMQooVi1MKS8oRy1MKQo=", func: null},
        {id: -6, name: LanguageModule.text("txt_formulation_name6"), description: "", content: "ViA8PSBHCjEKMQooSC1WKS8oSC1HKQo=", func: null},
        {id: -7, name: LanguageModule.text("txt_formulation_name7"), description: "", content: "ViA+PSBHCjEKMQowCg==", func: null},
        {id: -8, name: LanguageModule.text("txt_formulation_name8"), description: "", content: "ViA8PSBHCjEKMQowCg==", func: null},
        {id: -9, name: LanguageModule.text("txt_formulation_name9"), description: "", content: "ViA9IEcKMQpWIDw9IEwKMApWID49IEgKMApWIDwgRwooViAtIEwpLyhHLUwpCjEKKEgtVikvKEgtRykK+PSBteAowCnYgPCBnCih2IC0gbW4pLyhnLW1uKQoxCihteC12KS8obXgtZykK", func: null}
    ];
};

contentModule.makeDictionaryIndex = function(items){
    var dic = {};
    for (var i = 0; i < items.length; i++){
        dic[items[i].id] = i;
    }
    return dic;
};

contentModule.listTableHasGeneralDefault = [
    "allowance_policy_groups",
    "bonus_policy_groups",
    "benefit_policy_groups",
    "other_liability_policy_groups",
    "insurance_policy_groups",
    "tax_policy_groups",
    "punishment_policy_groups",
    "late_early_checkin_policy_groups",
    "trade_union_policy_groups",
    "overtime_policy_groups"
];

contentModule.makeDatabaseContent = function(host, content){
    var i, keys;
    keys = Object.keys(content);
    keys.forEach(function(item, i){
        host.database[item] = {};
        host.database[item].items = content[item];
        host.database[item].getIndex = function(id){
            for (var i = 0; i < host.database[item].items.length; i++){
                if (host.database[item].items[i].id == id) return i;
            }
            return -1;
        }
        for (var i = 0; i < host.database[item].items.length; i++){
            if (host.database[item].items[i].extrainfo !== undefined && EncodingClass.type.isString(host.database[item].items[i].extrainfo)){
                if (host.database[item].items[i].extrainfo != ""){
                    host.database[item].items[i].extrainfo = EncodingClass.string.toVariable(host.database[item].items[i].extrainfo);
                }
                else {
                    host.database[item].items[i].extrainfo = {};
                }
            }
        }
        if (item == "users"){
            host.database[item].getByhomeid = function(homeid){
                for (var i = 0; i < host.database[item].items.length; i++){
                    if (host.database[item].items[i].homeid == homeid) return i;
                }
                return -1;
            }
            for (var i = 0; i < host.database.users.items.length; i++){
                if (host.database.users.items[i].avatar !== ""){
                    host.database.users.items[i].avatarSrc = host.database.users.items[i].homeid + "_" + host.database.users.items[i].avatar;
                    host.database.users.items[i].avatarSrc = window.domainUser_avatarsNew + host.database.users.items[i].avatarSrc;
                }
                else {
                    if (systemconfig.connectorFile){
                        host.database.users.items[i].avatarSrc = window.domainUser_avatarsNew + "default.svg";
                    }
                    else {
                        host.database.users.items[i].avatarSrc = window.domainUser_avatars + "avatar-default.png";
                    }
                }
            }
        }
        else if (item == "typelists"){
            for (var i = 0; i < host.database[item].items.length; i++){
                if (host.database[item].items[i].content !== undefined){
                    if (host.database[item].items[i].content != ""){
                        host.database[item].items[i].content = EncodingClass.string.toVariable(host.database[item].items[i].content);
                    }
                    else {
                        host.database[item].items[i].content = {};
                    }
                }
            }
            host.database.typelists.items = contentModule.getDatatypePrimitiveList().concat(host.database.typelists.items);
        }
        else if (item == "leave_policy_groups"){
            var x = contentModule.getLeave_policy_groupsListPri();
            for (var i = 0; i < x.length; i++){
                if (host.database.leave_policy_groups.getIndex(x[i].id) < 0){
                    host.database.leave_policy_groups.items.unshift(x[i]);
                }
            }
        }
        else if (item == "advance_payment_policy_groups"){
            var x = contentModule.getAdvance_payment_policy_groupsListPri();
            for (var i = 0; i < x.length; i++){
                if (host.database.advance_payment_policy_groups.getIndex(x[i].id) < 0){
                    host.database.advance_payment_policy_groups.items.unshift(x[i]);
                }
            }
        }
        else if (item == "employment_contract_types"){
            var x = contentModule.getEmployment_contract_typesListPri();
            for (var i = 0; i < x.length; i++){
                if (host.database.employment_contract_types.getIndex(x[i].id) < 0){
                    host.database.employment_contract_types.items.unshift(x[i]);
                }
            }
        }
        else if (item == "religions"){
            var x = contentModule.getReligionsListPri();
            for (var i = 0; i < x.length; i++){
                if (host.database.religions.getIndex(x[i].id) < 0){
                    host.database.religions.items.unshift(x[i]);
                }
            }
        }
        else if (item == "document_groups"){
            contentModule.makeDocumentGroupsIndex(host);
        }
        else if (item == "document_properties"){
            var x = contentModule.getDocumentPropertiesListPri();
            var index;
            for (var i = x.length - 1; i >= 0; i--){
                index = host.database.document_properties.getIndex(x[i].id);
                if (index < 0){
                    host.database.document_properties.items.push(x[i]);
                }
                else {
                    host.database.document_properties.items[index].name = x[i].name;
                }
            }
            host.database.document_properties.items.sort(function(a, b){
                return a.id - b.id;
            });
            contentModule.makeDocumentPropertiesIndex(host);
        }
        else if (item == "document_folders"){
            contentModule.makeDocumentFoldersIndex(host);
        }
        else if (item == "chat_sessions"){
            for (var i = 0; i < host.database.chat_sessions.items.length; i++){
                if (host.database.chat_sessions.items[i].content != ""){
                    host.database.chat_sessions.items[i].content = EncodingClass.string.toVariable(host.database.chat_sessions.items[i].content);
                }
                else {
                    host.database.chat_sessions.items[i].content = [];
                }
            }
        }
        else if (item == "offboarding_types"){
            var x = contentModule.getOffboardingTypesListPri();
            for (var i = 0; i < x.length; i++){
                if (host.database.offboarding_types.getIndex(x[i].id) < 0){
                    host.database.offboarding_types.items.unshift(x[i]);
                }
            }
        }
        else if (item == "bsc_formulas"){
            var x = contentModule.getBscFormulasSystem();
            for (var i = x.length - 1; i >= 0; i--){
                host.database.bsc_formulas.items.unshift(x[i]);
            }
            for (var i = 0; i < host.database.bsc_formulas.items.length; i++){
                contentModule.makeBscFormulasData(host.database.bsc_formulas.items[i]);
            }
        }
        else if (item == "pay_sheet_column_configs"){
            host.database.pay_sheet_column_configs.getIndexByCode = function(code){
                for (var i = 0; i < host.database.pay_sheet_column_configs.items.length; i++){
                    if (host.database.pay_sheet_column_configs.items[i].code == code) return i;
                }
                return -1;
            };
            var x = contentModule.getPaySheetColumnSystem();
            var index;
            for (var i = x.length - 1; i >= 0; i--){
                index = host.database.pay_sheet_column_configs.getIndexByCode(x[i].code);
                if (index < 0){
                    x[i].type = "system";
                    host.database.pay_sheet_column_configs.items.unshift(x[i]);
                }
                else {
                    host.database.pay_sheet_column_configs.items[index].name = x[i].name;
                    host.database.pay_sheet_column_configs.items[index].code = x[i].code;
                }
            }
            host.database.pay_sheet_column_configs.items.sort(function(a, b){
                return a.cindex - b.cindex;
            });
        }
        else if (contentModule.listTableHasGeneralDefault.indexOf(item) >= 0){
            var x = contentModule.getGeneralDefault();
            if (host.database[item].getIndex(x.id) < 0){
                host.database[item].items.unshift(x);
            }
        }
    });
};

contentModule.makeBscFormulasData = function(item){
    var t = Base64.decode(item.content);
    var s = [], q;
    while (true){
        t = contentModule.getStringLine(t);
        if (t[1] == null) break;
        q = t[0];
        t = contentModule.getStringLine(t[1]);
        if (t[1] == null) break;
        s.push([q, t[0]]);
        t = t[1];
    }
    t = "na";
    for (var j = s.length-1; j >= 0; j--) {
        t = "if (" + s[j][0] + "," + s[j][1] + "," + t + ")";
    }
    item.condlist = s;
    item.parsedData = MathClass.Expression.parse(t);
    item.func = item.parsedData.calc;
};

contentModule.getStringLine = function(st) {
    var k;
    k = st.indexOf("\n");
    if (k == -1) return [st, null];
    return [st.substr(0, k), st.substr(k+1)];
};

contentModule.getBscFormulasMessageSystemList = function(){
    var res = [
        {
            cond: "L > G",
            content: LanguageModule.text("war_txt_target_smaller_low_threshold"),
            type: "system"
        },
        {
            cond: "H < G",
            content: LanguageModule.text("war_txt_target_bigger_high_threshold"),
            type: "system"
        },
        {
            cond: "L == H",
            content: LanguageModule.text("war_txt_low_threshold_equal_high_threshold"),
            type: "system"
        }
    ];
    return res;
};

contentModule.getTimeSend = function (timesend) {
    var res = "";
    var month, day, year, hour, minute;
    month = timesend.getMonth() + 1;
    day = timesend.getDate();
    year = timesend.getFullYear();
    hour = timesend.getHours();
    minute = timesend.getMinutes();
    if (month < 10) {
        month = "0" + month;
    }
    if (day < 10) {
        day = "0" + day;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (minute < 10) {
        minute = "0" + minute;
    }
    res += day + "/";
    res += month + "/";
    res += year;
    res += " " + hour + ":";
    res += minute;
    return res;
};

contentModule.getDateTimeView = function(timesend){
    if (!timesend) return "";
    var res = "";
    var month, day, year, hour, minute;
    month = timesend.getMonth() + 1;
    day = timesend.getDate();
    year = timesend.getFullYear();
    hour = timesend.getHours();
    minute = timesend.getMinutes();
    if (month < 10) {
        month = "0" + month;
    }
    if (day < 10) {
        day = "0" + day;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (minute < 10) {
        minute = "0" + minute;
    }
    res += day + "/";
    res += month + "/";
    res += year;
    res += " " + hour + ":";
    res += minute;
    return res;
};

contentModule.getTimeView = function(value){
    if (!value) return "";
    var res = "";
    var hour = parseInt(value/(60*60*1000), 10);
    value = value - hour*(60*60*1000);
    if (hour < 10) {
        hour = "0" + hour;
    }
    var minute = value/(60*1000);
    if (minute < 10) {
        minute = "0" + minute;
    }
    res = hour + ":";
    res += minute;
    return res;
};

contentModule.getHourView = function(dayOffset){
    var d = new Date(absol.datetime.beginOfDay(new Date()).getTime()+ dayOffset);
    return absol.datetime.formatDateTime(d, 'HH:mm');
};

contentModule.getDateView = function(timesend){
    if (!timesend) return "";
    var res = "";
    var month, day, year, hour, minute;
    month = timesend.getMonth() + 1;
    day = timesend.getDate();
    year = timesend.getFullYear();
    if (month < 10) {
        month = "0" + month;
    }
    if (day < 10) {
        day = "0" + day;
    }
    res += day + "/";
    res += month + "/";
    res += year;
    return res;
};

contentModule.getDateMonthView = function(timesend){
    if (!timesend) return "";
    var res = "";
    var month, day, year, hour, minute;
    month = timesend.getMonth() + 1;
    day = timesend.getDate();
    year = timesend.getFullYear();
    if (month < 10) {
        month = "0" + month;
    }
    if (day < 10) {
        day = "0" + day;
    }
    res += day + "/";
    res += month;
    return res;
};

contentModule.getTimeGallerySeparate = function(timeview){
    var now = new Date();
    var res = "";
    var seenHours = timeview.getHours();
    if (seenHours < 10){
        seenHours = "0" + seenHours;
    }
    var seenMinutes = timeview.getMinutes();
    if (seenMinutes < 10){
        seenMinutes = "0" + seenMinutes;
    }
    var nowTime = now.getTime()/86400000;
    var seenTime = timeview.getTime()/86400000;
    var nowDate = now.getDate()
    var seenDate = timeview.getDate();
    var nowMonth = now.getMonth() + 1;
    var seenMonth = timeview.getMonth() + 1;
    var nowYear = now.getFullYear();
    var seenYear = timeview.getFullYear();
    if (nowYear == seenYear){
        if (nowMonth == seenMonth && nowDate == seenDate){
            res = "Today";
        }
        else if (nowTime - seenTime < 7){
            var weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
            res = weekday[timeview.getDay()];
        }
        else {
            res = contentModule.getDateView(timeview);
        }
    }
    else {
        res = contentModule.getDateView(timeview);
    }
    return res;
};

contentModule.compareDate = function(time1, time2){
    var date1 = time1.getDate()
    var date2 = time2.getDate();
    var month1 = time1.getMonth() + 1;
    var month2 = time2.getMonth() + 1;
    var year1 = time1.getFullYear();
    var year2 = time2.getFullYear();
    if (date1 == date2 && month1 == month2 && year1 == year2) return true;
    return false;
};

contentModule.getTimeMessageList = function(timeview){
    var now = new Date();
    var res = "";
    var seenHours = timeview.getHours();
    if (seenHours < 10){
        seenHours = "0" + seenHours;
    }
    var seenMinutes = timeview.getMinutes();
    if (seenMinutes < 10){
        seenMinutes = "0" + seenMinutes;
    }
    var nowTime = now.getTime()/86400000;
    var seenTime = timeview.getTime()/86400000;
    var nowDate = now.getDate()
    var seenDate = timeview.getDate();
    var nowMonth = now.getMonth() + 1;
    var seenMonth = timeview.getMonth() + 1;
    var nowYear = now.getFullYear();
    var seenYear = timeview.getFullYear();
    if (nowYear == seenYear){
        if (nowMonth == seenMonth && nowDate == seenDate){
            res = seenHours + ":" + seenMinutes;
        }
        else if (nowTime - seenTime < 7){
            var weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
            res = weekday[timeview.getDay()];
        }
        else {
            res = contentModule.getDateView(timeview);
        }
    }
    else {
        res = contentModule.getTimeView(timeview);
    }
    return res;
};

contentModule.generateLanguageList = function () {
    var i, list = [];
    for (i = 0; i < LanguageModule.code.length; i++) {
        list.push({
            value: LanguageModule.code[i].name,
            text: LanguageModule.code[i].value
        });
    }
    return list;
};

contentModule.filterEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

contentModule.getUserNameByHomeid = function(host, homeid){
    for (var i = 0; i < host.database.users.items.length; i++){
        if (host.database.users.items[i].homeid == homeid) return host.database.users.items[i].username;
    }
    return "-";
};

contentModule.getFieldsMergeByTypeID = function(host, typeid, displayName, name){
    return new Promise(function(resolve, reject){
        var typeIndex = host.typelistsDic[typeid];
        var typeData = host.database.typelists.items[typeIndex];
        switch (typeData.type) {
            case "string":
            case "note":
            case "email_address":
            case "phonenumber":
            case "website":
            case "gps":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "string"
                });
                break;
            case "number":
            case "currency":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "number"
                });
                break;
            case "date":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "date"
                });
                break;
            case "datetime":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "datetime"
                });
                break;
            case "boolean":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "bool"
                });
                break;
            case "html":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "html"
                });
                break;
            case "color_picker":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "color"
                });
                break;
            case "any_file":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "file"
                });
                break;
            case "image_file":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "image"
                });
                break;
            case "files":
                resolve({
                    displayName: displayName,
                    name: name,
                    type: "file[]"
                });
                break;
            case "array":
                contentModule.getFieldsMergeByTypeID(host, typeData.content.typeof, "", "").then(function(v){
                    resolve({
                        displayName: displayName,
                        name: name,
                        type: "array",
                        of: v
                    });
                });
                break;
            case "treetable":
                contentModule.getFieldsMergeByTypeID(host, typeData.content.typeof, "", "").then(function(v){
                    resolve({
                        displayName: displayName,
                        name: name,
                        type: "treetable",
                        of: v
                    });
                });
                break;
            default:
                if (contentModule.listTypeSelectmenu.indexOf(typeData.type) >= 0){
                    if (typeData.type == "nation_city"){
                        contentModule.loadListPrimaryTypeEnum(typeData.type).then(function(list){
                            resolve({
                                displayName: displayName,
                                name: name,
                                type: "enum<pair>",
                                items: list
                            });
                        });
                    }
                    else {
                        contentModule.loadListPrimaryTypeEnum(typeData.type).then(function(list){
                            list[0].text = "";
                            resolve({
                                displayName: displayName,
                                name: name,
                                type: "enum",
                                items: list
                            });
                        });
                    }
                }
                else if (contentModule.listTypeSelectbox.indexOf(typeData.type) >= 0){
                    contentModule.loadListPrimaryTypeEnum(typeData.type).then(function(list){
                        resolve({
                            displayName: displayName,
                            name: name,
                            type: "{enum}",
                            items: list,
                            onchange: function(){
                                if (name == "type_partner_class"){
                                    host.change_partner_class_func(this.export());
                                }
                            }
                        });
                    });
                }
                else if (typeData.type == "enum" || typeData.type == "extends_enum" || typeData.type2 == "enum"){
                    var list = [];
                    contentModule.getDetailsExtends(host, list, typeid);
                    var listItems = [{value: 0, text: ""}];
                    for (var i = 0; i < list.length; i++){
                        listItems.push({value: list[i].localid, text: list[i].text});
                    }
                    resolve({
                        displayName: displayName,
                        name: name,
                        type: "enum",
                        items: listItems
                    });
                }
                else if (typeData.type == "enum_multi" || typeData.type == "extends_enum_multi" || typeData.type2 == "enum_multi"){
                    var list = [];
                    contentModule.getDetailsExtends(host, list, typeid);
                    var listItems = [];
                    for (var i = 0; i < list.length; i++){
                        listItems.push({value: list[i].localid, text: list[i].text});
                    }
                    resolve({
                        displayName: displayName,
                        name: name,
                        type: "{enum}",
                        items: listItems
                    });
                }
                else if (typeData.type == "structure" || typeData.type == "extends_structure" || typeData.type2 == "structure"){
                    var detailsList = [];
                    contentModule.getDetailsExtends(host, detailsList, typeid);
                    var promiseArray = [];
                    for (var i = 0; i < detailsList.length; i++){
                        promiseArray.push(contentModule.getFieldsMergeByTypeID(host, detailsList[i].type, detailsList[i].name, detailsList[i].localid));
                    }
                    Promise.all(promiseArray).then(function(fields){
                        resolve({
                            displayName: displayName,
                            name: name,
                            type: "struct",
                            fields: fields
                        });
                    });
                }
                else {
                    resolve({
                        displayName: displayName,
                        name: name,
                        type: "string"
                    });
                }
        }
    });
};

contentModule.getDatatypePrimitiveList = function(){
    var typelists = [
        {id: -1, name: LanguageModule.text("txt_string"), type: "string", stt: 1},
        {id: -2, name: LanguageModule.text("txt_textarea"), type: "note", stt: 2},
        {id: -3, name: LanguageModule.text("txt_number"), type: "number", stt: 3},
        {id: -4, name: LanguageModule.text("txt_date"), type: "date", stt: 4},
        {id: -5, name: LanguageModule.text("txt_date_time"), type: "datetime", stt: 5},
        {id: -6, name: LanguageModule.text("txt_boolean"), type: "boolean", stt: 6},
        {id: -7, name: LanguageModule.text("txt_email_address"), type: "email_address"},
        {id: -8, name: LanguageModule.text("txt_user"), type: "user"},
        {id: -9, name: LanguageModule.text("txt_userlist"), type: "userlist"},
        {id: -10, name: LanguageModule.text("txt_phone_number"), type: "phonenumber"},
        {id: -11, name: LanguageModule.text("txt_website"), type: "website"},
        {id: -12, name: LanguageModule.text("txt_gps"), type: "gps"},
        {id: -14, name: LanguageModule.text("txt_select_nation"), type: 'member_of_nations'},
        {id: -15, name: LanguageModule.text("txt_select_city"), type: 'member_of_cities'},
        {id: -16, name: LanguageModule.text("txt_select_ethnic"), type: 'member_of_ethnics'},
        {
            id: -17, name: LanguageModule.text("txt_phone_type"), type: 'phone_type', type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_phone_type_home", text: LanguageModule.text("txt_home")},
                    {value: 2, localid: "type_phone_type_mobile", text: LanguageModule.text("txt_mobile")}
                ]
            }
        },
        {
            id: -18, name: LanguageModule.text("txt_phone"), type: "phone", type2: "structure",
            content: {
                details: [
                    {localid: "type_phone_type", name: LanguageModule.text("txt_type"), type: -17, require: true},
                    {localid: "type_phone_number", name: LanguageModule.text("txt_phone_number"), type: -10, default: "", require: true}
                ]
            }
        },
        {
            id: - 19, name: LanguageModule.text("txt_personal_document_type"), type: "personal_document_type", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_personal_document_identity_card", text: LanguageModule.text("txt_identity_card")},
                    {value: 2, localid: "type_personal_document_passport", text: LanguageModule.text("txt_passport")},
                    {value: 3, localid: "type_personal_document_car_driving_license", text: LanguageModule.text("txt_car_driving_license")}
                ]
            }
        },
        {
            id: - 20, name: LanguageModule.text("txt_personal_document"), type: "personal_document", type2: "structure",
            content: {
                details: [
                    {localid: "type_personal_document_type", name: LanguageModule.text("txt_type"), type: -19, require: true},
                    {localid: "type_personal_document_number", name: LanguageModule.text("txt_number"), type: -1, default: "", require: true},
                    {localid: "type_personal_document_place", name: LanguageModule.text("txt_place_of_issue"), type: -1, default: "", require: true},
                    {localid: "type_personal_document_date", name: LanguageModule.text("txt_date_of_issue"), type: -4, default: ["custom", null], require: true},
                    {localid: "type_personal_document_expire_time", name: LanguageModule.text("txt_expire_time"), type: -4, default: ["custom", null], require: true}
                ]
            }
        },
        {
            id: - 21, name: LanguageModule.text("txt_dependent_person"), type: "dependent_persons", type2: "structure",
            content: {
                details: [
                    {localid: "type_dependent_person_fullname", name: LanguageModule.text("txt_fullname"), type: -1, require: true},
                    {localid: "type_dependent_person_dayofbirth", name: LanguageModule.text("txt_day_of_birth"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_dependent_person_sex", name: LanguageModule.text("txt_sex"), type: -40, require: false},
                    {localid: "type_dependent_person_relation", name: LanguageModule.text("txt_relation"), type: -1, require: false},
                    {localid: "type_dependent_person_nationalidno", name: LanguageModule.text("txt_nation_id_number"), type: -1, require: false},
                    {localid: "type_dependent_person_personal_tax_code", name: LanguageModule.text("txt_personal_tax_code"), type: -1, require: false}
                ]
            }
        },
        {id: -22, name: LanguageModule.text("txt_select_religion"), type: 'member_of_religions'},
        {id: -23, name: LanguageModule.text("txt_geographical_position"), type: 'geopos'},
        {id: -24, name: "Chọn bộ phận", type: 'member_of_department'},
        {
            id: -25, name: "Chọn nhiều chức danh", type: 'position_list'
        },
        {
            id: - 26, name: LanguageModule.text("txt_department"), type: "org", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_org_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_org_code", name: LanguageModule.text("txt_code"), type: -1, default: "", require: true},
                    {localid: "type_org_parentid", name: LanguageModule.text("txt_parent_department"), type: -24, default: 0, require: true},
                    {localid: "type_org_geopos", name: LanguageModule.text("txt_geographical_position"), type: -210, require: false}
                ]
            }
        },
        {
            id: - 27, name: LanguageModule.text("txt_employee"), type: "employee", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    // {localid: "type_employee_image", name: LanguageModule.text("txt_employee_image"), type: -32, require: true},
                    {localid: "type_employee_fullname", name: LanguageModule.text("txt_fullname"), type: -1, require: true},
                    {localid: "type_employee_userid", name: LanguageModule.text("txt_user"), type: -8, default: 0, require: false},
                    {localid: "type_employee_code", name: LanguageModule.text("txt_employee_code"), type: -1, default: "", require: true},
                    {localid: "type_employee_phone_1", name: LanguageModule.text("txt_phone_1"), type: -10, default: "", require: false},
                    {localid: "type_employee_phone_2", name: LanguageModule.text("txt_phone_2"), type: -10, default: "", require: false},
                    {localid: "type_employee_work_email", name: LanguageModule.text("txt_work_email"), type: -7, default: "", require: false},
                    {localid: "type_employee_private_email", name: LanguageModule.text("txt_private_email"), type: -7, default: "", require: false},
                    {localid: "type_employee_social_network", name: LanguageModule.text("txt_social_network"), type: -238, default: "", require: false},
                    {localid: "type_employee_dayofbirth", name: LanguageModule.text("txt_day_of_birth"), type: -4, default: ["custom", null], require: true},
                    {localid: "type_employee_sex", name: LanguageModule.text("txt_sex"), type: -40, default: 0, require: false},
                    {localid: "type_employee_marital_status", name: LanguageModule.text("txt_marital_status"), type: -39, default: 0, require: false},
                    {localid: "type_employee_nationalidno", name: LanguageModule.text("txt_nation_id_number"), type: -1, default: "", require: true},
                    {localid: "type_employee_nationalidno_date", name: LanguageModule.text("txt_date_of_issue"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_employee_nationalidno_place", name: LanguageModule.text("txt_place_of_issue"), type: -1, default: "", require: false},
                    {localid: "type_employee_nationality", name: LanguageModule.text("txt_nationality"), type: -14, default: 0, require: true},
                    {localid: "type_employee_religion", name: LanguageModule.text("txt_religion"), type: -22, default: 0, require: false},
                    {localid: "type_employee_ethnic", name: LanguageModule.text("txt_ethnic"), type: -16, default: 0, require: false},
                    {localid: "type_employee_permanent_address", name: LanguageModule.text("txt_permanent_address"), type: -1, require: false},
                    {localid: "type_employee_permanent_nation_city", name: LanguageModule.text("txt_permanent_nation_city"), type: -207, default: 0, require: false},
                    {localid: "type_employee_temporary_address", name: LanguageModule.text("txt_temporary_address"), type: -1, require: false},
                    {localid: "type_employee_temporary_nation_city", name: LanguageModule.text("txt_temporary_nation_city"), type: -207, default: 0, require: false},
                    {localid: "type_employee_personal_tax_code", name: LanguageModule.text("txt_personal_tax_code"), type: -1, default: "", require: false},
                    {localid: "type_employee_personal_income_tax_relief", name: LanguageModule.text("txt_personal_income_tax_relief"), type: -6, default: false, require: false},
                    {localid: "type_employee_social_security_number", name: LanguageModule.text("txt_social_security_number"), type: -1, default: "", require: false},
                    {localid: "type_employee_social_insurance_date", name: LanguageModule.text("txt_social_insurance_date"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_employee_place_of_social_insurance", name: LanguageModule.text("txt_place_of_social_insurance"), type: -1, default: "", require: false},
                    {localid: "type_employee_emergency_contact", name: LanguageModule.text("txt_emergency_contact"), type: -2, default: "", require: false},
                    {localid: "type_employee_reference", name: LanguageModule.text("txt_reference"), type: -2, default: "", require: false},
                    {localid: "type_employee_start_date", name: LanguageModule.text("txt_probation_start_date"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_employee_official_date", name: LanguageModule.text("txt_official_start_date_of_work"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_employee_hr_support_employee", name: LanguageModule.text("txt_hr_support_employee"), type: -47, default: 0, require: false},
                    {localid: "type_employee_direct_manager", name: LanguageModule.text("txt_direct_manager"), type: -47, default: 0, require: false},
                    {localid: "type_employee_indirect_manager", name: LanguageModule.text("txt_indirect_manager"), type: -47, default: 0, require: false},
                    {localid: "type_employee_positions", name: LanguageModule.text("txt_position"), type: -25, default: [], require: false},
                    {localid: "type_employee_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 28, name: LanguageModule.text("txt_position"), type: "position", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_position_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_position_code", name: LanguageModule.text("txt_code"), type: -1, default: "", require: true},
                    {localid: "type_position_orgid", name: LanguageModule.text("txt_department"), type: -24, default: 0, require: true},
                    {localid: "type_position_benefits", name: LanguageModule.text("txt_benefits"), type: -2, default: "", require: false},
                    {localid: "type_position_report_to", name: LanguageModule.text("txt_report_to"), type: -2, default: "", require: false},
                    {localid: "type_position_job_description", name: LanguageModule.text("txt_job_description"), type: -218, default: "", require: false},
                    {localid: "type_position_liability_and_authority", name: LanguageModule.text("txt_liability_and_authority"), type: -218, default: "", require: false},
                    {localid: "type_position_working_condition", name: LanguageModule.text("txt_working_condition"), type: -218, default: "", require: false},
                    {localid: "type_position_prefered_ability", name: LanguageModule.text("txt_prefered_ability"), type: -218, default: "", require: false}
                ]
            }
        },
        {id: -29, name: "Chọn chức danh", type: 'member_of_position'},
        // {
        //     id: -30, name: LanguageModule.text("txt_select_position_by_department"), type: "select_position", type2: "structure", isnotFieldofStructure: true,
        //     content: {
        //         details: [
        //             {localid: "type_select_position_orgid", name: LanguageModule.text("txt_department"), type: -24, default: "", require: true},
        //             {localid: "type_select_position_id", name: LanguageModule.text("txt_position"), type: -29, default: "", require: true}
        //         ]
        //     }
        // },
        {id: -32, name: LanguageModule.text("txt_image_file"), type: "image_file"},
        {id: -34, name: LanguageModule.text("txt_any_file"), type: "any_file"},
        {id: -35, name: LanguageModule.text("txt_languages"), type: 'language', type2: "enum", notTypeOfUnion : true},
        {
            id: - 39, name: LanguageModule.text("txt_marital_status"), type: "marital_status_type", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_marital_status_single", text: LanguageModule.text("txt_marital_status_single")},
                    {value: 2, localid: "type_marital_status_married", text: LanguageModule.text("txt_married")},
                    {value: 3, localid: "type_marital_status_other", text: LanguageModule.text("txt_other")}
                ]
            }
        },
        {
            id: - 40, name: LanguageModule.text("txt_sex"), type: "sex_type", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_sex_male", text: LanguageModule.text("txt_male")},
                    {value: 2, localid: "type_sex_female", text: LanguageModule.text("txt_female")},
                ]
            }
        },
        {
            id: -41, name: LanguageModule.text("txt_email_type"), type: 'email_type', type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_email_type_company", text: LanguageModule.text("txt_company")},
                    {value: 2, localid: "type_email_type_personal", text: LanguageModule.text("txt_personal")}
                ]
            }
        },
        {
            id: -42, name: LanguageModule.text("txt_email"), type: "email", type2: "structure",
            content: {
                details: [
                    {localid: "type_email_type", name: LanguageModule.text("txt_type"), type: -41, require: true},
                    {localid: "type_email_address", name: LanguageModule.text("txt_email_address"), type: -7, default: "", require: true}
                ]
            }
        },
        {id: -43, name: LanguageModule.text("txt_reminder"), type: 'reminder', type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {localid: "type_reminder_none", text: LanguageModule.text("txt_no_reminder"), value: 0},
                    {localid: "type_reminder_15_minutes", text: LanguageModule.text("txt_15_minutes"), value: 15},
                    {localid: "type_reminder_30_minutes", text: LanguageModule.text("txt_30_minutes"), value: 30},
                    {localid: "type_reminder_1_hour", text: LanguageModule.text("txt_1_hour"), value: 60},
                    {localid: "type_reminder_2_hours", text: LanguageModule.text("txt_2_hours"), value: 60 * 2},
                    {localid: "type_reminder_4_hours", text: LanguageModule.text("txt_4_hours"), value: 60 * 4},
                    {localid: "type_reminder_8_hours", text: LanguageModule.text("txt_8_hours"), value: 60 * 8},
                    {localid: "type_reminder_1_day", text: LanguageModule.text("txt_1_day"), value: 60 * 24},
                    {localid: "type_reminder_2_days", text: LanguageModule.text("txt_2_days"), value: 60 * 24 * 2},
                    {localid: "type_reminder_4_days", text: LanguageModule.text("txt_4_days"), value: 60 * 24 * 4},
                    {localid: "type_reminder_8_days", text: LanguageModule.text("txt_8_days"), value: 60 * 24 * 8}
                ]
            }
        },
        {id: -44, name: LanguageModule.text("txt_type_of_meeting"), type: 'type_of_task', type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {localid: "type_visit", text: LanguageModule.text("txt_visit"), value: 1},
                    {localid: "type_online", text: LanguageModule.text("txt_online"), value: 2}
                ]
            }
        },
        {
            id: -45, name: LanguageModule.text("txt_task"), type: "task", type2: "structure",
            content: {
                details: [
                    {localid: "type_task_name", name: LanguageModule.text("txt_name"), type: -1, require: true, default: ""},
                    {localid: "type_task_status", name: LanguageModule.text("txt_completed"), type: -6, default: false},
                    {localid: "type_task_start_time", name: LanguageModule.text("txt_start"), type: -5, default: ["today", ""]},
                    {localid: "type_task_expire_time", name: LanguageModule.text("txt_end"), type: -5, default: ["today", ""]},
                    {localid: "type_task_reminder", name: LanguageModule.text("txt_reminder"), type: -43, default: 'type_reminder_none'},
                    {localid: "type_task_assign_to", name: LanguageModule.text("txt_assign_to"), type: -47, require: true},
                    {localid: "type_task_participant", name: LanguageModule.text("txt_participant"), type: -48, default: []},
                    {localid: "type_task_result", name: LanguageModule.text("txt_result"), type: -218, default: ""}
                ]
            }
        },
        {
            id: -46, name: LanguageModule.text("txt_meeting"), type: "meeting", type2: "structure",
            content: {
                details: [
                    {localid: "type_meeting_name", name: LanguageModule.text("txt_name"), type: -1, require: true, default: ""},
                    {localid: "type_meeting_type", name: LanguageModule.text("txt_type"), type: -44, default: 'type_visit'},
                    {localid: "type_meeting_location", name: LanguageModule.text("txt_meeting_location"), type: -1, require: true, default: ""},
                    {localid: "type_meeting_status", name: LanguageModule.text("txt_completed"), type: -6, default: false},
                    {localid: "type_meeting_start_time", name: LanguageModule.text("txt_start"), type: -5, default: ["today", ""]},
                    {localid: "type_meeting_end_time", name: LanguageModule.text("txt_end"), type: -5, default: ["today", ""]},
                    {localid: "type_meeting_all_day", name: LanguageModule.text("txt_all_day"), type: -6, default: false},
                    {localid: "type_meeting_reminder", name: LanguageModule.text("txt_reminder"), type: -43, default: 'type_reminder_none'},
                    {localid: "type_meeting_assign_to", name: LanguageModule.text("txt_assign_to"), type: -47, require: true},
                    {localid: "type_meeting_participant", name: LanguageModule.text("txt_participant"), type: -48, default: []},
                    {localid: "type_meeting_result", name: LanguageModule.text("txt_result"), type: -218, default: ""}
                ]
            }
        },
        {id: -47, name: "Chọn nhân viên", type: 'member_of_employee'},
        {id: -48, name: "Chọn nhiều nhân viên", type: 'employee_list'},
        {
            id: -50, name: LanguageModule.text("txt_holiday"), type: "holidays", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_holiday_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_holiday_timestart", name: LanguageModule.text("txt_start_time"), type: -4, require: true},
                    {localid: "type_holiday_timeend", name: LanguageModule.text("txt_end_time"), type: -4, require: true},
                    {localid: "type_holiday_shifts", name: LanguageModule.text("txt_shift"), type: -138, require: false},
                    {localid: "type_holiday_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: -53, name: LanguageModule.text("txt_working_form"), type: 'working_form', type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_working_form_full_shift", text: LanguageModule.text("txt_full_shift")},
                    {value: 2, localid: "type_working_form_first_half_shift", text: LanguageModule.text("txt_first_half_shift")},
                    {value: 3, localid: "type_working_form_second_half_shift", text: LanguageModule.text("txt_second_half_shift")},
                    {value: 4, localid: "type_working_form_day_off", text: LanguageModule.text("txt_off")}
                ]
            }
        },
        {
            id: -54, name: LanguageModule.text("txt_shift_general"), type: "shift_general", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_shift_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_shift_description", name: LanguageModule.text("txt_description"), type: -2, default: "", require: false},
                    {localid: "type_shift_symbol", name: LanguageModule.text("txt_symbol"), type: -1, default: "", require: true},
                    {localid: "type_shift_color", name: LanguageModule.text("txt_color"), type: -261, require: false},
                    {localid: "type_shift_number_of_meal", name: LanguageModule.text("txt_number_of_meal"), type: -3, default: 1, require: false},
                    {localid: "type_shift_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -55, name: "Time", type: "time", stt: 5},
        {
            id: -56, name: LanguageModule.text("txt_worktime_checkins"), type: "worktime_checkins", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_worktime_checkins_employeeid", name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: "type_worktime_checkins_ctime", name: LanguageModule.text("txt_time"), type: -5, default: ["custom", null], require: true},
                    {localid: "type_worktime_checkins_machineid", name: LanguageModule.text("txt_worktime_machine"), type: -58, default: 0, require: true},
                    {localid: "type_worktime_checkins_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: -57, name: LanguageModule.text("txt_worktime_machine"), type: "worktime_machines", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_worktime_machines_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_worktime_machines_geoid", name: LanguageModule.text("txt_geographical_position"), type: -23, require: true},
                    {localid: "type_worktime_machines_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -58, name: "Chọn máy chấm công", type: 'member_of_worktime_machines'},
        {
            id: -59, name: LanguageModule.text("txt_worktime_logs"), type: "worktime_logs", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_worktime_logs_employeeid", name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: "type_worktime_logs_shift", name: LanguageModule.text("txt_shift"), type: -137, require: true},
                    {localid: "type_worktime_logs_intime", name: LanguageModule.text("txt_in_time"), type: -5, default: ["custom", null], require: true},
                    {localid: "type_worktime_logs_outtime", name: LanguageModule.text("txt_out_time"), type: -5, default: ["custom", null], require: true},
                    {localid: "type_worktime_logs_machineid", name: LanguageModule.text("txt_worktime_machine"), type: -58, default: 0, require: true},
                    {localid: "type_worktime_logs_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: -60, name: LanguageModule.text("txt_training_program"), type: "training_programs", type2: "structure",
            content: {
                details: [
                    {localid: "type_training_program_name", name: LanguageModule.text("txt_name"), type: -1, require: true, default: ""},
                    {localid: "type_training_program_status", name: LanguageModule.text("txt_status"), type: -63, require: true},
                    {localid: "type_training_program_group", name: LanguageModule.text("txt_group"), type: -86, require: true, default: 0},
                    {localid: "type_training_program_stime", name: LanguageModule.text("txt_start_time"), type: -5, require: true, default: ["today", ""]},
                    {localid: "type_training_program_etime", name: LanguageModule.text("txt_end_time"), type: -5, require: true, default: ["today", ""]},
                    {localid: "type_training_program_registration_deadline", name: LanguageModule.text("txt_registration_deadline"), type: -5, require: true, default: ["today", ""]},
                    {localid: "type_training_program_content", name: LanguageModule.text("txt_content"), type: -2, require: true, default: ""},
                    {localid: "type_training_program_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 61, name: LanguageModule.text("txt_training_lecturer_type"), type: "training_lecturer_type", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_internal_training", text: LanguageModule.text("txt_internal_training")},
                    {value: 2, localid: "type_outsource", text: LanguageModule.text("txt_outsource")}
                ]
            }
        },
        {
            id: - 62, name: LanguageModule.text("txt_training_method"), type: "training_method", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_online", text: LanguageModule.text("txt_online")},
                    {value: 2, localid: "type_direct", text: LanguageModule.text("txt_direct")},
                    {value: 3, localid: "type_seminor", text: LanguageModule.text("txt_seminor")},
                    {value: 4, localid: "type_extracurricular_activities", text: LanguageModule.text("txt_extracurricular_activities")}
                ]
            }
        },
        {
            id: - 63, name: LanguageModule.text("txt_training_status"), type: "training_status", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_plan", text: LanguageModule.text("txt_plan")},
                    {value: 2, localid: "type_processing", text: LanguageModule.text("txt_processing")},
                    {value: 3, localid: "type_finished", text: LanguageModule.text("txt_finished")},
                    {value: 4, localid: "type_canceled", text: LanguageModule.text("txt_canceled")},
                    {value: 5, localid: "type_pause", text: LanguageModule.text("txt_pause")}
                ]
            }
        },
        {
            id: - 64, name: LanguageModule.text("txt_files_list"), type: "files"
        },
        // {
        //     id: - 64, name: LanguageModule.text("txt_files_list"), type: "array", notPri: true,
        //     content: {
        //         typeof: -34
        //     }
        // },
        {
            id: -66, name: LanguageModule.text("txt_asset"), type: "assets", type2: "structure",
            content: {
                details: [
                    {localid: "type_asset_name", name: LanguageModule.text("txt_name"), type: -1, require: true, default: ""},
                    {localid: "type_asset_code", name: LanguageModule.text("txt_code"), type: -1, require: true, default: ""},
                    {localid: "type_asset_warehouseid", name: LanguageModule.text("txt_warehouse"), type: -70, require: true, default: 0},
                    {localid: "type_asset_asset_category", name: LanguageModule.text("txt_asset_category"), type: -203, require: true},
                    {localid: "type_asset_specification", name: LanguageModule.text("txt_specification"), type: -1, require: false, default: ""},
                    {localid: "type_asset_input_date", name: LanguageModule.text("txt_input_date"), type: -4, require: true, default: ["today", ""]},
                    {localid: "type_asset_purchased_price", name: LanguageModule.text("txt_purchased_price"), type: -3, require: false, decpre: 2},
                    {localid: "type_asset_comment", name: LanguageModule.text("txt_note"), type: -2, require: false, default: ""},
                    {localid: "type_asset_attachments", name: LanguageModule.text("txt_attachments"), type: -64}
                ]
            }
        },
        {
            id: -67, name: LanguageModule.text("txt_instruments_and_tools"), type: "instruments_and_tools", type2: "structure",
            content: {
                details: [
                    {localid: "type_instruments_and_tools_name", name: LanguageModule.text("txt_name"), type: -1, require: true, default: ""},
                    {localid: "type_instruments_and_tools_code", name: LanguageModule.text("txt_code"), type: -1, require: true, default: ""},
                    {localid: "type_instruments_and_tools_warehouseid", name: LanguageModule.text("txt_warehouse"), type: -70, require: true, default: 0},
                    {localid: "type_instruments_and_tools_asset_category", name: LanguageModule.text("txt_instruments_and_tools_category"), type: -205, require: true},
                    {localid: "type_instruments_and_tools_specification", name: LanguageModule.text("txt_specification"), type: -1, require: false, default: ""},
                    {localid: "type_instruments_and_tools_amount", name: LanguageModule.text("txt_quantity"), type: -3, require: true, default: ""},
                    {localid: "type_instruments_and_tools_unit", name: LanguageModule.text("txt_unit"), type: -1, require: false, default: ""},
                    {localid: "type_instruments_and_tools_input_date", name: LanguageModule.text("txt_input_date"), type: -4, require: true, default: ["today", ""]},
                    {localid: "type_instruments_and_tools_purchased_price", name: LanguageModule.text("txt_purchased_price"), type: -3, require: false, decpre: 2},
                    {localid: "type_instruments_and_tools_comment", name: LanguageModule.text("txt_note"), type: -2, require: false, default: ""},
                    {localid: "type_instruments_and_tools_attachments", name: LanguageModule.text("txt_attachments"), type: -64}
                ]
            }
        },
        {
            id: -68, name: LanguageModule.text("txt_warehouse"), type: "warehouses", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_warehouses_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_warehouses_code", name: LanguageModule.text("txt_code"), type: -1, default: "", require: true},
                    {localid: "type_warehouses_storekeepers", name: LanguageModule.text("txt_storekeeper"), type: -48, require: true},
                    {localid: "type_warehouses_geoid", name: LanguageModule.text("txt_geographical_position"), type: -23, require: true},
                    {localid: "type_warehouses_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -69, name: "Chọn tài sản", type: 'member_of_assets'},
        {id: -70, name: "Chọn kho", type: 'member_of_warehouses'},
        {
            id: -71, name: LanguageModule.text("txt_asset_handover_lines"), type: "asset_handover_lines", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_asset_handover_lines_assetid", name: LanguageModule.text("txt_asset"), type: -69, default: "", require: true},
                    {localid: "type_asset_handover_lines_status", name: LanguageModule.text("txt_status"), type: -1, default: "", require: true, readOnly: true},
                    {localid: "type_asset_handover_lines_comment", name: LanguageModule.text("txt_note"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 72, name: LanguageModule.text("txt_asset_handover_lines_array"), type: "array", notPri: true,
            content: {
                typeof: -71
            }
        },
        {
            id: -73, name: LanguageModule.text("txt_asset_handover"), type: "asset_handover", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_asset_handover_date", name: LanguageModule.text("txt_handover_date"), type: -4, default: ["today", ""], require: true},
                    {localid: "type_asset_handover_receiver", name: LanguageModule.text("txt_receiver"), type: -47, default: 0, require: true},
                    {localid: "type_asset_handover_warehouseid", name: LanguageModule.text("txt_warehouse"), type: -70, default: 0, require: true},
                    {localid: "type_asset_handover_comment", name: LanguageModule.text("txt_note"), type: -2, default: "", require: false},
                    {localid: "type_asset_handover_attachments", name: LanguageModule.text("txt_attachments"), type: -64},
                    {localid: "type_asset_handover_details", name: LanguageModule.text("txt_details"), type: -72}
                ]
            }
        },
        {id: -74, name: "Chọn tài sản và công cụ dụng cụ", type: 'member_of_assets_instruments_and_tools'},
        {
            id: -75, name: LanguageModule.text("txt_asset_recall_lines"), type: "asset_recall_lines", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_asset_recall_lines_assetid", name: LanguageModule.text("txt_asset"), type: -69, default: "", require: true},
                    {localid: "type_asset_recall_lines_status", name: LanguageModule.text("txt_status"), type: -1, default: "", require: true, readOnly: true},
                    {localid: "type_asset_recall_lines_comment", name: LanguageModule.text("txt_note"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 76, name: LanguageModule.text("txt_asset_recall_lines_array"), type: "array", notPri: true,
            content: {
                typeof: -75
            }
        },
        {
            id: -77, name: LanguageModule.text("txt_asset_recall"), type: "asset_recall", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_asset_recall_date", name: LanguageModule.text("txt_recall_date"), type: -4, default: ["today", ""], require: true},
                    {localid: "type_asset_recall_employeeid", name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: "type_asset_recall_warehouseid", name: LanguageModule.text("txt_warehouse"), type: -70, default: 0, require: true},
                    {localid: "type_asset_recall_comment", name: LanguageModule.text("txt_note"), type: -2, default: "", require: false},
                    {localid: "type_asset_recall_attachments", name: LanguageModule.text("txt_attachments"), type: -64},
                    {localid: "type_asset_recall_details", name: LanguageModule.text("txt_details"), type: -76}
                ]
            }
        },
        {
            id: -78, name: LanguageModule.text("txt_config_line"), type: "config_line", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_config_line_key", name: LanguageModule.text("txt_key"), type: -1, default: "", require: true},
                    {localid: "type_config_line_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: false},
                    {localid: "type_config_line_shortname", name: LanguageModule.text("txt_shortname"), type: -1, default: "", require: false},
                    {localid: "type_config_line_description", name: LanguageModule.text("txt_description"), type: -1, default: "", require: false},
                    {localid: "type_config_line_number_value", name: LanguageModule.text("txt_number_value"), type: -3, default: "", require: false},
                    {localid: "type_config_line_string_value", name: LanguageModule.text("txt_string_value"), type: -1, default: "", require: false}
                ]
            }
        },
        {
            id: - 79, name: LanguageModule.text("txt_config"), type: "array", notPri: true,
            content: {
                typeof: -78
            }
        },
        {
            id: - 80, name: LanguageModule.text("txt_allowance_policy_group"), type: "allowance_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_allowance_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_allowance_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_allowance_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -81, name: "Chọn nhóm chính sách trợ cấp", type: 'member_of_allowance_policy_groups'},
        {
            id: - 82, name: LanguageModule.text("txt_allowance_policy"), type: "allowance_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_allowance_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_allowance_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_allowance_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -81, default: 0, require: true},
                    {localid: 'type_allowance_policy_taxable_income', name: LanguageModule.text("txt_taxable_income"), type: -6, default: '', require: false},
                    {localid: 'type_allowance_policy_income_subject_to_insurance_contribution', name: LanguageModule.text("txt_income_subject_to_insurance_contribution"), type: -6, default: '', require: false},
                    {
                        localid: 'type_allowance_policy_allowance_type', name: LanguageModule.text("txt_allowance_type"), type: "union", typeOfUnion: -113, default: 0, require: true,
                        detailUnion: {
                            actual_expenses: [],
                            actual_expenses_with_limit: [
                                {localid: 'type_allowance_policy_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: '', require: true},
                                {localid: 'type_allowance_policy_frequency', name: LanguageModule.text("txt_frequency"), type: -84, default: 0, require: true}
                            ],
                            fixed_amount: [
                                {localid: 'type_allowance_policy_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: '', require: true},
                                {localid: 'type_allowance_policy_frequency', name: LanguageModule.text("txt_frequency"), type: -84, default: 0, require: true}
                            ]
                        }
                    },
                    {localid: 'type_allowance_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 83, name: LanguageModule.text("txt_benefit_type"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "actual_expenses", text: LanguageModule.text("txt_actual_expenses")},
                    {value: 2, localid: "actual_expenses_with_limit", text: LanguageModule.text("txt_actual_expenses_with_limit")},
                    {value: 3, localid: "fixed_amount", text: LanguageModule.text("txt_fixed_amount")}
                ]
            }
        },
        {
            id: - 84, name: LanguageModule.text("txt_allowance_frequency"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "week", text: LanguageModule.text("txt_week")},
                    {value: 2, localid: "month", text: LanguageModule.text("txt_month")},
                    {value: 3, localid: "quarter", text: LanguageModule.text("txt_quarter")},
                    {value: 4, localid: "six_months", text: LanguageModule.text("txt_six_months")},
                    {value: 5, localid: "year", text: LanguageModule.text("txt_year")},
                    {value: 6, localid: "one_time", text: LanguageModule.text("txt_one_time")}
                ]
            }
        },
        {
            id: - 85, name: LanguageModule.text("txt_training_program_group"), type: "training_program_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_training_program_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_training_program_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_training_program_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -86, name: "Chọn nhóm chương trình đào tạo", type: 'member_of_training_program_groups'},
        {
            id: - 87, name: LanguageModule.text("txt_insurance_policy"), type: "insurance_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_insurance_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_insurance_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_insurance_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -97, default: 0, require: true},
                    {localid: 'type_insurance_policy_calculated_on', name: LanguageModule.text("txt_calculated_on"), type: -88, default: 0, require: true},
                    {localid: 'type_insurance_policy_contributed_by_company', name: LanguageModule.text("txt_contributed_by_company") + " (%)", type: -3, default: '', require: false},
                    {localid: 'type_insurance_policy_contributed_by_employee', name: LanguageModule.text("txt_contributed_by_employee") + " (%)", type: -3, default: '', require: false},
                    {localid: 'type_insurance_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 88, name: LanguageModule.text("txt_insurance_calculation_base"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "basic", text: LanguageModule.text("txt_basic_salary")},
                    {value: 2, localid: "gross", text: LanguageModule.text("txt_gross_salary")},
                    {value: 3, localid: "option", text: LanguageModule.text("txt_option_follow_employee")}
                ]
            }
        },
        {id: - 89, name: LanguageModule.text("txt_select_employment_contract_type"), type: "member_of_employment_contract_types"},
        {id: -90, name: "Chọn nhóm chính sách nghỉ", type: 'member_of_leave_policy_groups'},
        {
            id: - 91, name: LanguageModule.text("txt_maximal_day_leave_calculation"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "fixed_number_of_day_per_year", text: LanguageModule.text("txt_fixed_number_of_day_per_year")},
                    {value: 2, localid: "monthly_incresmental", text: LanguageModule.text("txt_monthly_incresmental")}
                ]
            }
        },
        {
            id: - 92, name: LanguageModule.text("txt_approval_workflow"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "sequence", text: LanguageModule.text("txt_sequence")},
                    {value: 2, localid: "parallel", text: LanguageModule.text("txt_parallel")},
                    {value: 3, localid: "one_approver", text: LanguageModule.text("txt_one_approver")}
                ]
            }
        },
        {
            id: - 93, name: LanguageModule.text("txt_salary_payment_method"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "hourly_rate", text: LanguageModule.text("txt_hourly_rate")},
                    {value: 2, localid: "daily_rate", text: LanguageModule.text("txt_daily_rate")},
                    {value: 3, localid: "weekly_rate", text: LanguageModule.text("txt_weekly_rate")},
                    {value: 4, localid: "monthly_rate", text: LanguageModule.text("txt_monthly_rate")},
                    {value: 5, localid: "contractual_wages", text: LanguageModule.text("txt_contractual_wages")},
                    {value: 6, localid: "piece_rate", text: LanguageModule.text("txt_piece_rate")}
                ]
            }
        },
        {
            id: - 94, name: LanguageModule.text("txt_leave_policy"), type: "leave_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_leave_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_leave_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {
                        localid: 'type_leave_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: "union", typeOfUnion: -90, default: 0, require: true,
                        detailUnion: {
                            "-1": [
                                {localid: 'type_leave_policy_leave_days_per_year', name: LanguageModule.text("txt_leave_days_per_year"), type: -3, default: '', require: false, decpre: 1},
                                {localid: 'type_leave_policy_maximal_day_calculation', name: LanguageModule.text("txt_maximal_day_calculation"), type: -91, default: 0, require: true},
                                {localid: 'type_leave_policy_number_of_working_months_to_increase_one_day_leave', name: LanguageModule.text("txt_number_of_working_months_to_increase_one_day_leave"), type: -3, default: '', require: true, decpre: 1},
                                {localid: 'type_leave_policy_maximum_leave_days_per_year', name: LanguageModule.text("txt_maximum_leave_days_per_year"), type: -3, default: '', require: false, decpre: 1},
                                {localid: 'type_leave_policy_carried_forward_leave', name: LanguageModule.text("txt_carried_forward_leave"), type: -3, default: '', require: false, decpre: 1},
                                {localid: 'type_leave_policy_accumulated_leave_expired_before', name: LanguageModule.text("txt_accumulated_leave_expired_before"), type: -201, default: null, require: true},
                            ]
                        }
                    },
                    {localid: 'type_leave_policy_proposal_submitted_before', name: LanguageModule.text("txt_proposal_submitted_before"), type: -3, default: '', require: false, decpre: 1},
                    {localid: 'type_leave_policy_salary_paid', name: LanguageModule.text("txt_salary_paid"), type: -6, default: false, require: false},
                    {localid: 'type_leave_policy_cancel_request_days', name: LanguageModule.text("txt_cancel_request_days"), type: -3, default: false, require: false},
                    {localid: 'type_leave_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 95, name: LanguageModule.text("txt_leave_policy_group"), type: "leave_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_leave_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_leave_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_leave_policy_group_symbol', name: LanguageModule.text("txt_symbol"), type: -1, default: '', require: true},
                    {localid: 'type_leave_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 96, name: LanguageModule.text("txt_insurance_policy_group"), type: "insurance_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_insurance_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_insurance_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_insurance_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -97, name: "Chọn nhóm chính sách bảo hiểm", type: 'member_of_insurance_policy_groups'},
        {
            id: - 98, name: LanguageModule.text("txt_benefit_policy_group"), type: "benefit_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_benefit_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_benefit_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_benefit_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -99, name: "Chọn nhóm chính sách phúc lợi", type: 'member_of_benefit_policy_groups'},
        {
            id: - 100, name: LanguageModule.text("txt_benefit_policy"), type: "benefit_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_benefit_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_benefit_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_benefit_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -99, default: 0, require: true},
                    {localid: 'type_benefit_policy_taxable_income', name: LanguageModule.text("txt_taxable_income"), type: -6, default: '', require: false},
                    {localid: 'type_benefit_policy_income_subject_to_insurance_contribution', name: LanguageModule.text("txt_income_subject_to_insurance_contribution"), type: -6, default: '', require: false},
                    {
                        localid: 'type_benefit_policy_benefit_type', name: LanguageModule.text("txt_benefit_type"), type: "union", typeOfUnion: -83, default: 0, require: true,
                        detailUnion: {
                            actual_expenses: [],
                            actual_expenses_with_limit: [
                                {localid: 'type_benefit_policy_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: '', require: true},
                                {localid: 'type_benefit_policy_frequency', name: LanguageModule.text("txt_frequency"), type: -114, default: 0, require: true},
                            ],
                            fixed_amount: [
                                {localid: 'type_benefit_policy_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: '', require: true},
                                {localid: 'type_benefit_policy_frequency', name: LanguageModule.text("txt_frequency"), type: -114, default: 0, require: true},
                            ]
                        }
                    },
                    {localid: 'type_benefit_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 101, name: LanguageModule.text("txt_bonus_policy_group"), type: "bonus_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_bonus_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_bonus_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_bonus_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -102, name: "Chọn nhóm chính sách thưởng", type: 'member_of_bonus_policy_groups'},
        {
            id: - 103, name: LanguageModule.text("txt_punishment_policy_group"), type: "punishment_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_punishment_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_punishment_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_punishment_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -104, name: "Chọn nhóm chính sách thưởng", type: 'member_of_punishment_policy_groups'},
        {
            id: - 105, name: LanguageModule.text("txt_tax_policy_group"), type: "tax_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_tax_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_tax_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_tax_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -106, name: "Chọn nhóm chính sách thuế", type: 'member_of_tax_policy_groups'},
        {
            id: - 107, name: LanguageModule.text("txt_advance_payment_policy_group"), type: "advance_payment_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_advance_payment_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_advance_payment_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_advance_payment_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -108, name: "Chọn nhóm chính sách tạm ứng", type: 'member_of_advance_payment_policy_groups'},
        {
            id: - 109, name: LanguageModule.text("txt_late_early_checkin_policy_group"), type: "late_early_checkin_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_late_early_checkin_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_late_early_checkin_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_late_early_checkin_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -110, name: "Chọn nhóm chính sách DMVS", type: 'member_of_late_early_checkin_policy_groups'},
        {
            id: - 111, name: LanguageModule.text("txt_bonus_policy"), type: "bonus_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_bonus_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_bonus_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_bonus_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -102, default: 0, require: true},
                    {localid: 'type_bonus_policy_taxable_income', name: LanguageModule.text("txt_taxable_income"), type: -6, default: '', require: false},
                    {localid: 'type_bonus_policy_income_subject_to_insurance_contribution', name: LanguageModule.text("txt_income_subject_to_insurance_contribution"), type: -6, default: '', require: false},
                    {localid: 'type_bonus_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 112, name: LanguageModule.text("txt_punishment_policy"), type: "punishment_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_punishment_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_punishment_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_punishment_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -104, default: 0, require: true},
                    {localid: 'type_punishment_policy_tax_relief', name: LanguageModule.text("txt_tax_relief"), type: -6, default: false, require: false},
                    {localid: 'type_punishment_policy_insurance_contribution_relief', name: LanguageModule.text("txt_insurance_contribution_relief"), type: -6, default: '', require: false},
                    {localid: 'type_punishment_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 113, name: LanguageModule.text("txt_allowance_type"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "actual_expenses", text: LanguageModule.text("txt_actual_expenses")},
                    {value: 2, localid: "actual_expenses_with_limit", text: LanguageModule.text("txt_actual_expenses_with_limit")},
                    {value: 3, localid: "fixed_amount", text: LanguageModule.text("txt_fixed_amount")}
                ]
            }
        },
        {
            id: - 114, name: LanguageModule.text("txt_benefit_frequency"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "week", text: LanguageModule.text("txt_week")},
                    {value: 2, localid: "month", text: LanguageModule.text("txt_month")},
                    {value: 3, localid: "quarter", text: LanguageModule.text("txt_quarter")},
                    {value: 4, localid: "six_months", text: LanguageModule.text("txt_six_months")},
                    {value: 5, localid: "year", text: LanguageModule.text("txt_year")},
                    {value: 6, localid: "one_time", text: LanguageModule.text("txt_one_time")}
                ]
            }
        },
        {
            id: - 115, name: LanguageModule.text("txt_advance_payment_policy"), type: "advance_payment_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_advance_payment_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_advance_payment_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_advance_payment_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -108, default: 0, require: true},
                    {localid: 'type_advance_payment_policy_advance_payment_on', name: LanguageModule.text("txt_advance_payment_on"), type: "union", typeOfUnion: -117, default: 0, require: true,
                        detailUnion: {
                            basic_salary: [{localid: 'type_advance_payment_policy_maximum_percentage', name: LanguageModule.text("txt_maximum_percentage") + " (%)", type: -3, default: ""}],
                            gross_salary: [{localid: 'type_advance_payment_policy_maximum_percentage', name: LanguageModule.text("txt_maximum_percentage") + " (%)", type: -3, default: ""}],
                            fixed_amount: [{localid: 'type_advance_payment_policy_maximum_amount', name: LanguageModule.text("txt_maximum_amount") + " ($)", type: -118, default: ""}]
                        }
                    },
                    {localid: 'type_advance_payment_policy_calculated_on', name: LanguageModule.text("txt_calculated_on"), type: -116, default: 0, require: true},
                    {localid: 'type_advance_payment_policy_salary_advance', name: LanguageModule.text("txt_salary_advance"), type: -6, default: false},
                    {localid: 'type_advance_payment_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 116, name: LanguageModule.text("txt_advance_payment_frequency"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 4, localid: "one_request", text: LanguageModule.text("txt_one_request")},
                    {value: 1, localid: "week", text: LanguageModule.text("txt_week")},
                    {value: 2, localid: "month", text: LanguageModule.text("txt_month")},
                    {value: 3, localid: "year", text: LanguageModule.text("txt_year")},
                ]
            }
        },
        {
            id: - 117, name: LanguageModule.text("txt_advance_payment_calculation_base"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "basic_salary", text: LanguageModule.text("txt_basic_salary")},
                    {value: 2, localid: "gross_salary", text: LanguageModule.text("txt_gross_salary")},
                    {value: 3, localid: "fixed_amount", text: LanguageModule.text("txt_fixed_amount")}
                ]
            }
        },
        {id: -118, name: LanguageModule.text("txt_currency"), type: "currency"},
        {
            id: - 119, name: LanguageModule.text("txt_late_early_checkin_policy"), type: "late_early_checkin_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_late_early_checkin_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_late_early_checkin_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_late_early_checkin_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -110, default: 0, require: true},
                    {localid: 'type_late_early_checkin_policy_late', name: LanguageModule.text("txt_late_checkin_minute"), type: -3, default: "", require: true},
                    {localid: 'type_late_early_checkin_policy_early', name: LanguageModule.text("txt_early_checkout_minute"), type: -3, default: '', require: true},
                    {localid: 'type_late_early_checkin_policy_proposal_submitted_before', name: LanguageModule.text("txt_proposal_submitted_before"), type: -3, default: 0, require: false},
                    {localid: 'type_late_early_checkin_policy_salary_paid', name: LanguageModule.text("txt_salary_paid"), type: -6, default: false, require: false},
                    {localid: 'type_late_early_checkin_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 120, name: LanguageModule.text("txt_tax_rate_lines"), type: "tax_rate_lines", type2: "structure",
            content: {
                details: [
                    {localid: 'tax_rate_lines_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, default: '', require: true},
                    {localid: 'tax_rate_lines_rate', name: LanguageModule.text("txt_rate") + " (%)", type: -3, default: '', require: false}
                ]
            }
        },
        {
            id: - 121, name: LanguageModule.text("txt_tax_rate"), type: "array", notPri: true,
            content: {
                typeof: -120
            }
        },
        {
            id: - 122, name: LanguageModule.text("txt_tax_policy"), type: "tax_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_tax_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_tax_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_tax_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -106, default: 0, require: true},
                    {
                        localid: 'type_tax_policy_tax_type', name: LanguageModule.text("txt_tax_type"), type: "union", typeOfUnion: -123, default: 0, require: true,
                        detailUnion: {
                            progressive_tax: [{localid: 'type_tax_policy_tax_rate_progressive_tax', name: LanguageModule.text("txt_tax_rate"), type: -121, default: '', require: true}],
                            fixed_percentage: [{localid: 'type_tax_policy_tax_rate_fixed_percentage', name: LanguageModule.text("txt_tax_rate") + " (%)", type: -3, default: '', require: true}]
                        }
                    },
                    {localid: 'type_tax_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 123, name: LanguageModule.text("txt_tax_type"), type: "enum", notExtend: true,
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "progressive_tax", text: LanguageModule.text("txt_progressive_tax")},
                    {value: 2, localid: "fixed_percentage", text: LanguageModule.text("txt_fixed_percentage")}
                ]
            }
        },
        {
            id: - 124, name: LanguageModule.text("txt_salary_policy_group"), type: "salary_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_salary_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_salary_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_salary_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -125, name: "Chọn nhóm chính sách lương", type: 'member_of_salary_policy_groups'},
        {
            id: - 126, name: LanguageModule.text("txt_trade_union_policy_group"), type: "trade_union_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_trade_union_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_trade_union_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_trade_union_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -127, name: "Chọn nhóm chính sách công đoàn", type: 'member_of_trade_union_policy_groups'},
        {
            id: - 128, name: LanguageModule.text("txt_other_liability_policy_group"), type: "other_liability_policy_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_other_liability_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_other_liability_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_other_liability_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -129, name: "Chọn nhóm chính sách trách nhiệm khác", type: 'member_of_other_liability_policy_groups'},
        {
            id: - 130, name: LanguageModule.text("txt_other_liability_calculation_base"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "basic", text: LanguageModule.text("txt_basic_salary")},
                    {value: 2, localid: "gross", text: LanguageModule.text("txt_gross_salary")},
                    {value: 3, localid: "option", text: LanguageModule.text("txt_option_follow_employee")}
                ]
            }
        },
        {
            id: - 131, name: LanguageModule.text("txt_other_liability_frequency"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "week", text: LanguageModule.text("txt_week")},
                    {value: 2, localid: "month", text: LanguageModule.text("txt_month")},
                    {value: 3, localid: "quarter", text: LanguageModule.text("txt_quarter")},
                    {value: 4, localid: "six_months", text: LanguageModule.text("txt_six_months")},
                    {value: 5, localid: "year", text: LanguageModule.text("txt_year")},
                    {value: 6, localid: "one_time", text: LanguageModule.text("txt_one_time")}
                ]
            }
        },
        {
            id: - 132, name: LanguageModule.text("txt_trade_union_fee_type"), type: "enum", notExtend: true,
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "fixed_amount", text: LanguageModule.text("txt_fixed_amount")},
                    {value: 2, localid: "percentage", text: LanguageModule.text("txt_percentage")}
                ]
            }
        },
        {
            id: - 133, name: LanguageModule.text("txt_salary_policy"), type: "salary_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_salary_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_salary_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_salary_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -125, default: 0, require: true},
                    {localid: 'type_salary_policy_payment_method', name: LanguageModule.text("txt_salary_payment_method"), type: -93, default: 0, require: true},
                    {localid: 'type_salary_policy_minimum_salary_amount', name: LanguageModule.text("txt_minimum_salary_amount"), type: -118, default: 0, require: true},
                    {localid: 'type_salary_policy_maximum_salary_amount', name: LanguageModule.text("txt_maximum_salary_amount"), type: -118, default: 0, require: true},
                    {localid: 'type_salary_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 134, name: LanguageModule.text("txt_trade_union_policy"), type: "trade_union_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_trade_union_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_trade_union_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_trade_union_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -127, default: 0, require: true},
                    {localid: 'type_trade_union_policy_tax_relief', name: LanguageModule.text("txt_tax_relief"), type: -6, default: false, require: false},
                    {localid: 'type_trade_union_policy_insurance_contribution_relief', name: LanguageModule.text("txt_insurance_contribution_relief"), type: -6, default: false},
                    {
                        localid: 'type_trade_union_policy_fee_type', name: LanguageModule.text("txt_fee_type"), type: "union", typeOfUnion: -132, default: 0, require: true,
                        detailUnion: {
                            percentage: [{localid: 'type_trade_union_policy_rate', name: LanguageModule.text("txt_rate") + " (%)", type: -3, default: "", require: true}],
                            fixed_amount: [{localid: 'type_trade_union_policy_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, default: '', require: true}]
                        }
                    },
                    {localid: 'type_trade_union_policy_limit_on_maximum_trade_union_fee', name: LanguageModule.text("txt_limit_on_maximum_trade_union_fee"), type: -6, default: false, require: false},
                    {localid: 'type_trade_union_policy_maximum_trade_union_fee', name: LanguageModule.text("txt_maximum_trade_union_fee") + " ($)", type: -118, default: ""},
                    {localid: 'type_trade_union_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 135, name: LanguageModule.text("txt_other_liability_policy"), type: "other_liability_policies", type2: "structure",
            content: {
                details: [
                    {localid: 'type_other_liability_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_other_liability_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_other_liability_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -129, default: 0, require: true},
                    {localid: 'type_other_liability_policy_tax_relief', name: LanguageModule.text("txt_tax_relief"), type: -6, default: false, require: false},
                    {localid: 'type_other_liability_policy_insurance_contribution_relief', name: LanguageModule.text("txt_insurance_contribution_relief"), type: -6, default: false},
                    {
                        localid: 'type_other_liability_policy_other_liability_type', name: LanguageModule.text("txt_other_liability_type"), type: "union", typeOfUnion: -199, default: 0, require: true,
                        detailUnion: {
                            actual_expenses: [],
                            actual_expenses_with_limit: [
                                {localid: 'type_other_liability_policy_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: '', require: true},
                                {localid: 'type_other_liability_policy_frequency', name: LanguageModule.text("txt_frequency"), type: -131, default: 0, require: true},
                            ],
                            fixed_amount: [
                                {localid: 'type_other_liability_policy_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: '', require: true},
                                {localid: 'type_other_liability_policy_frequency', name: LanguageModule.text("txt_frequency"), type: -131, default: 0, require: true},
                            ]
                        }
                    },
                    {localid: 'type_other_liability_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -136, name: LanguageModule.text("txt_hour_period"), type: "hour_period"},
        {id: -137, name: LanguageModule.text("txt_select_shift"), type: "member_of_shifts"},
        {id: -138, name: LanguageModule.text("txt_select_shifts"), type: "members_of_shifts"},
        {id: -139, name: "Chọn chính sách bảo hiểm", type: 'member_of_insurance_policies'},
        {id: -140, name: "Chọn chính sách thuế", type: 'member_of_tax_policies'},
        {id: -141, name: "Chọn chính sách công đoàn", type: 'member_of_trade_union_policies'},
        {id: -142, name: "Chọn chính sách nghỉ ngày", type: 'member_of_leave_policies'},
        {id: -143, name: "Chọn chính sách phúc lợi", type: 'member_of_benefit_policies'},
        {id: -144, name: "Chọn chính sách trợ cấp", type: 'member_of_allowance_policies'},
        {id: -145, name: "Chọn chính sách thưởng", type: 'member_of_bonus_policies'},
        {id: -146, name: "Chọn chính sách phạt", type: 'member_of_punishment_policies'},
        {id: -147, name: "Chọn chính sách tạm ứng", type: 'member_of_advance_payment_policies'},
        {id: -148, name: "Chọn chính sách đi muộn, về sớm", type: 'member_of_late_early_checkin_policies'},
        {id: -149, name: "Chọn chính sách lương", type: 'member_of_salary_policies'},
        {id: -150, name: "Chọn chính sách trách nhiệm khác", type: 'member_of_other_liability_policies'},
        {
            id: - 151, name: LanguageModule.text("txt_insurance_policies_applied_to_employee"), type: "insurance_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_insurance_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_insurance_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -139, default: 0, require: true},
                    {localid: 'type_insurance_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false},
                    {
                        localid: 'type_insurance_policies_applied_to_employee_calculated_on', name: LanguageModule.text("txt_calculated_on"), type: "union", typeOfUnion: -88, default: 0, require: true,
                        detailUnion: {
                            option: [{localid: 'type_insurance_policies_applied_to_employee_value', name: LanguageModule.text("txt_value") + " ($)", type: -118, default: "", require: true}]
                        }
                    }
                ]
            }
        },
        {
            id: - 152, name: LanguageModule.text("txt_employment_contract_type"), type: "employment_contract_types", type2: "structure",
            content: {
                details: [
                    {localid: 'type_employment_contract_type_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_employment_contract_type_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_employment_contract_type_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 153, name: LanguageModule.text("txt_social_network"), type: "social_network", type2: "structure",
            content: {
                details: [
                    {localid: 'type_social_network_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_social_network_account', name: LanguageModule.text("txt_account"), type: -1, default: '', require: false}
                ]
            }
        },
        {
            id: - 154, name: LanguageModule.text("txt_education_history"), type: "education_history", type2: "structure",
            content: {
                details: [
                    {localid: 'type_education_history_major', name: LanguageModule.text("txt_major"), type: -1, default: '', require: true},
                    {localid: 'type_education_history_school', name: LanguageModule.text("txt_school"), type: -1, default: '', require: false},
                    {localid: 'type_education_history_degree', name: LanguageModule.text("txt_degree"), type: -157, default: 0, require: false},
                    {localid: 'type_education_history_from_month', name: LanguageModule.text("txt_from_month"), type: -267, require: false},
                    {localid: 'type_education_history_to_month', name: LanguageModule.text("txt_to_month"), type: -267, require: false},
                    {localid: 'type_education_history_comment', name: LanguageModule.text("txt_note"), type: -2, require: false},
                    {localid: 'type_education_history_top_level', name: LanguageModule.text("txt_top_level"), type: -6, require: false}
                ]
            }
        },
        {
            id: - 155, name: LanguageModule.text("txt_skill"), type: "skill", type2: "structure",
            content: {
                details: [
                    {localid: 'type_skill_skill', name: LanguageModule.text("txt_skill"), type: -1, default: '', require: true},
                    {localid: 'type_skill_level', name: LanguageModule.text("txt_level"), type: -156, default: 0, require: false}
                ]
            }
        },
        {
            id: - 156, name: LanguageModule.text("txt_skill_level"), type: "enum", notExtend: true,
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "1", text: 1},
                    {value: 2, localid: "2", text: 2},
                    {value: 3, localid: "3", text: 3},
                    {value: 4, localid: "4", text: 4},
                    {value: 5, localid: "5", text: 5}
                ]
            }
        },
        {
            id: - 157, name: LanguageModule.text("txt_degree"), type: "enum", notExtend: true,
            content: {
                typeof: -1,
                details: [
                    {value: "midle_school", localid: "midle_school", text: LanguageModule.text("txt_midle_school")},
                    {value: "high_school", localid: "high_school", text: LanguageModule.text("txt_high_school")},
                    {value: "intermediate", localid: "intermediate", text: LanguageModule.text("txt_intermediate")},
                    {value: "college", localid: "college", text: LanguageModule.text("txt_college")},
                    {value: "university", localid: "university", text: LanguageModule.text("txt_university")},
                    {value: "master", localid: "master", text: LanguageModule.text("txt_master")},
                    {value: "doctor", localid: "doctor", text: LanguageModule.text("txt_doctor")}
                ]
            }
        },
        {
            id: - 158, name: LanguageModule.text("txt_work_history"), type: "work_history", type2: "structure",
            content: {
                details: [
                    {localid: 'type_work_history_position', name: LanguageModule.text("txt_position"), type: -1, default: '', require: true},
                    {localid: 'type_work_history_organization', name: LanguageModule.text("txt_organization"), type: -1, default: '', require: false},
                    {localid: 'type_work_history_from_month', name: LanguageModule.text("txt_from_month"), type: -4, require: false},
                    {localid: 'type_work_history_to_month', name: LanguageModule.text("txt_to_month"), type: -4, require: false},
                    {localid: 'type_work_history_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
                ]
            }
        },
        {
            id: - 159, name: LanguageModule.text("txt_bank_account"), type: "bank_account", type2: "structure",
            content: {
                details: [
                    {localid: 'type_bank_account_number', name: LanguageModule.text("txt_account_number"), type: -1, default: '', require: true},
                    {localid: 'type_bank_account_holder_name', name: LanguageModule.text("txt_account_holder_name"), type: -1, default: "", require: false},
                    {localid: 'type_bank_account_bank_name', name: LanguageModule.text("txt_bank_name"), type: -1, default: "", require: false},
                    {localid: 'type_bank_account_agency', name: LanguageModule.text("txt_agency"), type: -1, default: "", require: false}
                ]
            }
        },
        {
            id: - 160, name: LanguageModule.text("txt_nation"), type: "nations", type2: "structure",
            content: {
                details: [
                    {localid: 'type_nation_short_name', name: LanguageModule.text("txt_shortname"), type: -1, default: '', require: true},
                    {localid: 'type_nation_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_nation_phonecode', name: LanguageModule.text("txt_phone_code"), type: -1, default: "", require: false},
                    {localid: 'type_nation_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 161, name: LanguageModule.text("txt_city"), type: "cities", type2: "structure",
            content: {
                details: [
                    {localid: 'type_city_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_city_nationid', name: LanguageModule.text("txt_nation"), type: -14, default: 0, require: true},
                    {localid: 'type_city_code', name: LanguageModule.text("txt_code"), type: -1, default: '', require: true},
                    {localid: 'type_city_postalcode', name: LanguageModule.text("txt_postal_code"), type: -1, default: '', require: false},
                    {localid: 'type_city_phonecode', name: LanguageModule.text("txt_phone_code"), type: -1, default: "", require: false},
                    {localid: 'type_city_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 162, name: LanguageModule.text("txt_ethnic"), type: "ethnics", type2: "structure",
            content: {
                details: [
                    {localid: 'type_ethnic_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_ethnic_code', name: LanguageModule.text("txt_code"), type: -1, default: '', require: true},
                    {localid: 'type_ethnic_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 163, name: LanguageModule.text("txt_religion"), type: "religions", type2: "structure",
            content: {
                details: [
                    {localid: 'type_religion_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_religion_code', name: LanguageModule.text("txt_code"), type: -1, default: '', require: true},
                    {localid: 'type_religion_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 164, name: LanguageModule.text("txt_bonus_policies_applied_to_employee"), type: "bonus_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_bonus_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_bonus_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -145, default: 0, require: true},
                    {localid: 'type_bonus_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 165, name: LanguageModule.text("txt_punishment_policies_applied_to_employee"), type: "punishment_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_punishment_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_punishment_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -146, default: 0, require: true},
                    {localid: 'type_punishment_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 166, name: LanguageModule.text("txt_benefit_policies_applied_to_employee"), type: "benefit_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_benefit_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_benefit_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -143, default: 0, require: true},
                    {localid: 'type_benefit_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 167, name: LanguageModule.text("txt_allowance_policies_applied_to_employee"), type: "allowance_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_allowance_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_allowance_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -144, default: 0, require: true},
                    {localid: 'type_allowance_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 168, name: LanguageModule.text("txt_tax_policies_applied_to_employee"), type: "tax_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_tax_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_tax_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -140, default: 0, require: true},
                    {localid: 'type_tax_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false},
                    {localid: 'type_tax_policies_applied_to_employee_tax_type', name: LanguageModule.text("txt_tax_type"), type: -123, default: 0, require: false}
                ]
            }
        },
        {
            id: - 169, name: LanguageModule.text("txt_trade_union_policies_applied_to_employee"), type: "trade_union_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_trade_union_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_trade_union_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -141, default: 0, require: true},
                    {localid: 'type_trade_union_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 170, name: LanguageModule.text("txt_other_liability_policies_applied_to_employee"), type: "other_liability_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_other_liability_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_other_liability_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -150, default: 0, require: true},
                    {localid: 'type_other_liability_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false},
                    {localid: 'type_other_liability_policies_applied_to_employee_tax_relief', name: LanguageModule.text("txt_tax_relief"), type: -6, default: false, require: false},
                    {localid: 'type_other_liability_policies_applied_to_employee_insurance_contribution_relief', name: LanguageModule.text("txt_insurance_contribution_relief"), type: -6, default: false},
                    {localid: 'type_other_liability_policies_applied_to_employee_other_liability_type', name: LanguageModule.text("txt_other_liability_type"), type: -199, default: 0, require: false},
                    {localid: 'type_other_liability_policies_applied_to_employee_frequency', name: LanguageModule.text("txt_frequency"), type: -131, default: 0, require: true}
                ]
            }
        },
        {
            id: - 171, name: LanguageModule.text("txt_leave_policies_applied_to_employee"), type: "leave_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_leave_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_leave_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -142, default: 0, require: true},
                    {localid: 'type_leave_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 172, name: LanguageModule.text("txt_late_early_checkin_policies_applied_to_employee"), type: "late_early_checkin_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_late_early_checkin_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_late_early_checkin_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -148, default: 0, require: true},
                    {localid: 'type_late_early_checkin_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 173, name: LanguageModule.text("txt_advance_payment_policies_applied_to_employee"), type: "advance_payment_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_advance_payment_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_advance_payment_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -147, default: 0, require: true},
                    {localid: 'type_advance_payment_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 174, name: LanguageModule.text("txt_salary_decisions_applied_to_employee"), type: "salary_decisions_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_salary_decisions_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_salary_decisions_applied_to_employee_position', name: LanguageModule.text("txt_position"), type: -1, default: "", require: false},
                    {localid: 'type_salary_decisions_applied_to_employee_salary_grade', name: LanguageModule.text("txt_salary_grade"), type: -1, default: "", require: false},
                    {localid: 'type_salary_decisions_applied_to_employee_basic_salary_amount', name: LanguageModule.text("txt_basic_salary_amount") + " ($)", type: -118, default: 0, require: false},
                    {localid: 'type_salary_decisions_applied_to_employee_gross_salary_amount', name: LanguageModule.text("txt_gross_salary_amount") + " ($)", type: -118, default: 0, require: false},
                    {localid: 'type_salary_decisions_applied_to_employee_calculated_on', name: LanguageModule.text("txt_calculated_on"), type: -181, default: 0, require: true},
                    {localid: 'type_salary_decisions_applied_to_employee_effective_date', name: LanguageModule.text("txt_effective_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_salary_decisions_applied_to_employee_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: false},
                    {localid: 'type_salary_decisions_applied_to_employee_decision_date', name: LanguageModule.text("txt_decision_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_salary_decisions_applied_to_employee_available', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 175, name: LanguageModule.text("txt_salary_policy_applied_to_employee"), type: "salary_policies_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_salary_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_salary_policies_applied_to_employee_position', name: LanguageModule.text("txt_position"), type: -1, default: "", require: false},
                    {localid: 'type_salary_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -149, default: 0, require: true},
                    {localid: 'type_salary_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 176, name: LanguageModule.text("txt_employment_contract"), type: "employment_contracts", type2: "structure",
            content: {
                details: [
                    {localid: 'type_employee_employment_contract_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_employee_employment_contract_contractid', name: LanguageModule.text("txt_employment_contract_type"), type: -89, default: 0, require: true},
                    {localid: 'type_employee_employment_contract_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false},
                    {localid: 'type_employee_employment_contract_effective_date_from', name: LanguageModule.text("txt_effective_date_from"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_employee_employment_contract_effective_date_to', name: LanguageModule.text("txt_effective_date_to"), type: -4, default: ["today", ""], require: false},
                    {localid: 'type_employee_employment_contract_attachments', name: LanguageModule.text("txt_attachments"), type: -64, default: [], require: false},
                    {localid: 'type_employee_employment_contract_available', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 177, name: LanguageModule.text("txt_bonus_list"), type: "bonus_list", type2: "structure",
            content: {
                details: [
                    {localid: 'type_bonus_list_cycleid', name: LanguageModule.text("txt_payroll_cycle"), type: -266, default: 0, require: true},
                    {localid: 'type_bonus_list_payroll_date_month', name: LanguageModule.text("txt_payroll_date"), type: -267, require: false},
                    {localid: 'type_bonus_list_payroll_date_week', name: LanguageModule.text("txt_payroll_date"), type: -268, require: false},
                    {localid: 'type_bonus_list_name', name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: 'type_bonus_list_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: true},
                    {localid: 'type_bonus_list_reference_date', name: LanguageModule.text("txt_reference_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_bonus_list_policyid', name: LanguageModule.text("txt_policy"), type: -145, default: 0, require: true}
                ]
            }
        },
        {
            id: - 178, name: LanguageModule.text("txt_training_lecturer"), type: "training_lecturer", type2: "structure",
            content: {
                details: [
                    {
                        localid: "type_training_program_lecturer", name: LanguageModule.text("txt_training_lecturer_source"), type: "union", typeOfUnion: -61, require: true,
                        detailUnion: {
                            type_internal_training: [{localid: 'type_training_program_internal_trainer', name: LanguageModule.text("txt_lecturer"), type: -47, require: true}],
                            type_outsource: [
                                {localid: 'type_training_program_outsource_trainer', name: LanguageModule.text("txt_lecturer"), type: -179, default: '', require: true}
                            ]
                        }
                    }
                ]
            }
        },
        {
            id: -179, name: LanguageModule.text("txt_people"), type: "people", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_people_fullname", name: LanguageModule.text("txt_fullname"), type: -1, require: true},
                    {localid: "type_people_dayofbirth", name: LanguageModule.text("txt_day_of_birth"), type: -4, default: ["custom", null], require: true},
                    {localid: "type_people_sex", name: LanguageModule.text("txt_sex"), type: -40, default: 0, require: false},
                    {localid: "type_people_marital_status", name: LanguageModule.text("txt_marital_status"), type: -39, default: 0, require: false},
                    {localid: "type_people_nationalidno", name: LanguageModule.text("txt_nation_id_number"), type: -1, default: "", require: true},
                    {localid: "type_people_nationalidno_date", name: LanguageModule.text("txt_date_of_issue"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_people_nationalidno_place", name: LanguageModule.text("txt_place_of_issue"), type: -1, default: "", require: false},
                    {localid: "type_people_nationality", name: LanguageModule.text("txt_nationality"), type: -14, default: 0, require: true},
                    {localid: "type_people_religion", name: LanguageModule.text("txt_religion"), type: -22, default: 0, require: false},
                    {localid: "type_people_ethnic", name: LanguageModule.text("txt_ethnic"), type: -16, default: 0, require: false},
                    {localid: "type_people_permanent_address", name: LanguageModule.text("txt_permanent_address"), type: -1, require: false},
                    {localid: "type_people_permanent_nation_city", name: LanguageModule.text("txt_permanent_nation_city"), type: -207, default: 0, require: false},
                    {localid: "type_people_temporary_address", name: LanguageModule.text("txt_temporary_address"), type: -1, require: false},
                    {localid: "type_people_temporary_nation_city", name: LanguageModule.text("txt_temporary_nation_city"), type: -207, default: 0, require: false},
                    {localid: "type_people_personal_tax_code", name: LanguageModule.text("txt_personal_tax_code"), type: -1, default: "", require: false},
                    {localid: "type_people_personal_income_tax_relief", name: LanguageModule.text("txt_personal_income_tax_relief"), type: -6, default: false, require: false},
                    {localid: "type_people_social_security_number", name: LanguageModule.text("txt_social_security_number"), type: -1, default: "", require: false},
                    {localid: "type_people_social_insurance_date", name: LanguageModule.text("txt_social_insurance_date"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_people_place_of_social_insurance", name: LanguageModule.text("txt_place_of_social_insurance"), type: -1, default: "", require: false},
                    {localid: "type_people_emergency_contact", name: LanguageModule.text("txt_emergency_contact"), type: -2, default: "", require: false},
                    {localid: "type_people_reference", name: LanguageModule.text("txt_reference"), type: -2, default: "", require: false},
                    {localid: "type_people_start_date", name: LanguageModule.text("txt_start_date"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_people_official_date", name: LanguageModule.text("txt_official_date"), type: -4, default: ["custom", null], require: false},
                    {localid: "type_people_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 180, name: LanguageModule.text("txt_training_participant"), type: "training_participant", type2: "structure",
            content: {
                details: [
                    {localid: "type_training_program_participant", name: LanguageModule.text("txt_training_participant"), type: -47, require: true}
                ]
            }
        },
        {
            id: - 181, name: LanguageModule.text("txt_calculated_on_salary_decision"), type: "enum",
            content: {
                typeof: -1,
                details: [
                    {value: "week", localid: "week", text: LanguageModule.text("txt_week")},
                    {value: "month", localid: "month", text: LanguageModule.text("txt_month")},
                    {value: "year", localid: "year", text: LanguageModule.text("txt_year")}
                ]
            }
        },
        {
            id: -182, name: LanguageModule.text("txt_request_advance_payment"), type: "request_advance_payment", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_request_advance_payment_employeeid", name: LanguageModule.text("txt_employee"), type: -47, require: true},
                    {localid: "type_request_advance_payment_policyid", name: LanguageModule.text("txt_policy"), type: -147, require: true, default: 0},
                    {localid: "type_request_advance_payment_time_hours_needed_for_approval", name: LanguageModule.text("txt_time_hours_needed_for_approval"), type: -3, require: false},
                    {localid: "type_request_advance_payment_date", name: LanguageModule.text("txt_date"), type: -4, require: true, default: ["today", ""]},
                    {localid: "type_request_advance_payment_amount", name: LanguageModule.text("txt_amount"), type: -118, require: true, default: 0},
                    {localid: "type_request_advance_payment_reason", name: LanguageModule.text("txt_reason"), type: -2, require: false, default: ""},
                    {localid: "type_request_advance_payment_attachments", name: LanguageModule.text("txt_attachments"), type: -64, require: false, default: []},
                    {localid: "type_request_advance_payment_approvers", name: LanguageModule.text("txt_approvers"), type: -1, require: false}
                ]
            }
        },
        {
            id: -183, name: LanguageModule.text("txt_examination_session"), type: "examination_session", type2: "structure",
            content: {
                details: [
                    {localid: "type_examination_session_name", name: LanguageModule.text("txt_name"), type: -1, require: true, default: ""},
                    {localid: "type_examination_session_status", name: LanguageModule.text("txt_status"), type: -184, require: true},
                    {localid: "type_examination_session_stime", name: LanguageModule.text("txt_start_time"), type: -5, require: true, default: ["today", ""]},
                    {localid: "type_examination_session_content", name: LanguageModule.text("txt_content"), type: -2, require: true, default: ""},
                    {localid: "type_examination_session_available", name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 184, name: LanguageModule.text("txt_examination_session_status"), type: "examination_session_status", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_examination_session_status_plan", text: LanguageModule.text("txt_plan")},
                    {value: 2, localid: "type_examination_session_status_processing", text: LanguageModule.text("txt_processing")},
                    {value: 3, localid: "type_examination_session_status_evaluating", text: LanguageModule.text("txt_evaluating")},
                    {value: 4, localid: "type_examination_session_status_finished", text: LanguageModule.text("txt_finished")},
                    {value: 5, localid: "type_examination_session_status_canceled", text: LanguageModule.text("txt_canceled")},
                    {value: 6, localid: "type_examination_session_status_pause", text: LanguageModule.text("txt_pause")}
                ]
            }
        },
        {
            id: - 185, name: LanguageModule.text("txt_examination_participant_status"), type: "examination_participant_status", type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "type_examination_participant_status_plan", text: LanguageModule.text("txt_plan")},
                    {value: 2, localid: "type_examination_participant_status_evaluating", text: LanguageModule.text("txt_evaluating")},
                    {value: 3, localid: "type_examination_participant_status_finished", text: LanguageModule.text("txt_finished")},
                    {value: 4, localid: "type_examination_participant_status_do_not_participate", text: LanguageModule.text("txt_do_not_participate")}
                ]
            }
        },
        {
            id: - 186, name: LanguageModule.text("txt_examination_participant"), type: "examination_participant", type2: "structure",
            content: {
                details: [
                    {localid: "type_examination_session_participant", name: LanguageModule.text("txt_examination_participant"), type: -47, require: true}
                ]
            }
        },
        {
            id: - 187, name: LanguageModule.text("txt_examination_lecturer"), type: "examination_lecturer", type2: "structure",
            content: {
                details: [
                    {
                        localid: "type_examination_session_lecturer", name: LanguageModule.text("txt_examination_lecturer_source"), type: "union", typeOfUnion: -61, require: true,
                        detailUnion: {
                            type_internal_training: [{localid: 'type_examination_session_internal_trainer', name: LanguageModule.text("txt_lecturer"), type: -47, require: true}],
                            type_outsource: [
                                {localid: 'type_examination_session_outsource_trainer', name: LanguageModule.text("txt_lecturer"), type: -179, default: '', require: true}
                            ]
                        }
                    }
                ]
            }
        },
        {
            id: -188, name: LanguageModule.text("txt_request_leave"), type: "request_leave", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_request_leave_employeeid", name: LanguageModule.text("txt_employee"), type: -47, require: true},
                    {localid: "type_request_leave_policyid", name: LanguageModule.text("txt_policy"), type: -142, require: true, default: 0},
                    {localid: "type_request_leave_remain_day_off", name: LanguageModule.text("txt_remain_day_off"), type: -3},
                    {localid: "type_request_leave_days_off", name: LanguageModule.text("txt_days_off"), type: -194, require: false},
                    {localid: "type_request_leave_number_of_day_off", name: LanguageModule.text("txt_number_of_day_off"), type: -3, require: true, default: ["today", ""]},
                    {localid: "type_request_leave_reason", name: LanguageModule.text("txt_reason"), type: -2, require: false, default: ""},
                    {localid: "type_request_leave_substitute", name: LanguageModule.text("txt_substitute"), type: -47, require: false},
                    {localid: "type_request_leave_approvers", name: LanguageModule.text("txt_approvers"), type: -1, require: false}
                ]
            }
        },
        {id: -189, name: LanguageModule.text("txt_select_department_employee"), type: "select_department_employee"},
        {
            id: -190, name: LanguageModule.text("txt_shift_schedule"), type: "shift_schedule", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_shift_schedule_date_from", name: LanguageModule.text("txt_date_from"), type: -4, require: true, default: ["today", ""]},
                    {localid: "type_shift_schedule_date_to", name: LanguageModule.text("txt_date_to"), type: -4, require: true, default: ["today", ""]},
                    {localid: "type_shift_schedule_shift", name: LanguageModule.text("txt_shift"), type: -137, require: true},
                    {localid: "type_shift_schedule_department_employee", name: LanguageModule.text("txt_department_employee"), type: -189, require: true}
                ]
            }
        },
        {
            id: - 191, name: LanguageModule.text("txt_punishment_list"), type: "punishment_list", type2: "structure",
            content: {
                details: [
                    {localid: 'type_punishment_list_cycleid', name: LanguageModule.text("txt_payroll_cycle"), type: -266, default: 0, require: true},
                    {localid: 'type_punishment_list_payroll_date_month', name: LanguageModule.text("txt_payroll_date"), type: -267, require: false},
                    {localid: 'type_punishment_list_payroll_date_week', name: LanguageModule.text("txt_payroll_date"), type: -268, require: false},
                    {localid: 'type_punishment_list_name', name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: 'type_punishment_list_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: true},
                    {localid: 'type_punishment_list_reference_date', name: LanguageModule.text("txt_reference_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_punishment_list_policyid', name: LanguageModule.text("txt_policy"), type: -146, default: 0, require: true}
                ]
            }
        },
        {
            id: -192, name: LanguageModule.text("txt_day_portion_leave"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "full_day", text: LanguageModule.text("txt_full_day")},
                    {value: 2, localid: "first_half_shift_day", text: LanguageModule.text("txt_first_half_shift_day")},
                    {value: 3, localid: "second_half_shift_day", text: LanguageModule.text("txt_second_half_shift_day")}
                ]
            }
        },
        {
            id: -193, name: LanguageModule.text("txt_day_off_lines"), type: "day_off_lines", type2: "structure",
            content: {
                details: [
                    {localid: 'type_day_off_lines_date', name: LanguageModule.text("txt_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_day_off_lines_days_portion', name: LanguageModule.text("txt_day_portion"), type: -192, default: 0, require: true}
                ]
            }
        },
        {
            id: - 194, name: LanguageModule.text("txt_days_off"), type: "array", notPri: true,
            content: {
                typeof: -193
            }
        },
        {
            id: - 195, name: LanguageModule.text("txt_request_late_early_checkin"), type: "request_late_early_checkin", type2: "structure",
            content: {
                details: [
                    {localid: 'type_request_late_early_checkin_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_request_late_early_checkin_policyid', name: LanguageModule.text("txt_policy"), type: -148, default: 0, require: true},
                    {localid: 'type_request_late_early_checkin_late', name: LanguageModule.text("txt_late_checkin_minute"), type: -3, default: 0, require: true},
                    {localid: 'type_request_late_early_checkin_early', name: LanguageModule.text("txt_early_checkout_minute"), type: -3, default: 0, require: false},
                    {localid: 'type_request_late_early_checkin_from', name: LanguageModule.text("txt_date_from"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_request_late_early_checkin_to', name: LanguageModule.text("txt_date_to"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_request_late_early_checkin_reason', name: LanguageModule.text("txt_reason"), type: -2, default: "", require: false},
                    {localid: 'type_request_late_early_checkin_approvers', name: LanguageModule.text("txt_approvers"), type: -1, default: "", require: false}
                ]
            }
        },
        {
            id: - 196, name: LanguageModule.text("txt_allowance_list"), type: "allowance_list", type2: "structure",
            content: {
                details: [
                    {localid: 'type_allowance_list_cycleid', name: LanguageModule.text("txt_payroll_cycle"), type: -266, default: 0, require: true},
                    {localid: 'type_allowance_list_payroll_date_month', name: LanguageModule.text("txt_payroll_date"), type: -267, require: false},
                    {localid: 'type_allowance_list_payroll_date_week', name: LanguageModule.text("txt_payroll_date"), type: -268, require: false},
                    {localid: 'type_allowance_list_name', name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: 'type_allowance_list_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: true},
                    {localid: 'type_allowance_list_reference_date', name: LanguageModule.text("txt_reference_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_allowance_list_policyid', name: LanguageModule.text("txt_policy"), type: -144, default: 0, require: true}
                ]
            }
        },
        {
            id: - 197, name: LanguageModule.text("txt_benefit_list"), type: "benefit_list", type2: "structure",
            content: {
                details: [
                    {localid: 'type_benefit_list_cycleid', name: LanguageModule.text("txt_payroll_cycle"), type: -266, default: 0, require: true},
                    {localid: 'type_benefit_list_payroll_date_month', name: LanguageModule.text("txt_payroll_date"), type: -267, require: false},
                    {localid: 'type_benefit_list_payroll_date_week', name: LanguageModule.text("txt_payroll_date"), type: -268, require: false},
                    {localid: 'type_benefit_list_name', name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: 'type_benefit_list_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: true},
                    {localid: 'type_benefit_list_reference_date', name: LanguageModule.text("txt_reference_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_benefit_list_policyid', name: LanguageModule.text("txt_policy"), type: -143, default: 0, require: true}
                ]
            }
        },
        {
            id: - 198, name: LanguageModule.text("txt_other_liability_list"), type: "other_liability_list", type2: "structure",
            content: {
                details: [
                    {localid: 'type_other_liability_list_cycleid', name: LanguageModule.text("txt_payroll_cycle"), type: -266, default: 0, require: true},
                    {localid: 'type_other_liability_list_payroll_date_month', name: LanguageModule.text("txt_payroll_date"), type: -267, require: false},
                    {localid: 'type_other_liability_list_payroll_date_week', name: LanguageModule.text("txt_payroll_date"), type: -268, require: false},
                    {localid: 'type_other_liability_list_name', name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: 'type_other_liability_list_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: true},
                    {localid: 'type_other_liability_list_reference_date', name: LanguageModule.text("txt_reference_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_other_liability_list_policyid', name: LanguageModule.text("txt_policy"), type: -150, default: 0, require: true}
                ]
            }
        },
        {
            id: - 199, name: LanguageModule.text("txt_other_liability_type"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "actual_expenses", text: LanguageModule.text("txt_actual_expenses")},
                    {value: 2, localid: "actual_expenses_with_limit", text: LanguageModule.text("txt_actual_expenses_with_limit")},
                    {value: 3, localid: "fixed_amount", text: LanguageModule.text("txt_fixed_amount")}
                ]
            }
        },
        {
            id: - 200, name: LanguageModule.text("txt_salary_adjustment_list"), type: "salary_adjustment_list", type2: "structure",
            content: {
                details: [
                    {localid: 'type_salary_adjustment_list_cycleid', name: LanguageModule.text("txt_payroll_cycle"), type: -266, default: 0, require: true},
                    {localid: 'type_salary_adjustment_list_payroll_date_month', name: LanguageModule.text("txt_payroll_date"), type: -267, require: false},
                    {localid: 'type_salary_adjustment_list_payroll_date_week', name: LanguageModule.text("txt_payroll_date"), type: -268, require: false},
                    {localid: 'type_salary_adjustment_list_name', name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: 'type_salary_adjustment_list_reference_number', name: LanguageModule.text("txt_reference_number"), type: -1, default: "", require: true},
                    {localid: 'type_salary_adjustment_list_reference_date', name: LanguageModule.text("txt_reference_date"), type: -4, default: ["today", ""], require: true}
                ]
            }
        },
        {
            id: - 201, name: LanguageModule.text("txt_date_month"), type: "datemonth"
        },
        {
            id: - 202, name: LanguageModule.text("txt_asset_category"), type: "asset_category", type2: "structure",
            content: {
                details: [
                    {localid: 'type_asset_category_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_asset_category_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_asset_category_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -203, name: "Chọn nhóm tài sản", type: 'member_of_asset_category'},
        {
            id: - 204, name: LanguageModule.text("txt_instruments_and_tools_category"), type: "instruments_and_tools_category", type2: "structure",
            content: {
                details: [
                    {localid: 'type_instruments_and_tools_category_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_instruments_and_tools_category_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_instruments_and_tools_category_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -205, name: "Chọn nhóm nhóm công cụ dụng cụ", type: 'member_of_instruments_and_tools_category'},
        {
            id: - 206, name: LanguageModule.text("txt_projects"), type: "projects", type2: "structure",
            content: {
                details: [
                    {localid: 'type_projects_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_projects_geoid', name: LanguageModule.text("txt_geographical_position"), type: -23, default: '', require: true},
                    {localid: 'type_projects_timestart', name: LanguageModule.text("txt_time_start"), type: -4, default: null, require: true},
                    {localid: 'type_projects_timeend', name: LanguageModule.text("txt_time_end"), type: -4, default: null, require: true},
                    {localid: 'type_projects_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_projects_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: - 207, name: LanguageModule.text("txt_nation_city"), type: "nation_city"},
        {id: - 208, name: LanguageModule.text("txt_choose_project"), type: "member_of_projects"},
        {
            id: - 209, name: LanguageModule.text("txt_project_applied_to_employee"), type: "project_applied_to_employee", type2: "structure",
            content: {
                details: [
                    {localid: 'type_project_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_project_applied_to_employee_projectid', name: LanguageModule.text("txt_projects"), type: -208, default: 0, require: true},
                    {localid: 'type_project_applied_to_employee_timestart', name: LanguageModule.text("txt_effective_date"), type: -4, default: ["today", ""], require: true},
                    {localid: 'type_project_applied_to_employee_timeend', name: LanguageModule.text("txt_attachments"), type: -4, default: ["today", ""], require: false},
                    {localid: 'type_project_applied_to_employee_available', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -210, name: LanguageModule.text("txt_select_locations"), type: "members_of_locations"},
        {
            id: - 211, name: LanguageModule.text("txt_document_type"), type: "document_types", type2: "structure",
            content: {
                details: [
                    {localid: 'type_document_type_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_document_type_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_document_type_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: -212, name: LanguageModule.text("txt_select_document_type"), type: 'member_of_document_types'},
        {
            id: - 213, name: LanguageModule.text("txt_document_group"), type: "document_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_document_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_document_group_parentid', name: LanguageModule.text("txt_parent_group"), type: -214, default: 0, require: false},
                    {localid: 'type_document_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_document_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: - 214, name: LanguageModule.text("txt_select_document_group"), type: 'member_of_document_groups'},
        {id: - 215, name: LanguageModule.text("txt_select_company"), type: 'member_of_orgs'},
        {
            id: - 216, name: LanguageModule.text("txt_document_template"), type: "document_templates", type2: "structure",
            content: {
                details: [
                    {localid: 'type_document_template_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_document_template_tag', name: LanguageModule.text("txt_tag"), type: -1, default: "", require: false},
                    {localid: 'type_document_template_summary_content', name: LanguageModule.text("txt_summary_content"), type: -2, default: "", require: false},
                    {localid: 'type_document_template_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false},
                    {localid: 'type_document_template_detail_content', name: LanguageModule.text("txt_detail_content"), type: -218, default: "", require: false}
                ]
            }
        },
        {id: - 217, name: LanguageModule.text("txt_select_folder"), type: 'member_of_document_folders'},
        {id: - 218, name: LanguageModule.text("txt_html"), type: 'html'},
        {
            id: - 219, name: LanguageModule.text("txt_documents"), type: "documents", type2: "structure",
            content: {
                details: [
                    {localid: 'type_document_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_document_number', name: "Số", type: -1, default: '', require: true},
                    {localid: 'type_document_issued_date', name: LanguageModule.text("txt_issued_date"), type: -4, default: ["custom", null], require: true},
                    {localid: 'type_document_effective_date', name: LanguageModule.text("txt_effective_date"), type: -4, default: ["custom", null], require: false},
                    {localid: 'type_document_expired_date', name: LanguageModule.text("txt_expired_date"), type: -4, default: ["custom", null], require: false},
                    {localid: 'type_document_tag', name: LanguageModule.text("txt_tag"), type: -1, default: "", require: false},
                    {localid: 'type_document_summary_content', name: LanguageModule.text("txt_summary_content"), type: -2, default: "", require: true},
                    {localid: 'type_document_attachments', name: LanguageModule.text("txt_attachments"), type: -64, default: [], require: false},
                    {localid: 'type_document_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false},
                    {localid: 'type_document_detail_content', name: LanguageModule.text("txt_detail_content"), type: -218, default: "", require: false}
                ]
            }
        },
        {id: - 220, name: LanguageModule.text("txt_variable_input"), type: 'variable_input'},
        {id: - 221, name: LanguageModule.text("txt_variable_textarea"), type: 'variable_textarea'},
        {
            id: - 222, name: LanguageModule.text("txt_template_groups"), type: "template_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_template_groups_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    // {localid: 'type_template_groups_typeid', name: LanguageModule.text("txt_datatypes"), type: -3, default: '', require: true},
                    {localid: 'type_template_groups_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_template_groups_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {id: - 223, name: LanguageModule.text("txt_select_template_groups"), type: 'member_of_template_groups'},
        {
            id: - 224, name: LanguageModule.text("txt_task_template"), type: "task_templates", type2: "structure",
            content: {
                details: [
                    {localid: 'type_task_template_name', name: LanguageModule.text("txt_template_name"), type: -1, default: '', require: true},
                    {localid: 'type_task_template_groupid', name: LanguageModule.text("txt_template_groups"), type: -223, default: '', require: true, disabled: true},
                    {localid: 'type_task_template_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_task_template_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false},
                    {localid: "type_task_template_task_name", name: LanguageModule.text("txt_task_name"), type: -220, require: true, default: ""},
                    {localid: "type_task_template_task_status", name: LanguageModule.text("txt_completed"), type: -6, default: false},
                    {localid: "type_task_template_task_expire_time", name: LanguageModule.text("txt_expire_time"), type: -220, default: ""},
                    {localid: "type_task_template_task_reminder", name: LanguageModule.text("txt_reminder"), type: -43, default: 'type_reminder_none'},
                    {localid: "type_task_template_task_assign_to", name: LanguageModule.text("txt_assign_to"), type: -220, default: ""},
                    {localid: "type_task_template_task_participant", name: LanguageModule.text("txt_participant"), type: -220, default: ""},
                    {localid: "type_task_template_task_result", name: LanguageModule.text("txt_result"), type: -221, default: ""}
                ]
            }
        },
        {
            id: - 225, name: LanguageModule.text("txt_meeting_template"), type: "meeting_templates", type2: "structure",
            content: {
                details: [
                    {localid: 'type_meeting_template_name', name: LanguageModule.text("txt_template_name"), type: -1, default: '', require: true},
                    {localid: 'type_meeting_template_groupid', name: LanguageModule.text("txt_template_groups"), type: -223, default: '', require: true, disabled: true},
                    {localid: 'type_meeting_template_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_meeting_template_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false},
                    {localid: "type_meeting_template_meeting_name", name: LanguageModule.text("txt_meeting_name"), type: -220, require: true, default: ""},
                    {localid: "type_meeting_template_meeting_type", name: LanguageModule.text("txt_type"), type: -44, default: 'type_visit'},
                    {localid: "type_meeting_template_meeting_location", name: LanguageModule.text("txt_meeting_location"), type: -220, require: true, default: ""},
                    {localid: "type_meeting_template_meeting_status", name: LanguageModule.text("txt_completed"), type: -6, default: false},
                    {localid: "type_meeting_template_meeting_start_time", name: LanguageModule.text("txt_start"), type: -220, default: ""},
                    {localid: "type_meeting_template_meeting_end_time", name: LanguageModule.text("txt_end"), type: -220, default: ""},
                    {localid: "type_meeting_template_meeting_all_day", name: LanguageModule.text("txt_all_day"), type: -6, default: false},
                    {localid: "type_meeting_template_meeting_reminder", name: LanguageModule.text("txt_reminder"), type: -43, default: 'type_reminder_none'},
                    {localid: "type_meeting_template_meeting_assign_to", name: LanguageModule.text("txt_assign_to"), type: -220, default: ""},
                    {localid: "type_meeting_template_meeting_participant", name: LanguageModule.text("txt_participant"), type: -220, default: ""},
                    {localid: "type_meeting_template_meeting_result", name: LanguageModule.text("txt_result"), type: -221, default: ""}
                ]
            }
        },
        {
            id: - 226, name: LanguageModule.text("txt_email_template"), type: "email_templates", type2: "structure",
            content: {
                details: [
                    {localid: 'type_email_template_name', name: LanguageModule.text("txt_template_name"), type: -1, default: '', require: true},
                    {localid: 'type_email_template_groupid', name: LanguageModule.text("txt_template_groups"), type: -223, default: '', require: true, disabled: true},
                    {localid: 'type_email_template_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_email_template_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false},
                    {localid: "type_email_template_receiver", name: LanguageModule.text("txt_receiver"), type: -220, require: true, default: ""},
                    {localid: "type_email_template_carbon_copy", name: LanguageModule.text("txt_carbon_copy"), type: -220, default: ""},
                    {localid: "type_email_template_blind_carbon_copy", name: LanguageModule.text("txt_blind_carbon_copy"), type: -220, default: ""},
                    {localid: "type_email_template_subject", name: LanguageModule.text("txt_subject"), type: -1, default: ""},
                    {localid: "type_email_template_content", name: LanguageModule.text("txt_content"), type: -221, default: ""}
                ]
            }
        },
        {
            id: - 227, name: LanguageModule.text("txt_onboarding"), type: "onboarding", type2: "structure",
            content: {
                details: [
                    {localid: 'type_onboarding_employee_id', name: LanguageModule.text("txt_employee_name"), type: -47, default: '', require: true},
                    {localid: 'type_onboarding_employee_code', name: LanguageModule.text("txt_employee_code"), type: -1, default: '', require: true, disabled: true},
                    {localid: 'type_onboarding_status', name: LanguageModule.text("txt_status"), type: -284, default: 'onboarding_onloading', require: true},
                    {localid: 'type_onboarding_employee_start_date', name: LanguageModule.text("txt_probation_start_date"), type: -4, default: ["custom", null], disabled: true},
                    {localid: 'type_onboarding_employee_official_date', name: LanguageModule.text("txt_official_start_date_of_work"), type: -4, default: ["custom", null], disabled: true},
                    {localid: 'type_onboarding_welcome_templateid', name: LanguageModule.text("txt_welcome_template"), type: -235, require: true},
                    {localid: 'type_onboarding_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_onboarding_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: true}
                ]
            }
        },
        {
            id: - 228, name: LanguageModule.text("txt_offboarding"), type: "offboarding", type2: "structure",
            content: {
                details: [
                    {localid: 'type_offboarding_employee_id', name: LanguageModule.text("txt_employee_name"), type: -47, default: '', require: true},
                    {localid: 'type_offboarding_status', name: LanguageModule.text("txt_status"), type: -285, default: 'offboarding_proposal', require: true},
                    {localid: 'type_offboarding_employee_code', name: LanguageModule.text("txt_employee_code"), type: -1, default: '', disabled: true},
                    {localid: 'type_offboarding_user', name: LanguageModule.text("txt_user"), type: -8, disabled: true},
                    {localid: 'type_offboarding_direct_manager', name: LanguageModule.text("txt_direct_manager"), type: -47, default: ["custom", null], disabled: true},
                    {localid: 'type_offboarding_indirect_manager', name: LanguageModule.text("txt_indirect_manager"), type: -47, disabled: true},
                    {localid: 'type_offboarding_hr_support_employee', name: LanguageModule.text("txt_hr_support_employee"), type: -47, disabled: true},
                    {localid: 'type_offboarding_application_recipients', name: LanguageModule.text("txt_application_recipients"), type: -48, require: true},
                    {localid: 'type_offboarding_expected_day_off', name: LanguageModule.text("txt_expected_day_off"), type: -4, require: true},
                    {localid: 'type_offboarding_handover_recipients', name: LanguageModule.text("txt_handover_recipients"), type: -48, require: true},
                    {localid: 'type_offboarding_resignation_letter', name: LanguageModule.text("txt_resignation_letter"), type: -218, default: '', require: false},
                    {localid: 'type_offboarding_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: true}
                ]
            }
        },
        {
            id: - 229, name: LanguageModule.text("txt_geographical_position"), type: "geographical_positions", type2: "structure",
            content: {
                details: [
                    {localid: 'type_geographical_position_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_geographical_position_location', name: LanguageModule.text("txt_location"), type: -12, default: '', require: true},
                    {localid: 'type_geographical_position_nation_city', name: LanguageModule.text("txt_nationcity"), type: -207, default: '', require: true},
                    {localid: 'type_geographical_position_address', name: LanguageModule.text("txt_address"), type: -1, default: '', require: false},
                    {localid: 'type_geographical_position_phone', name: LanguageModule.text("txt_phone"), type: -10, default: '', require: false},
                    {localid: 'type_geographical_position_post_code', name: LanguageModule.text("txt_postal_code"), type: -1, default: '', require: false},
                    {localid: 'type_geographical_position_comment', name: LanguageModule.text("txt_note"), type: -2, default: '', require: false},
                    {localid: 'type_geographical_position_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: -230, name: LanguageModule.text("txt_instruments_and_tools_handover_lines"), type: "instruments_and_tools_handover_lines", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_instruments_and_tools_handover_lines_assetid", name: LanguageModule.text("txt_instruments_and_tools"), type: -233, default: "", require: true},
                    {localid: "type_instruments_and_tools_handover_lines_unit", name: LanguageModule.text("txt_unit"), type: -1, default: "", require: true, readOnly: true},
                    {localid: "type_instruments_and_tools_handover_lines_inventory", name: LanguageModule.text("txt_inventory"), type: -3, default: "", require: true, readOnly: true},
                    {localid: "type_instruments_and_tools_handover_lines_amount", name: LanguageModule.text("txt_quantity"), type: -3, default: "", require: true},
                    {localid: "type_instruments_and_tools_handover_lines_comment", name: LanguageModule.text("txt_note"), type: -2, default: "", require: false}
                ]
            }
        },
        {
            id: - 231, name: LanguageModule.text("txt_instruments_and_tools_handover_lines_array"), type: "array", notPri: true,
            content: {
                typeof: -230
            }
        },
        {
            id: -232, name: LanguageModule.text("txt_instruments_and_tools_handover"), type: "instruments_and_tools_handover", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_instruments_and_tools_handover_date", name: LanguageModule.text("txt_handover_date"), type: -4, default: ["today", ""], require: true},
                    {localid: "type_instruments_and_tools_handover_receiver", name: LanguageModule.text("txt_receiver"), type: -47, default: 0, require: true},
                    {localid: "type_instruments_and_tools_handover_warehouseid", name: LanguageModule.text("txt_warehouse"), type: -70, default: 0, require: true},
                    {localid: "type_instruments_and_tools_handover_comment", name: LanguageModule.text("txt_note"), type: -2, default: "", require: false},
                    {localid: "type_instruments_and_tools_handover_attachments", name: LanguageModule.text("txt_attachments"), type: -64},
                    {localid: "type_instruments_and_tools_handover_details", name: LanguageModule.text("txt_details"), type: -231}
                ]
            }
        },
        {id: -233, name: "Chọn công cụ dụng cụ", type: 'member_of_instruments_and_tools'},
        {
            id: - 234, name: LanguageModule.text("txt_document_property"), type: "document_properties", type2: "structure",
            content: {
                details: [
                    {localid: 'type_document_property_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_document_property_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_document_property_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 1234, name: "test image", type: "test_image", type2: "structure",
            content: {
                details: [
                    {localid: 'test_image', name: LanguageModule.text("txt_image_file"), type: -32, require: false}
                ]
            }
        },
        {id: -235, name: LanguageModule.text("txt_select_welcome_template"), type: 'member_of_welcome_templates'},
        {
            id: - 236, name: LanguageModule.text("txt_offboarding_type"), type: "offboarding_types", type2: "structure",
            content: {
                details: [
                    {localid: 'type_offboarding_type_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_offboarding_type_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 237, name: LanguageModule.text("txt_offboarding_reason"), type: "offboarding_reasons", type2: "structure",
            content: {
                details: [
                    {localid: 'type_offboarding_reason_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_offboarding_reason_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 238, name: LanguageModule.text("txt_social_network_array"), type: "array", notPri: true,
            content: {
                typeof: -153
            }
        },
        {
            id: - 239, name: LanguageModule.text("txt_partner_class"), type: "partner_class", type2: "structure",
            content: {
                details: [
                    {localid: 'type_partner_class_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_partner_class_color', name: LanguageModule.text("txt_color"), type: -261, default: "white", require: true},
                    {localid: 'type_partner_class_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_partner_class_type_extra', name: LanguageModule.text("txt_type_extra"), type: -252, default: 0, require: false},
                    {localid: 'type_partner_class_input_form_extra', name: LanguageModule.text("txt_input_form_extra"), type: -253, default: 0, require: false},
                    {localid: 'type_partner_class_output_form_extra', name: LanguageModule.text("txt_output_form_extra"), type: -254, default: 0, require: false},
                    {localid: 'type_partner_class_mobile_input_form_extra', name: LanguageModule.text("txt_mobile_input_form_extra"), type: -258, default: 0, require: false},
                    {localid: 'type_partner_class_mobile_output_form_extra', name: LanguageModule.text("txt_mobile_output_form_extra"), type: -259, default: 0, require: false},
                    {localid: 'type_partner_class_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 240, name: LanguageModule.text("txt_select_partner_class"), type: "member_of_partner_class"
        },
        {
            id: - 241, name: LanguageModule.text("txt_partner"), type: "partner", type2: "structure",
            content: {
                details: [
                    {localid: 'type_partner_fullname', name: LanguageModule.text("txt_partner_fullname"), type: -1, default: '', require: true},
                    {localid: 'type_partner_name', name: LanguageModule.text("txt_shortname"), type: -1, default: '', require: true},
                    {localid: 'type_partner_class', name: LanguageModule.text("txt_partner_class"), type: -256, require: true},
                    {localid: 'type_partner_address', name: LanguageModule.text("txt_address"), type: -1, default: '', require: false},
                    {localid: 'type_partner_nation_city', name: LanguageModule.text("txt_nationcity"), type: -207, require: false},
                    {localid: 'type_partner_phone', name: LanguageModule.text("txt_phone"), type: -10, default: '', require: false},
                    {localid: 'type_partner_email', name: LanguageModule.text("txt_email"), type: -7, default: '', require: false},
                    {localid: 'type_partner_website', name: LanguageModule.text("txt_website"), type: -11, default: '', require: false},
                    {localid: 'type_partner_fax', name: LanguageModule.text("txt_fax"), type: -1, default: '', require: false},
                    {localid: 'type_partner_taxcode', name: LanguageModule.text("txt_taxcode"), type: -1, default: '', require: false},
                    {localid: 'type_partner_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_partner_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false},
                    {localid: 'type_partner_gps', name: LanguageModule.text("txt_gps"), type: -12, default: '', require: false}
                ]
            }
        },
        {
            id: - 242, name: LanguageModule.text("txt_select_partner"), type: "member_of_partner"
        },
        {
            id: - 243, name: LanguageModule.text("txt_contact"), type: "contact", type2: "structure",
            content: {
                details: [
                    {localid: 'type_contact_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_contact_position', name: LanguageModule.text("txt_position"), type: -1, default: "", require: false},
                    {localid: 'type_contact_department', name: LanguageModule.text("txt_department"), type: -1, default: '', require: false},
                    {localid: 'type_contact_partnerid', name: LanguageModule.text("txt_partner"), type: -242, require: false},
                    {localid: 'type_contact_phone_1', name: LanguageModule.text("txt_phone_1"), type: -10, default: '', require: false},
                    {localid: 'type_contact_phone_2', name: LanguageModule.text("txt_phone_2"), type: -10, default: '', require: false},
                    {localid: 'type_contact_email_1', name: LanguageModule.text("txt_email_1"), type: -7, default: '', require: false},
                    {localid: 'type_contact_email_2', name: LanguageModule.text("txt_email_2"), type: -7, default: '', require: false},
                    {localid: 'type_contact_owner', name: LanguageModule.text("txt_owner"), type: -47, default: 0, require: true},
                    {localid: 'type_contact_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 244, name: LanguageModule.text("txt_select_contact"), type: "member_of_contact"
        },
        {
            id: - 245, name: LanguageModule.text("txt_work_flow_group"), type: "work_flow_groups", type2: "structure",
            content: {
                details: [
                    {localid: 'type_work_flow_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_work_flow_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_work_flow_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 246, name: LanguageModule.text("txt_select_work_flow_group"), type: "member_of_work_flow_groups"
        },
        {
            id: - 247, name: LanguageModule.text("txt_work_flows"), type: "work_flows", type2: "structure",
            content: {
                details: [
                    {localid: 'type_work_flow_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_work_flow_groupid', name: LanguageModule.text("txt_group"), type: -246, default: 0, require: true},
                    {localid: 'type_work_flow_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_work_flow_type_extra_of_object', name: LanguageModule.text("txt_type_extra_of_object"), type: -252, default: 0, require: false},
                    {localid: 'type_work_flow_input_form_extra_of_object', name: LanguageModule.text("txt_input_form_extra_of_object"), type: -253, default: 0, require: false},
                    {localid: 'type_work_flow_output_form_extra_of_object', name: LanguageModule.text("txt_output_form_extra_of_object"), type: -254, default: 0, require: false},
                    {localid: 'type_work_flow_mobile_input_form_extra_of_object', name: LanguageModule.text("txt_mobile_input_form_extra_of_object"), type: -258, default: 0, require: false},
                    {localid: 'type_work_flow_mobile_output_form_extra_of_object', name: LanguageModule.text("txt_mobile_output_form_extra_of_object"), type: -259, default: 0, require: false},
                    {localid: 'type_work_flow_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 248, name: LanguageModule.text("txt_select_work_flow"), type: "member_of_work_flows"
        },
        {
            id: - 249, name: LanguageModule.text("txt_object"), type: "objects", type2: "structure",
            content: {
                details: [
                    {localid: 'type_object_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_object_work_flowid', name: LanguageModule.text("txt_work_flows"), type: -248, default: 0, require: true},
                    {localid: 'type_object_period', name: LanguageModule.text("txt_period"), type: -251, default: 0, require: true},
                    {localid: 'type_object_priority', name: LanguageModule.text("txt_priority"), type: -250, default: "medium", require: true},
                    {localid: 'type_object_attachments', name: LanguageModule.text("txt_attachments"), type: -64},
                    {localid: 'type_object_description', name: LanguageModule.text("txt_description"), type: -218, default: '', require: false}
                ]
            }
        },
        {
            id: - 250, name: LanguageModule.text("txt_object_priority"), type: "enum",
            content: {
                typeof: -3,
                details: [
                    {value: 1, localid: "high", text: LanguageModule.text("txt_high")},
                    {value: 2, localid: "medium", text: LanguageModule.text("txt_medium")},
                    {value: 3, localid: "low", text: LanguageModule.text("txt_low")}
                ]
            }
        },
        {
            id: - 251, name: LanguageModule.text("txt_object_period"), type: "enum", notExtend: true,
            content: {
                typeof: -3,
                details: [
                    {value: -1, localid: -1, text: LanguageModule.text("txt_success")},
                    {value: -2, localid: -2, text: LanguageModule.text("txt_failed")},
                    {value: -3, localid: -3, text: "Hủy thực hiện"}
                ]
            }
        },
        {
            id: -252, name: LanguageModule.text("txt_select_typelists"), type: "member_of_typelists"
        },
        {
            id: -253, name: "Chọn input form", type: "member_of_input_forms"
        },
        {
            id: -254, name: "Chọn output form", type: "member_of_output_forms"
        },
        {
            id: -255, name: LanguageModule.text("txt_select_object"), type: "member_of_objects"
        },
        {
            id: -256, name: "Chọn nhiều loại đối tác", type: "members_of_partner_class"
        },
        {id: -257, name: LanguageModule.text("txt_type_of_activity"), type: 'type_of_activity', type2: "enum",
            content: {
                typeof: -3,
                details: [
                    {localid: "type_task", text: LanguageModule.text("txt_task"), value: 1},
                    {localid: "type_meeting", text: LanguageModule.text("txt_meeting"), value: 2}
                ]
            }
        },
        {
            id: -258, name: "Chọn input form mobile", type: "member_of_mobile_input_forms"
        },
        {
            id: -259, name: "Chọn output form mobile", type: "member_of_mobile_output_forms"
        },
        {
            id: - 260, name: LanguageModule.text("txt_company"), type: "company", type2: "structure", isnotFieldofStructure: true,
            content: {
                details: [
                    {localid: "type_company_name", name: LanguageModule.text("txt_name"), type: -1, default: "", require: true},
                    {localid: "type_company_shortname", name: LanguageModule.text("txt_shortname"), type: -1, default: "", require: true},
                    {localid: "type_company_code", name: LanguageModule.text("txt_code"), type: -1, default: "", require: true},
                    {localid: "type_company_geopos", name: LanguageModule.text("txt_geographical_position"), type: -210, require: true}
                ]
            }
        },
        {
            id: -261, name: "Color picker", type: "color_picker"
        },
        // {
        //     id: -262, name: LanguageModule.text("txt_select_task"), type: "member_of_task"
        // },
        // {
        //     id: -263, name: LanguageModule.text("txt_select_meeting"), type: "member_of_meeting"
        // },
        {
            id: - 264, name: LanguageModule.text("txt_lesson_category"), type: "lesson_categories", type2: "structure",
            content: {
                details: [
                    {localid: 'type_lesson_category_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                    {localid: 'type_lesson_category_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                    {localid: 'type_lesson_category_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
                ]
            }
        },
        {
            id: - 265, name: "Chọn nhóm bài học", type: "member_of_lesson_categories"
        },
        {
            id: - 266, name: "Chọn chu kỳ tính lương", type: "member_of_payroll_cycle"
        },
        {
            id: - 267, name: LanguageModule.text("txt_month"), type: "month", stt: 5
        },
        {
            id: - 268, name: LanguageModule.text("txt_week"), type: "week", stt: 5
        },
        {
            id: - 269, name: LanguageModule.text("txt_bonus_list_details"), type: "bonus_list_details", type2: "structure",
            content: {
                details: [
                    {localid: 'type_bonus_list_details_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                    {localid: 'type_bonus_list_details_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, require: true},
                    {localid: 'type_bonus_list_details_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
                ]
            }
        },
        {
           id: -270, name: LanguageModule.text("txt_shift_worktime"), type: "shift_worktime", type2: "structure", isnotFieldofStructure: true,
           content: {
               details: [
                   {localid: "type_shift_working_time", name: LanguageModule.text("txt_working_time"), type: -136, require: true},
                   {localid: "type_shift_break_time", name: LanguageModule.text("txt_break_time"), type: -136, require: true},
                   {localid: "type_shift_night_work_time", name: LanguageModule.text("txt_night_work_time"), type: -136, require: true},
                   {localid: "type_shift_late_checkin_minutes", name: LanguageModule.text("txt_allow_late_check_in_minute"), type: -3, default: 0, require: false},
                   {localid: "type_shift_early_checkout_minutes", name: LanguageModule.text("txt_allow_early_check_out_minute"), type: -3, default: 0, require: false},
                   {localid: "type_shift_monday", name: LanguageModule.text("txt_monday"), type: -53, default: 4, require: true},
                   {localid: "type_shift_tuesday", name: LanguageModule.text("txt_tuesday"), type: -53, default: 4, require: true},
                   {localid: "type_shift_wednesday", name: LanguageModule.text("txt_wednesday"), type: -53, default: 4, require: true},
                   {localid: "type_shift_thursday", name: LanguageModule.text("txt_thursday"), type: -53, default: 4, require: true},
                   {localid: "type_shift_friday", name: LanguageModule.text("txt_friday"), type: -53, default: 4, require: true},
                   {localid: "type_shift_saturday", name: LanguageModule.text("txt_saturday"), type: -53, default: 4, require: true},
                   {localid: "type_shift_sunday", name: LanguageModule.text("txt_sunday"), type: -53, default: 4, require: true}
               ]
           }
       },
       {
           id: -271, name: LanguageModule.text("txt_shift_timekeeping"), type: "shift_timekeeping", type2: "structure", isnotFieldofStructure: true,
           content: {
               details: [
                   {localid: "type_shift_number_of_standard_working_hours", name: LanguageModule.text("txt_number_of_standard_working_hours"), type: -3, default: 8, require: false},
                   {localid: "type_shift_number_of_work_days", name: LanguageModule.text("txt_number_of_work_days"), type: -3, default: 0, require: false},
                   {localid: "type_shift_minimum_working_minutes_required_for_salary_calculation", name: LanguageModule.text("txt_minimum_working_minutes_required_for_salary_calculation"), type: -3, default: 0, require: false, decpre: 1},
                   {localid: "type_shift_round_to_one_days_wage", name: LanguageModule.text("txt_round_to_one_days_wage"), type: -3, default: 7.5, require: false, decpre: 1},
                   {localid: "type_shift_checkin_first_half_shift", name: LanguageModule.text("txt_checkin_first_half_shift"), type: -6, default: true, require: false},
                   {localid: "type_shift_time_for_checking_in_first_half_shift", name: LanguageModule.text("txt_time_for_checking_in_first_half_shift"), type: -136, require: false},
                   {localid: "type_shift_checkout_first_half_shift", name: LanguageModule.text("txt_checkout_first_half_shift"), type: -6, default: false, require: false},
                   {localid: "type_shift_time_for_checking_out_first_half_shift", name: LanguageModule.text("txt_time_for_checking_out_first_half_shift"), type: -136, require: false},
                   {localid: "type_shift_checkin_second_half_shift", name: LanguageModule.text("txt_checkin_second_half_shift"), type: -6, default: false, require: false},
                   {localid: "type_shift_time_for_checking_in_second_half_shift", name: LanguageModule.text("txt_time_for_checking_in_second_half_shift"), type: -136, require: false},
                   {localid: "type_shift_checkout_second_half_shift", name: LanguageModule.text("txt_checkout_second_half_shift"), type: -6, default: true, require: false},
                   {localid: "type_shift_time_for_checking_out_second_half_shift", name: LanguageModule.text("txt_time_for_checking_out_second_half_shift"), type: -136, require: false}
               ]
           }
       },
       {
           id: - 272, name: LanguageModule.text("txt_overtime_policy_group"), type: "overtime_policy_groups", type2: "structure",
           content: {
               details: [
                   {localid: 'type_overtime_policy_group_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                   {localid: 'type_overtime_policy_group_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                   {localid: 'type_overtime_policy_group_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
               ]
           }
       },
       {id: -273, name: LanguageModule.text("txt_select_overtime_policy_group"), type: 'member_of_overtime_policy_groups'},
       {
           id: - 274, name: LanguageModule.text("txt_overtime_policy"), type: "overtime_policies", type2: "structure",
           content: {
               details: [
                   {localid: 'type_overtime_policy_name', name: LanguageModule.text("txt_name"), type: -1, default: '', require: true},
                   {localid: 'type_overtime_policy_description', name: LanguageModule.text("txt_description"), type: -2, default: '', require: false},
                   {localid: 'type_overtime_policy_groupid', name: LanguageModule.text("txt_policy_group"), type: -127, default: 0, require: true},
                   {localid: 'type_overtime_policy_maximum_overtime_hours_per_day', name: LanguageModule.text("txt_maximum_overtime_hours_per_day"), type: -3, default: 0.0, require: false},
                   {localid: 'type_overtime_policy_maximum_overtime_hours_per_month', name: LanguageModule.text("txt_maximum_overtime_hours_per_month"), type: -3, default: 0.0, require: false},
                   {localid: 'type_overtime_policy_proposal_submitted_before', name: LanguageModule.text("txt_proposal_submitted_before_hour"), type: -3, default: "0.0"},
                   {localid: 'type_overtime_policy_active', name: LanguageModule.text("txt_active"), type: -6, default: true, require: false}
               ]
           }
       },
       {id: -275, name: LanguageModule.text("txt_select_overtime_policy"), type: 'member_of_overtime_policies'},
       {id: -276, name: LanguageModule.text("txt_type_of_overtime_request"), type: 'type_of_overtime_request', type2: "enum",
           content: {
               typeof: -1,
               details: [
                   {localid: "myself", text: LanguageModule.text("txt_request_for_myself"), value: "myself"},
                   {localid: "many_employees", text: LanguageModule.text("txt_request_for_many_employees"), value: "many_employees"}
               ]
           }
       },
       {
           id: - 277, name: LanguageModule.text("txt_overtime_request"), type: "overtime_request", type2: "structure",
           content: {
               details: [
                   {localid: 'type_overtime_request_type', name: LanguageModule.text("txt_request_type"), type: -276, default: 0, require: true},
                   {localid: 'type_overtime_request_policyid', name: LanguageModule.text("txt_policy"), type: -275, default: 0, require: true},
                   {localid: 'type_overtime_request_start', name: LanguageModule.text("txt_start"), type: -5, default: new Date(), require: true},
                   {localid: 'type_overtime_request_end', name: LanguageModule.text("txt_end"), type: -5, default: new Date(), require: true},
                   {localid: 'type_overtime_request_overtime_hours', name: LanguageModule.text("txt_overtime_hours"), type: -3, default: 0, require: false, decpre: 1},
                   {localid: 'type_overtime_request_reason', name: LanguageModule.text("txt_reason"), type: -2, default: ""},
                   {localid: 'type_overtime_request_requested_for', name: LanguageModule.text("txt_requested_for"), type: -48, default: [], require: true}
               ]
           }
       },
       {
           id: - 278, name: LanguageModule.text("txt_overtime_policies_applied_to_employee"), type: "overtime_policies_applied_to_employee", type2: "structure",
           content: {
               details: [
                   {localid: 'type_overtime_policies_applied_to_employee_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                   {localid: 'type_overtime_policies_applied_to_employee_policyid', name: LanguageModule.text("txt_policy"), type: -139, default: 0, require: true},
                   {localid: 'type_overtime_policies_applied_to_employee_description', name: LanguageModule.text("txt_description"), type: -2, default: "", require: false}
               ]
           }
       },
       {
           id: - 279, name: LanguageModule.text("txt_punishment_list_details"), type: "punishment_list_details", type2: "structure",
           content: {
               details: [
                   {localid: 'type_punishment_list_details_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                   {localid: 'type_punishment_list_details_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, require: true},
                   {localid: 'type_punishment_list_details_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
               ]
           }
       },
       {
           id: - 280, name: LanguageModule.text("txt_allowance_list_details"), type: "allowance_list_details", type2: "structure",
           content: {
               details: [
                   {localid: 'type_allowance_list_details_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                   {localid: 'type_allowance_list_details_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, require: true},
                   {localid: 'type_allowance_list_details_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
               ]
           }
       },
       {
           id: - 281, name: LanguageModule.text("txt_benefit_list_details"), type: "benefit_list_details", type2: "structure",
           content: {
               details: [
                   {localid: 'type_benefit_list_details_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                   {localid: 'type_benefit_list_details_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, require: true},
                   {localid: 'type_benefit_list_details_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
               ]
           }
       },
       {
           id: - 282, name: LanguageModule.text("txt_other_liability_list_details"), type: "other_liability_list_details", type2: "structure",
           content: {
               details: [
                   {localid: 'type_other_liability_list_details_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                   {localid: 'type_other_liability_list_details_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, require: true},
                   {localid: 'type_other_liability_list_details_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
               ]
           }
       },
       {
           id: - 283, name: LanguageModule.text("txt_salary_adjustment_list_details"), type: "salary_adjustment_list_details", type2: "structure",
           content: {
               details: [
                   {localid: 'type_salary_adjustment_list_details_employeeid', name: LanguageModule.text("txt_employee"), type: -47, default: 0, require: true},
                   {localid: 'type_salary_adjustment_list_details_amount', name: LanguageModule.text("txt_amount") + " ($)", type: -118, require: true},
                   {localid: 'type_salary_adjustment_list_details_tax_exempt', name: LanguageModule.text("txt_tax_exempt") + " ($)", type: -118, require: true},
                   {localid: 'type_salary_adjustment_list_details_insurance_exempt', name: LanguageModule.text("txt_insurance_exempt") + " ($)", type: -118, require: true},
                   {localid: 'type_salary_adjustment_list_details_comment', name: LanguageModule.text("txt_note"), type: -2, require: false}
               ]
           }
       },
       {
           id: - 284, name: LanguageModule.text("txt_onboarding_status"), type: "onboarding_status", type2: "enum",
           content: {
               typeof: -1,
               details: [
                   {localid: "onboarding_onloading", text: LanguageModule.text("txt_doing"), value: "onboarding_onloading"},
                   {localid: "onboarding_success", text: LanguageModule.text("txt_success"), value: "onboarding_success"}
               ]
           }
       },
       {
           id: - 285, name: LanguageModule.text("txt_offboarding_status"), type: "offboarding_status", type2: "enum",
           content: {
               typeof: -1,
               details: [
                   {localid: "offboarding_proposal", text: LanguageModule.text("txt_proposal"), value: "offboarding_proposal"},
                   {localid: "offboarding_approval", text: LanguageModule.text("txt_approval"), value: "offboarding_approval"},
                   {localid: "offboarding_evaluation", text: LanguageModule.text("txt_evaluation"), value: "offboarding_evaluation"},
                   {localid: "offboarding_finish", text: LanguageModule.text("txt_finish"), value: "offboarding_finish"}
               ]
           }
       },
       {
           id: - 286, name: "Chọn loại nghỉ việc", type: "member_of_offboarding_types"
       },
       {
           id: - 287, name: "Chọn lý do nghỉ việc", type: "member_of_offboarding_reasons"
       },
       {
           id: - 288, name: "Chọn lý do nghỉ việc", type: "multiselect_offboarding_reasons"
       },
       {
           id: - 289, name: LanguageModule.text("txt_leave_approval"), type: "approval_resignation", type2: "structure",
           content: {
               details: [
                   {localid: 'type_approval_resignation_approver', name: LanguageModule.text("txt_approver_quits_job"), type: -48, default: 0, require: true},
                   {localid: 'type_approval_resignation_the_last_working_day', name: LanguageModule.text("txt_the_last_working_day"), type: -4, require: true},
                   {localid: 'type_approval_resignation_interview', name: LanguageModule.text("txt_job_leave_interview"), type: -6, require: true, default: true},
                   {localid: 'type_approval_resignation_interviewer', name: LanguageModule.text("txt_interviewer_quits_job"), type: -48, require: false},
                   {localid: 'type_approval_resignation_interview_date', name: LanguageModule.text("txt_interview_date"), type: -4, require: false}
               ]
           }
       },
       {
           id: - 290, name: LanguageModule.text("txt_leave_review"), type: "leave_assessment", type2: "structure",
           content: {
               details: [
                   {localid: 'type_leave_assessment_type', name: LanguageModule.text("txt_offboarding_type"), type: -286, require: true},
                   {localid: 'type_leave_assessment_reason', name: LanguageModule.text("txt_offboarding_reason"), type: -288, require: true},
                   {localid: 'type_leave_assessment_comment', name: LanguageModule.text("txt_note"), type: -218, require: false},
               ]
           }
       },
       {
           id: - 291, name: "Đồ thị hiệu suất", type: "performance_chart"
       },
       {
           id: - 292, name: LanguageModule.text("txt_scorecard_report_line"), type: "scorecard_report_line", type2: "structure",
           content: {
               details: [
                   {localid: 'type_scorecard_report_line_name', name: LanguageModule.text("txt_name"), type: -1, require: false},
                   {localid: 'type_scorecard_report_line_measurement_unit', name: LanguageModule.text("txt_measurement_unit"), type: -1, require: false},
                   {localid: 'type_scorecard_report_line_weight', name: LanguageModule.text("txt_weight"), type: -1, require: false},
                   {localid: 'type_scorecard_report_line_goal', name: LanguageModule.text("txt_goal"), type: -3, require: false},
                   {localid: 'type_scorecard_report_line_low_threshold', name: LanguageModule.text("txt_low_threshold"), type: -3, require: false},
                   {localid: 'type_scorecard_report_line_high_threshold', name: LanguageModule.text("txt_high_threshold"), type: -3, require: false},
                   {localid: 'type_scorecard_report_line_result', name: LanguageModule.text("txt_result"), type: -3, require: false},
                   {localid: 'type_scorecard_report_line_performance', name: LanguageModule.text("txt_performance"), type: -1, require: false},
                   {localid: 'type_scorecard_report_line_chart', name: LanguageModule.text("txt_chart"), type: -291, require: false}
               ]
           }
       },
       {
           id: - 293, name: LanguageModule.text("txt_scorecard_report"), type: "scorecard_report", type2: "treetable", notPri: true,
           content: {
               typeof: -292
           }
       }
    ];
    for (var i = 0; i < typelists.length; i++){
        typelists[i].userid = systemconfig.userid;
        typelists[i].available = 1;
    }
    return typelists;
};

contentModule.datatypeAdvanced = ["array", "enum", "enum_multi", "structure", "extends_structure", "extends_enum", "extends_enum_multi", "treetable"];
contentModule.getDatatypeAdvancedList = function(){
    var typelists = [
        {id: -1000, name: LanguageModule.text("txt_enum"), type: "enum", stt: 7},
        {id: -1001, name: LanguageModule.text("txt_array"), type: "array", stt: 9},
        {id: -1001, name: "Treetable", type: "treetable", stt: 10},
        {id: -1002, name: LanguageModule.text("txt_structure"), type: "structure", stt: 10},
        {id: -1003, name: LanguageModule.text("txt_extends"), type: "extends", stt: 11},
        {id: -1004, name: LanguageModule.text("txt_enum_multi_select"), type: "enum_multi", stt: 8}
    ];
    for (var i = 0; i < typelists.length; i++){
        typelists[i].userid = systemconfig.userid;
        typelists[i].available = 1;
    }
    return typelists;
};

contentModule.dataTypeOfExtends = ["enum", "structure", "extends_structure", "extends_enum", "enum_multi", "extends_enum_multi"];

contentModule.getTypeName = function(type){
    if (type == "enum") return LanguageModule.text("txt_enum");
    if (type == "extends_enum" || type == "extends_structure" || type == "extends_enum_multi") return LanguageModule.text("txt_extends");
    var a = contentModule.getDatatypePrimitiveList();
    var b = contentModule.getDatatypeAdvancedList();
    var list = a.concat(b);
    for (var i = 0; i < list.length; i++){
        if (list[i].notPri) continue;
        if (list[i].type == type) return list[i].name;
    }
    return "-";
};
contentModule.getDescendantsId = function(host, item){
    if (item.descendanIdList !== undefined) return item.descendanIdList;
    item.descendanIdList = [];
    if (contentModule.datatypeAdvanced.indexOf(item.type) < 0) return item.descendanIdList;
    switch (item.type) {
        case "array":
        case "treetable":
            item.descendanIdList.push(item.content.typeof);
            var index = host.database.typelists.getIndex(item.content.typeof);
            if (index < 0) return item.descendanIdList;
            item.descendanIdList = item.descendanIdList.concat(contentModule.getDescendantsId(host, host.database.typelists.items[index]));
            break;
        case "enum":
        case "enum_multi":
            item.descendanIdList.push(item.content.typeof);
            var index = host.database.typelists.getIndex(item.content.typeof);
            if (index < 0) return item.descendanIdList;
            item.descendanIdList = item.descendanIdList.concat(contentModule.getDescendantsId(host, host.database.typelists.items[index]));
            break;
        case "structure":
            var index;
            for (var i = 0; i < item.content.details.length; i++){
                item.descendanIdList.push(item.content.details[i].type);
                index = host.database.typelists.getIndex(item.content.details[i].type);
                if (index < 0) continue;
                item.descendanIdList = item.descendanIdList.concat(contentModule.getDescendantsId(host, host.database.typelists.items[index]));
            }
            break;
        case "extends_enum":
        case "extends_enum_multi":
            item.descendanIdList.push(item.content.typeof);
            var index = host.database.typelists.getIndex(item.content.typeof);
            if (index < 0) return item.descendanIdList;
            item.descendanIdList = item.descendanIdList.concat(contentModule.getDescendantsId(host, host.database.typelists.items[index]));
            break;
        case "extends_structure":
            item.descendanIdList.push(item.content.typeof);
            var index = host.database.typelists.getIndex(item.content.typeof);
            if (index < 0) return item.descendanIdList;
            item.descendanIdList = item.descendanIdList.concat(contentModule.getDescendantsId(host, host.database.typelists.items[index]));
            for (var i = 0; i < item.content.details.length; i++){
                item.descendanIdList.push(item.content.details[i].type);
                index = host.database.typelists.getIndex(item.content.details[i].type);
                if (index < 0) continue;
                item.descendanIdList = item.descendanIdList.concat(contentModule.getDescendantsId(host, host.database.typelists.items[index]));
            }
            break;
        default:
            break;
    }
    return item.descendanIdList;
};

contentModule.makeDescendantsIdListDataType = function(host){
    for (var i = 0; i < host.database.typelists.items.length; i++){
        contentModule.getDescendantsId(host, host.database.typelists.items[i]);
    }
};

contentModule.makeDataTypeDecode = function(item){
    if (item.extrainfo && item.extrainfo != ""){
        if (EncodingClass.type.isString(item.extrainfo)){
            item.extrainfo = EncodingClass.string.toVariable(item.extrainfo);
        }
    }
    else item.extrainfo = {
        decpre: 2,
        comment: ""
    };
    if (contentModule.datatypeAdvanced.indexOf(item.type) >= 0 && EncodingClass.type.isString(item.content)) {
        item.content = EncodingClass.string.toVariable(item.content);
    }
};

contentModule.getLeave_policy_groupsListPri = function(){
    return [
        {id: -1, name: LanguageModule.text("txt_annual_leave"), description: "", symbol: "P", available: 1, extrainfo: [], ver: 1},
        {id: -2, name: LanguageModule.text("txt_business_trip"), description: "", symbol: "CT", available: 1, extrainfo: [], ver: 1}
    ];
};

contentModule.getEmployment_contract_typesListPri = function(){
    return [
        {id: -1, name: LanguageModule.text("txt_permanent"), description: "", available: 1, extrainfo: [], ver: 1},
        {id: -2, name: LanguageModule.text("txt_temporary"), description: "", available: 1, extrainfo: [], ver: 1},
        {id: -3, name: LanguageModule.text("txt_probationary"), description: "", available: 1, extrainfo: [], ver: 1},
        {id: -4, name: LanguageModule.text("txt_casual"), description: "", available: 1, extrainfo: [], ver: 1}
    ];
};

contentModule.getAdvance_payment_policy_groupsListPri = function(){
    return [
        {id: -1, name: LanguageModule.text("txt_salary_advance"), description: "", available: 1, extrainfo: [], ver: 1}
    ];
};

contentModule.getReligionsListPri = function(){
    return [
        {id: -1, code: "none", name: LanguageModule.text("txt_no"), available: 1, extrainfo: [], ver: 1},
        {id: -2, code: "christian", name: LanguageModule.text("txt_christian"), available: 1, extrainfo: [], ver: 1},
        {id: -3, code: "islam", name: LanguageModule.text("txt_islam"), available: 1, extrainfo: [], ver: 1},
        {id: -4, code: "buddhism", name: LanguageModule.text("txt_buddhism"), available: 1, extrainfo: [], ver: 1}
    ];
};

contentModule.getOffboardingTypesListPri = function(){
    return [
        {id: -1, name: LanguageModule.text("txt_resignation"), available: 1, extrainfo: [], ver: 1},
        {id: -2, name: LanguageModule.text("txt_layoff"), available: 1, extrainfo: [], ver: 1},
        {id: -3, name: LanguageModule.text("txt_retirement"), available: 1, extrainfo: [], ver: 1},
        {id: -4, name: LanguageModule.text("txt_end_of_contract"), available: 1, extrainfo: [], ver: 1}
    ];
};

contentModule.preventNotNumberInput = function(elt) {
    function getCaretPosition(oField) {
        var iCaretPos = 0;
        if (document.selection) {
            oField.focus();
            var oSel = document.selection.createRange();
            oSel.moveStart('character', -oField.value.length);
            iCaretPos = oSel.text.length;
        }
        else if (oField.selectionStart || oField.selectionStart == '0')
            iCaretPos = oField.selectionDirection == 'backward' ? oField.selectionStart : oField.selectionEnd;
        return iCaretPos;
    }

    elt.addEventListener("paste", function (e) {
        e.preventDefault();
        var text = "";
        if (e.clipboardData && e.clipboardData.getData) {
            text = e.clipboardData.getData("text/plain");

        } else if (window.clipboardData && window.clipboardData.getData) {
            text = window.clipboardData.getData("Text");
        }
        var matched = text.match(/[+-]?([0-9,]*[.])?[0-9,]+/);
        if (matched) {
            this.value = matched[0];
        }
    });
    elt.addEventListener('keydown', function (event) {
        var key = event.key;
        if (key && key.length == 1 && !event.ctrlKey && !event.altKey) {
            if (key.match(/[0-9,.\-\+]/)) {
                if (key == '.' && this.value.indexOf('.') >= 0) event.preventDefault();
                if ((key == '+' || key == '-') && (this.value.indexOf('+') >= 0 || this.value.indexOf('-') >= 0 || getCaretPosition(this) > 0)) event.preventDefault();
            }
            else event.preventDefault();
        }
    });
    return elt;
};

contentModule.makeCitiesIndex = function(host){
    var k, t = [];
    var holderForSort = host.database.nations.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.fullname.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    host.database.nations.items = holderForSort.map(function(holder){
        return holder.item;
    });
    holderForSort = host.database.cities.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    host.database.cities.items = holderForSort.map(function(holder){
        return holder.item;
    });
    for (var i = 0; i < host.database.nations.items.length; i++){
        host.database.nations.items[i].cityIndexList = [];
    }
    var nationsDic = contentModule.makeDictionaryIndex(host.database.nations.items);
    for (var i = 0; i < host.database.cities.items.length; i++){
        host.database.cities.items[i].nationIndex = k = nationsDic[host.database.cities.items[i].nationid];
        if (k !== undefined){
            host.database.nations.items[k].cityIndexList.push(t.length);
            t.push(host.database.cities.items[i]);
        }
    }
    host.database.cities.items = t;
};

contentModule.preventNotPhoneNumberInput = function(elt) {
    elt.addEventListener("paste", function (e) {
        e.preventDefault();
        var text = "";
        if (e.clipboardData && e.clipboardData.getData) {
            text = e.clipboardData.getData("text/plain");

        } else if (window.clipboardData && window.clipboardData.getData) {
            text = window.clipboardData.getData("Text");
        }
        text = text.replace(/[^0-9\-+\s\.]/g, '');
        var slstart = elt.selectionStart;
        var slend = elt.selectionEnd;
        var value = this.value +'';
        value = value.substr(0, slstart)+ text+ value.substr(slend);
        this.value = value;
        elt.setSelectionRange(slstart + text.length, slstart+ text.length);
    });
    elt.addEventListener('keydown', function (event) {
        var key = event.key;
        if (key && key.length == 1 && !event.ctrlKey && !event.altKey) {
            if (key.match(/[^0-9\-+\s\.]/)) {
               event.preventDefault();
            }
        }
    });
    return elt;
};

contentModule.getNationsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.nations.items.length; i++){
        list.push({
            value: host.database.nations.items[i].id,
            text: host.database.nations.items[i].fullname
        });
    }
    return list;
};

contentModule.getLanguageListSelectMenu = function(){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < data_module.languages.items.length; i++){
        list.push({
            value: data_module.languages.items[i].id,
            text: data_module.languages.items[i].name
        });
    }
    return list;
};

contentModule.getCitiesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.cities.items.length; i++){
        list.push({
            value: host.database.cities.items[i].id,
            text: host.database.cities.items[i].name
        });
    }
    return list;
};

contentModule.getEthnicsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.ethnics.items.length; i++){
        list.push({
            value: host.database.ethnics.items[i].id,
            text: host.database.ethnics.items[i].name
        });
    }
    return list;
};

contentModule.getReligionsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.religions.items.length; i++){
        list.push({
            value: host.database.religions.items[i].id,
            text: host.database.religions.items[i].name
        });
    }
    return list;
};

contentModule.getUsersListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.users.items.length; i++){
        list.push({
            value: host.database.users.items[i].homeid,
            text: host.database.users.items[i].username + " - " + host.database.users.items[i].fullname
        });
    }
    return list;
};

contentModule.getUsersListSelectBox = function(host){
    var list = [];
    for (var i = 0; i < host.database.users.items.length; i++){
        list.push({
            value: host.database.users.items[i].homeid,
            text: host.database.users.items[i].username + " - " + host.database.users.items[i].fullname
        });
    }
    return list;
};

contentModule.getPositionsListSelectBox = function(host){
    var list = [];
    for (var i = 0; i < host.database.positions.items.length; i++){
        list.push({
            value: host.database.positions.items[i].id,
            text: host.database.positions.items[i].name
        });
    }
    return list;
};

contentModule.getGeoposListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.geopos.items.length; i++){
        list.push({
            value: host.database.geopos.items[i].id,
            text: host.database.geopos.items[i].name
        });
    }
    return list;
};

contentModule.getGeoposListSelectBox = function(host){
    var list = [];
    for (var i = 0; i < host.database.geopos.items.length; i++){
        list.push({
            value: host.database.geopos.items[i].id,
            text: host.database.geopos.items[i].name
        });
    }
    return list;
};

contentModule.getPositionsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.positions.items.length; i++){
        list.push({
            value: host.database.positions.items[i].id,
            text: host.database.positions.items[i].name
        });
    }
    return list;
};

contentModule.getEmployeesListSelectMenu = function(host){
    var pDict = {};
    host.database.peoples.items.forEach(function(elt){
        pDict[elt.id] = elt;
    });
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.employees.items.length; i++){
        if (!host.database.employees.items[i].available) continue;
        list.push({
            value: host.database.employees.items[i].id,
            text: pDict[host.database.employees.items[i].peopleid].fullname
        });
    }
    return list;
};

contentModule.getEmployeesListMultiSelectMenu = function(host){
    var pDict = {};
    host.database.peoples.items.forEach(function(elt){
        pDict[elt.id] = elt;
    });
    var list = [];
    for (var i = 0; i < host.database.employees.items.length; i++){
        if (!host.database.employees.items[i].available) continue;
        list.push({
            value: host.database.employees.items[i].id,
            text: pDict[host.database.employees.items[i].peopleid].fullname
        });
    }
    return list;
};

contentModule.getDepartmentLink = function(host, departmentid){
    var dict = {};
    for (var i = 0; i < host.database.orgs.items.length; i++){
        dict[host.database.orgs.items[i].id] = host.database.orgs.items[i];
    }
    var str = "";
    if (!dict[departmentid]) return "";
    while (dict[departmentid].parentid != 0){
        if (str == "") str = dict[departmentid].name;
        else {
            str = dict[departmentid].name + "/" + str;
        }
        departmentid = dict[departmentid].parentid;
    }
    if (str == "") str = dict[departmentid].name;
    else str = dict[departmentid].name + "/" + str;
    return str;
};

contentModule.makeOrgsIndex = function(host){
    var k, t = [];
    var holderForSort = host.database.orgs.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });
    host.database.orgs.items = holderForSort.map(function(holder){
        return holder.item;
    });

    for (var i = 0; i < host.database.orgs.items.length; i++){
        host.database.orgs.items[i].childIndexList = [];
    }
    var orgDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var k;
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid == 0) continue;
        k = orgDic[host.database.orgs.items[i].parentid];
        if (k !== undefined) host.database.orgs.items[k].childIndexList.push(i);
    }
};

contentModule.makePositionsIndex = function(host){
    var k, t = [];
    var holderForSort = host.database.positions.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });
    host.database.positions.items = holderForSort.map(function(holder){
        return holder.item;
    });

    for (var i = 0; i < host.database.orgs.items.length; i++){
        host.database.orgs.items[i].positionIndexList = [];
    }
    var orgDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var k;
    for (var i = 0; i < host.database.positions.items.length; i++){
        k = orgDic[host.database.positions.items[i].orgid];
        if (k !== undefined) host.database.orgs.items[k].positionIndexList.push(i);
    }
};

contentModule.makeEmployeesIndex = function(host){
    var k, t = [];
    var holderForSort = host.database.employees.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.fullname.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });
    host.database.employees.items = holderForSort.map(function(holder){
        return holder.item;
    });

    for (var i = 0; i < host.database.orgs.items.length; i++){
        host.database.orgs.items[i].employeeIndexList = [];
        host.database.orgs.items[i].employeeIdList = [];
    }
    var orgDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var k;
    var t = [];
    for (var i = 0; i < host.database.employees.items.length; i++){
        k = orgDic[host.database.employees.items[i].orgid];
        host.database.employees.items[i].orgIndex = k;
        if (k !== undefined){
            host.database.orgs.items[k].employeeIndexList.push(t.length);
            host.database.orgs.items[k].employeeIdList.push(host.database.employees.items[i].id);
            t.push(host.database.employees.items[i]);
        }
    }
    host.database.employees.items = t;
};

contentModule.getOrgsListSelectTreeMenu = function(host, ps = {}){
    var noSelectDic = {};
    if (ps.noSelectDic) noSelectDic = ps.noSelectDic;
    function getOrgItem(index){
        var items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            ni = host.database.orgs.items[index].childIndexList[i];
            if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[ni].id]) continue;
            items.push(getOrgItem(ni));
        }
        var res = {
            value: host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            noSelect: (host.orgEditDic && !host.orgEditDic[host.database.orgs.items[index].id]) || noSelectDic[host.database.orgs.items[index].id],
            icon: {tag:'span', class: (host.database.orgs.items[index].parentid == 0)? ['mdi', 'mdi-home-variant'] : ['mdi', 'mdi-folder-account']},
            items: items
        };
        if (ps.disabledCompany && host.database.orgs.items[index].parentid == 0) res.noSelect = true;
        return res;
    };
    var items = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[i].id]) continue;
        items.push(getOrgItem(i));
    }
    return items;
};

contentModule.getNationCityDualSelectMenu = function(host){
    var items = [];
    var cityItems;
    for (var i = 0; i < host.database.nations.items.length; i++){
        cityItems = [];
        for (var j = 0; j < host.database.nations.items[i].cityIndexList.length; j++){
            cityItems.push({
                value: host.database.cities.items[host.database.nations.items[i].cityIndexList[j]].id,
                text: host.database.cities.items[host.database.nations.items[i].cityIndexList[j]].name,
                sortText: absol.string.nonAccentVietnamese(host.database.cities.items[host.database.nations.items[i].cityIndexList[j]].name).toLowerCase()
            });
        }
        cityItems.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        items.push({
            value: host.database.nations.items[i].id,
            text: host.database.nations.items[i].fullname,
            sortText: absol.string.nonAccentVietnamese(host.database.nations.items[i].fullname).toLowerCase(),
            items: cityItems
        });
    }
    items.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    return items;
};

contentModule.getMemberOfEmployeeSelectMenu = function(host){
    console.log(host);
    function getOrgItem(index){
        var items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            ni = host.database.orgs.items[index].childIndexList[i];
            if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[ni].id]) continue;
            items.push(getOrgItem(ni));
        }
        items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var e_items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].employeeIndexList.length; i++){
            ni = host.database.orgs.items[index].employeeIndexList[i];
            if (host.employeeEditDic && !host.employeeEditDic[host.database.employees.items[ni].id]) continue;
            e_items.push({
                value: host.database.employees.items[ni].id,
                text: host.database.employees.items[ni].fullname,
                code: host.database.employees.items[ni].code,
                isLeaf: true,
                icon: {tag:'span', class:['mdi', 'mdi-account']},
                sortText: absol.string.nonAccentVietnamese(host.database.employees.items[host.database.orgs.items[index].employeeIndexList[i]].fullname).toLowerCase(),
                noView: !host.database.employees.items[ni].available
            });
        }
        e_items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var res = {
            value: -host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            icon: {tag:'span', class: (host.database.orgs.items[index].parentid == 0)? ['mdi', 'mdi-home-variant'] : ['mdi', 'mdi-folder-account']},
            items: e_items.concat(items),
            sortText: absol.string.nonAccentVietnamese(host.database.orgs.items[index].name).toLowerCase()
        };
        return res;
    };
    var items = [{value: 0, text: LanguageModule.text("txt_select_value"), isLeaf: true}];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[i].id]) continue;
        items.push(getOrgItem(i));
    }
    items.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    return items;
};

contentModule.getMemberOfPositionSelectMenu = function(host){
    function getOrgItem(index){
        var items = [];
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            items.push(getOrgItem(host.database.orgs.items[index].childIndexList[i]));
        }
        items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var e_items = [];
        for (var i = 0; i < host.database.orgs.items[index].positionIndexList.length; i++){
            e_items.push({
                value: host.database.positions.items[host.database.orgs.items[index].positionIndexList[i]].id,
                text: host.database.positions.items[host.database.orgs.items[index].positionIndexList[i]].name,
                isLeaf: true,
                icon: {tag:'span', class: ['mdi', 'mdi-account']},
                sortText: absol.string.nonAccentVietnamese(host.database.positions.items[host.database.orgs.items[index].positionIndexList[i]].name).toLowerCase()
            });
        }
        e_items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var res = {
            value: -host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            icon: {tag:'span', class: (host.database.orgs.items[index].parentid == 0)? ['mdi', 'mdi-home-variant'] : ['mdi', 'mdi-folder-account']},
            items: e_items.concat(items),
            sortText: absol.string.nonAccentVietnamese(host.database.orgs.items[index].name).toLowerCase()
        };
        return res;
    };
    var items = [];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        items.push(getOrgItem(i));
    }
    items.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    return items;
};

contentModule.getOrgsAndEmployeesListSelectTreeMenu = function(host, params = {}){
    var noSelectDic = {};
    if (params.noSelectDic) noSelectDic = params.noSelectDic;
    var employee_type = "active";
    if (params.employee_type) employee_type = params.employee_type;
    function getOrgItem(index){
        var items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            ni = host.database.orgs.items[index].childIndexList[i];
            if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[ni].id]) continue;
            items.push(getOrgItem(ni));
        }
        items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var e_items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].employeeIndexList.length; i++){
            ni = host.database.orgs.items[index].employeeIndexList[i];
            if (host.employeeEditDic && !host.employeeEditDic[host.database.employees.items[ni].id]) continue;
            if ((employee_type == "active") && !host.database.employees.items[ni].available) continue;
            if ((employee_type == "inactive") && host.database.employees.items[ni].available) continue;
            e_items.push({
                value: -host.database.employees.items[ni].id,
                text: host.database.employees.items[ni].fullname,
                icon: {tag:'span', class:['mdi', 'mdi-account']},
                sortText: absol.string.nonAccentVietnamese(host.database.employees.items[ni].fullname).toLowerCase(),
                noSelect: noSelectDic[-host.database.employees.items[ni].id]
            });
        }
        e_items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var res = {
            value: host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            icon: {tag:'span', class: (host.database.orgs.items[index].parentid == 0)? ['mdi', 'mdi-home-variant'] : ['mdi', 'mdi-folder-account']},
            items: e_items.concat(items),
            sortText: absol.string.nonAccentVietnamese(host.database.orgs.items[index].name).toLowerCase(),
            noSelect: noSelectDic[host.database.orgs.items[index].id]
        };
        if (host.orgEditDic && !host.orgEditDic[host.database.orgs.items[index].id]) res.noSelect = true;
        return res;
    };
    var items = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[i].id]) continue;
        items.push(getOrgItem(i));
    }
    items.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    return items;
};

contentModule.getOrgsAndEmployeesListSelectTreeMenuLeaf = function(host, userNone){
    function getOrgItem(index){
        var items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            ni = host.database.orgs.items[index].childIndexList[i];
            if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[ni].id]) continue;
            items.push(getOrgItem(ni));
        }
        items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var e_items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].employeeIndexList.length; i++){
            ni = host.database.orgs.items[index].employeeIndexList[i];
            if (userNone && (userNone[host.database.employees.items[ni].userid] || host.database.employees.items[ni].userid == 0)) continue;
            if (host.employeeEditDic && !host.employeeEditDic[host.database.employees.items[ni].id]) continue;
            if (host.employeeNotViewDic && host.employeeNotViewDic[host.database.employees.items[ni].id]) continue;
            e_items.push({
                value: host.database.employees.items[ni].id,
                text: host.database.employees.items[ni].fullname,
                icon: {tag:'span', class:['mdi', 'mdi-account']},
                sortText: absol.string.nonAccentVietnamese(host.database.employees.items[ni].fullname).toLowerCase(),
                isLeaf: true,
                noView: !host.database.employees.items[ni].available
            });
        }
        e_items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var res = {
            value: -host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            icon: {tag:'span', class: (host.database.orgs.items[index].parentid == 0)? ['mdi', 'mdi-home-variant'] : ['mdi', 'mdi-folder-account']},
            items: e_items.concat(items),
            sortText: absol.string.nonAccentVietnamese(host.database.orgs.items[index].name).toLowerCase()
        };
        return res;
    };
    var items = [];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[i].id]) continue;
        items.push(getOrgItem(i));
    }
    items.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    return items;
};

contentModule.getCompanyListSelectTreeMenu = function(host){
    function getOrgItem(index){
        var items = [];
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            items.push(getOrgItem(host.database.orgs.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            items: items
        };
        return res;
    };
    var items = [];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        items.push(getOrgItem(i));
    }
    return items;
};

contentModule.getDepartmentListSelectTreeMenu = function(host, companyId){
    function getOrgItem(index){
        var items = [];
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            items.push(getOrgItem(host.database.orgs.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            items: items
        };
        return res;
    };
    var items = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != companyId) continue;
        items.push(getOrgItem(i));
    }
    return items;
};

contentModule.getDepartmentListSelectTreeMenuFilter = function(host, companyId){
    function getOrgItem(index){
        var items = [];
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            items.push(getOrgItem(host.database.orgs.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            items: items
        };
        return res;
    };
    var items = [];
    if (companyId != 0) items.push({value: 0, text: LanguageModule.text("txt_all_department")});
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != companyId) continue;
        items.push(getOrgItem(i));
    }
    return items;
};

contentModule.getDetailsEnumPri = function(type){
    var res = [];
    switch (type) {
        case "language":
            for (var i = 0; i < data_module.languages.items.length; i++){
                res.push({
                    localid: data_module.languages.items[i].id,
                    text: data_module.languages.items[i].name,
                    value: data_module.languages .items[i].id
                });
            }
            break;
        case "member_of_leave_policy_groups":
            var x = contentModule.getLeave_policy_groupsListPri();
            for (var i = 0; i < x.length; i++){
                res.push({
                    localid: x[i].id,
                    text: x[i].name,
                    value: x[i].id
                });
            }
            break;
        case "member_of_employment_contract_types":
            var x = contentModule.getEmployment_contract_typesListPri();
            for (var i = 0; i < x.length; i++){
                res.push({
                    localid: x[i].id,
                    text: x[i].name,
                    value: x[i].id
                });
            }
            break;

    }
    return res;
};

contentModule.viewPeopleInputForm = function(host, inputFormId, valueContent){
    var AssemblerInstance = absol.form.AssemblerInstance;
    var mPeopleFrag = AssemblerInstance.buildFragment({class: "" + inputFormId});
    mPeopleFrag.domElt.addStyle({
        width: '100%',
        height:'100%',
        display: 'block'
    });
    if (valueContent){
        mPeopleFrag.props = valueContent;
    }
    return mPeopleFrag;
};

contentModule.makeInputFormDecode = function(input_forms){
    input_forms.forEach(function(elt){
        elt.content = EncodingClass.string.toVariable(elt.content);
    });
};

contentModule.makeOutputFormDecode = function(output_forms){
    output_forms.forEach(function(elt){
        elt.content = EncodingClass.string.toVariable(elt.content);
    });
};

contentModule.makeTasksDecode = function(tasks){
    tasks.forEach(function(elt){
        elt.extrainfo = EncodingClass.string.toVariable(elt.extrainfo);
    });
};

contentModule.makeMeetingsDecode = function(tasks){
    tasks.forEach(function(elt){
        elt.extrainfo = EncodingClass.string.toVariable(elt.extrainfo);
    });
};

contentModule.makeExtraInfoDecode = function(items){
    items.forEach(function(elt){
        if (elt.extrainfo == ""){
            elt.extrainfo = {};
        }
        else if (EncodingClass.type.isString(elt.extrainfo)){
            elt.extrainfo = EncodingClass.string.toVariable(elt.extrainfo);
        }
    });
};

contentModule.makeExtendTypeData = function(host, typeid){
    var data = [];
    var index = host.dictionary.typelists[typeid];
    while (host.database.typelists.items[index].type == "extends_structure") {
        data = host.database.typelists.items[index].content.details.concat(data);
        index = host.dictionary.typelists[host.database.typelists.items[index].content.typeof];
    }
    data = host.database.typelists.items[index].content.details.concat(data);
    return data;
};

contentModule.getEmployeesList = function(host, orgid){
    var data = [];
    for (var i = 0; i < host.database.employees.items.length; i++){
        if (!host.database.employees.items[i].available) continue;
        if (host.database.employees.items[i].orgid == orgid) data.push({
            value: host.database.employees.items[i].id,
            text: host.database.employees.items[i].fullname,
            sortText: absol.string.nonAccentVietnamese(host.database.employees.items[i].fullname.toLowerCase())
        });
    }
    data.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    data.unshift({value: 0, text: LanguageModule.text("txt_select_value")});
    return data;
};

contentModule.getPositionsList = function(host, orgid){
    var data = [];
    for (var i = 0; i < host.database.positions.items.length; i++){
        if (host.database.positions.items[i].id == orgid) data.push({
            value: host.database.positions.items[i].id,
            text: host.database.positions.items[i].name
        });
    }
    data.sort(function(a, b){
        if (a.text > b.text) return 1;
        if (a.text < b.text) return -1;
        return 0;
    });
    data.unshift({value: 0, text: LanguageModule.text("txt_select_value")});
    return data;
};

contentModule.isChanged = function(oldData, newData, listFieldCheck){
    var item;
    for (var i = 0; i < listFieldCheck.length; i++){
        item = listFieldCheck[i];
        if (EncodingClass.string.compare(oldData[item], newData[item]) != 0) {
            console.log(oldData[item], newData[item], item);
            return true;
        }
    }
    return false;
};

contentModule.makeEmployeeData = function(host){
    var peoplesDic = contentModule.makeDictionaryIndex(host.database.peoples.items);
    var pIndex;
    for (var i = 0; i < host.database.employees.items.length; i++){
        pIndex = peoplesDic[host.database.employees.items[i].peopleid];
        if (pIndex !== undefined){
            host.database.employees.items[i].fullname = host.database.peoples.items[pIndex].fullname;
        }
        else {
            host.database.employees.items[i].fullname = "";
        }
    }
};

contentModule.makeEmployeeAllData = function(host){
    for (var i = 0; i < host.database.peoples.items.length; i++){
        if (EncodingClass.type.isString(host.database.peoples.items[i].content)){
            host.database.peoples.items[i].content = EncodingClass.string.toVariable(host.database.peoples.items[i].content);
        }
        for (var j = 0; j < contentModule.getPeopleContentField.length; j++){
            host.database.peoples.items[i][contentModule.getPeopleContentField[j]] = host.database.peoples.items[i].content[contentModule.getPeopleContentField[j]];
        }
    }
    var peoplesDic = contentModule.makeDictionaryIndex(host.database.peoples.items);
    var pIndex;
    for (var i = 0; i < host.database.employees.items.length; i++){
        pIndex = peoplesDic[host.database.employees.items[i].peopleid];
        if (pIndex !== undefined){
            for (var param in host.database.peoples.items[pIndex]) {
                if (param != "id" && param != "userid" && param != "available"){
                    host.database.employees.items[i][param] = host.database.peoples.items[pIndex][param];
                }
            }
        }
        else {
            host.database.employees.items[i].fullname = "";
        }
    }
};

contentModule.getValueOfForm = function(formView, typeid, typelists, mainData, no_alert){
    var typeDict = {};
    var dict2 = {};
    typelists.forEach(function(elt, index){
        typeDict[elt.id] = index;
        dict2[elt.id] = elt;
    });
    var primitiveTypeList = form_module.primitiveTypeList;
    var getType = function(index){
        var type = typelists[index].type;
        if (
            form_module.primitiveTypeList.indexOf(type) != -1
        ){
            type = typelists[index].type2;
        }
        return type;
    }
    var generateData = function(valueContent, typeid, elt){
        var data;
        var type;
        if (isNaN(parseInt(typeid, 10))) type = typeid;
        else type = getType(typeDict[typeid]);
        if (valueContent && valueContent.constructor === Object && valueContent[typeid]) valueContent = valueContent[typeid];
        switch (type) {
            case "nation_city":
                if (elt && elt.require && valueContent.value.length < 2) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.value;
                break;
            case "position_list":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "employee_list":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "number":
            case "currency":
                if (elt && elt.require && valueContent === "") {
                    if (!no_alert) ModalElement.alert({message: "Chưa nhập " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "string":
            case "phonenumber":
            case "website":
            case "gps":
            case "note":
            case "html":
            case "variable_input":
            case "variable_textarea":
            case "email_address":
                valueContent = valueContent.trim();
                if (elt && elt.require && valueContent == "") {
                    absol.form.traversal(formView, function(path){
                        if (path.node["$" + elt.localid]) {
                            if (!no_alert) ModalElement.alert({
                                message: "Chưa nhập " + elt.name,
                                func: function(){
                                    path.node["$" + elt.localid].domElt.focus();
                                }
                            });
                            path.stop();
                        }
                    });
                    return undefined;
                }
                data = valueContent;
                break;
            case "date":
            case "month":
            case "week":
            case "datetime":
            case "datemonth":
            case "boolean":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "hour_period":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = {
                    dayOffset: valueContent.dayOffset,
                    duration: valueContent.duration
                };
                break;
            case "time":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "user":
            case "geopos":
            case "member_of_position":
            case "member_of_employee":
            case "member_of_worktime_machines":
            case "member_of_assets":
            case "member_of_instruments_and_tools":
            case "member_of_warehouses":
            case "member_of_assets_instruments_and_tools":
            case "member_of_allowance_policy_groups":
            case "member_of_training_program_groups":
            case "member_of_leave_policy_groups":
            case "member_of_insurance_policy_groups":
            case "member_of_benefit_policy_groups":
            case "member_of_tax_policy_groups":
            case "member_of_bonus_policy_groups":
            case "member_of_overtime_policy_groups":
            case "member_of_offboarding_types":
            case "member_of_offboarding_reasons":
            case "member_of_work_flow_groups":
            case "member_of_work_flows":
            case "member_of_objects":
            case "member_of_lesson_categories":
            case "member_of_payroll_cycle":
            case "member_of_task":
            case "member_of_meeting":
            case "member_of_typelists":
            case "member_of_input_forms":
            case "member_of_output_forms":
            case "member_of_mobile_input_forms":
            case "member_of_mobile_output_forms":
            case "member_of_partner_class":
            case "member_of_partner":
            case "member_of_contact":
            case "member_of_trade_union_policy_groups":
            case "member_of_salary_policy_groups":
            case "member_of_other_liability_policy_groups":
            case "member_of_late_early_checkin_policy_groups":
            case "member_of_advance_payment_policy_groups":
            case "member_of_punishment_policy_groups":
            case "member_of_asset_category":
            case "member_of_instruments_and_tools_category":
            case "member_of_projects":
            case "member_of_insurance_policies":
            case "member_of_tax_policies":
            case "member_of_trade_union_policies":
            case "member_of_leave_policies":
            case "member_of_benefit_policies":
            case "member_of_allowance_policies":
            case "member_of_bonus_policies":
            case "member_of_overtime_policies":
            case "member_of_punishment_policies":
            case "member_of_advance_payment_policies":
            case "member_of_late_early_checkin_policies":
            case "member_of_salary_policies":
            case "member_of_other_liability_policies":
            case "member_of_employment_contract_types":
            case "member_of_nations":
            case "member_of_cities":
            case "member_of_religions":
            case "member_of_shifts":
            case "member_of_ethnics":
            case "member_of_document_types":
            case "member_of_document_groups":
            case "member_of_document_folders":
            case "member_of_orgs":
            case "member_of_template_groups":
            case "member_of_welcome_templates":
                if (elt && elt.require && valueContent.value == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.value;
                break;
            case "color_picker":
                if (elt && elt.require && valueContent == "") {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "member_of_department":
                data = valueContent.value;
                break;
            case "files":
                data = valueContent.map(function(elt){
                    if (elt.id) return elt.id;
                    else {
                        return {
                            filename: elt.filename,
                            old_cd: elt.old_cd,
                            content_type: elt.content_type
                        };
                    }
                });
                break;
            case "enum":
            case "extends_enum":
                if (elt && elt.require && valueContent.value == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.value;
                break;
            case "enum_multi":
            case "extends_enum_multi":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "userlist":
            case "members_of_shifts":
            case "members_of_locations":
            case "members_of_partner_class":
            case "multiselect_offboarding_reasons":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "select_department_employee":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "any_file":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent ? valueContent.id : 0;
                break;
            case "image_file":
                if (valueContent instanceof File) {
                    if (valueContent.type.startsWith("image")){
                        data = valueContent;
                    }
                }
                else {
                    data = valueContent.id;
                }
                break;
            case "structure":
                var t_value;
                var index = typeDict[typeid];
                var typeContent = typelists[index].content.details;
                data = {};
                for (var i = 0; i < typeContent.length; i++){
                    t_value = generateData(valueContent[typeContent[i].localid], typeContent[i].type, typeContent[i]);
                    if (t_value === undefined) return undefined;
                    if (t_value && t_value.detailUnion){
                        data[typeContent[i].localid] = t_value.value;
                        Object.assign(data, t_value.detailUnion);
                    }
                    else data[typeContent[i].localid] = t_value;
                }
                break;
            case "extends_structure":
                var t_value;
                var index = typeDict[typeid];
                var typeContent = typelists[index].content;
                var t_id = typeContent.typeof;
                var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                while (typelists[typeDict[t_id]].type == "extends_structure"){
                    t_id = typelists[typeDict[t_id]].content.typeof;
                    content = typelists[typeDict[t_id]].content.details.concat(content)
                }
                data = {};
                for (var i = 0; i < content.length; i++){
                    t_value = generateData(valueContent[content[i].localid], content[i].type, content[i]);
                    if (t_value === undefined) return undefined;
                    if (t_value && t_value.detailUnion){
                        data[content[i].localid] = t_value.value;
                        Object.assign(data, t_value.detailUnion);
                    }
                    else data[content[i].localid] = t_value;
                }
                break;
            case "array":
                data = [];
                var index = typeDict[typeid];
                var typeContent = typelists[index].content;
                var t_id = typeContent.typeof;
                var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                if (dataTypeOfArray == "advanced"){
                    var type = getType(typeDict[t_id]);
                    if (type == "structure" || type == "extends_structure"){
                        for (i = 0; i < valueContent.length; i++){
                            var x = generateData(valueContent[i], t_id);
                            if (x === undefined) return undefined;
                            if (x !== null) data.push(x);
                        }
                    }
                    else {
                        for (i = 0; i < valueContent.length; i++){
                            var x = generateData(valueContent[i][t_id], t_id);
                            if (x === undefined) return undefined;
                            if (x !== null) data.push(x);
                        }
                    }
                }
                else {
                    var type = getType(typeDict[t_id]);
                    if (type == "structure" || type == "extends_structure"){
                        var typeofarray = dict2[typeid].content.typeof;
                        var mainData = contentModule.getMainData(typeofarray, dict2);
                        if (!mainData) data = valueContent.records;
                        else {
                            var keys = Object.keys(mainData);
                            valueContent.records.forEach(function(record){
                                var x = EncodingClass.string.duplicate(record);
                                var cur = {};
                                keys.forEach(function(localid){
                                    cur[mainData[localid]] = x[localid];
                                    delete(x[localid]);
                                });
                                cur.extrainfo = x;
                                data.push(cur);
                            });
                        }
                    }
                    else {
                        for (i = 0; i < valueContent.records.length; i++){
                            data.push(valueContent.records[i][t_id]);
                        }
                    }
                }
                break;
            case "union":
                if (elt && elt.require && valueContent.value == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = {
                    value: valueContent.value,
                    detailUnion: {}
                };
                if (elt.detailUnion[data.value]){
                    for (var i = 0; i < elt.detailUnion[data.value].length; i++){
                        data.detailUnion[elt.detailUnion[data.value][i].localid] = generateData(formView.props[elt.detailUnion[data.value][i].localid], elt.detailUnion[data.value][i].type, elt.detailUnion[data.value][i]);
                        if (data.detailUnion[elt.detailUnion[data.value][i].localid] === undefined) return undefined;
                    }
                }
                break;
            default:

        }
        return data;
    };

    var verifyInfo = formView.verify();

    if (!verifyInfo.completed) {
        contentModule.handleIncomletedForm(formView, verifyInfo);
        return undefined;
    }

    var data = generateData(formView.props, typeid);

    if (data === undefined) return undefined;

    var returnValue = {
        extrainfo: {},
        files: []
    };
    var typeDataContent = [];
    var index = typeDict[typeid];
    while (typelists[index].type == "extends_structure") {
        typeDataContent = typelists[index].content.details.concat(typeDataContent);
        index = typeDict[typelists[index].content.typeof];
    }
    typeDataContent = typelists[index].content.details.concat(typeDataContent);
    typeDataContent.forEach(function(elt){
        var type;
        if (isNaN(parseInt(elt.type))) type = elt.type;
        else type = getType(typeDict[elt.type])
        if (type == "image_file") returnValue.files.push(data[elt.localid]);
        if (type == "any_file") returnValue.files.push(data[elt.localid]);
        if (elt.type == -64) returnValue.files = returnValue.files.concat(data[elt.localid]);
        returnValue.files = returnValue.files.filter(function(elt){
            return elt > 0;
        });
        if (mainData[elt.localid]){
            returnValue[mainData[elt.localid]] = data[elt.localid];
        }
        else {
            returnValue.extrainfo[elt.localid] = data[elt.localid];
        }
        if (type == "union") {
            if (elt.detailUnion[data[elt.localid]]){
                elt.detailUnion[data[elt.localid]].forEach(function(cur){
                    returnValue[mainData[cur.localid]] = data[cur.localid];
                });
            }
        }
    });
    return returnValue;
};

contentModule.getValueOfUserForm = function(formView, typeid, typelists, no_alert){
    var typeDict = {};
    var dict2 = {};
    typelists.forEach(function(elt, index){
        typeDict[elt.id] = index;
        dict2[elt.id] = elt;
    });
    var primitiveTypeList = form_module.primitiveTypeList;
    var getType = function(index){
        var type = typelists[index].type;
        if (
            form_module.primitiveTypeList.indexOf(type) != -1
        ){
            type = typelists[index].type2;
        }
        return type;
    }
    var generateData = function(valueContent, typeid, elt){
        var data;
        var type;
        if (isNaN(parseInt(typeid, 10))) type = typeid;
        else type = getType(typeDict[typeid]);
        if (valueContent && valueContent.constructor === Object && valueContent[typeid]) valueContent = valueContent[typeid];
        switch (type) {
            case "nation_city":
                if (elt && elt.require && valueContent.value.length < 2) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                if (valueContent.value === undefined) data = [];
                else data = valueContent.value;
                break;
            case "position_list":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                if (valueContent.values === undefined) data = [];
                else data = valueContent.values;
                break;
            case "employee_list":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                if (valueContent.values === undefined) data = [];
                else data = valueContent.values;
                break;
            case "number":
            case "currency":
                if (elt && elt.require && valueContent === "") {
                    if (!no_alert) ModalElement.alert({message: "Chưa nhập " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "string":
            case "phonenumber":
            case "website":
            case "gps":
            case "note":
            case "html":
            case "variable_input":
            case "variable_textarea":
            case "email_address":
                valueContent = valueContent.trim();
                if (elt && elt.require && valueContent == "") {
                    absol.form.traversal(formView, function(path){
                        if (path.node["$" + elt.localid]) {
                            if (!no_alert) ModalElement.alert({
                                message: "Chưa nhập " + elt.name,
                                func: function(){
                                    path.node["$" + elt.localid].domElt.focus();
                                }
                            });
                            path.stop();
                        }
                    });
                    return undefined;
                }
                data = valueContent;
                break;
            case "date":
            case "datetime":
            case "month":
            case "week":
            case "datemonth":
            case "boolean":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "hour_period":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = {
                    dayOffset: valueContent.dayOffset,
                    duration: valueContent.duration
                };
                break;
            case "time":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "user":
            case "geopos":
            case "member_of_position":
            case "member_of_employee":
            case "member_of_worktime_machines":
            case "member_of_assets":
            case "member_of_instruments_and_tools":
            case "member_of_warehouses":
            case "member_of_assets_instruments_and_tools":
            case "member_of_allowance_policy_groups":
            case "member_of_training_program_groups":
            case "member_of_leave_policy_groups":
            case "member_of_insurance_policy_groups":
            case "member_of_benefit_policy_groups":
            case "member_of_tax_policy_groups":
            case "member_of_bonus_policy_groups":
            case "member_of_overtime_policy_groups":
            case "member_of_offboarding_types":
            case "member_of_offboarding_reasons":
            case "member_of_work_flow_groups":
            case "member_of_work_flows":
            case "member_of_objects":
            case "member_of_lesson_categories":
            case "member_of_payroll_cycle":
            case "member_of_task":
            case "member_of_meeting":
            case "member_of_typelists":
            case "member_of_input_forms":
            case "member_of_output_forms":
            case "member_of_mobile_input_forms":
            case "member_of_mobile_output_forms":
            case "member_of_partner_class":
            case "member_of_partner":
            case "member_of_contact":
            case "member_of_trade_union_policy_groups":
            case "member_of_salary_policy_groups":
            case "member_of_other_liability_policy_groups":
            case "member_of_late_early_checkin_policy_groups":
            case "member_of_advance_payment_policy_groups":
            case "member_of_punishment_policy_groups":
            case "member_of_asset_category":
            case "member_of_instruments_and_tools_category":
            case "member_of_projects":
            case "member_of_insurance_policies":
            case "member_of_tax_policies":
            case "member_of_trade_union_policies":
            case "member_of_leave_policies":
            case "member_of_benefit_policies":
            case "member_of_allowance_policies":
            case "member_of_bonus_policies":
            case "member_of_overtime_policies":
            case "member_of_punishment_policies":
            case "member_of_advance_payment_policies":
            case "member_of_late_early_checkin_policies":
            case "member_of_salary_policies":
            case "member_of_other_liability_policies":
            case "member_of_employment_contract_types":
            case "member_of_nations":
            case "member_of_cities":
            case "member_of_religions":
            case "member_of_shifts":
            case "member_of_ethnics":
            case "member_of_document_types":
            case "member_of_document_groups":
            case "member_of_document_folders":
            case "member_of_orgs":
            case "member_of_template_groups":
            case "member_of_welcome_templates":
                if (elt && elt.require && valueContent.value == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.value.toString();
                break;
            case "color_picker":
                if (elt && elt.require && valueContent == "") {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "member_of_department":
                data = valueContent.value.toString;
                break;
            case "files":
                data = valueContent.map(function(elt){
                    if (elt.id) return elt.id;
                    else return {
                        filename: elt.filename,
                        old_cd: elt.old_cd,
                        content_type: elt.content_type
                    };
                });
                break;
            case "enum":
            case "extends_enum":
                if (elt && elt.require && valueContent.value == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                if (valueContent.value === undefined) data = "";
                else data = valueContent.value.toString();
                break;
            case "enum_multi":
            case "extends_enum_multi":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                if (valueContent.values === undefined) data = [];
                else data = valueContent.values;
                break;
            case "userlist":
            case "members_of_shifts":
            case "members_of_locations":
            case "multiselect_offboarding_reasons":
            case "members_of_partner_class":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "select_department_employee":
                if (elt && elt.require && valueContent.values.length == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "any_file":
                if (elt && elt.require && valueContent === null) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = valueContent ? valueContent.id : 0;
                break;
            case "image_file":
                if (valueContent instanceof File) {
                    if (valueContent.type.startsWith("image")){
                        data = valueContent;
                    }
                }
                else {
                    data = valueContent.id;
                }
                break;
            case "structure":
                var t_value;
                var index = typeDict[typeid];
                var typeContent = typelists[index].content.details;
                data = {};
                for (var i = 0; i < typeContent.length; i++){
                    t_value = generateData(valueContent[typeContent[i].localid], typeContent[i].type, typeContent[i]);
                    if (t_value === undefined) return undefined;
                    if (t_value && t_value.detailUnion){
                        data[typeContent[i].localid] = t_value.value;
                        Object.assign(data, t_value.detailUnion);
                    }
                    else data[typeContent[i].localid] = t_value;
                }
                break;
            case "extends_structure":
                var t_value;
                var index = typeDict[typeid];
                var typeContent = typelists[index].content;
                var t_id = typeContent.typeof;
                var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                while (typelists[typeDict[t_id]].type == "extends_structure"){
                    t_id = typelists[typeDict[t_id]].content.typeof;
                    content = typelists[typeDict[t_id]].content.details.concat(content)
                }
                data = {};
                for (var i = 0; i < content.length; i++){
                    t_value = generateData(valueContent[content[i].localid], content[i].type, content[i]);
                    if (t_value === undefined) return undefined;
                    if (t_value && t_value.detailUnion){
                        data[content[i].localid] = t_value.value;
                        Object.assign(data, t_value.detailUnion);
                    }
                    else data[content[i].localid] = t_value;
                }
                break;
            case "array":
                data = [];
                var index = typeDict[typeid];
                var typeContent = typelists[index].content;
                var t_id = typeContent.typeof;
                var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                if (dataTypeOfArray == "advanced"){
                    var type = getType(typeDict[t_id]);
                    if (type == "structure" || type == "extends_structure"){
                        for (i = 0; i < valueContent.length; i++){
                            var x = generateData(valueContent[i], t_id);
                            if (x === undefined) return undefined;
                            if (x !== null) data.push(x);
                        }
                    }
                    else {
                        for (i = 0; i < valueContent.length; i++){
                            var x = generateData(valueContent[i][t_id], t_id);
                            if (x === undefined) return undefined;
                            if (x !== null) data.push(x);
                        }
                    }
                }
                else {
                    var type = getType(typeDict[t_id]);
                    if (type == "structure" || type == "extends_structure"){
                        var typeofarray = dict2[typeid].content.typeof;
                        data = valueContent.records;
                        var t_dict = {};
                        typelists[typeDict[t_id]].content.details.forEach(function(elt){
                            t_dict[elt.localid] = elt.type;
                        });
                        var removeIndex = [];
                        if (!data) data = [];
                        data.forEach(function(elt, idx){
                            Object.keys(t_dict).forEach(function(cur){
                                if (elt[cur] === undefined) {
                                    var t_type = typelists[typeDict[t_dict[cur]]].type;
                                    switch (t_type) {
                                        case "enum":
                                        case "extends_enum":
                                            elt[cur] = "";
                                            break;
                                        case "enum_multi":
                                        case "extends_enum_multi":
                                            elt[cur] = [];
                                            break;
                                        case "datetime":
                                        case "date":
                                            removeIndex.push(idx);
                                            break;
                                        default:
                                            if (contentModule.listTypeSelectmenu.indexOf(t_type) >= 0){
                                                elt[cur] = "";
                                            }
                                            else if (contentModule.listTypeSelectbox.indexOf(t_type) >= 0) {
                                                elt[cur] = [];
                                            }
                                            else elt[cur] = "";
                                    }
                                }
                            })
                        });
                        removeIndex.forEach(function(elt, index){
                            data.splice(elt - index, 1);
                        });
                    }
                    else {
                        for (i = 0; i < valueContent.records.length; i++){
                            data.push(valueContent.records[i][t_id]);
                        }
                    }
                }
                break;
            case "union":
                if (elt && elt.require && valueContent.value == 0) {
                    if (!no_alert) ModalElement.alert({message: "Chưa chọn " + elt.name});
                    return undefined;
                }
                data = {
                    value: valueContent.value,
                    detailUnion: {}
                };
                if (elt.detailUnion[data.value]){
                    for (var i = 0; i < elt.detailUnion[data.value].length; i++){
                        data.detailUnion[elt.detailUnion[data.value][i].localid] = generateData(formView.props[elt.detailUnion[data.value][i].localid], elt.detailUnion[data.value][i].type, elt.detailUnion[data.value][i]);
                        if (data.detailUnion[elt.detailUnion[data.value][i].localid] === undefined) return undefined;
                    }
                }
                break;
            default:

        }
        return data;
    };

    var verifyInfo = formView.verify();

    if (!verifyInfo.completed) {
        contentModule.handleIncomletedForm(formView, verifyInfo);
        return undefined;
    }

    var data = generateData(formView.props, typeid);

    return data;
};

contentModule.getValueOfForm2 = function(valueContent, typeid, typelists, currentPath, unionValue){
    var typeDict = {};
    var dict2 = {};
    typelists.forEach(function(elt, index){
        typeDict[elt.id] = index;
        dict2[elt.id] = elt;
    });
    var mainData = contentModule.getMainData(typeid, dict2);
    var primitiveTypeList = form_module.primitiveTypeList;
    var getType = function(index){
        var type = typelists[index].type;
        if (
            form_module.primitiveTypeList.indexOf(type) != -1
        ){
            type = typelists[index].type2;
        }
        return type;
    }
    if (valueContent && valueContent.constructor === Object && valueContent[typeid]) valueContent = valueContent[typeid];
    // var generateData = function(valueContent, typeid, elt){
        var data;
        var type;
        if (isNaN(parseInt(typeid, 10))) type = typeid;
        else type = getType(typeDict[typeid]);
        switch (type) {
            case "nation_city":
                if (currentPath && currentPath.require && valueContent.value.length < 2) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.value;
                break;
            case "position_list":
                if (currentPath && currentPath.require && valueContent.values.length == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "employee_list":
                if (currentPath && currentPath.require && valueContent.values.length == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "number":
            case "currency":
                if (currentPath && currentPath.require && valueContent === "") {
                    ModalElement.alert({message: "Chưa nhập " + currentPath.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "string":
            case "phonenumber":
            case "website":
            case "gps":
            case "note":
            case "html":
            case "variable_input":
            case "variable_textarea":
            case "email_address":
                valueContent = valueContent.trim();
                if (currentPath && currentPath.require && valueContent == "") {
                    absol.form.traversal(formView, function(path){
                        if (path.node["$" + currentPath.localid]) {
                            ModalElement.alert({
                                message: "Chưa nhập " + currentPath.name,
                                func: function(){
                                    path.node["$" + currentPath.localid].domElt.focus();
                                }
                            });
                            path.stop();
                        }
                    });
                    return undefined;
                }
                data = valueContent;
                break;
            case "date":
            case "datetime":
            case "datemonth":
            case "boolean":
                if (currentPath && currentPath.require && valueContent === null) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "hour_period":
                if (currentPath && currentPath.require && valueContent === null) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = {
                    dayOffset: valueContent.dayOffset,
                    duration: valueContent.duration
                };
                break;
            case "time":
                if (currentPath && currentPath.require && valueContent === null) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "user":
            case "geopos":
            case "member_of_position":
            case "member_of_employee":
            case "member_of_worktime_machines":
            case "member_of_assets":
            case "member_of_instruments_and_tools":
            case "member_of_warehouses":
            case "member_of_assets_instruments_and_tools":
            case "member_of_allowance_policy_groups":
            case "member_of_training_program_groups":
            case "member_of_leave_policy_groups":
            case "member_of_insurance_policy_groups":
            case "member_of_benefit_policy_groups":
            case "member_of_tax_policy_groups":
            case "member_of_bonus_policy_groups":
            case "member_of_overtime_policy_groups":
            case "member_of_offboarding_types":
            case "member_of_offboarding_reasons":
            case "member_of_work_flow_groups":
            case "member_of_work_flows":
            case "member_of_objects":
            case "member_of_lesson_categories":
            case "member_of_payroll_cycle":
            case "member_of_task":
            case "member_of_meeting":
            case "member_of_typelists":
            case "member_of_input_forms":
            case "member_of_output_forms":
            case "member_of_mobile_input_forms":
            case "member_of_mobile_output_forms":
            case "member_of_partner_class":
            case "member_of_partner":
            case "member_of_contact":
            case "member_of_trade_union_policy_groups":
            case "member_of_salary_policy_groups":
            case "member_of_other_liability_policy_groups":
            case "member_of_late_early_checkin_policy_groups":
            case "member_of_advance_payment_policy_groups":
            case "member_of_punishment_policy_groups":
            case "member_of_asset_category":
            case "member_of_instruments_and_tools_category":
            case "member_of_projects":
            case "member_of_insurance_policies":
            case "member_of_tax_policies":
            case "member_of_trade_union_policies":
            case "member_of_leave_policies":
            case "member_of_benefit_policies":
            case "member_of_allowance_policies":
            case "member_of_bonus_policies":
            case "member_of_overtime_policies":
            case "member_of_punishment_policies":
            case "member_of_advance_payment_policies":
            case "member_of_late_early_checkin_policies":
            case "member_of_salary_policies":
            case "member_of_other_liability_policies":
            case "member_of_employment_contract_types":
            case "member_of_nations":
            case "member_of_cities":
            case "member_of_religions":
            case "member_of_shifts":
            case "member_of_ethnics":
            case "member_of_document_types":
            case "member_of_document_groups":
            case "member_of_orgs":
            case "member_of_document_folders":
            case "member_of_template_groups":
            case "member_of_welcome_templates":
                if (currentPath && currentPath.require && valueContent.value == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.value;
                break;
            case "color_picker":
                if (currentPath && currentPath.require && valueContent == "") {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent;
                break;
            case "member_of_department":
                data = valueContent.value;
                break;
            case "files":
                data = valueContent.map(function(elt){
                    if (elt.id) return elt.id;
                    else return {
                        filename: elt.filename,
                        old_cd: elt.old_cd,
                        content_type: elt.content_type
                    };
                });
                break;
            case "enum":
            case "extends_enum":
                if (currentPath && currentPath.require && valueContent.value == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.value;
                break;
            case "enum_multi":
            case "extends_enum_multi":
                if (currentPath && currentPath.require && valueContent.values.length == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "userlist":
            case "members_of_shifts":
            case "members_of_locations":
            case "multiselect_offboarding_reasons":
            case "members_of_partner_class":
                if (currentPath && currentPath.require && valueContent.values.length == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "select_department_employee":
                if (currentPath && currentPath.require && valueContent.values.length == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent.values;
                break;
            case "any_file":
                if (currentPath && currentPath.require && valueContent === null) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = valueContent ? valueContent.id : 0;
                break;
            case "image_file":
                if (valueContent instanceof File) {
                    if (valueContent.type.startsWith("image")){
                        data = valueContent;
                    }
                }
                else {
                    data = valueContent.id;
                }
                break;
            case "structure":
                var t_value;
                var index = typeDict[typeid];
                var typeContent = typelists[index].content.details;
                data = {};
                for (var i = 0; i < typeContent.length; i++){
                    t_value = contentModule.getValueOfForm2(valueContent[typeContent[i].localid], typeContent[i].type, typelists, typeContent[i], valueContent);
                    if (t_value === undefined) return undefined;
                    if (t_value && t_value.detailUnion){
                        data[typeContent[i].localid] = t_value.value;
                        Object.assign(data, t_value.detailUnion);
                    }
                    else data[typeContent[i].localid] = t_value;
                }
                var returnValue = {
                    extrainfo: {},
                    files: []
                };
                var typeDataContent = [];
                var index = typeDict[typeid];
                while (typelists[index].type == "extends_structure") {
                    typeDataContent = typelists[index].content.details.concat(typeDataContent);
                    index = typeDict[typelists[index].content.typeof];
                }
                typeDataContent = typelists[index].content.details.concat(typeDataContent);
                typeDataContent.forEach(function(elt){
                    var type;
                    if (isNaN(parseInt(elt.type))) type = elt.type;
                    else type = getType(typeDict[elt.type])
                    if (type == "image_file") returnValue.files.push(data[elt.localid]);
                    if (type == "any_file") returnValue.files.push(data[elt.localid]);
                    if (elt.type == -64) returnValue.files = returnValue.files.concat(data[elt.localid]);
                    returnValue.files = returnValue.files.filter(function(elt){
                        return elt > 0;
                    });
                    if (mainData[elt.localid]){
                        returnValue[mainData[elt.localid]] = data[elt.localid];
                    }
                    else {
                        returnValue.extrainfo[elt.localid] = data[elt.localid];
                    }
                    if (type == "union") {
                        if (elt.detailUnion[data[elt.localid]]){
                            elt.detailUnion[data[elt.localid]].forEach(function(cur){
                                returnValue[mainData[cur.localid]] = data[cur.localid];
                            });
                        }
                    }
                });
                data = returnValue;
                break;
            case "extends_structure":
                var t_value;
                var index = typeDict[typeid];
                var typeContent = typelists[index].content;
                var t_id = typeContent.typeof;
                var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                while (typelists[typeDict[t_id]].type == "extends_structure"){
                    t_id = typelists[typeDict[t_id]].content.typeof;
                    content = typelists[typeDict[t_id]].content.details.concat(content)
                }
                data = {};
                for (var i = 0; i < content.length; i++){
                    t_value = contentModule.getValueOfForm2(valueContent[content[i].localid], content[i].type, typelists, content[i], valueContent);
                    if (t_value === undefined) return undefined;
                    if (t_value && t_value.detailUnion){
                        data[content[i].localid] = t_value.value;
                        Object.assign(data, t_value.detailUnion);
                    }
                    else data[content[i].localid] = t_value;
                }
                var returnValue = {
                    extrainfo: {},
                    files: []
                };
                var typeDataContent = [];
                var index = typeDict[typeid];
                while (typelists[index].type == "extends_structure") {
                    typeDataContent = typelists[index].content.details.concat(typeDataContent);
                    index = typeDict[typelists[index].content.typeof];
                }
                typeDataContent = typelists[index].content.details.concat(typeDataContent);
                typeDataContent.forEach(function(elt){
                    var type;
                    if (isNaN(parseInt(elt.type))) type = elt.type;
                    else type = getType(typeDict[elt.type])
                    if (type == "image_file") returnValue.files.push(data[elt.localid]);
                    if (type == "any_file") returnValue.files.push(data[elt.localid]);
                    if (elt.type == -64) returnValue.files = returnValue.files.concat(data[elt.localid]);
                    returnValue.files = returnValue.files.filter(function(elt){
                        return elt > 0;
                    });
                    if (mainData[elt.localid]){
                        returnValue[mainData[elt.localid]] = data[elt.localid];
                    }
                    else {
                        returnValue.extrainfo[elt.localid] = data[elt.localid];
                    }
                    if (type == "union") {
                        if (elt.detailUnion[data[elt.localid]]){
                            elt.detailUnion[data[elt.localid]].forEach(function(cur){
                                returnValue[mainData[cur.localid]] = data[cur.localid];
                            });
                        }
                    }
                });
                data = returnValue;
                break;
            case "array":
                data = [];
                var index = typeDict[typeid];
                var typeContent = typelists[index].content;
                var t_id = typeContent.typeof;
                var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                if (dataTypeOfArray == "advanced"){
                    var type = getType(typeDict[t_id]);
                    if (type == "structure" || type == "extends_structure"){
                        for (i = 0; i < valueContent.length; i++){
                            var x = contentModule.getValueOfForm2(valueContent[i], t_id, typelists);
                            if (x === undefined) return undefined;
                            if (x !== null) data.push(x);
                        }
                    }
                    else {
                        for (i = 0; i < valueContent.length; i++){
                            var x = contentModule.getValueOfForm2(valueContent[i][t_id], t_id, typelists);
                            if (x === undefined) return undefined;
                            if (x !== null) data.push(x);
                        }
                    }
                }
                else {
                    var type = getType(typeDict[t_id]);
                    if (type == "structure" || type == "extends_structure"){
                        var typeofarray = dict2[typeid].content.typeof;
                        var mainData = contentModule.getMainData(typeofarray, dict2);
                        if (!mainData) data = valueContent.records;
                        else {
                            var keys = Object.keys(mainData);
                            valueContent.records.forEach(function(record){
                                var x = EncodingClass.string.duplicate(record);
                                var cur = {};
                                keys.forEach(function(localid){
                                    cur[mainData[localid]] = x[localid];
                                    delete(x[localid]);
                                });
                                cur.extrainfo = x;
                                data.push(cur);
                            });
                        }
                    }
                    else {
                        for (i = 0; i < valueContent.records.length; i++){
                            data.push(valueContent.records[i][t_id]);
                        }
                    }
                }
                break;
            case "union":
                if (currentPath && currentPath.require && valueContent.value == 0) {
                    ModalElement.alert({message: "Chưa chọn " + currentPath.name});
                    return undefined;
                }
                data = {
                    value: valueContent.value,
                    detailUnion: {}
                };
                if (currentPath.detailUnion[data.value]){
                    for (var i = 0; i < currentPath.detailUnion[data.value].length; i++){
                        data.detailUnion[currentPath.detailUnion[data.value][i].localid] = contentModule.getValueOfForm2(unionValue[currentPath.detailUnion[data.value][i].localid], currentPath.detailUnion[data.value][i].type, typelists, currentPath.detailUnion[data.value][i]);
                        if (data.detailUnion[currentPath.detailUnion[data.value][i].localid] === undefined) return undefined;
                    }
                }
                break;
            default:

        }
        return data;
    // };
    // var data = generateData(valueContent, typeid);

    // if (data === undefined) return undefined;
};

contentModule.setValueOfForm = function(params){
    var valueContent, typeid, mainData, typelists;
    valueContent = params.valueContent;
    typeid = params.typeid;
    mainData = params.mainData;
    typelists = params.typelists;
    return new Promise(function(resolve, reject){
        valueContent = EncodingClass.string.duplicate(valueContent);
        var result;
        var typeDict = {};
        var dict2 = {};
        var primitiveTypeList = form_module.primitiveTypeList;
        var getType = function(index){
            var type = typelists[index].type;
            if (form_module.primitiveTypeList.indexOf(type) != -1){
                type = typelists[index].type2;
            }
            return type;
        }
        typelists.forEach(function(elt, index){
            typeDict[elt.id] = index;
            dict2[elt.id] = elt;
        });
        var posDict = {};
        var generateData = function(valueContent, typeid, currentPath){
            return new Promise(function(rs, rj){
                var data;
                var type;
                if (isNaN(parseInt(typeid, 10))) type = typeid;
                else type = getType(typeDict[typeid]);
                switch (type) {
                    case "nation_city":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "position_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "employee_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "string":
                    case "phonenumber":
                    case "gps":
                    case "website":
                    case "note":
                    case "html":
                    case "variable_input":
                    case "variable_textarea":
                    case "email_address":
                        data = valueContent !== undefined ? valueContent : "";
                        rs(data);
                        break;
                    case "month":
                    case "week":
                    case "datemonth":
                    case "time":
                        data = valueContent;
                        rs(data);
                        break;
                    case "boolean":
                        data = (valueContent === undefined || valueContent === null) ? currentPath.default : valueContent;
                        rs(data);
                        break;
                    case "date":
                        if (!valueContent && currentPath.default){
                            if (currentPath.default[0] == "custom") data = currentPath.default[1];
                            else if (currentPath.default[0] == "today") data = new Date();
                            else {
                                data = new Date();
                                data.setDate(1);
                            }
                        }
                        else data = valueContent;
                        rs(data);
                        break;
                    case "datetime":
                        if (!valueContent && currentPath.default){
                            if (currentPath.default[0] == "custom") data = currentPath.default[1];
                            else if (currentPath.default[0] == "today") {
                                data = new Date();
                                data.setHours(0);
                                data.setMilliseconds(0);
                                data.setSeconds(0);
                                data.setMinutes(0);
                            }
                            else {
                                data = new Date();
                                data.setDate(1);
                                data.setHours(0);
                                data.setMilliseconds(0);
                                data.setSeconds(0);
                                data.setMinutes(0);
                            }
                        }
                        else data = valueContent;
                        rs(data);
                        break;
                    case "number":
                    case "currency":
                        data = valueContent !== undefined ? valueContent == "" ? 0 : valueContent : 0;
                        rs(data);
                        break;
                    case "hour_period":
                        data = valueContent;
                        rs(data);
                        break;
                    case "userlist":
                    case "members_of_shifts":
                    case "members_of_partner_class":
                    case "multiselect_offboarding_reasons":
                    case "members_of_locations":
                    case "select_department_employee":
                        data = {
                            values: valueContent !== undefined ? valueContent : []
                        };
                        rs(data);
                        break;
                    case "member_of_position":
                        if (!valueContent || valueContent == 0){
                            rs({
                                value: 0
                            });
                        }
                        else {
                            Promise.all([data_module.loadOrgsList(), data_module.loadPositionById2(valueContent)]).then(function(result){
                                if (result[1].length == 0){
                                    rs({
                                        value: 0
                                    });
                                }
                                else {
                                    var subHost = {
                                        database: {}
                                    };
                                    contentModule.makeDatabaseContent(subHost, {orgs: result[0]});
                                    contentModule.makeOrgsIndex(subHost);
                                    var t = subHost.database.orgs.items[subHost.database.orgs.getIndex(result[1][0].orgid)];
                                    while (t.parentid != 0){
                                        t = subHost.database.orgs.items[subHost.database.orgs.getIndex(t.parentid)];
                                    }
                                    var data = {
                                        position: {
                                            value: valueContent
                                        },
                                        department: {
                                            value: result[1][0].orgid
                                        },
                                        company: {
                                            value: t.id
                                        }
                                    };
                                    rs(data);
                                }
                            });
                        }
                        break;
                    case "user":
                    case "member_of_worktime_machines":
                    case "geopos":
                    case "member_of_department":
                    case "member_of_employee":
                    case "member_of_template_groups":
                    case "member_of_welcome_templates":
                    case "member_of_assets":
                    case "member_of_instruments_and_tools":
                    case "member_of_assets_instruments_and_tools":
                    case "member_of_warehouses":
                    case "member_of_allowance_policy_groups":
                    case "member_of_bonus_policy_groups":
                    case "member_of_work_flow_groups":
                    case "member_of_work_flows":
                    case "member_of_payroll_cycle":
                    case "member_of_objects":
                    case "member_of_lesson_categories":
                    case "member_of_task":
                    case "member_of_meeting":
                    case "member_of_typelists":
                    case "member_of_input_forms":
                    case "member_of_output_forms":
                    case "member_of_mobile_input_forms":
                    case "member_of_mobile_output_forms":
                    case "member_of_partner_class":
                    case "member_of_partner":
                    case "member_of_contact":
                    case "member_of_trade_union_policy_groups":
                    case "member_of_overtime_policy_groups":
                    case "member_of_offboarding_types":
                    case "member_of_offboarding_reasons":
                    case "member_of_other_liability_policy_groups":
                    case "member_of_salary_policy_groups":
                    case "member_of_punishment_policy_groups":
                    case "member_of_asset_category":
                    case "member_of_instruments_and_tools_category":
                    case "member_of_projects":
                    case "member_of_tax_policy_groups":
                    case "member_of_advance_payment_policy_groups":
                    case "member_of_late_early_checkin_policy_groups":
                    case "member_of_benefit_policy_groups":
                    case "member_of_leave_policy_groups":
                    case "member_of_insurance_policy_groups":
                    case "member_of_training_program_groups":
                    case "member_of_shifts":
                    case "member_of_insurance_policies":
                    case "member_of_tax_policies":
                    case "member_of_trade_union_policies":
                    case "member_of_leave_policies":
                    case "member_of_benefit_policies":
                    case "member_of_allowance_policies":
                    case "member_of_bonus_policies":
                    case "member_of_overtime_policies":
                    case "member_of_punishment_policies":
                    case "member_of_advance_payment_policies":
                    case "member_of_late_early_checkin_policies":
                    case "member_of_salary_policies":
                    case "member_of_other_liability_policies":
                    case "member_of_employment_contract_types":
                    case "member_of_nations":
                    case "member_of_cities":
                    case "member_of_ethnics":
                    case "member_of_religions":
                    case "member_of_document_types":
                    case "member_of_document_groups":
                    case "member_of_document_folders":
                    case "member_of_orgs":
                        data = {
                            value: valueContent !== undefined ? valueContent : currentPath.default !== undefined ? currentPath.default : 0
                        };
                        rs(data);
                        break;
                    case "color_picker":
                        data = valueContent == "" ? "white" : valueContent;
                        rs(data);
                        break;
                    case "files":
                        if (!valueContent) rs([]);
                        else {
                            if (valueContent["-64"]) data = valueContent["-64"];
                            else data = valueContent;
                            data_module.makeFilesContent(data).then(function(result){
                                rs(result);
                            });
                        }
                        break;
                    case "any_file":
                    case "image_file":
                        data_module.makeImageContent(valueContent).then(function(result){
                            rs(result);
                        });
                        break;
                    case "enum":
                    case "extends_enum":
                        var index = typeDict[typeid];
                        var typeContent = typelists[index].content.details;
                        if (currentPath.default !== undefined) {
                            for (var i = 0; i < typeContent.length; i++) {
                                if (typeContent[i].value == currentPath.default) {
                                    currentPath.default = typeContent[i].localid;
                                    break;
                                }
                            }
                        }
                        data = {
                            value: valueContent !== undefined ? valueContent : currentPath.default !== undefined ? currentPath.default : 0
                            // list: lists
                        };
                        rs(data);
                        break;
                    case "enum_multi":
                    case "extends_enum_multi":
                        data = {
                            value: valueContent !== undefined ? valueContent : []
                            // list: lists
                        };
                        rs(data);
                        break;
                    case "structure":
                        if (!valueContent) rs({});
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content.details;
                            var t_data = {};
                            typeContent.forEach(function(elt){
                                t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                            });
                            Promise.all(Object.values(t_data)).then(function(result){
                                data = {};
                                Object.keys(t_data).forEach(function(elt, idx){
                                    // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                    //     data[elt] = result[idx].employee;
                                    //     data[elt + "_choose_department"] = result[idx].department;
                                    //     data[elt + "_choose_company"] = result[idx].company;
                                    // }
                                    // else if (result[idx] && result[idx].position && result[idx].department && result[idx].company){
                                    //     data[elt] = result[idx].position;
                                    //     data[elt + "_choose_department"] = result[idx].department;
                                    //     data[elt + "_choose_company"] = result[idx].company;
                                    // }
                                    // else
                                    if (result[idx] && result[idx].detailUnion){
                                        data[elt] = {
                                            value: result[idx].value
                                        };
                                        Object.assign(data, result[idx].detailUnion);
                                    }
                                    else data[elt] = result[idx];
                                });
                                rs(data);
                            }, function(message){rj(message);});
                        }
                        break;
                    case "extends_structure":
                        if (!valueContent) rs({});
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                            while (typelists[typeDict[t_id]].type == "extends_structure"){
                                t_id = typelists[typeDict[t_id]].content.typeof;
                                content = typelists[typeDict[t_id]].content.details.concat(content)
                            }
                            var t_data = {};
                            content.forEach(function(elt){
                                if (valueContent[elt.localid]) t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                            });
                            Promise.all(Object.values(t_data)).then(function(result){
                                data = {};
                                Object.keys(t_data).forEach(function(elt, idx){
                                    // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                    //     data[elt] = result[idx].employee;
                                    //     data[elt + "_choose_department"] = result[idx].department;
                                    //     data[elt + "_choose_company"] = result[idx].company;
                                    // }
                                    // else if (result[idx] && result[idx].position && result[idx].department && result[idx].company){
                                    //     data[elt] = result[idx].position;
                                    //     data[elt + "_choose_department"] = result[idx].department;
                                    //     data[elt + "_choose_company"] = result[idx].company;
                                    // }
                                    // else
                                    if (result[idx] && result[idx].detailUnion){
                                        data[elt] = {
                                            value: result[idx].value
                                        };
                                        Object.assign(data, result[idx].detailUnion);
                                    }
                                    else data[elt] = result[idx];
                                });
                                rs(data);
                            }, function(message){rj(message);});
                        }
                        break;
                    case "array":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            if (!t) t = [];
                            if (dataTypeOfArray == "advanced"){
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                        // data[typeid].push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        data[typeid] = result;
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                                else {
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        result.forEach(function(elt){
                                            var x = {};
                                            x[t_id] = elt;
                                            data[typeid].push(x);
                                        });
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                            }
                            else {
                                data[typeid] = {records: []};
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var typeofarray = dict2[typeid].content.typeof;
                                    var mainData = contentModule.getMainData(typeofarray, dict2);
                                    if (!mainData) data[typeid].records = t;
                                    else {
                                        var keys = Object.keys(mainData);
                                        t.forEach(function(record){
                                            var x = EncodingClass.string.duplicate(record);
                                            var cur = x.extrainfo;
                                            keys.forEach(function(localid){
                                                cur[localid] = x[mainData[localid]];
                                                if (typeof(cur[localid]) == "string") {
                                                    var tempDate = new Date(cur[localid]);
                                                    if (tempDate.toString() != "Invalid Date") {
                                                        cur[localid] = tempDate;
                                                    }
                                                }
                                            });
                                            data[typeid].records.push(cur);
                                        });
                                    }
                                }
                                else {
                                    t.forEach(function(elt){
                                        var x = {};
                                        x[t_id] = elt;
                                        data[typeid].records.push(x);
                                    });
                                }
                                rs(data);
                            }
                        }
                        break;
                    case "union":
                        data = {
                            value: valueContent,
                            detailUnion: {}
                        };
                        var t_data = {};
                        if (currentPath.detailUnion[data.value]){
                            currentPath.detailUnion[data.value].forEach(function(elt){
                                t_data[elt.localid] = generateData(result[elt.localid], elt.type, elt);
                                // t_data[elt.localid] = generateData(valueContent.detailUnion[elt.localid], elt.type, elt);
                            });
                        }
                        Promise.all(Object.values(t_data)).then(function(result){
                            Object.keys(t_data).forEach(function(elt, idx){
                                data.detailUnion[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    default:
                        rj("undefined type: " + type);
                }
            });
        };

        var typeDataContent = [];
        var index = typeDict[typeid];
        while (typelists[index].type == "extends_structure") {
            typeDataContent = typelists[index].content.details.concat(typeDataContent);
            index = typeDict[typelists[index].content.typeof];
        }
        typeDataContent = typelists[index].content.details.concat(typeDataContent);
        ////////////
        result = valueContent.extrainfo ? valueContent.extrainfo : {};
        if (mainData) {
            typeDataContent.forEach(function(elt){
                if (mainData[elt.localid]){
                    result[elt.localid] = valueContent[mainData[elt.localid]];
                    if (elt.type == "union") {
                        Object.keys(elt.detailUnion).forEach(function(cur){
                            elt.detailUnion[cur].forEach(function(ud){
                                result[ud.localid] = valueContent[mainData[ud.localid]];
                            });
                        });
                    }
                }
            });
        }

        generateData(result, typeid).then(function(result){
            resolve(result);
        }, function(message){console.log(message); reject(message);});
        ////////////
    });
};

contentModule.setValueOfUserForm = function(params){
    var valueContent, typeid, typelists;
    valueContent = params.valueContent;
    typeid = params.typeid;
    typelists = params.typelists;
    return new Promise(function(resolve, reject){
        valueContent = EncodingClass.string.duplicate(valueContent);
        var result;
        var typeDict = {};
        var dict2 = {};
        var primitiveTypeList = form_module.primitiveTypeList;
        var getType = function(index){
            var type = typelists[index].type;
            if (form_module.primitiveTypeList.indexOf(type) != -1){
                type = typelists[index].type2;
            }
            return type;
        }
        typelists.forEach(function(elt, index){
            typeDict[elt.id] = index;
            dict2[elt.id] = elt;
        });
        var posDict = {};
        var generateData = function(valueContent, typeid, currentPath){
            return new Promise(function(rs, rj){
                var data;
                var type;
                if (isNaN(parseInt(typeid, 10))) type = typeid;
                else type = getType(typeDict[typeid]);
                switch (type) {
                    case "nation_city":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "position_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "employee_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "string":
                    case "phonenumber":
                    case "gps":
                    case "website":
                    case "note":
                    case "html":
                    case "variable_input":
                    case "variable_textarea":
                    case "email_address":
                        data = valueContent !== undefined ? valueContent : "";
                        rs(data);
                        break;
                    case "month":
                    case "week":
                    case "datemonth":
                    case "time":
                        data = valueContent;
                        rs(data);
                        break;
                    case "boolean":
                        data = (valueContent === undefined || valueContent === null) ? currentPath.default : valueContent;
                        rs(data);
                        break;
                    case "date":
                        if (!valueContent && currentPath.default){
                            if (currentPath.default[0] == "custom") data = currentPath.default[1];
                            else if (currentPath.default[0] == "today") data = new Date();
                            else {
                                data = new Date();
                                data.setDate(1);
                            }
                        }
                        else data = valueContent;
                        rs(data);
                        break;
                    case "datetime":
                        if (!valueContent && currentPath.default){
                            if (currentPath.default[0] == "custom") data = currentPath.default[1];
                            else if (currentPath.default[0] == "today") {
                                data = new Date();
                                data.setHours(0);
                                data.setMilliseconds(0);
                                data.setSeconds(0);
                                data.setMinutes(0);
                            }
                            else {
                                data = new Date();
                                data.setDate(1);
                                data.setHours(0);
                                data.setMilliseconds(0);
                                data.setSeconds(0);
                                data.setMinutes(0);
                            }
                        }
                        else data = valueContent;
                        rs(data);
                        break;
                    case "number":
                    case "currency":
                        data = valueContent !== undefined ? valueContent == "" ? 0 : valueContent : 0;
                        rs(data);
                        break;
                    case "hour_period":
                        data = valueContent;
                        rs(data);
                        break;
                    case "userlist":
                    case "members_of_shifts":
                    case "members_of_partner_class":
                    case "multiselect_offboarding_reasons":
                    case "members_of_locations":
                    case "select_department_employee":
                        data = {
                            values: valueContent !== undefined ? valueContent : []
                        };
                        rs(data);
                        break;
                    case "member_of_position":
                        if (!valueContent || valueContent == 0){
                            rs({
                                value: 0
                            });
                        }
                        else {
                            Promise.all([data_module.loadOrgsList(), data_module.loadPositionById2(valueContent)]).then(function(result){
                                if (result[1].length == 0){
                                    rs({
                                        value: 0
                                    });
                                }
                                else {
                                    var subHost = {
                                        database: {}
                                    };
                                    contentModule.makeDatabaseContent(subHost, {orgs: result[0]});
                                    contentModule.makeOrgsIndex(subHost);
                                    var t = subHost.database.orgs.items[subHost.database.orgs.getIndex(result[1][0].orgid)];
                                    while (t.parentid != 0){
                                        t = subHost.database.orgs.items[subHost.database.orgs.getIndex(t.parentid)];
                                    }
                                    var data = {
                                        position: {
                                            value: valueContent
                                        },
                                        department: {
                                            value: result[1][0].orgid
                                        },
                                        company: {
                                            value: t.id
                                        }
                                    };
                                    rs(data);
                                }
                            });
                        }
                        break;
                    case "geopos":
                    case "user":
                    case "member_of_department":
                    case "member_of_employee":
                    case "member_of_template_groups":
                    case "member_of_welcome_templates":
                    case "member_of_worktime_machines":
                    case "member_of_assets":
                    case "member_of_instruments_and_tools":
                    case "member_of_assets_instruments_and_tools":
                    case "member_of_warehouses":
                    case "member_of_allowance_policy_groups":
                    case "member_of_bonus_policy_groups":
                    case "member_of_work_flow_groups":
                    case "member_of_work_flows":
                    case "member_of_objects":
                    case "member_of_payroll_cycle":
                    case "member_of_lesson_categories":
                    case "member_of_task":
                    case "member_of_meeting":
                    case "member_of_typelists":
                    case "member_of_input_forms":
                    case "member_of_output_forms":
                    case "member_of_mobile_input_forms":
                    case "member_of_mobile_output_forms":
                    case "member_of_partner_class":
                    case "member_of_partner":
                    case "member_of_contact":
                    case "member_of_other_liability_policy_groups":
                    case "member_of_trade_union_policy_groups":
                    case "member_of_overtime_policy_groups":
                    case "member_of_offboarding_types":
                    case "member_of_offboarding_reasons":
                    case "member_of_salary_policy_groups":
                    case "member_of_punishment_policy_groups":
                    case "member_of_asset_category":
                    case "member_of_instruments_and_tools_category":
                    case "member_of_projects":
                    case "member_of_tax_policy_groups":
                    case "member_of_advance_payment_policy_groups":
                    case "member_of_late_early_checkin_policy_groups":
                    case "member_of_benefit_policy_groups":
                    case "member_of_leave_policy_groups":
                    case "member_of_insurance_policy_groups":
                    case "member_of_training_program_groups":
                    case "member_of_shifts":
                    case "member_of_insurance_policies":
                    case "member_of_tax_policies":
                    case "member_of_trade_union_policies":
                    case "member_of_leave_policies":
                    case "member_of_benefit_policies":
                    case "member_of_allowance_policies":
                    case "member_of_bonus_policies":
                    case "member_of_overtime_policies":
                    case "member_of_punishment_policies":
                    case "member_of_advance_payment_policies":
                    case "member_of_late_early_checkin_policies":
                    case "member_of_salary_policies":
                    case "member_of_other_liability_policies":
                    case "member_of_employment_contract_types":
                    case "member_of_nations":
                    case "member_of_cities":
                    case "member_of_ethnics":
                    case "member_of_religions":
                    case "member_of_document_types":
                    case "member_of_document_groups":
                    case "member_of_document_folders":
                    case "member_of_orgs":
                        data = {
                            value: valueContent !== undefined ? valueContent : 0
                        };
                        rs(data);
                        break;
                    case "color_picker":
                        data = valueContent == "" ? "white" : valueContent;
                        rs(data);
                        break;
                    case "files":
                        if (!valueContent) rs([]);
                        else {
                            if (valueContent["-64"]) data = valueContent["-64"];
                            else data = valueContent;
                            data_module.makeFilesContent(data).then(function(result){
                                rs(result);
                            });
                        }
                        break;
                    case "any_file":
                    case "image_file":
                        data_module.makeImageContent(valueContent).then(function(result){
                            rs(result);
                        });
                        break;
                    case "enum":
                    case "extends_enum":
                        data = {
                            value: valueContent !== undefined ? valueContent : 0,
                            // list: lists
                        };
                        rs(data);
                        break;
                    case "enum_multi":
                    case "extends_enum_multi":
                        data = {
                            values: valueContent !== undefined ? valueContent : []
                            // list: lists
                        };
                        rs(data);
                        break;
                    case "structure":
                        if (!valueContent) rs({});
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content.details;
                            var t_data = {};
                            typeContent.forEach(function(elt){
                                t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                            });
                            Promise.all(Object.values(t_data)).then(function(result){
                                data = {};
                                Object.keys(t_data).forEach(function(elt, idx){
                                    if (result[idx] && result[idx].detailUnion){
                                        data[elt] = {
                                            value: result[idx].value
                                        };
                                        Object.assign(data, result[idx].detailUnion);
                                    }
                                    else data[elt] = result[idx];
                                });
                                rs(data);
                            }, function(message){rj(message);});
                        }
                        break;
                    case "extends_structure":
                        if (!valueContent) rs({});
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                            while (typelists[typeDict[t_id]].type == "extends_structure"){
                                t_id = typelists[typeDict[t_id]].content.typeof;
                                content = typelists[typeDict[t_id]].content.details.concat(content)
                            }
                            var t_data = {};
                            content.forEach(function(elt){
                                if (valueContent[elt.localid]) t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                            });
                            Promise.all(Object.values(t_data)).then(function(result){
                                data = {};
                                Object.keys(t_data).forEach(function(elt, idx){
                                    if (result[idx] && result[idx].detailUnion){
                                        data[elt] = {
                                            value: result[idx].value
                                        };
                                        Object.assign(data, result[idx].detailUnion);
                                    }
                                    else data[elt] = result[idx];
                                });
                                rs(data);
                            }, function(message){rj(message);});
                        }
                        break;
                    case "array":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            if (!t) t  = [];
                            if (dataTypeOfArray == "advanced"){
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        data[typeid] = result;
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                                else {
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        result.forEach(function(elt){
                                            var x = {};
                                            x[t_id] = elt;
                                            data[typeid].push(x);
                                        });
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                            }
                            else {
                                data[typeid] = {records: []};
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var typeofarray = dict2[typeid].content.typeof;
                                    t.forEach((item, i) => {
                                        var keys = Object.keys(item);
                                        keys.forEach(function(localid){
                                            if (typeof(item[localid]) == "string") {
                                                var tempDate = new Date(item[localid]);
                                                if (tempDate.toString() != "Invalid Date") {
                                                    item[localid] = tempDate;
                                                }
                                            }
                                        });
                                    });

                                    data[typeid].records = t;
                                }
                                else {
                                    t.forEach(function(elt){
                                        var x = {};
                                        x[t_id] = elt;
                                        data[typeid].records.push(x);
                                    });
                                }
                                rs(data);
                            }
                        }
                        break;
                    case "union":
                        data = {
                            value: valueContent,
                            detailUnion: {}
                        };
                        var t_data = {};
                        if (currentPath.detailUnion[data.value]){
                            currentPath.detailUnion[data.value].forEach(function(elt){
                                t_data[elt.localid] = generateData(result[elt.localid], elt.type, elt);
                            });
                        }
                        Promise.all(Object.values(t_data)).then(function(result){
                            Object.keys(t_data).forEach(function(elt, idx){
                                data.detailUnion[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    default:
                        rj("undefined type: " + type);
                }
            });
        };

        // var typeDataContent = [];
        // var index = typeDict[typeid];
        // while (typelists[index].type == "extends_structure") {
        //     typeDataContent = typelists[index].content.details.concat(typeDataContent);
        //     index = typeDict[typelists[index].content.typeof];
        // }
        // typeDataContent = typelists[index].content.details.concat(typeDataContent);
        ////////////
        // result = valueContent.extrainfo ? valueContent.extrainfo : {};

        generateData(valueContent, typeid).then(function(result){
            resolve(result);
        }, function(message){console.log(message); reject(message);});
        ////////////
    });
};

contentModule.setValueOfForm2 = function(params){
    return new Promise(function(rs, rj){
        var valueContent, typeid, mainData, typelists;
        valueContent = params.valueContent;
        typeid = params.typeid;
        typelists = params.typelists;
        valueContent = EncodingClass.string.duplicate(valueContent);
        var result;
        var typeDict = {};
        var dict2 = {};
        var primitiveTypeList = form_module.primitiveTypeList;
        var getType = function(index){
            var type = typelists[index].type;
            if (
                form_module.primitiveTypeList.indexOf(type) != -1
            ){
                type = typelists[index].type2;
            }
            return type;
        }
        typelists.forEach(function(elt, index){
            typeDict[elt.id] = index;
            dict2[elt.id] = elt;
        });
        mainData = contentModule.getMainData(typeid, dict2);
        var posDict = {};
        // var generateData = function(valueContent, typeid, currentPath){
        //     return new Promise(function(rs, rj){
                var data;
                var type;
                if (isNaN(parseInt(typeid, 10))) type = typeid;
                else type = getType(typeDict[typeid]);
                switch (type) {
                    case "nation_city":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "position_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "employee_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "string":
                    case "phonenumber":
                    case "website":
                    case "gps":
                    case "note":
                    case "html":
                    case "variable_input":
                    case "variable_textarea":
                    case "email_address":
                        data = valueContent !== undefined ? valueContent : "";
                        rs(data);
                        break;
                    case "datemonth":
                    case "time":
                        data = valueContent;
                        rs(data);
                        break;
                    case "boolean":
                        data = (valueContent === undefined || valueContent === null) ? currentPath.default : valueContent;
                        rs(data);
                        break;
                    case "date":
                        if (!valueContent && currentPath.default){
                            if (currentPath.default[0] == "custom") data = currentPath.default[1];
                            else if (currentPath.default[0] == "today") data = new Date();
                            else {
                                data = new Date();
                                data.setDate(1);
                            }
                        }
                        else data = valueContent;
                        rs(data);
                        break;
                    case "datetime":
                        if (!valueContent && currentPath.default){
                            if (currentPath.default[0] == "custom") data = currentPath.default[1];
                            else if (currentPath.default[0] == "today") {
                                data = new Date();
                                data.setHours(0);
                                data.setMilliseconds(0);
                                data.setSeconds(0);
                                data.setMinutes(0);
                            }
                            else {
                                data = new Date();
                                data.setDate(1);
                                data.setHours(0);
                                data.setMilliseconds(0);
                                data.setSeconds(0);
                                data.setMinutes(0);
                            }
                        }
                        else data = valueContent;
                        rs(data);
                        break;
                    case "number":
                    case "currency":
                        data = valueContent !== undefined ? valueContent == "" ? 0 : valueContent : 0;
                        rs(data);
                        break;
                    case "hour_period":
                        data = valueContent;
                        rs(data);
                        break;
                    case "userlist":
                    case "members_of_shifts":
                    case "members_of_partner_class":
                    case "multiselect_offboarding_reasons":
                    case "members_of_locations":
                    case "select_department_employee":
                        data = {
                            values: valueContent !== undefined ? valueContent : []
                        };
                        rs(data);
                        break;
                    case "member_of_position":
                        if (!valueContent || valueContent == 0){
                            rs({
                                value: 0
                            });
                        }
                        else {
                            Promise.all([data_module.loadOrgsList(), data_module.loadPositionById2(valueContent)]).then(function(result){
                                if (result[1].length == 0){
                                    rs({
                                        value: 0
                                    });
                                }
                                else {
                                    var subHost = {
                                        database: {}
                                    };
                                    contentModule.makeDatabaseContent(subHost, {orgs: result[0]});
                                    contentModule.makeOrgsIndex(subHost);
                                    var t = subHost.database.orgs.items[subHost.database.orgs.getIndex(result[1][0].orgid)];
                                    while (t.parentid != 0){
                                        t = subHost.database.orgs.items[subHost.database.orgs.getIndex(t.parentid)];
                                    }
                                    var data = {
                                        position: {
                                            value: valueContent
                                        },
                                        department: {
                                            value: result[1][0].orgid
                                        },
                                        company: {
                                            value: t.id
                                        }
                                    };
                                    rs(data);
                                }
                            });
                        }
                        break;
                    case "member_of_employee":
                    case "user":
                    case "geopos":
                    case "member_of_department":
                    case "member_of_template_groups":
                    case "member_of_welcome_templates":
                    case "member_of_worktime_machines":
                    case "member_of_assets":
                    case "member_of_instruments_and_tools":
                    case "member_of_assets_instruments_and_tools":
                    case "member_of_warehouses":
                    case "member_of_allowance_policy_groups":
                    case "member_of_bonus_policy_groups":
                    case "member_of_work_flow_groups":
                    case "member_of_work_flows":
                    case "member_of_objects":
                    case "member_of_payroll_cycle":
                    case "member_of_lesson_categories":
                    case "member_of_task":
                    case "member_of_meeting":
                    case "member_of_typelists":
                    case "member_of_input_forms":
                    case "member_of_output_forms":
                    case "member_of_mobile_input_forms":
                    case "member_of_mobile_output_forms":
                    case "member_of_partner_class":
                    case "member_of_partner":
                    case "member_of_contact":
                    case "member_of_other_liability_policy_groups":
                    case "member_of_trade_union_policy_groups":
                    case "member_of_overtime_policy_groups":
                    case "member_of_offboarding_types":
                    case "member_of_offboarding_reasons":
                    case "member_of_salary_policy_groups":
                    case "member_of_punishment_policy_groups":
                    case "member_of_asset_category":
                    case "member_of_instruments_and_tools_category":
                    case "member_of_projects":
                    case "member_of_tax_policy_groups":
                    case "member_of_advance_payment_policy_groups":
                    case "member_of_late_early_checkin_policy_groups":
                    case "member_of_benefit_policy_groups":
                    case "member_of_leave_policy_groups":
                    case "member_of_insurance_policy_groups":
                    case "member_of_training_program_groups":
                    case "member_of_shifts":
                    case "member_of_insurance_policies":
                    case "member_of_tax_policies":
                    case "member_of_trade_union_policies":
                    case "member_of_leave_policies":
                    case "member_of_benefit_policies":
                    case "member_of_allowance_policies":
                    case "member_of_bonus_policies":
                    case "member_of_overtime_policies":
                    case "member_of_punishment_policies":
                    case "member_of_advance_payment_policies":
                    case "member_of_late_early_checkin_policies":
                    case "member_of_salary_policies":
                    case "member_of_other_liability_policies":
                    case "member_of_employment_contract_types":
                    case "member_of_nations":
                    case "member_of_cities":
                    case "member_of_ethnics":
                    case "member_of_religions":
                    case "member_of_document_types":
                    case "member_of_document_groups":
                    case "member_of_document_folders":
                    case "member_of_orgs":
                        data = {
                            value: valueContent !== undefined ? valueContent : 0
                        };
                        rs(data);
                        break;
                    case "color_picker":
                        data = valueContent == "" ? "white" : valueContent;
                        rs(data);
                        break;
                    case "files":
                        if (!valueContent) rs([]);
                        else {
                            if (valueContent["-64"]) data = valueContent["-64"];
                            else data = valueContent;
                            data_module.makeFilesContent(data).then(function(result){
                                rs(result);
                            });
                        }
                        break;
                    case "any_file":
                    case "image_file":
                        data_module.makeImageContent(valueContent).then(function(result){
                            rs(result);
                        });
                        break;
                    case "enum":
                    case "extends_enum":
                        data = {
                            value: valueContent !== undefined ? valueContent : 0
                        };
                        rs(data);
                        break;
                    case "enum_multi":
                    case "extends_enum_multi":
                        data = {
                            value: valueContent !== undefined ? valueContent : []
                        };
                        rs(data);
                        break;
                    case "structure":
                        if (!valueContent) rs({});
                        else {
                            var typeDataContent = [];
                            var index = typeDict[typeid];
                            while (typelists[index].type == "extends_structure") {
                                typeDataContent = typelists[index].content.details.concat(typeDataContent);
                                index = typeDict[typelists[index].content.typeof];
                            }
                            typeDataContent = typelists[index].content.details.concat(typeDataContent);
                            ////////////
                            var t_content = valueContent.extrainfo ? valueContent.extrainfo : {};
                            typeDataContent.forEach(function(elt){
                                if (mainData[elt.localid]){
                                    t_content[elt.localid] = valueContent[mainData[elt.localid]];
                                    if (elt.type == "union") {
                                        Object.keys(elt.detailUnion).forEach(function(cur){
                                            elt.detailUnion[cur].forEach(function(ud){
                                                t_content[ud.localid] = valueContent[mainData[ud.localid]];
                                            });
                                        });
                                    }
                                }
                            });
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content.details;
                            var t_data = {};
                            typeContent.forEach(function(elt){
                                var t_params = {
                                    valueContent: t_content[elt.localid],
                                    typeid: elt.type,
                                    typelists: typelists,
                                    currentPath: elt
                                };
                                if (elt.type == "union") t_params.unionValue = t_content;
                                t_data[elt.localid] = contentModule.setValueOfForm2(t_params);
                            });
                            Promise.all(Object.values(t_data)).then(function(result){
                                data = {};
                                Object.keys(t_data).forEach(function(elt, idx){
                                    // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                    //     data[elt] = result[idx].employee;
                                    //     data[elt + "_choose_department"] = result[idx].department;
                                    //     data[elt + "_choose_company"] = result[idx].company;
                                    // }
                                    // else
                                    if (result[idx] && result[idx].detailUnion){
                                        data[elt] = {
                                            value: result[idx].value
                                        };
                                        var t_detailUnion = {};
                                        Object.keys(result[idx].detailUnion).forEach(function(cur){
                                            // if (result[idx].detailUnion[cur] && result[idx].detailUnion[cur].employee && result[idx].detailUnion[cur].department && result[idx].detailUnion[cur].company){
                                            //     t_detailUnion[cur] = result[idx].detailUnion[cur].employee;
                                            //     t_detailUnion[cur + "_choose_department"] = result[idx].detailUnion[cur].department;
                                            //     t_detailUnion[cur + "_choose_company"] = result[idx].detailUnion[cur].company;
                                            // }
                                            // else
                                            t_detailUnion[cur] = result[idx].detailUnion[cur];
                                        });
                                        Object.assign(data, t_detailUnion);
                                        // Object.assign(data, result[idx].detailUnion);
                                    }
                                    else data[elt] = result[idx];
                                });
                                rs(data);
                            }, function(message){rj(message);});
                        }
                        break;
                    case "extends_structure":
                        if (!valueContent) rs({});
                        else {
                            var typeDataContent = [];
                            var index = typeDict[typeid];
                            while (typelists[index].type == "extends_structure") {
                                typeDataContent = typelists[index].content.details.concat(typeDataContent);
                                index = typeDict[typelists[index].content.typeof];
                            }
                            typeDataContent = typelists[index].content.details.concat(typeDataContent);
                            ////////////
                            var t_content = valueContent.extrainfo ? valueContent.extrainfo : {};
                            typeDataContent.forEach(function(elt){
                                if (mainData[elt.localid]){
                                    t_content[elt.localid] = valueContent[mainData[elt.localid]];
                                    if (elt.type == "union") {
                                        Object.keys(elt.detailUnion).forEach(function(cur){
                                            elt.detailUnion[cur].forEach(function(ud){
                                                t_content[ud.localid] = valueContent[mainData[ud.localid]];
                                            });
                                        });
                                    }
                                }
                            });
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                            while (typelists[typeDict[t_id]].type == "extends_structure"){
                                t_id = typelists[typeDict[t_id]].content.typeof;
                                content = typelists[typeDict[t_id]].content.details.concat(content)
                            }
                            var t_data = {};
                            content.forEach(function(elt){
                                var t_params = {
                                    valueContent: t_content[elt.localid],
                                    typeid: elt.type,
                                    typelists: typelists,
                                    currentPath: elt
                                };
                                if (elt.type == "union") t_params.unionValue = t_content;
                                if (t_content[elt.localid]) t_data[elt.localid] = contentModule.setValueOfForm2(t_params);
                            });
                            Promise.all(Object.values(t_data)).then(function(result){
                                data = {};
                                Object.keys(t_data).forEach(function(elt, idx){
                                    // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                    //     data[elt] = result[idx].employee;
                                    //     data[elt + "_choose_department"] = result[idx].department;
                                    //     data[elt + "_choose_company"] = result[idx].company;
                                    // }
                                    // else
                                    if (result[idx] && result[idx].detailUnion){
                                        data[elt] = {
                                            value: result[idx].value
                                        };
                                        var t_detailUnion = {};
                                        Object.keys(result[idx].detailUnion).forEach(function(cur){
                                            // if (result[idx].detailUnion[cur] && result[idx].detailUnion[cur].employee && result[idx].detailUnion[cur].department && result[idx].detailUnion[cur].company){
                                            //     t_detailUnion[cur] = result[idx].detailUnion[cur].employee;
                                            //     t_detailUnion[cur + "_choose_department"] = result[idx].detailUnion[cur].department;
                                            //     t_detailUnion[cur + "_choose_company"] = result[idx].detailUnion[cur].company;
                                            // }
                                            // else
                                            t_detailUnion[cur] = result[idx].detailUnion[cur];
                                        });
                                        Object.assign(data, t_detailUnion);
                                        // Object.assign(data, result[idx].detailUnion);
                                    }
                                    else data[elt] = result[idx];
                                });
                                rs(data);
                            }, function(message){rj(message);});
                        }
                        break;
                    case "array":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);{
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            if (dataTypeOfArray == "advanced"){
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(contentModule.setValueOfForm2({
                                            valueContent: elt,
                                            typeid: t_id,
                                            typelists: typelists
                                        }));
                                        // data[typeid].push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        data[typeid] = result;
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                                else {
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(contentModule.setValueOfForm2({
                                            valueContent: elt,
                                            typeid: t_id,
                                            typelists: typelists
                                        }));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        result.forEach(function(elt){
                                            var x = {};
                                            x[t_id] = elt;
                                            data[typeid].push(x);
                                        });
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                            }
                            else {
                                data[typeid] = {records: []};
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var typeofarray = dict2[typeid].content.typeof;
                                    var mainData = contentModule.getMainData(typeofarray, dict2);
                                    if (!mainData) data[typeid].records = t;
                                    else {
                                        var keys = Object.keys(mainData);
                                        t.forEach(function(record){
                                            var x = EncodingClass.string.duplicate(record);
                                            var cur = x.extrainfo;
                                            keys.forEach(function(localid){
                                                cur[localid] = x[mainData[localid]];
                                            });
                                            data[typeid].records.push(cur);
                                        });
                                    }
                                }
                                else {
                                    t.forEach(function(elt){
                                        var x = {};
                                        x[t_id] = elt;
                                        data[typeid].records.push(x);
                                    });
                                }
                                rs(data);
                            }
                        }
                        break;
                    case "union":
                        data = {
                            value: valueContent,
                            detailUnion: {}
                        };
                        var t_data = {};
                        var currentPath = params.currentPath;
                        if (currentPath.detailUnion[data.value]){
                            currentPath.detailUnion[data.value].forEach(function(elt){
                                t_data[elt.localid] = contentModule.setValueOfForm2({
                                    valueContent: params.unionValue[elt.localid],
                                    typeid: elt.type,
                                    typelists: typelists,
                                    currentPath: elt
                                });
                                // t_data[elt.localid] = generateData(valueContent.detailUnion[elt.localid], elt.type, elt);
                            });
                        }
                        Promise.all(Object.values(t_data)).then(function(result){
                            Object.keys(t_data).forEach(function(elt, idx){
                                data.detailUnion[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    default:
                        rj("undefined type: " + type);
                }
        //     });
        // };



        // generateData(result, typeid).then(function(result){
        //     resolve(result);
        // }, function(message){console.log(message); reject(message);});
        ////////////
    });
};

contentModule.setValueOfOutputForm = function(params){
    var valueContent, typeid, mainData, typelists;
    valueContent = params.valueContent;
    typeid = params.typeid;
    mainData = params.mainData;
    typelists = params.typelists;
    return new Promise(function(resolve, reject){
        valueContent = EncodingClass.string.duplicate(valueContent);
        var result;
        var typeDict = {};
        var dict2 = {};
        var primitiveTypeList = form_module.primitiveTypeList;
        var getType = function(index){
            var type = typelists[index].type;
            if (
                form_module.primitiveTypeList.indexOf(type) != -1
            ){
                type = typelists[index].type2;
            }
            return type;
        }
        typelists.forEach(function(elt, index){
            typeDict[elt.id] = index;
            dict2[elt.id] = elt;
        });
        var posDict = {};
        var generateData = function(valueContent, typeid, currentPath){
            return new Promise(function(rs, rj){
                var data;
                var type;
                if (isNaN(parseInt(typeid, 10))) type = typeid;
                else type = getType(typeDict[typeid]);
                switch (type) {
                    case "nation_city":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "position_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "employee_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "string":
                    case "phonenumber":
                    case "website":
                    case "gps":
                    case "note":
                    case "html":
                    case "variable_input":
                    case "variable_textarea":
                    case "time":
                    case "email_address":
                    case "boolean":
                    case "month":
                    case "week":
                        data = valueContent;
                        rs(data);
                        break;
                    case "number":
                    case "currency":
                        data = valueContent == "" ? 0 : parseInt(valueContent);
                        rs(data);
                        break;
                    case "date":
                        // data = contentModule.getDateView(valueContent);
                        data = valueContent;
                        rs(data);
                        break;
                    case "datetime":
                        // data = contentModule.getDateTimeView(valueContent);
                        data = valueContent;
                        rs(data);
                        break;
                    case "datemonth":
                        if (valueContent){
                            if (valueContent.month !== undefined && valueContent.month !== null){
                                var month = valueContent.month + 1;
                                if (month < 10) month = "0" + month;
                                var date = valueContent.date;
                                if (date < 10) date = "0" + date;
                                data = date + "/" + month;
                            }
                            else {
                                data = "";
                            }
                        }
                        else {
                            data = "";
                        }
                        rs(data);
                        break;
                    case "hour_period":
                        // data = contentModule.getDateTimeView(valueContent.dayOffset) + " - " + contentModule.getDateTimeView(valueContent.dayOffset + valueContent.duration);
                        data = valueContent;
                        rs(data);
                        break;
                    case "user":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "userlist":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "members_of_shifts":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "members_of_partner_class":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "members_of_locations":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "select_department_employee":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "geopos":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_department":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_position":
                        if (!valueContent || valueContent == 0){
                            rs({
                                value: 0
                            });
                        }
                        else {
                            Promise.all([data_module.loadOrgsList(), data_module.loadPositionById2(valueContent)]).then(function(result){
                                if (result[1].length == 0){
                                    rs({
                                        value: 0
                                    });
                                }
                                else {
                                    var subHost = {
                                        database: {}
                                    };
                                    contentModule.makeDatabaseContent(subHost, {orgs: result[0]});
                                    contentModule.makeOrgsIndex(subHost);
                                    var t = subHost.database.orgs.items[subHost.database.orgs.getIndex(result[1][0].orgid)];
                                    while (t.parentid != 0){
                                        t = subHost.database.orgs.items[subHost.database.orgs.getIndex(t.parentid)];
                                    }
                                    var data = {
                                        position: {
                                            value: valueContent
                                        },
                                        department: {
                                            value: result[1][0].orgid
                                        },
                                        company: {
                                            value: t.id
                                        }
                                    };
                                    rs(data);
                                }
                            });
                        }
                        break;
                    case "member_of_employee":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_template_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_welcome_templates":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_worktime_machines":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_assets":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_instruments_and_tools":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_assets_instruments_and_tools":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_warehouses":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_allowance_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_bonus_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_work_flow_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_work_flows":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_objects":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_payroll_cycle":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_lesson_categories":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_task":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_meeting":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_typelists":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_input_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_output_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_mobile_input_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_mobile_output_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "color_picker":
                        data = valueContent == "" ? "white" : valueContent;
                        rs(data);
                        break;
                    case "member_of_partner_class":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_partner":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_contact":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_other_liability_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_trade_union_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_overtime_policy_groups":
                    case "member_of_offboarding_types":
                    case "member_of_offboarding_reasons":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "multiselect_offboarding_reasons":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_salary_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_punishment_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_asset_category":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_instruments_and_tools_category":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_projects":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_tax_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_advance_payment_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_late_early_checkin_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_benefit_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_leave_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_insurance_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_training_program_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_shifts":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_insurance_policies":
                    case "member_of_tax_policies":
                    case "member_of_trade_union_policies":
                    case "member_of_leave_policies":
                    case "member_of_benefit_policies":
                    case "member_of_allowance_policies":
                    case "member_of_bonus_policies":
                    case "member_of_overtime_policies":
                    case "member_of_punishment_policies":
                    case "member_of_advance_payment_policies":
                    case "member_of_late_early_checkin_policies":
                    case "member_of_salary_policies":
                    case "member_of_other_liability_policies":
                    case "member_of_employment_contract_types":
                    case "member_of_nations":
                    case "member_of_cities":
                    case "member_of_ethnics":
                    case "member_of_religions":
                    case "member_of_document_types":
                    case "member_of_document_groups":
                    case "member_of_document_folders":
                    case "member_of_orgs":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "files":
                        if (!valueContent) rs([]);
                        else {
                            if (valueContent["-64"]) data = valueContent["-64"];
                            else data = valueContent;
                            data_module.makeFilesContent(data).then(function(result){
                                rs(result);
                            });
                        }
                        break;
                    case "any_file":
                    case "image_file":
                        data_module.makeImageContent(valueContent).then(function(result){
                            rs(result);
                        });
                        break;
                    case "extends_enum":
                    case "enum":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "enum_multi":
                    case "extends_enum_multi":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "structure":
                        var index = typeDict[typeid];
                        var typeContent = typelists[index].content.details;
                        var t_data = {};
                        typeContent.forEach(function(elt){
                            t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                        });
                        Promise.all(Object.values(t_data)).then(function(result){
                            // data = {};
                            // Object.keys(t_data).forEach(function(elt, idx){
                            //     if (result[idx] && result[idx].detailUnion){
                            //         data[elt] = {
                            //             value: result[idx].value
                            //         };
                            //         Object.assign(data, result[idx].detailUnion);
                            //     }
                            //     else data[elt] = result[idx];
                            // });
                            // rs(data);
                            data = {};
                            Object.keys(t_data).forEach(function(elt, idx){
                                // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].employee;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else if (result[idx] && result[idx].position && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].position;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else
                                if (result[idx] && result[idx].detailUnion){
                                    data[elt] = {
                                        value: result[idx].value
                                    };
                                    Object.assign(data, result[idx].detailUnion);
                                }
                                else data[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    case "extends_structure":
                        var index = typeDict[typeid];
                        var typeContent = typelists[index].content;
                        var t_id = typeContent.typeof;
                        var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                        while (typelists[typeDict[t_id]].type == "extends_structure"){
                            t_id = typelists[typeDict[t_id]].content.typeof;
                            content = typelists[typeDict[t_id]].content.details.concat(content)
                        }
                        var t_data = {};
                        content.forEach(function(elt){
                            if (valueContent[elt.localid]) t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                        });
                        Promise.all(Object.values(t_data)).then(function(result){
                            // data = {};
                            // Object.keys(t_data).forEach(function(elt, idx){
                            //     if (result[idx] && result[idx].detailUnion){
                            //         data[elt] = {
                            //             value: result[idx].value
                            //         };
                            //         Object.assign(data, result[idx].detailUnion);
                            //     }
                            //     else data[elt] = result[idx];
                            // });
                            // rs(data);
                            data = {};
                            Object.keys(t_data).forEach(function(elt, idx){
                                // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].employee;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else if (result[idx] && result[idx].position && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].position;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else
                                if (result[idx] && result[idx].detailUnion){
                                    data[elt] = {
                                        value: result[idx].value
                                    };
                                    Object.assign(data, result[idx].detailUnion);
                                }
                                else data[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    case "array":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            if (dataTypeOfArray == "advanced"){
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                        // data[typeid].push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        data[typeid] = result;
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                                else {
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        result.forEach(function(elt){
                                            var x = {};
                                            x[t_id] = elt;
                                            data[typeid].push(x);
                                        });
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                            }
                            else {
                                data[typeid] = {records: []};
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var typeofarray = dict2[typeid].content.typeof;
                                    var mainData = contentModule.getMainData(typeofarray, dict2);
                                    if (!mainData) data[typeid].records = t;
                                    else {
                                        var keys = Object.keys(mainData);
                                        t.forEach(function(record){
                                            var x = EncodingClass.string.duplicate(record);
                                            var cur = x.extrainfo;
                                            keys.forEach(function(localid){
                                                cur[localid] = x[mainData[localid]];
                                                if (typeof(cur[localid]) == "string") {
                                                    var tempDate = new Date(cur[localid]);
                                                    if (tempDate.toString() != "Invalid Date") {
                                                        cur[localid] = tempDate;
                                                    }
                                                }
                                            });
                                            data[typeid].records.push(cur);
                                        });
                                    }
                                }
                                else {
                                    t.forEach(function(elt){
                                        var x = {};
                                        x[t_id] = elt;
                                        data[typeid].records.push(x);
                                    });
                                }
                                rs(data);
                            }
                        }
                        break;
                    case "treetable":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            data[typeid] = {records: []};
                            var type = getType(typeDict[t_id]);
                            var typeofarray = dict2[typeid].content.typeof;
                            var mainData = contentModule.getMainData(typeofarray, dict2);
                            if (!mainData) data[typeid].records = t;
                            else {
                                var keys = Object.keys(mainData);
                                var makeData = function(items){
                                    var t_data = [];
                                    t.forEach(function(record){
                                        var x = EncodingClass.string.duplicate(record);
                                        var cur = x.extrainfo;
                                        keys.forEach(function(localid){
                                            cur[localid] = x[mainData[localid]];
                                            if (typeof(cur[localid]) == "string") {
                                                var tempDate = new Date(cur[localid]);
                                                if (tempDate.toString() != "Invalid Date") {
                                                    cur[localid] = tempDate;
                                                }
                                            }
                                        });
                                        if (record.__children__) cur.__children__ = makeData(record.__children__);
                                        t_data.push(cur);
                                    });
                                    return t_data;
                                }
                                data[typeid].records = makeData(t);
                            }
                            rs(data);
                        }
                        break;
                    case "union":
                        data = {
                            value: valueContent,
                            detailUnion: {}
                        };
                        var t_data = {};
                        if (currentPath.detailUnion[data.value]){
                            currentPath.detailUnion[data.value].forEach(function(elt){
                                t_data[elt.localid] = generateData(result[elt.localid], elt.type, elt);
                                // t_data[elt.localid] = generateData(valueContent.detailUnion[elt.localid], elt.type, elt);
                            });
                        }
                        Promise.all(Object.values(t_data)).then(function(result){
                            Object.keys(t_data).forEach(function(elt, idx){
                                data.detailUnion[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    default:
                        rj("undefined type: " + type);
                }
            });
        };

        var typeDataContent = [];
        var index = typeDict[typeid];
        while (typelists[index].type == "extends_structure") {
            typeDataContent = typelists[index].content.details.concat(typeDataContent);
            index = typeDict[typelists[index].content.typeof];
        }
        typeDataContent = typelists[index].content.details.concat(typeDataContent);
        ////////////
        result = valueContent.extrainfo ? valueContent.extrainfo : {};
        if (mainData) {
            typeDataContent.forEach(function(elt){
                if (mainData[elt.localid]){
                    result[elt.localid] = valueContent[mainData[elt.localid]];
                    if (elt.type == "union") {
                        Object.keys(elt.detailUnion).forEach(function(cur){
                            elt.detailUnion[cur].forEach(function(ud){
                                result[ud.localid] = valueContent[mainData[ud.localid]];
                            });
                        });
                    }
                }
            });
        }

        generateData(result, typeid).then(function(result){
            resolve(result);
        }, function(message){console.log(message); reject(message);});
        ////////////
    });
};

contentModule.setValueOfUserOutputForm = function(params){
    var valueContent, typeid, typelists;
    valueContent = params.valueContent;
    typeid = params.typeid;
    typelists = params.typelists;
    return new Promise(function(resolve, reject){
        valueContent = EncodingClass.string.duplicate(valueContent);
        var result;
        var typeDict = {};
        var dict2 = {};
        var primitiveTypeList = form_module.primitiveTypeList;
        var getType = function(index){
            var type = typelists[index].type;
            if (
                form_module.primitiveTypeList.indexOf(type) != -1
            ){
                type = typelists[index].type2;
            }
            return type;
        }
        typelists.forEach(function(elt, index){
            typeDict[elt.id] = index;
            dict2[elt.id] = elt;
        });
        var posDict = {};
        var generateData = function(valueContent, typeid, currentPath){
            return new Promise(function(rs, rj){
                var data;
                var type;
                if (isNaN(parseInt(typeid, 10))) type = typeid;
                else type = getType(typeDict[typeid]);
                switch (type) {
                    case "nation_city":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "position_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "employee_list":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "string":
                    case "phonenumber":
                    case "website":
                    case "gps":
                    case "note":
                    case "html":
                    case "variable_input":
                    case "variable_textarea":
                    case "time":
                    case "email_address":
                    case "boolean":
                    case "month":
                    case "week":
                        data = valueContent;
                        rs(data);
                        break;
                    case "number":
                    case "currency":
                        data = valueContent == "" ? 0 : parseInt(valueContent);
                        rs(data);
                        break;
                    case "date":
                        // data = contentModule.getDateView(valueContent);
                        data = valueContent;
                        rs(data);
                        break;
                    case "datetime":
                        // data = contentModule.getDateTimeView(valueContent);
                        data = valueContent;
                        rs(data);
                        break;
                    case "datemonth":
                        if (valueContent){
                            if (valueContent.month !== undefined && valueContent.month !== null){
                                var month = valueContent.month + 1;
                                if (month < 10) month = "0" + month;
                                var date = valueContent.date;
                                if (date < 10) date = "0" + date;
                                data = date + "/" + month;
                            }
                            else {
                                data = "";
                            }
                        }
                        else {
                            data = "";
                        }
                        rs(data);
                        break;
                    case "hour_period":
                        // data = contentModule.getDateTimeView(valueContent.dayOffset) + " - " + contentModule.getDateTimeView(valueContent.dayOffset + valueContent.duration);
                        data = valueContent;
                        rs(data);
                        break;
                    case "user":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "userlist":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "members_of_shifts":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "members_of_partner_class":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "members_of_locations":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "select_department_employee":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "geopos":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_department":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_position":
                        if (!valueContent || valueContent == 0){
                            rs({
                                value: 0
                            });
                        }
                        else {
                            Promise.all([data_module.loadOrgsList(), data_module.loadPositionById2(valueContent)]).then(function(result){
                                if (result[1].length == 0){
                                    rs({
                                        value: 0
                                    });
                                }
                                else {
                                    var subHost = {
                                        database: {}
                                    };
                                    contentModule.makeDatabaseContent(subHost, {orgs: result[0]});
                                    contentModule.makeOrgsIndex(subHost);
                                    var t = subHost.database.orgs.items[subHost.database.orgs.getIndex(result[1][0].orgid)];
                                    while (t.parentid != 0){
                                        t = subHost.database.orgs.items[subHost.database.orgs.getIndex(t.parentid)];
                                    }
                                    var data = {
                                        position: {
                                            value: valueContent
                                        },
                                        department: {
                                            value: result[1][0].orgid
                                        },
                                        company: {
                                            value: t.id
                                        }
                                    };
                                    rs(data);
                                }
                            });
                        }
                        break;
                    case "member_of_employee":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_template_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_welcome_templates":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_worktime_machines":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_assets":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_instruments_and_tools":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_assets_instruments_and_tools":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_warehouses":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_allowance_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_bonus_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_work_flow_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_work_flows":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_objects":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_payroll_cycle":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_lesson_categories":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_task":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_meeting":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_typelists":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_input_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_output_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_mobile_input_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_mobile_output_forms":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "color_picker":
                        data = valueContent == "" ? "white" : valueContent;
                        rs(data);
                        break;
                    case "member_of_partner_class":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_partner":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_contact":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_other_liability_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_trade_union_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_overtime_policy_groups":
                    case "member_of_offboarding_types":
                    case "member_of_offboarding_reasons":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "multiselect_offboarding_reasons":
                        data = {
                            values: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_salary_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_punishment_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_asset_category":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_instruments_and_tools_category":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_projects":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_tax_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_advance_payment_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_late_early_checkin_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_benefit_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_leave_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_insurance_policy_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_training_program_groups":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_shifts":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "member_of_insurance_policies":
                    case "member_of_tax_policies":
                    case "member_of_trade_union_policies":
                    case "member_of_leave_policies":
                    case "member_of_benefit_policies":
                    case "member_of_allowance_policies":
                    case "member_of_bonus_policies":
                    case "member_of_overtime_policies":
                    case "member_of_punishment_policies":
                    case "member_of_advance_payment_policies":
                    case "member_of_late_early_checkin_policies":
                    case "member_of_salary_policies":
                    case "member_of_other_liability_policies":
                    case "member_of_employment_contract_types":
                    case "member_of_nations":
                    case "member_of_cities":
                    case "member_of_ethnics":
                    case "member_of_religions":
                    case "member_of_document_types":
                    case "member_of_document_groups":
                    case "member_of_document_folders":
                    case "member_of_orgs":
                        data = {
                            value: valueContent
                        };
                        rs(data);
                        break;
                    case "files":
                        if (!valueContent) rs([]);
                        else {
                            if (valueContent["-64"]) data = valueContent["-64"];
                            else data = valueContent;
                            data_module.makeFilesContent(data).then(function(result){
                                rs(result);
                            });
                        }
                        break;
                    case "any_file":
                    case "image_file":
                        data_module.makeImageContent(valueContent).then(function(result){
                            rs(result);
                        });
                        break;
                    case "enum":
                    case "extends_enum":
                        data = {
                            value: valueContent,
                            // list: lists
                        };
                        rs(data);
                        break;
                    case "enum_multi":
                    case "extends_enum_multi":
                        data = {
                            values: valueContent,
                            // list: lists
                        };
                        rs(data);
                        break;
                    case "structure":
                        var index = typeDict[typeid];
                        var typeContent = typelists[index].content.details;
                        var t_data = {};
                        typeContent.forEach(function(elt){
                            t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                        });
                        Promise.all(Object.values(t_data)).then(function(result){
                            // data = {};
                            // Object.keys(t_data).forEach(function(elt, idx){
                            //     if (result[idx] && result[idx].detailUnion){
                            //         data[elt] = {
                            //             value: result[idx].value
                            //         };
                            //         Object.assign(data, result[idx].detailUnion);
                            //     }
                            //     else data[elt] = result[idx];
                            // });
                            // rs(data);
                            data = {};
                            Object.keys(t_data).forEach(function(elt, idx){
                                // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].employee;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else if (result[idx] && result[idx].position && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].position;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else
                                if (result[idx] && result[idx].detailUnion){
                                    data[elt] = {
                                        value: result[idx].value
                                    };
                                    Object.assign(data, result[idx].detailUnion);
                                }
                                else data[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    case "extends_structure":
                        var index = typeDict[typeid];
                        var typeContent = typelists[index].content;
                        var t_id = typeContent.typeof;
                        var content = typelists[typeDict[t_id]].content.details.concat(typeContent.details);
                        while (typelists[typeDict[t_id]].type == "extends_structure"){
                            t_id = typelists[typeDict[t_id]].content.typeof;
                            content = typelists[typeDict[t_id]].content.details.concat(content)
                        }
                        var t_data = {};
                        content.forEach(function(elt){
                            if (valueContent[elt.localid]) t_data[elt.localid] = generateData(valueContent[elt.localid], elt.type, elt);
                        });
                        Promise.all(Object.values(t_data)).then(function(result){
                            // data = {};
                            // Object.keys(t_data).forEach(function(elt, idx){
                            //     if (result[idx] && result[idx].detailUnion){
                            //         data[elt] = {
                            //             value: result[idx].value
                            //         };
                            //         Object.assign(data, result[idx].detailUnion);
                            //     }
                            //     else data[elt] = result[idx];
                            // });
                            // rs(data);
                            data = {};
                            Object.keys(t_data).forEach(function(elt, idx){
                                // if (result[idx] && result[idx].employee && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].employee;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else if (result[idx] && result[idx].position && result[idx].department && result[idx].company){
                                //     data[elt] = result[idx].position;
                                //     data[elt + "_choose_department"] = result[idx].department;
                                //     data[elt + "_choose_company"] = result[idx].company;
                                // }
                                // else
                                if (result[idx] && result[idx].detailUnion){
                                    data[elt] = {
                                        value: result[idx].value
                                    };
                                    Object.assign(data, result[idx].detailUnion);
                                }
                                else data[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    case "array":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var dataTypeOfArray = contentModule.checkDatatypeOfArray(typelists, t_id);
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            if (dataTypeOfArray == "advanced"){
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                        // data[typeid].push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        data[typeid] = result;
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                                else {
                                    var t_data = [];
                                    t.forEach(function(elt){
                                        t_data.push(generateData(elt, t_id));
                                    });
                                    Promise.all(t_data).then(function(result){
                                        result.forEach(function(elt){
                                            var x = {};
                                            x[t_id] = elt;
                                            data[typeid].push(x);
                                        });
                                        rs(data);
                                    }, function(message){rj(message);});
                                }
                            }
                            else {
                                data[typeid] = {records: []};
                                var type = getType(typeDict[t_id]);
                                if (type == "structure" || type == "extends_structure"){
                                    var typeofarray = dict2[typeid].content.typeof;
                                    data[typeid].records = t;
                                }
                                else {
                                    t.forEach(function(elt){
                                        var x = {};
                                        x[t_id] = elt;
                                        data[typeid].records.push(x);
                                    });
                                }
                                rs(data);
                            }
                        }
                        break;
                    case "treetable":
                        data = {};
                        data[typeid] = [];
                        if (!valueContent) rs(data);
                        else {
                            var index = typeDict[typeid];
                            var typeContent = typelists[index].content;
                            var t_id = typeContent.typeof;
                            var t;
                            if (valueContent.constructor === Object) t = valueContent[typeid];
                            else t = valueContent;
                            data[typeid] = {records: []};
                            var type = getType(typeDict[t_id]);
                            var typeofarray = dict2[typeid].content.typeof;
                            var mainData = contentModule.getMainData(typeofarray, dict2);
                            if (!mainData) data[typeid].records = t;
                            else {
                                var keys = Object.keys(mainData);
                                var makeData = function(items){
                                    var t_data = [];
                                    t.forEach(function(record){
                                        var x = EncodingClass.string.duplicate(record);
                                        var cur = x.extrainfo;
                                        keys.forEach(function(localid){
                                            cur[localid] = x[mainData[localid]];
                                            if (typeof(cur[localid]) == "string") {
                                                var tempDate = new Date(cur[localid]);
                                                if (tempDate.toString() != "Invalid Date") {
                                                    cur[localid] = tempDate;
                                                }
                                            }
                                        });
                                        if (record.__children__) cur.__children__ = makeData(record.__children__);
                                        t_data.push(cur);
                                    });
                                    return t_data;
                                }
                                data[typeid].records = makeData(t);
                            }
                            rs(data);
                        }
                        break;
                    case "union":
                        data = {
                            value: valueContent,
                            detailUnion: {}
                        };
                        var t_data = {};
                        if (currentPath.detailUnion[data.value]){
                            currentPath.detailUnion[data.value].forEach(function(elt){
                                t_data[elt.localid] = generateData(result[elt.localid], elt.type, elt);
                                // t_data[elt.localid] = generateData(valueContent.detailUnion[elt.localid], elt.type, elt);
                            });
                        }
                        Promise.all(Object.values(t_data)).then(function(result){
                            Object.keys(t_data).forEach(function(elt, idx){
                                data.detailUnion[elt] = result[idx];
                            });
                            rs(data);
                        }, function(message){rj(message);});
                        break;
                    default:
                        rj("undefined type: " + type);
                }
            });
        };

        var typeDataContent = [];
        var index = typeDict[typeid];
        while (typelists[index].type == "extends_structure") {
            typeDataContent = typelists[index].content.details.concat(typeDataContent);
            index = typeDict[typelists[index].content.typeof];
        }
        typeDataContent = typelists[index].content.details.concat(typeDataContent);

        generateData(valueContent, typeid).then(function(result){
            resolve(result);
        }, function(message){console.log(message); reject(message);});
        ////////////
    });
};

contentModule.getOrgMainData = function(){
    return {
        type_org_name: "name",
        type_org_code: "code",
        type_org_parentid: "parentid",
        type_org_geopos: "geopos"
    };
};

contentModule.getCompanyMainData = function(){
    return {
        type_company_name: "fullname",
        type_company_shortname: "name",
        type_company_code: "code",
        type_company_geopos: "geopos"
    };
};

contentModule.getTrainingLecturerMainData = function(){
    return {
        type_training_program_lecturer: "type",
        type_training_program_internal_trainer: "peopleid",
        type_training_program_outsource_trainer: "peopleid"
    };
};

contentModule.getTrainingParticipantMainData = function(){
    return {
        type_training_program_participant: "peopleid"
    };
};

contentModule.getDependentPersonMainData = function(){
    return {
        type_dependent_person_fullname: "fullname",
        type_dependent_person_dayofbirth: "dayofbirth",
        type_dependent_person_sex: "sex",
        type_dependent_person_nationalidno: "nationalidno",
        type_dependent_person_relation: "relation",
        type_dependent_person_personal_tax_code: "personal_tax_code"
    };
};

contentModule.getPositionMainData = function(){
    return {
        type_position_name: "name",
        type_position_code: "code",
        type_position_orgid: "orgid",
        type_position_benefits: "benefits",
        type_position_report_to: "report_to",
        type_position_job_description: "job_description",
        type_position_working_condition: "working_condition",
        type_position_prefered_ability: "prefered_ability",
        type_position_liability_and_authority: "liability_and_authority"
    };
};

contentModule.getEmployeeMainData = function(){
    return {
        type_employee_fullname: "fullname",
        // type_employee_image: "image",
        type_employee_userid: "userid",
        type_employee_code: "code",
        type_employee_phone_1: "phone_1",
        type_employee_phone_2: "phone_2",
        type_employee_work_email: "work_email",
        type_employee_private_email: "private_email",
        type_employee_social_network: "social_network",
        type_employee_nationalidno: "nationalidno",
        type_employee_dayofbirth: "dayofbirth",
        type_employee_sex: "sex",
        type_employee_marital_status: "marital_status",
        type_employee_nationalidno_date: "nationalidno_date",
        type_employee_nationalidno_place: "nationalidno_place",
        type_employee_nationality: "nationality",
        type_employee_religion: "religion",
        type_employee_ethnic: "ethnic",
        type_employee_permanent_address: "permanent_address",
        type_employee_permanent_nation_city: "permanent_nation_city",
        type_employee_temporary_address: "temporary_address",
        type_employee_temporary_nation_city: "temporary_nation_city",
        type_employee_personal_tax_code: "personal_tax_code",
        type_employee_personal_income_tax_relief: "personal_income_tax_relief",
        type_employee_social_security_number: "social_security_number",
        type_employee_social_insurance_date: "social_insurance_date",
        type_employee_place_of_social_insurance: "place_of_social_insurance",
        type_employee_emergency_contact: "emergency_contact",
        type_employee_reference: "reference",
        type_employee_start_date: "start_date",
        type_employee_official_date: "official_date",
        type_employee_hr_support_employee: "hr_support_employee",
        type_employee_positions: "positions",
        type_employee_direct_manager: "direct_manager",
        type_employee_indirect_manager: "indirect_manager",
        type_employee_available: "available"
    };
};

contentModule.getPeopleMainData = function(){
    return {
        type_people_fullname: "fullname",
        type_people_nationalidno: "nationalidno",
        type_people_dayofbirth: "dayofbirth",
        type_people_sex: "sex",
        type_people_marital_status: "marital_status",
        type_people_nationalidno_date: "nationalidno_date",
        type_people_nationalidno_place: "nationalidno_place",
        type_people_nationality: "nationality",
        type_people_religion: "religion",
        type_people_ethnic: "ethnic",
        type_people_permanent_address: "permanent_address",
        type_people_permanent_nation_city: "permanent_nation_city",
        type_people_temporary_address: "temporary_address",
        type_people_temporary_nation_city: "temporary_nation_city",
        type_people_personal_tax_code: "personal_tax_code",
        type_people_personal_income_tax_relief: "personal_income_tax_relief",
        type_people_social_security_number: "social_security_number",
        type_people_social_insurance_date: "social_insurance_date",
        type_people_place_of_social_insurance: "place_of_social_insurance",
        type_people_emergency_contact: "emergency_contact",
        type_people_reference: "reference",
        type_people_start_date: "start_date",
        type_people_official_date: "official_date",
        type_people_available: "available"
    };
};

contentModule.getPeopleContentField = [
    "image",
    "phone_1",
    "phone_2",
    "work_email",
    "private_email",
    "social_network",
    "religion",
    "ethnic",
    "sex",
    "marital_status",
    "nationalidno_date",
    "nationalidno_place",
    "permanent_address",
    "permanent_nation_city",
    "temporary_address",
    "temporary_nation_city",
    "personal_tax_code",
    "personal_income_tax_relief",
    "social_security_number",
    "social_insurance_date",
    "place_of_social_insurance",
    "emergency_contact",
    "reference",
    "start_date",
    "official_date",
    "hr_support_employee"
];

contentModule.getTaskMainData = function(){
    return {
        type_task_name: "name",
        type_task_status: "status",
        type_task_start_time: "starttime",
        type_task_expire_time: "endtime",
        type_task_reminder: "reminder",
        type_task_assign_to: "assignto",
        type_task_participant: "participant",
        type_task_result: "result"
    };
};

contentModule.getMeetingMainData = function(){
    return {
        type_meeting_name: "name",
        type_meeting_location: "location",
        type_meeting_status: "status",
        type_meeting_type: "type",
        type_meeting_start_time: "starttime",
        type_meeting_end_time: "endtime",
        type_meeting_all_day: "allday",
        type_meeting_reminder: "reminder",
        type_meeting_assign_to: "assignto",
        type_meeting_participant: "participant",
        type_meeting_result: "result"
    };
};

contentModule.getHolidayMainData = function(){
    return {
        type_holiday_name: "name",
        type_holiday_timestart: "timestart",
        type_holiday_timeend: "timeend",
        type_holiday_shifts: "shifts",
        type_holiday_available: "available"
    }
};

contentModule.getRequestAdvancePaymentMainData = function(){
    return {
        type_request_advance_payment_employeeid: "employeeid",
        type_request_advance_payment_policyid: "policyid",
        type_request_advance_payment_time_hours_needed_for_approval: "time_hours_needed_for_approval",
        type_request_advance_payment_date: "date",
        type_request_advance_payment_amount: "amount",
        type_request_advance_payment_reason: "reason",
        type_request_advance_payment_attachments: "attachments",
        type_request_advance_payment_approvers: "approvers"
    };
};

contentModule.getRequestLateEarlyCheckinMainData = function(){
    return {
        type_request_late_early_checkin_employeeid: "employeeid",
        type_request_late_early_checkin_policyid: "policyid",
        type_request_late_early_checkin_from: "fromdate",
        type_request_late_early_checkin_to: "todate",
        type_request_late_early_checkin_late: "late",
        type_request_late_early_checkin_early: "early",
        type_request_late_early_checkin_reason: "reason",
        type_request_late_early_checkin_approvers: "approvers"
    };
};

contentModule.getRequestLeaveMainData = function(){
    return {
        type_request_leave_employeeid: "employeeid",
        type_request_leave_policyid: "policyid",
        type_request_leave_remain_day_off: "remain_day_off",
        type_request_leave_days_off: "days_off",
        type_request_leave_number_of_day_off: "number_of_day_off",
        type_request_leave_reason: "reason",
        type_request_leave_substitute: "substitute",
        type_request_leave_approvers: "approvers"
    };
};

contentModule.getShiftScheduleManualMainData = function(){
    return {
        type_shift_schedule_shift: "shiftid",
        type_shift_schedule_date_from: "date_from",
        type_shift_schedule_date_to: "date_to",
        type_shift_schedule_department_employee: "department_employee"
    };
};

contentModule.getDocumentTypesMainData = function(){
    return {
        type_document_type_name: "name",
        type_document_type_description: "description",
        type_document_type_active: "available"
    };
};

contentModule.getOffboardingTypesMainData = function(){
    return {
        type_offboarding_type_name: "name",
        type_offboarding_type_active: "available"
    };
};

contentModule.getOffboardingReasonsMainData = function(){
    return {
        type_offboarding_reason_name: "name",
        type_offboarding_reason_active: "available"
    };
};


contentModule.getApprovalResignationMainData = function(){
    return {
        type_approval_resignation_approver: "approvers",
        type_approval_resignation_the_last_working_day: "the_last_working_day",
        type_approval_resignation_interview: "interview",
        type_approval_resignation_interviewer: "interviewers",
        type_approval_resignation_interview_date: "interview_date"
    };
};

contentModule.getLeaveAssessmentMainData = function(){
    return {
        type_leave_assessment_type: "type",
        type_leave_assessment_reason: "reasons",
        type_leave_assessment_comment: "comment"
    };
};

contentModule.getDocumentGroupsMainData = function(){
    return {
        type_document_group_name: "name",
        type_document_group_parentid: "parentid",
        type_document_group_description: "description",
        type_document_group_active: "available"
    };
};

contentModule.getDocumentPropertiesMainData = function(){
    return {
        type_document_property_name: "name",
        type_document_property_description: "description",
        type_document_property_active: "available"
    };
};

contentModule.getDocumentTemplatesMainData = function(){
    return {
        type_document_template_name: "name",
        type_document_template_tag: "tag",
        type_document_template_summary_content: "summary_content",
        type_document_template_active: "available",
        type_document_template_detail_content: "detail_content"
    };
};

contentModule.getDocumentsMainData = function(){
    return {
        type_document_name: "name",
        type_document_number: "number",
        type_document_issued_date: "issued_date",
        type_document_effective_date: "effective_date",
        type_document_expired_date: "expired_date",
        type_document_tag: "tag",
        type_document_summary_content: "summary_content",
        type_document_attachments: "attachments",
        type_document_active: "available",
        type_document_detail_content: "detail_content"
    };
};

contentModule.getLessonCategoriesMainData = function(){
    return {
        type_lesson_category_name: "name",
        type_lesson_category_description: "description",
        type_lesson_category_active: "available"
    };
};

contentModule.makePathIndex = function(host){
    var holderForSort = host.database.paths.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    host.database.paths.items = holderForSort.map(function(holder){
        return holder.item;
    });
    for (var i = 0; i < host.database.paths.items.length; i++){
        host.database.paths.items[i].childIndexList = [];
    }
    var pathsDic = contentModule.makeDictionaryIndex(host.database.paths.items);
    var k;
    for (var i = 0; i < host.database.paths.items.length; i++){
        if (host.database.paths.items[i].parentid == 0) continue;
        k = pathsDic[host.database.paths.items[i].parentid];
        if (k !== undefined){
            host.database.paths.items[k].childIndexList.push(i);
        }
    }
};

contentModule.makeFilesIndex = function(host){
    for (var i = 0; i < host.database.paths.items.length; i++){
        host.database.paths.items[i].filesIndexList = [];
    }
    var pathsDic = contentModule.makeDictionaryIndex(host.database.paths.items);
    var k, t = [];
    for (var i = 0; i < host.database.files.items.length; i++){
        k = pathsDic[host.database.files.items[i].pathid];
        if (k !== undefined){
            host.database.paths.items[k].filesIndexList.push(t.length);
            t.push(host.database.files.items[i]);
        }
    }
    host.database.files.items = t;
};

contentModule.getPathTreeList = function(host){
    var list = [];
    function getRow(item){
        var items = [], ni;
        for (var i = 0; i < item.childIndexList.length; i++){
            ni = item.childIndexList[i];
            items.push(getRow(host.database.paths.items[ni]));
        }
        return {
            value: item.id,
            text: item.name,
            items: items
        };
    };
    for (var i = 0; i < host.database.paths.items.length; i++){
        if (host.database.paths.items[i].parentid != 0) continue;
        list.push(getRow(host.database.paths.items[i]));
    }
    return list;
};

contentModule.listSuffFiles = ["3g2","3ga","3gp","7z","aa","aac","ac","accdb","accdt","ace","adn","ai","aif","aifc","aiff","ait","amr","ani",
    "apk","app","applescript","asax","asc","ascx","asf","ash","ashx","asm","asmx","asp","aspx","asx","au","aup","avi","axd","aze","bak","bash",
    "bat","bin","blank","bmp","bowerrc","bpg","browser","bz2","bzempty","c","cab","cad","caf","cal","cd","cdda","cer","cfg","cfm","cfml","cgi",
    "chm","class","cmd","codeworkspace","codekit","coffee","coffeelintignore","com","compile","conf","config","cpp","cptx","cr2","crdownload",
    "crt","crypt","cs","csh","cson","csproj","css","csv","cue","cur","dart","dat","data","db","dbf","deb","default","dgn","dist","diz","dll",
    "dmg","dng","doc","docb","docm","docx","dot","dotm","dotx","download","dpj","ds_store","dsn","dtd","dwg","dxf","editorconfig","el","elf",
    "eml","enc","eot","eps","epub","eslintignore","exe","f4v","fax","fb2","fla","flac","flv","fnt","folder","fon","gadget","gdp","gem","gif",
    "gitattributes","gitignore","go","gpg","gpl","gradle","gz","h","handlebars","hbs","heic","hlp","hs","hsl","htm","html","ibooks","icns","ico",
    "ics","idx","iff","ifo","image","img","iml","in","inc","indd","inf","info","ini","inv","iso","j2","jar","java","jpe","jpeg","jpg","js",
    "json","jsp","jsx","key","kf8","kmk","ksh","kt","kts","kup","less","lex","licx","lisp","lit","lnk","lock","log","lua","m","m2v","m3u","m3u8",
    "m4","m4a","m4r","m4v","map","master","mc","md","mdb","mdf","me","mi","mid","midi","mk","mkv","mm","mng","mo","mobi","mod","mov","mp2","mp3",
    "mp4","mpa","mpd","mpe","mpeg","mpg","mpga","mpp","mpt","msg","msi","msu","nef","nes","nfo","nix","npmignore","ocx","odb","ods","odt","ogg",
    "ogv","ost","otf","ott","ova","ovf","p12","p7b","pages","part","pcd","pdb","pdf","pem","pfx","pgp","ph","phar","php","pid","pkg","pl","plist",
    "pm","png","po","pom","pot","potx","pps","ppsx","ppt","pptm","pptx","prop","ps","ps1","psd","psp","pst","pub","py","pyc","qt","ra","ram",
    "rar","raw","rb","rdf","rdl","reg","resx","retry","rm","rom","rpm","rpt","rsa","rss","rst","rtf","ru","rub","sass","scss","sdf","sed","sh",
    "sit","sitemap","skin","sldm","sldx","sln","sol","sphinx","sql","sqlite","step","stl","svg","swd","swf","swift","swp","sys","tar","tax",
    "tcsh","tex","tfignore","tga","tgz","tif","tiff","tmp","tmx","torrent","tpl","ts","tsv","ttf","twig","txt","udf","vb","vbproj","vbs","vcd",
    "vcf","vcs","vdi","vdx","vmdk","vob","vox","vscodeignore","vsd","vss","vst","vsx","vtx","war","wav","wbk","webinfo","webm","webp","wma",
    "wmf","wmv","woff","woff2","wps","wsf","xaml","xcf","xfl","xlm","xls","xlsm","xlsx","xlt","xltm","xltx","xml","xpi","xps","xrb","xsd","xsl",
    "xspf","xz","yaml","yml","z","zip","zsh"
];

contentModule.getAvatarByHomeid = function(host, userid){
    var index = host.database.users.getByhomeid(userid);
    if (index < 0) return "";
    if (host.database.users.items[index].avatar !== ""){
        return window.domainUser_avatarsNew + host.database.users.items[index].homeid + "_" + host.database.users.items[index].avatar;
    }
    else {
        if (systemconfig.connectorFile){
            return window.domainUser_avatarsNew + "default.svg";
        }
        else {
            return window.domainUser_avatars + "avatar-default.png";
        }
    }
};


contentModule.checkDatatypeOfArray = function(typelists, typeid){
    var index, dict, type, content;
    dict = {};
    typelists.forEach(function(elt, index){
        dict[elt.id] = index;
    });
    index = dict[typeid];
    var getType = function(index){
        var type = typelists[index].type;
        if (
            type == "phone_type"
            || type == "personal_document_type"
            || type == "personal_document"
            || type == "org"
            || type == "company"
            || type == "employee"
            || type == "people"
            || type == "position"
            || type == "select_position"
            || type == "position_list"
            || type == "marital_status_type"
            || type == "sex_type"
            || type == "email_type"
            || type == "task"
            || type == "meeting"
            || type == "holidays"
            || type == "shift_general"
            || type == "shift_worktime"
            || type == "shift_timekeeping"
            || type == "worktime_checkins"
            || type == "worktime_machines"
            || type == "worktime_logs"
            || type == "training_programs"
            || type == "training_type"
            || type == "training_method"
            || type == "training_status"
            || type == "asset_category"
            || type == "assets"
            || type == "instruments_and_tools"
            || type == "warehouses"
            || type == "asset_handover_lines"
            || type == "asset_handover"
            || type == "instruments_and_tools_handover_lines"
            || type == "instruments_and_tools_handover"
            || type == "asset_recall_lines"
            || type == "day_off_lines"
            || type == "asset_recall"
            || type == "allowance_policy_groups"
            || type == "lesson_categories"
            || type == "bonus_policy_groups"
            || type == "work_flow_groups"
            || type == "work_flows"
            || type == "objects"
            || type == "partner_class"
            || type == "partner"
            || type == "contact"
            || type == "other_liability_policy_groups"
            || type == "salary_policy_groups"
            || type == "trade_union_policy_groups"
            || type == "overtime_policy_groups"
            || type == "late_early_checkin_policy_groups"
            || type == "punishment_policy_groups"
            || type == "asset_category"
            || type == "instruments_and_tools_category"
            || type == "projects"
            || type == "project_applied_to_employee"
            || type == "tax_policy_groups"
            || type == "advance_payment_policy_groups"
            || type == "allowance_policies"
            || type == "benefit_policies"
            || type == "training_program_groups"
            || type == "insurance_policies"
            || type == "bonus_policies"
            || type == "advance_payment_policies"
            || type == "late_early_checkin_policies"
            || type == "punishment_policies"
            || type == "leave_policy_groups"
            || type == "insurance_policy_groups"
            || type == "leave_policies"
            || type == "benefit_policy_groups"
            || type == "tax_rate_lines"
            || type == "tax_policies"
            || type == "trade_union_policies"
            || type == "overtime_policies"
            || type == "overtime_request"
            || type == "salary_policies"
            || type == "other_liability_policies"
            || type == "insurance_policies_applied_to_employee"
            || type == "overtime_policies_applied_to_employee"
            || type == "bonus_policies_applied_to_employee"
            || type == "punishment_policies_applied_to_employee"
            || type == "benefit_policies_applied_to_employee"
            || type == "allowance_policies_applied_to_employee"
            || type == "tax_policies_applied_to_employee"
            || type == "trade_union_policies_applied_to_employee"
            || type == "other_liability_policies_applied_to_employee"
            || type == "leave_policies_applied_to_employee"
            || type == "late_early_checkin_policies_applied_to_employee"
            || type == "advance_payment_policies_applied_to_employee"
            || type == "salary_policies_applied_to_employee"
            || type == "salary_decisions_applied_to_employee"
            || type == "employment_contracts"
            || type == "request_advance_payment"
            || type == "request_late_early_checkin"
            || type == "request_leave"
            || type == "shift_schedule"
            || type == "bonus_list"
            || type == "bonus_list_details"
            || type == "punishment_list_details"
            || type == "allowance_list_details"
            || type == "benefit_list_details"
            || type == "other_liability_list_details"
            || type == "punishment_list"
            || type == "allowance_list"
            || type == "benefit_list"
            || type == "other_liability_list"
            || type == "salary_adjustment_list"
            || type == "salary_adjustment_list_details"
            || type == "scorecard_report_line"
            || type == "scorecard_report"
            || type == "offboarding"
            || type == "dependent_persons"
            || type == "employment_contract_types"
            || type == "social_network"
            || type == "work_history"
            || type == "education_history"
            || type == "skill"
            || type == "bank_account"
            || type == "phone"
            || type == "email"
            || type == "nations"
            || type == "cities"
            || type == "ethnics"
            || type == "religions"
            || type == "training_lecturer"
            || type == "training_participant"
            || type == "examination_session"
            || type == "examination_participant"
            || type == "examination_lecturer"
            || type == "examination_session_status"
            || type == "examination_participant_status"
            || type == "document_types"
            || type == "document_groups"
            || type == "document_properties"
            || type == "document_templates"
            || type == "documents"
            || type == "offboarding_types"
            || type == "offboarding_reasons"
        ){
            type = typelists[index].type2;
        }
        return type;
    }
    type = getType(index);
    if (type == "any_file") return "advanced";
    if (type != "structure" && type != "extends_structure" && type != "array") return "primitive";
    if (type == "array") return "advanced";
    if (type == "structure") content = typelists[index].content.details;
    else if (type == "extends_structure") {
        var host = {
            database: {
                typelists: {items: typelists}
            },
            dictionary: {
                typelists: dict
            }
        };
        content = contentModule.makeExtendTypeData(host, typeid);
    }
    for (var i = 0; i < content.length; i++){
        index = dict[content[i].type];
        type = getType(index);
        if (type == "structure" || type == "extends_structure" || type == "array") return "advanced";
    }
    return "primitive";
};

contentModule.getPathTreeRootList = function(host, id){
    var list = [];
    function getRow(item){
        var items = [], ni;
        for (var i = 0; i < item.childIndexList.length; i++){
            ni = item.childIndexList[i];
            if (host.database.paths.items[ni].id == id) continue;
            items.push(getRow(host.database.paths.items[ni]));
        }
        return {
            value: item.id,
            text: item.name,
            items: items
        };
    };
    for (var i = 0; i < host.database.paths.items.length; i++){
        if (host.database.paths.items[i].parentid != 0) continue;
        if (host.database.paths.items[i].id == id) continue;
        list.push(getRow(host.database.paths.items[i]));
    }
    return [{
        value: 0,
        text: "Root",
        items: list
    }];
};

contentModule.getDocumentFoldersSelectTreeMenuMove = function(host, id){
    var list = [];
    function getRow(item){
        var items = [], ni;
        for (var i = 0; i < item.childIndexList.length; i++){
            ni = item.childIndexList[i];
            if (host.database.document_folders.items[ni].id == id) continue;
            items.push(getRow(host.database.document_folders.items[ni]));
        }
        return {
            value: item.id,
            text: item.name,
            items: items
        };
    };
    for (var i = 0; i < host.database.document_folders.items.length; i++){
        if (host.database.document_folders.items[i].parentid != 0) continue;
        if (host.database.document_folders.items[i].id == id) continue;
        list.push(getRow(host.database.document_folders.items[i]));
    }
    return [{
        value: 0,
        text: "",
        items: list
    }];
};

contentModule.getSystemVariable = function(){
    var content = [
        {task: "company", title: LanguageModule.text("txt_company"), name: "company", tablename: "orgs", typeid: -260, input_form: -260, output_form: -1260},
        {task: "org", title: LanguageModule.text("txt_department"), name: "orgs", tablename: "orgs", typeid: -26, input_form: -26, output_form: -1026},
        {task: "employee", title: LanguageModule.text("txt_employee"), name: "employees", tablename: "employees", typeid: -27, input_form: -27, output_form: -1027},
        {task: "people", title: LanguageModule.text("txt_people"), name: "people", tablename: "peoples", typeid: -179, input_form: -179, output_form: -1179},
        {task: "position", title: LanguageModule.text("txt_position"), name: "positions", tablename: "positions", typeid: -28, input_form: -28, output_form: -1028},
        {task: "holidays", title: LanguageModule.text("txt_holiday"), name: "holidays", tablename: "holidays", typeid: -50, input_form: -50, output_form: -1050},
        {task: "task", title: LanguageModule.text("txt_task"), name: "tasks", tablename: "task", typeid: -45, input_form: -45, output_form: -1045},
        {task: "meeting", title: LanguageModule.text("txt_meeting"), name: "meetings", tablename: "meeting", typeid: -46, input_form: -46, output_form: -1046},
        {task: "shift_general", title: LanguageModule.text("txt_shift_general"), name: "shift_general", tablename: "shifts", typeid: -54, input_form: -54, output_form: -1054},
        {task: "shift_worktime", title: LanguageModule.text("txt_shift_worktime"), name: "shift_worktime", tablename: "shifts", typeid: -270, input_form: -270, output_form: -1270},
        {task: "shift_timekeeping", title: LanguageModule.text("txt_shift_timekeeping"), name: "shift_timekeeping", tablename: "shifts", typeid: -271, input_form: -271, output_form: -1271},
        {task: "worktime_checkins", title: LanguageModule.text("txt_worktime_checkins"), name: "worktime_checkins", tablename: "worktime_checkins", typeid: -56, input_form: -56, output_form: -1056},
        {task: "worktime_logs", title: LanguageModule.text("txt_worktime_logs"), name: "worktime_logs", tablename: "worktime_logs", typeid: -59, input_form: -59, output_form: -1059},
        {task: "worktime_machines", title: LanguageModule.text("txt_worktime_machine"), name: "worktime_machines", tablename: "worktime_machines", typeid: -57, input_form: -57, output_form: -1057},
        {task: "training_programs", title: LanguageModule.text("txt_training_program"), name: "training_programs", tablename: "training_programs", typeid: -60, input_form: -60, output_form: -1060},
        {task: "assets", title: LanguageModule.text("txt_asset"), name: "assets", tablename: "assets", typeid: -66, input_form: -66, output_form: -1066},
        {task: "instruments_and_tools", title: LanguageModule.text("txt_instruments_and_tools"), name: "instruments_and_tools", tablename: "instruments_and_tools", typeid: -67, input_form: -67, output_form: -1067},
        {task: "warehouses", title: LanguageModule.text("txt_warehouse"), name: "warehouses", tablename: "warehouses", typeid: -68, input_form: -68, output_form: -1068},
        {task: "asset_handover", title: LanguageModule.text("txt_asset_handover"), name: "asset_handover", tablename: "asset_transactions", typeid: -73, input_form: -73, output_form: -1073},
        {task: "instruments_and_tools_handover", title: LanguageModule.text("txt_instruments_and_tools_handover"), name: "instruments_and_tools_handover", tablename: "asset_transactions", typeid: -232, input_form: -232, output_form: -1232},
        {task: "asset_recall", title: LanguageModule.text("txt_asset_recall"), name: "asset_recall", tablename: "asset_transactions", typeid: -77, input_form: -77, output_form: -1077},
        {task: "allowance_policy_groups", title: LanguageModule.text("txt_allowance_policy_group"), name: "allowance_policy_groups", tablename: "allowance_policy_groups", typeid: -80, input_form: -80, output_form: -1080},
        {task: "bonus_policy_groups", title: LanguageModule.text("txt_bonus_policy_group"), name: "bonus_policy_groups", tablename: "bonus_policy_groups", typeid: -101, input_form: -101, output_form: -1101},
        {task: "work_flow_groups", title: LanguageModule.text("txt_work_flow_group"), name: "work_flow_groups", tablename: "work_flow_groups", typeid: -245, input_form: -245, output_form: -1245},
        {task: "work_flows", title: LanguageModule.text("txt_work_flows"), name: "work_flows", tablename: "work_flows", typeid: -247, input_form: -247, output_form: -1247},
        {task: "objects", title: LanguageModule.text("txt_object"), name: "objects", tablename: "objects", typeid: -249, input_form: -249, output_form: -1249},
        {task: "partner_class", title: LanguageModule.text("txt_partner_class"), name: "partner_class", tablename: "partner_class", typeid: -239, input_form: -239, output_form: -1239},
        {task: "partner", title: LanguageModule.text("txt_partner"), name: "partner", tablename: "partner", typeid: -241, input_form: -241, output_form: -1241},
        {task: "contact", title: LanguageModule.text("txt_contact"), name: "contact", tablename: "contact", typeid: -243, input_form: -243, output_form: -1243},
        {task: "punishment_policy_groups", title: LanguageModule.text("txt_punishment_policy_group"), name: "punishment_policy_groups", tablename: "punishment_policy_groups", typeid: -103, input_form: -103, output_form: -1103},
        {task: "asset_category", title: LanguageModule.text("txt_asset_category"), name: "asset_category", tablename: "asset_category", typeid: -202, input_form: -202, output_form: -1202},
        {task: "instruments_and_tools_category", title: LanguageModule.text("txt_instruments_and_tools_category"), name: "instruments_and_tools_category", tablename: "instruments_and_tools_category", typeid: -204, input_form: -204, output_form: -1204},
        {task: "projects", title: LanguageModule.text("txt_projects"), name: "projects", tablename: "projects", typeid: -206, input_form: -206, output_form: -1206},
        {task: "project_applied_to_employee", title: LanguageModule.text("txt_project_applied_to_employee"), name: "project_applied_to_employee", tablename: "employee_projects", typeid: -209, input_form: -209, output_form: -1209},
        {task: "tax_policy_groups", title: LanguageModule.text("txt_tax_policy_group"), name: "tax_policy_groups", tablename: "tax_policy_groups", typeid: -105, input_form: -105, output_form: -1105},
        {task: "advance_payment_policy_groups", title: LanguageModule.text("txt_advance_payment_policy_group"), name: "advance_payment_policy_groups", tablename: "advance_payment_policy_groups", typeid: -107, input_form: -107, output_form: -1107},
        {task: "late_early_checkin_policy_groups", title: LanguageModule.text("txt_late_early_checkin_policy_group"), name: "late_early_checkin_policy_groups", tablename: "late_early_checkin_policy_groups", typeid: -109, input_form: -109, output_form: -1109},
        {task: "salary_policy_groups", title: LanguageModule.text("txt_salary_policy_group"), name: "salary_policy_groups", tablename: "salary_policy_groups", typeid: -124, input_form: -124, output_form: -1124},
        {task: "trade_union_policy_groups", title: LanguageModule.text("txt_trade_union_policy_group"), name: "trade_union_policy_groups", tablename: "trade_union_policy_groups", typeid: -126, input_form: -126, output_form: -1126},
        {task: "overtime_policy_groups", title: LanguageModule.text("txt_overtime_policy_group"), name: "overtime_policy_groups", tablename: "overtime_policy_groups", typeid: -272, input_form: -272, output_form: -1272},
        {task: "other_liability_policy_groups", title: LanguageModule.text("txt_other_liability_policy_group"), name: "other_liability_policy_groups", tablename: "other_liability_policy_groups", typeid: -128, input_form: -128, output_form: -1128},
        {task: "allowance_policies", title: LanguageModule.text("txt_allowance_policy"), name: "allowance_policies", tablename: "allowance_policies", typeid: -82, input_form: -82, output_form: -1082},
        {task: "benefit_policies", title: LanguageModule.text("txt_benefit_policy"), name: "benefit_policies", tablename: "benefit_policies", typeid: -100, input_form: -100, output_form: -1100},
        {task: "training_program_groups", title: LanguageModule.text("txt_training_program_group"), name: "training_program_groups", tablename: "training_program_groups", typeid: -85, input_form: -85, output_form: -1085},
        {task: "insurance_policies", title: LanguageModule.text("txt_insurance_policy"), name: "insurance_policies", tablename: "insurance_policies", typeid: -87, input_form: -87, output_form: -1087},
        {task: "bonus_policies", title: LanguageModule.text("txt_bonus_policy"), name: "bonus_policies", tablename: "bonus_policies", typeid: -111, input_form: -111, output_form: -1111},
        {task: "punishment_policies", title: LanguageModule.text("txt_punishment_policy"), name: "punishment_policies", tablename: "bonus_policies", typeid: -112, input_form: -112, output_form: -1112},
        {task: "advance_payment_policies", title: LanguageModule.text("txt_advance_payment_policy"), name: "advance_payment_policies", tablename: "advance_payment_policies", typeid: -115, input_form: -115, output_form: -1115},
        {task: "late_early_checkin_policies", title: LanguageModule.text("txt_late_early_checkin_policy"), name: "late_early_checkin_policies", tablename: "late_early_checkin_policies", typeid: -119, input_form: -119, output_form: -1119},
        {task: "leave_policy_groups", title: LanguageModule.text("txt_leave_policy_group"), name: "leave_policy_groups", tablename: "leave_policy_groups", typeid: -95, input_form: -95, output_form: -1095},
        {task: "insurance_policy_groups", title: LanguageModule.text("txt_insurance_policy_group"), name: "insurance_policy_groups", tablename: "insurance_policy_groups", typeid: -96, input_form: -96, output_form: -1096},
        {task: "leave_policies", title: LanguageModule.text("txt_leave_policy"), name: "leave_policies", tablename: "leave_policies", typeid: -94, input_form: -94, output_form: -1094},
        {task: "benefit_policy_groups", title: LanguageModule.text("txt_benefit_policy_group"), name: "benefit_policy_groups", tablename: "benefit_policy_groups", typeid: -98, input_form: -98, output_form: -1098},
        {task: "tax_policies", title: LanguageModule.text("txt_tax_policy"), name: "tax_policies", tablename: "tax_policies", typeid: -122, input_form: -122, output_form: -1122},
        {task: "salary_policies", title: LanguageModule.text("txt_salary_policy"), name: "salary_policies", tablename: "salary_policies", typeid: -133, input_form: -133, output_form: -1133},
        {task: "trade_union_policies", title: LanguageModule.text("txt_trade_union_policy"), name: "trade_union_policies", tablename: "trade_union_policies", typeid: -134, input_form: -134, output_form: -1134},
        {task: "overtime_policies", title: LanguageModule.text("txt_overtime_policy"), name: "overtime_policies", tablename: "overtime_policies", typeid: -274, input_form: -274, output_form: -1274},
        {task: "overtime_request", title: LanguageModule.text("txt_overtime_request"), name: "overtime_request", tablename: "overtime_request", typeid: -277, input_form: -277, output_form: -1277},
        {task: "other_liability_policies", title: LanguageModule.text("txt_other_liability_policy"), name: "other_liability_policies", tablename: "other_liability_policies", typeid: -135, input_form: -135, output_form: -1135},
        {task: "dependent_persons", title: LanguageModule.text("txt_dependent_person"), name: "dependent_persons", tablename: "employee_dependent_persons", typeid: -21, input_form: -21, output_form: -1021},
        {task: "employment_contract_types", title: LanguageModule.text("txt_employment_contract_type"), name: "employment_contract_types", tablename: "employment_contract_types", typeid: -152, input_form: -152, output_form: -1152},
        {task: "social_network", title: LanguageModule.text("txt_social_network"), name: "social_network", tablename: "", typeid: -153, input_form: -153, output_form: -1153},
        {task: "work_history", title: LanguageModule.text("txt_work_history"), name: "work_history", tablename: "", typeid: -158, input_form: -158, output_form: -1158},
        {task: "education_history", title: LanguageModule.text("txt_education_history"), name: "education_history", tablename: "", typeid: -154, input_form: -154, output_form: -1154},
        {task: "skill", title: LanguageModule.text("txt_skill"), name: "skill", tablename: "", typeid: -155, input_form: -155, output_form: -1155},
        {task: "bank_account", title: LanguageModule.text("txt_bank_account"), name: "bank_account", tablename: "", typeid: -159, input_form: -159, output_form: -1159},
        {task: "phone", title: LanguageModule.text("txt_phone"), name: "phone", tablename: "phone", typeid: -18, input_form: -18, output_form: -1018},
        {task: "email", title: LanguageModule.text("txt_email"), name: "email", tablename: "email", typeid: -42, input_form: -42, output_form: -1042},
        {task: "personal_document", title: LanguageModule.text("txt_personal_document"), name: "personal_document", tablename: "personal_document", typeid: -20, input_form: -20, output_form: -1020},
        {task: "nations", title: LanguageModule.text("txt_nation"), name: "nations", tablename: "nations", typeid: -160, input_form: -160, output_form: -1160},
        {task: "cities", title: LanguageModule.text("txt_city"), name: "cities", tablename: "cities", typeid: -161, input_form: -161, output_form: -1161},
        {task: "ethnics", title: LanguageModule.text("txt_ethnic"), name: "ethnics", tablename: "ethnics", typeid: -162, input_form: -162, output_form: -1162},
        {task: "religions", title: LanguageModule.text("txt_religion"), name: "religions", tablename: "religions", typeid: -163, input_form: -163, output_form: -1163},
        {task: "insurance_policies_applied_to_employee", title: LanguageModule.text("txt_insurance_policies_applied_to_employee"), name: "insurance_policies_applied_to_employee", tablename: "employee_policies", typeid: -151, input_form: -151, output_form: -1151},//để tạm, chưa biết lưu như nào
        {task: "overtime_policies_applied_to_employee", title: LanguageModule.text("txt_overtime_policies_applied_to_employee"), name: "overtime_policies_applied_to_employee", tablename: "employee_policies", typeid: -278, input_form: -278, output_form: -1278},//để tạm, chưa biết lưu như nào
        {task: "bonus_policies_applied_to_employee", title: LanguageModule.text("txt_bonus_policies_applied_to_employee"), name: "bonus_policies_applied_to_employee", tablename: "employee_policies", typeid: -164, input_form: -164, output_form: -1164},
        {task: "punishment_policies_applied_to_employee", title: LanguageModule.text("txt_punishment_policies_applied_to_employee"), name: "punishment_policies_applied_to_employee", tablename: "employee_policies", typeid: -165, input_form: -165, output_form: -1165},
        {task: "benefit_policies_applied_to_employee", title: LanguageModule.text("txt_benefit_policies_applied_to_employee"), name: "benefit_policies_applied_to_employee", tablename: "employee_policies", typeid: -166, input_form: -166, output_form: -1166},
        {task: "allowance_policies_applied_to_employee", title: LanguageModule.text("txt_allowance_policies_applied_to_employee"), name: "allowance_policies_applied_to_employee", tablename: "employee_policies", typeid: -167, input_form: -167, output_form: -1167},
        {task: "tax_policies_applied_to_employee", title: LanguageModule.text("txt_tax_policies_applied_to_employee"), name: "tax_policies_applied_to_employee", tablename: "employee_policies", typeid: -168, input_form: -168, output_form: -1168},
        {task: "trade_union_policies_applied_to_employee", title: LanguageModule.text("txt_trade_union_policies_applied_to_employee"), name: "trade_union_policies_applied_to_employee", tablename: "employee_policies", typeid: -169, input_form: -169, output_form: -1169},
        {task: "other_liability_policies_applied_to_employee", title: LanguageModule.text("txt_other_liability_policies_applied_to_employee"), name: "other_liability_policies_applied_to_employee", tablename: "employee_policies", typeid: -170, input_form: -170, output_form: -1170},
        {task: "leave_policies_applied_to_employee", title: LanguageModule.text("txt_leave_policies_applied_to_employee"), name: "leave_policies_applied_to_employee", tablename: "employee_policies", typeid: -171, input_form: -171, output_form: -1171},
        {task: "late_early_checkin_policies_applied_to_employee", title: LanguageModule.text("txt_late_early_checkin_policies_applied_to_employee"), name: "late_early_checkin_policies_applied_to_employee", tablename: "employee_policies", typeid: -172, input_form: -172, output_form: -1172},
        {task: "advance_payment_policies_applied_to_employee", title: LanguageModule.text("txt_advance_payment_policies_applied_to_employee"), name: "advance_payment_policies_applied_to_employee", tablename: "employee_policies", typeid: -173, input_form: -173, output_form: -1173},
        {task: "salary_policies_applied_to_employee", title: LanguageModule.text("txt_salary_policy_applied_to_employee"), name: "salary_policies_applied_to_employee", tablename: "employee_policies", typeid: -175, input_form: -175, output_form: -1175},
        {task: "employment_contracts", title: LanguageModule.text("txt_employee_employment_contract"), name: "employment_contracts", tablename: "employment_contracts", typeid: -176, input_form: -176, output_form: -1176},
        {task: "bonus_list", title: LanguageModule.text("txt_bonus_list"), name: "bonus_list", tablename: "employee_benefit_and_liability_list", typeid: -177, input_form: -177, output_form: -1177},
        {task: "bonus_list_details", title: LanguageModule.text("txt_bonus_list_details"), name: "bonus_list_details", tablename: "employee_benefit_and_liability_list_details", typeid: -269, input_form: -269, output_form: -1269},
        {task: "punishment_list", title: LanguageModule.text("txt_punishment_list"), name: "punishment_list", tablename: "employee_benefit_and_liability_list_details", typeid: -191, input_form: -191, output_form: -1191},
        {task: "punishment_list_details", title: LanguageModule.text("txt_punishment_list_details"), name: "punishment_list_details", tablename: "employee_benefit_and_liability_list_details", typeid: -279, input_form: -279, output_form: -1279},
        {task: "allowance_list", title: LanguageModule.text("txt_allowance_list"), name: "allowance_list", tablename: "employee_benefit_and_liability_list_details", typeid: -196, input_form: -196, output_form: -1196},
        {task: "allowance_list_details", title: LanguageModule.text("txt_allowance_list_details"), name: "allowance_list_details", tablename: "employee_benefit_and_liability_list_details", typeid: -280, input_form: -280, output_form: -1280},
        {task: "benefit_list", title: LanguageModule.text("txt_benefit_list"), name: "benefit_list", tablename: "employee_benefit_and_liability_list_details", typeid: -197, input_form: -197, output_form: -1197},
        {task: "benefit_list_details", title: LanguageModule.text("txt_benefit_list_details"), name: "benefit_list_details", tablename: "employee_benefit_and_liability_list_details", typeid: -281, input_form: -281, output_form: -1281},
        {task: "other_liability_list", title: LanguageModule.text("txt_other_liability_list"), name: "other_liability_list", tablename: "employee_benefit_and_liability_list_details", typeid: -198, input_form: -198, output_form: -1198},
        {task: "other_liability_list_details", title: LanguageModule.text("txt_other_liability_list_details"), name: "other_liability_list_details", tablename: "employee_benefit_and_liability_list_details", typeid: -282, input_form: -282, output_form: -1282},
        {task: "salary_adjustment_list", title: LanguageModule.text("txt_salary_adjustment_list"), name: "salary_adjustment_list", tablename: "employee_benefit_and_liability_list_details", typeid: -200, input_form: -200, output_form: -1200},
        {task: "salary_adjustment_list_details", title: LanguageModule.text("txt_salary_adjustment_list_details"), name: "salary_adjustment_list_details", tablename: "employee_benefit_and_liability_list_details", typeid: -283, input_form: -283, output_form: -1283},
        {task: "scorecard_report", title: LanguageModule.text("txt_scorecard_report"), name: "scorecard_report", tablename: "", typeid: -293, input_form: -293, output_form: -1293},
        {task: "offboarding", title: LanguageModule.text("txt_offboarding"), name: "offboarding", tablename: "offboarding", typeid: -228, input_form: -228, output_form: -1228},
        {task: "salary_decisions_applied_to_employee", title: LanguageModule.text("txt_salary_decisions_applied_to_employee"), name: "salary_decisions_applied_to_employee", tablename: "employee_salary_decisions", typeid: -174, input_form: -174, output_form: -1174},
        {task: "training_lecturer", title: LanguageModule.text("txt_training_lecturer"), name: "training_lecturer", tablename: "training_lecturers", typeid: -178, input_form: -178, output_form: -1178},
        {task: "people", title: LanguageModule.text("txt_people"), name: "people", tablename: "peoples", typeid: -179, input_form: -179, output_form: -1179},
        {task: "training_participant", title: LanguageModule.text("txt_training_participant"), name: "training_participant", tablename: "training_participants", typeid: -180, input_form: -180, output_form: -1180},
        {task: "request_advance_payment", title: LanguageModule.text("txt_request_advance_payment"), name: "request_advance_payment", tablename: "employee_benefit_and_liability_request", typeid: -182, input_form: -182, output_form: -1182},
        {task: "request_late_early_checkin", title: LanguageModule.text("txt_request_late_early_checkin"), name: "request_late_early_checkin", tablename: "employee_benefit_and_liability_request", typeid: -195, input_form: -195, output_form: -1195},
        {task: "request_leave", title: LanguageModule.text("txt_request_leave"), name: "request_leave", tablename: "employee_benefit_and_liability_request", typeid: -188, input_form: -188, output_form: -1188},
        {task: "shift_schedule", title: LanguageModule.text("txt_shift_schedule"), name: "shift_schedule", tablename: "assign_employee_shifts", typeid: -190, input_form: -190, output_form: -1190},
        {task: "examination_session", title: LanguageModule.text("txt_training_program"), name: "examination_session", tablename: "examination_session", typeid: -183, input_form: -183, output_form: -1183},
        {task: "examination_participant", title: LanguageModule.text("txt_training_program"), name: "examination_participant", tablename: "examination_participant", typeid: -186, input_form: -186, output_form: -1186},
        {task: "examination_lecturer", title: LanguageModule.text("txt_training_program"), name: "examination_lecturer", tablename: "examination_lecturer", typeid: -187, input_form: -187, output_form: -1187},
        {task: "document_types", title: LanguageModule.text("txt_document_type"), name: "document_types", tablename: "document_types", typeid: -211, input_form: -211, output_form: -1211},
        {task: "document_groups", title: LanguageModule.text("txt_document_group"), name: "document_groups", tablename: "document_groups", typeid: -213, input_form: -213, output_form: -1213},
        {task: "document_properties", title: LanguageModule.text("txt_document_property"), name: "document_properties", tablename: "document_properties", typeid: -234, input_form: -234, output_form: -1234},
        {task: "document_templates", title: LanguageModule.text("txt_document_template"), name: "document_templates", tablename: "document_templates", typeid: -216, input_form: -216, output_form: -1216},
        {task: "documents", title: LanguageModule.text("txt_documents"), name: "documents", tablename: "documents", typeid: -219, input_form: -219, output_form: -1219},
        {task: "template_groups", title: LanguageModule.text("txt_template_groups"), name: "template_groups", tablename: "template_groups", typeid: -222, input_form: -222, output_form: -1222},
        {task: "task_templates", title: LanguageModule.text("txt_task_template"), name: "task_templates", tablename: "task_templates", typeid: -224, input_form: -224, output_form: -1224},
        {task: "meeting_templates", title: LanguageModule.text("txt_meeting_template"), name: "meeting_templates", tablename: "meeting_templates", typeid: -225, input_form: -225, output_form: -1225},
        {task: "email_templates", title: LanguageModule.text("txt_email_template"), name: "email_templates", tablename: "email_templates", typeid: -226, input_form: -226, output_form: -1226},
        {task: "onboarding", title: LanguageModule.text("txt_email_template"), name: "onboarding", tablename: "onboarding", typeid: -227, input_form: -227, output_form: -1227},
        {task: "geographical_positions", title: LanguageModule.text("txt_geographical_position"), name: "geographical_positions", tablename: "geopos", typeid: -229, input_form: -229, output_form: -1229},
        {task: "offboarding_types", title: LanguageModule.text("txt_offboarding_type"), name: "offboarding_types", tablename: "offboarding_types", typeid: -236, input_form: -236, output_form: -1236},
        {task: "offboarding_reasons", title: LanguageModule.text("txt_offboarding_reason"), name: "offboarding_reasons", tablename: "offboarding_reasons", typeid: -237, input_form: -237, output_form: -1237},
        {task: "lesson_categories", title: LanguageModule.text("txt_lesson_category"), name: "lesson_categories", tablename: "lesson_categories", typeid: -264, input_form: -264, output_form: -1264},
        {task: "approval_resignation", title: LanguageModule.text("txt_leave_approval"), name: "approval_resignation", tablename: "approval_resignation", typeid: -289, input_form: -289, output_form: -1289},
        {task: "leave_assessment", title: LanguageModule.text("txt_leave_review"), name: "leave_assessment", tablename: "leave_assessment", typeid: -290, input_form: -290, output_form: -1290}
    ];
    content.forEach(function(elt){
        elt.mobile_input_form = "m_" + elt.input_form;
        elt.mobile_output_form = "m_" + elt.output_form;
    });
    return content;
};

contentModule.configVariableDefault = function(){
    var systemVariable = contentModule.getSystemVariable();
    var dict = {};
    systemVariable.forEach(function(elt){
        dict[elt.task] = elt;
    });
    return dict;
};

contentModule.configVariable = function(host){
    var systemVariable = contentModule.getSystemVariable();
    var dict = {};
    if (host.database.form_config.items.length == 0){
        systemVariable.forEach(function(elt){
            dict[elt.task] = elt;
            // dict[elt.task] = EncodingClass.string.duplicate(elt);
            if (hr.isMobile){
                dict[elt.task].input_form = dict[elt.task].mobile_input_form
                dict[elt.task].output_form = dict[elt.task].mobile_output_form
            }
        });
    }
    else {
        var form_config = EncodingClass.string.toVariable(host.database.form_config.items[0].content);
        systemVariable.forEach(function(elt){
            // dict[elt.task] = EncodingClass.string.toVariable(elt);
            dict[elt.task] = elt;
            if (form_config[elt.task]){
                dict[elt.task].typeid = form_config[elt.task].typeid;
                if (hr.isMobile) {
                    if (form_config[elt.task].mobile_input_form != 0) dict[elt.task].input_form = form_config[elt.task].mobile_input_form;
                    if (form_config[elt.task].mobile_output_form != 0) dict[elt.task].output_form = form_config[elt.task].mobile_output_form;
                }
                else {
                    if (form_config[elt.task].input_form != 0) dict[elt.task].input_form = form_config[elt.task].input_form;
                    if (form_config[elt.task].output_form != 0) dict[elt.task].output_form = form_config[elt.task].output_form;
                }
            }
        });
    }
    return dict;
};

contentModule.viewInputForm = function(host, formid, valueContent){
    var AssemblerInstance = absol.form.AssemblerInstance;
    var $ = absol.$;
    var _ = absol._;
    var JSZip = absol.JSZip;
    var makeFmFragmentClass = absol.form.makeFmFragmentClass;
    var mSignUpFrag = AssemblerInstance.buildFragment({class: formid.toString()});
    mSignUpFrag.domElt.addStyle({
        width: '100%',
        height:'100%',
        display: 'block'
    });
    if (valueContent){
        mSignUpFrag.props = valueContent;
    }
    return mSignUpFrag;
};
contentModule.makeTypelistsIndex = function(host){
    var typeDic = contentModule.makeDictionaryIndex(host.database.typelists.items);
    for (var i = 0; i < host.database.typelists.items.length; i++){
        host.database.typelists.items[i].extendsList = [];
    }
    var k;
    for (var i = 0; i < host.database.typelists.items.length; i++){
        if (host.database.typelists.items[i].type != "extends_enum" && host.database.typelists.items[i].type != "extends_structure" && host.database.typelists.items[i].type != "extends_enum_multi") continue;
        k = typeDic[host.database.typelists.items[i].content.typeof];
        if (k !== undefined) host.database.typelists.items[k].extendsList.push(host.database.typelists.items[i].id);
    }
};

contentModule.getListTypeExtends = function(host, list, type){
    var index = host.database.typelists.getIndex(type);
    list.push({
        value: host.database.typelists.items[index].id,
        text: host.database.typelists.items[index].name
    });
    for (var i = 0; i < host.database.typelists.items[index].extendsList.length; i++){
        contentModule.getListTypeExtends(host, list, host.database.typelists.items[index].extendsList[i]);
    }
};

contentModule.getListTypeSimilar = function(host, type){
    var index = host.database.typelists.getIndex(type);
    while (host.database.typelists.items[index].type == "extends_enum" || host.database.typelists.items[index].type == "extends_structure" || host.database.typelists.items[index].type == "extends_enum_multi") {
        type = host.database.typelists.items[index].content.typeof;
        index = host.database.typelists.getIndex(type);
    }
    var list = [];
    var x = ["structure", "enum", "enum_multi"];
    if (x.indexOf(host.database.typelists.items[index].type) >= 0 || x.indexOf(host.database.typelists.items[index].type2) >= 0){
        contentModule.getListTypeExtends(host, list, host.database.typelists.items[index].id);
    }
    else {
        list.push({
            value: host.database.typelists.items[index].id,
            text: host.database.typelists.items[index].name
        });
    }
    return list;
};

contentModule.getDetailsExtendsConcat = function(list, list2){
    list2 = EncodingClass.string.duplicate(list2);
    var k;
    for (var i = list2.length - 1; i >= 0; i--){
        k = -1;
        for (var j = 0; j < list.length; j++){
            if (list[j].localid == list2[i].localid){
                k = j;
                break;
            }
        }
        if (k >= 0){
            if (list[k].oldType === undefined) list2[i].oldType = list2[i].type;
            else list2[i].oldType = list[k].oldType;
            list2[i].type = list[k].type;
            list[k] = "delete";
        }
        else list2[i].oldType = list2[i].type;
        list2[i].noEdit = true;
        list.unshift(list2[i]);
    }
    for (var i = list.length - 1; i >= 0; i--){
        if (list[i] == "delete") list.splice(i, 1);
    }
};

contentModule.getDetailsExtends = function(host, list, type) {
    var index = host.database.typelists.getIndex(type);
    type = host.database.typelists.items[index].type;
    var content = host.database.typelists.items[index].content;
    switch (type) {
        case "enum":
        case "enum_multi":
        case "structure":
            contentModule.getDetailsExtendsConcat(list, content.details);
            break;
        case "extends_enum":
        case "extends_structure":
        case "extends_enum_multi":
            contentModule.getDetailsExtendsConcat(list, content.details);
            contentModule.getDetailsExtends(host, list, content.typeof);
            break;
        case "language":
        case "member_of_leave_policy_groups":
        case "member_of_employment_contract_types":
            var x = contentModule.getDetailsEnumPri(type);
            contentModule.getDetailsExtendsConcat(list, x);
            break;
        default:
            if (contentModule.dataTypeOfExtends.indexOf(host.database.typelists.items[index].type2) >= 0){
                contentModule.getDetailsExtendsConcat(list, content.details);
            }
            break;
    }
};

contentModule.getCitiesListByID = function(host, nationid){
    var nIndex = host.database.nations.getIndex(nationid);
    var list = [
        {value: 0, text: LanguageModule.text("txt_select_value")}
    ];
    if (nIndex < 0) return list;
    var ni;
    for (var i = 0; i < host.database.nations.items[nIndex].cityIndexList.length; i++){
        ni = host.database.nations.items[nIndex].cityIndexList[i];
        list.push({
            value: host.database.cities.items[ni].id,
            text: host.database.cities.items[ni].name
        });
    }
    return list;
};

contentModule.seachPeople = function(listUsed){
    return new Promise(function(resolve, reject){
        function drawPeople(content){
            DOMElement.removeAllChildren(data_ctn);
            var data = [];
            var nationName, nIndex, celldata, nationalityName, cityName, cIndex;
            for (var i = 0; i < content.length; i++){
                nationName = "", nationalityName = "", cityName = "";
                nIndex = data_module.nations.getIndex(content[i].nationality);
                if (nIndex >= 0) nationalityName = data_module.nations.items[nIndex].fullname;
                nIndex = data_module.nations.getIndex(content[i].nationid);
                if (nIndex >= 0) nationName = data_module.nations.items[nIndex].fullname;
                cIndex = data_module.cities.getIndex(content[i].cityid);
                if (cIndex >= 0) nationName = data_module.cities.items[cIndex].name;
                if (listUsed && listUsed[content[i].id]){
                    celldata = [
                        {attrs: {className: "hr-td-disabled"}, text: content[i].fullname},
                        {attrs: {className: "hr-td-disabled"}, text: nationalityName},
                        {attrs: {className: "hr-td-disabled"}, text: nationName},
                        {attrs: {className: "hr-td-disabled"}, text: cityName},
                        {attrs: {className: "hr-td-disabled"}, text: content[i].nationalidno},
                        {attrs: {className: "hr-td-disabled"}, text: contentModule.getDateView(content[i].dayofbirth)},
                        {attrs: {className: "hr-td-disabled"}, text: content[i].address}
                    ];
                    celldata.push({attrs: {className: "hr-td-disabled"}});
                }
                else {
                    celldata = [
                        {text: content[i].fullname},
                        {text: nationalityName},
                        {text: nationName},
                        {text: cityName},
                        {text: content[i].nationalidno},
                        {text: contentModule.getDateView(content[i].dayofbirth)},
                        {text: content[i].address}
                    ];
                    celldata.push({
                        attrs: {align: "center"},
                        children: [DOMElement.a({
                            attrs: {
                                style: {color: "var(--a-color)", cursor: "pointer"},
                                onclick: function(i){
                                    return function(){
                                        ModalElement.close(1);
                                        resolve(content[i]);
                                    }
                                }(i)
                            },
                            text: LanguageModule.text("txt_selected")
                        })]
                    });
                }
                data.push(celldata);
            }
            data_ctn.appendChild(DOMElement.table({
                attrs: {style: {width: "100%"}},
                header: [
                    {text: LanguageModule.text("txt_fullname")},
                    {text: LanguageModule.text("txt_nationality")},
                    {text: LanguageModule.text("txt_nation")},
                    {text: LanguageModule.text("txt_city")},
                    {text: LanguageModule.text("txt_nation_id_number")},
                    {text: LanguageModule.text("txt_day_of_birth")},
                    {text: LanguageModule.text("txt_address")},
                    {}
                ],
                data: data
            }));
        };
        var data_ctn = DOMElement.div({attrs: {className: "cardsimpletableclass"}});
        function searchFunc(){
            var fullname = fullname_input.value.trim();
            var nationality = nationality_select.value;
            var nationid = nation_select.value;
            var cityid = city_select.value;
            var nationalidno = nationalidno_input.value.trim();
            var address = address_input.value.trim();
            if (nationalidno.length > 0 && nationalidno.length < 5){
                ModalElement.alert({message: LanguageModule.text2("war_txt_minimum_search_digit_nationalidno", [5])});
                return;
            }
            if (fullname.length > 0 && fullname.length < 3){
                ModalElement.alert({message: LanguageModule.text2("war_txt_minimum_search_digit_fullname", [3])});
                return;
            }
            if (address.length > 0 && address.length < 3){
                ModalElement.alert({message: LanguageModule.text2("war_txt_minimum_search_digit_address", [3])});
                return;
            }
            if (fullname == "" && nationalidno == "" && address == "" && cityid == 0){
                ModalElement.alert({message: LanguageModule.text("war_txt_minimum_search_digit")});
                return;
            }
            var data = {
                fullname: absol.string.nonAccentVietnamese(fullname.toLowerCase()),
                address: absol.string.nonAccentVietnamese(address.toLowerCase()),
                nationality: nationality,
                nationid: nationid,
                cityid: cityid,
                nationalidno: nationalidno
            };
            ModalElement.show_loading();
            FormClass.api_call({
                url: "database_load.php",
                params: [
                    {name: "task", value: "search_employee"},
                    {name: "data", value: EncodingClass.string.fromVariable(data)}
                ],
                func: function(success, message){
                    ModalElement.close(-1);
                    if (success){
                        if (message.substr(0, 2) == "ok"){
                            var content = EncodingClass.string.toVariable(message.substr(2));
                            drawPeople(content);
                        }
                        else {
                            ModalElement.alert({message: message});
                        }
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
            });
        };

        var fullname_input = theme.input({
            style: {width: "300px"}
        });
        var nationality_select = absol.buildDom({
            tag: "selectmenu",
            props: {
                items: contentModule.getNationsListSelectMenu()
            }
        });
        var nation_select = absol.buildDom({
            tag: "selectmenu",
            props: {
                items: contentModule.getNationsListSelectMenu()
            },
            on: {
                change: function(){
                    city_select.items = contentModule.getCitiesListByID(this.value);
                }
            }
        });
        var city_select = absol.buildDom({
            tag: "selectmenu",
            props: {
                items: contentModule.getCitiesListByID(0)
            }
        });
        var nationalidno_input = theme.input({
            style: {width: "150px"}
        });
        var address_input = theme.input({
            style: {width: "300px"}
        });
        ModalElement.showWindow({
            index: 1,
            bodycontent: DOMElement.div({
                children: [
                    DOMElement.div({
                        children: [
                            DOMElement.div({
                                attrs: {
                                    className: "button-panel-header"
                                },
                                children: [
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header",
                                            whiteSpace: "nowrap"
                                        },
                                        children: [
                                            DOMElement.span({
                                                attrs: {
                                                    style: {
                                                        lineHeight: "var(--control-height)",
                                                        marginRight: "var(--control-horizontal-distance-1)"
                                                    }
                                                },
                                                text: LanguageModule.text("txt_fullname")
                                            }),
                                            fullname_input
                                        ]
                                    }),
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header",
                                            whiteSpace: "nowrap"
                                        },
                                        children: [
                                            DOMElement.span({
                                                attrs: {
                                                    style: {
                                                        lineHeight: "var(--control-height)",
                                                        marginRight: "var(--control-horizontal-distance-1)"
                                                    }
                                                },
                                                text: LanguageModule.text("txt_nation_id_number")
                                            }),
                                            nationalidno_input
                                        ]
                                    }),
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header",
                                            whiteSpace: "nowrap"
                                        },
                                        children: [
                                            DOMElement.span({
                                                attrs: {
                                                    style: {
                                                        lineHeight: "var(--control-height)",
                                                        marginRight: "var(--control-horizontal-distance-1)"
                                                    }
                                                },
                                                text: LanguageModule.text("txt_address")
                                            }),
                                            address_input
                                        ]
                                    }),
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header",
                                            whiteSpace: "nowrap"
                                        },
                                        children: [
                                            DOMElement.span({
                                                attrs: {
                                                    style: {
                                                        lineHeight: "var(--control-height)",
                                                        marginRight: "var(--control-horizontal-distance-1)"
                                                    }
                                                },
                                                text: LanguageModule.text("txt_nation")
                                            }),
                                            nation_select
                                        ]
                                    }),
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header",
                                            whiteSpace: "nowrap"
                                        },
                                        children: [
                                            DOMElement.span({
                                                attrs: {
                                                    style: {
                                                        lineHeight: "var(--control-height)",
                                                        marginRight: "var(--control-horizontal-distance-1)"
                                                    }
                                                },
                                                text: LanguageModule.text("txt_city")
                                            }),
                                            city_select
                                        ]
                                    }),
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header",
                                            whiteSpace: "nowrap"
                                        },
                                        children: [
                                            DOMElement.span({
                                                attrs: {
                                                    style: {
                                                        lineHeight: "var(--control-height)",
                                                        marginRight: "var(--control-horizontal-distance-1)"
                                                    }
                                                },
                                                text: LanguageModule.text("txt_nationality")
                                            }),
                                            nationality_select
                                        ]
                                    }),
                                    DOMElement.div({
                                        attrs: {
                                            className: "single-button-header"
                                        },
                                        children: [theme.noneIconButton({
                                            onclick: function() {
                                                searchFunc();
                                            },
                                            text: LanguageModule.text("txt_search")
                                        })]
                                    })
                                ]
                            }),
                            data_ctn
                        ]
                    }),
                    DOMElement.div({
                        attrs: {align: "center", style: {paddingTop: "var(--control-verticle-distance-2)"}},
                        children: [DOMElement.table({
                            data: [[{
                                children: [theme.noneIconButton({
                                    onclick: function() {
                                        ModalElement.close(1);
                                    },
                                    text: LanguageModule.text("txt_close")
                                })]
                            }]]
                        })]
                    })
                ]
            })
        });
        fullname_input.focus();
    });
};

contentModule.getIncludedid = function(host, typeid){
    var st = "";
    var typeIndex = host.database.typelists.getIndex(typeid);
    if (typeIndex < 0) return st;
    if (host.database.typelists.items[typeIndex].type == "extends_enum_multi" || host.database.typelists.items[typeIndex].type == "extends_enum" || host.database.typelists.items[typeIndex].type == "extends_structure"){
        st += contentModule.getIncludedid(host, host.database.typelists.items[typeIndex].content.typeof);
    }
    st += "_" + typeid;
    return st;
};

contentModule.makeHolidaysData = function(host){
    for (var i = 0; i < host.database.holidays.items.length; i++){
        host.database.holidays.items[i].shifts = [];
    }
    var holidaysDic = contentModule.makeDictionaryIndex(host.database.holidays.items);
    var k;
    for (var i = 0; i < host.database.shift_holidays.items.length; i++){
        k = holidaysDic[host.database.shift_holidays.items[i].holidayid];
        if (k !== undefined) host.database.holidays.items[k].shifts.push(host.database.shift_holidays.items[i].shiftid);
    }
};

contentModule.makeShiftData = function(item){
    item.extrainfo = {};
    if (item.content_general == "") item.content_general = {};
    else item.content_general = EncodingClass.string.toVariable(item.content_general);
    for (var j = 0; j < contentModule.getShiftContentGeneralField.length; j++){
        if (contentModule.getShiftContentGeneralField[j] == "extrainfo"){
            for (var x in item.content_general.extrainfo){
                item.extrainfo[x] = item.content_general.extrainfo[x];
            }
        }
        else {
            item[contentModule.getShiftContentGeneralField[j]] = item.content_general[contentModule.getShiftContentGeneralField[j]];
        }
    }
    if (item.content_worktime == "") item.content_worktime = {};
    else item.content_worktime = EncodingClass.string.toVariable(item.content_worktime);
    for (var xx in item.content_worktime){
        if (xx == "extrainfo"){
            for (var x in item.content_worktime.extrainfo){
                item.extrainfo[x] = item.content_worktime.extrainfo[x];
            }
        }
        else {
            item[xx] = item.content_worktime[xx];
        }
    }
    if (item.content_timekeeping == "") item.content_timekeeping = {};
    else item.content_timekeeping = EncodingClass.string.toVariable(item.content_timekeeping);
    for (var xx in item.content_timekeeping){
        if (xx == "extrainfo"){
            for (var x in item.content_timekeeping.extrainfo){
                item.extrainfo[x] = item.content_timekeeping.extrainfo[x];
            }
        }
        else {
            item[xx] = item.content_timekeeping[xx];
        }
    }
};

contentModule.makeShiftsData = function(host){
    for (var i = 0; i < host.database.shifts.items.length; i++){
        contentModule.makeShiftData(host.database.shifts.items[i]);
    }
};

contentModule.getShiftGeneralMainData = function(){
    return {
        type_shift_name: "name",
        type_shift_description: "description",
        type_shift_symbol: "symbol",
        type_shift_color: "color",
        type_shift_number_of_meal: "number_of_meal",
        type_shift_available: "available"
    };
};

contentModule.getShiftWorktimeMainData = function(){
    return {
        type_shift_working_time: "working_time",
        type_shift_break_time: "break_time",
        type_shift_night_work_time: "night_work_time",
        type_shift_late_checkin_minutes: "late_checkin_minutes",
        type_shift_early_checkout_minutes: "early_checkout_minutes",
        type_shift_monday: "monday",
        type_shift_tuesday: "tuesday",
        type_shift_wednesday: "wednesday",
        type_shift_thursday: "thursday",
        type_shift_friday: "friday",
        type_shift_saturday: "saturday",
        type_shift_sunday: "sunday"
    };
};

contentModule.getShiftTimekeepingMainData = function(){
    return {
        type_shift_number_of_standard_working_hours: "number_of_standard_working_hours",
        type_shift_number_of_work_days: "number_of_work_days",
        type_shift_minimum_working_minutes_required_for_salary_calculation: "minimum_working_minutes_required_for_salary_calculation",
        type_shift_round_to_one_days_wage: "round_to_one_days_wage",
        type_shift_checkin_first_half_shift: "checkin_first_half_shift",
        type_shift_time_for_checking_in_first_half_shift: "time_for_checking_in_first_half_shift",
        type_shift_checkout_first_half_shift: "checkout_first_half_shift",
        type_shift_time_for_checking_out_first_half_shift: "time_for_checking_out_first_half_shift",
        type_shift_checkin_second_half_shift: "checkin_second_half_shift",
        type_shift_time_for_checking_in_second_half_shift: "time_for_checking_in_second_half_shift",
        type_shift_checkout_second_half_shift: "checkout_second_half_shift",
        type_shift_time_for_checking_out_second_half_shift: "time_for_checking_out_second_half_shift"
    };
};

contentModule.getShiftContentGeneralField = [
    "color",
    "number_of_meal",
    "extrainfo"
];

contentModule.chooseFile = function (params) {
    return new Promise(function (resolve, reject) {
        var DEFAULT_PATH_ID = -1;
        var host = {
            database: {},

        };//host chỉ có 1, không cần return function
        function openDialog() {
            // init some module
            var iconSrc = window.location.origin + "/vivid_exticons/";


            /***** VIEW ****************************/
            var $ = absol.$;
            var buildDom = absol._;
            var _ = absol._;

            var okBtn = theme.noneIconButton({
                onclick: function () {
                    finishWithResult();

                },
                text: LanguageModule.text("txt_ok")
            });

            var cancelBtn = theme.noneIconButton({
                onclick: function () {
                    ModalElement.close();
                    resolve(null);//cancel
                },
                text: LanguageModule.text("txt_cancel")
            });


            var view = buildDom({
                class: 'kv-choose-file-dialog',
                child: [
                    {
                        class: 'kv-choose-file-dialog-body',
                        child: [
                            {
                                class: 'kv-choose-file-dialog-tree-ctn'
                            },
                            {
                                class: 'kv-choose-file-dialog-files-ctn',
                                child: [
                                    {
                                        class: 'kv-choose-file-dialog-offline-files-ctn',
                                        child: {
                                            tag: 'filelistinput',
                                            class: 'kv-choose-file-dialog-offline-files-input',
                                            props: {
                                                multiple: true,
                                            }
                                        }
                                    },
                                    {
                                        class: 'kv-choose-file-dialog-online-files-ctn',
                                        child: {
                                            tag: 'filelistinput',
                                            class: 'kv-choose-file-dialog-online-files-input',
                                            props: {
                                                readOnly: true,
                                                showCheck: true
                                            }
                                        }
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        class: 'kv-choose-file-dialog-footer',

                        child: [okBtn, cancelBtn]
                    }
                ]
            });

            var pathTreeCtn = $('.kv-choose-file-dialog-tree-ctn', view);

            var files_ctn = $('.kv-choose-file-dialog-files-ctn', view);
            var offlineFilesCtn = $('.kv-choose-file-dialog-offline-files-ctn', view);
            var onlineFilesCtn = $('.kv-choose-file-dialog-online-files-ctn', view);
            var offlineFiles = $('.kv-choose-file-dialog-offline-files-input', view);
            var onlineFiles = $('.kv-choose-file-dialog-online-files-input', view);
            var activatedNode = null;
            okBtn.disabled = true;


            /********************** DRAW PATH TREE ********************************************************************/

            function createTree(id) {
                var index = host.database.paths.getIndex(id);
                var childs = [], ni;
                for (var i = 0; i < host.database.paths.items[index].childIndexList.length; i++) {
                    ni = host.database.paths.items[index].childIndexList[i];
                    childs.push(createTree(host.database.paths.items[ni].id));
                }
                var props = {
                    name: host.database.paths.items[index].name,
                    icon: {
                        tag: 'img',
                        props: {
                            src: iconSrc + 'folder.svg'
                        }
                    }
                };
                if (childs.length > 0) props.status = "close";
                return _({
                    tag: "exptree",
                    attr: {
                        'data-path-id': id + ''
                    },
                    props: props,
                    on: {
                        press: function () {
                            redrawOnlineFiles(id);
                        }
                    },
                    child: childs
                });
            }

            function redrawPathList() {
                pathTreeCtn.clearChild();
                var tree, item;
                for (var i = 0; i < host.database.paths.items.length; i++) {
                    item = host.database.paths.items[i];
                    if (item.parentid != 0) continue;
                    tree = createTree(item.id);
                    pathTreeCtn.addChild(tree);
                }
            }


            /********************** DRAW FILES ************************************************************************/

            function redrawOnlineFiles(id) {
                if (activatedNode) activatedNode.active = false;
                activatedNode = $('[data-path-id="' + id + '"]', pathTreeCtn);
                if (activatedNode) activatedNode.active = true;
                host.pathid = id;
                contentModule.makeFilesIndex(host);
                var index = host.database.paths.getIndex(id);

                onlineFiles.files = [];
                var imageSuffixes = ["jpg", "png", "gif", "jpeg", 'tif', 'bmp', 'webm'];

                var files = host.database.paths.items[index].filesIndexList.map(function (ni) {
                    var fileInfo = host.database.files.items[ni];
                    var fileName = fileInfo.name;
                    var fileid = fileInfo.id;
                    var fileType = absol.$.fileInfoOf(fileName).type;
                    if (imageSuffixes.indexOf(fileType) >= 0) {
                        return {
                            name: fileName,
                            fileid: fileid
                        }
                    }
                    else {
                        return {
                            name: fileName,
                            fileid: fileid
                        }
                    }

                });
                onlineFiles.files = files;
            }

            /********************** DATA ******************************************************************************/

            function getSelectedFileIdList() {
                return onlineFiles.getChildren().filter(function (it) {
                    return it.checked;
                }).map(function (it) {
                    return it.value.fileid;
                });
            }

            function getPendingUploadFileList() {
                return offlineFiles.getChildren().map(function (it) {
                    return it.value;
                });
            }

            function uploadPendingFiles() {
                var files = getPendingUploadFileList();
                if (files.length === 0) return Promise.resolve([]);
                return  hr.paths.addFileSubmit(host, files).then(function (st) {
                    offlineFiles.files = [];
                    return st ||[];
                }).then(function (st){
                    onlineFiles.defaultChecked = true;
                    st.slice().reverse().forEach(function (item){
                        item.url = window.domainFilesNew + item.id + "_"+ item.name + ".upload";
                        item.fileid = item.id;
                        onlineFiles.add(item, 0);
                    });
                    onlineFiles.defaultChecked = false;
                    onCheckListChange();
                    return st.map(function (item){
                        return item.id;
                    });
                });
            }

            /********************** EVENTS ************************************************************************/

            function onCheckListChange() {
                var fileIdList = getSelectedFileIdList();
                var pendingFileList = getPendingUploadFileList();
                okBtn.disabled = fileIdList.length + pendingFileList.length === 0;
            }

            onlineFiles.on('check', onCheckListChange);
            offlineFiles.on('change', uploadPendingFiles);

            function finishWithResult() {
                var fileIdList = getSelectedFileIdList();
                var fileInfoList =  fileIdList.map(function (fileid){
                    var index = host.database.files.getIndex(fileid);
                    var item = host.database.files.items[index];
                    item.url = window.domainFilesNew + item.id + "_" + item.name + ".upload";
                    return item;
                });
                ModalElement.close();
                resolve(fileInfoList);

            }

            /********************** MAIN ******************************************************************************/


            redrawPathList();
            redrawOnlineFiles(DEFAULT_PATH_ID);

            ModalElement.showWindow({
                title: "Chọn file",
                bodycontent: view
            });
        }


        ModalElement.show_loading();
        FormClass.api_call({
            url: "database_load.php",
            params: [
                { name: "task", value: "paths_load_init" }
            ],
            func: function (success, message) {
                if (success) {
                    ModalElement.close(-1);
                    if (message.substr(0, 2) == "ok") {
                        var content = EncodingClass.string.toVariable(message.substr(2));
                        contentModule.makeDatabaseContent(host, content);
                        contentModule.makePathIndex(host);
                        openDialog();
                    }
                    else {
                        ModalElement.alert({ message: message });
                    }
                }
                else {
                    ModalElement.alert({ message: message });
                }
            }
        });
    });
};

contentModule.getWorktime_checkinMainData = function(){
    return {
        type_worktime_checkins_employeeid: "employeeid",
        type_worktime_checkins_machineid: "machineid",
        type_worktime_checkins_ctime: "ctime",
        type_worktime_checkins_available: "available"
    }
};

contentModule.getWorktime_machineMainData = function(){
    return {
        type_worktime_machines_name: "name",
        type_worktime_machines_geoid: "geoid",
        type_worktime_machines_available: "available"
    }
};

contentModule.getWorktime_machinesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.worktime_machines.items.length; i++){
        list.push({
            value: host.database.worktime_machines.items[i].id,
            text: host.database.worktime_machines.items[i].name
        });
    }
    return list;
};

contentModule.getMemberOfTemplateGroupSelectMenu = function(host){
    var list = [
        {
            value: 0,
            text: LanguageModule.text("txt_select_value")
        },
        {
            value: -1,
            typeid: 0,
            text: LanguageModule.text("txt_onboarding")
        },
        {
            value: -2,
            typeid: 0,
            text: "Khác..."
        }
    ];
    for (var i = 0; i < host.database.template_groups.items.length; i++){
        list.push({
            value: host.database.template_groups.items[i].id,
            typeid: host.database.template_groups.items[i].typeid,
            text: host.database.template_groups.items[i].name
        });
    }
    return list;
};

contentModule.getMemberOfWelcomeTemplateSelectMenu = function(host){
    // var list = [{
    //     value: 0,
    //     text: LanguageModule.text("txt_select_value")
    // }];
    var list = [];
    for (var i = 0; i < host.database.welcome_templates.items.length; i++){
        list.push({
            value: host.database.welcome_templates.items[i].id,
            text: host.database.welcome_templates.items[i].name
        });
    }
    return list;
};

contentModule.getWorktime_logMainData = function(){
    return {
        type_worktime_logs_employeeid: "employeeid",
        type_worktime_logs_shift: "shiftid",
        type_worktime_logs_machineid: "machineid",
        type_worktime_logs_intime: "intime",
        type_worktime_logs_outtime: "outtime",
        type_worktime_logs_available: "available"
    }
};

contentModule.getLanguageCodeList = function(type){
    var res = [];
    if (!type || type == "display") res.push({
        value: "javascript",
        text: LanguageModule.text("txt_javascript")
    });
    res.push(
        {
            value: "simple_code",
            text: LanguageModule.text("txt_simple_code")
        }
    );
    return res;
};

contentModule.getLanguageCodeName = function(language){
    var list = contentModule.getLanguageCodeList();
    for (var i = 0; i < list.length; i++){
        if (language == list[i].value) return list[i].text;
    }
    return "-";
};

contentModule.makeDataFunctions = function(content){
    content.params = EncodingClass.string.toVariable(content.params);
    switch (content.language) {
        case "simple_code":
            content.content = EncodingClass.string.toVariable(content.content);
            break;
        default:

    }
};

contentModule.getFunctionTypeList = function(){
    return [
        {
            value: "display",
            text: LanguageModule.text("txt_display")
        },
        {
            value: "handle",
            text: LanguageModule.text("txt_handle")
        }
    ];
};

contentModule.loadListPrimaryTypeEnum = function(type){
    return new Promise(function(resolve, reject){
        function makeData(st){
            var x = {
                database: {}
            };
            contentModule.makeDatabaseContent(x, st);
            var list;
            switch (type) {
                case "user":
                    list = contentModule.getUsersListSelectMenu(x);
                    break
                case "userlist":
                    list = contentModule.getUsersListSelectBox(x);
                    break;
                case "member_of_position":
                    contentModule.makeOrgsIndex(x);
                    contentModule.makePositionsIndex(x);
                    list = contentModule.getMemberOfPositionSelectMenu(x);
                    break;
                case "member_of_template_groups":
                    list = contentModule.getMemberOfTemplateGroupSelectMenu(x);
                    break;
                case "member_of_welcome_templates":
                    list = contentModule.getMemberOfWelcomeTemplateSelectMenu(x);
                    break;
                case "member_of_employee":
                    contentModule.makeOrgsIndex(x);
                    contentModule.makeEmployeeData(x);
                    contentModule.makeEmployeesIndex(x);
                    list = contentModule.getMemberOfEmployeeSelectMenu(x);
                    break;
                case "employee_list":
                    contentModule.makeOrgsIndex(x);
                    contentModule.makeEmployeeData(x);
                    contentModule.makeEmployeesIndex(x);
                    list = contentModule.getMemberOfEmployeeSelectMenu(x);
                    break;
                case "position_list":
                    contentModule.makeOrgsIndex(x);
                    contentModule.makePositionsIndex(x);
                    list = contentModule.getMemberOfPositionSelectMenu(x);
                    break;
                case "select_department_employee":
                    contentModule.makeOrgsIndex(x);
                    contentModule.makeEmployeeData(x);
                    contentModule.makeEmployeesIndex(x);
                    list = contentModule.getOrgsAndEmployeesListSelectTreeMenu(x);
                    break;
                case "member_of_worktime_machines":
                    list = contentModule.getWorktime_machinesListSelectMenu(x);
                    break;
                case "member_of_department":
                    contentModule.makeOrgsIndex(x);
                    list = contentModule.getOrgsListSelectTreeMenu(x);
                    break;
                case "member_of_assets":
                    list = contentModule.getAssetsListSelectMenu(x);
                    break;
                case "member_of_instruments_and_tools":
                    list = contentModule.getInstrumentAndToolsListSelectMenu(x);
                    break;
                case "member_of_warehouses":
                    list = contentModule.getWarehousesListSelectMenu(x);
                    break;
                case "member_of_assets_instruments_and_tools":
                    list = contentModule.getAssetsInstrumentAndToolsListSelectMenu(x);
                    break;
                case "member_of_allowance_policy_groups":
                    list = contentModule.getAllowancePolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_insurance_policy_groups":
                    list = contentModule.getInsurancePolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_bonus_policy_groups":
                    list = contentModule.getBonusPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_work_flow_groups":
                    list = contentModule.getWorkFlowGroupsListSelectMenu(x);
                    break;
                case "member_of_work_flows":
                    list = contentModule.getWorkFlowsListSelectMenu(x);
                    break;
                case "member_of_objects":
                    list = contentModule.getObjectsListSelectMenu(x);
                    break;
                case "member_of_payroll_cycle":
                    list = contentModule.getPayrollCycleListSelectMenu(x);
                    break;
                case "member_of_lesson_categories":
                    list = contentModule.getLessonCategoriesListSelectMenu(x);
                    break;
                case "member_of_task":
                    list = contentModule.getTaskListSelectMenu(x);
                    break;
                case "member_of_meeting":
                    list = contentModule.getMeetingListSelectMenu(x);
                    break;
                case "member_of_typelists":
                    list = contentModule.getTypeListsListSelectMenu(x);
                    break;
                case "member_of_input_forms":
                    list = contentModule.getInputFormsListSelectMenu();
                    break;
                case "member_of_output_forms":
                    list = contentModule.getOutputFormsListSelectMenu();
                    break;
                case "member_of_mobile_input_forms":
                    list = contentModule.getMobileInputFormsListSelectMenu();
                    break;
                case "member_of_mobile_output_forms":
                    list = contentModule.getMobileOutputFormsListSelectMenu();
                    break;
                case "member_of_partner_class":
                    list = contentModule.getPartnerClassListSelectMenu(x);
                    break;
                case "member_of_partner":
                    list = contentModule.getPartnerListSelectMenu(x);
                    break;
                case "member_of_contact":
                    list = contentModule.getContactListSelectMenu(x);
                    break;
                case "member_of_other_liability_policy_groups":
                    list = contentModule.getOtherLiabilityPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_salary_policy_groups":
                    list = contentModule.getSalaryPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_trade_union_policy_groups":
                    list = contentModule.getTradeUnionPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_overtime_policy_groups":
                    list = contentModule.getOvertimePolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_offboarding_types":
                    list = contentModule.getOffboardingTypeListSelectMenu(x);
                    break;
                case "member_of_offboarding_reasons":
                    list = contentModule.getOffboardingReasonListSelectMenu(x);
                    break;
                case "multiselect_offboarding_reasons":
                    list = contentModule.getOffboardingReasonListSelectMenu(x);
                    list.splice(0, 1);
                    break;
                case "member_of_punishment_policy_groups":
                    list = contentModule.getPunishmentPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_asset_category":
                    list = contentModule.getAssetCategoryListSelectMenu(x);
                    break;
                case "member_of_instruments_and_tools_category":
                    list = contentModule.getAssetsInstrumentAndToolsCategoryListSelectMenu(x);
                    break;
                case "member_of_projects":
                    list = contentModule.getProjectsListSelectMenu(x);
                    break;
                case "member_of_tax_policy_groups":
                    list = contentModule.getTaxPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_advance_payment_policy_groups":
                    list = contentModule.getAdvancePaymentPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_late_early_checkin_policy_groups":
                    list = contentModule.getLateEarlyCheckinPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_training_program_groups":
                    list = contentModule.getTrainingProgramGroupsListSelectMenu(x);
                    break;
                case "member_of_leave_policy_groups":
                    list = contentModule.getLeavePolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_benefit_policy_groups":
                    list = contentModule.getBenefitPolicyGroupsListSelectMenu(x);
                    break;
                case "member_of_shifts":
                    list = contentModule.getShiftsListSelectMenu(x);
                    break;
                case "members_of_shifts":
                    list = contentModule.getShiftsListSelectBox(x);
                    break;
                case "members_of_partner_class":
                    list = contentModule.getPartnerClassListSelectBox(x);
                    break;
                case "members_of_locations":
                    list = contentModule.getGeoposListSelectBox(x);
                    break;
                case "member_of_insurance_policies":
                    list = contentModule.getInsurancePoliciesListSelectMenu(x);
                    break;
                case "member_of_tax_policies":
                    list = contentModule.getTaxPoliciesListSelectMenu(x);
                    break;
                case "member_of_leave_policies":
                    list = contentModule.getLeavePoliciesListSelectMenu(x);
                    break;
                case "member_of_trade_union_policies":
                    list = contentModule.getTradeUnionPoliciesListSelectMenu(x);
                    break;
                case "member_of_bonus_policies":
                    list = contentModule.getBonusPoliciesListSelectMenu(x);
                    break;
                case "member_of_overtime_policies":
                    list = contentModule.getOvertimePoliciesListSelectMenu(x);
                    break;
                case "member_of_punishment_policies":
                    list = contentModule.getPunishmentPoliciesListSelectMenu(x);
                    break;
                case "member_of_benefit_policies":
                    list = contentModule.getBenefitPoliciesListSelectMenu(x);
                    break;
                case "member_of_allowance_policies":
                    list = contentModule.getAllowancePoliciesListSelectMenu(x);
                    break;
                case "member_of_advance_payment_policies":
                    list = contentModule.getAdvancePaymentPoliciesListSelectMenu(x);
                    break;
                case "member_of_late_early_checkin_policies":
                    list = contentModule.getLateEarlyCheckinPoliciesListSelectMenu(x);
                    break;
                case "member_of_salary_policies":
                    list = contentModule.getSalaryPoliciesListSelectMenu(x);
                    break;
                case "member_of_other_liability_policies":
                    list = contentModule.getOtherLiabilityPoliciesListSelectMenu(x);
                    break;
                case "member_of_employment_contract_types":
                    list = contentModule.getEmploymentContractTypesListSelectMenu(x);
                    break;
                case "member_of_nations":
                    list = contentModule.getNationsListSelectMenu(x);
                    break;
                case "member_of_cities":
                    list = contentModule.getCitiesListSelectMenu(x);
                    break;
                case "nation_city":
                    contentModule.makeCitiesIndex(x);
                    list = contentModule.getNationCityDualSelectMenu(x);
                    break;
                case "member_of_ethnics":
                    list = contentModule.getEthnicsListSelectMenu(x);
                    break;
                case "member_of_religions":
                    list = contentModule.getReligionsListSelectMenu(x);
                    break;
                case "geopos":
                    list = contentModule.getGeoposListSelectMenu(x);
                    break;
                case "member_of_document_types":
                    list = contentModule.getDocumentTypesListSelectMenu(x);
                    break;
                case "member_of_document_groups":
                    list = contentModule.getDocumentGroupsListSelectTreeMenu(x);
                    break;
                case "member_of_orgs":
                    list = contentModule.getOrgsListSelectMenu(x);
                    break;
                case "member_of_document_folders":
                    list = contentModule.getDocumentFoldersListSelectTreeMenu(x);
                    break;
                default:
                    list = [];
            }
            resolve(list);
        };
        switch (type) {
            case "user":
            case "userlist":
                data_module.loadUsersList().then(function(content){
                    makeData({
                        users: content
                    });
                });
                break;
            case "member_of_position":
            case "position_list":
                Promise.all([data_module.loadPositionsList(), data_module.loadOrgsList()]).then(function(content){
                    makeData({
                        positions: content[0],
                        orgs: content[1]
                    });
                });
                break;
            case "member_of_employee":
            case "employee_list":
            case "select_department_employee":
                Promise.all([data_module.loadEmployeesList(), data_module.loadPeoplesList(), data_module.loadOrgsList()]).then(function(content){
                    makeData({
                        employees: content[0],
                        peoples: content[1],
                        orgs: content[2]
                    });
                });
                break;
            case "member_of_worktime_machines":
                data_module.loadWorktimeMachinesList().then(function(content){
                    makeData({
                        worktime_machines: content
                    });
                });
                break;
            case "member_of_template_groups":
                data_module.loadTemplateGroupList().then(function(content){
                    makeData({
                        template_groups: content
                    });
                });
                break;
            case "member_of_welcome_templates":
                data_module.loadWelcomeTemplatesList().then(function(content){
                    makeData({
                        welcome_templates: content
                    });
                });
                break;
            case "member_of_assets":
                data_module.loadAssetsList().then(function(content){
                    makeData({
                        assets: content
                    });
                });
                break;
            case "member_of_instruments_and_tools":
                data_module.loadInstruments_and_toolsList().then(function(content){
                    makeData({
                        instruments_and_tools: content
                    });
                });
                break;
            case "member_of_assets_instruments_and_tools":
                Promise.all([data_module.loadAssetsList(), data_module.loadInstruments_and_toolsList()]).then(function(content){
                    makeData({
                        assets: content[0],
                        instruments_and_tools: content[1]
                    });
                })
                break;
            case "member_of_warehouses":
                data_module.loadWarehousesList().then(function(content){
                    makeData({
                        warehouses: content
                    });
                });
                break;
            case "member_of_department":
                data_module.loadOrgsList().then(function(content){
                    makeData({
                        orgs: content
                    });
                });
                break;
            case "member_of_allowance_policy_groups":
                data_module.loadAllowance_policy_groupsList().then(function(content){
                    makeData({
                        allowance_policy_groups: content
                    });
                });
                break;
            case "member_of_insurance_policy_groups":
                data_module.loadInsurance_policy_groupsList().then(function(content){
                    makeData({
                        insurance_policy_groups: content
                    });
                });
                break;
            case "member_of_bonus_policy_groups":
                data_module.loadBonus_policy_groupsList().then(function(content){
                    makeData({
                        bonus_policy_groups: content
                    });
                });
                break;
            case "member_of_work_flow_groups":
                data_module.loadWork_flow_groupsList().then(function(content){
                    makeData({
                        work_flow_groups: content
                    });
                });
                break;
            case "member_of_work_flows":
                data_module.loadWork_flowsList().then(function(content){
                    makeData({
                        work_flows: content
                    });
                });
                break;
            case "member_of_objects":
                data_module.loadObjectsList().then(function(content){
                    makeData({
                        objects: content
                    });
                });
                break;
            case "member_of_payroll_cycle":
                data_module.loadPayrollCycleList().then(function(content){
                    makeData({
                        payroll_cycle: content
                    });
                });
                break;
            case "member_of_lesson_categories":
                data_module.loadLesson_categoriesList().then(function(content){
                    makeData({
                        objects: content
                    });
                });
                break;
            case "member_of_task":
                data_module.loadTaskListLazySimpleData().then(function(content){
                    makeData({
                        task: content
                    });
                });
                break;
            case "member_of_meeting":
                data_module.loadMeetingListLazySimpleData().then(function(content){
                    makeData({
                        meeting: content
                    });
                });
                break;
            case "member_of_typelists":
                data_module.loadType_listsList().then(function(content){
                    makeData({
                        typelists: content
                    });
                });
                break;
            case "member_of_input_forms":
                makeData({});
                break;
            case "member_of_output_forms":
                makeData({});
                break;
            case "member_of_mobile_input_forms":
                makeData({});
                break;
            case "member_of_mobile_output_forms":
                makeData({});
                break;
            case "member_of_partner_class":
                data_module.loadPartner_classList().then(function(content){
                    makeData({
                        partner_class: content
                    });
                });
                break;
            case "member_of_partner":
                data_module.loadPartnerSingleList().then(function(content){
                    makeData({
                        partner: content
                    });
                });
                break;
            case "member_of_contact":
                data_module.loadContactList().then(function(content){
                    makeData({
                        contact: content
                    });
                });
                break;
            case "member_of_other_liability_policy_groups":
                data_module.loadOther_liability_policy_groupsList().then(function(content){
                    makeData({
                        other_liability_policy_groups: content
                    });
                });
                break;
            case "member_of_salary_policy_groups":
                data_module.loadSalary_policy_groupsList().then(function(content){
                    makeData({
                        salary_policy_groups: content
                    });
                });
                break;
            case "member_of_trade_union_policy_groups":
                data_module.loadTrade_union_policy_groupsList().then(function(content){
                    makeData({
                        trade_union_policy_groups: content
                    });
                });
                break;
            case "member_of_overtime_policy_groups":
                data_module.loadOvertime_policy_groupsList().then(function(content){
                    makeData({
                        overtime_policy_groups: content
                    });
                });
                break;
            case "member_of_offboarding_types":
                data_module.loadOffboardingTypeList().then(function(content){
                    makeData({
                        offboarding_types: content
                    });
                });
                break;
            case "member_of_offboarding_reasons":
                data_module.loadOffboardingReasonList().then(function(content){
                    makeData({
                        offboarding_reasons: content
                    });
                });
                break;
            case "multiselect_offboarding_reasons":
                data_module.loadOffboardingReasonList().then(function(content){
                    makeData({
                        offboarding_reasons: content
                    });
                });
                break;
            case "member_of_punishment_policy_groups":
                data_module.loadPunishment_policy_groupsList().then(function(content){
                    makeData({
                        punishment_policy_groups: content
                    });
                });
                break;
            case "member_of_asset_category":
                data_module.loadAssetCategoryList().then(function(content){
                    makeData({
                        asset_category: content
                    });
                });
                break;
            case "member_of_instruments_and_tools_category":
                data_module.loadInstrumentsAndToolsCategoryList().then(function(content){
                    makeData({
                        instruments_and_tools_category: content
                    });
                });
                break;
            case "member_of_projects":
                data_module.loadProjectsList().then(function(content){
                    makeData({
                        projects: content
                    });
                });
                break;
            case "member_of_tax_policy_groups":
                data_module.loadTax_policy_groupsList().then(function(content){
                    makeData({
                        tax_policy_groups: content
                    });
                });
                break;
            case "member_of_advance_payment_policy_groups":
                data_module.loadAdvance_payment_policy_groupsList().then(function(content){
                    makeData({
                        advance_payment_policy_groups: content
                    });
                });
                break;
            case "member_of_late_early_checkin_policy_groups":
                data_module.loadLate_early_checkin_policy_groupsList().then(function(content){
                    makeData({
                        late_early_checkin_policy_groups: content
                    });
                });
                break;
            case "member_of_benefit_policy_groups":
                data_module.loadBenefit_policy_groupsList().then(function(content){
                    makeData({
                        benefit_policy_groups: content
                    });
                });
                break;
            case "member_of_training_program_groups":
                data_module.loadTrainingProgram_groupsList().then(function(content){
                    makeData({
                        training_program_groups: content
                    });
                });
                break;
            case "member_of_leave_policy_groups":
                data_module.loadLeave_policy_groupsList().then(function(content){
                    makeData({
                        leave_policy_groups: content
                    });
                });
                break;
            case "member_of_shifts":
                data_module.loadShiftsList().then(function(content){
                    makeData({
                        shifts: content
                    });
                });
                break;
            case "members_of_shifts":
                data_module.loadShiftsList().then(function(content){
                    makeData({
                        shifts: content
                    });
                });
                break;
            case "members_of_partner_class":
                data_module.loadPartner_classList().then(function(content){
                    makeData({
                        partner_class: content
                    });
                });
                break;
            case "members_of_locations":
                data_module.loadGeographiesList().then(function(content){
                    makeData({
                        geopos: content
                    });
                });
                break;
            case "member_of_insurance_policies":
                data_module.loadInsurance_policiesList().then(function(content){
                    makeData({
                        insurance_policies: content
                    });
                });
                break;
            case "member_of_tax_policies":
                data_module.loadTax_policiesList().then(function(content){
                    makeData({
                        tax_policies: content
                    });
                });
                break;
            case "member_of_trade_union_policies":
                data_module.loadTrade_union_policiesList().then(function(content){
                    makeData({
                        trade_union_policies: content
                    });
                });
                break;
            case "member_of_benefit_policies":
                data_module.loadBenefit_policiesList().then(function(content){
                    makeData({
                        benefit_policies: content
                    });
                });
                break;
            case "member_of_allowance_policies":
                data_module.loadAllowance_policiesList().then(function(content){
                    makeData({
                        allowance_policies: content
                    });
                });
                break;
            case "member_of_bonus_policies":
                data_module.loadBonus_policiesList().then(function(content){
                    makeData({
                        bonus_policies: content
                    });
                });
                break;
            case "member_of_overtime_policies":
                data_module.loadOvertime_policiesList().then(function(content){
                    makeData({
                        overtime_policies: content
                    });
                });
                break;
            case "member_of_punishment_policies":
                data_module.loadPunishment_policiesList().then(function(content){
                    makeData({
                        punishment_policies: content
                    });
                });
                break;
            case "member_of_advance_payment_policies":
                data_module.loadAdvance_payment_policiesList().then(function(content){
                    makeData({
                        advance_payment_policies: content
                    });
                });
                break;
            case "member_of_late_early_checkin_policies":
                data_module.loadLate_early_checkin_policiesList().then(function(content){
                    makeData({
                        late_early_checkin_policies: content
                    });
                });
                break;
            case "member_of_salary_policies":
                data_module.loadSalary_policiesList().then(function(content){
                    makeData({
                        salary_policies: content
                    });
                });
                break;
            case "member_of_leave_policies":
                data_module.loadLeave_policiesList().then(function(content){
                    makeData({
                        leave_policies: content
                    });
                });
                break;
            case "member_of_other_liability_policies":
                data_module.loadOther_liability_policiesList().then(function(content){
                    makeData({
                        other_liability_policies: content
                    });
                });
                break;
            case "member_of_employment_contract_types":
                data_module.loadEmployment_contract_typesList().then(function(content){
                    makeData({
                        employment_contract_types: content
                    });
                });
                break;
            case "member_of_nations":
                data_module.loadNationsList().then(function(content){
                    makeData({
                        nations: content
                    });
                });
                break;
            case "nation_city":
                Promise.all([data_module.loadNationsList(), data_module.loadCitiesList()]).then(function(content){
                    makeData({
                        nations: content[0],
                        cities: content[1]
                    });
                });
                break;
            case "member_of_cities":
                data_module.loadCitiesList().then(function(content){
                    makeData({
                        cities: content
                    });
                });
                break;
            case "member_of_ethnics":
                data_module.loadEthnicsList().then(function(content){
                    makeData({
                        ethnics: content
                    });
                });
                break;
            case "member_of_religions":
                data_module.loadReligionsList().then(function(content){
                    makeData({
                        religions: content
                    });
                });
                break;
            case "geopos":
                data_module.loadGeographiesList().then(function(content){
                    makeData({
                        geopos: content
                    });
                });
                break;
            case "member_of_document_types":
                data_module.loadDocument_typesList().then(function(content){
                    makeData({
                        document_types: content
                    });
                });
                break;
            case "member_of_document_groups":
                data_module.loadDocument_groupsList().then(function(content){
                    makeData({
                        document_groups: content
                    });
                });
                break;
            case "member_of_document_folders":
                data_module.loadDocument_foldersList().then(function(content){
                    makeData({
                        document_folders: content
                    });
                });
                break;
            case "member_of_orgs":
                data_module.loadOrgCompanysList().then(function(content){
                    makeData({
                        orgs: content
                    });
                });
                break;
            default:
                makeData({});
        }
    });
};

contentModule.getAssetMainData = function(){
    return {
        type_asset_name: "name",
        type_asset_code: "code",
        type_asset_asset_category: "categoryid",
        type_asset_specification: "specification",
        type_asset_warehouseid: "warehouseid",
        type_asset_input_date: "input_date",
        type_asset_purchased_price: "purchased_price",
        type_asset_comment: "comment",
        type_asset_attachments: "attachments"
    };
};

contentModule.getInstrumentsAndToolsMainData = function(){
    return {
        type_instruments_and_tools_name: "name",
        type_instruments_and_tools_code: "code",
        type_instruments_and_tools_warehouseid: "warehouseid",
        type_instruments_and_tools_asset_category: "categoryid",
        type_instruments_and_tools_specification: "specification",
        type_instruments_and_tools_amount: "amount",
        type_instruments_and_tools_unit: "unit",
        type_instruments_and_tools_input_date: "input_date",
        type_instruments_and_tools_purchased_price: "purchased_price",
        type_instruments_and_tools_comment: "comment",
        type_instruments_and_tools_attachments: "attachments"
    };
};

contentModule.getWarehouseMainData = function(){
    return {
        type_warehouses_name: "name",
        type_warehouses_code: "code",
        type_warehouses_storekeepers: "storekeepers",
        type_warehouses_geoid: "geoid",
        type_warehouses_available: "available"
    };
};

contentModule.getAssetHandoverLinesMainData = function(){
    return {
        type_asset_handover_lines_assetid: "assetid",
        type_asset_handover_lines_status: "status",
        type_asset_handover_lines_comment: "comment"
    };
};

contentModule.getAssetHandoverMainData = function(){
    return {
        type_asset_handover_date: "date_transaction",
        type_asset_handover_warehouseid: "warehouseid",
        type_asset_handover_receiver: "employeeid",
        type_asset_handover_comment: "comment",
        type_asset_handover_attachments: "attachments",
        type_asset_handover_details: "details"
    };
};

contentModule.getInstrumentsAndToolsHandoverLinesMainData = function(){
    return {
        type_instruments_and_tools_handover_lines_assetid: "assetid",
        type_instruments_and_tools_handover_lines_unit: "unit",
        type_instruments_and_tools_handover_lines_inventory: "inventory",
        type_instruments_and_tools_handover_lines_amount: "amount",
        type_instruments_and_tools_handover_lines_comment: "comment"
    };
};

contentModule.getInstrumentsAndToolsHandoverMainData = function(){
    return {
        type_instruments_and_tools_handover_date: "date_transaction",
        type_instruments_and_tools_handover_warehouseid: "warehouseid",
        type_instruments_and_tools_handover_receiver: "employeeid",
        type_instruments_and_tools_handover_comment: "comment",
        type_instruments_and_tools_handover_attachments: "attachments",
        type_instruments_and_tools_handover_details: "details"
    };
};

contentModule.getAssetRecallLinesMainData = function(){
    return {
        type_asset_recall_lines_assetid: "assetid",
        type_asset_recall_lines_status: "status",
        type_asset_recall_lines_comment: "comment"
    };
};

contentModule.getDayOffLinesMainData = function(){
    return {
        type_day_off_lines_date: "date",
        type_day_off_lines_days_portion: "days_portion"
    };
};

contentModule.getAssetRecallMainData = function(){
    return {
        type_asset_recall_date: "date_transaction",
        type_asset_recall_warehouseid: "warehouseid",
        type_asset_recall_employeeid: "employeeid",
        type_asset_recall_comment: "comment",
        type_asset_recall_attachments: "attachments",
        type_asset_recall_details: "details"
    };
};

contentModule.getTrainingProgramGroupsMainData = function(){
    return {
        type_training_program_group_name: "name",
        type_training_program_group_description: "description",
        type_training_program_group_active: "available"
    };
};

contentModule.getTrainingProgramMainData = function(){
    return {
        type_training_program_name: "name",
        type_training_program_status: "status",
        type_training_program_group: "groupid",
        type_training_program_stime: "stime",
        type_training_program_etime: "etime",
        type_training_program_registration_deadline: "deadline",
        type_training_program_content: "content",
        type_training_program_available: "available"
    };
};

contentModule.getAllowancePolicyGroupsMainData = function(){
    return {
        type_allowance_policy_group_name: "name",
        type_allowance_policy_group_description: "description",
        type_allowance_policy_group_active: "available"
    };
};

contentModule.getBonusPolicyGroupsMainData = function(){
    return {
        type_bonus_policy_group_name: "name",
        type_bonus_policy_group_description: "description",
        type_bonus_policy_group_active: "available"
    };
};

contentModule.getWorkFlowGroupsMainData = function(){
    return {
        type_work_flow_group_name: "name",
        type_work_flow_group_description: "description",
        type_work_flow_group_active: "available"
    };
};

contentModule.getWorkFlowsMainData = function(){
    return {
        type_work_flow_name: "name",
        type_work_flow_groupid: "groupid",
        type_work_flow_description: "description",
        type_work_flow_type_extra_of_object: "type_extra_of_object",
        type_work_flow_input_form_extra_of_object: "input_form_extra_of_object",
        type_work_flow_output_form_extra_of_object: "output_form_extra_of_object",
        type_work_flow_mobile_input_form_extra_of_object: "mobile_input_form_extra_of_object",
        type_work_flow_mobile_output_form_extra_of_object: "mobile_output_form_extra_of_object",
        type_work_flow_active: "available"
    };
};

contentModule.getObjectsMainData = function(){
    return {
        type_object_name: "name",
        type_object_work_flowid: "work_flowid",
        type_object_period: "period",
        type_object_priority: "priority",
        type_object_attachments: "attachments",
        type_object_description: "description"
    };
};

contentModule.getPartnerClassMainData = function(){
    return {
        type_partner_class_name: "name",
        type_partner_class_color: "color",
        type_partner_class_description: "description",
        type_partner_class_type_extra: "type_extra",
        type_partner_class_input_form_extra: "input_form_extra",
        type_partner_class_output_form_extra: "output_form_extra",
        type_partner_class_mobile_input_form_extra: "mobile_input_form_extra",
        type_partner_class_mobile_output_form_extra: "mobile_output_form_extra",
        type_partner_class_active: "available"
    };
};

contentModule.getPartnerMainData = function(){
    return {
        type_partner_fullname: "fullname",
        type_partner_name: "name",
        type_partner_class: "class",
        type_partner_address: "address",
        type_partner_nation_city: "nation_city",
        type_partner_phone: "phone",
        type_partner_email: "email",
        type_partner_website: "website",
        type_partner_fax: "fax",
        type_partner_taxcode: "taxcode",
        type_partner_description: "description",
        type_partner_active: "available",
        type_partner_gps: "gps"
    };
};

contentModule.getContactMainData = function(){
    return {
        type_contact_name: "name",
        type_contact_position: "position",
        type_contact_department: "department",
        type_contact_partnerid: "partnerid",
        type_contact_phone_1: "phone_1",
        type_contact_phone_2: "phone_2",
        type_contact_email_1: "email_1",
        type_contact_email_2: "email_2",
        type_contact_owner: "owner",
        type_contact_active: "available"
    };
};


contentModule.getSalaryPolicyGroupsMainData = function(){
    return {
        type_salary_policy_group_name: "name",
        type_salary_policy_group_description: "description",
        type_salary_policy_group_active: "available"
    };
};

contentModule.getTradeUnionPolicyGroupsMainData = function(){
    return {
        type_trade_union_policy_group_name: "name",
        type_trade_union_policy_group_description: "description",
        type_trade_union_policy_group_active: "available"
    };
};

contentModule.getOvertimePolicyGroupsMainData = function(){
    return {
        type_overtime_policy_group_name: "name",
        type_overtime_policy_group_description: "description",
        type_overtime_policy_group_active: "available"
    };
};

contentModule.getOtherLiabilityPolicyGroupsMainData = function(){
    return {
        type_other_liability_policy_group_name: "name",
        type_other_liability_policy_group_description: "description",
        type_other_liability_policy_group_active: "available"
    };
};

contentModule.getPunishmentPolicyGroupsMainData = function(){
    return {
        type_punishment_policy_group_name: "name",
        type_punishment_policy_group_description: "description",
        type_punishment_policy_group_active: "available"
    };
};

contentModule.getAssetCategoryMainData = function(){
    return {
        type_asset_category_name: "name",
        type_asset_category_description: "description",
        type_asset_category_active: "available"
    };
};

contentModule.getInstrumentsAndToolsCategoryMainData = function(){
    return {
        type_instruments_and_tools_category_name: "name",
        type_instruments_and_tools_category_description: "description",
        type_instruments_and_tools_category_active: "available"
    };
};

contentModule.getProjectsMainData = function(){
    return {
        type_projects_name: "name",
        type_projects_geoid: "geoid",
        type_projects_timestart: "timestart",
        type_projects_timeend: "timeend",
        type_projects_comment: "comment",
        type_projects_active: "available"
    };
};

contentModule.getProjectAppliedToEmployeeMainData = function(){
    return {
        type_project_applied_to_employee_employeeid: "employeeid",
        type_project_applied_to_employee_projectid: "projectid",
        type_project_applied_to_employee_timestart: "timestart",
        type_project_applied_to_employee_timeend: "timeend",
        type_project_applied_to_employee_available: "available"
    };
};

contentModule.getTaxPolicyGroupsMainData = function(){
    return {
        type_tax_policy_group_name: "name",
        type_tax_policy_group_description: "description",
        type_tax_policy_group_active: "available"
    };
};

contentModule.getAdvancePaymentPolicyGroupsMainData = function(){
    return {
        type_advance_payment_policy_group_name: "name",
        type_advance_payment_policy_group_description: "description",
        type_advance_payment_policy_group_active: "available"
    };
};

contentModule.getLateEarlyCheckinPolicyGroupsMainData = function(){
    return {
        type_late_early_checkin_policy_group_name: "name",
        type_late_early_checkin_policy_group_description: "description",
        type_late_early_checkin_policy_group_active: "available"
    };
};

contentModule.getBenefitPolicyGroupsMainData = function(){
    return {
        type_benefit_policy_group_name: "name",
        type_benefit_policy_group_description: "description",
        type_benefit_policy_group_active: "available"
    };
};

contentModule.getAllowancePoliciesMainData = function(){
    return {
        type_allowance_policy_name: "name",
        type_allowance_policy_description: "description",
        type_allowance_policy_groupid: "groupid",
        type_allowance_policy_taxable_income: "taxable_income",
        type_allowance_policy_income_subject_to_insurance_contribution: "income_subject_to_insurance_contribution",
        type_allowance_policy_allowance_type: "allowance_type",
        type_allowance_policy_value: "value",
        type_allowance_policy_frequency: "frequency",
        type_allowance_policy_active: "available"
    };
};

contentModule.getBenefitPoliciesMainData = function(){
    return {
        type_benefit_policy_name: "name",
        type_benefit_policy_description: "description",
        type_benefit_policy_groupid: "groupid",
        type_benefit_policy_taxable_income: "taxable_income",
        type_benefit_policy_income_subject_to_insurance_contribution: "income_subject_to_insurance_contribution",
        type_benefit_policy_benefit_type: "benefit_type",
        type_benefit_policy_value: "value",
        type_benefit_policy_frequency: "frequency",
        type_benefit_policy_active: "available"
    };
};

contentModule.getLeavePoliciesMainData = function(){
    return {
        type_leave_policy_name: "name",
        type_leave_policy_description: "description",
        type_leave_policy_groupid: "groupid",
        type_leave_policy_leave_days_per_year: "leave_days_per_year",
        type_leave_policy_maximum_leave_days_per_year: "maximum_leave_days_per_year",
        type_leave_policy_maximal_day_calculation: "maximal_day_calculation",
        type_leave_policy_number_of_working_months_to_increase_one_day_leave: "number_of_working_months_to_increase_one_day_leave",
        type_leave_policy_carried_forward_leave: "carried_forward_leave",
        type_leave_policy_accumulated_leave_expired_before: "accumulated_leave_expired_before",
        type_leave_policy_proposal_submitted_before: "proposal_submitted_before",
        type_leave_policy_salary_paid: "salary_paid",
        type_leave_policy_cancel_request_days: "cancel_request_days",
        type_leave_policy_active: "available"
    };
};

contentModule.getInsurancePolicesMainData = function(){
    return {
        type_insurance_policy_name: "name",
        type_insurance_policy_description: "description",
        type_insurance_policy_groupid: "groupid",
        type_insurance_policy_calculated_on: "calculated_on",
        type_insurance_policy_contributed_by_company: "contributed_by_company",
        type_insurance_policy_contributed_by_employee: "contributed_by_employee",
        type_insurance_policy_active: "available"
    };
};

contentModule.getBonusPolicesMainData = function(){
    return {
        type_bonus_policy_name: "name",
        type_bonus_policy_description: "description",
        type_bonus_policy_groupid: "groupid",
        type_bonus_policy_taxable_income: "taxable_income",
        type_bonus_policy_income_subject_to_insurance_contribution: "income_subject_to_insurance_contribution",
        type_bonus_policy_active: "available"
    };
};

contentModule.getPunishmentPolicesMainData = function(){
    return {
        type_punishment_policy_name: "name",
        type_punishment_policy_description: "description",
        type_punishment_policy_groupid: "groupid",
        type_punishment_policy_tax_relief: "tax_relief",
        type_punishment_policy_insurance_contribution_relief: "insurance_contribution_relief",
        type_punishment_policy_active: "available"
    };
};

contentModule.getLeavePolicyGroupsMainData = function(){
    return {
        type_leave_policy_group_name: "name",
        type_leave_policy_group_description: "description",
        type_leave_policy_group_symbol: "symbol",
        type_leave_policy_group_active: "available"
    };
};

contentModule.getInsurancePolicyGroupsMainData = function(){
    return {
        type_insurance_policy_group_name: "name",
        type_insurance_policy_group_description: "description",
        type_insurance_policy_group_active: "available"
    };
};

contentModule.getEmploymentContractTypesMainData = function(){
    return {
        type_employment_contract_type_name: "name",
        type_employment_contract_type_description: "description",
        type_employment_contract_type_active: "available"
    };
};

contentModule.getSocialNetworkMainData = function(){
    return {
        type_social_network_name: "name",
        type_social_network_account: "account"
    };
};

contentModule.getWorkHistoryMainData = function(){
    return {
        type_work_history_position: "position",
        type_work_history_organization: "organization",
        type_work_history_from_month: "from_month",
        type_work_history_to_month: "to_month",
        type_work_history_comment: "comment"
    };
};

contentModule.getEducationHistoryMainData = function(){
    return {
        type_education_history_major: "major",
        type_education_history_school: "school",
        type_education_history_degree: "degree",
        type_education_history_from_month: "from_month",
        type_education_history_to_month: "to_month",
        type_education_history_comment: "comment",
        type_education_history_top_level: "top_level"
    };
};

contentModule.getSkillMainData = function(){
    return {
        type_skill_skill: "skill",
        type_skill_level: "level"
    };
};

contentModule.getBankAccountMainData = function(){
    return {
        type_bank_account_number: "account_number",
        type_bank_account_holder_name: "account_holder_name",
        type_bank_account_bank_name: "bank_name",
        type_bank_account_agency: "agency"
    };
};

contentModule.getPersonalDocumentMainData = function(){
    return {
        type_personal_document_type: "type",
        type_personal_document_number: "number",
        type_personal_document_place: "place_of_issue",
        type_personal_document_date: "date_of_issue",
        type_personal_document_expire_time: "expire_time"
    };
};

contentModule.getPhoneMainData = function(){
    return {
        type_phone_type: "type",
        type_phone_number: "number"
    };
};

contentModule.getEmailMainData = function(){
    return {
        type_email_type: "type",
        type_email_address: "address"
    };
};

contentModule.getAdvancePaymentPolicesMainData = function(){
    return {
        type_advance_payment_policy_name: "name",
        type_advance_payment_policy_description: "description",
        type_advance_payment_policy_groupid: "groupid",
        type_advance_payment_policy_advance_payment_on: "advance_payment_on",
        type_advance_payment_policy_maximum_percentage: "maximum_percentage",
        type_advance_payment_policy_maximum_amount: "maximum_amount",
        type_advance_payment_policy_calculated_on: "calculated_on",
        type_advance_payment_policy_salary_advance: "salary_advance",
        type_advance_payment_policy_active: "available"
    };
};

contentModule.getLateEarlyCheckinPolicesMainData = function(){
    return {
        type_late_early_checkin_policy_name: "name",
        type_late_early_checkin_policy_description: "description",
        type_late_early_checkin_policy_groupid: "groupid",
        type_late_early_checkin_policy_late: "late",
        type_late_early_checkin_policy_early: "early",
        type_late_early_checkin_policy_proposal_submitted_before: "proposal_submitted_before",
        type_late_early_checkin_policy_salary_paid: "salary_paid",
        type_late_early_checkin_policy_active: "available"
    };
};

contentModule.getTaxPolicesMainData = function(){
    return {
        type_tax_policy_name: "name",
        type_tax_policy_description: "description",
        type_tax_policy_groupid: "groupid",
        type_tax_policy_tax_type: "tax_type",
        type_tax_policy_tax_rate_progressive_tax: "tax_rate_progressive_tax",
        type_tax_policy_tax_rate_fixed_percentage: "tax_rate_fixed_percentage",
        type_tax_policy_active: "available"
    };
};

contentModule.getSalaryPolicesMainData = function(){
    return {
        type_salary_policy_name: "name",
        type_salary_policy_description: "description",
        type_salary_policy_groupid: "groupid",
        type_salary_policy_payment_method: "payment_method",
        type_salary_policy_minimum_salary_amount: "minimum_salary_amount",
        type_salary_policy_maximum_salary_amount: "maximum_salary_amount",
        type_salary_policy_active: "available"
    };
};

contentModule.getTradeUnionPolicesMainData = function(){
    return {
        type_trade_union_policy_name: "name",
        type_trade_union_policy_description: "description",
        type_trade_union_policy_groupid: "groupid",
        type_trade_union_policy_tax_relief: "tax_relief",
        type_trade_union_policy_insurance_contribution_relief: "insurance_contribution_relief",
        type_trade_union_policy_fee_type: "fee_type",
        type_trade_union_policy_rate: "rate",
        type_trade_union_policy_amount: "amount",
        type_trade_union_policy_limit_on_maximum_trade_union_fee: "limit_on_maximum_trade_union_fee",
        type_trade_union_policy_maximum_trade_union_fee: "maximum_trade_union_fee",
        type_trade_union_policy_active: "available"
    };
};

contentModule.getOvertimePolicesMainData = function(){
    return {
        type_overtime_policy_name: "name",
        type_overtime_policy_description: "description",
        type_overtime_policy_groupid: "groupid",
        type_overtime_policy_maximum_overtime_hours_per_day: "maximum_overtime_hours_per_day",
        type_overtime_policy_maximum_overtime_hours_per_month: "maximum_overtime_hours_per_month",
        type_overtime_policy_proposal_submitted_before: "proposal_submitted_before",
        type_overtime_policy_active: "available"
    };
};

contentModule.getOvertimeRequestMainData = function(){
    return {
        type_overtime_request_type: "type",
        type_overtime_request_policyid: "policyid",
        type_overtime_request_start: "fromdate",
        type_overtime_request_end: "todate",
        type_overtime_request_overtime_hours: "overtime_hours",
        type_overtime_request_reason: "reason",
        type_overtime_request_requested_for: "requested_for"
    };
};

contentModule.getOtherLiabilityPolicesMainData = function(){
    return {
        type_other_liability_policy_name: "name",
        type_other_liability_policy_description: "description",
        type_other_liability_policy_groupid: "groupid",
        type_other_liability_policy_tax_relief: "tax_relief",
        type_other_liability_policy_insurance_contribution_relief: "insurance_contribution_relief",
        type_other_liability_policy_other_liability_type: "other_liability_type",
        type_other_liability_policy_value: "value",
        type_other_liability_policy_frequency: "frequency",
        type_other_liability_policy_active: "available"
    };
};

contentModule.getInsurancePoliciesAppliedToEmployeeMainData = function(){
    return {
        type_insurance_policies_applied_to_employee_employeeid: "employeeid",
        type_insurance_policies_applied_to_employee_policyid: "policyid",
        type_insurance_policies_applied_to_employee_description: "description",
        type_insurance_policies_applied_to_employee_calculated_on: "calculated_on",
        type_insurance_policies_applied_to_employee_value: "value"
    };
};

contentModule.getOvertimePoliciesAppliedToEmployeeMainData = function(){
    return {
        type_overtime_policies_applied_to_employee_employeeid: "employeeid",
        type_overtime_policies_applied_to_employee_policyid: "policyid",
        type_overtime_policies_applied_to_employee_description: "description"
    };
};

contentModule.getBonusPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_bonus_policies_applied_to_employee_employeeid: "employeeid",
        type_bonus_policies_applied_to_employee_policyid: "policyid",
        type_bonus_policies_applied_to_employee_description: "description"
    };
};

contentModule.getPunishmentPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_punishment_policies_applied_to_employee_employeeid: "employeeid",
        type_punishment_policies_applied_to_employee_policyid: "policyid",
        type_punishment_policies_applied_to_employee_description: "description"
    };
};

contentModule.getBenefitPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_benefit_policies_applied_to_employee_employeeid: "employeeid",
        type_benefit_policies_applied_to_employee_policyid: "policyid",
        type_benefit_policies_applied_to_employee_description: "description",
        type_benefit_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getAllowancePoliciesAppliedToEmployeeMainData = function(){
    return {
        type_allowance_policies_applied_to_employee_employeeid: "employeeid",
        type_allowance_policies_applied_to_employee_policyid: "policyid",
        type_allowance_policies_applied_to_employee_description: "description",
        type_allowance_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getTaxPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_tax_policies_applied_to_employee_employeeid: "employeeid",
        type_tax_policies_applied_to_employee_policyid: "policyid",
        type_tax_policies_applied_to_employee_description: "description",
        type_tax_policies_applied_to_employee_tax_type: "tax_type",
        type_tax_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getTradeUnionPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_trade_union_policies_applied_to_employee_employeeid: "employeeid",
        type_trade_union_policies_applied_to_employee_policyid: "policyid",
        type_trade_union_policies_applied_to_employee_description: "description",
        type_trade_union_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getOtherLiabilityPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_other_liability_policies_applied_to_employee_employeeid: "employeeid",
        type_other_liability_policies_applied_to_employee_policyid: "policyid",
        type_other_liability_policies_applied_to_employee_description: "description",
        type_other_liability_policies_applied_to_employee_tax_relief: "tax_relief",
        type_other_liability_policies_applied_to_employee_insurance_contribution_relief: "insurance_contribution_relief",
        type_other_liability_policies_applied_to_employee_other_liability_type: "other_liability_type",
        type_other_liability_policies_applied_to_employee_frequency: "frequency",
        type_other_liability_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getLeavePoliciesAppliedToEmployeeMainData = function(){
    return {
        type_leave_policies_applied_to_employee_employeeid: "employeeid",
        type_leave_policies_applied_to_employee_policyid: "policyid",
        type_leave_policies_applied_to_employee_description: "description",
        type_leave_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getLateEarlyCheckinPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_late_early_checkin_policies_applied_to_employee_employeeid: "employeeid",
        type_late_early_checkin_policies_applied_to_employee_policyid: "policyid",
        type_late_early_checkin_policies_applied_to_employee_description: "description",
        type_late_early_checkin_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getAdvancePaymentPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_advance_payment_policies_applied_to_employee_employeeid: "employeeid",
        type_advance_payment_policies_applied_to_employee_policyid: "policyid",
        type_advance_payment_policies_applied_to_employee_description: "description",
        type_advance_payment_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getSalaryDecisionsAppliedToEmployeeMainData = function(){
    return {
        type_salary_decisions_applied_to_employee_employeeid: "employeeid",
        type_salary_decisions_applied_to_employee_position: "position",
        type_salary_decisions_applied_to_employee_salary_grade: "salary_grade",
        type_salary_decisions_applied_to_employee_basic_salary_amount: "basic_salary_amount",
        type_salary_decisions_applied_to_employee_gross_salary_amount: "gross_salary_amount",
        type_salary_decisions_applied_to_employee_calculated_on: "calculated_on",
        type_salary_decisions_applied_to_employee_effective_date: "effective_date",
        type_salary_decisions_applied_to_employee_reference_number: "reference_number",
        type_salary_decisions_applied_to_employee_decision_date: "decision_date",
        type_salary_decisions_applied_to_employee_attachments: "attachments",
        type_salary_decisions_applied_to_employee_available: "available"
    };
};

contentModule.getSalaryPoliciesAppliedToEmployeeMainData = function(){
    return {
        type_salary_policies_applied_to_employee_employeeid: "employeeid",
        type_salary_policies_applied_to_employee_position: "position",
        type_salary_policies_applied_to_employee_policyid: "policyid",
        type_salary_policies_applied_to_employee_description: "description",
        type_salary_policies_applied_to_employee_attachments: "attachments"
    };
};

contentModule.getEmploymentContractsMainData = function(){
    return {
        type_employee_employment_contract_employeeid: "employeeid",
        type_employee_employment_contract_contractid: "contractid",
        type_employee_employment_contract_description: "description",
        type_employee_employment_contract_effective_date_from: "effective_date_from",
        type_employee_employment_contract_effective_date_to: "effective_date_to",
        type_employee_employment_contract_attachments: "attachments",
        type_employee_employment_contract_available: "available"
    };
};

contentModule.getBonusListMainData = function(){
    return {
        type_bonus_list_cycleid: "cycleid",
        type_bonus_list_payroll_date_month: "payroll_date_month",
        type_bonus_list_payroll_date_week: "payroll_date_week",
        type_bonus_list_name: "name",
        type_bonus_list_reference_number: "reference_number",
        type_bonus_list_reference_date: "reference_date",
        type_bonus_list_policyid: "policyid"
    };
};

contentModule.getBonusListDetailsMainData = function(){
    return {
        type_bonus_list_details_employeeid: "employeeid",
        type_bonus_list_details_amount: "amount",
        type_bonus_list_details_comment: "comment"
    };
};

contentModule.getPunishmentListDetailsMainData = function(){
    return {
        type_punishment_list_details_employeeid: "employeeid",
        type_punishment_list_details_amount: "amount",
        type_punishment_list_details_comment: "comment"
    };
};

contentModule.getBenefitListDetailsMainData = function(){
    return {
        type_benefit_list_details_employeeid: "employeeid",
        type_benefit_list_details_amount: "amount",
        type_benefit_list_details_comment: "comment"
    };
};

contentModule.getOtherLiabilityListDetailsMainData = function(){
    return {
        type_other_liability_list_details_employeeid: "employeeid",
        type_other_liability_list_details_amount: "amount",
        type_other_liability_list_details_comment: "comment"
    };
};

contentModule.getScoreCardReportLineMainData = function(){
    return {
        type_scorecard_report_line_name: "name",
        type_scorecard_report_line_measurement_unit: "unit",
        type_scorecard_report_line_weight: "weight",
        type_scorecard_report_line_goal: "goal",
        type_scorecard_report_line_low_threshold: "min",
        type_scorecard_report_line_high_threshold: "max",
        type_scorecard_report_line_result: "result",
        type_scorecard_report_line_performance: "performance",
        type_scorecard_report_line_chart: "chart"
    };
};

contentModule.getSalaryAdjustmentListDetailsMainData = function(){
    return {
        type_salary_adjustment_list_details_employeeid: "employeeid",
        type_salary_adjustment_list_details_amount: "amount",
        type_salary_adjustment_list_details_tax_exempt: "tax_exempt",
        type_salary_adjustment_list_details_insurance_exempt: "insurance_exempt",
        type_salary_adjustment_list_details_comment: "comment"
    };
};

contentModule.getOffboardingMainData = function(){
    return {
        type_offboarding_employee_id: "employeeid",
        type_offboarding_status: "status",
        type_offboarding_user: "username",
        type_offboarding_employee_code: "code",
        type_offboarding_direct_manager: "direct_manager",
        type_offboarding_indirect_manager: "indirect_manager",
        type_offboarding_hr_support_employee: "hr_support_employee",
        type_offboarding_application_recipients: "application_recipients",
        type_offboarding_expected_day_off: "expected_day_off",
        type_offboarding_handover_recipients: "handover_recipients",
        type_offboarding_resignation_letter: "letter",
        type_offboarding_active: "available",
    };
};

contentModule.getAllowanceListDetailsMainData = function(){
    return {
        type_allowance_list_details_employeeid: "employeeid",
        type_allowance_list_details_amount: "amount",
        type_allowance_list_details_comment: "comment"
    };
};

contentModule.getPunishmentListMainData = function(){
    return {
        type_punishment_list_cycleid: "cycleid",
        type_punishment_list_payroll_date_month: "payroll_date_month",
        type_punishment_list_payroll_date_week: "payroll_date_week",
        type_punishment_list_name: "name",
        type_punishment_list_reference_number: "reference_number",
        type_punishment_list_reference_date: "reference_date",
        type_punishment_list_policyid: "policyid"
    };
};

contentModule.getAllowanceListMainData = function(){
    return {
        type_allowance_list_cycleid: "cycleid",
        type_allowance_list_payroll_date_month: "payroll_date_month",
        type_allowance_list_payroll_date_week: "payroll_date_week",
        type_allowance_list_name: "name",
        type_allowance_list_reference_number: "reference_number",
        type_allowance_list_reference_date: "reference_date",
        type_allowance_list_policyid: "policyid"
    };
};

contentModule.getBenefitListMainData = function(){
    return {
        type_benefit_list_cycleid: "cycleid",
        type_benefit_list_payroll_date_month: "payroll_date_month",
        type_benefit_list_payroll_date_week: "payroll_date_week",
        type_benefit_list_name: "name",
        type_benefit_list_reference_number: "reference_number",
        type_benefit_list_reference_date: "reference_date",
        type_benefit_list_policyid: "policyid"
    };
};

contentModule.getOtherLiabilityListMainData = function(){
    return {
        type_other_liability_list_cycleid: "cycleid",
        type_other_liability_list_payroll_date_month: "payroll_date_month",
        type_other_liability_list_payroll_date_week: "payroll_date_week",
        type_other_liability_list_name: "name",
        type_other_liability_list_reference_number: "reference_number",
        type_other_liability_list_reference_date: "reference_date",
        type_other_liability_list_policyid: "policyid"
    };
};

contentModule.getSalaryAdjustmentListMainData = function(){
    return {
        type_salary_adjustment_list_cycleid: "cycleid",
        type_salary_adjustment_list_payroll_date_month: "payroll_date_month",
        type_salary_adjustment_list_payroll_date_week: "payroll_date_week",
        type_salary_adjustment_list_name: "name",
        type_salary_adjustment_list_reference_number: "reference_number",
        type_salary_adjustment_list_reference_date: "reference_date"
    };
};

contentModule.getNationsMainData = function(){
    return {
        type_nation_short_name: "shortname",
        type_nation_name: "fullname",
        type_nation_phonecode: "phonecode",
        type_nation_active: "available"
    };
};

contentModule.getCitiesMainData = function(){
    return {
        type_city_name: "name",
        type_city_code: "code",
        type_city_nationid: "nationid",
        type_city_postalcode: "postalcode",
        type_city_phonecode: "phonecode",
        type_city_active: "available"
    };
};

contentModule.getEthnicsMainData = function(){
    return {
        type_ethnic_name: "name",
        type_ethnic_code: "code",
        type_ethnic_active: "available"
    };
};

contentModule.getReligionsMainData = function(){
    return {
        type_religion_name: "name",
        type_religion_code: "code",
        type_religion_active: "available"
    };
};

contentModule.getExaminationSessionMainData = function(){
    return {
        type_examination_session_name: "name",
        type_examination_session_status: "status",
        type_examination_session_stime: "stime",
        type_examination_session_content: "content",
        type_examination_session_available: "available"
    };
};

contentModule.getExaminationLectureMainData = function(){
    return {
        type_examination_session_lecturer: "type",
        type_examination_session_internal_trainer: "peopleid",
        type_examination_session_outsource_trainer: "peopleid"
    };
};

contentModule.getExaminationParticipantMainData = function(){
    return {
        type_examination_session_participant: "peopleid"
    };
};

contentModule.getTaskTemplateMainData = function(){
    return {
        type_task_template_name: "name",
        type_task_template_groupid: "groupid",
        type_task_template_comment: "comment",
        type_task_template_active: "available",
        type_task_template_task_name: "task_name",
        type_task_template_task_status: "task_status",
        type_task_template_task_expire_time: "task_expire_time",
        type_task_template_task_reminder: "task_reminder",
        type_task_template_task_assign_to: "task_assign_to",
        type_task_template_task_participant: "task_participant",
        type_task_template_task_result: "task_result"
    };
};

contentModule.getMeetingTemplateMainData = function(){
    return {
        type_meeting_template_name: "name",
        type_meeting_template_groupid: "groupid",
        type_meeting_template_comment: "comment",
        type_meeting_template_active: "available",
        type_meeting_template_meeting_name: "meeting_name",
        type_meeting_template_meeting_type: "meeting_type",
        type_meeting_template_meeting_location: "meeting_location",
        type_meeting_template_meeting_status: "meeting_status",
        type_meeting_template_meeting_start_time: "meeting_start_time",
        type_meeting_template_meeting_end_time: "meeting_end_time",
        type_meeting_template_meeting_all_day: "meeting_all_day",
        type_meeting_template_meeting_reminder: "meeting_reminder",
        type_meeting_template_meeting_assign_to: "meeting_assign_to",
        type_meeting_template_meeting_participant: "meeting_participant",
        type_meeting_template_meeting_result: "meeting_result"
    };
};

contentModule.getEmailTemplateMainData = function(){
    return {
        type_email_template_name: "name",
        type_email_template_groupid: "groupid",
        type_email_template_comment: "comment",
        type_email_template_active: "available",
        type_email_template_receiver: "receiver",
        type_email_template_carbon_copy: "carbon_copy",
        type_email_template_blind_carbon_copy: "blind_carbon_copy",
        type_email_template_subject: "subject",
        type_email_template_content: "email_content"
    };
};

contentModule.getOnboardingMainData = function(){
    return {
        type_onboarding_employee_id: "employeeid",
        type_onboarding_employee_code: "code",
        type_onboarding_status: "status",
        type_onboarding_employee_start_date: "start_date",
        type_onboarding_employee_official_date: "official_date",
        type_onboarding_welcome_templateid: "welcome_templateid",
        type_onboarding_comment: "comment",
        type_onboarding_active: "available"
    };
};

contentModule.getGeographicalPositionMainData = function(){
    return {
        type_geographical_position_name: "name",
        type_geographical_position_location: "location",
        type_geographical_position_nation_city: "nation_city",
        type_geographical_position_address: "address",
        type_geographical_position_phone: "phone",
        type_geographical_position_post_code: "post_code",
        type_geographical_position_comment: "comment",
        type_geographical_position_active: "available"
    };
};

contentModule.getTemplateGroupMainData = function(){
    return {
        type_template_groups_name: "name",
        type_template_groups_typeid: "typeid",
        type_template_groups_comment: "comment",
        type_template_groups_active: "available"
    };
};

contentModule.getMainData = function(typeid, dict){
    var mainData;
    if (!dict[typeid]) return null;
    var type = dict[typeid].type;
    while(type == "extends_structure"){
        type = dict[dict[typeid].content.typeof].type;
    }
    switch (type) {
        case "company":
            mainData = contentModule.getCompanyMainData();
            break;
        case "org":
            mainData = contentModule.getOrgMainData();
            break;
        case "employee":
            mainData = contentModule.getEmployeeMainData();
            break;
        case "people":
            mainData = contentModule.getPeopleMainData();
            break;
        case "position":
            mainData = contentModule.getPositionMainData();
            break;
        case "task":
            mainData = contentModule.getTaskMainData();
            break;
        case "meeting":
            mainData = contentModule.getMeetingMainData();
            break;
        case "holidays":
            mainData = contentModule.getHolidayMainData();
            break;
        case "shift_general":
            mainData = contentModule.getShiftGeneralMainData();
            break;
        case "shift_worktime":
            mainData = contentModule.getShiftWorktimeMainData();
            break;
        case "shift_timekeeping":
            mainData = contentModule.getShiftTimekeepingMainData();
            break;
        case "worktime_checkins":
            mainData = contentModule.getWorktime_checkinMainData();
            break;
        case "worktime_machines":
            mainData = contentModule.getWorktime_machineMainData();
            break;
        case "worktime_logs":
            mainData = contentModule.getWorktime_logMainData();
            break;
        case "training_programs":
            mainData = contentModule.getTrainingProgramMainData();
            break;
        case "assets":
            mainData = contentModule.getAssetMainData();
            break;
        case "instruments_and_tools":
            mainData = contentModule.getInstrumentsAndToolsMainData();
            break;
        case "warehouses":
            mainData = contentModule.getWarehouseMainData();
            break;
        case "asset_handover_lines":
            mainData = contentModule.getAssetHandoverLinesMainData();
            break;
        case "asset_handover":
            mainData = contentModule.getAssetHandoverMainData();
            break;
        case "instruments_and_tools_handover_lines":
            mainData = contentModule.getInstrumentsAndToolsHandoverLinesMainData();
            break;
        case "instruments_and_tools_handover":
            mainData = contentModule.getInstrumentsAndToolsHandoverMainData();
            break;
        case "asset_recall_lines":
            mainData = contentModule.getAssetRecallLinesMainData();
            break;
        case "day_off_lines":
            mainData = contentModule.getDayOffLinesMainData();
            break;
        case "asset_recall":
            mainData = contentModule.getAssetRecallMainData();
            break;
        case "allowance_policy_groups":
            mainData = contentModule.getAllowancePolicyGroupsMainData();
            break;
        case "bonus_policy_groups":
            mainData = contentModule.getBonusPolicyGroupsMainData();
            break;
        case "work_flow_groups":
            mainData = contentModule.getWorkFlowGroupsMainData();
            break;
        case "work_flows":
            mainData = contentModule.getWorkFlowsMainData();
            break;
        case "objects":
            mainData = contentModule.getObjectsMainData();
            break;
        case "partner_class":
            mainData = contentModule.getPartnerClassMainData();
            break;
        case "partner":
            mainData = contentModule.getPartnerMainData();
            break;
        case "contact":
            mainData = contentModule.getContactMainData();
            break;
        case "other_liability_policy_groups":
            mainData = contentModule.getOtherLiabilityPolicyGroupsMainData();
            break;
        case "trade_union_policy_groups":
            mainData = contentModule.getTradeUnionPolicyGroupsMainData();
            break;
        case "overtime_policy_groups":
            mainData = contentModule.getOvertimePolicyGroupsMainData();
            break;
        case "salary_policy_groups":
            mainData = contentModule.getSalaryPolicyGroupsMainData();
            break;
        case "punishment_policy_groups":
            mainData = contentModule.getPunishmentPolicyGroupsMainData();
            break;
        case "asset_category":
            mainData = contentModule.getAssetCategoryMainData();
            break;
        case "instruments_and_tools_category":
            mainData = contentModule.getInstrumentsAndToolsCategoryMainData();
            break;
        case "projects":
            mainData = contentModule.getProjectsMainData();
            break;
        case "project_applied_to_employee":
            mainData = contentModule.getProjectAppliedToEmployeeMainData();
            break;
        case "tax_policy_groups":
            mainData = contentModule.getTaxPolicyGroupsMainData();
            break;
        case "advance_payment_policy_groups":
            mainData = contentModule.getAdvancePaymentPolicyGroupsMainData();
            break;
        case "late_early_checkin_policy_groups":
            mainData = contentModule.getLateEarlyCheckinPolicyGroupsMainData();
            break;
        case "benefit_policy_groups":
            mainData = contentModule.getBenefitPolicyGroupsMainData();
            break;
        case "allowance_policies":
            mainData = contentModule.getAllowancePoliciesMainData();
            break;
        case "benefit_policies":
            mainData = contentModule.getBenefitPoliciesMainData();
            break;
        case "training_program_groups":
            mainData = contentModule.getTrainingProgramGroupsMainData();
            break;
        case "insurance_policies":
            mainData = contentModule.getInsurancePolicesMainData();
            break;
        case "leave_policy_groups":
            mainData = contentModule.getLeavePolicyGroupsMainData();
            break;
        case "leave_policies":
            mainData = contentModule.getLeavePoliciesMainData();
            break;
        case "insurance_policy_groups":
            mainData = contentModule.getInsurancePolicyGroupsMainData();
            break;
        case "bonus_policies":
            mainData = contentModule.getBonusPolicesMainData();
            break;
        case "punishment_policies":
            mainData = contentModule.getPunishmentPolicesMainData();
            break;
        case "advance_payment_policies":
            mainData = contentModule.getAdvancePaymentPolicesMainData();
            break;
        case "late_early_checkin_policies":
            mainData = contentModule.getLateEarlyCheckinPolicesMainData();
            break;
        case "tax_policies":
            mainData = contentModule.getTaxPolicesMainData();
            break;
        case "salary_policies":
            mainData = contentModule.getSalaryPolicesMainData();
            break;
        case "trade_union_policies":
            mainData = contentModule.getTradeUnionPolicesMainData();
            break;
        case "overtime_policies":
            mainData = contentModule.getOvertimePolicesMainData();
            break;
        case "overtime_request":
            mainData = contentModule.getOvertimeRequestMainData();
            break;
        case "other_liability_policies":
            mainData = contentModule.getOtherLiabilityPolicesMainData();
            break;
        case "insurance_policies_applied_to_employee":
            mainData = contentModule.getInsurancePoliciesAppliedToEmployeeMainData();
            break;
        case "overtime_policies_applied_to_employee":
            mainData = contentModule.getOvertimePoliciesAppliedToEmployeeMainData();
            break;
        case "bonus_policies_applied_to_employee":
            mainData = contentModule.getBonusPoliciesAppliedToEmployeeMainData();
            break;
        case "punishment_policies_applied_to_employee":
            mainData = contentModule.getPunishmentPoliciesAppliedToEmployeeMainData();
            break;
        case "benefit_policies_applied_to_employee":
            mainData = contentModule.getBenefitPoliciesAppliedToEmployeeMainData();
            break;
        case "allowance_policies_applied_to_employee":
            mainData = contentModule.getAllowancePoliciesAppliedToEmployeeMainData();
            break;
        case "tax_policies_applied_to_employee":
            mainData = contentModule.getTaxPoliciesAppliedToEmployeeMainData();
            break;
        case "trade_union_policies_applied_to_employee":
            mainData = contentModule.getTradeUnionPoliciesAppliedToEmployeeMainData();
            break;
        case "other_liability_policies_applied_to_employee":
            mainData = contentModule.getOtherLiabilityPoliciesAppliedToEmployeeMainData();
            break;
        case "leave_policies_applied_to_employee":
            mainData = contentModule.getLeavePoliciesAppliedToEmployeeMainData();
            break;
        case "late_early_checkin_policies_applied_to_employee":
            mainData = contentModule.getLateEarlyCheckinPoliciesAppliedToEmployeeMainData();
            break;
        case "advance_payment_policies_applied_to_employee":
            mainData = contentModule.getAdvancePaymentPoliciesAppliedToEmployeeMainData();
            break;
        case "salary_decisions_applied_to_employee":
            mainData = contentModule.getSalaryDecisionsAppliedToEmployeeMainData();
            break;
        case "salary_policies_applied_to_employee":
            mainData = contentModule.getSalaryPoliciesAppliedToEmployeeMainData();
            break;
        case "employment_contracts":
            mainData = contentModule.getEmploymentContractsMainData();
            break;
        case "bonus_list":
            mainData = contentModule.getBonusListMainData();
            break;
        case "bonus_list_details":
            mainData = contentModule.getBonusListDetailsMainData();
            break;
        case "punishment_list":
            mainData = contentModule.getPunishmentListMainData();
            break;
        case "punishment_list_details":
            mainData = contentModule.getPunishmentListDetailsMainData();
            break;
        case "allowance_list_details":
            mainData = contentModule.getAllowanceListDetailsMainData();
            break;
        case "allowance_list":
            mainData = contentModule.getAllowanceListMainData();
            break;
        case "benefit_list":
            mainData = contentModule.getBenefitListMainData();
            break;
        case "benefit_list_details":
            mainData = contentModule.getBenefitListDetailsMainData();
            break;
        case "other_liability_list":
            mainData = contentModule.getOtherLiabilityListMainData();
            break;
        case "other_liability_list_details":
            mainData = contentModule.getOtherLiabilityListDetailsMainData();
            break;
        case "scorecard_report_line":
            mainData = contentModule.getScoreCardReportLineMainData();
            break;
        case "salary_adjustment_list":
            mainData = contentModule.getSalaryAdjustmentListMainData();
            break;
        case "salary_adjustment_list_details":
            mainData = contentModule.getSalaryAdjustmentListDetailsMainData();
            break;
        case "dependent_persons":
            mainData = contentModule.getDependentPersonMainData();
            break;
        case "employment_contract_types":
            mainData = contentModule.getEmploymentContractTypesMainData();
            break;
        case "social_network":
            mainData = contentModule.getSocialNetworkMainData();
            break;
        case "work_history":
            mainData = contentModule.getWorkHistoryMainData();
            break;
        case "education_history":
            mainData = contentModule.getEducationHistoryMainData();
            break;
        case "skill":
            mainData = contentModule.getSkillMainData();
            break;
        case "bank_account":
            mainData = contentModule.getBankAccountMainData();
            break;
        case "phone":
            mainData = contentModule.getPhoneMainData();
            break;
        case "email":
            mainData = contentModule.getEmailMainData();
            break;
        case "personal_document":
            mainData = contentModule.getPersonalDocumentMainData();
            break;
        case "nations":
            mainData = contentModule.getNationsMainData();
            break;
        case "cities":
            mainData = contentModule.getCitiesMainData();
            break;
        case "ethnics":
            mainData = contentModule.getEthnicsMainData();
            break;
        case "religions":
            mainData = contentModule.getReligionsMainData();
            break;
        case "training_lecturer":
            mainData = contentModule.getTrainingLecturerMainData();
            break;
        case "training_participant":
            mainData = contentModule.getTrainingParticipantMainData();
            break;
        case "request_advance_payment":
            mainData = contentModule.getRequestAdvancePaymentMainData();
            break;
        case "request_late_early_checkin":
            mainData = contentModule.getRequestLateEarlyCheckinMainData();
            break;
        case "examination_session":
            mainData = contentModule.getExaminationSessionMainData();
            break;
        case "examination_lecturer":
            mainData = contentModule.getExaminationLectureMainData();
            break;
        case "examination_participant":
            mainData = contentModule.getExaminationParticipantMainData();
            break;
        case "request_leave":
            mainData = contentModule.getRequestLeaveMainData();
            break;
        case "shift_schedule":
            mainData = contentModule.getShiftScheduleManualMainData();
            break;
        case "document_types":
            mainData = contentModule.getDocumentTypesMainData();
            break;
        case "document_groups":
            mainData = contentModule.getDocumentGroupsMainData();
            break;
        case "document_properties":
            mainData = contentModule.getDocumentPropertiesMainData();
            break;
        case "document_templates":
            mainData = contentModule.getDocumentTemplatesMainData();
            break;
        case "documents":
            mainData = contentModule.getDocumentsMainData();
            break;
        case "template_groups":
            mainData = contentModule.getTemplateGroupMainData();
            break;
        case "task_templates":
            mainData = contentModule.getTaskTemplateMainData();
            break;
        case "meeting_templates":
            mainData = contentModule.getMeetingTemplateMainData();
            break;
        case "email_templates":
            mainData = contentModule.getEmailTemplateMainData();
            break;
        case "onboarding":
            mainData = contentModule.getOnboardingMainData();
            break;
        case "offboarding":
            mainData = contentModule.getOffboardingMainData();
            break;
        case "geographical_positions":
            mainData = contentModule.getGeographicalPositionMainData();
            break;
        case "offboarding_types":
            mainData = contentModule.getOffboardingTypesMainData();
            break;
        case "leave_assessment":
            mainData = contentModule.getLeaveAssessmentMainData();
            break;
        case "approval_resignation":
            mainData = contentModule.getApprovalResignationMainData();
            break;
        case "offboarding_reasons":
            mainData = contentModule.getOffboardingReasonsMainData();
            break;
        case "lesson_categories":
            mainData = contentModule.getLessonCategoriesMainData();
            break;
        default:
            mainData = null;
    }
    return mainData;
};

/*

contentModule.makeFormData({
    variableType: "system" hoặc "userdefined",
    typeid: typeid,
    formid: nếu form đã được vẽ thì truyền vào formid,
    formContent: nếu form chưa được vẽ thì truyền vào mô tả của form,
    initialValue:   nếu variableType = "system" thì truyền vào record value (ví dụ biến peoples thì truyền vào record tương ứng trong bảng peoples, không có thì không cần truyền)
                    nếu variableType = "userdefined" thì truyền vào valueid (nếu biến đã được nhập giá trị thì valueid > 0, nếu không thì valueid = 0)
    formContainer: form nhập được tạo ra sẽ được gán vào element này,
    typelists: danh sách kiểu dữ liệu
    values: nếu variableType == "userdefined" thì phải truyền vào mảng các record value (trong bảng values) nếu initialValue > 0
});

Function này là promise resolve về 1 funtion getValue dùng để lấy dữ liệu của form, dữ liệu trả về có thể dùng để lưu luôn, không cần xử lý. reject về "error" nếu có lỗi.

*/

contentModule.makeOutputFormData = function(params){
    return new Promise(function(resolve, reject){
        console.log(params);
        ModalElement.show_loading();
        var callbackfunc = function(){
            if (data_module.pendingData.status == "error"){
                ModalElement.alert("Có lỗi trong quá trình khởi tạo dữ liệu");
                return;
            }
            else if (data_module.pendingData.status == "pending") {
                setTimeout(function(){
                    callbackfunc();
                }, 500);
                return;
            }
            var typeid, formid, formContent, initialValue, formContainer, typelists, values, valueDict, variableType;
            variableType = params.variableType;
            typeid = params.typeid;
            formid = params.formid;
            formContent = params.formContent;
            initialValue = params.initialValue;
            formContainer = params.formContainer;
            typelists = params.typelists;
            values = params.values;
            if (!variableType){
                ModalElement.alert({message: "Invalid params: variableType"});
                reject("error");
                return;
            }
            if (!typeid || !formContainer){
                ModalElement.alert({message: "Invalid params: typeid, formContainer"});
                reject("error");
                return;
            }
            if (!formid && formContent){
                ModalElement.alert({message: "Invalid params: formid, formContent"});
                reject("error");
                return;
            }
            var dict = {};
            typelists.forEach(function (elt, index) {
                dict[elt.id] = elt;
            });
            var AssemblerInstance = absol.form.AssemblerInstance;
            var $ = absol.$;
            var _ = absol._;
            var JSZip = absol.JSZip;
            var makeFmFragmentClass = absol.form.makeFmFragmentClass;
            if (formid) {
                var mSignUpFrag = AssemblerInstance.buildFragment({class: formid.toString()});
            }
            else {
                form_module.attachOnCreatedCb(formContent);
                var formName = (formContent.attributes && formContent.attributes.name) || "not_detected";
                var constructor = hr.input_form.fragmentClasses[formName];
                if (constructor) {//có class viết sẵn
                    constructor.prototype.tag = "TempForm" + (new Date()).getTime().toString();
                    constructor.prototype.contentViewData = formContent;
                }
                else {//chưa xác địnhh
                    constructor = absol.form.makeFmFragmentConstructor({
                        tag: "TempForm" + (new Date()).getTime().toString(),
                        contentViewData: formContent
                    });
                    if ((dict[typeid]) && (dict[typeid].type == "array" || dict[typeid].type2 == "array")) {
                        constructor.prototype.onCreated = function () {
                            var myArrayComp = this.findViewByName(typeid.toString());
                            if (!myArrayComp) {
                                var t_id = dict[typeid].content.typeof;
                                myArrayComp = this.findViewByName(t_id);
                            }
                            myArrayComp.on('cmd_insert_row', this.handleCmdInsertRow.bind(this));
                            myArrayComp.on('cmd_remove_row', this.handleCmdRemoveRow.bind(this));
                        };
                        constructor.prototype.handleCmdRemoveRow = function (event) {
                            event.accept(new Promise(function (resolve) {
                                ModalElement.question({
                                    title: LanguageModule.text("txt_warning"),
                                    message: "Bạn có muốn xóa không?",
                                    onclick: function (sel) {
                                        if (sel == 0) {
                                            resolve(true);
                                        }
                                        else {
                                            resolve(false);
                                        }
                                    }
                                });
                            }))
                        };
                        constructor.prototype.handleCmdInsertRow = function (event) {
                            var shareData = this.getContext("shareData");

                            var orgid;

                            if (shareData) {
                                orgid = shareData.orgid;
                            }

                            if (orgid && typeid == -25) event.resolve({type_select_position_orgid: {value: orgid}});
                            else event.resolve({});
                        };
                    }
                }
                absol.form.AssemblerInstance.addConstructor(constructor);
                form.FragmentClass = constructor;
                var mSignUpFrag = AssemblerInstance.buildFragment({class: "TempForm" + (new Date()).getTime().toString()});
            }
            mSignUpFrag.setContext("SHARE_PARAMS", {});
            mSignUpFrag.domElt.addStyle({
                width: '100%',
                height:'100%',
                display: 'block'
            });
            DOMElement.removeAllChildren(formContainer);
            formContainer.appendChild(mSignUpFrag.domElt);
            formContainer.formFragment = mSignUpFrag;
            if (params.onPreload) params.onPreload(mSignUpFrag);
            var getValue = function(){
                if (variableType == "system"){
                    var mainData = contentModule.getMainData(typeid, dict);
                    return contentModule.getValueOfForm(mSignUpFrag, typeid, typelists, mainData);
                }
                else if (variableType == "user") {
                    var rs = {};
                    dict[typeid].content.details.forEach(function(elt){
                        rs[elt.localid] = mSignUpFrag.props[elt.localid];
                    });
                    return rs;
                }
                else {
                    return form_module.makeDataToSave(mSignUpFrag, typeid, typelists);
                }
            }
            if (variableType == "system"){
                if (!initialValue) initialValue = {};
                var mainData = contentModule.getMainData(typeid, dict);
                // ModalElement.show_loading();
                resolve(getValue);
                contentModule.setValueOfOutputForm({
                    typelists: typelists,
                    valueContent: initialValue,
                    typeid: typeid,
                    mainData: mainData
                }).then(function(value){
                    if (mSignUpFrag.state === "RUNNING"){
                        mSignUpFrag.props = value;
                        ModalElement.close(-1);
                    }
                    else {
                        mSignUpFrag.onReady = function(){
                            this.props = value;
                            this.onReady = null;
                            ModalElement.close(-1);
                        }
                    }

                });
            }
            else {
                if (!initialValue) initialValue = {};
                resolve(getValue);
                contentModule.setValueOfUserOutputForm({
                    typelists: typelists,
                    valueContent: initialValue,
                    typeid: typeid
                }).then(function(value){
                    ModalElement.close(-1);
                    if (mSignUpFrag.state === "RUNNING"){
                        mSignUpFrag.props = value;
                        ModalElement.close(-1);
                    }
                    else {
                        mSignUpFrag.onReady = function(){
                            this.props = value;
                            this.onReady = null;
                            ModalElement.close(-1);
                        }
                    }

                });
            }
        };
        callbackfunc();
    });
};

contentModule.makeFormData = function(params){
    return new Promise(function(resolve, reject){
        console.log(params);
        ModalElement.show_loading();
        var callbackfunc = function(){
            if (data_module.pendingData.status == "error"){
                ModalElement.alert("Có lỗi trong quá trình khởi tạo dữ liệu");
                return;
            }
            else if (data_module.pendingData.status == "pending") {
                setTimeout(function(){
                    callbackfunc();
                }, 500);
                return;
            }
            var typeid, formid, formContent, initialValue, formContainer, typelists, values, valueDict, variableType;
            variableType = params.variableType;
            typeid = params.typeid;
            formid = params.formid;
            formContent = params.formContent;
            initialValue = params.initialValue;
            formContainer = params.formContainer;
            typelists = params.typelists ? params.typelists : data_module.typelists.items;
            values = params.values;
            if (!variableType){
                ModalElement.alert({message: "Invalid params: variableType"});
                reject("error");
                return;
            }
            if (!typeid || !formContainer){
                ModalElement.alert({message: "Invalid params: typeid, formContainer"});
                reject("error");
                return;
            }
            if (!formid && formContent){
                ModalElement.alert({message: "Invalid params: formid, formContent"});
                reject("error");
                return;
            }
            var dict = {};
            typelists.forEach(function (elt, index) {
                dict[elt.id] = elt;
            });
            var AssemblerInstance = absol.form.AssemblerInstance;
            var $ = absol.$;
            var _ = absol._;
            var JSZip = absol.JSZip;
            var makeFmFragmentClass = absol.form.makeFmFragmentClass;
            if (formid) {
                var mSignUpFrag = AssemblerInstance.buildFragment({class: formid.toString()});
            }
            else {
                form_module.attachOnCreatedCb(formContent);
                var formName = (formContent.attributes && formContent.attributes.name) || "not_detected";
                var constructor = hr.input_form.fragmentClasses[formName];
                if (constructor) {//có class viết sẵn
                    constructor.prototype.tag = "TempForm" + (new Date()).getTime().toString();
                    constructor.prototype.contentViewData = formContent;
                }
                else {//chưa xác địnhh
                    constructor = absol.form.makeFmFragmentConstructor({
                        tag: "TempForm" + (new Date()).getTime().toString(),
                        contentViewData: formContent
                    });
                    if ((dict[typeid]) && (dict[typeid].type == "array" || dict[typeid].type2 == "array")) {
                        constructor.prototype.onCreated = function () {
                            var myArrayComp = this.findViewByName(typeid.toString());
                            if (!myArrayComp) {
                                var t_id = dict[typeid].content.typeof;
                                myArrayComp = this.findViewByName(t_id);
                            }
                            myArrayComp.on('cmd_insert_row', this.handleCmdInsertRow.bind(this));
                            myArrayComp.on('cmd_remove_row', this.handleCmdRemoveRow.bind(this));
                        };
                        constructor.prototype.handleCmdRemoveRow = function (event) {
                            event.accept(new Promise(function (resolve) {
                                ModalElement.question({
                                    title: LanguageModule.text("txt_warning"),
                                    message: "Bạn có muốn xóa không?",
                                    onclick: function (sel) {
                                        if (sel == 0) {
                                            resolve(true);
                                        }
                                        else {
                                            resolve(false);
                                        }
                                    }
                                });
                            }))
                        };
                        constructor.prototype.handleCmdInsertRow = function (event) {
                            var shareData = this.getContext("shareData");

                            var orgid;

                            if (shareData) {
                                orgid = shareData.orgid;
                            }

                            if (orgid && typeid == -25) event.resolve({type_select_position_orgid: {value: orgid}});
                            else event.resolve({});
                        };
                    }
                }
                absol.form.AssemblerInstance.addConstructor(constructor);
                form.FragmentClass = constructor;
                var mSignUpFrag = AssemblerInstance.buildFragment({class: "TempForm" + (new Date()).getTime().toString()});
            }
            mSignUpFrag.setContext("SHARE_PARAMS", {});
            mSignUpFrag.domElt.addStyle({
                width: '100%',
                height:'100%',
                display: 'block'
            });
            DOMElement.removeAllChildren(formContainer);
            formContainer.appendChild(mSignUpFrag.domElt);
            formContainer.formFragment = mSignUpFrag;
            if (params.onPreload) params.onPreload(mSignUpFrag);
            var getValue = function(alert_value){
                if (variableType == "system") {
                    var mainData = contentModule.getMainData(typeid, dict);
                    return contentModule.getValueOfForm(mSignUpFrag, typeid, typelists, mainData, alert_value == "no_alert" ? true : false);
                }
                else if (variableType == "user") {
                    return contentModule.getValueOfUserForm(mSignUpFrag, typeid, typelists, alert_value == "no_alert" ? true : false);
                    // var rs = {};
                    // dict[typeid].content.details.forEach(function(elt){
                    //     rs[elt.localid] = mSignUpFrag.props[elt.localid];
                    // });
                    // return rs;
                }
                else {
                    return form_module.makeDataToSave(mSignUpFrag, typeid, typelists);
                }
            }
            if (variableType == "system"){
                if (!initialValue) initialValue = {};
                if (initialValue){
                    var mainData = contentModule.getMainData(typeid, dict);
                    // ModalElement.show_loading();
                    resolve(getValue);
                    contentModule.setValueOfForm({
                        typelists: typelists,
                        valueContent: initialValue,
                        typeid: typeid,
                        mainData: mainData
                    }).then(function(value){
                        if (mSignUpFrag.state === "RUNNING"){
                            mSignUpFrag.props = value;
                            ModalElement.close(-1);
                        }
                        else {
                            mSignUpFrag.onReady = function(){
                                this.props = value;
                                this.onReady = null;
                                ModalElement.close(-1);
                            }
                        }

                    });
                }
            }
            else if (variableType == "user") {
                if (!initialValue) initialValue = {};
                // ModalElement.show_loading();
                resolve(getValue);
                contentModule.setValueOfUserForm({
                    typelists: typelists,
                    valueContent: initialValue,
                    typeid: typeid
                }).then(function(value){
                    if (mSignUpFrag.state === "RUNNING"){
                        mSignUpFrag.props = value;
                        ModalElement.close(-1);
                    }
                    else {
                        mSignUpFrag.onReady = function(){
                            this.props = value;
                            this.onReady = null;
                            ModalElement.close(-1);
                        }
                    }
                });
                // mSignUpFrag.props = initialValue;
                // resolve(getValue);
            }
        }
        callbackfunc();
    });
};

contentModule.makeFormData2 = function(params){
    return new Promise(function(resolve, reject){
        var typeid, formid, formContent, initialValue, formContainer, typelists, values, valueDict, variableType;
        variableType = params.variableType;
        typeid = params.typeid;
        formid = params.formid;
        formContent = params.formContent;
        initialValue = params.initialValue;
        formContainer = params.formContainer;
        typelists = params.typelists;
        values = params.values;
        if (!variableType){
            ModalElement.alert({message: "Invalid params: variableType"});
            reject("error");
            return;
        }
        if (!typeid || !formContainer){
            ModalElement.alert({message: "Invalid params: typeid, formContainer"});
            reject("error");
            return;
        }
        if (!formid && formContent){
            ModalElement.alert({message: "Invalid params: formid, formContent"});
            reject("error");
            return;
        }
        var dict = {};
        typelists.forEach(function (elt, index) {
            dict[elt.id] = elt;
        });
        var AssemblerInstance = absol.form.AssemblerInstance;
        var $ = absol.$;
        var _ = absol._;
        var JSZip = absol.JSZip;
        var makeFmFragmentClass = absol.form.makeFmFragmentClass;
        if (formid) {
            var mSignUpFrag = AssemblerInstance.buildFragment({class: formid.toString()});
        }
        else {
            form_module.attachOnCreatedCb(formContent);
            var formName = (formContent.attributes && formContent.attributes.name) || "not_detected";
            var constructor = hr.input_form.fragmentClasses[formName];
            if (constructor) {//có class viết sẵn
                constructor.prototype.tag = "TempForm" + (new Date()).getTime().toString();
                constructor.prototype.contentViewData = formContent;
            }
            else {//chưa xác địnhh
                constructor = absol.form.makeFmFragmentConstructor({
                    tag: "TempForm" + (new Date()).getTime().toString(),
                    contentViewData: formContent
                });
                if ((dict[typeid]) && (dict[typeid].type == "array" || dict[typeid].type2 == "array")) {
                    constructor.prototype.onCreated = function () {
                        var myArrayComp = this.findViewByName(typeid.toString());
                        if (!myArrayComp) {
                            var t_id = dict[typeid].content.typeof;
                            myArrayComp = this.findViewByName(t_id);
                        }
                        myArrayComp.on('cmd_insert_row', this.handleCmdInsertRow.bind(this));
                        myArrayComp.on('cmd_remove_row', this.handleCmdRemoveRow.bind(this));
                    };
                    constructor.prototype.handleCmdRemoveRow = function (event) {
                        event.accept(new Promise(function (resolve) {
                            ModalElement.question({
                                title: LanguageModule.text("txt_warning"),
                                message: "Bạn có muốn xóa không?",
                                onclick: function (sel) {
                                    if (sel == 0) {
                                        resolve(true);
                                    }
                                    else {
                                        resolve(false);
                                    }
                                }
                            });
                        }))
                    };
                    constructor.prototype.handleCmdInsertRow = function (event) {
                        var shareData = this.getContext("shareData");

                        var orgid;

                        if (shareData) {
                            orgid = shareData.orgid;
                        }

                        if (orgid && typeid == -25) event.resolve({type_select_position_orgid: {value: orgid}});
                        else event.resolve({});
                    };
                }
            }
            absol.form.AssemblerInstance.addConstructor(constructor);
            form.FragmentClass = constructor;
            var mSignUpFrag = AssemblerInstance.buildFragment({class: "TempForm" + (new Date()).getTime().toString()});
        }
        mSignUpFrag.domElt.addStyle({
            width: '100%',
            height:'100%',
            display: 'block'
        });
        DOMElement.removeAllChildren(formContainer);
        formContainer.appendChild(mSignUpFrag.domElt);
        formContainer.formFragment = mSignUpFrag;
        var getValue = function(){
            if (variableType != "system"){
                return form_module.makeDataToSave(mSignUpFrag, typeid, typelists);
            }
            else {
                // var mainData = contentModule.getMainData(typeid, dict);
                return contentModule.getValueOfForm2(mSignUpFrag.props, typeid, typelists);
            }
        }
        if (variableType != "system"){
            if (!isNaN(initialValue) && initialValue > 0){
                ModalElement.show_loading();
                form_module.makeDataToSet({
                    typelists: typelists,
                    values: values,
                    typeid: typeid,
                    valueid: initialValue
                }).then(function(value){
                    ModalElement.close(-1);
                    mSignUpFrag.props = value;
                    resolve(getValue);
                });
            }
            resolve(getValue);
        }
        else {
            if (!initialValue) initialValue = {};
            if (initialValue){
                ModalElement.show_loading();
                contentModule.setValueOfForm2({
                    typelists: typelists,
                    valueContent: initialValue,
                    typeid: typeid
                }).then(function(value){
                    ModalElement.close(-1);
                    if (mSignUpFrag.state === "RUNNING"){
                        mSignUpFrag.props = value;
                    }
                    else {
                        mSignUpFrag.onReady = function(){
                            this.props = value;
                            this.onReady = null;
                        }
                    }

                    resolve(getValue);
                });
            }
            resolve(getValue);
        }
    });
};

contentModule.getAssetsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var nameText;
    for (var i = 0; i < host.database.assets.items.length; i++){
        nameText = host.database.assets.items[i].name;
        if (host.database.assets.items[i].specification.length > 0) nameText += " - " + host.database.assets.items[i].specification;
        list.push({
            value: host.database.assets.items[i].id,
            text: nameText
        });
    }
    return list;
};

contentModule.getInstrumentAndToolsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var nameText;
    for (var i = 0; i < host.database.instruments_and_tools.items.length; i++){
        nameText = host.database.instruments_and_tools.items[i].name;
        if (host.database.instruments_and_tools.items[i].specification.length > 0) nameText += " - " + host.database.instruments_and_tools.items[i].specification;
        list.push({
            value: host.database.instruments_and_tools.items[i].id,
            text: nameText
        });
    }
    return list;
};

contentModule.getAssetsInstrumentAndToolsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var nameText;
    for (var i = 0; i < host.database.assets.items.length; i++){
        nameText = host.database.assets.items[i].name;
        if (host.database.assets.items[i].specification.length > 0) nameText += " - " + host.database.assets.items[i].specification;
        list.push({
            value: host.database.assets.items[i].id,
            text: nameText
        });
    }
    for (var i = 0; i < host.database.instruments_and_tools.items.length; i++){
        nameText = host.database.instruments_and_tools.items[i].name;
        if (host.database.instruments_and_tools.items[i].specification.length > 0) nameText += " - " + host.database.instruments_and_tools.items[i].specification;
        list.push({
            value: - host.database.instruments_and_tools.items[i].id,
            text: nameText
        });
    }
    var holderForSort = list.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.text.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    list = holderForSort.map(function(holder){
        return holder.item;
    });
    return list;
};

contentModule.getAssetsInstrumentsAndToolsHandoverListSelectMenu = function(host, warehouseid, asset_transactionid){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var assetsDic = {};
    var instruments_and_toolsDic = {};
    if (asset_transactionid > 0){
        for (var i = 0; i < host.asset_transaction_details.length; i++){
            if (host.asset_transaction_details[i].assetid > 0){
                assetsDic[host.asset_transaction_details[i].assetid] = true;
            }
            else {
                instruments_and_toolsDic[-host.asset_transaction_details[i].assetid] = true;
            }
        }
    }
    var nameText;
    for (var i = 0; i < host.database.assets.items.length; i++){
        if (assetsDic[host.database.assets.items[i].id] || (host.database.assets.items[i].status == "good" && host.database.assets.items[i].location == "" && host.database.assets.items[i].warehouseid == warehouseid)){
            nameText = host.database.assets.items[i].name;
            if (host.database.assets.items[i].specification.length > 0) nameText += " - " + host.database.assets.items[i].specification;
            list.push({
                value: host.database.assets.items[i].id,
                text: nameText
            });
        }
    }
    for (var i = 0; i < host.database.instruments_and_tools.items.length; i++){
        if (host.database.instruments_and_tools.items[i].warehouseid != warehouseid) continue;
        if (instruments_and_toolsDic[host.database.instruments_and_tools.items[i].id] || host.database.instruments_and_tools.items[i].inventory > 0){
            nameText = host.database.instruments_and_tools.items[i].name;
            if (host.database.instruments_and_tools.items[i].specification.length > 0) nameText += " - " + host.database.instruments_and_tools.items[i].specification;
            list.push({
                value: - host.database.instruments_and_tools.items[i].id,
                text: nameText
            });
        }
    }
    var holderForSort = list.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.text.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    list = holderForSort.map(function(holder){
        return holder.item;
    });
    return list;
};

contentModule.getAssetsHandoverListSelectMenu = function(host, warehouseid, asset_transactionid){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var assetsDic = {};
    if (asset_transactionid > 0){
        for (var i = 0; i < host.asset_transaction_details.length; i++){
            assetsDic[host.asset_transaction_details[i].assetid] = true;
        }
    }
    var nameText;
    for (var i = 0; i < host.database.assets.items.length; i++){
        if ((assetsDic[host.database.assets.items[i].id] && host.database.assets.items[i].warehouseid == warehouseid) || (host.database.assets.items[i].status == "good" && host.database.assets.items[i].location == "" && host.database.assets.items[i].warehouseid == warehouseid)){
            nameText = host.database.assets.items[i].name;
            if (host.database.assets.items[i].specification.length > 0) nameText += " - " + host.database.assets.items[i].specification;
            list.push({
                value: host.database.assets.items[i].id,
                text: nameText
            });
        }
    }
    var holderForSort = list.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.text.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    list = holderForSort.map(function(holder){
        return holder.item;
    });
    return list;
};
contentModule.getInstrumentAndToolsHandoverListSelectMenu = function(host, warehouseid, asset_transactionid){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var instruments_and_toolsDic = {};
    if (asset_transactionid > 0){
        for (var i = 0; i < host.asset_transaction_details.length; i++){
            instruments_and_toolsDic[host.asset_transaction_details[i].assetid] = true;
        }
    }
    var nameText;
    for (var i = 0; i < host.database.instruments_and_tools.items.length; i++){
        if (host.database.instruments_and_tools.items[i].warehouseid != warehouseid) continue;
        if (instruments_and_toolsDic[host.database.instruments_and_tools.items[i].id] || host.database.instruments_and_tools.items[i].inventory > 0){
            nameText = host.database.instruments_and_tools.items[i].name;
            if (host.database.instruments_and_tools.items[i].specification.length > 0) nameText += " - " + host.database.instruments_and_tools.items[i].specification;
            list.push({
                value: host.database.instruments_and_tools.items[i].id,
                text: nameText
            });
        }
    }
    var holderForSort = list.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.text.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    list = holderForSort.map(function(holder){
        return holder.item;
    });
    return list;
};

contentModule.getAssetsRecallListSelectMenu = function(host, employeeid, asset_transactionid){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var assetsDic = {};
    var instruments_and_toolsDic = {};
    if (asset_transactionid > 0){
        // for (var i = 0; i < host.asset_transaction_details.length; i++){
        //     if (host.asset_transaction_details[i].assetid > 0){
        //         assetsDic[host.asset_transaction_details[i].assetid] = true;
        //     }
        //     else {
        //         instruments_and_toolsDic[host.asset_transaction_details[i].assetid] = true;
        //     }
        // }
    }
    var nameText;
    for (var i = 0; i < host.database.assets.items.length; i++){
        if (assetsDic[host.database.assets.items[i].id] || (host.database.assets.items[i].location == "employee" && host.database.assets.items[i].locationid == employeeid)){
            nameText = host.database.assets.items[i].name;
            if (host.database.assets.items[i].specification.length > 0) nameText += " - " + host.database.assets.items[i].specification;
            list.push({
                value: host.database.assets.items[i].id,
                text: nameText
            });
        }
    }
    var holderForSort = list.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.text.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    list = holderForSort.map(function(holder){
        return holder.item;
    });
    return list;
};

contentModule.getWarehousesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.warehouses.items.length; i++){
        if (!host.database.warehouses.items[i].available) continue;
        if (host.listWarehousePriv && host.listWarehousePriv.indexOf(host.database.warehouses.items[i].id) < 0) continue;
        list.push({
            value: host.database.warehouses.items[i].id,
            text: host.database.warehouses.items[i].name
        });
    }
    return list;
};

contentModule.getAllowancePolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.allowance_policy_groups.items.length; i++){
        if (!host.database.allowance_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.allowance_policy_groups.items[i].id,
            text: host.database.allowance_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getLessonCategoriesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.lesson_categories.items.length; i++){
        list.push({
            value: host.database.lesson_categories.items[i].id,
            text: host.database.lesson_categories.items[i].name,
            noView: !host.database.lesson_categories.items[i].available
        });
    }
    return list;
};

contentModule.getBonusPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.bonus_policy_groups.items.length; i++){
        if (!host.database.bonus_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.bonus_policy_groups.items[i].id,
            text: host.database.bonus_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getWorkFlowGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.work_flow_groups.items.length; i++){
        if (!host.database.work_flow_groups.items[i].available) continue;
        list.push({
            value: host.database.work_flow_groups.items[i].id,
            text: host.database.work_flow_groups.items[i].name
        });
    }
    return list;
};

contentModule.getWorkFlowsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.work_flows.items.length; i++){
        if (!host.database.work_flows.items[i].available) continue;
        list.push({
            value: host.database.work_flows.items[i].id,
            text: host.database.work_flows.items[i].name
        });
    }
    return list;
};

contentModule.getObjectsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.objects.items.length; i++){
        list.push({
            value: host.database.objects.items[i].id,
            text: host.database.objects.items[i].name
        });
    }
    return list;
};

contentModule.getPayrollCycleListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.payroll_cycle.items.length; i++){
        list.push({
            value: host.database.payroll_cycle.items[i].id,
            text: host.database.payroll_cycle.items[i].name
        });
    }
    return list;
};

contentModule.getTaskListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.task.items.length; i++){
        list.push({
            value: host.database.task.items[i].id,
            text: host.database.task.items[i].name
        });
    }
    return list;
};

contentModule.getMeetingListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.meeting.items.length; i++){
        list.push({
            value: host.database.meeting.items[i].id,
            text: host.database.meeting.items[i].name
        });
    }
    return list;
};

contentModule.getPartnerClassListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.partner_class.items.length; i++){
        if (!host.database.partner_class.items[i].available) continue;
        list.push({
            value: host.database.partner_class.items[i].id,
            text: host.database.partner_class.items[i].name
        });
    }
    return list;
};

contentModule.getPartnerListSelectMenu = function(host, notSelectValue){
    var list = [];
    list.push({
        value: 0,
        text: LanguageModule.text("txt_select_value")
    });
    var item;
    for (var i = 0; i < host.database.partner.items.length; i++){
        item = {
            value: host.database.partner.items[i].id,
            text: host.database.partner.items[i].name.substr(0, 50)
        };
        list.push(item);
    }
    return list;
};

contentModule.getContactListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.contact.items.length; i++){
        if (!host.database.contact.items[i].available) continue;
        list.push({
            value: host.database.contact.items[i].id,
            text: host.database.contact.items[i].name
        });
    }
    return list;
};

contentModule.getDocumentTypesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.document_types.items.length; i++){
        if (!host.database.document_types.items[i].available) continue;
        list.push({
            value: host.database.document_types.items[i].id,
            text: host.database.document_types.items[i].name
        });
    }
    return list;
};

contentModule.getOrgsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        list.push({
            value: host.database.orgs.items[i].id,
            text: host.database.orgs.items[i].name
        });
    }
    return list;
};

contentModule.getDocumentTypesListSelectMenuFilter = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_all_document_type")
    }];
    for (var i = 0; i < host.database.document_types.items.length; i++){
        if (!host.database.document_types.items[i].available) continue;
        list.push({
            value: host.database.document_types.items[i].id,
            text: host.database.document_types.items[i].name
        });
    }
    return list;
};

contentModule.makeDocumentGroupsIndex = function(host){
    var k, t = [];
    var holderForSort = host.database.document_groups.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });
    host.database.document_groups.items = holderForSort.map(function(holder){
        return holder.item;
    });

    for (var i = 0; i < host.database.document_groups.items.length; i++){
        host.database.document_groups.items[i].childIndexList = [];
    }
    var documentGroupDic = contentModule.makeDictionaryIndex(host.database.document_groups.items);
    var k;
    for (var i = 0; i < host.database.document_groups.items.length; i++){
        if (host.database.document_groups.items[i].parentid == 0) continue;
        k = documentGroupDic[host.database.document_groups.items[i].parentid];
        if (k !== undefined) host.database.document_groups.items[k].childIndexList.push(i);
    }
};

contentModule.makeDocumentPropertiesIndex = function(host){
    for (var i = 0; i < host.database.document_properties.items.length; i++){
        host.database.document_properties.items[i].childIndexList = [];
    }
    var documentGroupDic = contentModule.makeDictionaryIndex(host.database.document_properties.items);
    var k;
    for (var i = 0; i < host.database.document_properties.items.length; i++){
        if (host.database.document_properties.items[i].parentid == 0) continue;
        k = documentGroupDic[host.database.document_properties.items[i].parentid];
        if (k !== undefined) host.database.document_properties.items[k].childIndexList.push(i);
    }
};

contentModule.makeDocumentFoldersIndex = function(host){
    var k, t = [];
    var holderForSort = host.database.document_folders.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });
    host.database.document_folders.items = holderForSort.map(function(holder){
        return holder.item;
    });

    for (var i = 0; i < host.database.document_folders.items.length; i++){
        host.database.document_folders.items[i].childIndexList = [];
    }
    var documentGroupDic = contentModule.makeDictionaryIndex(host.database.document_folders.items);
    var k;
    for (var i = 0; i < host.database.document_folders.items.length; i++){
        if (host.database.document_folders.items[i].parentid == 0) continue;
        k = documentGroupDic[host.database.document_folders.items[i].parentid];
        if (k !== undefined) host.database.document_folders.items[k].childIndexList.push(i);
    }
};

contentModule.getDocumentGroupsListSelectTreeMenu = function(host){
    function getGroupItem(index){
        var items = [];
        for (var i = 0; i < host.database.document_groups.items[index].childIndexList.length; i++){
            items.push(getGroupItem(host.database.document_groups.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.document_groups.items[index].id,
            text: host.database.document_groups.items[index].name,
            items: items
        };
        return res;
    };
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.document_groups.items.length; i++){
        if (host.database.document_groups.items[i].parentid != 0) continue;
        list.push(getGroupItem(i));
    }
    return list;
};

contentModule.getDocumentGroupsListSelectTreeMenuFilter = function(host){
    function getGroupItem(index){
        var items = [];
        for (var i = 0; i < host.database.document_groups.items[index].childIndexList.length; i++){
            items.push(getGroupItem(host.database.document_groups.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.document_groups.items[index].id,
            text: host.database.document_groups.items[index].name,
            items: items
        };
        return res;
    };
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_all_document_group")
    }];
    for (var i = 0; i < host.database.document_groups.items.length; i++){
        if (host.database.document_groups.items[i].parentid != 0) continue;
        list.push(getGroupItem(i));
    }
    return list;
};

contentModule.getDocumentFoldersListSelectTreeMenu = function(host){
    function getFolderItem(index){
        var items = [];
        for (var i = 0; i < host.database.document_folders.items[index].childIndexList.length; i++){
            items.push(getFolderItem(host.database.document_folders.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.document_folders.items[index].id,
            text: host.database.document_folders.items[index].name,
            items: items
        };
        return res;
    };
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.document_folders.items.length; i++){
        if (host.database.document_folders.items[i].parentid != 0) continue;
        list.push(getFolderItem(i));
    }
    return list;
};

contentModule.getDocumentFoldersSelectTreeMenu = function(host){
    function getFolderItem(index){
        var items = [];
        for (var i = 0; i < host.database.document_folders.items[index].childIndexList.length; i++){
            items.push(getFolderItem(host.database.document_folders.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.document_folders.items[index].id,
            text: host.database.document_folders.items[index].name,
            items: items
        };
        return res;
    };
    var list = [{value: 0, text: ""}];
    for (var i = 0; i < host.database.document_folders.items.length; i++){
        if (host.database.document_folders.items[i].parentid != 0) continue;
        list.push(getFolderItem(i));
    }
    return list;
};

contentModule.getOtherLiabilityPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.other_liability_policy_groups.items.length; i++){
        if (!host.database.other_liability_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.other_liability_policy_groups.items[i].id,
            text: host.database.other_liability_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getSalaryPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.salary_policy_groups.items.length; i++){
        if (!host.database.salary_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.salary_policy_groups.items[i].id,
            text: host.database.salary_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getTradeUnionPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.trade_union_policy_groups.items.length; i++){
        if (!host.database.trade_union_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.trade_union_policy_groups.items[i].id,
            text: host.database.trade_union_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getOvertimePolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.overtime_policy_groups.items.length; i++){
        if (!host.database.overtime_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.overtime_policy_groups.items[i].id,
            text: host.database.overtime_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getOffboardingTypeListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.offboarding_types.items.length; i++){
        if (!host.database.offboarding_types.items[i].available) continue;
        list.push({
            value: host.database.offboarding_types.items[i].id,
            text: host.database.offboarding_types.items[i].name
        });
    }
    return list;
};

contentModule.getOffboardingReasonListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.offboarding_reasons.items.length; i++){
        if (!host.database.offboarding_reasons.items[i].available) continue;
        list.push({
            value: host.database.offboarding_reasons.items[i].id,
            text: host.database.offboarding_reasons.items[i].name
        });
    }
    return list;
};

contentModule.getPunishmentPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.punishment_policy_groups.items.length; i++){
        if (!host.database.punishment_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.punishment_policy_groups.items[i].id,
            text: host.database.punishment_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getAssetCategoryListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.asset_category.items.length; i++){
        if (!host.database.asset_category.items[i].available) continue;
        list.push({
            value: host.database.asset_category.items[i].id,
            text: host.database.asset_category.items[i].name
        });
    }
    return list;
};

contentModule.getAssetsInstrumentAndToolsCategoryListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.instruments_and_tools_category.items.length; i++){
        if (!host.database.instruments_and_tools_category.items[i].available) continue;
        list.push({
            value: host.database.instruments_and_tools_category.items[i].id,
            text: host.database.instruments_and_tools_category.items[i].name
        });
    }
    return list;
};

contentModule.getProjectsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.projects.items.length; i++){
        if (!host.database.projects.items[i].available) continue;
        list.push({
            value: host.database.projects.items[i].id,
            text: host.database.projects.items[i].name
        });
    }
    return list;
};

contentModule.getTaxPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.tax_policy_groups.items.length; i++){
        if (!host.database.tax_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.tax_policy_groups.items[i].id,
            text: host.database.tax_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getAdvancePaymentPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.advance_payment_policy_groups.items.length; i++){
        if (!host.database.advance_payment_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.advance_payment_policy_groups.items[i].id,
            text: host.database.advance_payment_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getLateEarlyCheckinPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.late_early_checkin_policy_groups.items.length; i++){
        if (!host.database.late_early_checkin_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.late_early_checkin_policy_groups.items[i].id,
            text: host.database.late_early_checkin_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getBenefitPolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.benefit_policy_groups.items.length; i++){
        if (!host.database.benefit_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.benefit_policy_groups.items[i].id,
            text: host.database.benefit_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getShiftsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    var content_worktime, timeText;
    for (var i = 0; i < host.database.shifts.items.length; i++){
        if (!host.database.shifts.items[i].available) continue;
        content_worktime = EncodingClass.string.toVariable(host.database.shifts.items[i].content_worktime);
        timeText = contentModule.getHourView(content_worktime.working_time.dayOffset) + " - " + contentModule.getHourView(content_worktime.working_time.dayOffset + content_worktime.working_time.duration);
        list.push({
            value: host.database.shifts.items[i].id,
            text: host.database.shifts.items[i].name + " (" + timeText + ")"
        });
    }
    return list;
};

contentModule.getShiftsListSelectBox = function(host){
    var list = [];
    for (var i = 0; i < host.database.shifts.items.length; i++){
        if (!host.database.shifts.items[i].available) continue;
        list.push({
            value: host.database.shifts.items[i].id,
            text: host.database.shifts.items[i].name
        });
    }
    return list;
};

contentModule.getPartnerClassListSelectBox = function(host){
    var list = [];
    for (var i = 0; i < host.database.partner_class.items.length; i++){
        if (!host.database.partner_class.items[i].available) continue;
        list.push({
            value: host.database.partner_class.items[i].id,
            text: host.database.partner_class.items[i].name
        });
    }
    return list;
};

contentModule.getLeavePolicyGroupsListSelectMenu = function(host){
    var holderForSort = host.database.leave_policy_groups.items.map(function(item){
        return {
            item: item,
            val: absol.string.nonAccentVietnamese(item.name.toLowerCase())
        }
    });
    holderForSort.sort(function(a, b){
        if (a.val < b.val) return -1;
        if (a.val > b.val) return 1;
        return 0;
    });

    host.database.leave_policy_groups.items = holderForSort.map(function(holder){
        return holder.item;
    });
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.leave_policy_groups.items.length; i++){
        if (!host.database.leave_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.leave_policy_groups.items[i].id,
            text: host.database.leave_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getInsurancePolicyGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.insurance_policy_groups.items.length; i++){
        if (!host.database.insurance_policy_groups.items[i].available) continue;
        list.push({
            value: host.database.insurance_policy_groups.items[i].id,
            text: host.database.insurance_policy_groups.items[i].name
        });
    }
    return list;
};

contentModule.getTrainingProgramGroupsListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.training_program_groups.items.length; i++){
        if (!host.database.training_program_groups.items[i].available) continue;
        list.push({
            value: host.database.training_program_groups.items[i].id,
            text: host.database.training_program_groups.items[i].name
        });
    }
    return list;
};

contentModule.makeAsset_handoverData = function(host){
    for (var i = 0; i < host.database.asset_transactions.items.length; i++){
        host.database.asset_transactions.items[i].details = {};
        host.database.asset_transactions.items[i].details[-72] = [];
    }
    var asset_transactionsDic = contentModule.makeDictionaryIndex(host.database.asset_transactions.items);
    var k;
    for (var i = 0; i < host.database.asset_transaction_details.items.length; i++){
        k = asset_transactionsDic[host.database.asset_transaction_details.items[i].asset_transactionid];
        if (k === undefined) continue;
        host.database.asset_transactions.items[k].details[-72].push({
            assetid: host.database.asset_transaction_details.items[i].assetid,
            status: host.database.asset_transaction_details.items[i].status,
            amount: host.database.asset_transaction_details.items[i].amount,
            comment: host.database.asset_transaction_details.items[i].comment
        });
    }
};

contentModule.makeInstruments_and_tools_handoverData = function(host){
    for (var i = 0; i < host.database.asset_transactions.items.length; i++){
        host.database.asset_transactions.items[i].details = {};
        host.database.asset_transactions.items[i].details[-231] = [];
    }
    var asset_transactionsDic = contentModule.makeDictionaryIndex(host.database.asset_transactions.items);
    var k;
    for (var i = 0; i < host.database.asset_transaction_details.items.length; i++){
        k = asset_transactionsDic[host.database.asset_transaction_details.items[i].asset_transactionid];
        if (k === undefined) continue;
        host.database.asset_transactions.items[k].details[-231].push({
            assetid: host.database.asset_transaction_details.items[i].assetid,
            status: host.database.asset_transaction_details.items[i].status,
            amount: host.database.asset_transaction_details.items[i].amount,
            comment: host.database.asset_transaction_details.items[i].comment
        });
    }
};

contentModule.makeAsset_recallData = function(host){
    for (var i = 0; i < host.database.asset_transactions.items.length; i++){
        host.database.asset_transactions.items[i].details = {};
        host.database.asset_transactions.items[i].details[-76] = [];
    }
    var asset_transactionsDic = contentModule.makeDictionaryIndex(host.database.asset_transactions.items);
    var k;
    for (var i = 0; i < host.database.asset_transaction_details.items.length; i++){
        k = asset_transactionsDic[host.database.asset_transaction_details.items[i].asset_transactionid];
        if (k === undefined) continue;
        host.database.asset_transactions.items[k].details[-76].push({
            assetid: host.database.asset_transaction_details.items[i].assetid,
            status: host.database.asset_transaction_details.items[i].status,
            comment: host.database.asset_transaction_details.items[i].comment
        });
    }
};

contentModule.getInsurancePoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.insurance_policies.items.length; i++){
        if (!host.database.insurance_policies.items[i].available) continue;
        list.push({
            value: host.database.insurance_policies.items[i].id,
            text: host.database.insurance_policies.items[i].name
        });
    }
    return list;
};

contentModule.getTaxPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.tax_policies.items.length; i++){
        if (!host.database.tax_policies.items[i].available) continue;
        list.push({
            value: host.database.tax_policies.items[i].id,
            text: host.database.tax_policies.items[i].name
        });
    }
    return list;
};

contentModule.getTradeUnionPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.trade_union_policies.items.length; i++){
        if (!host.database.trade_union_policies.items[i].available) continue;
        list.push({
            value: host.database.trade_union_policies.items[i].id,
            text: host.database.trade_union_policies.items[i].name
        });
    }
    return list;
};

contentModule.getLeavePoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.leave_policies.items.length; i++){
        if (!host.database.leave_policies.items[i].available) continue;
        list.push({
            value: host.database.leave_policies.items[i].id,
            text: host.database.leave_policies.items[i].name
        });
    }
    return list;
};

contentModule.getBenefitPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.benefit_policies.items.length; i++){
        if (!host.database.benefit_policies.items[i].available) continue;
        list.push({
            value: host.database.benefit_policies.items[i].id,
            text: host.database.benefit_policies.items[i].name
        });
    }
    return list;
};

contentModule.getAllowancePoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.allowance_policies.items.length; i++){
        if (!host.database.allowance_policies.items[i].available) continue;
        list.push({
            value: host.database.allowance_policies.items[i].id,
            text: host.database.allowance_policies.items[i].name
        });
    }
    return list;
};

contentModule.getBonusPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.bonus_policies.items.length; i++){
        if (!host.database.bonus_policies.items[i].available) continue;
        list.push({
            value: host.database.bonus_policies.items[i].id,
            text: host.database.bonus_policies.items[i].name
        });
    }
    return list;
};

contentModule.getOvertimePoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.overtime_policies.items.length; i++){
        if (!host.database.overtime_policies.items[i].available) continue;
        list.push({
            value: host.database.overtime_policies.items[i].id,
            text: host.database.overtime_policies.items[i].name
        });
    }
    return list;
};

contentModule.getPunishmentPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.punishment_policies.items.length; i++){
        if (!host.database.punishment_policies.items[i].available) continue;
        list.push({
            value: host.database.punishment_policies.items[i].id,
            text: host.database.punishment_policies.items[i].name
        });
    }
    return list;
};

contentModule.getAdvancePaymentPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.advance_payment_policies.items.length; i++){
        if (!host.database.advance_payment_policies.items[i].available) continue;
        list.push({
            value: host.database.advance_payment_policies.items[i].id,
            text: host.database.advance_payment_policies.items[i].name
        });
    }
    return list;
};

contentModule.getLateEarlyCheckinPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.late_early_checkin_policies.items.length; i++){
        if (!host.database.late_early_checkin_policies.items[i].available) continue;
        list.push({
            value: host.database.late_early_checkin_policies.items[i].id,
            text: host.database.late_early_checkin_policies.items[i].name
        });
    }
    return list;
};

contentModule.getSalaryPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.salary_policies.items.length; i++){
        if (!host.database.salary_policies.items[i].available) continue;
        list.push({
            value: host.database.salary_policies.items[i].id,
            text: host.database.salary_policies.items[i].name
        });
    }
    return list;
};

contentModule.getOtherLiabilityPoliciesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.other_liability_policies.items.length; i++){
        if (!host.database.other_liability_policies.items[i].available) continue;
        list.push({
            value: host.database.other_liability_policies.items[i].id,
            text: host.database.other_liability_policies.items[i].name
        });
    }
    return list;
};

contentModule.getEmploymentContractTypesListSelectMenu = function(host){
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.employment_contract_types.items.length; i++){
        if (!host.database.employment_contract_types.items[i].available) continue;
        list.push({
            value: host.database.employment_contract_types.items[i].id,
            text: host.database.employment_contract_types.items[i].name
        });
    }
    return list;
};

contentModule.getAssetStatusName = function(status){
    switch (status) {
        case "good":
            return LanguageModule.text("txt_good");
        case "liquidate":
            return LanguageModule.text("txt_liquidated");
        case "missing":
            return LanguageModule.text("txt_missing");
        case "broken":
            return LanguageModule.text("txt_broken");
        default:

    }
};

contentModule.getCategoryNameAsset = function(host, asset_category, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_asset_asset_category"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == asset_category) return list[i].text;
    }
    return "-";
};

contentModule.getDependentPersonSex = function(host, sex, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_dependent_person_sex"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == sex) return list[i].text;
    }
    return "-";
};

contentModule.getSalary_payment_methodName = function(host, payment_method, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_salary_policy_payment_method"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == payment_method) return list[i].text;
    }
    return "-";
};

contentModule.getEducationHistoryDegree = function(host, degree, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_education_history_degree"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == degree) return list[i].text;
    }
    return "-";
};

contentModule.getSkillLevel = function(host, level, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_skill_level"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == level) return list[i].text;
    }
    return "-";
};

contentModule.getPhoneType = function(host, type, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_phone_type"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == type) return list[i].text;
    }
    return "-";
};

contentModule.getEmailType = function(host, type, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_email_type"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == type) return list[i].text;
    }
    return "-";
};

contentModule.getPersonalDocumentType = function(host, type, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_personal_document_type"){
            typeid = list[i].type;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == type) return list[i].text;
    }
    return "-";
};

contentModule.getTaxType = function(host, tax_type, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_tax_policy_tax_type"){
            typeid = list[i].type;
            if (typeid == "union") typeid = list[i].typeOfUnion;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == tax_type) return list[i].text;
    }
    return "-";
};


contentModule.getPositionNameByEmployee = function(host, id){
    var index = host.database.employees.getIndex(id);
    if (index < 0) return "";
    return host.database.employees.items[index].positionName;
};

contentModule.getApproversTextOfPolicy = function(host, type, policyid, employeeid, number_of_day_off){
    return new Promise(function(resolve, reject){
        var pIndex = host.database[type + "_policies"].getIndex(policyid);
        if (pIndex < 0){
            resolve("");
            return;
        }
        if (!employeeid){
            resolve("");
            return;
        }
        var f1 = function(){
            var eEx = {};
            var getText = function(employeeid){
                if (eEx[employeeid]) return;
                var tIndex, uid, uIndex;
                tIndex = employeeDic[employeeid];
                if (tIndex >= 0){
                    res += ", " + host.database.employees.items[tIndex].fullname;
                    uid = host.database.employees.items[tIndex].userid;
                    uIndex = host.database.users.getByhomeid(uid);
                    if (uIndex >= 0) res += " - " + "@" + host.database.users.items[uIndex].username;
                }
                eEx[employeeid] = true;
            };
            var employeeDic = contentModule.makeDictionaryIndex(host.database.employees.items);
            var res = "";
            if (host.database[type + "_policies"].items[pIndex].direct_manager_approves_first){
                if (host.employeeOfMe.indexOf(employeeid) < 0){
                    for (var i = 0; i < manageOfYou.length; i++){
                        getText(manageOfYou[i]);
                    }
                }
                else {
                    for (var i = 0; i < host.directManageOfMe.length; i++){
                        getText(host.directManageOfMe[i]);
                    }
                }
            }
            if (type == "leave" && host.database[type + "_policies"].items[pIndex].long_leave_approval && number_of_day_off > host.database[type + "_policies"].items[pIndex].long_leave_threshold){
                for (var i = 0; i < host.database[type + "_policies"].items[pIndex].long_approvers.length; i++){
                    getText(host.database[type + "_policies"].items[pIndex].long_approvers[i].employeeid);
                }
            }
            else {
                for (var i = 0; i < host.database[type + "_policies"].items[pIndex].approvers.length; i++){
                    getText(host.database[type + "_policies"].items[pIndex].approvers[i].employeeid);
                }
            }
            if (res.length > 0) res = res.substr(2);
            resolve(res);
        };
        if (host.employeeOfMe.indexOf(employeeid) < 0 && host.database[type + "_policies"].items[pIndex].direct_manager_approves_first){
            var manageOfYou = [];
            ModalElement.show_loading();
            FormClass.api_call({
                url: "database_load.php",
                params: [
                    {name: "task", value: "employee_load_direct_manager"},
                    {name: "employeeid", value: employeeid}
                ],
                func: function(success, message){
                    ModalElement.close(-1);
                    if (success){
                        if (message.substr(0, 2) == "ok"){
                            var st = EncodingClass.string.toVariable(message.substr(2));
                            for (var i = 0; i < st.length; i++){
                                manageOfYou.push(st[i].managerid);
                            }
                            f1();
                        }
                        else {
                            ModalElement.alert({message: message});
                        }
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
            });
        }
        else {
            f1();
        }
    });
};

contentModule.getPoliciesListOfEmployee = function(host, type, id){
    return new Promise(function(resolve, reject){
        var index = host.database.employees.getIndex(id);
        var list = [{value: 0, text: LanguageModule.text("txt_select_value")}];
        if (index < 0) resolve(list);
        ModalElement.show_loading();
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "load_employee_policies"},
                {name: "employeeid", value: id},
                {name: "type", value: type}
            ],
            func: function(success, message){
                ModalElement.close(-1);
                if (success){
                    if (message.substr(0, 2) == "ok"){
                        var st = EncodingClass.string.toVariable(message.substr(2));
                        if (id == 0) resolve(list);
                        var dic = contentModule.makeDictionaryIndex(host.database[type + "_policies"].items);
                        var pIndex;
                        var listDic = {};
                        for (var i = 0; i < st.length; i++){
                            if (st[i].type != type) continue;
                            if (st[i].employeeid != host.database.employees.items[index].id) continue;
                            pIndex = dic[st[i].policyid];
                            if (pIndex != undefined){
                                if (listDic[host.database[type + "_policies"].items[pIndex].id]) continue;
                                list.push({
                                    value: host.database[type + "_policies"].items[pIndex].id,
                                    text: host.database[type + "_policies"].items[pIndex].name
                                });
                                listDic[host.database[type + "_policies"].items[pIndex].id] = true;
                            }
                        }
                        resolve(list);
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
        });
    });
};

contentModule.getDisplayRemainDayOffByLeavePolicy = function(host, id){
    var index = host.database.leave_policies.getIndex(id);
    if (index < 0) return false;
    var groupid = host.database.leave_policies.items[index].groupid;
    return groupid == -1;
};

contentModule.getNumberOfDayOffLeavePolicy = function(records){
    var res = 0;
    for (var i = 0; i < records.length; i++){
        switch (records[i].type_day_off_lines_days_portion) {
            case "full_day":
                res+= 1;
                break;
            case "first_half_shift_day":
            case "second_half_shift_day":
                res = res + 0.5;
                break;
            default:
        }
    }
    return res;
};

contentModule.getRemainDayOffByLeavePolicy = function(host, policyid, employeeid, records){//chưa có đề xuất cho năm cũ, năm tiếp theo
    return new Promise(function(resolve, reject){
        var pIndex = host.database.leave_policies.getIndex(policyid);
        if (pIndex < 0){
            resolve(0);
            return;
        }
        var eIndex = host.database.employees.getIndex(employeeid);
        if (eIndex < 0){
            resolve(0);
            return;
        }
        var groupid = host.database.leave_policies.items[pIndex].groupid;
        if (groupid != -1){
            resolve(0);
            return;
        }
        if (records.length == 0){
            resolve(0);
            return;
        }
        var f = function(){
            var start_date = host.database.employees.items[eIndex].start_date;
            var day_offs = EncodingClass.string.duplicate(records);
            day_offs.sort(function(a, b){
                if (!a.type_day_off_lines_date) return 1;
                if (!b.type_day_off_lines_date) return 1;
                return a.type_day_off_lines_date.getTime() - b.type_day_off_lines_date.getTime();
            });
            var request_date = day_offs[0].type_day_off_lines_date;
            if (!request_date){
                resolve(0);
                return;
            }
            var sM = 0;
            var uL = 0;
            var tC, ac, annual_leaveContent;
            var tY = new Date().getFullYear();
            if (start_date.getFullYear() == tY){
                var c = absol.datetime.compareDate(absol.datetime.nextMonth(start_date), start_date);
                if (c >= 15) sM++;
                var s = start_date.getMonth();
                var r = request_date.getMonth();
                if (request_date) sM = sM +(r - s) - 1;
                tC = host.database.leave_policies.items[pIndex].leave_days_per_year/12*sM;
            }
            else {
                if (host.contentGetRemainDayOffByLeavePolicy.annual_leave.length > 0){
                    annual_leaveContent = EncodingClass.string.toVariable(host.contentGetRemainDayOffByLeavePolicy.annual_leave[0].content);
                    uL = parseFloat(annual_leaveContent.last_year_remain);
                    uL = uL - parseFloat(annual_leaveContent.leave_day_use_last_year);
                }
                else {
                    if (host.contentGetRemainDayOffByLeavePolicy.employee_year.length > 0){
                        var x = EncodingClass.string.toVariable(host.contentGetRemainDayOffByLeavePolicy.employee_year[0].content);
                        if (x.unused_leave) uL = x.unused_leave;
                    }
                }
                if (uL > host.database.leave_policies.items[pIndex].carried_forward_leave) uL = host.database.leave_policies.items[pIndex].carried_forward_leave;
                var accumulated_leave_expired_before = EncodingClass.string.toVariable(host.database.leave_policies.items[pIndex].accumulated_leave_expired_before);
                if (accumulated_leave_expired_before){
                    ac = new Date(new Date().setDate(accumulated_leave_expired_before.date)).setMonth(accumulated_leave_expired_before.month);
                    ac = new Date(ac).setHours(0, 0, 0, 0);
                }
                sM = request_date.getMonth();
                var dPY = host.database.leave_policies.items[pIndex].leave_days_per_year;
                if (host.database.leave_policies.items[pIndex].maximal_day_calculation == "monthly_incresmental"){
                    var d = ((request_date.getFullYear()*12 + request_date.getMonth()) - (start_date.getFullYear()*12 + start_date.getMonth()));
                    var lo = parseInt(d/host.database.leave_policies.items[pIndex].number_of_working_months_to_increase_one_day_leave);
                    dPY+= lo;
                    if (dPY > host.database.leave_policies.items[pIndex].maximum_leave_days_per_year){
                        dPY = host.database.leave_policies.items[pIndex].maximum_leave_days_per_year;
                    }
                }
                tC = dPY/12*sM;
            }
            if (annual_leaveContent){
                tC = tC - parseFloat(annual_leaveContent.leave_day_use_this_year);
            }
            for (var i = 0; i < host.contentGetRemainDayOffByLeavePolicy.day_off_lines.length; i++){
                if (host.contentGetRemainDayOffByLeavePolicy.day_off_lines[i].date.getFullYear() == tY){
                    switch (host.contentGetRemainDayOffByLeavePolicy.day_off_lines[i].days_portion){
                        case "full_day":
                            if (uL > 0){
                                if (ac){
                                    if (host.contentGetRemainDayOffByLeavePolicy.day_off_lines[i].date.getTime() > ac) tC --;
                                    else uL--;
                                }
                                else {
                                    uL--;
                                }
                            }
                            else {
                                tC--;
                            }
                            break;
                        case "first_half_shift_day":
                        case "second_half_shift_day":
                            if (uL > 0){
                                if (ac){
                                    if (host.contentGetRemainDayOffByLeavePolicy.day_off_lines[i].date.getTime() > ac) tC = tC - 0.5;
                                    else uL = uL - 0.5;
                                }
                                else {
                                    uL = uL - 0.5;
                                }
                            }
                            else {
                                tC = tC - 0.5;
                            }
                            break;
                        default:
                    }
                }
            }
            if (ac && request_date.getTime() > ac) uL = 0;
            tC = tC + uL;
            resolve(tC);
        };
        if (host.contentGetRemainDayOffByLeavePolicy){
            f();
            return;
        }
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "load_day_off_by_leave_policy_and_employee"},
                {name: "policyid", value: policyid},
                {name: "employeeid", value: employeeid}
            ],
            func: function(success, message){
                if (success){
                    if (message.substr(0, 2) == "ok"){
                        var content = EncodingClass.string.toVariable(message.substr(2));
                        host.contentGetRemainDayOffByLeavePolicy = content;
                        f();
                    }
                    else {
                        resolve(0);
                        console.log(message);
                    }
                }
                else {
                    resolve(0);
                    console.log(message);
                }
            }
        });
    });
};

contentModule.getDisabledAmountAllowanceList = function(host, id){
    var index = host.database.allowance_policies.getIndex(id);
    if (index < 0) return false;
    return host.database.allowance_policies.items[index].allowance_type == "fixed_amount";
};

contentModule.getAmountAllowanceList = function(host, id){
    var index = host.database.allowance_policies.getIndex(id);
    if (index < 0) return false;
    if (host.database.allowance_policies.items[index].allowance_type == "fixed_amount"){
        return host.database.allowance_policies.items[index].value;
    }
    else {
        return Promise.reject();
    }
};

contentModule.getDisabledAmountBenefitList = function(host, id){
    var index = host.database.benefit_policies.getIndex(id);
    if (index < 0) return false;
    return host.database.benefit_policies.items[index].benefit_type == "fixed_amount";
};

contentModule.getAmountBenefitList = function(host, id){
    var index = host.database.benefit_policies.getIndex(id);
    if (index < 0) return false;
    if (host.database.benefit_policies.items[index].benefit_type == "fixed_amount"){
        return host.database.benefit_policies.items[index].value;
    }
    else {
        return Promise.reject();
    }
};

contentModule.getDisabledAmountOther_liabilityList = function(host, id){
    var index = host.database.other_liability_policies.getIndex(id);
    if (index < 0) return false;
    return host.database.other_liability_policies.items[index].other_liability_type == "fixed_amount";
};

contentModule.getAmountOther_liabilityList = function(host, id){
    var index = host.database.other_liability_policies.getIndex(id);
    if (index < 0) return false;
    if (host.database.other_liability_policies.items[index].other_liability_type == "fixed_amount"){
        return host.database.other_liability_policies.items[index].value;
    }
    else {
        return Promise.reject();
    }
};

contentModule.getTimestartOfProject = function(host, id){
    var index = host.database.projects.getIndex(id);
    if (index < 0) return "";
    return host.database.projects.items[index].timestart;
};

contentModule.getTimeendOfProject = function(host, id){
    var index = host.database.projects.getIndex(id);
    if (index < 0) return "";
    return host.database.projects.items[index].timeend;
};

contentModule.getDescriptionByContract = function(host, id){
    var index = host.database.employment_contract_types.getIndex(id);
    if (index < 0) return "";
    return host.database.employment_contract_types.items[index].description;
};

contentModule.getDescriptionByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return "";
    return host.database[policy].items[index].description;
};

contentModule.getTime_hours_needed_for_approvalByPolicy = function(host, type, id){
    var index = host.database[type + "_policies"].getIndex(id);
    if (index < 0) return "";
    return host.database[type + "_policies"].items[index].time_hours_needed_for_approval;
};

contentModule.getCalculated_onByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return 0;
    return host.database[policy].items[index].calculated_on;
};

contentModule.getAttachmentsByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return [];
    if (host.database[policy].items[index].attachments === "") return [];
    else if (EncodingClass.type.isString(host.database[policy].items[index].attachments)){
        return EncodingClass.string.toVariable(host.database[policy].items[index].attachments);
    }
    else return host.database[policy].items[index].attachments;
};

contentModule.getTax_typeByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return 0;
    return host.database[policy].items[index].tax_type;
};

contentModule.getContributed_by_companyByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return 0;
    return host.database[policy].items[index].contributed_by_company;
};

contentModule.getContributed_by_employeeByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return 0;
    return host.database[policy].items[index].contributed_by_employee;
};

contentModule.getTax_reliefByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return false;
    return host.database[policy].items[index].tax_relief;
};

contentModule.getInsurance_contribution_reliefByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return false;
    return host.database[policy].items[index].insurance_contribution_relief;
};

contentModule.getFrequencyByPolicy = function(host, policy, id){
    var index = host.database[policy].getIndex(id);
    if (index < 0) return 0;
    return host.database[policy].items[index].frequency;
};

contentModule.getDepartmentIDList = function(host, index){
    if (index < 0) return [];
    var list = [host.database.orgs.items[index].id];
    for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
        list = list.concat(contentModule.getDepartmentIDList(host, host.database.orgs.items[index].childIndexList[i]));
    }
    return list;
};

contentModule.makeEmployeePositionData = function(host){
    for (var i = 0; i < host.database.employees.items.length; i++){
        host.database.employees.items[i].positionName = "";
        host.database.employees.items[i].positions = [];
    }
    var employeeDic = contentModule.makeDictionaryIndex(host.database.employees.items);
    var positionDic = contentModule.makeDictionaryIndex(host.database.positions.items);
    var eIndex, pIndex;
    for (var i = 0; i < host.database.employee_positions.items.length; i++){
        eIndex = employeeDic[host.database.employee_positions.items[i].employeeid];
        pIndex = positionDic[host.database.employee_positions.items[i].positionid];
        if (eIndex !== undefined && pIndex !== undefined){
            host.database.employees.items[eIndex].positionName += ", " + host.database.positions.items[pIndex].name;
            host.database.employees.items[eIndex].positions.push(host.database.positions.items[pIndex].id);
        }
    }
    for (var i = 0; i < host.database.employees.items.length; i++){
        host.database.employees.items[i].positionName = host.database.employees.items[i].positionName.substr(2);
    }
};

contentModule.makeGeoposOrgsData = function(host){
    for (var i = 0; i < host.database.orgs.items.length; i++){
        host.database.orgs.items[i].geopos = [];
    }
    var orgDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var oIndex;
    for (var i = 0; i < host.database.geopos_orgs.items.length; i++){
        oIndex = orgDic[host.database.geopos_orgs.items[i].orgid];
        if (oIndex !== undefined){
            host.database.orgs.items[oIndex].geopos.push(host.database.geopos_orgs.items[i].geoid);
        }
    }
};

contentModule.makeGeoposCompaniesData = function(host){
    for (var i = 0; i < host.database.companies.items.length; i++){
        host.database.companies.items[i].geopos = [];
    }
    var orgDic = contentModule.makeDictionaryIndex(host.database.companies.items);
    var oIndex;
    for (var i = 0; i < host.database.geopos_orgs.items.length; i++){
        oIndex = orgDic[host.database.geopos_orgs.items[i].orgid];
        if (oIndex !== undefined){
            host.database.companies.items[oIndex].geopos.push(host.database.geopos_orgs.items[i].geoid);
        }
    }
};

contentModule.makeEmployeeManagerData = function(host){
    for (var i = 0; i < host.database.employees.items.length; i++){
        host.database.employees.items[i].direct_manager = 0;
        host.database.employees.items[i].indirect_manager = 0;
    }
    var employeeDic = contentModule.makeDictionaryIndex(host.database.employees.items);
    var eIndex;
    for (var i = 0; i < host.database.employee_managers.items.length; i++){
        eIndex = employeeDic[host.database.employee_managers.items[i].employeeid];
        if (eIndex !== undefined){
            if (host.database.employee_managers.items[i].type == "direct") host.database.employees.items[eIndex].direct_manager = host.database.employee_managers.items[i].managerid;
            if (host.database.employee_managers.items[i].type == "indirect") host.database.employees.items[eIndex].indirect_manager = host.database.employee_managers.items[i].managerid;
        }
    }
};

contentModule.getCalculated_onText = function(host, calculated_on, typeid){
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == "type_salary_decisions_applied_to_employee_calculated_on"){
            typeid = list[i].type;
            if (typeid == "union") typeid = list[i].typeOfUnion;
            break;
        }
    }
    list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    for (var i = 0; i < list.length; i++){
        if (list[i].localid == calculated_on) return list[i].text;
    }
    return "-";
};

contentModule.moneyFormat = function(num, minF, maxF) {
    var i, k, x;
    var st = "";
    if (minF === undefined) {
        minF = 0;
        maxF = -1;
    }
    if (maxF === undefined) {
        maxF = -1;
    }
    num = parseFloat(num);
    if (num < 0) return "-" + contentModule.moneyFormat(-num, minF, maxF);
    if (maxF != -1) {
        x = 0.01;
        k = maxF;
        for (i = 0; i <= k; i++) {
            x /= 10;
        }
    }
    else {
        x = 0;
    }
    num = "" + (num + x);
    if (num.length == 0) {
        if (minF > 0) {
            st = ".";
            for (i = 0; i < minF; i++) st += "0";
        }
        return "0" + st;
    }
    if (num.substr(0, 1) == ".") num = "0" + num;
    k = num.indexOf(".");
    if (k != -1) {
        x = num.substr(0, k);
        num = num.substr(k+1);
        for (k = x.length; k > 3; k -= 3) {
            if (st != "") {
                st = x.substr(k - 3) + "," + st;
            }
            else {
                st = x.substr(k - 3);
            }
            x = x.substr(0, k - 3);
        }
        if (st != "") {
            st = x + "," + st;
        }
        else {
            st = x;
        }
        k = strlen(num);
        if ((maxF != -1) && (maxF < k)) k = maxF;
        if (k > 0) {
            st += ".";
            for (i = 0; i < k; i++) st += num.substr(i, 1);
        }
        return st;
    }

    for (k = num.length; k > 3; k -= 3) {
        st = num.substr(k - 3) + "," + st;
        num = num.substr(0, k - 3);
    }
    st = num + "," + st;
    return st.substr(0, st.length - 1);
};

contentModule.copyToClipboard = function(str){
    var el = document.createElement('textarea');
    el.value = str;
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
};

contentModule.getFrom_ToDateByFrequency = function(frequency, date){
    date = EncodingClass.string.duplicate(date);
    var fromdate, todate;
    switch (frequency) {
        case 'week':
            fromdate = absol.datetime.beginOfWeek(date, false, 1);
            todate = new Date(absol.datetime.beginOfWeek(date).getTime() + 7*24*60*60*1000);
            break;
        case 'month':
            fromdate = absol.datetime.beginOfMonth(date);
            todate = absol.datetime.nextMonth(date);
            break;
        case 'year':
            fromdate = absol.datetime.beginOfYear(date);
            todate = new Date(absol.datetime.beginOfYear(date).setFullYear(date.getFullYear() + 1));
            break
        case 'quarter':
            var m = date.getMonth();
            var mod = m%3;
            fromdate = new Date(date.setMonth(m - mod));
            fromdate = absol.datetime.beginOfMonth(fromdate);
            todate = absol.datetime.nextMonth(absol.datetime.nextMonth(absol.datetime.nextMonth(fromdate)));
            break
        case "six_months":
            var m = date.getMonth();
            fromdate = new Date(date.setDate(1));
            if (m >= 6){
                fromdate = new Date(date.setMonth(6));
                todate = new Date(date.setMonth(0));
                todate = new Date(date.setFullYear(date.getFullYear() + 1));
            }
            else {
                fromdate = new Date(date.setMonth(0));
                todate = new Date(date.setMonth(6));
            }
            break;
        default:
            fromdate = new Date();
            todate = new Date();
            break;
    }
    return {
        fromdate: fromdate,
        todate: todate
    };
};

contentModule.drawEmployeeApplyPolcies = function(host, params){
    var orgEmpItems;
    var drawEmployeeApply = function(){
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "load_employee_policies_active_by_policy"},
                {name: "type", value: params.type},
                {name: "policyid", value: params.policyid}
            ],
            func: function(success, message){
                if (success){
                    if (message.substr(0, 2) == "ok"){
                        var st = EncodingClass.string.toVariable(message.substr(2));
                        console.log(st);
                        var values = [];
                        for (var i = 0; i < st.length; i++){
                            if (values.indexOf(st[i].employeeid) >= 0) continue;
                            values.push(st[i].employeeid);
                        }
                        var f = function(){
                            DOMElement.removeAllChildren(employee_apply_ctn);
                            employee_apply_ctn.appendChild(absol.buildDom({
                                tag: "multichecktreemenu",
                                props: {
                                    items: orgEmpItems,
                                    values: values,
                                    disabled: true,
                                    leafOnly: true
                                }
                            }));
                        };
                        if (orgEmpItems){
                            f();
                        }
                        else {
                            Promise.all([
                                data_module.loadOrgsList(),
                                data_module.loadEmployeesList(),
                                data_module.loadPeoplesList()
                            ]).then(function(value){
                                var temp = {database: {}};
                                contentModule.makeDatabaseContent(temp, {orgs: value[0], employees: value[1], peoples: value[2]});
                                var pDict = {};
                                temp.database.peoples.items.forEach(function(elt){
                                    pDict[elt.id] = elt;
                                });
                                temp.database.employees.items.forEach(function(elt){
                                    elt.fullname = pDict[elt.peopleid].fullname;
                                });
                                contentModule.makeOrgsIndex(temp);
                                contentModule.makeEmployeesIndex(temp);
                                orgEmpItems = contentModule.getOrgsAndEmployeesListSelectTreeMenuLeaf(temp);
                                f();
                            });
                        }
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
        });
    };
    var employee_apply_ctn = DOMElement.div({
        attrs: {
            style: {
                paddingLeft: "var(--control-verticle-distance-2)",
                paddingTop: "var(--control-verticle-distance-2)"
            }
        }
    });
    var childs = [
        {
            class: 'mk-section-header-name',
            child: { text: LanguageModule.text("txt_employee_apply") },
        }
    ];
    if (systemconfig.privSystem >= 2 || data_module.admin_rights_of_me.human_resource_policy){
        childs.push({
            class: 'mk-section-header-right',
            child: [
                DOMElement.a({
                    attrs: {
                        onclick: function(){
                            contentModule.formApplyToPolicies({
                                type: params.type,
                                policyid: params.policyid,
                                calculated_on: host.dataPolicyEdit.calculated_on
                            }).then(function(){
                                drawEmployeeApply();
                            });
                        }
                    },
                    text: LanguageModule.text("txt_edit")
                })
            ]
        });
    }
    var res = absol.buildDom({
        attr: {
            "data-sectionid": "employee_apply"
        },
        child: [
            absol.buildDom({
                class: 'mk-section-header',
                child: childs
            }),
            employee_apply_ctn
        ]
    });
    drawEmployeeApply();
    return res;
};

contentModule.drawGeneralInformationPolicy = function(host, params){
    var viewGeneralInformation = DOMElement.div({
        attrs: {
            style: {
                paddingLeft: "var(--control-verticle-distance-2)",
                paddingTop: "var(--control-verticle-distance-2)"
            }
        }
    });
    host.drawGeneralInforFunc = function(){
        contentModule.makeOutputFormData({
            typeid: host.form_config[params.type + "_policies"].typeid,
            formid: host.form_config[params.type + "_policies"].output_form,
            initialValue: host.dataPolicyEdit,
            formContainer: viewGeneralInformation,
            typelists: host.database.typelists.items,
            variableType: "system"
        }).then(function(getValue){});
    };
    host.drawGeneralInforFunc();
    var childs = [
        {
            class: 'mk-section-header-name',
            child: { text: LanguageModule.text("txt_general_information") },
        }
    ];
    if (systemconfig.privSystem >= 2 || data_module.admin_rights_of_me.human_resource_policy){
        childs.push({
            class: 'mk-section-header-right',
            child: [
                DOMElement.a({
                    attrs: {
                        onclick: function(){
                            params.editInforFunc();
                        }
                    },
                    text: LanguageModule.text("txt_edit")
                })
            ]
        });
    }
    var res = absol.buildDom({
        attr: {
            "data-sectionid": "general_information"
        },
        child: [
            absol.buildDom({
                class: 'mk-section-header',
                child: childs
            }),
            viewGeneralInformation
        ]
    });
    return res;
};

contentModule.drawApprovalPolicyNoDirect = function(host, params){
    var drawApprovalFunc = function(){
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "policy_load_approval_no_direct"},
                {name: "type", value: params.type},
                {name: "id", value: host.dataPolicyEdit.id}
            ],
            func: function(success, message){
                if (success){
                    if (message. substr(0, 2) == "ok"){
                        var st = EncodingClass.string.toVariable(message.substr(2));
                        DOMElement.removeAllChildren(approval_ctn);
                        approval_ctn.appendChild(contentModule.getApprovalPolicyNoDirect(host, st, "view"));
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
        });
    };
    var saveFunc = function(data){
        return new Promise(function(rs, rj){
            data.id = host.dataPolicyEdit.id;
            data.type = params.type;
            ModalElement.show_loading();
            FormClass.api_call({
                url: "policies_save_approval_nodirect.php",
                params: [{name: "data", value: EncodingClass.string.fromVariable(data)}],
                func: function(success, message){
                    ModalElement.close(-1);
                    if (success){
                        if (message.substr(0, 2) == "ok"){
                            var index = host.database[params.type + "_policies"].getIndex(host.dataPolicyEdit.id);
                            if (index >= 0){
                                host.database[params.type + "_policies"].items[index].approval_method = data.approval_method;
                            }
                            rs();
                        }
                        else {
                            ModalElement.alert({message: message});
                        }
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
            });
        });
    };
    var editFunc = function(){
        ModalElement.show_loading();
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "policy_load_approval_no_direct"},
                {name: "type", value: params.type},
                {name: "id", value: host.dataPolicyEdit.id}
            ],
            func: function(success, message){
                ModalElement.close(-1);
                if (success){
                    if (message. substr(0, 2) == "ok"){
                        var st = EncodingClass.string.toVariable(message.substr(2));
                        var res = contentModule.getApprovalPolicyNoDirect(host, st);
                        ModalElement.showWindow({
                            title: LanguageModule.text("txt_approval"),
                            bodycontent: res,
                            buttonlist: [
                                {
                                    text: LanguageModule.text("txt_save"),
                                    onclick: function(){
                                        var data = res.getValue();
                                        if (!data) return;
                                        saveFunc(data).then(function(){
                                            drawApprovalFunc();
                                            ModalElement.close();
                                        });
                                    }
                                },
                                {
                                    text: LanguageModule.text("txt_cancel"),
                                    onclick: function(){
                                        ModalElement.close();
                                    }
                                }
                            ]
                        });
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
        });
    };
    var approval_ctn = DOMElement.div({
        attrs: {
            style: {
                paddingLeft: "var(--control-verticle-distance-2)",
                paddingTop: "var(--control-verticle-distance-2)"
            }
        }
    });
    var res = absol.buildDom({
        attr: {
            "data-sectionid": "approval"
        },
        child: [
            absol.buildDom({
                class: 'mk-section-header',
                child: [
                    {
                        class: 'mk-section-header-name',
                        child: { text: LanguageModule.text("txt_approval") },
                    },
                    {
                        class: 'mk-section-header-right',
                        child: [
                            DOMElement.a({
                                attrs: {
                                    onclick: function(){
                                        editFunc();
                                    }
                                },
                                text: LanguageModule.text("txt_edit")
                            })
                        ]
                    }
                ]
            }),
            approval_ctn
        ]
    });
    drawApprovalFunc();
    return res;
};

contentModule.showPolicyHasApprovalNoDirect = function(host, params){
    hr.menu.changeCurrentUrlTab(host, params.type + "_policies/" + params.policyid);
    var nav = absol.buildDom({
        tag:'mknav',
        class: 'mk-nav',
        props: {
            items: [
                {text: LanguageModule.text("txt_general_information"), value: "general_information"},
                {text: LanguageModule.text("txt_employee_apply"), value: "employee_apply"},
                {text: LanguageModule.text("txt_approval"), value: "approval"},
                {text: LanguageModule.text("txt_comment"), value: "comment"}
            ],
            value: "general_information"
        },
        on:{
            clickitem: function(event){
                rightCtn.off('scroll',scrollRightFunc);// prevent loop
                if (sectionList[this.value]) sectionList[this.value].scrollIntoView();
                setTimeout(function(){
                    rightCtn.on('scroll',scrollRightFunc );
                }, 10);
            }
        }
    });
    var scrollRightFunc = function(){
        var elt;
        var bound = rightCtn.getBoundingClientRect();
        var eltBound;
        var nearestEltId;
        var nearestDistance = 100000000;
        var distance;
        for (var i in sectionList){
            elt = sectionList[i];
            eltBound = elt.getBoundingClientRect();
            distance = 1000000;
            if (eltBound.top <= bound.top){
                if (eltBound.bottom >= bound.bottom){
                    distance = -1e6;
                }
                else if (bound.top - eltBound.top  < 30){
                    distance = eltBound.top - bound.bottom;//negative
                }
                else if (eltBound.bottom > bound.top){
                    distance = bound.top - eltBound.top;
                }
            }
            else if (eltBound.top < bound.bottom){
                distance = eltBound.top - bound.bottom;//negative
            }
            else {
                distance = Math.abs(bound.top - eltBound.top)
            }
            if (nearestDistance > distance){
                nearestDistance = distance;
                nearestEltId = i;
            }
        }
        nav.value = nearestEltId;
    };
    var rightCtn = absol.buildDom({
        class: 'mk-main-right',
        style: {
            paddingBottom: "var(--footer-margin)"
        },
        on: {
            scroll: scrollRightFunc
        }
    });
    rightCtn.appendChild(contentModule.drawGeneralInformationPolicy(host, params));
    rightCtn.appendChild(contentModule.drawEmployeeApplyPolcies(host, params));
    rightCtn.appendChild(contentModule.drawApprovalPolicyNoDirect(host, params));
    rightCtn.appendChild(contentModule.drawComment({taskid: params.policyid, tablename: params.type + "_policies"}));
    var data_ctn = absol._({
        class: 'mk-main',
        style: {
            height: '100%'
        },
        child: [
            {
                class: 'mk-main-left-ctn',
                child: [nav]
            },
            rightCtn
        ]
    });
    var sectionList = {};
    absol.$("div", rightCtn, function(elt){
        var id = elt.getAttribute("data-sectionid");
        if (!id) return;
        sectionList[id] = elt;
    });
    var singlePage = absol.buildDom({
        tag: "singlepage",
        class: ["cd-page-not-padding-right", "as-viewport-full", "as-no-scroll"],
        child: [
            DOMElement.div({
                attrs: {className: 'button-panel-header absol-single-page-header'},
                children: [
                    DOMElement.div({
                        attrs: {className: "single-button-header"},
                        children: [theme.backButton({
                            onclick: function(){
                                host.frameList.removeLast();
                                hr.menu.changeCurrentUrlTab(host, "human_resource_policies");
                            }
                        })]
                    })
                ]
            }),
            data_ctn
        ]
    });
    host.frameList.addChild(singlePage);
    singlePage.requestActive();
};

contentModule.showPolicyNoApproval = function(host, params){
    hr.menu.changeCurrentUrlTab(host, params.type + "_policies/" + params.policyid);
    var nav = absol.buildDom({
        tag:'mknav',
        class: 'mk-nav',
        props: {
            items: [
                {text: LanguageModule.text("txt_general_information"), value: "general_information"},
                {text: LanguageModule.text("txt_employee_apply"), value: "employee_apply"},
                {text: LanguageModule.text("txt_comment"), value: "comment"}
            ],
            value: "general_information"
        },
        on:{
            clickitem: function(event){
                rightCtn.off('scroll',scrollRightFunc);// prevent loop
                if (sectionList[this.value]) sectionList[this.value].scrollIntoView();
                setTimeout(function(){
                    rightCtn.on('scroll',scrollRightFunc );
                }, 10);
            }
        }
    });
    var scrollRightFunc = function(){
        var elt;
        var bound = rightCtn.getBoundingClientRect();
        var eltBound;
        var nearestEltId;
        var nearestDistance = 100000000;
        var distance;
        for (var i in sectionList){
            elt = sectionList[i];
            eltBound = elt.getBoundingClientRect();
            distance = 1000000;
            if (eltBound.top <= bound.top){
                if (eltBound.bottom >= bound.bottom){
                    distance = -1e6;
                }
                else if (bound.top - eltBound.top  < 30){
                    distance = eltBound.top - bound.bottom;//negative
                }
                else if (eltBound.bottom > bound.top){
                    distance = bound.top - eltBound.top;
                }
            }
            else if (eltBound.top < bound.bottom){
                distance = eltBound.top - bound.bottom;//negative
            }
            else {
                distance = Math.abs(bound.top - eltBound.top)
            }
            if (nearestDistance > distance){
                nearestDistance = distance;
                nearestEltId = i;
            }
        }
        nav.value = nearestEltId;
    };
    var rightCtn = absol.buildDom({
        class: 'mk-main-right',
        style: {
            paddingBottom: "var(--footer-margin)"
        },
        on: {
            scroll: scrollRightFunc
        }
    });
    rightCtn.appendChild(contentModule.drawGeneralInformationPolicy(host, params));
    rightCtn.appendChild(contentModule.drawEmployeeApplyPolcies(host, params));
    rightCtn.appendChild(contentModule.drawComment({taskid: params.policyid, tablename: params.type + "_policies"}));
    var data_ctn = absol._({
        class: 'mk-main',
        style: {
            height: '100%'
        },
        child: [
            {
                class: 'mk-main-left-ctn',
                child: [nav]
            },
            rightCtn
        ]
    });
    var sectionList = {};
    absol.$("div", rightCtn, function(elt){
        var id = elt.getAttribute("data-sectionid");
        if (!id) return;
        sectionList[id] = elt;
    });
    var singlePage = absol.buildDom({
        tag: "singlepage",
        class: ["cd-page-not-padding-right", "as-viewport-full", "as-no-scroll"],
        child: [
            DOMElement.div({
                attrs: {className: 'button-panel-header absol-single-page-header'},
                children: [
                    DOMElement.div({
                        attrs: {className: "single-button-header"},
                        children: [theme.backButton({
                            onclick: function(){
                                host.frameList.removeLast();
                                hr.menu.changeCurrentUrlTab(host, "human_resource_policies");
                            }
                        })]
                    })
                ]
            }),
            data_ctn
        ]
    });
    host.frameList.addChild(singlePage);
    singlePage.requestActive();
};

contentModule.drawApprovalPolicy = function(host, params){
    var viewApproval = DOMElement.div({
        attrs: {
            style: {
                paddingLeft: "var(--control-verticle-distance-2)",
                paddingTop: "var(--control-verticle-distance-2)"
            }
        }
    });
    var getApprovalMethod = function(value){
        var list = contentModule.getListApprovalMethod();
        for (var i = 0; i < list.length; i++){
            if (list[i].value == value) return list[i].text;
        }
        return "";
    };
    host.drawApprovalFunc = function(){
        var getRowApproverView = function(employeeid){
            var res = [];
            var eIndex = host.database.employees.getIndex(employeeid);
            var dIndex = host.database.employees.items[eIndex].orgIndex;
            res.push({
                value: host.database.orgs.items[dIndex].name
            });
            res.push({
                value: host.database.employees.items[eIndex].fullname
            });
            return res;
        };
        var approval_method = getApprovalMethod(host.dataPolicyEdit.approval_method);
        var direct_manager_approves_first = host.dataPolicyEdit.direct_manager_approves_first? LanguageModule.text("txt_yes") : LanguageModule.text("txt_no");
        var time_hours_needed_for_approval = host.dataPolicyEdit.time_hours_needed_for_approval;
        var approvers = host.dataPolicyEdit.approvers;
        var header = [];
        header.push(
            {value: LanguageModule.text("txt_department")},
            {value: LanguageModule.text("txt_employee")}
        );
        var data = [];
        for (var i = 0; i < approvers.length; i++){
            data.push(getRowApproverView(approvers[i].employeeid));
        }
        var tableView = pizo.tableView(
            header,
            data,
            false,
            false
        );
        DOMElement.removeAllChildren(viewApproval);
        var approvalElt = DOMElement.div({
            children: [
                DOMElement.table({
                    data: [
                        [
                            {
                                attrs: {style: {lineHeight: "var(--control-height)"}},
                                text: LanguageModule.text("txt_direct_manager_approves_first")
                            },
                            {attrs: {style: {width: "var(--distance-between-title-value)"}}},
                            {text: direct_manager_approves_first}
                        ],
                        [{attrs: {style: {height: "var(--control-verticle-distance-2)"}}}],
                        [
                            {
                                attrs: {style: {lineHeight: "var(--control-height)"}},
                                text: LanguageModule.text("txt_time_hours_needed_for_approval")
                            },
                            {attrs: {style: {width: "var(--distance-between-title-value)"}}},
                            {text: time_hours_needed_for_approval}
                        ],
                        [{attrs: {style: {height: "var(--control-verticle-distance-2)"}}}],
                        [
                            {
                                attrs: {style: {lineHeight: "var(--control-height)"}},
                                text: LanguageModule.text("txt_approval_method")
                            },
                            {attrs: {style: {width: "var(--distance-between-title-value)"}}},
                            {text: approval_method}
                        ]
                    ]
                }),
                DOMElement.div({attrs: {style: {height: "var(--control-verticle-distance-2)"}}}),
                DOMElement.div({
                    children: [
                        DOMElement.span({text: LanguageModule.text("txt_approvers")})
                    ]
                }),
                DOMElement.div({attrs: {style: {height: "var(--control-verticle-distance-2)"}}}),
                DOMElement.div({
                    attrs: {className: "cardsimpletableclass"},
                    children: [tableView]
                })
            ]
        });
        viewApproval.appendChild(approvalElt);
    };
    host.drawApprovalFunc();
    var childs = [
        {
            class: 'mk-section-header-name',
            child: { text: LanguageModule.text("txt_approval") },
        }
    ];
    if (systemconfig.privSystem >= 2 || data_module.admin_rights_of_me.human_resource_policy){
        childs.push({
            class: 'mk-section-header-right',
            child: [
                DOMElement.a({
                    attrs: {
                        onclick: function(){
                            params.editApprovalFunc();
                        }
                    },
                    text: LanguageModule.text("txt_edit")
                })
            ]
        });
    }
    var res = absol.buildDom({
        attr: {
            "data-sectionid": "approval"
        },
        child: [
            absol.buildDom({
                class: 'mk-section-header',
                child: childs
            }),
            viewApproval
        ]
    });
    return res;
};

contentModule.showPolicyApprover = function(host, params){
    hr.menu.changeCurrentUrlTab(host, params.type + "_policies/" + params.policyid);
    var nav = absol.buildDom({
        tag:'mknav',
        class: 'mk-nav',
        props: {
            items: [
                {text: LanguageModule.text("txt_general_information"), value: "general_information"},
                {text: LanguageModule.text("txt_employee_apply"), value: "employee_apply"},
                {text: LanguageModule.text("txt_approval"), value: "approval"},
                {text: LanguageModule.text("txt_comment"), value: "comment"}
            ],
            value: "general_information"
        },
        on:{
            clickitem: function(event){
                rightCtn.off('scroll',scrollRightFunc);// prevent loop
                if (sectionList[this.value]) sectionList[this.value].scrollIntoView();
                setTimeout(function(){
                    rightCtn.on('scroll',scrollRightFunc );
                }, 10);
            }
        }
    });
    var scrollRightFunc = function(){
        var elt;
        var bound = rightCtn.getBoundingClientRect();
        var eltBound;
        var nearestEltId;
        var nearestDistance = 100000000;
        var distance;
        for (var i in sectionList){
            elt = sectionList[i];
            eltBound = elt.getBoundingClientRect();
            distance = 1000000;
            if (eltBound.top <= bound.top){
                if (eltBound.bottom >= bound.bottom){
                    distance = -1e6;
                }
                else if (bound.top - eltBound.top  < 30){
                    distance = eltBound.top - bound.bottom;//negative
                }
                else if (eltBound.bottom > bound.top){
                    distance = bound.top - eltBound.top;
                }
            }
            else if (eltBound.top < bound.bottom){
                distance = eltBound.top - bound.bottom;//negative
            }
            else {
                distance = Math.abs(bound.top - eltBound.top)
            }
            if (nearestDistance > distance){
                nearestDistance = distance;
                nearestEltId = i;
            }
        }
        nav.value = nearestEltId;
    };
    var rightCtn = absol.buildDom({
        class: 'mk-main-right',
        style: {
            paddingBottom: "var(--footer-margin)"
        },
        on: {
            scroll: scrollRightFunc
        }
    });

    rightCtn.appendChild(contentModule.drawGeneralInformationPolicy(host, params));
    rightCtn.appendChild(contentModule.drawEmployeeApplyPolcies(host, params));
    if (params.type == "leave"){
        rightCtn.appendChild(hr.leave_policies.drawApprovalPolicy(host, params.policyid));
    }
    else {
        rightCtn.appendChild(contentModule.drawApprovalPolicy(host, params));
    }
    rightCtn.appendChild(contentModule.drawComment({taskid: params.policyid, tablename: params.type + "_policies"}));
    var data_ctn = absol._({
        class: 'mk-main',
        style: {
            height: '100%'
        },
        child: [
            {
                class: 'mk-main-left-ctn',
                child: [nav]
            },
            rightCtn
        ]
    });
    var sectionList = {};
    absol.$("div", rightCtn, function(elt){
        var id = elt.getAttribute("data-sectionid");
        if (!id) return;
        sectionList[id] = elt;
    });
    var singlePage = absol.buildDom({
        tag: "singlepage",
        class: ["cd-page-not-padding-right", "as-viewport-full", "as-no-scroll"],
        child: [
            DOMElement.div({
                attrs: {className: 'button-panel-header absol-single-page-header'},
                children: [
                    DOMElement.div({
                        attrs: {className: "single-button-header"},
                        children: [theme.backButton({
                            onclick: function(){
                                host.frameList.removeLast();
                                hr.menu.changeCurrentUrlTab(host, "human_resource_policies");
                            }
                        })]
                    })
                ]
            }),
            data_ctn
        ]
    });
    host.frameList.addChild(singlePage);
    singlePage.requestActive();
};

contentModule.getUnitByInstrumentsAndToolsId = function(host, id){
    if (id == 0) return "";
    var iIndex = host.database.instruments_and_tools.getIndex(id);
    return host.database.instruments_and_tools.items[iIndex].unit;
};

contentModule.getInventoryByByInstrumentsAndToolsId = function(host, id){
    if (id == 0) return "";
    var iIndex = host.database.instruments_and_tools.getIndex(id);
    return host.database.instruments_and_tools.items[iIndex].inventory;
};

contentModule.getStatusByAssetId = function(host, assetid){
    if (assetid > 0){
        var aIndex = host.database.assets.getIndex(assetid);
        return contentModule.getAssetStatusName(host.database.assets.items[aIndex].status);
    }
    else {
        return contentModule.getAssetStatusName("good");
    }
};

contentModule.listTypeSelectmenu = [
    "member_of_position",
    "member_of_employee",
    "member_of_worktime_machines",
    "member_of_assets",
    "member_of_instruments_and_tools",
    "member_of_warehouses",
    "member_of_assets_instruments_and_tools",
    "member_of_allowance_policy_groups",
    "member_of_training_program_groups",
    "member_of_leave_policy_groups",
    "member_of_insurance_policy_groups",
    "member_of_benefit_policy_groups",
    "member_of_tax_policy_groups",
    "member_of_bonus_policy_groups",
    "member_of_work_flow_groups",
    "member_of_work_flows",
    "member_of_objects",
    "member_of_payroll_cycle",
    "member_of_lesson_categories",
    "member_of_task",
    "member_of_meeting",
    "member_of_typelists",
    "member_of_input_forms",
    "member_of_output_forms",
    "member_of_mobile_input_forms",
    "member_of_mobile_output_forms",
    "member_of_partner_class",
    "member_of_partner",
    "member_of_contact",
    "member_of_trade_union_policy_groups",
    "member_of_overtime_policy_groups",
    "member_of_offboarding_types",
    "member_of_offboarding_reasons",
    "member_of_salary_policy_groups",
    "member_of_other_liability_policy_groups",
    "member_of_late_early_checkin_policy_groups",
    "member_of_advance_payment_policy_groups",
    "member_of_punishment_policy_groups",
    "member_of_asset_category",
    "member_of_instruments_and_tools_category",
    "member_of_projects",
    "member_of_insurance_policies",
    "member_of_tax_policies",
    "member_of_trade_union_policies",
    "member_of_leave_policies",
    "member_of_benefit_policies",
    "member_of_allowance_policies",
    "member_of_bonus_policies",
    "member_of_overtime_policies",
    "member_of_punishment_policies",
    "member_of_advance_payment_policies",
    "member_of_late_early_checkin_policies",
    "member_of_salary_policies",
    "member_of_other_liability_policies",
    "member_of_employment_contract_types",
    "member_of_nations",
    "member_of_cities",
    "member_of_religions",
    "member_of_shifts",
    "member_of_ethnics",
    "member_of_department",
    "geopos",
    "user",
    "member_of_document_types",
    "member_of_orgs",
    "member_of_document_groups",
    "member_of_document_folders",
    "member_of_template_groups",
    "member_of_welcome_templates",
    "nation_city"
];

contentModule.listTypeSelectbox = [
    "select_department_employee",
    "userlist",
    "members_of_shifts",
    "members_of_partner_class",
    "multiselect_offboarding_reasons",
    "members_of_locations",
    "employee_list",
    "position_list"
];

contentModule.listPurposeHasActivities = function(){
    return [
        {name: LanguageModule.text("txt_partner"), tablename: "partner", datatype: "member_of_partner"},
        {name: LanguageModule.text("txt_contact"), tablename: "contact", datatype: "member_of_contact"},
        {name: LanguageModule.text("txt_object"), tablename: "objects", datatype: "member_of_objects"},
        {name: LanguageModule.text("txt_onboarding"), tablename: "onboarding"},
        {name: LanguageModule.text("txt_offboarding"), tablename: "offboarding"}
    ]
};

contentModule.getColumnListConfig = function(host, user_column_configsDic, columnList, tabletype){
    return new Promise(function(resolve, reject){
        var res = EncodingClass.string.duplicate(columnList);
        if (user_column_configsDic[tabletype] !== undefined){
            var dic = {};
            for (var i = 0; i < user_column_configsDic[tabletype].length; i++){
                dic[user_column_configsDic[tabletype][i].value] = i + 1;
            }
            for (var i = 0; i < res.length; i++){
                if (dic[res[i].value]){
                    res[i].stt = dic[res[i].value];
                    res[i].display = user_column_configsDic[tabletype][dic[res[i].value] - 1].display;
                }
                else {
                    res[i].stt = 1000;
                }
            }
            res.sort(function(a, b){
                return a.stt - b.stt;
            });
        }
        res = res.filter(function(item){
            return item.display;
        });
        if (!host){
            resolve(res);
            return;
        }
        var listPromise = [];
        var typeDic = contentModule.makeDictionaryIndex(host.database.typelists.items);
        listPromise = res.map(function(item){
            if (!item.type) return;
            var res1;
            var tIndex, type;
            if (item.type == "purpose"){
                var listPurpose = contentModule.listPurposeHasActivities();
                var res2 = [];
                item.itemsDic = {};
                listPurpose.forEach(function(itemPurpose){
                    if (itemPurpose.datatype){
                        res2.push(new Promise(function(rs, rj){
                            contentModule.loadListPrimaryTypeEnum(itemPurpose.datatype).then(function(list){
                                if (list.length > 0) list[0].text = "";
                                item.itemsDic[itemPurpose.tablename] = {
                                     type: itemPurpose.datatype,
                                     listItems: list,
                                     listItemsDic: new absol.ListDictionary(list),
                                     name: itemPurpose.name
                                };
                                rs();
                            });
                        }));
                    }
                    else {
                        item.itemsDic[itemPurpose.tablename] = {
                             name: itemPurpose.name
                        };
                    }
                });
                res1 = new Promise(function(rs, rj){
                    Promise.all(res2).then(function(){
                        item.type = "purpose";
                        rs();
                    });
                });
            }
            else if (item.type == "marked"){
                // TODO:
            }
            else {
                tIndex = typeDic[item.type];
                type = host.database.typelists.items[tIndex].type;
                if (contentModule.listTypeSelectmenu.indexOf(type) >= 0){
                    res1 = new Promise(function(rs, rj){
                        contentModule.loadListPrimaryTypeEnum(type).then(function(list){
                            item.listItems = list;
                            if (type == "nation_city"){
                                item.listItems.forEach(function(nationItem){
                                    nationItem.listItemsDic = new absol.ListDictionary(nationItem.items);
                                });
                                item.listItemsDic = new absol.ListDictionary(item.listItems, {depth: false});
                            }
                            else {
                                if (item.listItems.length > 0) item.listItems[0].text = "";
                                item.listItemsDic = new absol.ListDictionary(item.listItems);
                            }
                            rs();
                        });
                    });
                    item.type = type;
                }
                else if (contentModule.listTypeSelectbox.indexOf(type) >= 0){
                    res1 = new Promise(function(rs, rj){
                        contentModule.loadListPrimaryTypeEnum(type).then(function(list){
                            item.listItems = list;
                            item.listItemsDic = new absol.ListDictionary(list);
                            rs();
                        });
                    });
                    item.type = type;
                }
                else if (type == "enum" || type == "extends_enum" || host.database.typelists.items[tIndex].type2 == "enum"){
                    var list = [];
                    contentModule.getDetailsExtends(host, list, item.type);
                    item.listItems = [];
                    for (var i = 0; i < list.length; i++){
                        item.listItems.push({value: list[i].localid, text: list[i].text});
                    }
                    item.listItemsDic = new absol.ListDictionary(item.listItems);
                    item.type = "enum";
                }
                else if (type == "enum_multi" || type == "extends_enum_multi" || host.database.typelists.items[tIndex].type2 == "enum_multi"){
                    var list = [];
                    contentModule.getDetailsExtends(host, list, item.type);
                    item.listItems = [];
                    for (var i = 0; i < list.length; i++){
                        item.listItems.push({value: list[i].localid, text: list[i].text});
                    }
                    item.listItemsDic = new absol.ListDictionary(item.listItems);
                    item.type = "enum_multi";
                }
                else {
                    item.type = type;
                }
            }
            return res1;
        }).filter(function(res1){return !!res;});
        Promise.all(listPromise).then(function(){
            resolve(res);
        });
    });
};

contentModule.userColumnConfigForm = function(params){
    return new Promise(function(resolve, reject){
        var saveFunc = function(){
            var data = tableView.data;
            var dataSave = [];
            var countDisplay = 0;
            for (var i = 0; i < data.length; i++){
                dataSave.push({
                    value: data[i][1].value,
                    display: data[i][2].element.checked
                });
                if (data[i][2].element.checked) countDisplay++;
            }
            if (countDisplay == 0){
                ModalElement.alert({message: "Phải chọn ít nhất 1 cột"});
                return;
            }
            ModalElement.show_loading();
            FormClass.api_call({
                url: "user_column_configs_save.php",
                params: [
                    {name: "config", value: EncodingClass.string.fromVariable(dataSave)},
                    {name: "type", value: params.type}
                ],
                func: function(success, message){
                    ModalElement.close(-1);
                    if (success){
                        if (message.substr(0, 2) == "ok"){
                            resolve(dataSave);
                            ModalElement.close();
                        }
                        else {
                            ModalElement.alert({message: message});
                        }
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
            });
        };
        var tableView;
        var drawFunc = function(){
            var header = [
                {type: "dragzone", style: {paddingLeft: "var(--control-verticle-distance-1)", paddingRight: "var(--control-verticle-distance-1)", width: "40px"}},
                {value: LanguageModule.text("txt_column_name")},
                {value: LanguageModule.text("txt_display")}
            ];
            var data = [];
            for (var i = 0; i < config.length; i++){
                data.push([
                    {},
                    {
                        value: config[i].value,
                        element: DOMElement.span({
                            text: config[i].text
                        })
                    },
                    {
                        element: absol.buildDom({
                            tag: "switch",
                            style: {
                                font: "var(--switch-fontsize)",
                                margin: "auto"
                            },
                            props: {
                                checked: config[i].display
                            }
                        })
                    }
                ]);
            }
            tableView = pizo.tableView(
                header,
                data,
                false,
                true
            );
            tableView.style.width = "100%";
            tableView.realTable.style.width = "100%";
            ModalElement.showWindow({
                title: LanguageModule.text("txt_show_columns"),
                bodycontent: tableView,
                buttonlist: [
                    {
                        text: LanguageModule.text("txt_save"),
                        onclick: function(){
                            saveFunc();
                        }
                    },
                    {
                        text: LanguageModule.text("txt_cancel"),
                        onclick: function(){
                            ModalElement.close();
                        }
                    }
                ]
            });
        };
        var config = params.columnList;
        ModalElement.show_loading();
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "user_column_configs"},
                {name: "type", value: params.type}
            ],
            func: function(success, message){
                ModalElement.close(-1);
                if (success){
                    if (message.substr(0, 2) == "ok"){
                        var st = EncodingClass.string.toVariable(message.substr(2));
                        if (st.length > 0){
                            st[0].config = EncodingClass.string.toVariable(st[0].config);
                            var dic = {};
                            for (var i = 0; i < st[0].config.length; i++){
                                dic[st[0].config[i].value] = i + 1;
                            }
                            for (var i = 0; i < config.length; i++){
                                if (dic[config[i].value]){
                                    config[i].stt = dic[config[i].value];
                                    config[i].display = st[0].config[dic[config[i].value] - 1].display;
                                }
                                else {
                                    config[i].stt = 1000;
                                }
                            }
                            config.sort(function(a, b){
                                return a.stt - b.stt;
                            });
                        }
                        drawFunc();
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
        });
    });
};

contentModule.getUser_column_configsDic = function(host){
    var dic = {};
    host.database.user_column_configs.items.forEach(function(item){
        dic[item.type] = EncodingClass.string.toVariable(item.config);
    });
    return dic;
};

contentModule.getColumnListFromTypeid = function(host, typeid, displayDic, extra, ps = {}){
    var typeIndex = host.database.typelists.getIndex(typeid);
    var content = host.database.typelists.items[typeIndex].content;
    if (contentModule.datatypeAdvanced.indexOf(host.database.typelists.items[typeIndex].type) >= 0 && EncodingClass.type.isString(content)){
        content = EncodingClass.string.toVariable(content);
    }
    var list = [];
    contentModule.getDetailsExtends(host, list, typeid);
    var dict = {};
    host.database.typelists.items.forEach(function (elt, index) {
        dict[elt.id] = elt;
    });
    var columnList = [], colItem;
    if (!extra) var mainData = contentModule.getMainData(typeid, dict);
    var type, tIndex;
    for (var i = 0; i < list.length; i++){
        type = list[i].type;
        if (type == "union") type = list[i].typeOfUnion;
        tIndex = host.database.typelists.getIndex(type);
        if (!ps.all){
            if (host.database.typelists.items[tIndex].type == "structure") continue;
            if (host.database.typelists.items[tIndex].type == "extends_structure") continue;
            if (host.database.typelists.items[tIndex].type2 == "structure") continue;
            if (host.database.typelists.items[tIndex].type == "files") continue;
            if (host.database.typelists.items[tIndex].type == "image_file") continue;
            if (host.database.typelists.items[tIndex].type == "any_file") continue;
        }
        if (!extra && mainData[list[i].localid]){
            colItem = {
                value: mainData[list[i].localid],
                display: displayDic[mainData[list[i].localid]],
                main: true
            };
        }
        else {
            if (!ps.all) if (host.database.typelists.items[tIndex].type == "array") continue;
            colItem = {
                value: list[i].localid,
                display: false
            }
            if (ps.all && host.database.typelists.items[tIndex].type == "array") colItem.notView = true;
        }
        if (list[i].type == "union") colItem.type = list[i].typeOfUnion;
        else colItem.type = list[i].type;
        colItem.text = list[i].name;
        if (ps.all){
            if (host.database.typelists.items[tIndex].type == "structure") colItem.notView = true;
            if (host.database.typelists.items[tIndex].type == "extends_structure") colItem.notView = true;
            if (host.database.typelists.items[tIndex].type2 == "structure") colItem.notView = true;
            if (host.database.typelists.items[tIndex].type == "files") colItem.notView = true;
            if (host.database.typelists.items[tIndex].type == "image_file") colItem.notView = true;
            if (host.database.typelists.items[tIndex].type == "any_file") colItem.notView = true;
        }
        columnList.push(colItem);
    }
    return columnList;
};

contentModule.getColumnListFromDatatype = function(host, type, displayDic, extra, ps){
    var typeid = host.form_config[type].typeid;
    return contentModule.getColumnListFromTypeid(host, typeid, displayDic, extra, ps);
};
contentModule.getMarkIcon = function(marked, func){
    if (marked){
        return DOMElement.div({
            attrs: {
                className: "card-icon-cover",
                onclick: function(event, me){
                    func(false).then(function(){
                        var pa = me.parentNode;
                        DOMElement.removeAllChildren(pa);
                        pa.appendChild(contentModule.getMarkIcon(false, func));
                    });
                }
            },
            children: [DOMElement.i({
                attrs: {
                    className: "material-icons ",
                    style: {
                        cursor: "pointer",
                        color: "#ffa834",
                        fontSize: "var(--icon-fontsize)"
                    }
                },
                text: "star"
            })]
        });
    }
    else {
        return DOMElement.div({
            attrs: {
                className: "card-icon-cover",
                onclick: function(event, me){
                    func(true).then(function(){
                        var pa = me.parentNode;
                        DOMElement.removeAllChildren(pa);
                        pa.appendChild(contentModule.getMarkIcon(true, func));
                    });
                }
            },
            children: [
                DOMElement.i({
                    attrs: {
                        className: "material-icons",
                        style: {
                            cursor: "pointer",
                            color: "#7a7a7a",
                            fontSize: "var(--icon-fontsize)"
                        }
                    },
                    text: "star_border"
                })
            ]
        });
    }
};

contentModule.getstarIconView = function(){
    return DOMElement.span({
        attrs: {
            className: "material-icons",
            style: {
                color: "#ffa834",
                fontSize: "var(--icon-fontsize)",
                marginLeft: "5px",
                verticalAlign: "middle"
            }
        },
        text: "star"
    });
};

contentModule.getCellDynamicTable = function(content, value, paramsFunc = {}, paramsExtra = {}){
    var res;
    function applyParam(elt){
        if (paramsFunc.onclick){
            elt.classList.add("hr-table-cell-link");
            elt.onclick = paramsFunc.onclick;
        }
        return elt;
    }
    switch (content.type){
        case "color_picker":
            res = {
                style: {textAlign: "center"},
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(absol.buildDom({
                            tag: "colorpickerbutton",
                            props: {
                                mode: 'HEX6',
                                value: value == "" ? "white" : value,
                                disabled: true
                            }
                        }));
                    }
                    else {
                        tdElt.addChild(DOMElement.div({
                            children: [
                                absol.buildDom({
                                    tag: "colorpickerbutton",
                                    style: {
                                        display: "inline-block"
                                    },
                                    props: {
                                        mode: 'HEX6',
                                        value: value == "" ? "white" : value,
                                        disabled: true
                                    }
                                }),
                                contentModule.getstarIconView()
                            ]
                        }));
                    }
                },
                keySort: value == "" ? "white" : value
            };
            break;
        case "marked":
            var markIcon = contentModule.getMarkIcon(value, paramsFunc.markedFunc);
            res = {
                style: {textAlign: "center"},
                render: function(tdElt){
                    tdElt.addChild(DOMElement.div({
                        children: [markIcon]
                    }));
                },
                keySort: ""
            };
            break;
        case "string":
        case "email_address":
        case "website":
        case "phonenumber":
            res = {
                innerText: value,
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: value
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: value}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "gps":
            res = {
                innerText: value,
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: value.length > 10? value.substr(0, 10) + "..." : value
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: value.length > 10? value.substr(0, 10) + "..." : value}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "note":
            var valueText = value? value.substr(0, 200) : "";
            res = {
                innerText: value,
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            attrs: {
                                className: "hr-table-desc-ctn"
                            },
                            text: value
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            attrs: {
                                className: "hr-table-desc-ctn"
                            },
                            children: [
                                DOMElement.span({text: value}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "number":
            res = {
                innerText: (value === "" || value === undefined)? "" : absol.$.formatLocalFloat(value),
                style: {
                    textAlign: "right"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value === "" || value === undefined)? "" : absol.$.formatLocalFloat(value)
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value === "" || value === undefined)? "" : absol.$.formatLocalFloat(value)}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "currency":
            res = {
                innerText: (value === "" || value === undefined)? "" : absol.$.formatLocalFloat(value),
                style: {
                    textAlign: "right"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value === "" || value === undefined)? "" : absol.$.formatLocalFloat(value)
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value === "" || value === undefined)? "" : absol.$.formatLocalFloat(value)}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "date":
            res = {
                innerText: (value && value.getTime() > 0)? contentModule.getDateView(value) : "",
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value && value.getTime() > 0)? contentModule.getDateView(value) : ""
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value && value.getTime() > 0)? contentModule.getDateView(value) : ""}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "datemonth":
            var textView = "";
            console.log(value);
            if (value){
                var month = value.month + 1;
                if (month < 10) month = "0" + month;
                var date = value.date;
                if (date < 10) date = "0" + date;
                textView = date + "/" + month;
            }
            res = {
                innerText: textView,
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: textView
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: textView}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "datetime":
            res = {
                innerText: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : "",
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : ""
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : ""}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "time":
            res = {
                innerText: (value && value.getTime() > 0)? contentModule.getTimeView(value) : "",
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value && value.getTime() > 0)? contentModule.getTimeView(value) : ""
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value && value.getTime() > 0)? contentModule.getTimeView(value) : ""}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "datetime":
            res = {
                innerText: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : "",
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : ""
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : ""}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "month":
            res = {
                innerText: (value && value.getTime() > 0)? contentModule.getMonthView(value) : "",
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value && value.getTime() > 0)? contentModule.getMonthView(value) : ""
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value && value.getTime() > 0)? contentModule.getMonthView(value) : ""}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "week":
            res = {
                innerText: (value && value.getTime() > 0)? contentModule.getWeekView(value) : "",
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: (value && value.getTime() > 0)? contentModule.getWeekView(value) : ""
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: (value && value.getTime() > 0)? contentModule.getWeekView(value) : ""}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value
            };
            break;
        case "boolean":
            res = {
                innerText: value? LanguageModule.text("txt_yes") : LanguageModule.text("txt_no"),
                style: {
                    textAlign: "center"
                },
                render: function(tdElt){
                    if (content.notLink){
                        tdElt.addChild(absol.buildDom({
                            tag: "switch",
                            style: {
                                font: "var(--switch-fontsize)"
                            },
                            props: {
                                checked: value,
                                disabled: !content.notDisabled
                            },
                            on: {
                                change: function(){
                                    if (paramsFunc.changeStatus) paramsFunc.changeStatus(this.checked);
                                }
                            }
                        }));
                    }
                    else {
                        tdElt.addChild(absol.buildDom({
                            tag: "switch",
                            style: {
                                font: "var(--switch-fontsize)"
                            },
                            props: {
                                checked: value,
                                disabled: !content.notDisabled
                            }
                        }));
                    }
                },
                keySort: value
            };
            break;
        case "hour_period":
            var text = "";
            if (value && value.dayOffset) text = contentModule.getHourView(value.dayOffset) + " - " + contentModule.getHourView(value.dayOffset + value.duration);
            res = {
                innerText: text,
                style: {whiteSpace: "nowrap"},
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            attrs: {
                                align: "center"
                            },
                            text: value
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            attrs: {
                                align: "center"
                            },
                            children: [
                                DOMElement.span({text: value}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: text
            };
            break;
        case "html":
            var xt = DOMElement.div({
                innerHTML: value? value: ""
            });
            var valueText = xt.innerText.substr(0, 200);
            res = {
                innerText: valueText,
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: valueText
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: valueText}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: value? value: ""
            };
            break;
        case "nation_city":
            var text = "";
            if (value){
                var item = content.listItemsDic.getItemByValue(value[0]);
                if (item){
                    text = item.text;
                    item = item.listItemsDic.getItemByValue(value[1]);
                    if (item) text += " - " +  item.text;
                }
            }
            res = {
                innerText: text,
                style: {whiteSpace: "nowrap"},
                render: function(tdElt){
                    if (!paramsExtra.marked){
                        tdElt.addChild(applyParam(DOMElement.div({
                            text: text
                        })));
                    }
                    else {
                        tdElt.addChild(applyParam(DOMElement.div({
                            children: [
                                DOMElement.span({text: text}),
                                contentModule.getstarIconView()
                            ]
                        })));
                    }
                },
                keySort: text
            };
            break;
        default:
            if (contentModule.listTypeSelectmenu.indexOf(content.type) >= 0 || content.type == "enum" || content.type == "extends_enum"){
                if (content.type == "member_of_employee"){
                    if (data_module.all_employeesDic && data_module.all_employeesDic[value]) value = data_module.all_employeesDic[value];
                }
                var item = content.listItemsDic.getItemByValue(value);
                var text;
                if (!item) text = "";
                else text = item.text;
                res = {
                    innerText: text,
                    render: function(tdElt){
                        if (!paramsExtra.marked){
                            tdElt.addChild(applyParam(DOMElement.div({
                                text: text
                            })));
                        }
                        else {
                            tdElt.addChild(applyParam(DOMElement.div({
                                children: [
                                    DOMElement.span({text: text}),
                                    contentModule.getstarIconView()
                                ]
                            })));
                        }
                    },
                    keySort: text
                };
            }
            else if (contentModule.listTypeSelectbox.indexOf(content.type) >= 0 || content.type == "enum_multi") {
                var text = "";
                var item;
                if (value){
                    for (var i = 0; i < value.length; i++){
                        if (content.type == "employee_list"){
                            if (data_module.all_employeesDic[value[i]]) value[i] = data_module.all_employeesDic[value[i]];
                        }
                        else if (content.type == "select_department_employee"){
                            if (-value[i] < 0){
                                if (data_module.all_employeesDic[-value[i]]) value[i] = -data_module.all_employeesDic[-value[i]];
                            }
                        }
                        item = content.listItemsDic.getItemByValue(value[i]);
                        if (item) text += ", " + item.text
                    }
                    text = text.substr(2);
                }
                res = {
                    innerText: text,
                    render: function(tdElt){
                        if (!paramsExtra.marked){
                            tdElt.addChild(applyParam(DOMElement.div({
                                text: text
                            })));
                        }
                        else {
                            tdElt.addChild(applyParam(DOMElement.div({
                                children: [
                                    DOMElement.span({text: text}),
                                    contentModule.getstarIconView()
                                ]
                            })));
                        }
                    },
                    keySort: text
                };
            }
            else if (content.type == "purpose"){
                var text = "";
                if (value){
                    if (content.itemsDic[value.tablename]){
                        text = content.itemsDic[value.tablename].name;
                        if (content.itemsDic[value.tablename].listItems){
                            var item = content.itemsDic[value.tablename].listItemsDic.getItemByValue(value.instanceid);
                            if (item) text += ": " + item.text;
                            else text += ":";
                        }
                    }
                }
                res = {
                    innerText: text,
                    render: function(tdElt){
                        if (!paramsExtra.marked){
                            tdElt.addChild(applyParam(DOMElement.div({
                                text: text
                            })));
                        }
                        else {
                            tdElt.addChild(applyParam(DOMElement.div({
                                children: [
                                    DOMElement.span({text: text}),
                                    contentModule.getstarIconView()
                                ]
                            })));
                        }
                    },
                    keySort: text
                };
            }
            else {
                res = {
                    innerText: value,
                    render: function(tdElt){
                        if (!paramsExtra.marked){
                            tdElt.addChild(applyParam(DOMElement.div({
                                text: text
                            })));
                        }
                        else {
                            tdElt.addChild(applyParam(DOMElement.div({
                                children: [
                                    DOMElement.span({text: text}),
                                    contentModule.getstarIconView()
                                ]
                            })));
                        }
                    },
                    keySort: value
                };
            }

    }
    return res;
};

contentModule.getCellTableView = function(content, value, func){
    var res;
    switch (content.type) {
        case "color_picker":
            res = {
                value: "color_picker___",
                style: {
                    textAlign: "center"
                },
                element: absol.buildDom({
                    tag: "colorpickerbutton",
                    props: {
                        mode: 'HEX6',
                        value: value == "" ? "white" : value,
                        disabled: true
                    }
                })
            };
            break;
        case "marked":
            var markIcon = contentModule.getMarkIcon(value, func.markedFunc);
            res = {
                value: "marked___",
                style: {
                    textAlign: "center"
                },
                element: DOMElement.div({
                    children: [markIcon]
                })
            };
            break;
        case "string":
        case "email_address":
        case "gps":
        case "website":
        case "phonenumber":
            res = {
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view"
                    },
                    text: value
                })
            };
            break;
        case "note":
            var valueText = value? value.substr(0, 200) : "";
            res = {
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view hr-table-desc-ctn"
                    },
                    text: value
                })
            };
            break;
        case "number":
            res = {
                style: {
                    textAlign: "right"
                },
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value === "")? "" : absol.$.formatLocalFloat(value)
                })
            };
            break;
        case "currency":
            res = {
                style: {
                    textAlign: "right"
                },
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value === "")? "" : absol.$.formatLocalFloat(value)
                })
            };
            break;
        case "date":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getDateView(value) : ""
                })
            };
            break;
        case "datetime":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : ""
                })
            };
            break;
        case "time":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getTimeView(value) : ""
                })
            };
            break;
        case "month":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getMonthView(value) : ""
                })
            };
            break;
        case "week":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getWeekView(value) : ""
                })
            };
            break;
        case "boolean":
            res = {
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                        align: "center"
                    },
                    children: [absol.buildDom({
                        tag: "switch",
                        style: {
                            font: "var(--switch-fontsize)"
                        },
                        props: {
                            checked: value,
                            disabled: true
                        }
                    })]
                })
            };
            break;
        case "hour_period":
            var text = "";
            if (value && value.dayOffset) text = contentModule.getHourView(value.dayOffset) + " - " + contentModule.getHourView(value.dayOffset + value.duration);
            res = {
                style: {whiteSpace: "nowrap"},
                value: text,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                        align: "center"
                    },
                    text: text
                })
            };
            break;
        case "html":
            var xt = DOMElement.div({
                innerHTML: value? value: ""
            });
            var valueText = xt.innerText.substr(0, 200);
            res = {
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view hr-table-desc-ctn"
                    },
                    text: valueText
                })
            };
            break;
        case "nation_city":
            var text = "";
            if (value){
                var item = content.listItemsDic.getItemByValue(value[0]);
                if (item) text = item.text;
                var ld = new absol.ListDictionary(item.items);
                item = ld.getItemByValue(value[1]);
                if (item) text += " - " +  item.text;
            }
            res = {
                style: {whiteSpace: "nowrap"},
                value: text,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view"
                    },
                    text: text
                })
            };
            break;
        default:
            if (contentModule.listTypeSelectmenu.indexOf(content.type) >= 0 || content.type == "enum" || content.type == "extends_enum"){
                if (content.type == "member_of_employee"){
                    if (data_module.all_employeesDic[value]) value = data_module.all_employeesDic[value];
                }
                var item = content.listItemsDic.getItemByValue(value);
                var text;
                if (!item) text = "";
                else text = item.text;
                res = {
                    value: text,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: text
                    })
                };
            }
            else if (contentModule.listTypeSelectbox.indexOf(content.type) >= 0) {
                var text = "";
                var item;
                if (value){
                    for (var i = 0; i < value.length; i++){
                        if (content.type == "employee_list"){
                            if (data_module.all_employeesDic[value[i]]) value[i] = data_module.all_employeesDic[value[i]];
                        }
                        else if (content.type == "select_department_employee"){
                            if (-value[i] < 0){
                                if (data_module.all_employeesDic[-value[i]]) value[i] = -data_module.all_employeesDic[-value[i]];
                            }
                        }
                        item = content.listItemsDic.getItemByValue(value[i]);
                        if (item) text += ", " + item.text
                    }
                    text = text.substr(2);
                }
                res = {
                    value: text,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: text
                    })
                };
            }
            else if (content.type == "purpose"){
                var text = "";
                if (value){
                    if (content.itemsDic[value.tablename]){
                        text = content.itemsDic[value.tablename].name;
                        if (content.itemsDic[value.tablename].listItems){
                            var item = content.itemsDic[value.tablename].listItemsDic.getItemByValue(value.instanceid);
                            if (item) text += ": " + item.text;
                            else text += ":";
                        }
                    }
                }
                res = {
                    value: text,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: text
                    })
                };
            }
            else {
                res = {
                    value: value,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: value
                    })
                };
            }

    }
    return res;
};

contentModule.getFilterColumnIcon = function(params){
    return DOMElement.i({
        attrs: {
            className: "bsc-icon-hover-black mdi mdi-table-settings",
            onclick: params.func
        }
    });
};

contentModule.getCellHeaderTableView = function(content){
    return {value: content.text};
};

contentModule.getCellHeaderDynamicTable = function(content, paramsExtra = {}){
    var res = {
        style: {
            whiteSpace: "nowrap"
        },
        innerText: content.text,
        child: absol.buildDom({text: content.text})
    };
    if (paramsExtra.sort) res.sortKey = content.value;
    return res;
};

contentModule.makeEmailTemplateIndex = function(host){
    var k;
    for (var i = 0; i < host.database.template_groups.items.length; i++){
        host.database.template_groups.items[i].email_templates_index_list = [];
    }
    var data = [];
    for (var i = 0; i < host.database.email_templates.items.length; i++){
        if (host.database.email_templates.items[i].content == "") host.database.email_templates.items[i].content = {};
        else host.database.email_templates.items[i].content = EncodingClass.string.toVariable(host.database.email_templates.items[i].content);
        k = host.database.template_groups.getIndex(host.database.email_templates.items[i].typeid);
        if (k != -1) {
            host.database.email_templates.items[i].typeIndex = k;
            host.database.template_groups.items[k].email_templates_index_list.push(i);
            data.push(host.database.email_templates.items[i]);
        }
    }
    host.database.email_templates.items = data;
};

contentModule.makeTaskTemplateIndex = function(host){
    var k;
    for (var i = 0; i < host.database.template_groups.items.length; i++){
        host.database.template_groups.items[i].task_templates_index_list = [];
    }
    var data = [];
    for (var i = 0; i < host.database.task_templates.items.length; i++){
        if (host.database.task_templates.items[i].content == "") host.database.task_templates.items[i].content = {};
        else host.database.task_templates.items[i].content = EncodingClass.string.toVariable(host.database.task_templates.items[i].content);
        k = host.database.template_groups.getIndex(host.database.task_templates.items[i].typeid);
        if (k != -1) {
            host.database.task_templates.items[i].typeIndex = k;
            host.database.template_groups.items[k].task_templates_index_list.push(i);
            data.push(host.database.task_templates.items[i]);
        }
    }
    host.database.task_templates.items = data;
};

contentModule.makeMeetingTemplateIndex = function(host){
    var k;
    for (var i = 0; i < host.database.template_groups.items.length; i++){
        host.database.template_groups.items[i].meeting_templates_index_list = [];
    }
    var data = [];
    for (var i = 0; i < host.database.meeting_templates.items.length; i++){
        if (host.database.meeting_templates.items[i].content == "") host.database.meeting_templates.items[i].content = {};
        else host.database.meeting_templates.items[i].content = EncodingClass.string.toVariable(host.database.meeting_templates.items[i].content);
        k = host.database.template_groups.getIndex(host.database.meeting_templates.items[i].typeid);
        if (k != -1) {
            host.database.meeting_templates.items[i].typeIndex = k;
            host.database.template_groups.items[k].meeting_templates_index_list.push(i);
            data.push(host.database.meeting_templates.items[i]);
        }
    }
    host.database.meeting_templates.items = data;
};

contentModule.makeDocumentsIndex = function(host){
    for (var i = 0; i < host.database.document_folders.items.length; i++){
        host.database.document_folders.items[i].documentIndexList = [];
    }
    var folderDic = contentModule.makeDictionaryIndex(host.database.document_folders.items);
    var k;
    for (var i = 0; i < host.database.documents.items.length; i++){
        k = folderDic[host.database.documents.items[i].folderid];
        if (k !== undefined) host.database.document_folders.items[k].documentIndexList.push(i);
    }
};

contentModule.getVariableForTemplate = function(typeid, currentExpression){
    if (typeid === undefined) {
        ModalElement.alert({message: LanguageModule.text("txt_no_template_group_is_selected_yet")});
        return;
    };
    var examinationPluginVariable = [
        {text: "Tên bài kiểm tra", value: "name_of_examination"},
        {text: "Mô tả", value: "description_of_examination"},
        {text: "Giai đoạn", value: "stage_of_examination"},
        {text: "Thời gian chấm điểm (giờ)", value: "duration_of_examination_scoring"},
        {text: "Thời gian bắt đầu kiểm tra", value: "start_time_of_examination"},
        {text: "Thời lượng (phút)", value: "duration_of_examination"},
        {text: "Được phép bắt đầu trễ (phút)", value: "late_start_duration_of_examination"}
    ];
    var generalVariable = [
        {text: LanguageModule.text("txt_today"), value: "today"},
        {text: LanguageModule.text("txt_software_link"), value: "software_link"},
        {text: LanguageModule.text("txt_company_name_of_employee"), value: "company_name_of_employee"},
        {text: LanguageModule.text("txt_company_address_of_employee"), value: "company_address_of_employee"},
        {text: LanguageModule.text("txt_company_phonenumber_of_employee"), value: "company_phonenumber_of_employee"},
        {text: LanguageModule.text("txt_username"), value: "username"},
        {text: LanguageModule.text("txt_employee_name"), value: "employee_name"},
        {text: LanguageModule.text("txt_email_of_employee"), value: "email_of_employee"},
        {text: LanguageModule.text("txt_phonenumber_of_employee"), value: "phonenumber_of_employee"},
        {text: LanguageModule.text("txt_permanent_address"), value: "permanent_address"},
        {text: LanguageModule.text("txt_probation_start_date"), value: "probation_start_date"},
        {text: LanguageModule.text("txt_start_date_of_work"), value: "start_date_of_work"},
        {text: LanguageModule.text("txt_position_of_employee"), value: "position_of_employee"},
        {text: LanguageModule.text("txt_department_of_employee"), value: "department_of_employee"},
        {text: LanguageModule.text("txt_workplace_address_of_employee"), value: "workplace_address_of_employee"},
        {text: LanguageModule.text("txt_workplace_name_of_employee"), value: "workplace_name_of_employee"},
        {text: LanguageModule.text("txt_workplace_gps_address_of_employee"), value: "workplace_gps_address_of_employee"},
        {text: LanguageModule.text("txt_support_staff_hr"), value: "support_staff_hr"},
        {text: LanguageModule.text("txt_name_of_direct_manager"), value: "name_of_direct_manager"},
        {text: LanguageModule.text("txt_phonenumber_of_direct_manager"), value: "phonenumber_of_direct_manager"},
        {text: LanguageModule.text("txt_email_of_direct_manager"), value: "email_of_direct_manager"},
        {text: LanguageModule.text("txt_position_of_direct_manager"), value: "position_of_direct_manager"},
        {text: LanguageModule.text("txt_department_of_direct_manager"), value: "department_of_direct_manager"}
    ];
    var accordingToDataType = {};
    accordingToDataType[-227] = [
        {text: LanguageModule.text("txt_link_to_open_form"), value: "link_to_open_form"}
    ];
    accordingToDataType[-228] = [
        {text: LanguageModule.text("txt_link_to_open_form"), value: "link_to_open_form"},
        {text: LanguageModule.text("txt_end_date_of_work"), value: "end_date_of_work"}
    ];
    return new Promise(function (resolve) {
        var is_expression;
        if (currentExpression) {
            var pattern = /[+,\-,*,/]/;
            var rs = currentExpression.match(pattern);
            if (rs) is_expression = true;
            else is_expression = false;
        }
        else is_expression = false;
        var switchBtn = absol._({
            tag: "switch",
            style: {
                font: "var(--switch-fontsize)"
            },
            props: {
                checked: is_expression
            },
            on: {
                change: function(){
                    if (this.checked) {
                        absol.$(".hr-meeting-template-choose-variable", table, function(elt){
                            elt.style.display = "none";
                        });
                        absol.$(".hr-meeting-template-write-expression", table, function(elt){
                            elt.style.display = null;
                        });
                    }
                    else {
                        absol.$(".hr-meeting-template-choose-variable", table, function(elt){
                            elt.style.display = null;
                        });
                        absol.$(".hr-meeting-template-write-expression", table, function(elt){
                            elt.style.display = "none";
                        });
                    }
                }
            }
        });
        var variableList = generalVariable;
        if (accordingToDataType[typeid]) variableList = variableList.concat(accordingToDataType[typeid]);
        variableList.forEach(function(elt){
            elt.isLeaf = true;
            elt.sortText = absol.string.nonAccentVietnamese(elt.text.toLowerCase());
        });
        variableList.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });

        examinationPluginVariable.forEach(function(elt){
            elt.isLeaf = true;
            elt.sortText = absol.string.nonAccentVietnamese(elt.text.toLowerCase());
        });
        examinationPluginVariable.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });

        var cbbItems = [
            {value: "hr", text: "HR", items: variableList},
            {value: "plugin", text: "Bài kiểm tra (plugin)", items: examinationPluginVariable}
        ]

        var selectMenu = absol._({
            tag: 'selecttreeleafmenu',
            props: {
                items: cbbItems,
                value: currentExpression || variableList[0].value,
                enableSearch: true
            },
            style: {
                width: "400px"
            },
        });
        var user_chose_variable = function(currentExpression){
            return new Promise(function (resolve) {
                var selectMenu = absol._({
                    tag: 'selecttreeleafmenu',
                    props: {
                        items: cbbItems,
                        value: currentExpression || variableList[0].value,
                        enableSearch: true
                    },
                    style: {
                        width: "400px"
                    },
                });
                var table = DOMElement.table({
                    data: [
                        [
                            {
                                text: "Biến"},
                            {
                                attrs: {style: {paddingLeft: "10px"}},
                                children: [selectMenu]
                            }
                        ]
                    ]
                });
                ModalElement.showWindow({
                    index: 3,
                    title: "Chọn biến",
                    bodycontent: DOMElement.div({
                        style: {
                            padding: "10px"
                        },
                        children: [
                            DOMElement.div({
                                children: [table]
                            }),
                            DOMElement.div({
                                attrs: {
                                    style: {
                                        paddingTop: "20px",
                                        textAlign: "center"
                                    }
                                },
                                children: [
                                    DOMElement.div({
                                        attrs: {style: {
                                            display: "inline-block"
                                        }},
                                        children: [theme.okButton({
                                            onclick: function () {
                                                resolve(selectMenu.value);
                                                ModalElement.close(3);
                                            }
                                        })]
                                    }),
                                    DOMElement.div({
                                        attrs: {style: {
                                            display: "inline-block",
                                            paddingLeft: "10px"
                                        }},
                                        children: [theme.cancelButton({
                                            onclick: function () {
                                                resolve(null);
                                                ModalElement.close(3);
                                            }
                                        })]
                                    })
                                ]
                            })
                        ]
                    })
                });
            });
        };
        var variableForExpresstionInput = {};
        variableList.forEach(function(elt){
            variableForExpresstionInput[elt.value] = {text: elt.text};
        });
        examinationPluginVariable.forEach(function(elt){
            variableForExpresstionInput[elt.value] = {text: elt.text};
        });
        var shortExpressionInput = absol._({
            tag: 'ckinlineshorttext',
            props: {
                extensions: ['variable'],
                variables: variableForExpresstionInput
            },
            style: {
                minWidth: "400px"
            },
            on: {
                focus: function () {
                    // lastFocusHolder = this;
                    // bt.disabled = false;
                },
                change: function () {
                    absol.require('snackbar').show(this.data);
                },
                command: function (event) {
                    var ck = this;//ckplaceholder
                    switch (event.command) {
                        case 'insert_variable':
                            user_chose_variable(this.getSelectedVariable()).then(function (result) {
                                if (result) {
                                    ck.insertVariable(result);//expression
                                }
                            });
                            break;
                    }
                }
            }
        });
        shortExpressionInput.data = currentExpression || "";
        var table = DOMElement.table({
            data: [
                [
                    {text: "Thêm biểu thức"},
                    {
                        attrs: {style: {paddingLeft: "10px"}},
                        children: [switchBtn]
                    }
                ],
                [{attrs: {style: {paddingTop: "10px", display: is_expression ? "none" : null}, className: "hr-meeting-template-choose-variable"}}],
                [
                    {
                        attrs: {style: {display: is_expression ? "none" : null}, className: "hr-meeting-template-choose-variable"},
                        text: "Biến"},
                    {
                        attrs: {style: {paddingLeft: "10px", display: is_expression ? "none" : null}, className: "hr-meeting-template-choose-variable"},
                        children: [selectMenu]
                    }
                ],
                [{attrs: {style: {paddingTop: "10px", display: is_expression ? null : "none"}, className: "hr-meeting-template-write-expression"}}],
                [
                    {
                        attrs: {className: "hr-meeting-template-write-expression", style: {display: is_expression ? null : "none"}},
                        text: "Biểu thức"
                    },
                    {
                        attrs: {style: {paddingLeft: "10px", display: is_expression ? null : "none"}, className: "hr-meeting-template-write-expression"},
                        children: [shortExpressionInput]
                    }
                ]
            ]
        });
        ModalElement.showWindow({
            index: 2,
            title: "Chọn biến, biểu thức",
            bodycontent: DOMElement.div({
                style: {
                    padding: "10px"
                },
                children: [
                    DOMElement.div({
                        children: [table]
                    }),
                    DOMElement.div({
                        attrs: {
                            style: {
                                paddingTop: "20px",
                                textAlign: "center"
                            }
                        },
                        children: [
                            DOMElement.div({
                                attrs: {style: {
                                    display: "inline-block"
                                }},
                                children: [theme.okButton({
                                    onclick: function () {
                                        if (switchBtn.checked) {
                                            if (shortExpressionInput.data.trim().length == 0) {
                                                ModalElement.alert({message: "Chưa nhập biểu thức"});
                                            }
                                            else {
                                                resolve(shortExpressionInput.data.trim());
                                                ModalElement.close(2);
                                            }
                                        }
                                        else {
                                            resolve(selectMenu.value);
                                            ModalElement.close(2);
                                        }
                                    }
                                })]
                            }),
                            DOMElement.div({
                                attrs: {style: {
                                    display: "inline-block",
                                    paddingLeft: "10px"
                                }},
                                children: [theme.cancelButton({
                                    onclick: function () {
                                        resolve(null);
                                        ModalElement.close(2);
                                    }
                                })]
                            })
                        ]
                    })
                ]
            })
        });
    });
};

contentModule.makeEmployeePoliciesData = function(host){
    var k, t = [];
    host.database.employee_policies.items.forEach(function(item){
        k = host.database[item.type + "_policies"].getIndex(item.policyid);
        if (k < 0) return;
        item.description = host.database[item.type + "_policies"].items[k].description;
        if (item.type == "insurance"){
            item.calculated_on = host.database[item.type + "_policies"].items[k].calculated_on;
        }
        else if (item.type == "tax"){
            item.tax_type = host.database[item.type + "_policies"].items[k].tax_type;
        }
        else if(item.type == 'other_liability'){
            item.tax_relief = host.database[item.type + "_policies"].items[k].tax_relief;
            item.insurance_contribution_relief = host.database[item.type + "_policies"].items[k].insurance_contribution_relief;
            item.other_liability_type = host.database[item.type + "_policies"].items[k].other_liability_type;
            item.frequency = host.database[item.type + "_policies"].items[k].frequency;
        }
        t.push(item);
    });
    host.database.employee_policies.items = t;
};

contentModule.getDocumentPropertiesListPri = function(){
    return [
        {id: -87, name: "Văn bản nội bộ", parentid: -99, description: "", available: 1, extrainfo: [], ver: 1},
        {id: -88, name: "Văn bản đi", parentid: -99, description: "", available: 1, extrainfo: [], ver: 1},
        {id: -89, name: "Văn bản đến", parentid: -99, description: "", available: 1, extrainfo: [], ver: 1},
        {id: -97, name: LanguageModule.text("txt_storage"), parentid: 0, description: "", available: 1, extrainfo: [], ver: 1},
        {id: -98, name: LanguageModule.text("txt_document_category"), parentid: 0, description: "", available: 1, extrainfo: [], ver: 1},
        {id: -99, name: LanguageModule.text("txt_document_type"), parentid: 0, description: "", available: 1, extrainfo: [], ver: 1}
    ];
};

contentModule.makeDocument_propertiesSelectItems = function(host, id, listPropsPriv){
    var index = host.database.document_properties.getIndex(id);
    var items = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    var ni;
    for (var i = 0; i < host.database.document_properties.items[index].childIndexList.length; i++){
        ni = host.database.document_properties.items[index].childIndexList[i];
        if (!host.database.document_properties.items[ni].available) continue;
        if (listPropsPriv.indexOf(0) < 0 && listPropsPriv.indexOf(host.database.document_properties.items[ni].id) < 0) continue;
        items.push({
            value: host.database.document_properties.items[ni].id,
            text: host.database.document_properties.items[ni].name
        });
    }
    return items;
};

contentModule.makeDocument_propertiesSelectFilterItems = function(host, id){
    var index = host.database.document_properties.getIndex(id);
    var items = [];
    if (hr.isMobile){
        items.push({value: 0, text: LanguageModule.text("txt_all")});
    }
    else {
        items.push({value: 0, text: LanguageModule.text("txt_all") + " - " + host.database.document_properties.items[index].name});
    }
    var ni;
    for (var i = 0; i < host.database.document_properties.items[index].childIndexList.length; i++){
        ni = host.database.document_properties.items[index].childIndexList[i];
        if (!host.database.document_properties.items[ni].available) continue;
        items.push({
            value: host.database.document_properties.items[ni].id,
            text: host.database.document_properties.items[ni].name
        });
    }
    return items;
};

contentModule.makeDocumentsProperties = function(host){
    var documentDic = contentModule.makeDictionaryIndex(host.database.documents.items);
    for (var i = 0; i < host.database.documents.items.length; i++){
        host.database.documents.items[i].properties = {};
    }
    var k, item;
    for (var i = 0; i < host.database.document_properties_links.items.length; i++){
        item = host.database.document_properties_links.items[i];
        k = documentDic[item.documentid];
        if (k !== undefined){
            host.database.documents.items[k].properties[item.property_groupid] = item.propertyid;
        }
    }
};

contentModule.makeEmployeeGroupMemberIndex = function(host){
    for (var i = 0; i < host.database.employee_groups.items.length; i++){
        host.database.employee_groups.items[i].members = [];
    }
    var gDic = contentModule.makeDictionaryIndex(host.database.employee_groups.items);
    var k;
    for (var i = 0; i < host.database.employee_group_members.items.length; i++){
        k = gDic[host.database.employee_group_members.items[i].groupid];
        if (k >= 0) host.database.employee_groups.items[k].members.push(host.database.employee_group_members.items[i].employeeid);
    }
    host.groupOfMe = [];
    if (host.employeeOfMe.length == 0) return;
    host.database.employee_groups.items.forEach(function(item){
        if (item.members.indexOf(host.employeeOfMe[0]) >= 0){
            host.groupOfMe.push(item.id);
        }
    });
};

contentModule.makePrivilegeDocumentConfigs = function(host){
    host.listConfigPrivilegeOfMe = [];
    if (systemconfig.privSystem >= 2) return;
    if (host.employeeOfMe.length == 0) return;
    host.database.configs_document_privileges.items.forEach(function(item){
        if (item.content.employees.indexOf(0) >= 0 || item.content.employees.indexOf(host.employeeOfMe[0]) >= 0){
            host.listConfigPrivilegeOfMe.push(item);
        }
        else {
            if (item.content.employee_groups.indexOf(0) >= 0){
                if (host.groupOfMe.length > 0) host.listConfigPrivilegeOfMe.push(item);
            }
            else {
                for (var i = 0; i < item.content.employee_groups.length; i++){
                    if (host.groupOfMe.indexOf(item.content.employee_groups[i]) >= 0){
                        host.listConfigPrivilegeOfMe.push(item);
                        break;
                    }
                }
            }
        }
    });
    var getFolderList = function(folderList, fIndex){
        folderList.push(host.database.document_folders.items[fIndex].id);
        for (var i = 0; i < host.database.document_folders.items[fIndex].childIndexList.length; i++){
            getFolderList(folderList, host.database.document_folders.items[fIndex].childIndexList[i]);
        }
    };
    for (var i = 0; i < host.listConfigPrivilegeOfMe.length; i++){
        host.listConfigPrivilegeOfMe[i].folderList = [];
        if (host.listConfigPrivilegeOfMe[i].taskdetails == 1){
            host.listConfigPrivilegeOfMe[i].folderList.push(host.listConfigPrivilegeOfMe[i].taskid);
        }
        else {
            var fIndex = host.database.document_folders.getIndex(host.listConfigPrivilegeOfMe[i].taskid);
            if (fIndex >= 0) getFolderList(host.listConfigPrivilegeOfMe[i].folderList, fIndex);
        }
    }
};

contentModule.getPrivDocument = function(host, item, typePriv){
    for (var i = 0; i < host.listConfigPrivilegeOfMe.length; i++){
        if (host.listConfigPrivilegeOfMe[i].folderList.indexOf(item.folderid) < 0) continue;
        if (typePriv == "edit"){
            if (!host.listConfigPrivilegeOfMe[i].content.edit) continue;
        }
        else if (!host.listConfigPrivilegeOfMe[i].content.edit && !host.listConfigPrivilegeOfMe[i].content.view) continue;
        var propertiesPriv = host.listConfigPrivilegeOfMe[i].content.properties;
        var listAccept = [];
        host.listPropertiesRoot.forEach(function(propsItem){
            if (!item.properties[propsItem.id] || item.properties[propsItem.id] == 0){
                listAccept.push(true);
            }
            else {
                if (propertiesPriv[propsItem.id]){
                    if (propertiesPriv[propsItem.id].indexOf(0) >= 0){
                        listAccept.push(true);
                    }
                    else {
                        if (propertiesPriv[propsItem.id].indexOf(item.properties[propsItem.id]) >= 0){
                            listAccept.push(true);
                        }
                    }
                }
            }
        });
        if (listAccept.length == host.listPropertiesRoot.length){
            return true;
        }
    }
    return false;
};

contentModule.makeDocument_foldersSelectItems = function(host, folderList){
    function getFolderItem(index){
        var items = [];
        for (var i = 0; i < host.database.document_folders.items[index].childIndexList.length; i++){
            items.push(getFolderItem(host.database.document_folders.items[index].childIndexList[i]));
        }
        var res = {
            value: host.database.document_folders.items[index].id,
            text: host.database.document_folders.items[index].name,
            items: items
        };
        if (folderList.indexOf(0) < 0 && folderList.indexOf(host.database.document_folders.items[index].id) < 0) res.disabled = true;
        return res;
    };
    var list = [{
        value: 0,
        text: LanguageModule.text("txt_select_value")
    }];
    for (var i = 0; i < host.database.document_folders.items.length; i++){
        if (host.database.document_folders.items[i].parentid != 0) continue;
        list.push(getFolderItem(i));
    }
    return list;
};

contentModule.makePrivilegeOrgConfigs = function(host){
    host.listConfigPrivilegeOfMe = [];
    host.orgViewDic = {};
    host.orgEditDic = {};
    host.employeeViewDic = {};
    host.employeeEditDic = {};
    if (systemconfig.privSystem >= 2) {
        for (var i = 0; i < host.database.orgs.items.length; i++){
            host.orgViewDic[host.database.orgs.items[i].id] = true;
            host.orgEditDic[host.database.orgs.items[i].id] = true;
        }
        for (var i = 0; i < host.database.employees.items.length; i++){
            host.employeeViewDic[host.database.employees.items[i].id] = true;
            host.employeeEditDic[host.database.employees.items[i].id] = true;
        }
        return;
    };
    if (host.employeeOfMe.length == 0) return;
    host.database.configs_org_privileges.items.forEach(function(item){
        if (item.content.employees.indexOf(0) >= 0 || item.content.employees.indexOf(host.employeeOfMe[0]) >= 0){
            host.listConfigPrivilegeOfMe.push(item);
        }
        else {
            if (item.content.employee_groups.indexOf(0) >= 0){
                if (host.groupOfMe.length > 0) host.listConfigPrivilegeOfMe.push(item);
            }
            else {
                for (var i = 0; i < item.content.employee_groups.length; i++){
                    if (host.groupOfMe.indexOf(item.content.employee_groups[i]) >= 0){
                        host.listConfigPrivilegeOfMe.push(item);
                        break;
                    }
                }
            }
        }
    });
    var getDepartmentList = function(departmentList, dIndex){
        departmentList.push(host.database.orgs.items[dIndex].id);
        for (var i = 0; i < host.database.orgs.items[dIndex].childIndexList.length; i++){
            getDepartmentList(departmentList, host.database.orgs.items[dIndex].childIndexList[i]);
        }
    };
    for (var i = 0; i < host.listConfigPrivilegeOfMe.length; i++){
        host.listConfigPrivilegeOfMe[i].departmentList = [];
        if (host.listConfigPrivilegeOfMe[i].taskdetails == 1){
            host.listConfigPrivilegeOfMe[i].departmentList.push(host.listConfigPrivilegeOfMe[i].taskid);
        }
        else {
            var dIndex = host.database.orgs.getIndex(host.listConfigPrivilegeOfMe[i].taskid);
            if (dIndex >= 0) getDepartmentList(host.listConfigPrivilegeOfMe[i].departmentList, dIndex);
        }
    }
    var orgsDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var listAuthorityViewOrgEmp = [
        "view_employee_profiles",
        "edit_general_information_abilities_contact_communications",
        "edit_employment_contracts_salary_decisions_bank_accounts",
        "edit_hr_policies",
        "edit_organization_and_employee",
        "handle_onboarding",
        "handle_offboarding",
        "project_setting"
    ];
    var k, ex, ex2;
    for (var i = 0; i < host.listConfigPrivilegeOfMe.length; i++){
        ex2 = false;
        if (host.listConfigPrivilegeOfMe[i].content.edit_organization_and_employee) ex2 = true;
        ex = false;
        for (var j = 0; j < listAuthorityViewOrgEmp.length; j++){
            if (host.listConfigPrivilegeOfMe[i].content[listAuthorityViewOrgEmp[j]]){
                ex = true;
                break;
            }
        }
        if (!ex) continue;
        for (var j = 0; j < host.listConfigPrivilegeOfMe[i].departmentList.length; j++){
            host.orgViewDic[host.listConfigPrivilegeOfMe[i].departmentList[j]] = true;
            if (ex2) host.orgEditDic[host.listConfigPrivilegeOfMe[i].departmentList[j]] = true;
            k = orgsDic[host.listConfigPrivilegeOfMe[i].departmentList[j]];
            if (k >= 0){
                host.database.orgs.items[k].employeeIdList.forEach(function(eid){
                    host.employeeViewDic[eid] = true;
                    if (ex2) host.employeeEditDic[eid] = true;
                });
            }
        }
        k = orgsDic[host.listConfigPrivilegeOfMe[i].taskid];
        if (k >= 0){
            while (host.database.orgs.items[k].parentid > 0){
                host.orgViewDic[host.database.orgs.items[k].parentid] = true;
                k = orgsDic[host.database.orgs.items[k].parentid];
            }
        }
    }
    if (host.employeeOfMe.length > 0){
        host.employeeViewDic[host.employeeOfMe[0]] = true;
        var eIndex = host.database.employees.getIndex(host.employeeOfMe[0]);
        var pid = host.database.employees.items[eIndex].orgid;
        host.orgViewDic[pid] = true;
        var oIndex = host.database.orgs.getIndex(pid);
        while (host.database.orgs.items[oIndex].parentid > 0) {
            pid = host.database.orgs.items[oIndex].parentid;
            host.orgViewDic[pid] = true;
            oIndex = host.database.orgs.getIndex(pid);
        }
    }
};

contentModule.makeStorekeepersData = function(host){
    for (var i = 0; i < host.database.warehouses.items.length; i++){
        host.database.warehouses.items[i].storekeepers = [];
    }
    var warehousesDic = contentModule.makeDictionaryIndex(host.database.warehouses.items);
    var k;
    for (var i = 0; i < host.database.storekeepers.items.length; i++){
        k = warehousesDic[host.database.storekeepers.items[i].warehouseid];
        if (k >= 0){
            host.database.warehouses.items[k].storekeepers.push(host.database.storekeepers.items[i].employeeid);
        }
    }
};


contentModule.getNationsFilterList = function(host){
    var res = [{value: 0, text: LanguageModule.text("txt_all_nation")}];
    for (var i = 0; i < host.database.nations.items.length; i++){
        if (!host.database.nations.items[i].available) continue;
        res.push({
            value: host.database.nations.items[i].id,
            text: host.database.nations.items[i].fullname
        });
    }
    return res;
};

contentModule.getCitiesFilterList = function(host, nationid){
    var res = [{value: 0, text: LanguageModule.text("txt_all_city")}];
    var nIndex = host.database.nations.getIndex(nationid);
    if (nIndex >= 0){
        var ni;
        for (var i = 0; i < host.database.nations.items[nIndex].cityIndexList.length; i++){
            ni = host.database.nations.items[nIndex].cityIndexList[i];
            if (!host.database.cities.items[ni].available) continue;
            res.push({
                value: host.database.cities.items[ni].id,
                text: host.database.cities.items[ni].name
            });
        }
    }
    return res;
};

contentModule.getPartnerClassFilterList = function(host){
    var res = [{value: 0, text: LanguageModule.text("txt_all_partner_class")}];
    for (var i = 0; i < host.database.partner_class.items.length; i++){
        if (!host.database.partner_class.items[i].available) continue;
        res.push({
            value: host.database.partner_class.items[i].id,
            text: host.database.partner_class.items[i].name
        });
    }
    return res;
};

contentModule.makePartnerData = function(host){
    for (var i = 0; i < host.database.partner.items.length; i++){
        if ((host.database.partner.items[i].nationid != 0) && (host.database.partner.items[i].cityid != 0)){
            host.database.partner.items[i].nation_city = [host.database.partner.items[i].nationid, host.database.partner.items[i].cityid];
        }
        else {
            host.database.partner.items[i].nation_city = null;
        }
    }
};

contentModule.getPartnerFilterList = function(host){
    var res = [{value: 0, text: LanguageModule.text("txt_all_partner")}];
    for (var i = 0; i < host.database.partner.items.length; i++){
        if (!host.database.partner.items[i].available) continue;
        res.push({
            value: host.database.partner.items[i].id,
            text: host.database.partner.items[i].name.substr(0, 50),
            desc: host.database.partner.items[i].className + ", " + host.database.partner.items[i].fullname.substr(0, 50)
        });
    }
    return res;
};

contentModule.getEmployeeFilterList = function(host){
    function getOrgItem(index){
        var items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].childIndexList.length; i++){
            ni = host.database.orgs.items[index].childIndexList[i];
            if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[ni].id]) continue;
            items.push(getOrgItem(ni));
        }
        items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var e_items = [], ni;
        for (var i = 0; i < host.database.orgs.items[index].employeeIndexList.length; i++){
            ni = host.database.orgs.items[index].employeeIndexList[i];
            if (!host.database.employees.items[ni].available) continue;
            if (host.employeeViewDic && !host.employeeViewDic[host.database.employees.items[ni].id]) continue;
            e_items.push({
                value: host.database.employees.items[ni].id,
                text: host.database.employees.items[ni].fullname,
                code: host.database.employees.items[ni].code,
                isLeaf: true,
                icon: {tag:'span', class:['mdi', 'mdi-account']},
                sortText: absol.string.nonAccentVietnamese(host.database.employees.items[host.database.orgs.items[index].employeeIndexList[i]].fullname).toLowerCase()
            });
        }
        e_items.sort(function(a, b){
            if (a.sortText > b.sortText) return 1;
            if (a.sortText < b.sortText) return -1;
            return 0;
        });
        var res = {
            value: -host.database.orgs.items[index].id,
            text: host.database.orgs.items[index].name,
            icon: {tag:'span', class: (host.database.orgs.items[index].parentid == 0)? ['mdi', 'mdi-home-variant'] : ['mdi', 'mdi-folder-account']},
            items: e_items.concat(items),
            sortText: absol.string.nonAccentVietnamese(host.database.orgs.items[index].name).toLowerCase()
        };
        return res;
    };
    var items = [{value: 0, text: LanguageModule.text("txt_all_employee"), isLeaf: true}];
    for (var i = 0; i < host.database.orgs.items.length; i++){
        if (host.database.orgs.items[i].parentid != 0) continue;
        if (host.orgViewDic && !host.orgViewDic[host.database.orgs.items[i].id]) continue;
        items.push(getOrgItem(i));
    }
    items.sort(function(a, b){
        if (a.sortText > b.sortText) return 1;
        if (a.sortText < b.sortText) return -1;
        return 0;
    });
    return items;
};
contentModule.calcCrow = function(lat1, lon1, lat2, lon2){
    var toRad = function(value){
        return value * Math.PI / 180;
    };
    var R = 6371000;
    var dLat = toRad(lat2-lat1);
    var dLon = toRad(lon2-lon1);
    var lat1 = toRad(lat1);
    var lat2 = toRad(lat2);

    var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
    Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    var d = R * c;
    return d;
};

contentModule.makeParnerCheckinData = function(host){
    var partnerDic = contentModule.makeDictionaryIndex(host.database.partner.items);
    var k, t = [], k1;
    var check_in_lat, check_in_lng, partner_lat, partner_lng, x;
    var citiesDic = contentModule.makeDictionaryIndex(host.database.cities.items);
    for (var i = 0; i < host.database.partner_checkin.items.length; i++){
        k = partnerDic[host.database.partner_checkin.items[i].partnerid];
        if (k >= 0){
            host.database.partner_checkin.items[i].gps = host.database.partner.items[k].gps;
            host.database.partner_checkin.items[i].partner = host.database.partner.items[k].name;
            host.database.partner_checkin.items[i].address = host.database.partner.items[k].address;
            host.database.partner_checkin.items[i].cityid = host.database.partner.items[k].cityid;
            k1 = citiesDic[host.database.partner.items[k].cityid];
            if (k1 >= 0){
                host.database.partner_checkin.items[i].cityName = host.database.cities.items[k1].name;
            }
            else {
                host.database.partner_checkin.items[i].cityName = "";
            }
            x = host.database.partner_checkin.items[i].checkingps.indexOf(",");
            if (x > 0){
                check_in_lat = parseFloat(host.database.partner_checkin.items[i].checkingps.substr(0, x));
                check_in_lng = parseFloat(host.database.partner_checkin.items[i].checkingps.substr(x + 1));
            }
            else {
                check_in_lat = 0;
                check_in_lng = 0;
            }
            x = host.database.partner.items[k].gps.indexOf(",");
            if (x > 0){
                partner_lat = parseFloat(host.database.partner.items[k].gps.substr(0, x));
                partner_lng = parseFloat(host.database.partner.items[k].gps.substr(x + 1));
            }
            else {
                partner_lat = 0;
                partner_lng = 0;
            }
            if (check_in_lat && check_in_lng && partner_lat && partner_lng){
                host.database.partner_checkin.items[i].distance = absol.$.formatLocalFloat(Math.round(contentModule.calcCrow(check_in_lat, check_in_lng, partner_lat, partner_lng)));
            }
            else {
                host.database.partner_checkin.items[i].distance = "";
            }
            t.push(host.database.partner_checkin.items[i]);
        }
    }
    host.database.partner_checkin.items = t;
};

contentModule.getWork_flowGroupsFilterList  = function(host){
    var res = [{value: 0, text: LanguageModule.text("txt_all_work_flow_group")}];
    for (var i = 0; i < host.database.work_flow_groups.items.length; i++){
        if (!host.database.work_flow_groups.items[i].available) continue;
        res.push({
            value: host.database.work_flow_groups.items[i].id,
            text: host.database.work_flow_groups.items[i].name
        });
    }
    return res;
};

contentModule.getTypeListsListSelectMenu = function(host){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < host.database.typelists.items.length; i++){
        if (!host.database.typelists.items[i].available) continue;
        res.push({
            value: host.database.typelists.items[i].id,
            text: host.database.typelists.items[i].name
        });
    }
    return res;
};

contentModule.getInputFormsListSelectMenu = function(){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.input_forms.items.length; i++){
        if (!data_module.input_forms.items[i].available) continue;
        res.push({
            value: data_module.input_forms.items[i].id,
            text: data_module.input_forms.items[i].name
        });
    }
    return res;
};

contentModule.getMobileInputFormsListSelectMenu = function(){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.mobile_input_forms.items.length; i++){
        if (!data_module.mobile_input_forms.items[i].available) continue;
        res.push({
            value: data_module.mobile_input_forms.items[i].id,
            text: data_module.mobile_input_forms.items[i].name
        });
    }
    return res;
};

contentModule.getOutputFormsListSelectMenu = function(){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.output_forms.items.length; i++){
        if (!data_module.output_forms.items[i].available) continue;
        res.push({
            value: data_module.output_forms.items[i].id,
            text: data_module.output_forms.items[i].name
        });
    }
    return res;
};

contentModule.getMobileOutputFormsListSelectMenu = function(){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.mobile_output_forms.items.length; i++){
        if (!data_module.mobile_output_forms.items[i].available) continue;
        res.push({
            value: data_module.mobile_output_forms.items[i].id,
            text: data_module.mobile_output_forms.items[i].name
        });
    }
    return res;
};

contentModule.getObjectPeriodSystemList = function(){
    return [
        {id: -1, name: LanguageModule.text("txt_success"), color: "rgb(146,211,110)", isSystem: true},
        {id: -2, name: LanguageModule.text("txt_failed"), color: "rgb(230,22,16)", isSystem: true},
        {id: -3, name: "Hủy thực hiện", color: "rgb(230,146,248)", isSystem: true}
    ]
};

contentModule.getInputFormsOfTypeId = function(host, typeid){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.input_forms.items.length; i++){
        if (!data_module.input_forms.items[i].available) continue;
        if (data_module.input_forms.items[i].typeid != typeid) continue;
        res.push({
            value: data_module.input_forms.items[i].id,
            text: data_module.input_forms.items[i].name
        });
    }
    return res;
};

contentModule.getOutputFormsOfTypeId = function(host, typeid){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.output_forms.items.length; i++){
        if (!data_module.output_forms.items[i].available) continue;
        if (data_module.output_forms.items[i].typeid != typeid) continue;
        res.push({
            value: data_module.output_forms.items[i].id,
            text: data_module.output_forms.items[i].name
        });
    }
    return res;
};

contentModule.getMobileInputFormsOfTypeId = function(host, typeid){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.mobile_input_forms.items.length; i++){
        if (!data_module.mobile_input_forms.items[i].available) continue;
        if (data_module.mobile_input_forms.items[i].typeid != typeid) continue;
        res.push({
            value: data_module.mobile_input_forms.items[i].id,
            text: data_module.mobile_input_forms.items[i].name
        });
    }
    return res;
};

contentModule.getMobileOutputFormsOfTypeId = function(host, typeid){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    for (var i = 0; i < data_module.mobile_output_forms.items.length; i++){
        if (!data_module.mobile_output_forms.items[i].available) continue;
        if (data_module.mobile_output_forms.items[i].typeid != typeid) continue;
        res.push({
            value: data_module.mobile_output_forms.items[i].id,
            text: data_module.mobile_output_forms.items[i].name
        });
    }
    return res;
};

contentModule.getPeriodsListByWorkFlowId = function(host, work_flowid, form){
    var periodsList = [];
    if (form == "output"){
        periodsList.push({value: 0, text: ""});
    }
    else {
        periodsList.push({value: 0, text: LanguageModule.text("txt_select_value")});
    }
    for (var i = 0; i < host.database.work_flow_periods.items.length; i++){
        periodsList.push({
            value: host.database.work_flow_periods.items[i].id,
            text: host.database.work_flow_periods.items[i].name
        });
    }
    var x = contentModule.getObjectPeriodSystemList();
    for (var i = 0; i < x.length; i++){
        periodsList.push({
            value: x[i].id,
            text: x[i].name
        });
    }
    return periodsList;
};

contentModule.makeOrgEmpDicPrivilegesWorkFlow = function(host, listOrgPriv){
    host.employeeEditDic = {};
    host.orgViewDic = {};
    host.orgEditDic = {};
    var orgsDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var employeesDic = contentModule.makeDictionaryIndex(host.database.employees.items);
    var getDepartmentList = function(departmentList, dIndex){
        departmentList.push(host.database.orgs.items[dIndex].id);
        for (var i = 0; i < host.database.orgs.items[dIndex].childIndexList.length; i++){
            getDepartmentList(departmentList, host.database.orgs.items[dIndex].childIndexList[i]);
        }
    };
    var k, departmentList, orgid, oIndex;
    for (var i = 0; i < listOrgPriv.length; i++){
        if (listOrgPriv[i] > 0){
            k = orgsDic[listOrgPriv[i]];
            if (k === undefined) continue;
            departmentList = [];
            getDepartmentList(departmentList, k);
            for (var j = 0; j < departmentList.length; j++){
                host.orgEditDic[departmentList[j]] = true;
                host.orgViewDic[departmentList[j]] = true;
                oIndex = orgsDic[departmentList[j]];
                if (oIndex >= 0){
                    host.database.orgs.items[oIndex].employeeIdList.forEach(function(eid){
                        host.employeeEditDic[eid] = true;
                    });
                }
            }
            orgid = listOrgPriv[i];
        }
        else {
            host.employeeEditDic[-listOrgPriv[i]] = true;
            k = employeesDic[-listOrgPriv[i]];
            if (k === undefined) continue;
            orgid = host.database.employees.items[k].orgid;
        }
        host.orgViewDic[orgid] = true;
        k = host.database.orgs.getIndex(orgid);
        while (host.database.orgs.items[k].parentid > 0) {
            orgid = host.database.orgs.items[k].parentid;
            host.orgViewDic[orgid] = true;
            k = host.database.orgs.getIndex(orgid);
        }
    }
};

contentModule.activitiesInformation = function(params){
    var host = {
        database: {}
    };
    return new Promise(function(rs, rj){
        FormClass.api_call({
            url: "database_load.php",
            params: [
                {name: "task", value: "activities_load"},
                {name: "workSelected", value: params.workSelected},
                {name: "tableName", value: params.tableName},
                {name: "instanceid", value: params.instanceid}
            ],
            func: function(success, message){
                if (success) {
                    if (message.substr(0, 2) == "ok") {
                        var content = EncodingClass.string.toVariable(message.substr(2));
                        host.employeeOfMe = content.employeeOfMe;
                        var meeting_link_dict = {};
                        content.meeting_links.forEach(function(elt){
                            meeting_link_dict[elt.meetingid] = elt;
                        });
                        host.chartContent = {
                            count: 0,
                            success: 0,
                            unsuccess: 0,
                            pending: 0
                        };

                        var task_link_dict = {};
                        content.task_links.forEach(function(elt){
                            task_link_dict[elt.taskid] = elt;
                        });
                        content.activities = [];
                        content.meetings.forEach(function(elt){
                            if (elt.participant.indexOf("_") != -1) {
                                var participantStr = elt.participant.split("_");
                                var participant = [];
                                for (var i = 0; i < participantStr.length; i++) {
                                    if (participantStr[i] == "") continue;
                                    participant.push(parseInt(participantStr[i], 10));
                                }
                                elt.participant = participant;
                            }
                            else if (elt.participant == "") elt.participant = [];
                            else elt.participant = EncodingClass.string.toVariable(elt.participant);
                            if (meeting_link_dict[elt.id]){
                                elt.tablename = meeting_link_dict[elt.id].tablename;
                                elt.instanceid = meeting_link_dict[elt.id].instanceid;
                            }
                            elt.meetingid = elt.id;
                            elt.id = "meeting_" + elt.id;
                            elt.activityType = "type_meeting";
                            content.activities.push(elt);
                        });
                        content.tasks.forEach(function(elt){
                            if (elt.participant.indexOf("_") != -1) {
                                var participantStr = elt.participant.split("_");
                                var participant = [];
                                for (var i = 0; i < participantStr.length; i++) {
                                    if (participantStr[i] == "") continue;
                                    participant.push(parseInt(participantStr[i], 10));
                                }
                                elt.participant = participant;
                            }
                            else if (elt.participant == "") elt.participant = [];
                            else elt.participant = EncodingClass.string.toVariable(elt.participant);
                            if (task_link_dict[elt.id]) {
                                elt.tablename = task_link_dict[elt.id].tablename;
                                elt.instanceid = task_link_dict[elt.id].instanceid;
                            }
                            elt.taskid = elt.id;
                            elt.id = "task_" + elt.id;
                            elt.activityType = "type_task";
                            content.activities.push(elt);
                        });
                        contentModule.makeDatabaseContent(host, content);
                        host.user_column_configsDic = contentModule.getUser_column_configsDic(host);
                        if (!params.employeeid) params.employeeid = content.employeeOfMe[0];
                        host.form_config = contentModule.configVariable(host);
                        contentModule.makeOrgsIndex(host);
                        contentModule.makeEmployeeData(host);
                        contentModule.makeEmployeesIndex(host);
                        contentModule.makeEmployeeGroupMemberIndex(host);
                        contentModule.makePrivilegesActivitiesConfigs(host);
                        host.task_user_column_configsDic = contentModule.getUser_column_configsDic({database: {user_column_configs: host.database.task_user_column_configs}});
                        host.meeting_user_column_configsDic = contentModule.getUser_column_configsDic({database: {user_column_configs: host.database.meeting_user_column_configs}});
                        params.host = host;
                        params.chartContainer = absol._({});
                        params.meeting = absol._({});
                        params.task = absol._({});
                        params.activities = absol._({});
                        params.addTaskByTemplate = function(){
                            hr.onboarding.addTaskByTemplate(host, params.instanceid, params);
                        };
                        params.addMeetingByTemplate = function(){
                            hr.onboarding.addMeetingByTemplate(host, params.instanceid, params);
                        };

                        params.chartContainer.addChild(hr.onboarding.drawEmployeeInformationChart(host, params));

                        if (params.workSelected == "meeting" || params.workSelected == "both") hr.onboarding.drawMeetingInformation(host, params.instanceid, params);
                        if (params.workSelected == "task" || params.workSelected == "both") hr.onboarding.drawTaskInformation(host, params.instanceid, params);
                        hr.onboarding.drawActivitiesInformation(host, params.instanceid, params);
                        var retval = {
                            chart: params.chart,
                            meeting: params.meeting,
                            task: params.task,
                            activities: params.activities,
                            getMeetingContent: function(){
                                return params.meeting;
                            },
                            getTaskContent: function(){
                                return params.activities;
                            },
                            getActivitiesContent: function(){
                                return params.activities;
                            },
                            getChartContent: function(){
                                return params.chartContainer;
                            }
                        };
                        rs(retval);
                    }
                    else {
                        console.log(message);
                        rj(message)
                    }
                }
                else {
                    console.log(message);
                    rj(message)
                }
            }
        })
    });
};

contentModule.makePartnerClassLinksData = function(host){
    var partnerDic = contentModule.makeDictionaryIndex(host.database.partner.items);
    for (var i = 0; i < host.database.partner.items.length; i++){
        host.database.partner.items[i].class = [];
    }
    var k;
    for (var i = 0; i < host.database.partner_class_links.items.length; i++){
        k = partnerDic[host.database.partner_class_links.items[i].partnerid];
        if (k >= 0 && host.database.partner_class_links.items[i].classid > 0){
            host.database.partner.items[k].class.push(host.database.partner_class_links.items[i].classid);
        }
    }
};

contentModule.makePartnerClassLinksDataText = function(host){
    var classDic = contentModule.makeDictionaryIndex(host.database.partner_class.items);
    var ni, cIndex;
    for (var i = 0; i < host.database.partner.items.length; i++){
        host.database.partner.items[i].className = "";
        for (var j = 0; j < host.database.partner.items[i].class.length; j++){
            ni = host.database.partner.items[i].class[j];
            cIndex = classDic[ni];
            if (cIndex >= 0){
                host.database.partner.items[i].className += ", " + host.database.partner_class.items[cIndex].name;
            }
        }
        if (host.database.partner.items[i].class.length > 0){
            host.database.partner.items[i].className = host.database.partner.items[i].className.substr(2);
        }
    }
};

contentModule.loadWorkFlowObjectPrivView = function(){
    return new Promise(function(resolve, reject){
        var host = {database: {}};
        FormClass.api_call({
            url: "database_load.php",
            params: [{name: "task", value: "load_work_flow_object_priv"}],
            func: function(success, message){
                if (success){
                    if (message.substr(0, 2) == "ok"){
                        var st = EncodingClass.string.toVariable(message.substr(2));
                        host.employeeOfMe = st.employeeOfMe;
                        delete st.employeeOfMe;
                        contentModule.makeDatabaseContent(host, st);
                        contentModule.makeOrgsIndex(host);
                        contentModule.makeEmployeeData(host);
                        contentModule.makeEmployeesIndex(host);
                        var orgDict = {};
                        var root;
                        host.database.orgs.items.forEach((item, i) => {
                            orgDict[item.id] = i;
                            if (item.parentid == 0) root = item.id;
                        });
                        var createAllEmployeeInOrg = function(orgid){
                            var index = orgDict[orgid];
                            host.database.orgs.items[index].allEmployeeIdList = host.database.orgs.items[index].employeeIdList;
                            host.database.orgs.items[index].childIndexList.forEach((item, i) => {
                                createAllEmployeeInOrg(host.database.orgs.items[item].id);
                                host.database.orgs.items[index].allEmployeeIdList = host.database.orgs.items[index].allEmployeeIdList.concat(
                                    host.database.orgs.items[item].allEmployeeIdList
                                );
                            });
                        };
                        createAllEmployeeInOrg(root);
                        var work_flowsViewList = contentModule.stageReportMakePrivilegeViewWorkFlow(host);
                        var objectsList = contentModule.stageReportMakePrivilegeObjects(host);
                        var work_flow_admin_privileges_dict = {};
                        var editAllObject = [];
                        st.work_flow_admin_privileges.forEach(function(elt){
                            if (!work_flow_admin_privileges_dict[elt.work_flowid]) work_flow_admin_privileges_dict[elt.work_flowid] = [];
                            work_flow_admin_privileges_dict[elt.work_flowid].push(elt.employeeid);
                            if (elt.employeeid == host.employeeOfMe[0]) editAllObject.push(elt.work_flowid);
                        });
                        resolve({
                            work_flowsViewList: work_flowsViewList,
                            objectsViewList: objectsList.viewList,
                            objectsEditList: objectsList.editList,
                            objPermission: objectsList.objPermission,
                            editAllObject: editAllObject,
                            work_flow_admin_privileges_dict: work_flow_admin_privileges_dict
                        });
                    }
                    else {
                        ModalElement.alert({message: message});
                    }
                }
                else {
                    ModalElement.alert({message: message});
                }
            }
        });
    });
};

contentModule.stageReportMakePrivilegeViewWorkFlow = function(host){
    if (host.employeeOfMe.length == 0) return [];
    contentModule.makeOrgsIndex(host);
    contentModule.makeEmployeeData(host);
    contentModule.makeEmployeesIndex(host);
    var orgsDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    var empOrgMeDic = {};
    empOrgMeDic[host.employeeOfMe[0]];
    var eIndex = host.database.employees.getIndex(host.employeeOfMe[0]);
    var orgid = host.database.employees.items[eIndex].orgid;
    while (orgid > 0) {
        empOrgMeDic[orgid] = true;
        var oIndex = orgsDic[orgid];
        if (oIndex >= 0){
            orgid = host.database.orgs.items[oIndex].parentid;
        }
        else {
            break;
        }
    }
    var list = [];
    for (var i = 0; i < host.database.work_flow_members.items.length; i++){
        if (empOrgMeDic[host.database.work_flow_members.items[i].orgid]){
            list.push(host.database.work_flow_members.items[i].work_flowid);
        }
    }
    return list;
};

contentModule.stageReportMakePrivilegeObjects = function(host){
    if (host.employeeOfMe.length == 0) return {editList: [], viewList: []};
    var orgsDic = contentModule.makeDictionaryIndex(host.database.orgs.items);
    host.empOrgMeDic = {};
    host.empOrgMeDic[host.employeeOfMe[0]];
    var eIndex = host.database.employees.getIndex(host.employeeOfMe[0]);
    var orgid = host.database.employees.items[eIndex].orgid;
    while (orgid > 0) {
        host.empOrgMeDic[orgid] = true;
        var oIndex = orgsDic[orgid];
        if (oIndex >= 0){
            orgid = host.database.orgs.items[oIndex].parentid;
        }
        else {
            break;
        }
    }
    var viewList = [];
    var editList = [];
    var dict = {};
    for (var i = 0; i < host.database.object_permissions.items.length; i++){
        if (host.database.object_permissions.items[i].orgid > 0) {
            if (host.empOrgMeDic[host.database.object_permissions.items[i].orgid]){
                viewList.push(host.database.object_permissions.items[i].objectid);
                if (host.database.object_permissions.items[i].priv == "edit"){
                    editList.push(host.database.object_permissions.items[i].objectid);
                }
            }
        }
        else {
            if (-host.database.object_permissions.items[i].orgid == host.employeeOfMe[0]){
                viewList.push(host.database.object_permissions.items[i].objectid);
                if (host.database.object_permissions.items[i].priv == "edit"){
                    editList.push(host.database.object_permissions.items[i].objectid);
                }
            }
        }
        if (!dict[host.database.object_permissions.items[i].objectid]) dict[host.database.object_permissions.items[i].objectid] = {
            edit: [],
            view: []
        };
        if (host.database.object_permissions.items[i].orgid < 0) {
            dict[host.database.object_permissions.items[i].objectid][host.database.object_permissions.items[i].priv].push(-host.database.object_permissions.items[i].orgid);
        }
        else {
            dict[host.database.object_permissions.items[i].objectid][host.database.object_permissions.items[i].priv] = dict[host.database.object_permissions.items[i].objectid][host.database.object_permissions.items[i].priv].concat(
                host.database.orgs.items[orgsDic[host.database.object_permissions.items[i].orgid]].allEmployeeIdList
            )
        }
    }
    return {
        viewList: viewList,
        editList: editList,
        objPermission: dict
    };
};

contentModule.reportTimeModule = function(params){
    var timeClass = params.class;
    var timeItems = [
        {value: 1, text: LanguageModule.text("txt_yesterday")},
        {value: 2, text: LanguageModule.text("txt_today")},
        {value: 3, text: LanguageModule.text("txt_last_week")},
        {value: 4, text: LanguageModule.text("txt_this_week")},
        {value: 5, text: LanguageModule.text("txt_last_7_days")},
        {value: 13, text: LanguageModule.text("txt_7_days_before_after")},
        {value: 15, text: LanguageModule.text("txt_30_days_before_after")},
        {value: 6, text: LanguageModule.text("txt_last_month")},
        {value: 7, text: LanguageModule.text("txt_this_month")},
        {value: 8, text: LanguageModule.text("txt_last_30_days")},
        {value: 9, text: LanguageModule.text("txt_last_quarter")},
        {value: 10, text: LanguageModule.text("txt_this_quarter")},
        {value: 11, text: LanguageModule.text("txt_last_90_days")},
        {value: 12, text: LanguageModule.text("txt_last_year")},
        {value: 14, text: LanguageModule.text("txt_this_year")},
        {value: 0, text: LanguageModule.text("txt_option")}
    ];
    var props;
    if (params.props) {
        props = params.props;
    }
    else {
        props = {};
    }
    props.items = timeItems;
    props.value = params.value.relativeTime ? params.value.relativeTime: 0;
    var displayFunc = function(value){
        if (value == 0) {
            absol.$("." + timeClass, params.container, function(elt){
                elt.style.display = null;
            });
        }
        else {
            absol.$("." + timeClass, params.container, function(elt){
                elt.style.display = "none";
            });
        }
    };
    var cbb = absol._({
        tag: "selectmenu",
        props: {
            items: timeItems,
            value: params.value.relativeTime ? params.value.relativeTime: 0
        },
        on: {
            change: function(){
                displayFunc(cbb.value);
                start.disabled = cbb.value != 0;
                end.disabled = cbb.value != 0;
                if (params.change) params.change();
            }
        }
    });

    var start = absol._({
        tag: 'dateinput',
        props: {
            value: params.value.start,
            disabled: cbb.value != 0
        },
        on: {
            change: function(){
                if (params.change) params.change();
            }
        }
    });

    var end = absol._({
        tag: 'dateinput',
        props: {
            value: params.value.end,
            disabled: cbb.value != 0
        },
        on: {
            change: function(){
                if (params.change) params.change();
            }
        }
    });

    var retval = {
        timeElt: cbb,
        startElt: start,
        endElt: end,
        getValue: function(){
            var timeValue, startValue, endValue;
            timeValue = cbb.value;
            startValue = start.value;
            endValue = end.value;
            var rs = contentModule.generateRelativeTime({value: timeValue, from: startValue, to: endValue});
            return {
                originValue: {
                    relativeTime: timeValue,
                    start: startValue,
                    end: endValue
                },
                specificValue: {
                    start: rs.start,
                    end: rs.end
                }
            };
        }
    };

    return retval;

};

contentModule.getMillisecondsWithoutTime = function(date){
    var y, m, d, t;
    y = date.getFullYear();
    m = date.getMonth();
    d = date.getDate();
    t = new Date(y, m, d);
    return t.getTime();
};

contentModule.getMillisecondsWithoutSecond = function(date){
    var y, m, d, h, mt, t;
    y = date.getFullYear();
    m = date.getMonth();
    d = date.getDate();
    h = date.getHours();
    mt = date.getMinutes();
    t = new Date(y, m, d, h, mt);
    return t.getTime();
};

contentModule.getTime = function(date){
    var start, end;
    start = contentModule.getMillisecondsWithoutTime(date);
    date.setDate(date.getDate() + 1);
    end = contentModule.getMillisecondsWithoutTime(date);
    return {
        start: start,
        end: end
    };
};

contentModule.getWeekTime = function(firstDayOfWeek){
    var start, end;
    start = contentModule.getMillisecondsWithoutTime(firstDayOfWeek);
    firstDayOfWeek.setDate(firstDayOfWeek.getDate() + 7);
    end = contentModule.getMillisecondsWithoutTime(firstDayOfWeek);
    return {
        start: start,
        end: end
    };
};

contentModule.getMonthTime = function(firstDayOfMonth){
    var start, end;
    start = contentModule.getMillisecondsWithoutTime(firstDayOfMonth);
    firstDayOfMonth.setMonth(firstDayOfMonth.getMonth() + 1);
    end = contentModule.getMillisecondsWithoutTime(firstDayOfMonth);
    return {
        start: start,
        end: end
    };
};

contentModule.getQuaterTime = function(firstDayOfQuater){
    var start, end;
    start = contentModule.getMillisecondsWithoutTime(firstDayOfQuater);
    firstDayOfQuater.setMonth(firstDayOfQuater.getMonth() + 3);
    end = contentModule.getMillisecondsWithoutTime(firstDayOfQuater);
    return {
        start: start,
        end: end
    };
};

contentModule.getYearTime = function(firstDayOfYear){
    var start, end;
    start = contentModule.getMillisecondsWithoutTime(firstDayOfYear);
    firstDayOfYear.setFullYear(firstDayOfYear.getFullYear() + 1);
    end = contentModule.getMillisecondsWithoutTime(firstDayOfYear);
    return {
        start: start,
        end: end
    };
};

contentModule.getLastXDayTime = function(firstDay){
    var start, end;
    start = contentModule.getMillisecondsWithoutTime(firstDay);
    end = contentModule.getMillisecondsWithoutTime(new Date());
    return {
        start: start,
        end: end
    };
};

contentModule.generateRelativeTime = function(condition){
    /*
    condition: {
        value:
        from:
        to:
    }
    */
    // giá trị trả về là miliseconds
    var time, temp;
    var date = new Date();
    switch (condition.value) {
        case 0:
            if (condition.from && condition.to) {
                var from = contentModule.getMillisecondsWithoutTime(condition.from);
                from = new Date(from);
                var to = contentModule.getMillisecondsWithoutTime(condition.to);
                to = new Date(to);
                to.setDate(to.getDate() + 1);
                time = {
                    start: from.getTime(),
                    end: to.getTime()
                };
            }
            else {
                time = {
                    start: 0,
                    end: 0
                };
            }
            break;
        case 1:
            date.setDate(date.getDate() - 1);
            time = contentModule.getTime(date);
            break;
        case 2:
            time = contentModule.getTime(date);
            break;
        case 3:
            temp = date.getDay() - 1;
            date.setDate(date.getDate() - temp - 7);
            time = contentModule.getWeekTime(date);
            break;
        case 4:
            temp = date.getDay() - 1;
            date.setDate(date.getDate() - temp);
            time = contentModule.getWeekTime(date);
            break;
        case 5:
            date.setDate(date.getDate() - 7);
            time = contentModule.getLastXDayTime(date);
            break;
        case 6:
            date.setMonth(date.getMonth() - 1);
            date.setDate(1);
            time = contentModule.getMonthTime(date);
            break;
        case 7:
            date.setDate(1);
            time = contentModule.getMonthTime(date);
            break;
        case 8:
            date.setDate(date.getDate() - 30);
            time = contentModule.getLastXDayTime(date);
            break;
        case 9:
            temp = Math.floor(date.getMonth() / 3) * 3;
            date.setMonth(temp - 3);
            date.setDate(1);
            time = contentModule.getQuaterTime(date);
            break;
        case 10:
            temp = Math.floor(date.getMonth() / 3) * 3;
            date.setMonth(temp);
            date.setDate(1);
            time = contentModule.getQuaterTime(date);
            break;
        case 11:
            date.setDate(date.getDate() - 90);
            time = contentModule.getLastXDayTime(date);
            break;
        case 12:
            date.setDate(1);
            date.setMonth(0);
            date.setFullYear(date.getFullYear() - 1);
            time = contentModule.getYearTime(date);
            break;
        case 13:
            date.setDate(date.getDate() - 6);
            time = {
                start: contentModule.getTime(date).start
            };
            date.setDate(date.getDate() + 12);
            time.end = contentModule.getTime(date).end;
            break;
        case 15:
            date.setDate(date.getDate() - 29);
            time = {
                start: contentModule.getTime(date).start
            };
            date.setDate(date.getDate() + 58);
            time.end = contentModule.getTime(date).end;
            break;
        case 14:
            time = {
                end: contentModule.getTime(date).end
            }
            date.setDate(1);
            date.setMonth(0);
            time.start = contentModule.getYearTime(date).start;
            break;
    }
    return time;
};

contentModule.makeTableRow = function(content, value){
    var res;
    switch (content.type) {
        case "string":
        case "email_address":
        case "gps":
        case "website":
        case "phonenumber":
            res = DOMElement.td({
                attrs: {
                    style: {whiteSpace: "nowrap"},
                }
            })
            res = {
                style: {whiteSpace: "nowrap"},
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view"
                    },
                    text: value
                })
            };
            break;
        case "note":
            var valueText = value? value.substr(0, 200) : "";
            res = {
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view hr-table-desc-ctn"
                    },
                    text: value
                })
            };
            break;
        case "number":
            res = {
                style: {
                    textAlign: "right"
                },
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: value
                })
            };
            break;
        case "currency":
            res = {
                style: {
                    textAlign: "right"
                },
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value === "")? "" : absol.$.formatLocalFloat(value)
                })
            };
            break;
        case "date":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getDateView(value) : ""
                })
            };
            break;
        case "datetime":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getDateTimeView(value) : ""
                })
            };
            break;
        case "time":
            res = {
                style: {
                    textAlign: "center"
                },
                value: (value)? value.getTime() : 0,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                    },
                    text: (value && value.getTime() > 0)? contentModule.getTimeView(value) : ""
                })
            };
            break;
        case "boolean":
            res = {
                value: value,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                        align: "center"
                    },
                    children: [absol.buildDom({
                        tag: "switch",
                        style: {
                            font: "var(--switch-fontsize)"
                        },
                        props: {
                            checked: value,
                            disabled: true
                        }
                    })]
                })
            };
            break;
        case "hour_period":
            var text = "";
            if (value && value.dayOffset) text = contentModule.getHourView(value.dayOffset) + " - " + contentModule.getHourView(value.dayOffset + value.duration);
            res = {
                style: {whiteSpace: "nowrap"},
                value: text,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view",
                        align: "center"
                    },
                    text: text
                })
            };
            break;
        case "html":
            var xt = DOMElement.div({
                innerHTML: value? value: ""
            });
            var valueText = xt.innerText.substr(0, 200);
            res = {
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view hr-table-desc-ctn"
                    },
                    text: valueText
                })
            };
            break;
        case "nation_city":
            var text = "";
            if (value){
                var item = content.listItemsDic.getItemByValue(value[0]);
                if (item) text = item.text;
                var ld = new absol.ListDictionary(item.itemsDic);
                item = ld.getItemByValue(value[1]);
                if (item) text += " - " +  item.text;
            }
            res = {
                style: {whiteSpace: "nowrap"},
                value: text,
                element: DOMElement.div({
                    attrs: {
                        className: "sortTable-cell-view"
                    },
                    text: text
                })
            };
            break;
        default:
            if (contentModule.listTypeSelectmenu.indexOf(content.type) >= 0 || content.type == "enum" || content.type == "extends_enum"){
                var item = content.listItemsDic.getItemByValue(value);
                var text;
                if (!item) text = "";
                else text = item.text;
                res = {
                    value: text,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: text
                    })
                };
            }
            else if (contentModule.listTypeSelectbox.indexOf(content.type) >= 0) {
                var text = "";
                var item;
                if (value){
                    for (var i = 0; i < value.length; i++){
                        item = content.listItemsDic.getItemByValue(value[i]);
                        if (item) text += ", " + item.text
                    }
                    text = text.substr(2);
                }
                res = {
                    value: text,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: text
                    })
                };
            }
            else if (content.type == "purpose"){
                var text = "";
                if (value){
                    text = content.itemsDic[value.tablename].name;
                    if (content.itemsDic[value.tablename].listItems){
                        var item = content.itemsDic[value.tablename].listItemsDic.getItemByValue(value.instanceid);
                        if (item) text += ": " + item.text;
                        else text += ":";
                    }
                }
                res = {
                    value: text,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: text
                    })
                };
            }
            else {
                res = {
                    value: value,
                    element: DOMElement.div({
                        attrs: {
                            className: "sortTable-cell-view"
                        },
                        text: value
                    })
                };
            }

    }
    return res;
};

contentModule.fixObjectExtraDataTPN = function(){

    data_module.loadObjectsList().then(function(temp1){
        var length = temp1.length;
        var count = 0;
        temp1.forEach(function(elt){
            var pattern = {
                type: "struct",
                cond: "and",
                children: {
                    objectid: {
                        type: "number",
                        cond: "eq",
                        value: parseInt(elt.id, 10)
                    },
                    extraid: {
                        type: "number",
                        cond: "true"
                    }
                }
            };

            fconnector.search("extradata_objects_links", pattern, function(value1) {
                if (value1 && value1.length > 0){
                    fconnector.read("extradata_objects_links", value1[0], function (success2, value2){
                        if (success2){
                            fconnector.read("extradata_objects", value2.extraid, function (success3, value3){
                                var isChanged = false;
                                if (success3){
                                    if (value3["type_3_1653099260843"]){
                                        if (value3["type_3_1653099260843"][6]) {
                                            if (value3["type_3_1653099260843"][6].constructor === Array) value3["type_3_1653099260843"] = value3["type_3_1653099260843"][6];
                                            else value3["type_3_1653099260843"] = [value3["type_3_1653099260843"][6]];
                                            isChanged = true;
                                        }
                                    }
                                    else {
                                        isChanged = true;
                                        value3["type_3_1653099260843"] = [];
                                    }
                                    if (!value3["type_3_1653097703606"]) {
                                        isChanged = true;
                                        value3["type_3_1653097703606"] = "";
                                    }
                                    if (!value3["type_3_1653097707826"]) {
                                        isChanged = true;
                                        value3["type_3_1653097707826"] = "";
                                    }
                                    if (!value3["type_3_1653097725528"]) {
                                        isChanged = true;
                                        value3["type_3_1653097725528"] = [];
                                    }
                                    if (!value3["type_3_1653099033232"]) {
                                        isChanged = true;
                                        value3["type_3_1653099033232"] = [];
                                    }
                                    if (!value3["type_3_1653099200511"]) {
                                        isChanged = true;
                                        value3["type_3_1653099200511"] = 0;
                                    }
                                    if (!value3["type_3_1653099230071"]) {
                                        isChanged = true;
                                        value3["type_3_1653099230071"] = false;
                                    }
                                    if (isChanged) {
                                        FormClass.api_call({
                                            url: "fix_extra_data_save.php",
                                            params: [
                                                {name: "task", value: "object"},
                                                {name: "data", value: EncodingClass.string.fromVariable({
                                                    id: value2.extraid,
                                                    data: value3
                                                })}
                                            ],
                                            func: function(success, message) {
                                                if (success) {
                                                    if (message.substr(0, 2) == "ok") {
                                                        console.log("ok", ++count + "/" + length);
                                                    }
                                                    else {
                                                        console.log(message, ++count + "/" + length);
                                                    }
                                                }
                                                else {
                                                    console.log(message, ++count + "/" + length);
                                                }
                                            }
                                        })
                                    }
                                    else {
                                        console.log(++count + "/" + length);
                                        // rs(null);
                                    }
                                }
                                else {
                                    console.log(++count + "/" + length);
                                    // rs(null);
                                }
                            });
                        }
                        else {
                            console.log(++count + "/" + length);
                            // rs(null);
                        }
                    });
                }
                else {
                    console.log(++count + "/" + length);
                    // rs(null);
                }
            });

        });
    });

};

contentModule.fixPartnerExtraDataTPN = function(){
    var length = data_module.partner.items.length;
    var count = 0;
    data_module.partner.items.forEach(function(elt){
        var pattern = {
            type: "struct",
            cond: "and",
            children: {
                partnerid: {
                    type: "number",
                    cond: "eq",
                    value: parseInt(elt.id, 10)
                },
                typeid: {
                    type: "number",
                    cond: "true"
                },
                extraid: {
                    type: "number",
                    cond: "true"
                }
            }
        };

        fconnector.search("extradata_partner_links", pattern, function(value1) {
            if (value1 && value1.length > 0){
                fconnector.read("extradata_partner_links", value1[0], function (success2, value2){
                    if (success2){
                        fconnector.read("extradata_partner", value2.extraid, function (success3, value3){
                            var isChanged = false;
                            if (success3){
                                switch (value2.typeid) {
                                    case 9:
                                        if (value3["type_3_1651584164420"]){
                                            if (value3["type_3_1651584164420"][6]) {
                                                if (value3["type_3_1651584164420"][6].constructor === Array) value3["type_3_1651584164420"] = value3["type_3_1651584164420"][6];
                                                else value3["type_3_1651584164420"] = [value3["type_3_1651584164420"][6]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1651584164420"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_3_1651584151929"]){
                                            if (value3["type_3_1651584151929"][12]) {
                                                if (value3["type_3_1651584151929"][12].constructor === Array) value3["type_3_1651584151929"] = value3["type_3_1651584151929"][12];
                                                else value3["type_3_1651584151929"] = [value3["type_3_1651584151929"][12]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1651584151929"] = [];
                                            isChanged = true;
                                        }
                                        break;
                                    case 10:
                                        if (value3["type_3_1651584661917"]){
                                            if (value3["type_3_1651584661917"][6]) {
                                                if (value3["type_3_1651584661917"][6].constructor === Array) value3["type_3_1651584661917"] = value3["type_3_1651584661917"][6];
                                                else value3["type_3_1651584661917"] = [value3["type_3_1651584661917"][6]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1651584661917"] = [];
                                            isChanged = true;
                                        }
                                        break;
                                    case 11:
                                        if (value3["type_3_1653384709158"]){
                                            if (value3["type_3_1653384709158"][6]) {
                                                if (value3["type_3_1653384709158"][6].constructor === Array) value3["type_3_1653384709158"] = value3["type_3_1653384709158"][6];
                                                else value3["type_3_1653384709158"] = [value3["type_3_1653384709158"][6]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1653384709158"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_3_1651590841942"]){
                                            if (value3["type_3_1651590841942"][12]) {
                                                if (value3["type_3_1651590841942"][12].constructor === Array) value3["type_3_1651590841942"] = value3["type_3_1651590841942"][12];
                                                else value3["type_3_1651590841942"] = [value3["type_3_1651590841942"][12]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1651590841942"] = [];
                                            isChanged = true;
                                        }
                                        break;
                                    case 16:
                                        if (value3["type_3_1653384689799"]){
                                            if (value3["type_3_1653384689799"][6]) {
                                                if (value3["type_3_1653384689799"][6].constructor === Array) value3["type_3_1653384689799"] = value3["type_3_1653384689799"][6];
                                                else  value3["type_3_1653384689799"] = [value3["type_3_1653384689799"][6]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1653384689799"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_3_1653384402748"]){
                                            if (value3["type_3_1653384402748"][12]) {
                                                if (value3["type_3_1653384402748"][12].constructor === Array) value3["type_3_1653384402748"] = value3["type_3_1653384402748"][12];
                                                else value3["type_3_1653384402748"] = [value3["type_3_1653384402748"][12]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_3_1653384402748"] = [];
                                            isChanged = true;
                                        }
                                        break;
                                    default:
                                        // rs(null);

                                }

                                if (isChanged) {
                                    FormClass.api_call({
                                        url: "fix_extra_data_save.php",
                                        params: [
                                            {name: "task", value: "partner"},
                                            {name: "data", value: EncodingClass.string.fromVariable({
                                                id: value2.extraid,
                                                data: value3
                                            })}
                                        ],
                                        func: function(success, message) {
                                            if (success) {
                                                if (message.substr(0, 2) == "ok") {
                                                    console.log("ok", ++count + "/" + length);
                                                }
                                                else {
                                                    console.log(message, ++count + "/" + length);

                                                }
                                            }
                                            else {
                                                console.log(message, ++count + "/" + length);

                                            }
                                        }
                                    });
                                }
                                else {
                                    console.log(++count + "/" + length);
                                    // rs(null);
                                }
                            }
                            else {
                                console.log(++count + "/" + length);
                                // rs(null);
                            }
                        });
                    }
                    else {
                        console.log(++count + "/" + length);
                        // rs(null);
                    }
                });
            }
            else {
                console.log(++count + "/" + length);
                // rs(null);
            }
        });

    });

};

contentModule.fixObjectExtraDataNTP = function(){

    data_module.loadObjectsList().then(function(temp1){
        var length = temp1.length;
        var count = 0;
        temp1.forEach(function(elt){
            var pattern = {
                type: "struct",
                cond: "and",
                children: {
                    objectid: {
                        type: "number",
                        cond: "eq",
                        value: parseInt(elt.id, 10)
                    },
                    extraid: {
                        type: "number",
                        cond: "true"
                    }
                }
            };

            fconnector.search("extradata_objects_links", pattern, function(value1) {
                if (value1 && value1.length > 0){
                    fconnector.read("extradata_objects_links", value1[0], function (success2, value2){
                        if (success2){
                            fconnector.read("extradata_objects", value2.extraid, function (success3, value3){
                                var isChanged = false;
                                if (success3){
                                    if (value3["type_1_1652771680413"]){
                                        if (value3["type_1_1652771680413"][7]) {
                                            if (value3["type_1_1652771680413"][7].constructor === Array) value3["type_1_1652771680413"] = value3["type_1_1652771680413"][7];
                                            else value3["type_1_1652771680413"] = [value3["type_1_1652771680413"][7]];
                                            isChanged = true;
                                        }
                                    }
                                    else {
                                        value3["type_1_1652771680413"] = [];
                                        isChanged = true;
                                    }
                                    if (value3["type_1_1652771693302"]){
                                        if (value3["type_1_1652771693302"][28]) {
                                            if (value3["type_1_1652771693302"][28].constructor === Array) value3["type_1_1652771693302"] = value3["type_1_1652771693302"][28];
                                            else value3["type_1_1652771693302"] = [value3["type_1_1652771693302"][28]];
                                            isChanged = true;
                                        }
                                    }
                                    else {
                                        value3["type_1_1652771693302"] = [];
                                        isChanged = true;
                                    }
                                    if (!value3["type_1_1651637311687"]) {
                                        isChanged = true;
                                        value3["type_1_1651637311687"] = "";
                                    }
                                    if (!value3["type_1_1651637330931"]) {
                                        isChanged = true;
                                        value3["type_1_1651637330931"] = "";
                                    }
                                    if (!value3["type_1_1651637347745"]) {
                                        isChanged = true;
                                        value3["type_1_1651637347745"] = [];
                                    }
                                    if (!value3["type_1_1651637421042"]) {
                                        isChanged = true;
                                        value3["type_1_1651637421042"] = [];
                                    }
                                    if (!value3["type_1_1651637500250"]) {
                                        isChanged = true;
                                        value3["type_1_1651637500250"] = 0;
                                    }
                                    if (!value3["type_1_1651641280821"]) {
                                        isChanged = true;
                                        value3["type_1_1651641280821"] = "";
                                    }
                                    if (!value3["type_1_1651637508822"]) {
                                        isChanged = true;
                                        value3["type_1_1651637508822"] = "type_1_1651637008324";
                                    }
                                    if (!value3["type_1_1651637536756"]) {
                                        isChanged = true;
                                        value3["type_1_1651637536756"] = false;
                                    }
                                    if (isChanged) {
                                        FormClass.api_call({
                                            url: "fix_extra_data_save.php",
                                            params: [
                                                {name: "task", value: "object"},
                                                {name: "data", value: EncodingClass.string.fromVariable({
                                                    id: value2.extraid,
                                                    data: value3
                                                })}
                                            ],
                                            func: function(success, message) {
                                                if (success) {
                                                    if (message.substr(0, 2) == "ok") {
                                                        console.log("ok", ++count + "/" + length);
                                                    }
                                                    else {
                                                        console.log(message, ++count + "/" + length);
                                                    }
                                                }
                                                else {
                                                    console.log(message, ++count + "/" + length);
                                                }
                                            }
                                        })
                                    }
                                    else {
                                        console.log(++count + "/" + length);
                                    }
                                }
                                else {
                                    console.log(++count + "/" + length);
                                    // rs(null);
                                }
                            });
                        }
                        else {
                            console.log(++count + "/" + length);
                            // rs(null);
                        }
                    });
                }
                else {
                    console.log(++count + "/" + length);
                    // rs(null);
                }
            });

        });
    });

};

contentModule.fixNullValue = function(){
    FormClass.api_call({
        url: "fix_extra_data_save.php",
        params: [
            {name: "task", value: "object"},
            {name: "data", value: EncodingClass.string.fromVariable({
                id: 1560,
                data: {
                    type_1_1651637311687: "",
                    type_1_1651637330931: "",
                    type_1_1651637347745: [],
                    type_1_1651637421042: [],
                    type_1_1651637500250: 0,
                    type_1_1651637508822: "type_1_1651637008324",
                    type_1_1651637536756: false,
                    type_1_1651641280821: "",
                    type_1_1652771680413: [],
                    type_1_1652771693302: []
                }
            })}
        ],
        func: function(success, message) {
            if (success) {
                if (message.substr(0, 2) == "ok") {
                    console.log("ok-" + 1560);
                }
                else {
                    console.log(message);
                }
            }
            else {
                console.log(message);
            }
        }
    });
    FormClass.api_call({
        url: "fix_extra_data_save.php",
        params: [
            {name: "task", value: "object"},
            {name: "data", value: EncodingClass.string.fromVariable({
                id: 1561,
                data: {
                    type_1_1651637311687: "",
                    type_1_1651637330931: "",
                    type_1_1651637347745: [],
                    type_1_1651637421042: [],
                    type_1_1651637500250: 0,
                    type_1_1651637508822: "type_1_1651637008324",
                    type_1_1651637536756: false,
                    type_1_1651641280821: "",
                    type_1_1652771680413: [],
                    type_1_1652771693302: []
                }
            })}
        ],
        func: function(success, message) {
            if (success) {
                if (message.substr(0, 2) == "ok") {
                    console.log("ok-" + 1561);
                }
                else {
                    console.log(message);
                }
            }
            else {
                console.log(message);
            }
        }
    });
    FormClass.api_call({
        url: "fix_extra_data_save.php",
        params: [
            {name: "task", value: "object"},
            {name: "data", value: EncodingClass.string.fromVariable({
                id: 1562,
                data: {
                    type_1_1651637311687: "",
                    type_1_1651637330931: "",
                    type_1_1651637347745: [],
                    type_1_1651637421042: [],
                    type_1_1651637500250: 0,
                    type_1_1651637508822: "type_1_1651637008324",
                    type_1_1651637536756: false,
                    type_1_1651641280821: "",
                    type_1_1652771680413: [],
                    type_1_1652771693302: []
                }
            })}
        ],
        func: function(success, message) {
            if (success) {
                if (message.substr(0, 2) == "ok") {
                    console.log("ok-" + 1562);
                }
                else {
                    console.log(message);
                }
            }
            else {
                console.log(message);
            }
        }
    });
    FormClass.api_call({
        url: "fix_extra_data_save.php",
        params: [
            {name: "task", value: "object"},
            {name: "data", value: EncodingClass.string.fromVariable({
                id: 1565,
                data: {
                    type_1_1651637311687: "",
                    type_1_1651637330931: "",
                    type_1_1651637347745: [],
                    type_1_1651637421042: [],
                    type_1_1651637500250: 0,
                    type_1_1651637508822: "type_1_1651637008324",
                    type_1_1651637536756: false,
                    type_1_1651641280821: "",
                    type_1_1652771680413: [],
                    type_1_1652771693302: []
                }
            })}
        ],
        func: function(success, message) {
            if (success) {
                if (message.substr(0, 2) == "ok") {
                    console.log("ok-" + 1565);
                }
                else {
                    console.log(message);
                }
            }
            else {
                console.log(message);
            }
        }
    });
}

contentModule.fixPartnerExtraDataNTP = function(){
    var length = data_module.partner.items.length;
    var count = 0;
    data_module.partner.items.forEach(function(elt){
        var pattern = {
            type: "struct",
            cond: "and",
            children: {
                partnerid: {
                    type: "number",
                    cond: "eq",
                    value: parseInt(elt.id, 10)
                },
                typeid: {
                    type: "number",
                    cond: "true"
                },
                extraid: {
                    type: "number",
                    cond: "true"
                }
            }
        };

        fconnector.search("extradata_partner_links", pattern, function(value1) {
            if (value1 && value1.length > 0){
                fconnector.read("extradata_partner_links", value1[0], function (success2, value2){
                    if (success2){
                        fconnector.read("extradata_partner", value2.extraid, function (success3, value3){
                            var isChanged = false;
                            if (success3){
                                switch (value2.typeid) {
                                    case 5:
                                        if (value3["type_1_1651228862798"]){
                                            if (value3["type_1_1651228862798"][4]) {
                                                if (value3["type_1_1651228862798"][4].constructor === Array) value3["type_1_1651228862798"] = value3["type_1_1651228862798"][4];
                                                else value3["type_1_1651228862798"] = [value3["type_1_1651228862798"][4]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651228862798"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1652771653477"]){
                                            if (value3["type_1_1652771653477"][7]) {
                                                if (value3["type_1_1652771653477"][7].constructor === Array) value3["type_1_1652771653477"] = value3["type_1_1652771653477"][7];
                                                else value3["type_1_1652771653477"] = [value3["type_1_1652771653477"][7]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1652771653477"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651243621319"]){
                                            if (value3["type_1_1651243621319"][30]) {
                                                if (value3["type_1_1651243621319"][30].constructor === Array) value3["type_1_1651243621319"] = value3["type_1_1651243621319"][30];
                                                else value3["type_1_1651243621319"] = [value3["type_1_1651243621319"][30]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651243621319"] = [];
                                            isChanged = true;
                                        }
                                        if (!value3["type_1_1651564353133"]) {
                                            isChanged = true;
                                            value3["type_1_1651564353133"] = [];
                                        }
                                        break;
                                    case 12:
                                        if (value3["type_1_1651241850018"]){
                                            if (value3["type_1_1651241850018"][4]) {
                                                if (value3["type_1_1651241850018"][4].constructor === Array) value3["type_1_1651241850018"] = value3["type_1_1651241850018"][4];
                                                else value3["type_1_1651241850018"] = [value3["type_1_1651241850018"][4]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651241850018"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651240952220"]){
                                            if (value3["type_1_1651240952220"][7]) {
                                                if (value3["type_1_1651240952220"][7].constructor === Array) value3["type_1_1651240952220"] = value3["type_1_1651240952220"][7];
                                                else value3["type_1_1651240952220"] = [value3["type_1_1651240952220"][7]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651240952220"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651243741259"]){
                                            if (value3["type_1_1651243741259"][30]) {
                                                if (value3["type_1_1651243741259"][30].constructor === Array) value3["type_1_1651243741259"] = value3["type_1_1651243741259"][30];
                                                else value3["type_1_1651243741259"] = [value3["type_1_1651243741259"][30]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651243741259"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651577905144"]){
                                            if (value3["type_1_1651577905144"][10]) {
                                                if (value3["type_1_1651577905144"][10].constructor === Array) value3["type_1_1651577905144"] = value3["type_1_1651577905144"][10];
                                                else value3["type_1_1651577905144"] = [value3["type_1_1651577905144"][10]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651577905144"] = [];
                                            isChanged = true;
                                        }
                                        if (!value3["type_1_1651240940056"]) {
                                            isChanged = true;
                                            value3["type_1_1651240940056"] = [];
                                        }
                                        break;
                                    case 16:
                                        if (value3["type_1_1651578682981"]){
                                            if (value3["type_1_1651578682981"][4]) {
                                                if (value3["type_1_1651578682981"][4].constructor === Array) value3["type_1_1651578682981"] = value3["type_1_1651578682981"][4];
                                                else value3["type_1_1651578682981"] = [value3["type_1_1651578682981"][4]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651578682981"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651578696698"]){
                                            if (value3["type_1_1651578696698"][7]) {
                                                if (value3["type_1_1651578696698"][7].constructor === Array) value3["type_1_1651578696698"] = value3["type_1_1651578696698"][7];
                                                else value3["type_1_1651578696698"] = [value3["type_1_1651578696698"][7]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651578696698"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651578670788"]){
                                            if (value3["type_1_1651578670788"][30]) {
                                                if (value3["type_1_1651578670788"][30].constructor === Array) value3["type_1_1651578670788"] = value3["type_1_1651578670788"][30];
                                                else value3["type_1_1651578670788"] = [value3["type_1_1651578670788"][30]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651578670788"] = [];
                                            isChanged = true;
                                        }
                                        if (value3["type_1_1651578708848"]){
                                            if (value3["type_1_1651578708848"][10]) {
                                                if (value3["type_1_1651578708848"][10].constructor === Array) value3["type_1_1651578708848"] = value3["type_1_1651578708848"][10];
                                                else value3["type_1_1651578708848"] = [value3["type_1_1651578708848"][10]];
                                                isChanged = true;
                                            }
                                        }
                                        else {
                                            value3["type_1_1651578708848"] = [];
                                            isChanged = true;
                                        }
                                        break;
                                    default:
                                        // rs(null);

                                }

                                if (isChanged) {
                                    FormClass.api_call({
                                        url: "fix_extra_data_save.php",
                                        params: [
                                            {name: "task", value: "partner"},
                                            {name: "data", value: EncodingClass.string.fromVariable({
                                                id: value2.extraid,
                                                data: value3
                                            })}
                                        ],
                                        func: function(success, message) {
                                            if (success) {
                                                if (message.substr(0, 2) == "ok") {
                                                    console.log("ok", ++count + "/" + length);
                                                }
                                                else {
                                                    console.log(message, ++count + "/" + length);

                                                }
                                            }
                                            else {
                                                console.log(message, ++count + "/" + length);

                                            }
                                        }
                                    });
                                }
                                else {
                                    console.log(++count + "/" + length);
                                    // rs(null);
                                }
                            }
                            else {
                                console.log(++count + "/" + length);
                                // rs(null);
                            }
                        });
                    }
                    else {
                        console.log(++count + "/" + length);
                        // rs(null);
                    }
                });
            }
            else {
                console.log(++count + "/" + length);
                // rs(null);
            }
        });

    });

};


contentModule.formEditApprovalPolicies = function(params){
    var getRowApprover = function(employeeid){
        var employee_select = absol.buildDom({
            tag: "selecttreeleafmenu",
            style: {
                display: "block",
                width: "100%"
            },
            props: {
                items: params.employeeViewItems,
                enableSearch: true,
                value: employeeid
            }
        });
        var cells = [
            {
                style: {
                    width: '30px',
                    textAlign: 'center',
                    fontSize: '25px'
                },
                class: 'as-drag-zone',
                child: 'span.mdi.mdi-drag'
            },
            {
                child: employee_select
            }
        ];
        var deleteIcon = DOMElement.div({
            attrs: {
                className: "card-icon-remove-cover",
                onclick: function(){
                    var x = tableView.rowOf(row)
                    x.remove();
                }
            },
            children: [DOMElement.i({
                attrs: {
                    className: "material-icons card-icon-remove"
                },
                text: "remove_circle"
            })]
        });
        cells.push({
            child: deleteIcon
        });
        var row = {cells: cells};
        row.getValue = function(){
            var x = employee_select.value;
            if (x == 0){
                ModalElement.alert({
                    message: LanguageModule.text("txt_employee_is_null")
                });
                return;
            }
            return x;
        };
        return row;
    };
    var approval_method_select = absol.buildDom({
        tag: "selectmenu",
        style: {
            display: "block",
            width: "100%"
        },
        props: {
            items: contentModule.getListApprovalMethod()
        }
    });
    if (params.dataPolicyEdit.approval_method != "") approval_method_select.value = params.dataPolicyEdit.approval_method;
    var direct_manager_approves_first_checkbox = absol.buildDom({
        tag: "checkbox",
        props: {
             checked: params.dataPolicyEdit.direct_manager_approves_first
        }
    });
    var time_hours_needed_for_approval_input = theme.input({
        type: "number",
        min: 0,
        style: {
            textAlign: "right"
        },
        value: params.dataPolicyEdit.time_hours_needed_for_approval
    });
    var data = [];
    for (var i = 0; i < params.dataPolicyEdit.approvers.length; i++){
        data.push(getRowApprover(params.dataPolicyEdit.approvers[i].employeeid));
    }
    var tableView = absol.buildDom({
        tag: "dynamictable",
        props: {
            adapter: {
               rowsPerPage: Infinity,
               data: {
                   head: {
                       rows: [
                           {
                               cells: [
                                   {},
                                   {
                                       child:  absol.buildDom({text: LanguageModule.text("txt_employee")})
                                   },
                                   {}
                               ]
                           }
                       ]
                   },
                   body: {
                       rows: data
                   }
               }
           }
        }
    });
    var editApprovalForm = DOMElement.div({
        children: [
            DOMElement.table({
                data: [
                    [
                        {text: LanguageModule.text("txt_direct_manager_approves_first")},
                        {attrs: {style: {width: "var(--control-horizontal-distance-2)"}}},
                        direct_manager_approves_first_checkbox
                    ],
                    [{attrs: {style: {height: "var(--control-verticle-distance-2)"}}}],
                    [
                        {text: LanguageModule.text("txt_time_hours_needed_for_approval")},
                        {attrs: {style: {width: "var(--control-horizontal-distance-2)"}}},
                        time_hours_needed_for_approval_input
                    ],
                    [{attrs: {style: {height: "var(--control-verticle-distance-2)"}}}],
                    [
                        {text: LanguageModule.text("txt_approval_method")},
                        {attrs: {style: {width: "var(--control-horizontal-distance-2)"}}},
                        approval_method_select
                    ]
                ]
            }),
            DOMElement.div({attrs: {style: {height: "var(--control-verticle-distance-2)"}}}),
            DOMElement.div({
                children: [
                    DOMElement.span({text: LanguageModule.text("txt_approvers")}),
                    DOMElement.div({
                        attrs: {
                            className: "mk-table-wrapper-header-cmd",
                            onclick: function(){
                                tableView.addRow(getRowApprover(0));
                            }
                        },
                        text: LanguageModule.text("txt_add")
                    })
                ]
            }),
            DOMElement.div({attrs: {style: {height: "var(--control-verticle-distance-2)"}}}),
            tableView
        ]
    });
    var getValue = function(){
        var time_hours_needed_for_approval = parseFloat(time_hours_needed_for_approval_input.value);
        var direct_manager_approves_first = direct_manager_approves_first_checkbox.checked? 1 : 0;
        if (!time_hours_needed_for_approval){
            ModalElement.alert({
                message: LanguageModule.text("txt_time_hours_needed_for_approval_is_null"),
                func: function(){
                    time_hours_needed_for_approval_input.focus();
                }
            });
            return;
        }
        var approvers = [], value;
        var data = tableView.requireRows();
        var rowData;
        for (var i = 0; i < data.length; i++){
            rowData = data[i];
            value = rowData.data.getValue();
            if (!value) return;
            approvers.push(value);
        }
        if (!direct_manager_approves_first && approvers.length == 0){
            ModalElement.alert({
                message: LanguageModule.text("txt_approvers_is_null")
            });
            return;
        }
        var res = {
            direct_manager_approves_first: direct_manager_approves_first,
            time_hours_needed_for_approval: time_hours_needed_for_approval,
            approval_method: approval_method_select.value,
            approvers: approvers
        };
        return res;
    };
    ModalElement.showWindow({
        title: LanguageModule.text("txt_approval"),
        bodycontent: editApprovalForm,
        buttonlist: [
            {
                text: LanguageModule.text("txt_save"),
                onclick: function(){
                    var data = getValue();
                    if (!data) return;
                    params.func.save(data);
                }
            },
            {
                text: LanguageModule.text("txt_cancel"),
                onclick: function(){
                    ModalElement.close();
                }
            }
        ]
    });
};

contentModule.getPolicyHasApplyToEmployee = function(host, id, type, employeeid){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    if (employeeid == 0) return res;
    var dic = {};
    for (var i = 0; i < host.database.employee_policies.items.length; i++){
        if (host.database.employee_policies.items[i].employeeid != employeeid) continue;
        if (host.database.employee_policies.items[i].id == id) continue;
        if (host.database.employee_policies.items[i].type != type) continue;
        dic[host.database.employee_policies.items[i].policyid] = true;
    }
    for (var i = 0; i < host.database[type + "_policies"].items.length; i++){
        if (dic[host.database[type + "_policies"].items[i].id]) continue;
        res.push({
            value: host.database[type + "_policies"].items[i].id,
            text: host.database[type + "_policies"].items[i].name
        });
    }
    return res;
};

contentModule.getLeavePolicyHasApplyToEmployee = function(host, id, employeeid){
    var res = [{value: 0, text: LanguageModule.text("txt_select_value")}];
    if (employeeid == 0) return res;
    var pIndex;
    var dic = {};
    for (var i = 0; i < host.database.employee_policies.items.length; i++){
        if (host.database.employee_policies.items[i].employeeid != employeeid) continue;
        if (host.database.employee_policies.items[i].id == id) continue;
        if (host.database.employee_policies.items[i].type != "leave") continue;
        pIndex = host.database.leave_policies.getIndex(host.database.employee_policies.items[i].policyid);
        if (pIndex >= 0) dic[host.database.leave_policies.items[pIndex].groupid] = true;
    }
    for (var i = 0; i < host.database.leave_policies.items.length; i++){
        if (dic[host.database.leave_policies.items[i].groupid]) continue;
        res.push({
            value: host.database.leave_policies.items[i].id,
            text: host.database.leave_policies.items[i].name
        });
    }
    return res;
};

contentModule.getGeneralDefault = function(){
    return {id: -1, name: LanguageModule.text("txt_general"), description: "", available: 1, extrainfo: [], ver: 1};
};


contentModule.handleIncomletedForm = function(formView, verifyInfo){
    var mess = "";
    var comp = verifyInfo.comp;
    if (verifyInfo.comp.tag == "TableInput") {
        mess = comp.attributes.inpcompletedMessage || "Lỗi nhập thiếu trường $fieldName";
        mess = mess.replace("$fieldName", verifyInfo.incompleteCell.descriptor.text);
        ModalElement.alert({
            message: mess,
            func: function(){
                comp.focusIncompleteCell();
            }
        });
    }
};

if (hr.systemFunctions === undefined) hr.systemFunctions = {};
/****
 * hàm gọi form trong modal
 * @param {number|string} typeId
 * @param {number|string|null} formId

 * @param {any=}initValue - có thể null, undefined, có thể lỗi dữ liệu do user truyền sai
 * @param {boolean=}cancelable - mặc định là false, nếu cancelable= true, thì mới có nút cancel
 * @returns {Promise<any>} hàm resolve về kết quả của form trong promise sau khi người ta nhấn ok, nếu nhấn cancel, resolve null
 */
hr.systemFunctions.openInputForm = function (typeId, formId, initValue, cancelable) {
    return new Promise(function(rs, rj){
        var formContainer = absol._({});
        var buttonlist = [
            {
                text: LanguageModule.text("txt_ok"),
                onclick: function(){
                    var value = formContainer.getValue();
                    if (value !== undefined) {
                        rs(value);
                        ModalElement.close();
                    }
                    else rj(value);
                }
            }
        ];
        if (cancelable) buttonlist.push({
            text: LanguageModule.text("txt_cancel"),
            onclick: function(){
                ModalElement.close();
                rj("close");
            }
        });
        ModalElement.showWindow({
            title: "Input",
            bodycontent: formContainer,
            buttonlist: buttonlist
        })
        var callbackfunc = function(){
            if (data_module.pendingData.status == "error"){
                ModalElement.alert("Có lỗi trong quá trình khởi tạo dữ liệu");
                return;
            }
            else if (data_module.pendingData.status == "pending") {
                setTimeout(function(){
                    callbackfunc();
                }, 500);
                return;
            }
            var typelists = data_module.typelists.items;
            var dict = {};
            typelists.forEach(function (elt, index) {
                dict[elt.id] = elt;
            });
            var AssemblerInstance = absol.form.AssemblerInstance;
            var $ = absol.$;
            var _ = absol._;
            var JSZip = absol.JSZip;
            var makeFmFragmentClass = absol.form.makeFmFragmentClass;
            var mSignUpFrag = AssemblerInstance.buildFragment({class: formId.toString()});
            mSignUpFrag.setContext("SHARE_PARAMS", {});
            mSignUpFrag.domElt.addStyle({
                width: '100%',
                height:'100%',
                display: 'block'
            });
            DOMElement.removeAllChildren(formContainer);
            formContainer.appendChild(mSignUpFrag.domElt);
            formContainer.formFragment = mSignUpFrag;
            formContainer.getValue = function(alert_value){
                return contentModule.getValueOfUserForm(mSignUpFrag, typeId, typelists, alert_value == "no_alert" ? true : false);
            }
            if (!initValue) initValue = {};
            contentModule.setValueOfUserForm({
                typelists: typelists,
                valueContent: initValue,
                typeid: typeId
            }).then(function(value){
                if (mSignUpFrag.state === "RUNNING"){
                    mSignUpFrag.props = value;
                    ModalElement.close(-1);
                }
                else {
                    mSignUpFrag.onReady = function(){
                        this.props = value;
                        this.onReady = null;
                        ModalElement.close(-1);
                    }
                }
            });
        }
        if (formId === undefined) {
            FormClass.api_call({
                url: "database_load.php",
                params: [{name: "task", value: "load_form_config"}],
                func: function(success, message) {
                    if (success) {
                        if (message.substr(0, 2) == "ok"){
                            var x = {
                                database: {
                                    form_config: {items: EncodingClass.string.toVariable(message.substr(2))}
                                }
                            };
                            var typeDict = {};
                            var dict2 = {};
                            data_module.typelists.items.forEach(function(elt, index){
                                typeDict[elt.id] = index;
                                dict2[elt.id] = elt;
                            });
                            var getType = function(index){
                                var type = data_module.typelists.items[index].type;
                                if (
                                    form_module.primitiveTypeList.indexOf(type) != -1
                                ){
                                    type = data_module.typelists.items[index].type2;
                                }
                                return type;
                            }
                            var type = getType(typeDict[typeId]);
                            var form_config = contentModule.configVariable(x);
                            // var datatypePrimitiveList = contentModule.getDatatypePrimitiveList();
                            if (type == "array" || type == "structure" || type == "extends_structure"){
                                if (form_config[dict2[typeId].type]) {
                                    formId = form_config[dict2[typeId].type].input_form;
                                }
                                else {
                                    for(var i = 0; i < data_module.input_forms.items.length; i++){
                                        if (data_module.input_forms.items[i].typeid == typeId){
                                            formId = data_module.input_forms.items[i].id;
                                            break;
                                        }
                                    }
                                }

                                callbackfunc();
                            }
                            else {
                                var t;
                                if (type == "enum" || type == "extends_enum" || type == "enum_multi" || type == "extends_enum_multi"){
                                    t = hr.systemFunctions.makePrimitiveForm[type](typeId, initValue);
                                }
                                else t = hr.systemFunctions.makePrimitiveForm[type](initValue);
                                DOMElement.removeAllChildren(formContainer);
                                formContainer.appendChild(t);
                                formContainer.getValue = t.getValue;
                            }
                        }
                    }
                }
            })
        }

        // callbackfunc();
    })
};





/****
 * hàm gọi form trong modal
 * @param {Array<{formId:number|string, typeId: number|string, initValue: any, displayName: string}>} formParamsArray
 * @param {boolean=}cancelable - mặc định là false, nếu cancelable= true, thì mới có nút cancel
 * @returns {Promise<Array<any>>} hàm resolve về mảng kết quả của form trong promise sau khi người ta nhấn ok, nếu nhấn cancel, resolve null
 */
hr.systemFunctions.openInputFormArray = function (formParamsArray, cancelable) {
    return new Promise(function(rs, rj){
        var getConfig = function(){
            return new Promise(function(ok, cancel){
                FormClass.api_call({
                    url: "database_load.php",
                    params: [{name: "task", value: "load_form_config"}],
                    func: function(success, message) {
                        if (success) {
                            if (message.substr(0, 2) == "ok"){
                                var x = {
                                    database: {
                                        form_config: {items: EncodingClass.string.toVariable(message.substr(2))}
                                    }
                                };
                                var form_config = contentModule.configVariable(x);

                                ok(form_config);
                            }
                        }
                    }
                })
            })
        };
        getConfig().then(function(form_config){
            var typeDict = {};
            var dict = {};
            var getType = function(index){
                var type = data_module.typelists.items[index].type;
                if (
                    form_module.primitiveTypeList.indexOf(type) != -1
                ){
                    type = data_module.typelists.items[index].type2;
                }
                return type;
            }
            var typelists = data_module.typelists.items;
            typelists.forEach(function (elt, index) {
                typeDict[elt.id] = index;
                dict[elt.id] = elt;
            });
            var callbackfunc = function(typeId, formId, initValue){
                return new Promise(function(rs, rj) {
                    if (data_module.pendingData.status == "error"){
                        ModalElement.alert("Có lỗi trong quá trình khởi tạo dữ liệu");
                        return;
                    }
                    else if (data_module.pendingData.status == "pending") {
                        setTimeout(function(){
                            callbackfunc();
                        }, 500);
                        return;
                    }
                    var AssemblerInstance = absol.form.AssemblerInstance;
                    var $ = absol.$;
                    var _ = absol._;
                    var JSZip = absol.JSZip;
                    var makeFmFragmentClass = absol.form.makeFmFragmentClass;
                    var mSignUpFrag = AssemblerInstance.buildFragment({class: formId.toString()});
                    mSignUpFrag.setContext("SHARE_PARAMS", {});
                    mSignUpFrag.domElt.addStyle({
                        width: '100%',
                        height:'100%',
                        display: 'block'
                    });
                    var x = mSignUpFrag.domElt;
                    x.getValue = function(alert_value){
                        return contentModule.getValueOfUserForm(mSignUpFrag, typeId, typelists);
                    }
                    if (!initValue) initValue = {};
                    contentModule.setValueOfUserForm({
                        typelists: typelists,
                        valueContent: initValue,
                        typeid: typeId
                    }).then(function(value){
                        if (mSignUpFrag.state === "RUNNING"){
                            mSignUpFrag.props = value;
                        }
                        else {
                            mSignUpFrag.onReady = function(){
                                this.props = value;
                                this.onReady = null;
                            }
                        }
                        rs (x);
                    });
                })
            }

            var promiseArray = [];
            var cbbItems = formParamsArray.forEach(function(elt, idx){
                if (!elt.formId) {
                    var type = getType(typeDict[elt.typeId]);
                    // var datatypePrimitiveList = contentModule.getDatatypePrimitiveList();
                    if (type == "array" || type == "structure" || type == "extends_structure"){
                        if (form_config[dict[elt.typeId].type]) {
                            elt.formId = form_config[dict[elt.typeId].type].input_form;
                        }
                        else {
                            for(var i = 0; i < data_module.input_forms.items.length; i++){
                                if (data_module.input_forms.items[i].typeid == elt.typeId){
                                    elt.formId = data_module.input_forms.items[i].id;
                                    break;
                                }
                            }
                        }
                        promiseArray.push(callbackfunc(elt.typeId, elt.formId, elt.initValue));
                    }
                    else {
                        var t;
                        if (type == "enum" || type == "extends_enum" || type == "enum_multi" || type == "extends_enum_multi"){
                            t = hr.systemFunctions.makePrimitiveForm[type](elt.typeId, elt.initValue);
                        }
                        else t = hr.systemFunctions.makePrimitiveForm[type](elt.initValue);
                        promiseArray.push(Promise.resolve(t));
                        // DOMElement.removeAllChildren(formContainer);
                        // formContainer.appendChild(t);
                        // formContainer.getValue = t.getValue;
                    }
                }
                else promiseArray.push(callbackfunc(elt.typeId, elt.formId, elt.initValue));
                // return {value: idx, text: elt.displayName};
            });
            ModalElement.show_loading();
            Promise.all(promiseArray).then(function(formArray){
                ModalElement.close(-1);
                var data = [];
                formParamsArray.forEach((item, i) => {
                    if (data.length > 0) {
                        data.push([
                            {
                                attrs: {
                                    colSpan: 3,
                                    style: {
                                        paddingTop: "10px",
                                        paddingBottom: "10px"
                                    }
                                },
                                children: [absol._({
                                    style: {
                                        height: "1px",
                                        border: "1px solid grey"
                                    }
                                })]
                            }
                        ]);
                    }
                    data.push([
                        {
                            text: item.displayName
                        },
                        {attrs: {style: {width: "20px"}}},
                        {
                            children: [formArray[i]]
                        }
                    ])
                });

                // var cbb = absol._({
                //     tag: "selectmenu",
                //     props: {
                //         items: cbbItems
                //     },
                //     on: {
                //         change: function(){
                //             DOMElement.removeAllChildren(formContainer);
                //             formContainer.appendChild(formArray[parseInt(this.value)]);
                //         }
                //     }
                // });
                var formContainer = absol._({
                    child: DOMElement.table({
                        data: data
                    })
                    // child: formArray[0]
                });
                var buttonlist = [
                    {
                        text: LanguageModule.text("txt_ok"),
                        onclick: function(){
                            var value = [];
                            for (var i = 0; i < formArray.length; i++){
                                var t = formArray[i].getValue();
                                if (t !== undefined) value.push(t);
                                else {
                                    rj();
                                    return;
                                }
                            }
                            rs(value);
                            ModalElement.close();
                        }
                    }
                ];
                if (cancelable) buttonlist.push({
                    text: LanguageModule.text("txt_cancel"),
                    onclick: function(){
                        ModalElement.close();
                        rj("close");
                    }
                });
                ModalElement.showWindow({
                    title: "Input",
                    bodycontent: absol._({
                        child: [
                            // {
                            //     style: {
                            //         paddingBottom: "20px"
                            //     },
                            //     child: [
                            //         {
                            //             style: {
                            //                 display: "inline"
                            //             },
                            //             child: {text: "Chọn Input"}
                            //         },
                            //         {
                            //             style: {
                            //                 display: "inline",
                            //                 paddingLeft: "5px"
                            //             },
                            //             child: cbb
                            //         }
                            //     ]
                            // },
                            formContainer
                        ]
                    }),
                    buttonlist: buttonlist
                });
            });
        })
    });
};

hr.systemFunctions.makePrimitiveForm = {};

hr.systemFunctions.makePrimitiveForm.nation_city = function(value){
    var element = absol._({
        tag: "dualselectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        return element.value;
    };
    ModalElement.show_loading();
    Promise.all([
        data_module.loadNationsList(),
        data_module.loadCitiesList()
    ]).then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {nations: rs[0], cities: rs[1]});
        contentModule.makeCitiesIndex(host);
        var items = contentModule.getNationCityDualSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.position_list = function(value){
    var element = absol._({
        tag: "multichecktreeleafmenu",
        props: {
            values: value,
            leafOnly: true
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    Promise.all([
        data_module.loadOrgsList(),
        data_module.loadPositionsList()
    ]).then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {orgs: rs[0], positions: rs[1]});
        contentModule.makeOrgsIndex(host);
        contentModule.makePositionsIndex(host);
        var items = contentModule.getMemberOfPositionSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.employee_list = function(value){
    var element = absol._({
        tag: "multichecktreeleafmenu",
        props: {
            values: value,
            leafOnly: true
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadEmployeeItemsPrivView().then(function(host){
        var items = contentModule.getMemberOfEmployeeSelectMenu(host);
        items.splice(0, 1);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.string = function(value){
    var element = absol._({
        tag: "input",
        class: "cardsimpleInput",
        style: {
            width: "400px"
        },
        props: {
            type: "text",
            value: value ? value : ""
        }
    });
    element.getValue = function(){
        var value = element.value.trim();
        if (value == "") {
            ModalElement.alert({
                message: "Chưa nhập đủ dữ liệu",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return value;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.phonenumber = hr.systemFunctions.makePrimitiveForm.string;
hr.systemFunctions.makePrimitiveForm.website = hr.systemFunctions.makePrimitiveForm.string;

hr.systemFunctions.makePrimitiveForm.gps = function(value){
    var element = absol._({
        tag: "locationinput",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        var value = element.value.trim();
        if (value == "") {
            ModalElement.alert({
                message: "Chưa nhập đủ dữ liệu",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return value;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.note = function(value){
    var element = absol._({
        tag: "textarea",
        class: "cardsimpleTextarea",
        style: {
            height: "100px",
            width: "400px"
        },
        props: {
            value: value ? value : ""
        }
    });
    element.getValue = function(){
        var value = element.value.trim();
        if (value == "") {
            ModalElement.alert({
                message: "Chưa nhập đủ dữ liệu",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return value;
    };
    return element;
};
hr.systemFunctions.makePrimitiveForm.html = hr.systemFunctions.makePrimitiveForm.string;
hr.systemFunctions.makePrimitiveForm.email_address = hr.systemFunctions.makePrimitiveForm.string;

hr.systemFunctions.makePrimitiveForm.time = function(value){
    var element = absol._({
        tag: "timeinput",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (!element.value) {
            ModalElement.alert({
                message: "Chưa nhập đủ dữ liệu",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.boolean = function(value){
    var element = absol._({
        tag: "checkbox",
        props: {
            checked: value
        }
    });
    element.getValue = function(){
        return element.checked;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.date = function(value){
    var element = absol._({
        tag: "dateinput",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (!element.value) {
            ModalElement.alert({
                message: "Chưa nhập đủ dữ liệu",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.datetime = function(value){
    var element = absol._({
        tag: "datetimeinput",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (!element.value) {
            ModalElement.alert({
                message: "Chưa nhập đủ dữ liệu",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.number = function(value){
    var element = absol._({
        tag: "numberinput",
        style: {
            width: "400px"
        },
        props: {
            value: value
        }
    });
    element.getValue = function(){
        return element.value;
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.currency = hr.systemFunctions.makePrimitiveForm.number;

hr.systemFunctions.makePrimitiveForm.hour_period = function(value){
    var element = absol._({
        tag: "timerange24input",
        props: {
            dayOffset: 0,
            duration: 0
        }
    });
    element.getValue = function(){
        return {
            dayOffset: element.dayOffset,
            duration: element.duration
        };
    };
    return element;
};

hr.systemFunctions.makePrimitiveForm.userlist = function(value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadUsersList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {users: rs});
        var items = contentModule.getUsersListSelectMenu(host);
        items.splice(0, 1);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.members_of_shifts = function(value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadShiftsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {shifts: rs});
        var items = contentModule.getShiftsListSelectBox(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.members_of_partner_class = function(value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadPartner_classList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {partner_class: rs});
        var items = contentModule.getPartnerClassListSelectBox(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.members_of_locations = function(value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadGeographiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {geopos: rs});
        var items = contentModule.getGeoposListSelectBox(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.select_department_employee = function(value){
    var element = absol._({
        tag: "multichecktreemenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    Promise.all([data_module.loadOrgsList(), data_module.loadEmployeesList(), data_module.loadPeoplesList()]).then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {orgs: rs[0], employees: rs[1], peoples: rs[2]});
        var pDict = {};
        host.database.peoples.items.forEach(function(elt){
            pDict[elt.id] = elt;
        });
        host.database.employees.items.forEach(function(elt){
            elt.fullname = pDict[elt.peopleid].fullname;
        });
        contentModule.makeOrgsIndex(host);
        contentModule.makeEmployeesIndex(host);
        var items = contentModule.getOrgsAndEmployeesListSelectTreeMenu(host);
        items.splice(0, 1);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_position = function(value){
    var element = absol._({
        tag: "selecttreeleafmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    Promise.all([
        data_module.loadOrgsList(),
        data_module.loadPositionsList()
    ]).then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {orgs: rs[0], positions: rs[1]});
        contentModule.makeOrgsIndex(host);
        contentModule.makePositionsIndex(host);
        var items = contentModule.getMemberOfPositionSelectMenu(host);
        items.unshift({text: LanguageModule.text("txt_select_value"), value: 0});
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.user = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadUsersList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {users: rs});
        var items = contentModule.getUsersListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_worktime_machines = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadWorktimeMachinesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {worktime_machines: rs});
        var items = contentModule.getWorktime_machinesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.geopos = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadGeographiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {geopos: rs});
        var items = contentModule.getGeoposListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_department = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOrgsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {orgs: rs});
        contentModule.makeOrgsIndex(host);
        var items = contentModule.getOrgsListSelectTreeMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_employee = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadEmployeeItemsPrivView().then(function(host){
        var items = contentModule.getMemberOfEmployeeSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_template_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadTemplateGroupList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {template_groups: rs});
        var items = contentModule.getMemberOfTemplateGroupSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_template_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadWelcomeTemplatesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {welcome_templates: rs});
        var items = contentModule.getMemberOfWelcomeTemplateSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_assets = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadAssetsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {assets: rs});
        var items = contentModule.getAssetsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_instruments_and_tools = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadInstruments_and_toolsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {instruments_and_tools: rs});
        var items = contentModule.getInstrumentAndToolsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_assets_instruments_and_tools = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    var host = {database: {}};
    Promise.all([data_module.loadAssetsList(), data_module.loadInstruments_and_toolsList()]).then(function(content){
        contentModule.makeDatabaseContent(host, {assets: content[0], instruments_and_tools: content[1]});
        var items = contentModule.getAssetsInstrumentAndToolsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    });
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_warehouses = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadWarehousesList().then(function(rs){
        var host = {database: {}};
        if (fragment && fragment.getContext){
            var shareParams = fragment.getContext("SHARE_PARAMS");
            host.listWarehousePriv = shareParams.listWarehousePriv;
        }
        contentModule.makeDatabaseContent(host, {warehouses: rs});
        var items = contentModule.getWarehousesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_allowance_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadAllowance_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {allowance_policy_groups: rs});
        var items = contentModule.getAllowancePolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_bonus_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadBonus_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {bonus_policy_groups: rs});
        var items = contentModule.getBonusPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_work_flow_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadWork_flow_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {work_flow_groups: rs});
        var items = contentModule.getWorkFlowGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_work_flows = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadWork_flowsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {work_flows: rs});
        var items = contentModule.getWorkFlowsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_payroll_cycle = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadPayrollCycleList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {payroll_cycle: rs});
        var items = contentModule.getPayrollCycleListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_objects = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadObjectsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {objects: rs});
        var items = contentModule.getObjectsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_lesson_categories = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadLesson_categoriesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {lesson_categories: rs});
        var items = contentModule.getLessonCategoriesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_task = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadType_listsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {typelists: rs});
        var items = contentModule.getTypeListsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_input_forms = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    var items = contentModule.getMobileInputFormsListSelectMenu();
    element.items = items;
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_output_forms = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    var items = contentModule.getOutputFormsListSelectMenu();
    element.items = items;
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_mobile_input_forms = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    var items = contentModule.getMobileInputFormsListSelectMenu();
    element.items = items;
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_mobile_input_forms = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    var items = contentModule.getMobileInputFormsListSelectMenu();
    element.items = items;
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_partner_class = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadPartner_classList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {partner_class: rs});
        var items = contentModule.getPartnerClassListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_partner = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadPartnerList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {partner: rs});
        var items = contentModule.getPartnerListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_contact = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadContactList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {contact: rs});
        var items = contentModule.getContactListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_trade_union_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadTrade_union_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {trade_union_policy_groups: rs});
        var items = contentModule.getTradeUnionPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_overtime_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOvertime_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {overtime_policy_groups: rs});
        var items = contentModule.getOvertimePolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_offboarding_types = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOffboardingTypeList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {overtime_policy_groups: rs});
        var items = contentModule.getOffboardingTypeListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_offboarding_reasons = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOffboardingReasonList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {overtime_policy_groups: rs});
        var items = contentModule.getOffboardingReasonListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_offboarding_reasons = function(value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadOffboardingReasonList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {overtime_policy_groups: rs});
        var items = contentModule.getOffboardingReasonListSelectMenu(host);
        items.splice(0, 1);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_other_liability_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOther_liability_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {other_liability_policy_groups: rs});
        var items = contentModule.getOtherLiabilityPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_salary_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadSalary_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {salary_policy_groups: rs});
        var items = contentModule.getSalaryPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_punishment_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadPunishment_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {punishment_policy_groups: rs});
        var items = contentModule.getPunishmentPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_asset_category = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadAssetCategoryList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {asset_category: rs});
        var items = contentModule.getAssetCategoryListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_instruments_and_tools_category = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadInstrumentsAndToolsCategoryList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {instruments_and_tools_category: rs});
        var items = contentModule.getAssetsInstrumentAndToolsCategoryListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_projects = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadProjectsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {projects: rs});
        var items = contentModule.getProjectsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_tax_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadTax_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {tax_policy_groups: rs});
        var items = contentModule.getTaxPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_advance_payment_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadAdvance_payment_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {advance_payment_policy_groups: rs});
        var items = contentModule.getAdvancePaymentPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_late_early_checkin_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadLate_early_checkin_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {late_early_checkin_policy_groups: rs});
        var items = contentModule.getLateEarlyCheckinPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_benefit_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadBenefit_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {benefit_policy_groups: rs});
        var items = contentModule.getBenefitPolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_leave_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadLeave_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {leave_policy_groups: rs});
        var items = contentModule.getLeavePolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_insurance_policy_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadInsurance_policy_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {insurance_policy_groups: rs});
        var items = contentModule.getInsurancePolicyGroupsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_shifts = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadShiftsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {shifts: rs});
        var items = contentModule.getShiftsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_insurance_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadInsurance_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {insurance_policies: rs});
        var items = contentModule.getInsurancePoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_tax_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadTax_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {tax_policies: rs});
        var items = contentModule.getTaxPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_trade_union_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadTrade_union_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {trade_union_policies: rs});
        var items = contentModule.getTradeUnionPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_leave_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadLeave_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {leave_policies: rs});
        var items = contentModule.getLeavePoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_benefit_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadBenefit_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {benefit_policies: rs});
        var items = contentModule.getBenefitPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_allowance_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadAllowance_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {allowance_policies: rs});
        var items = contentModule.getAllowancePoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_bonus_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadBonus_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {bonus_policies: rs});
        var items = contentModule.getBonusPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_overtime_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOvertime_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {overtime_policies: rs});
        var items = contentModule.getOvertimePoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_punishment_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadPunishment_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {punishment_policies: rs});
        var items = contentModule.getPunishmentPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_advance_payment_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadAdvance_payment_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {advance_payment_policies: rs});
        var items = contentModule.getAdvancePaymentPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_late_early_checkin_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadLate_early_checkin_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {late_early_checkin_policies: rs});
        var items = contentModule.getLateEarlyCheckinPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_salary_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadSalary_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {salary_policies: rs});
        var items = contentModule.getSalaryPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_other_liability_policies = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOther_liability_policiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {other_liability_policies: rs});
        var items = contentModule.getOtherLiabilityPoliciesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_employment_contract_types = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadEmployment_contract_typesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {employment_contract_types: rs});
        var items = contentModule.getEmploymentContractTypesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_nations = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadNationsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {nations: rs});
        var items = contentModule.getNationsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_cities = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadCitiesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {cities: rs});
        var items = contentModule.getCitiesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_ethnics = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadEthnicsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {ethnics: rs});
        var items = contentModule.getEthnicsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_religions = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadReligionsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {religions: rs});
        var items = contentModule.getReligionsListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_document_types = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadDocument_typesList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {document_types: rs});
        var items = contentModule.getDocumentTypesListSelectMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_document_groups = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadDocument_groupsList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {document_groups: rs});
        var items = contentModule.getDocumentGroupsListSelectTreeMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};


hr.systemFunctions.makePrimitiveForm.member_of_document_folders = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadDocument_foldersList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {document_folders: rs});
        var items = contentModule.getDocumentFoldersListSelectTreeMenu(host);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.member_of_orgs = function(value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    data_module.loadOrgCompanysList().then(function(rs){
        var host = {database: {}};
        contentModule.makeDatabaseContent(host, {orgs: rs});
        var items = contentModule.getOrgsListSelectMenu(host);
        items.splice(0, 1);
        element.items = items;
        ModalElement.close(-1);
    }, function(rj){console.log(rj);});
    return element;
};

hr.systemFunctions.makePrimitiveForm.enum = function(t_id, value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    Promise.all([
        data_module.loadTypeList(),
        data_module.loadLeave_policy_groupsList(),
        data_module.loadEmployment_contract_typesList()
    ]).then(function(values){
        var host = {
            database: {}
        };
        contentModule.makeDatabaseContent(host, {typelists: values[0], leave_policy_groups: values[1], employment_contract_types: values[2]});
        var typeDict = {};
        host.database.typelists.items.forEach(function (elt, index) {
            contentModule.makeDataTypeDecode(elt);
            typeDict[elt.id] = elt;
        });
        var type = typeDict[t_id].type;
        var items;
        switch (type) {
            case 'language':
                items = contentModule.getLanguageListSelectMenu(task);
                break;
            case 'member_of_leave_policy_groups':
                items = contentModule.getLeavePolicyGroupsListSelectMenu(host, task);
                break;
            case 'member_of_employment_contract_types':
                items = contentModule.getEmploymentContractTypesListSelectMenu(host, task);
                break;
            default:
                var content = typeDict[t_id].content;
                var lists = content.details.map(function(elt){
                    return {
                        text: elt.text,
                        value: elt.localid
                    };
                });
                lists.unshift({text: LanguageModule.text("txt_select_value"), value: 0});
                items = lists;
        }
        element.items = items;
        ModalElement.close(-1);
    });
    return element;
};

hr.systemFunctions.makePrimitiveForm.extends_enum = function(t_id, value){
    var element = absol._({
        tag: "selectmenu",
        props: {
            value: value
        }
    });
    element.getValue = function(){
        if (element.value == 0) {
            ModalElement.alert({
                message: "Chưa chọn giá trị",
                func: function(){
                    element.focus();
                }
            });
            return;
        }
        return element.value;
    };
    ModalElement.show_loading();
    Promise.all([
        data_module.loadTypeList(),
        data_module.loadLeave_policy_groupsList(),
        data_module.loadEmployment_contract_typesList()
    ]).then(function(values){
        var host = {
            database: {}
        };
        contentModule.makeDatabaseContent(host, {typelists: values[0], leave_policy_groups: values[1], employment_contract_types: values[2]});
        var typeDict = {};
        host.database.typelists.items.forEach(function (elt, index) {
            contentModule.makeDataTypeDecode(elt);
            typeDict[elt.id] = elt;
        });
        var type = typeDict[t_id].type;
        var items;
        switch (type) {
            case 'language':
                items = contentModule.getLanguageListSelectMenu(task);
                break;
            case 'member_of_leave_policy_groups':
                items = contentModule.getLeavePolicyGroupsListSelectMenu(host, task);
                break;
            case 'member_of_employment_contract_types':
                items = contentModule.getEmploymentContractTypesListSelectMenu(host, task);
                break;
            default:
                var content = typeDict[t_id].content;
                var lists = content.details.map(function(elt){
                    return {
                        text: elt.text,
                        value: elt.localid
                    };
                });
                lists.unshift({text: LanguageModule.text("txt_select_value"), value: 0});
                items = lists;
        }
        element.items = items;
        ModalElement.close(-1);
    });
    return element;
};

hr.systemFunctions.makePrimitiveForm.enum_multi = function(t_id, value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    Promise.all([
        data_module.loadTypeList(),
        data_module.loadLeave_policy_groupsList(),
        data_module.loadEmployment_contract_typesList()
    ]).then(function(values){
        var host = {
            database: {}
        };
        contentModule.makeDatabaseContent(host, {typelists: values[0], leave_policy_groups: values[1], employment_contract_types: values[2]});
        var typeDict = {};
        host.database.typelists.items.forEach(function (elt, index) {
            contentModule.makeDataTypeDecode(elt);
            typeDict[elt.id] = elt;
        });
        var type = typeDict[t_id].type;
        var items;
        switch (type) {
            case 'language':
                items = contentModule.getLanguageListSelectMenu(task);
                break;
            case 'member_of_leave_policy_groups':
                items = contentModule.getLeavePolicyGroupsListSelectMenu(host, task);
                break;
            case 'member_of_employment_contract_types':
                items = contentModule.getEmploymentContractTypesListSelectMenu(host, task);
                break;
            default:
                var content = typeDict[t_id].content;
                var lists = content.details.map(function(elt){
                    return {
                        text: elt.text,
                        value: elt.localid
                    };
                });
                lists.unshift({text: LanguageModule.text("txt_select_value"), value: 0});
                items = lists;
        }
        items.splice(0, 1);
        element.items = items;
        ModalElement.close(-1);
    });
    return element;
};

hr.systemFunctions.makePrimitiveForm.extends_enum_multi = function(t_id, value){
    var element = absol._({
        tag: "multiselectmenu",
        props: {
            values: value
        }
    });
    element.getValue = function(){
        return element.values;
    };
    ModalElement.show_loading();
    data_module.loadTypeList().then(function(typelists){
        var host = {
            database: {}
        };
        contentModule.makeDatabaseContent(host, {typelists: typelists});
        var typeDict = {};
        host.database.typelists.items.forEach(function (elt, index) {
            contentModule.makeDataTypeDecode(elt);
            typeDict[elt.id] = elt;
        });
        var t_id = typeDict[typeid].content.typeof;
        var content = typeDict[typeid].content.details;
        while (typeDict[t_id].type == "extends_enum_multi"){
            content = typeDict[t_id].content.details.concat(content)
            t_id = typeDict[t_id].content.typeof;
        }
        var type = typeDict[t_id].type;
        var lists;
        switch (type) {
            case 'language':
                lists = contentModule.getLanguageListSelectMenu();
                break;
            default:
                lists = typeDict[t_id].content.details.map(function(elt){
                    return {
                        text: elt.text,
                        value: elt.localid
                    };
                });
                lists.unshift({text: LanguageModule.text("txt_select_value"), value: 0});
        }
        content.forEach(function(elt){
            lists.push({
                text: elt.text,
                value: elt.localid
            });
        });
        lists.splice(0, 1);
        element.items = lists;
        ModalElement.close(-1);
    });
    return element;
};

VaKeR 2022