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

    TEMPLATE.loadHearder('#includedHeader');
    TEMPLATE.loadConfirmModal('#includedConfirmModal');
    RF.initFormView();
};

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

        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;
        if (reportStartDate) prarams.reportStartDate = reportStartDate;

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