pickup.js 29.7 KB
Newer Older
NGO THI HONG committed
1 2 3 4
/**
 * pickup js in pickup.html
 * @since cms:1.4.3.2&1.4.3.3 web:1.0
 */
NGO THI HONG committed
5 6 7 8 9
var PICKUP = {};

PICKUP.newReportList;
PICKUP.continousWorkReport;
PICKUP.reportWithWarning;
10 11
PICKUP.pickupDefault = 'newReport';
PICKUP.pickupActive = 'newReport';
NGO THI HONG committed
12 13 14

PICKUP.countNewReportList = 0;
PICKUP.countContinousWorkReport = 0;
15
PICKUP.countReportWithWarning = 0;
NGO THI HONG committed
16

NGO THI HONG committed
17 18 19 20
/**
 * Report type
 */
PICKUP.REPORT_TYPE = {
21 22 23 24 25
    REPORTONLY: 0, //report only
    INSPECT: 1, //rountine
    WITHREPLY: 2, // report answer
    WORKFLOW: 3, // continuous
};
NGO THI HONG committed
26 27 28 29
/**
 * operation type
 */
PICKUP.OPERATION_TYPE = {
30 31 32 33
    LIST: '0',
    DRAWING: '1',
    VTOUR: '2',
    PDF: '3',
NGO THI HONG committed
34 35 36 37 38
};
/**
 * task type of report answer
 */
PICKUP.REPLYREPORT_TASK_TYPE = {
39 40 41
    REPORT: 0,
    ANSWER: 1,
};
NGO THI HONG committed
42

NGO THI HONG committed
43 44 45
/**
 * default Pickup List
 */
NGO THI HONG committed
46
PICKUP.defaultPickupList = {
47 48
    operationList: [],
};
NGO THI HONG committed
49

Kang Donghun committed
50
PICKUP.baseApiUrl = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath());
Kang Donghun committed
51 52 53
PICKUP.getNewReportListApiUrl = PICKUP.baseApiUrl + CONSTANT.URL.CMS.API.NEW_REPORT;
PICKUP.getContinuousWorkListApiUrl = PICKUP.baseApiUrl + CONSTANT.URL.CMS.API.WORKING_FLOW;
PICKUP.getReportWithWarningsListApiUrl = PICKUP.baseApiUrl + CONSTANT.URL.CMS.API.WARNING_WITH_REPORT;
NGO THI HONG committed
54 55

/**
56
 * Call get new report list api get data
Takumi Imai committed
57
 * @param callback
NGO THI HONG committed
58
 */
59
PICKUP.getNewreportListData = function (callback) {
NGO THI HONG committed
60 61 62
    let param = {
        sid: COMMON.getSid(),
    };
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    COMMON.cmsAjax(
        PICKUP.getNewReportListApiUrl,
        param,
        false,
        function (json) {
            if (callback) {
                callback(json);
            }
        },
        function () {
            console.log('DASHBOARD.getNewreportListData error');
            if (callback) {
                callback(PICKUP.defaultPickupList);
            }
        },
    );
NGO THI HONG committed
79 80
};
/**
81 82
 * Call get Continuous Work list api get data
 * @param {*} callback
NGO THI HONG committed
83 84 85 86 87
 */
PICKUP.getContinuousWorkListData = function (callback) {
    let param = {
        sid: COMMON.getSid(),
    };
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
    COMMON.cmsAjax(
        PICKUP.getContinuousWorkListApiUrl,
        param,
        false,
        function (json) {
            if (callback) {
                callback(json);
            }
        },
        function () {
            console.log('DASHBOARD.getContinuousWorkListData error');
            if (callback) {
                callback(PICKUP.defaultPickupList);
            }
        },
    );
NGO THI HONG committed
104 105 106
};

/**
107 108
 * Call get Report With Warnings list api get data
 * @param {*} callback
NGO THI HONG committed
109 110 111 112 113
 */
PICKUP.getReportWithWarningsListData = function (callback) {
    let param = {
        sid: COMMON.getSid(),
    };
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    COMMON.cmsAjax(
        PICKUP.getReportWithWarningsListApiUrl,
        param,
        false,
        function (json) {
            if (callback) {
                callback(json);
            }
        },
        function () {
            console.log('DASHBOARD.getReportWithWarningListData error');
            if (callback) {
                callback(PICKUP.defaultPickupList);
            }
        },
    );
NGO THI HONG committed
130 131
};
/**
132
 * Initialization pickup html
NGO THI HONG committed
133
 */
