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

var FS = {};

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

    FS.loadCommon();

    COMMON.closeLoading();
};

/**
 * load common
 */
FS.loadCommon = function () {
    TEMPLATE.loadHeader('#includedHeader');
    TEMPLATE.loadConfirmModal('#includedConfirmModal');
    let navs = [
        {
            titleLang: CONSTANT.PAGE_NAME.OPERATION_LIST,
            href: CONSTANT.URL_TREE_NAME.OPERATION_LIST,
        },
        {
            titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
            href: CONSTANT.URL_TREE_NAME.REPORT_LIST,
        },
        {
            titleLang: CONSTANT.PAGE_NAME.PDF_PRINT,
            href: CONSTANT.URL_TREE_NAME.PDF_PRINT,
        },
        {
            titleLang: CONSTANT.PAGE_NAME.FILE_SELECT,
        }
    ];
    TEMPLATE.loadMainNavsTitle('#includedMainTitle', CONSTANT.PAGE_NAME.FILE_SELECT, navs, FS.initFileList);
};

/**
 * init pdf list
 */
FS.initFileList = function () {
    if (sessionStorage.getItem("operationId")) {
        let params = {};
        params.sid = COMMON.getSid();
        params.operationId = sessionStorage.getItem("operationId");
        let url = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath()) + CONSTANT.URL.CMS.HTML.BASE + CONSTANT.URL.CMS.HTML.QUICK_REPORT_PRINT + CONSTANT.URL.CMS.HTML.PDF_FILE_SELECT;
        $('#fileSelectDiv').load(url, params);
    } else {
        COMMON.showAlert('error');
        COMMON.avwScreenMove('reportList.html');
    }
};