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/input_form_mobile.js
"use strict";

hr.input_form_mobile.fragmentClasses = {
    staticLoaded: false
};

//load những class viết trực tiếp từ js


//dùng để thông báo các sự kiện thay đổi dữ liệu, cập nhật hiển thị
hr.input_form_mobile.emittor = absol.form.emittor;

// hr.input_form_mobile


hr.input_form_mobile.generateOperateFunctionOfArray = function (typelist) {
    var handleCmdInsertRow;

    return handleCmdInsertRow;
}

hr.input_form_mobile.loadFormConstructorToAssembler = function (formList, typelists, mode) {
    return new Promise(function(rs, rj){
        var latestVersionForm = {};
        var dict = {};
        var caculateFunc = function(){
            typelists.forEach(function (elt, index) {
                if (typeof(elt.content) == "string") elt.content = EncodingClass.string.toVariable(elt.content);
                dict[elt.id] = elt;
            });
            typelists.forEach(function (elt, index) {
                if (
                    // elt.type != "treetable"
                    form_module.requireFormType.indexOf(elt.type) == -1
                    && elt.id < 0
                ){
                    var st = form_module.generateDefaultLinearMobileInputForm({
                        database: {
                            input_forms: {items: formList},
                            typelists: {items: typelists}
                        },
                        typeDict: dict
                    }, elt.id, elt);
                    var constructor = absol.form.makeFmFragmentConstructor({
                        tag: elt.id + "_input",
                        contentViewData: st
                    });
                    absol.form.AssemblerInstance.addConstructor(constructor);
                }
            });
            formList.forEach(function (form) {
                if (!form.content.layout) return;
                if (dict[form.typeid].type == "structure" || dict[form.typeid].type == "extends_structure" || dict[form.typeid].type2 == "structure") {
                    if (form.content.layout.attributes.formVersion != form_module.formVersion){
                        if (!latestVersionForm[form.typeid]) {
                            var t_form = form_module.generateDefaultLinearMobileInputForm({
                                database: {
                                    input_forms: {items: formList},
                                    typelists: {items: typelists}
                                },
                                typeDict: dict
                            }, form.typeid, dict[form.typeid]);
                            latestVersionForm[form.typeid] = {
                                layout: {},
                                circuit: {
                                    blocks: {},
                                    lines: {}
                                }
                            };
                            if (t_form !== false) {
                                var nameDict = {};
                                form_module.getNameDictOfTypelist(dict[form.typeid].content, nameDict);
                                form_module.makeLayoutFormDictionary(t_form.layout, nameDict, latestVersionForm[form.typeid]);
                                form_module.makeCircuitFormDictionary(t_form.circuit, latestVersionForm[form.typeid]);
                            }
                            else {
                                ModalElement.close();
                            }
                        }
                        form_module.convertLayoutInputFormToNewVersion(form.content.layout.children, latestVersionForm[form.typeid]);
                        form_module.convertCircuitInputFormToNewVersion(form.content.circuit, latestVersionForm[form.typeid]);
                        var t_dict = {};
                        form.content.circuit.blocks.forEach(function(elt){
                            if (!t_dict[elt.attributes.id]) {
                                t_dict[elt.attributes.id] = elt;
                            }
                            else {
                                if (!t_dict[elt.attributes.id].attributes.permissions) {
                                    t_dict[elt.attributes.id] = elt;
                                }
                            }
                        });
                        form.content.circuit.blocks = Object.values(t_dict);

                        t_dict = {};
                        form.content.circuit.lines.forEach(function(elt){
                            var text = elt.u + elt.uPin + elt.v + elt.vPin;
                            if (!t_dict[text]) {
                                t_dict[text] = elt;
                            }
                            else {
                                if (!t_dict[text].attributes.permissions) {
                                    t_dict[text] = elt;
                                }
                            }
                        });
                        form.content.circuit.lines = Object.values(t_dict);
                    }
                }
                var constructor = absol.form.makeFmFragmentConstructor({
                    tag: '' + form.id,
                    contentViewData: form.content
                });
                if ((dict[form.typeid]) && (dict[form.typeid].type == "array" || dict[form.typeid].type2 == "array")) {
                    form_module.attachOnCreatedCb(form.content.layout);
                    constructor.prototype.onCreated = function () {
                        var myArrayComp = this.findViewByName(form.typeid.toString());
                        if (!myArrayComp) {
                            var t_id = dict[form.typeid].content.typeof;
                            myArrayComp = this.findViewByName("$value$");
                        }
                        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 parentFrg = this.parentFragment;//laf cais form o ngoai
                        // var orgId = parentFrg.props.___.value;
                        var shareData = this.getContext("shareData");

                        var orgid;

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

                        if (orgid && form.typeid == -25) event.resolve({type_select_position_orgid: {value: orgid}});
                        else event.resolve({});
                    };
                }
                absol.form.AssemblerInstance.addConstructor(constructor);
                form.FragmentClass = constructor;
            });
            rs("success");
        };
        if (!mode) {
            form_module.defaultMobileInputFormForPrimitiveType().then(function(primitiveForm){
                // primitiveForm.forEach(function(elt){
                //     elt.content = EncodingClass.string.toVariable(elt.content);
                // });
                for (var i = primitiveForm.length - 1; i >= 0; i--){
                    primitiveForm[i].content = EncodingClass.string.toVariable(primitiveForm[i].content);
                    formList.unshift(primitiveForm[i]);
                }
                caculateFunc();
            });
        }
        else caculateFunc();
    });
};