134 135
PICKUP.init = function () {
    //Check if user is logged in
136
    COMMON.showLoading();
137 138
    COMMON.checkAuth(false);
    console.log('PICKUP.init');
139

140
    sessionStorage.removeItem('pickUpType');
141
    sessionStorage.activeHomePage = CONSTANT.PAGE_TAB.DASHBOARD;
Kang Donghun committed
142
    TEMPLATE.loadHeader('#includedHeader');
143
    TEMPLATE.loadConfirmModal('#includedConfirmModal');
144 145 146 147 148 149 150 151 152 153
    navs = [
        {
            titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
            href: CONSTANT.URL_TREE_NAME.DASHBOARD,
        },
        {
            titleLang: CONSTANT.PAGE_NAME.PICKUP,
        },
    ];
    TEMPLATE.loadMainNavsTitle('#includedMainTitle', 'pickup', navs, null);
154 155
    PICKUP.initSettingActivePickup();
    PICKUP.settingPickup();
156
    COMMON.closeLoading();
157
};
158

NGO THI HONG committed
159 160 161
/**
 * Setting pickup data
 */
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
PICKUP.settingPickup = function () {
    DashboardSetting.getSettingData(function (settings) {
        $('#liTabNewReport').addClass('d-none');
        $('#liTabContinousWork').addClass('d-none');
        $('#liTabReportWithWarning').addClass('d-none');
        if (settings.newReport) {
            $('#liTabNewReport').removeClass('d-none');
            PICKUP.initNewReportTab();
        }
        if (settings.continousWork) {
            $('#liTabContinousWork').removeClass('d-none');
            PICKUP.initContinuosWorkTab();
        }
        if (settings.warningReport) {
            $('#liTabReportWithWarning').removeClass('d-none');
            PICKUP.initReportWithWarningsTab();
        }
NGO THI HONG committed
179
    });
180
};
NGO THI HONG committed
181 182 183
/**
 * init Setting Active Pickup
 */
184 185 186 187 188 189 190 191
PICKUP.initSettingActivePickup = function () {
    var urlParam = COMMON.getUrlParameter();
    if (urlParam.pickupActive == undefined || urlParam.pickupActive == '') {
        urlParam.pickupActive = PICKUP.pickupDefault;
    }
    PICKUP.pickupActive = urlParam.pickupActive;
    PICKUP.settingActivePickup(PICKUP.pickupActive);
};
NGO THI HONG committed
192

NGO THI HONG committed
193 194
/**
 * setting Active Pickup
195 196
 * @param {*} pickupActive
 * @returns
NGO THI HONG committed
197
 */
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
PICKUP.settingActivePickup = function (pickupActive) {
    PICKUP.pickupActive = pickupActive;
    $('#liTabNewReport a').removeClass('active');
    $('#liTabContinousWork a').removeClass('active');
    $('#liTabReportWithWarning a').removeClass('active');

    $('#tab-content-NewReport').removeClass('active show');
    $('#tab-content-ContinousWork').removeClass('active show');
    $('#tab-content-ReportWithWarnings').removeClass('active show');

    if (pickupActive == 'newReport') {
        $('#liTabNewReport a').addClass('active');
        $('#tab-content-NewReport').addClass('active show');
        return;
    }

    if (pickupActive == 'continousWork') {
        $('#liTabContinousWork a').addClass('active');
        $('#tab-content-ContinousWork').addClass('active show');
        return;
    }
219
    if (pickupActive == 'warningReport') {
220 221 222 223 224
        $('#liTabReportWithWarning a').addClass('active');
        $('#tab-content-ReportWithWarnings').addClass('active show');
        return;
    }
};
NGO THI HONG committed
225 226

/**
227 228
 * Initialization show not found pickup item html
 * @param {*} elementId
NGO THI HONG committed
229
 */
230 231 232 233 234 235 236 237 238 239 240 241
PICKUP.showNotFoundPickupItem = function (elementId) {
    $(elementId).removeClass();
    $(elementId).addClass('p-0 mt-3 card-list');
    let li = $("<li class='card mb-2 not-found'></li>");
    let div = $("<div class='text-dark mb-1 px-3 py-5 text-center m-auto'></div>");
    let imgdiv = $('<img src="../common/img/icon_not_found.svg" alt=\'' + I18N.i18nText('msgNotFound') + "' class='not-found-img mb-2'>");
    let childDiv = $("<div class='fs-9 text-secondary font-weight-bold'>" + I18N.i18nText('msgNotFound') + '</div>');
    div.append(imgdiv);
    div.append(childDiv);
    li.append(div);
    $(elementId).append(li);
};
NGO THI HONG committed
242

