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 : 3.144.104.175


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

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

function cncl_data() {
    $('#page-container-body').load('work_entry_grid.php', function () {
        $('#btn_addn').show()
        $('#btn_save').hide()
        $('#btn_cncl').hide()
        load_grid_data(20, 1)
    })
}

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

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

function clrs_data() {
    $('#btn_addn').hide()
    $('#btn_save').show()
    $('#btn_cncl').show()
    $(function () {
        $('#txtworkdate').datepicker({ dateFormat: 'dd/mm/yy' })
    })
    $(function () {
        $('#txtstrtdate').datepicker({ dateFormat: 'dd/mm/yy' })
    })
    $(function () {
        $('#txtlastdate').datepicker({ dateFormat: 'dd/mm/yy' })
    })
    $(function () {
        $('#txtcompdate').datepicker({ dateFormat: 'dd/mm/yy' })
    })
}

function addn_data() {
    $('#page-container-body').load('work_entry_form.php', function () {
        clrs_data()
        document.getElementById('lblpagemode').innerHTML = 'Add'
        document.getElementById('txtpagemode').value = 'add'
        document.getElementById('txtworkdate').value = get_today_date()
        document.getElementById('txtworkname').focus()
    })
}

function edit_data(prim_data) {
    $('#page-container-body').load('work_entry_form.php', function () {
        clrs_data()
        document.getElementById('lblpagemode').innerHTML = 'Edit'
        document.getElementById('txtpagemode').value = 'edit'
        document.getElementById('txtworkname').focus()
        document.getElementById('txtworkdate').disabled = true
        document.getElementById('txtassncode').disabled = true
        document.getElementById('txtworkname').disabled = true

        $.ajax({
            type: 'POST',
            url: 'src/work_entry.php',
            data: {
                load_data: 'disp_data',
                work_code: prim_data,
            },
            cache: false,
            success: function (data) {
                var data = JSON.parse(data)
                document.getElementById('txtworkcode').value = data.fworkcode
                document.getElementById('txtassncode').value = data.fassncode
                document.getElementById('txtassncode').option = data.fassncode
                document.getElementById('txtrepthead').value = data.freptempl
                document.getElementById('txtworkdate').value = get_format_date(
                    data.fworkdate
                )
                document.getElementById('txtworkname').value = data.fworkname
                document.getElementById('txtworkplan').value = data.fworkplan

                document.getElementById('txtworktype').value = data.fworktype
                document.getElementById('txtclntcode').value = data.fclntcode
                document.getElementById('txtworkplce').value = data.fworkplce
                document.getElementById('txtworkhour').value = data.fworkhour
                document.getElementById('txtworkmins').value = data.fworkmins

                document.getElementById('txtworkdetl').value = data.fworkdetl
                document.getElementById('txtworkstat').value = data.fworkstat
                document.getElementById('txtworkremk').value = data.fworkremk
            },
            error: function (data) {
                $('#page-container-form').html('Error: ' + data)
            },
        })
    })
}

function dele_data(prim_data) {
    var r = confirm('Delete Record?')
    if (r == true) {
        $.ajax({
            type: 'POST',
            url: 'src/work_entry.php',
            data: {
                load_data: 'dele_data',
                dele_code: prim_data,
            },
            success: function (data) {
                load_grid_data(20, 1)
            },
        })
    }
}

function load_work_type() {
    $.ajax({
        type: 'POST',
        url: 'src/work_entry.php',
        data: {
            load_data: 'work_type',
        },
        cache: false,
        success: function (data) {
            $('#txtworktype').html(data)
        },
    })
}

function load_clnt_data() {
    $.ajax({
        type: 'POST',
        url: 'src/work_entry.php',
        data: {
            load_data: 'clnt_data',
        },
        cache: false,
        success: function (data) {
            $('#txtclntcode').html(data)
        },
    })
}

function load_work_plce() {
    $.ajax({
        type: 'POST',
        url: 'src/work_entry.php',
        data: {
            load_data: 'plce_data',
        },
        cache: false,
        success: function (data) {
            $('#txtworkplce').html(data)
        },
    })
}

function save_data() {
    $work_name = document.getElementById('txtworkname').value
    if ($work_name.length < 10) {
        alert('Please enter valid work name!')
        txtworkname.focus()
        return false
    }

    $work_detl = document.getElementById('txtworkdetl').value
    if ($work_detl.length < 10) {
        alert('Please enter valid / correct work details!')
        txtworkdetl.focus()
        return false
    }

    if (document.getElementById('txtworkdate').value == '') {
        alert('Please select work date!')
        txtworkdate.focus()
        return false
    }

    if (document.getElementById('txtworktype').value == 0) {
        alert('Please select work type!')
        txtworktype.focus()
        return false
    }

    if (document.getElementById('txtclntcode').value == 0) {
        alert('Please select client!')
        txtclntcode.focus()
        return false
    }

    if (document.getElementById('txtworkplce').value == 0) {
        alert('Please select work place!')
        txtworkplce.focus()
        return false
    }

    if (document.getElementById('txtworkhour').value == '') {
        alert('Please enter working hours!')
        txtworkhour.focus()
        return false
    }

    if (document.getElementById('txtworkmins').value == '') {
        alert('Please enter working minutes!')
        txtworkmins.focus()
        return false
    }

    $.ajax({
        type: 'POST',
        url: 'src/work_entry.php',
        dataType: 'json',
        data: {
            load_data: 'save_data',
            page_mode: document.getElementById('txtpagemode').value,
            work_code: document.getElementById('txtworkcode').value,
            work_date: document.getElementById('txtworkdate').value,
            rept_empl: document.getElementById('txtrepthead').value,
            work_name: document.getElementById('txtworkname').value,
            work_type: document.getElementById('txtworktype').value,
            work_plan: document.getElementById('txtworkplan').value,
            clnt_code: document.getElementById('txtclntcode').value,
            work_plce: document.getElementById('txtworkplce').value,
            work_hour: document.getElementById('txtworkhour').value,
            work_mins: document.getElementById('txtworkmins').value,
            work_detl: document.getElementById('txtworkdetl').value,
            work_stat: document.getElementById('txtworkstat').value,
            work_remk: document.getElementById('txtworkremk').value,
            assn_code: document.getElementById('txtassncode').value,
        },
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            hide_process()
            alert(data.mesg)
            if (data.stat == 'T') {
                addn_data()
            }
        },
        error: function (data) {
            $('#page-container-form').html('Error:' + data)
            hide_process()
        },
    })
}

function show_assignment() {
    if (document.getElementById('txtassncode').value == 0) {
        document.getElementById('txtworkname').disabled = false
        document.getElementById('txtworkname').value = ''
        document.getElementById('txtworkplan').disabled = false
    } else {
        document.getElementById('txtworkname').disabled = true
        document.getElementById('txtworkname').value = $(
            '#txtassncode option:selected'
        ).text()
        document.getElementById('txtworkplan').value = 'T'
        document.getElementById('txtworkplan').disabled = true
    }
}