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

 var RL = {};

 /**
  * init
  */
 RL.init = function () {
     //Check if user is logged in
     COMMON.showLoading();
     console.log("kdh check closeLoading RL.init1");
     COMMON.checkAuth(false);
     console.log("kdh check closeLoading RL.init2");
     console.log('ReportList init start');
     console.log("kdh check closeLoading RL.init3");
     RL.checkQuickReport();
     console.log("kdh check closeLoading RL.init4");
     RL.loadCommon();
     console.log("kdh check closeLoading RL.init5");
     RL.initTaskReportList();
     console.log("kdh check closeLoading RL.init6");
     COMMON.closeLoading();
     console.log("kdh check closeLoading RL.init7");
 };
 
 /**
  * load common
  */
 RL.loadCommon = function () {
     TEMPLATE.loadHeader('#includedHeader');
     TEMPLATE.loadConfirmModal('#includedConfirmModal');
     RL.initBreadcrumb();
     
 };
 
 /**
  * create breadcrumb menu on ReportList
  */
 RL.initBreadcrumb = function () {
     if (sessionStorage.activeHomePage == CONSTANT.PAGE_TAB.DASHBOARD) {
         navs = [
             {
                 titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
                 href: CONSTANT.URL_TREE_NAME.DASHBOARD,
             },
             {
                 titleLang: CONSTANT.PAGE_NAME.PICKUP,
                 href: CONSTANT.URL_TREE_NAME.PICKUP_NEW,
             },
             {
                 titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
             },
         ]
     } else {
         if (sessionStorage.getItem("pickUpType")) sessionStorage.removeItem("pickUpType");
         navs = [
             {
                 titleLang: CONSTANT.PAGE_NAME.OPERATION_LIST,
                 href: CONSTANT.URL_TREE_NAME.OPERATION_LIST,
             },
             {
                 titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
             },
         ]
     }
     TEMPLATE.loadMainNavsTitle('#includedMainTitle', CONSTANT.PAGE_NAME.REPORT_LIST, navs, RL.loadMainTitleCallback);
 }
 
 RL.isQuickReport;
 
 /**
  * check quick report
  */
 RL.checkQuickReport = 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.API.IS_QUICK_REPORT;
         COMMON.cmsAjax(
             url,
             params,
             false,
             function (result) {
                 RL.isQuickReport = result.isQuickReport;
             },
             function () {
                 COMMON.showAlert('msgOperationEmpty');
                 COMMON.avwScreenMove('index.html');
             },
         );
     } else {
         COMMON.showAlert('error');
         COMMON.avwScreenMove('index.html');
     }
 };
 
 /**
  * init task report list
  */
 RL.initTaskReportList = 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.TASK_REPORT_LIST;
         $('#reportList').load(url, params, function () {
             COMMON.closeLoading();
         });
     } else {
         COMMON.showAlert('error');
         COMMON.avwScreenMove('index.html');
     }
 };
 
 /**
  * load main title callcack
  */
 RL.loadMainTitleCallback = function () {
     //add dashboard setting item
     if (RL.isQuickReport) {
         var elmA = $('<div id="btnPdfPrint" onclick="RL.goPdfPrint();">');
         let elmImg = $('<img src="../common/img/icon_pdf.svg" alt="pdf出力" class="p-1 w-40px" data-toggle="tooltip" data-placement="bottom" title="pdf出力">');
         elmImg.attr('title', I18N.i18nText('reportList'));
         elmA.append(elmImg);
         $('#mainTitleHeader').after(elmA);
     }
 };
 
 /**
  * go pdf print
  */
 RL.goPdfPrint = function () {
     COMMON.avwScreenMove('pdfPrint.html');
 };
 