NGO THI HONG committed
243
/**
244 245 246
 * Initialization view pickup menu html
 * @param {*} elementId
 * @param {*} count
NGO THI HONG committed
247
 */
248 249 250 251 252
PICKUP.showCountDisplayPickupItem = function (elementId, count) {
    let span = $('<span>' + I18N.i18nText('display') + '</span>');
    $(elementId).append(count);
    $(elementId).append(span);
};
NGO THI HONG committed
253 254

/**
255
 * Initialization new report list html
NGO THI HONG committed
256
 */
257 258 259 260 261
PICKUP.initNewReportTab = function () {
    PICKUP.getNewreportListData(function (json) {
        PICKUP.createNewReportList(json.operationList);
    });
};
NGO THI HONG committed
262 263

/**
264
 * Initialization continuous work list html
NGO THI HONG committed
265
 */
266 267 268 269 270
PICKUP.initContinuosWorkTab = function () {
    PICKUP.getContinuousWorkListData(function (json) {
        PICKUP.createContinousWorkList(json.operationList);
    });
};
NGO THI HONG committed
271 272

/**
273
 * Initialization continuous work list html
NGO THI HONG committed
274
 */
275 276 277 278 279
PICKUP.initReportWithWarningsTab = function () {
    PICKUP.getReportWithWarningsListData(function (json) {
        PICKUP.createReportWithWarningList(json.operationList);
    });
};
NGO THI HONG committed
280 281 282

/**
 * sort New report operation list
283 284
 * @param {*} operationList
 * @returns
NGO THI HONG committed
285
 */
286 287 288 289 290 291 292 293
PICKUP.sortNewReportList = function (operationList) {
    operationList = operationList.sort(function (a, b) {
        if (a.operationId < b.operationId) return 1;
        if (a.operationId > b.operationId) return -1;
        return 0;
    });
    return operationList;
};
NGO THI HONG committed
294 295
/**
 * Implement new report list html
296 297
 * @param {*} operationListOld
 * @returns
NGO THI HONG committed
298
 */
299 300 301
PICKUP.createNewReportList = function (operationListOld) {
    if (typeof operationListOld === 'undefined' || operationListOld.length < 1) {
        PICKUP.showNotFoundPickupItem('#newReport-list');
NGO THI HONG committed
302 303 304 305
        $('#viewMenuNewReport').addClass('d-none');
        return;
    }

306 307 308 309 310
    let operationList = PICKUP.sortNewReportList(operationListOld);
    $('#viewMenuNewReport').removeClass('d-none');
    $('#newReport-list').empty();
    PICKUP.countNewReportList = 0;

NGO THI HONG committed
311
    $('#newReport-list').addClass('task-list view-content view-block');
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
    let classIcon;
    for (let i = 0; i < operationList.length; i++) {
        switch (operationList[i].reportType) {
            case PICKUP.REPORT_TYPE.REPORTONLY:
                classIcon = 'report';
                break;
            case PICKUP.REPORT_TYPE.INSPECT:
                classIcon = 'inspection';
                break;
            case PICKUP.REPORT_TYPE.WITHREPLY:
                classIcon = 'questionary';
                break;
            case PICKUP.REPORT_TYPE.WORKFLOW:
                classIcon = 'proccess';
                break;
        }
        let messageli = $("<li class='card mb-2' name = 'operationId_" + operationList[i].operationId + "' ></li>");
        let ahrefRequiredFlg = $(
330
            '<a href="javascript:PICKUP.sendReportFormFromNewReport (\'' + operationList[i].operationId + "');\" class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'></a>",
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
        );
        let divIcon = $("<div class='position-absolute translate-middle top-50 left-0 ml-3'>" + "<div class='type-icon'>" + "<span class='" + classIcon + "'></span>" + '</div></div>');

        let divText = $(
            "<div class='pl-5 h-100 d-flex align-items-center'>" + "<div class='w-100'>" + "<div class='fs-12 text-truncate'>" + operationList[i].operationName + '</div>' + '</div></div>',
        );
        ahrefRequiredFlg.append(divIcon);
        ahrefRequiredFlg.append(divText);
        messageli.append(ahrefRequiredFlg);

        $('#newReport-list').append(messageli);
        PICKUP.countNewReportList = PICKUP.countNewReportList + 1;
    }
    // show not found if
    if (PICKUP.countNewReportList == 0) {
        PICKUP.showNotFoundPickupItem('#newReport-list');
        $('#viewMenuNewReport').addClass('d-none');
        return;
NGO THI HONG committed
349
    }
350 351
    PICKUP.showCountDisplayPickupItem('#count-NewReport', PICKUP.countNewReportList);
};
NGO THI HONG committed
352 353
/**
 * sort continuous work operation list
354 355
 * @param {*} operationList
 * @returns
NGO THI HONG committed
356
 */
