/**
 * 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();
};

/**
 * load common
 */
RF.loadCommon = function () {
    TEMPLATE.loadHeader('#includedHeader');
    TEMPLATE.loadConfirmModal('#includedConfirmModal');
};

/**
 * 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();
            COMMON.closeLoading();
        });
    } else {
        COMMON.avwScreenMove('index.html');
    }
};
