0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.118.198.191


Current Path : /var/www/html/oums/js/
Upload File :
Current File : /var/www/html/oums/js/work_review.js

var view_ordr = ''
var work_empl = ''

function load_page(file_name) {
    load_page_data(
        window.location.href.substr(window.location.href.lastIndexOf('/') + 1)
    )
    cncl_data()
    load_grid_data(20, 1)
}

function cncl_data() {
    $('#btn_addn').show()
    $('#btn_save').hide()
    $('#btn_cncl').hide()
    $('#page-container-main').show()
    $('#page-container-grid').show()
    $('#page-container-form').hide()
    load_grid_data(20, 1)
    view_ordr = ''
    work_empl = ''
    document.getElementById('page-container-titl').innerHTML = 'Work Review'
}

function clrs_data() {
    $('#btn_addn').hide()
    $('#btn_save').show()
    $('#btn_cncl').show()
    $('#page-container-main').hide()
    $('#page-container-grid').hide()
    $('#page-container-form').show()
    document.getElementById('txtemplname').value = ''
    document.getElementById('txtdesnname').value = ''
    document.getElementById('txtworkdate').value = ''
    document.getElementById('txtworkstat').value = ''
    document.getElementById('txtworkname').value = ''
    document.getElementById('txttypedesc').value = ''
    document.getElementById('txtworkplce').value = ''
    document.getElementById('txtclntname').value = ''
    document.getElementById('txtworkdetl').value = ''
    document.getElementById('txtworkremk').value = ''
}

function load_grid_data(page_limt, page_numb) {
    $.ajax({
        type: 'POST',
        url: 'src/work_review.php',
        data: {
            load_data: 'grid_data',
            page_limt: page_limt,
            page_numb: page_numb,
            empl_code: document.getElementById('selemplcode').value,
            view_stat: document.getElementById('selviewstat').value,
            work_stat: document.getElementById('selworkstat').value,
            work_type: document.getElementById('selworktype').value,
            rept_head: document.getElementById('selreptempl').value,
            work_find: document.getElementById('txtworkfind').value,
        },
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            hide_process()
            $('#page-container-grid').html(data)
        },
        error: function (data) {
            hide_process()
            $('#page-container-grid').html('Error: ' + data)
        },
    })
}

function load_page_limt(page_limt) {
    load_grid_data(page_limt, 1)
}

function edit_data(prim_data) {
    clrs_data()
    document.getElementById('lblpagemode').innerHTML = 'Edit'
    document.getElementById('txtpagemode').value = 'edit'
    document.getElementById('txtworkdate').disabled = true
    document.getElementById('txtviewstat').focus()

    if (view_ordr == '') {
        var r = confirm('Review work entry employee wise?')
        if (r == true) {
            view_ordr = 'empl'
            work_empl = document.getElementById('selemplcode').value
            work_empl_name = $('#selemplcode option:selected').text()
            document.getElementById('page-container-titl').innerHTML =
                'Work Review [Employee wise - ' + work_empl_name + ']'
            alert('Work entry will be displayed employee wise')
        } else {
            view_ordr = 'date'
            work_empl_name = ''
            document.getElementById('page-container-titl').innerHTML =
                'Work Review [Date wise]'
            work_empl = ''
            alert('Work entry will be displayed date wise!')
        }
    }

    $.ajax({
        type: 'POST',
        url: 'src/work_review.php',
        data: {
            load_data: 'disp_data',
            work_code: prim_data,
        },
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            var data = JSON.parse(data)
            document.getElementById('page-container-titl').innerHTML =
                'Work Review [Employee wise - ' + work_empl_name + ']'
            document.getElementById('txtworkcode').value = data.fworkcode
            document.getElementById('txtemplname').value =
                data.femplname + ' [' + data.femplcode + ']'
            document.getElementById('txtdesnname').value = data.fempldesn
            document.getElementById('txtworkdate').value = get_format_date(
                data.fworkdate
            )
            document.getElementById('txtworkname').value = data.fworkname

            document.getElementById('txttypedesc').value = data.ftypedesc
            document.getElementById('txtclntname').value =
                data.fclntname + ' [' + data.fclntcode + ']'
            document.getElementById('txtworkplce').value = data.fworkplce

            document.getElementById('txtworkdetl').value = data.fworkdetl
            document.getElementById('txtworkstat').value = data.fworkstat
            document.getElementById('txtworkremk').value = data.fworkremk

            document.getElementById('txtviewdetl').value = data.fviewdetl
            document.getElementById('txtviewstat').value = data.fviewstat
            if (data.fviewtime != '' || data.fviewtime != 'null') {
                document.getElementById('txtviewtime').textContent =
                    ' Reviewed on [' + data.fviewtime + ']'
            }
            btnsavenext.disabled = false
            hide_process()
        },
        error: function (data) {
            $('#page-container-form').html('Error: ' + data)
        },
    })
}

function save_data() {
    if (
        document.getElementById('txtviewstat').value == '' ||
        document.getElementById('txtviewstat').value == 'PENDING'
    ) {
        alert('Please select review status!')
        txtviewstat.focus()
        return false
    }

    $.ajax({
        type: 'POST',
        url: 'src/work_review.php',
        dataType: 'json',
        data: {
            load_data: 'save_data',
            work_code: document.getElementById('txtworkcode').value,
            work_date: document.getElementById('txtworkdate').value,
            view_detl: document.getElementById('txtviewdetl').value,
            view_stat: document.getElementById('txtviewstat').value,
        },
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            alert(data.mesg)
            if (data.stat != 'F') {
                cncl_data()
                load_grid_data(20, 1)
            }
            hide_process()
        },
        error: function (data) {
            $('#page-container-form').html('Error: ' + data)
        },
    })
}

function save_data_next_disp() {
    if (document.getElementById('txtworkstat').value == '') {
        alert('Please select work status!')
        txtworkstat.focus()
        return false
    }
    btnsavenext.disabled = true
    $.ajax({
        type: 'POST',
        url: 'src/work_review.php',
        dataType: 'json',
        data: {
            load_data: 'save_data',
            work_code: document.getElementById('txtworkcode').value,
            work_date: document.getElementById('txtworkdate').value,
            view_detl: document.getElementById('txtviewdetl').value,
            work_stat: document.getElementById('txtworkstat').value,
            // view_stat: document.getElementById("txtviewstat").value,
        },
        cache: false,
        success: function (data) {
            if (data.mesg != '') {
                alert(data.mesg)
            }

            if (data.stat != 'F') {
                clrs_data()
                disp_next()
            }
        },
        error: function (data) {
            $('#page-container-form').html('Error: ' + data)
        },
    })
}

function disp_next() {
    $.ajax({
        type: 'POST',
        url: 'src/work_review.php',
        dataType: 'json',
        data: {
            load_data: 'disp_next',
            view_ordr: view_ordr,
            work_empl: work_empl,
        },
        cache: false,
        success: function (data) {
            clrs_data()
            edit_data(data.fworkcode)
        },
        error: function (data) {
            $('#page-container-form').html('Error: ' + data)
        },
    })
}

function show_view_remarks() {
    if (document.getElementById('txtworkstat').value == 'INCOMPLETE') {
        document.getElementById('txtviewdetl').value =
            'INCOMPLETE WORK, UPDATE ACTUAL WORK STATUS'
    }

    if (document.getElementById('txtworkstat').value == 'INVALID') {
        document.getElementById('txtviewdetl').value =
            'INVALID WORK, UPDATE VALID WORK DETAILS'
    }
}