357
PICKUP.sortContinousWorkList = function (operationList) {
NGO THI HONG committed
358
    let newOperationList = [];
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
    for (let i = 0; i < operationList.length; i++) {
        if (operationList[i].reportType === 3) {
            if (typeof operationList[i].processList === 'undefined') continue;
            if (operationList[i].processList && operationList[i].processList.length != 0) {
                for (let j = 0; j < operationList[i].processList.length; j++) {
                    if (typeof operationList[i].processList[j].phaseList === 'undefined') continue;
                    for (let g = 0; g < operationList[i].processList[j].phaseList.length; g++) {
                        if (operationList[i].processList[j].phaseList[g].phaseStatus != 999) {
                            let item = {
                                reportType: operationList[i].reportType,
                                operationType: operationList[i].operationType,
                                phaseList: operationList[i].processList[j].phaseList,
                                processKey: operationList[i].processList[j].processKey,
                                permitCodeRequiredFlg: operationList[i].permitCodeRequiredFlg,
                                operationId: operationList[i].operationId,
                                contentId: operationList[i].contentId,
                                operationName: operationList[i].operationName,
                                taskCode: operationList[i].processList[j].taskCode,
                                taskKey: operationList[i].processList[j].taskKey,
                                taskName: operationList[i].processList[j].taskName,
                                updateDate: operationList[i].processList[j].phaseList[g].updateDate,
                                phaseNo: operationList[i].processList[j].phaseList[g].phaseNo,
                                phaseName: operationList[i].processList[j].phaseList[g].phaseName,
                            };
NGO THI HONG committed
383 384
                            newOperationList.push(item);
                        }
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
                    }
                }
            }
        }
    }
    newOperationList = newOperationList.sort(function (a, b) {
        if (!a.updateDate) {
            a.updateDate = '1900-01-01 00:00:00';
        }
        if (!b.updateDate) {
            b.updateDate = '1900-01-01 00:00:00';
        }
        if (a.updateDate < b.updateDate) return 1;
        if (a.updateDate > b.updateDate) return -1;
        return 0;
    });
    //console.log("newOperationList: " + JSON.stringify(newOperationList));
    return newOperationList;
};
NGO THI HONG committed
404

NGO THI HONG committed
405 406
/**
 * Implement continous work html
407 408
 * @param {*} operationListOld
 * @returns
NGO THI HONG committed
409
 */
