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

var PP = {};

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

    PP.loadCommon();

    COMMON.closeLoading();
};

/**
 * load common
 */
PP.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,
        }
    ];
    TEMPLATE.loadMainNavsTitle('#includedMainTitle', CONSTANT.PAGE_NAME.PDF_PRINT, navs, PP.initPdfList);
};

/**
 * init pdf list
 */
PP.initPdfList = 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;
        $('#pdfPrintDiv').load(url, params);
    } else {
        COMMON.showAlert('error');
        COMMON.avwScreenMove('reportList.html');
    }
};
