/**
 * ReportForm function js
 * @since cms:1.4.3.2&1.4.3.3 web:1.0
 */

var RF = {};

/**
 * init
 */
RF.init = function () {
    //Check if user is logged in
    COMMON.checkAuth(false);

    RF.loadCommon();

    RF.initFormView();
    COMMON.closeLoading();
};

/**
 * load common
 */
RF.loadCommon = function () {
    $('#includedHeader').load('../common/html/header.html', function () {
        I18N.initi18n();
        HEADER.init();
    });
    $('#includedConfirmModal').load('../html/common/confirm-modal.html', function () {
        I18N.initi18n();
    });
};

/**
 * iinit form view
 */
RF.initFormView = function () {
    const urlParameterList = COMMON.getUrlParameter();
    const operationId = urlParameterList['operationId'];
    if (operationId) {
        let params = {};
        const taskKey = urlParameterList['taskKey'];
        const replyNo = urlParameterList['replyNo'];
        const processKey = urlParameterList['processKey'];
        const phaseNo = urlParameterList['phaseNo'];

        params.sid = COMMON.getSid();
        params.operationId = operationId;
        params.lang = I18N.getCurrentLanguage;
        if (taskKey) params.taskKey = taskKey;
        if (replyNo) params.replyNo = replyNo;
        if (processKey) params.processKey = processKey;
        if (phaseNo) params.phaseNo = phaseNo;

        const url = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath()) + CONSTANT.URL.CMS.HTML.BASE + CONSTANT.URL.CMS.HTML.LIST_REPORT_FORM;
        $('#report-form').load(url, params, function () {
            initPageLoad();
        });
    } else {
        COMMON.avwScreenMove('index.html');
    }
};