410 411 412
PICKUP.createContinousWorkList = function (operationListOld) {
    if (typeof operationListOld === 'undefined' || operationListOld.length < 1) {
        PICKUP.showNotFoundPickupItem('#continousWork-list');
NGO THI HONG committed
413
        $('#viewMenuContinuousWork').addClass('d-none');
NGO THI HONG committed
414 415
        return;
    }
NGO THI HONG committed
416

NGO THI HONG committed
417 418
    let operationList = PICKUP.sortContinousWorkList(operationListOld);
    $('#viewMenuContinuousWork').removeClass('d-none');
419
    $('#continousWork-list').empty();
NGO THI HONG committed
420 421 422

    PICKUP.countContinousWorkReport = 0;

423
    $('#continousWork-list').addClass('task-list view-content view-block');
NGO THI HONG committed
424 425

    for (let i = 0; i < operationList.length; i++) {
426 427 428
        let directKey = operationList[i].processKey;
        if (operationList[i].operationType == PICKUP.OPERATION_TYPE.VTOUR || operationList[i].operationType == PICKUP.OPERATION_TYPE.PDF) {
            directKey = operationList[i].taskKey;
NGO THI HONG committed
429
        }
430 431 432 433
        let messageli = $("<li class='card mb-2' id = 'list_" + operationList[i].processKey + '$' + operationList[i].phaseNo + "'></li>");

        let ahrefRequiredFlg;
        if (operationList[i].permitCodeRequiredFlg == 1) {
434
            ahrefRequiredFlg = $("<a href=\"javascript:COMMON.showAlert('onlyRfid');\" class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'></a>");
435 436 437 438 439 440 441 442 443 444 445 446
        } else {
            ahrefRequiredFlg = $(
                '<a href="javascript:PICKUP.sendReportFormFromContinuousWork (\'' +
                    operationList[i].operationId +
                    "','" +
                    operationList[i].taskKey +
                    "','" +
                    operationList[i].processKey +
                    "'," +
                    operationList[i].phaseNo +
                    ");\"  class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'></a>",
            );
NGO THI HONG committed
447 448
        }

449 450 451 452 453 454 455 456 457 458
        let divProccess = $("<div class='position-absolute translate-middle top-50 left-0 ml-3'><div class='type-icon'><span class='proccess'></span></div></div>");

        let divInfor = $("<div class='pl-5 h-100 d-flex align-items-center'></div>");
        let divChildInfor = $("<div class='w-100'></div>");
        let divOperationName = $("<div class='fs-8 bg-dark10 px-2 py-1 mr-2 rounded mb-1 w-fit-content text-truncate mw-100'>" + operationList[i].phaseName + '</div>');

        let divProcessName = $("<div class='fs-12 text-truncate'>" + operationList[i].operationName + '</div>');
        let divReportInfor = $("<div class='d-flex justify-content-between align-items-center'></div>");
        let divReportName = $("<div class='fs-10 text-truncate'>" + operationList[i].taskName + '</div>');
        let divReportCode = $("<div class='fs-8 text-secondary text-truncate'>" + operationList[i].taskCode + '</div>');
NGO THI HONG committed
459

460 461
        divReportInfor.append(divReportName);
        divReportInfor.append(divReportCode);
NGO THI HONG committed
462

463 464 465
        divChildInfor.append(divOperationName);
        divChildInfor.append(divProcessName);
        divChildInfor.append(divReportInfor);
NGO THI HONG committed
466

467
        divInfor.append(divChildInfor);
NGO THI HONG committed
468

469 470 471
        ahrefRequiredFlg.append(divProccess);
        ahrefRequiredFlg.append(divInfor);
        messageli.append(ahrefRequiredFlg);
NGO THI HONG committed
472

473
        $('#continousWork-list').append(messageli);
NGO THI HONG committed
474 475
        PICKUP.countContinousWorkReport = PICKUP.countContinousWorkReport + 1;
    }
476 477 478 479 480 481 482 483

    // show not found if
    if (PICKUP.countContinousWorkReport == 0) {
        PICKUP.showNotFoundPickupItem('#continousWork-list');
        $('#viewMenuContinuousWork').addClass('d-none');
        return;
    }
    PICKUP.showCountDisplayPickupItem('#count-ContinuousWork', PICKUP.countContinousWorkReport);
NGO THI HONG committed
484 485 486
};
/**
 * sort report with warnings list
487 488
 * @param {*} operationList
 * @returns
NGO THI HONG committed
489
 */
490
PICKUP.sortWarningList = function (operationList) {
NGO THI HONG committed
491
    let newOperationList = [];
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
    for (let i = 0; i < operationList.length; i++) {
        if (typeof operationList[i].warningReportList === 'undefined') continue;
        if (operationList[i].warningReportList && operationList[i].warningReportList.length != 0) {
            for (let j = 0; j < operationList[i].warningReportList.length; j++) {
                let item = {
                    reportType: operationList[i].reportType,
                    operationType: operationList[i].operationType,
                    permitCodeRequiredFlg: operationList[i].permitCodeRequiredFlg,
                    operationId: operationList[i].operationId,
                    contentId: operationList[i].contentId,
                    operationName: operationList[i].operationName,
                    taskCode: operationList[i].warningReportList[j].taskCode,
                    taskKey: operationList[i].warningReportList[j].taskKey,
                    taskName: operationList[i].warningReportList[j].taskName,
                    taskType: operationList[i].warningReportList[j].taskType,
                    updateDate: operationList[i].warningReportList[j].updateDate,
                    reportStartDateString: operationList[i].warningReportList[j].reportStartDateString,
                    reportEndDateString: operationList[i].warningReportList[j].reportEndDateString,
                    processKey: operationList[i].warningReportList[j].processKey,
                    phaseNo: operationList[i].warningReportList[j].phaseNo,
                    phaseName: operationList[i].warningReportList[j].phaseName,
                };
                newOperationList.push(item);
            }
        }
    }
    newOperationList = newOperationList.sort(function (a, b) {
        if (!a.updateDate) {
            a.updateDate = '1900-01-01 00:00:00';
        }
        if (!b.updateDate) {
            b.updateDate = '1900-01-01 00:00:00';
        }
        if (a.updateDate < b.updateDate) return 1;
        if (a.updateDate > b.updateDate) return -1;
        return 0;
    });
    //console.log("newOperationList: " + JSON.stringify(newOperationList));
    return newOperationList;
};
NGO THI HONG committed
532