hr.input_form_mobile.init = function (host) {
    if (window.ABSOL_DEBUG) console.trace(host);

    host.database = {};
    host.taskName = "m_input";
    /////////////////////////////////
    // Load người dùng, quốc gia, thành phố, form, kiểu dữ liệu
    var users = host.funcs.loadUsersList();
    var input_forms = host.funcs.loadFormList();
    var typelists = host.funcs.loadTypeList();
    var peoples = host.funcs.loadPeoplesList();
    var orgs = host.funcs.loadOrgsList();
    var employees = host.funcs.loadEmployeesList();
    var positions = host.funcs.loadPositionsList();
    var geographies = host.funcs.loadGeographiesList();
    host.isMobile = true;
    /////////////////////////////////
    Promise.all([users, input_forms, typelists, peoples, orgs, employees, positions, geographies]).then(function (result) {
        var content = {
            users: result[0],
            input_forms: result[1],
            typelists: result[2],
            peoples: result[3],
            orgs: result[4],
            employees: result[5],
            positions: result[6],
            geopos: result[7]
        };
        contentModule.makeDatabaseContent(host, content);
        contentModule.makeOrgsIndex(host);
        host.database.input_forms.items.forEach(function (elt) {
            elt.content = EncodingClass.string.toVariable(elt.content);
        });
        hr.input_form_mobile.loadFormConstructorToAssembler(host.database.input_forms.items, host.database.typelists.items).then(function(result){
            host.database.input_forms.items.sort(function (a, b) {
                if (absol.string.nonAccentVietnamese(a.name).toLowerCase() < absol.string.nonAccentVietnamese(b.name).toLowerCase()) return -1;
                if (absol.string.nonAccentVietnamese(a.name).toLowerCase() > absol.string.nonAccentVietnamese(b.name).toLowerCase()) return 1;
                return 0;
            });
            hr.input_form_mobile.emittor.emit('form_load', { formList: host.database.input_forms.items });
            host.formEditor = new absol.form.FormEditor({downloadPrefixFileName: "input_"});
            host.formEditor.getView()
            .addStyle({
                width: '100%',
                height: '100%'
            }).addTo(host.holder);
            host.formEditor.setContext("HOST", host);
            host.formEditor.start();
            host.holder.on('deactive', function () {
                host.formEditor.pause();
            });

            host.holder.on('active', function () {
                host.formEditor.start();
            });

            host.holder.on('remove', function () {
                host.formEditor.destroy();
            });
        });
    }, function (rj_mes) {
        console.log(rj_mes);
    });
}

VaKeR 2022