NGO THI HONG committed
533 534
/**
 * init Warning Report With ReportOnly Type
535 536
 * @param {*} report
 * @returns
NGO THI HONG committed
537
 */
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
PICKUP.initWarningReportWithReportOnlyType = function (report) {
    let ele = $(
        "<li class='card mb-2'>" +
            '<a href="javascript:PICKUP.sendReportFormFromWarningReport (\'' +
            report.operationId +
            "'," +
            PICKUP.REPORT_TYPE.REPORTONLY +
            ",'" +
            report.taskKey +
            "', null,null,null);\"  class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'>" +
            "<div class='position-absolute translate-middle top-50 left-0 ml-3'>" +
            "<div class='type-icon'><span class='report'></span></div></div>" +
            "<div class='pl-5 h-100 d-flex align-items-center'><div class='w-100'>" +
            "<div class='fs-12 text-truncate'>" +
            report.operationName +
            '</div>' +
            "<div class='d-flex justify-content-between align-items-center'>" +
            "<div class='fs-10 text-truncate'>" +
            report.taskName +
            '</div>' +
            "<div class='fs-8 text-secondary text-truncate'> " +
            report.taskCode +
            '</div>' +
            '</div></div></div></a></li>',
    );
    return ele;
};

Takumi Imai committed
566 567 568 569 570
/**
 * init Warning Report With Inspect Type
 * @param {*} report
 * @returns
 */
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
PICKUP.initWarningReportWithInspectType = function (report) {
    let ele = $(
        "<li class='card mb-2'>" +
            '<a href="javascript:PICKUP.sendReportFormFromWarningReport (\'' +
            report.operationId +
            "'," +
            PICKUP.REPORT_TYPE.INSPECT +
            ",'" +
            report.taskKey +
            "', null,null,null);\"   class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'>" +
            "<div class='position-absolute translate-middle top-50 left-0 ml-3'>" +
            "<div class='type-icon'><span class='inspection'></span></div></div>" +
            "<div class='pl-5 h-100 d-flex align-items-center'><div class='w-100'>" +
            "<div class='fs-12 text-truncate'>" +
            report.operationName +
            '</div>' +
            "<div class='d-flex justify-content-between align-items-center'>" +
            "<div class='fs-10 text-truncate'></div>" +
            "<div class='fs-8 text-secondary text-truncate'>" +
            PICKUP.getInspectDate(report.reportStartDateString) +
            ' ~ ' +
            PICKUP.getInspectDate(report.reportEndDateString) +
            '</div></div></div></div></a></li>',
    );
    return ele;
};
NGO THI HONG committed
597 598
/**
 * init Warning Report With AnswerReport Type
599 600 601
 * @param {*} report
 * @param {*} reportTypeMsg
 * @returns
NGO THI HONG committed
602
 */
603
PICKUP.initWarningReportWithAnswerReportType = function (report, reportType, reportTypeMsg) {
604 605 606 607 608 609
    let ele = $(
        "<li class='card mb-2'>" +
            '<a href="javascript:PICKUP.sendReportFormFromWarningReport (\'' +
            report.operationId +
            "'," +
            PICKUP.REPORT_TYPE.WITHREPLY +
610 611 612
            ",'" +
            report.taskKey +
            "', null,null," +
613
            reportType +
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
            ");\" class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'>" +
            "<div class='position-absolute translate-middle top-50 left-0 ml-3'><div class='type-icon'>" +
            "<span class='questionary'></span></div></div><div class='pl-5 h-100 d-flex align-items-center'><div class='w-100'>" +
            "<div class='fs-8 bg-dark10 px-2 py-1 mr-2 rounded mb-1 w-fit-content text-truncate mw-100'>" +
            reportTypeMsg +
            '</div>' +
            "<div class='fs-12 text-truncate'>" +
            report.operationName +
            '</div>' +
            "<div class='d-flex justify-content-between align-items-center'>" +
            "<div class='fs-10 text-truncate'>" +
            report.taskName +
            '</div>' +
            "<div class='fs-8 text-secondary text-truncate'>" +
            report.taskCode +
            '</div>' +
            '</div></div></div></a></li>',
    );
    return ele;
};
NGO THI HONG committed
634

NGO THI HONG committed
635 636
/**
 * init Warning Report With Continuous Report Type
637 638
 * @param {*} report
 * @returns
NGO THI HONG committed
639
 */
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
PICKUP.initWarningReportWithContinuousReportType = function (report) {
    let directKey = report.processKey;
    if (report.operationType == PICKUP.OPERATION_TYPE.VTOUR || report.operationType == PICKUP.OPERATION_TYPE.PDF) {
        directKey = report.taskKey;
        if (report.phaseNo > 1) {
            //find taskKey of phaseNo 1
            for (let k = 0; k < operationList.length; k++) {
                if (operationList[k].phaseNo == 1 && operationList[k].processKey == report.processKey) {
                    directKey = operationList[k].taskKey;
                    break;
                }
            }
        }
    }
    let ele = $(
        "<li class='card mb-2'>" +
            '<a href="javascript:PICKUP.sendReportFormFromWarningReport (\'' +
            report.operationId +
            "'," +
            PICKUP.REPORT_TYPE.WORKFLOW +
            ",null,'" +
            report.processKey +
            "' ,'" +
            report.phaseNo +
            "',null);\"  class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'>" +
            "<div class='position-absolute translate-middle top-50 left-0 ml-3'>" +
            "<div class='type-icon'><span class='proccess'></span></div></div>" +
            "<div class='pl-5 h-100 d-flex align-items-center'><div class='w-100'>" +
            "<div class='fs-8 bg-dark10 px-2 py-1 mr-2 rounded mb-1 w-fit-content text-truncate mw-100'>" +
            report.phaseName +
            '</div>' +
            "<div class='fs-12 text-truncate'>" +
            report.operationName +
            '</div>' +
            "<div class='d-flex justify-content-between align-items-center'>" +
            "<div class='fs-10 text-truncate'>" +
            report.taskName +
            '</div>' +
            "<div class='fs-8 text-secondary text-truncate'>" +
            report.taskCode +
            '</div>' +
            '</div></div></div></a></li>',
    );
    return ele;
};
NGO THI HONG committed
685 686
/**
 * create Report With Warnings List html
687 688
 * @param {*} operationListOld
 * @returns
NGO THI HONG committed
689
 */
690
PICKUP.createReportWithWarningList = function (operationListOld) {
NGO THI HONG committed
691
    if (typeof operationListOld === 'undefined' || operationListOld.length < 1) {
692
        PICKUP.showNotFoundPickupItem('#reportWithWarnings-list');
NGO THI HONG committed
693 694 695 696
        $('#viewMenuReportWithWarnings').addClass('d-none');
        return;
    }

697 698 699 700
    let operationList = PICKUP.sortWarningList(operationListOld);
    $('#viewMenuReportWithWarnings').removeClass('d-none');
    $('#reportWithWarnings-list').empty();
    PICKUP.countReportWithWarning = 0;
NGO THI HONG committed
701

702
    $('#reportWithWarnings-list').addClass('task-list view-content view-block');
NGO THI HONG committed
703

704 705
    const msgLevelReport = I18N.i18nText('reportLevelReport');
    const msgLevelAnswer = I18N.i18nText('reportLevelAnswer');
NGO THI HONG committed
706
    for (let i = 0; i < operationList.length; i++) {
707 708 709 710 711 712 713 714 715 716
        let operationNameLi;
        switch (operationList[i].reportType) {
            case PICKUP.REPORT_TYPE.REPORTONLY:
                operationNameLi = PICKUP.initWarningReportWithReportOnlyType(operationList[i]);
                break;
            case PICKUP.REPORT_TYPE.INSPECT:
                operationNameLi = PICKUP.initWarningReportWithInspectType(operationList[i]);
                break;
            case PICKUP.REPORT_TYPE.WITHREPLY: // report answer
                if (operationList[i].taskType == PICKUP.REPLYREPORT_TASK_TYPE.REPORT) {
717
                    operationNameLi = PICKUP.initWarningReportWithAnswerReportType(operationList[i], PICKUP.REPLYREPORT_TASK_TYPE.REPORT, msgLevelReport);
718
                } else {
719
                    operationNameLi = PICKUP.initWarningReportWithAnswerReportType(operationList[i], PICKUP.REPLYREPORT_TASK_TYPE.ANSWER, msgLevelAnswer);
720 721 722 723 724 725 726 727 728 729 730 731 732 733
                }
                break;
            case PICKUP.REPORT_TYPE.WORKFLOW: // continouswork
                operationNameLi = PICKUP.initWarningReportWithContinuousReportType(operationList[i]);
                break;
        }
        $('#reportWithWarnings-list').append(operationNameLi);
        PICKUP.countReportWithWarning = PICKUP.countReportWithWarning + 1;
    }
    // show not found if
    if (PICKUP.countReportWithWarning == 0) {
        PICKUP.showNotFoundPickupItem('#reportWithWarnings-list');
        $('#viewMenuReportWithWarnings').addClass('d-none');
        return;
NGO THI HONG committed
734
    }
735
    PICKUP.showCountDisplayPickupItem('#count-ReportWithWarnings', PICKUP.countReportWithWarning);
NGO THI HONG committed
736 737
};

NGO THI HONG committed
738 739
/**
 * get Inspect Date format
740 741
 * @param {*} dateString
 * @returns
NGO THI HONG committed
742
 */
743 744 745 746
PICKUP.getInspectDate = function (dateString) {
    let date = new Date(dateString);
    return date.getFullYear() + '/' + ('0' + (date.getMonth() + 1)).slice(-2) + '/' + ('0' + date.getDate()).slice(-2);
};
747 748 749

/**
 * send data to open report form from New report pickup
Takumi Imai committed
750
 * @param operarionId
751
 * @returns
752
 */
753
PICKUP.sendReportFormFromNewReport = function (operationId) {
754
    //Transition to the report form or operation list screen
755 756
    sessionStorage.setItem('pickUpType', CONSTANT.PICK_UP_TYPE.NEW_REPORT);
    sessionStorage.setItem('operationId', operationId);
757
    const url = 'reportForm.html?operationId=' + operationId;
758
    COMMON.avwScreenMove(url);
759
};
760 761 762

/**
 * send data to open report form of event click continuous work operation report
Takumi Imai committed
763 764 765 766
 * @param {*} operationId
 * @param {*} taskKey
 * @param {*} processKey
 * @param {*} phaseNo
767
 */
768 769
PICKUP.sendReportFormFromContinuousWork = function (operationId, taskKey, processKey, phaseNo) {
    //Transition to the report form or operation list screen
770 771
    sessionStorage.setItem('pickUpType', CONSTANT.PICK_UP_TYPE.CONTINOUS_WORK);
    sessionStorage.setItem('operationId', operationId);
772 773
    const url = 'reportForm.html?operationId=' + operationId + '&processKey=' + processKey + '&phaseNo=' + phaseNo;
    COMMON.avwScreenMove(url);
774
};
775 776

/**
Takumi Imai committed
777 778 779 780 781 782 783
 * send data to open report form of event click warning operation reports
 * @param {*} operationId
 * @param {*} reportType
 * @param {*} taskKey
 * @param {*} processKey
 * @param {*} phaseNo
 * @param {*} replyNo
784
 */
785
PICKUP.sendReportFormFromWarningReport = function (operationId, reportType, taskKey, processKey, phaseNo, replyNo) {
786
    //Transaction to the report form or operation list screen
787 788
    sessionStorage.setItem('pickUpType', CONSTANT.PICK_UP_TYPE.WARNING_REPORT);
    sessionStorage.setItem('operationId', operationId);
789
    let url = 'reportForm.html?operationId=' + operationId;
790 791
    switch (reportType) {
        case PICKUP.REPORT_TYPE.REPORTONLY:
792
            url += '&taskKey=' + taskKey;
793 794
            break;
        case PICKUP.REPORT_TYPE.INSPECT:
795
            url += '&taskKey=' + taskKey;
796 797
            break;
        case PICKUP.REPORT_TYPE.WITHREPLY:
798 799
            url += '&taskKey=' + taskKey;
            url += '&replyNo=' + replyNo;
800 801
            break;
        case PICKUP.REPORT_TYPE.WORKFLOW:
802 803
            url += '&processKey=' + processKey;
            url += '&phaseNo=' + phaseNo;
804 805 806
            break;
    }

807
    COMMON.avwScreenMove(url);
808
};