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.137.219.221


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

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()
}

function clrs_data() {
    $('#btn_addn').hide()
    $('#btn_save').show()
    $('#btn_cncl').show()
    $('#page-container-main').hide()
    $('#page-container-grid').hide()
    $('#page-container-form').show()
    $(function () {
        $('#txtholidate').datepicker({ dateFormat: 'dd/mm/yy' })
    })
    document.getElementById('txtholidate').value = ''
    document.getElementById('txtholidesc').value = ''
}

function load_grid_data(page_limt, page_numb) {
    $.ajax({
        type: 'POST',
        url: 'src/holidays.php',
        data: {
            load_data: 'grid_data',
            page_limt: page_limt,
            page_numb: page_numb,
            dept_code: document.getElementById('seldeptcode').value,
            date_type: document.getElementById('seldatetype').value,
            holi_find: document.getElementById('txtholifind').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 addn_data() {
    clrs_data()
    document.getElementById('lblpagemode').innerHTML = 'Add'
    document.getElementById('txtpagemode').value = 'add'
    document.getElementById('txtholidate').value = get_today_date()
    document.getElementById('txtholidate').disabled = false
    document.getElementById('txtdeptcode').disabled = false
    load_dept_data('add')
    document.getElementById('txtdeptcode').focus()
}

function edit_data(prim_data) {
    clrs_data()
    document.getElementById('lblpagemode').innerHTML = 'Edit'
    document.getElementById('txtpagemode').value = 'edit'
    document.getElementById('txtholidate').disabled = true
    document.getElementById('txtdeptcode').disabled = true
    load_dept_data('edit')
    document.getElementById('txtholidesc').focus()
    $.ajax({
        type: 'POST',
        url: 'src/holidays.php',
        data: {
            load_data: 'disp_data',
            disp_code: prim_data,
        },
        cache: false,
        success: function (data) {
            var data = JSON.parse(data)
            document.getElementById('txtholicode').value = data.fholicode
            document.getElementById('txtdeptcode').value = data.fdeptcode
            document.getElementById('txtholidate').value = get_format_date(
                data.fholidate
            )
            document.getElementById('txtholidesc').value = data.fholidesc
        },
        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/holidays.php',
            dataType: 'json',
            data: {
                load_data: 'dele_data',
                dele_code: prim_data,
            },
            success: function (data) {
                if (data.stat == 'F') {
                    alert(data.mesg)
                }
                load_grid_data(20, 1)
            },
        })
    }
}

function save_data() {
    if (document.getElementById('txtdeptcode').value == '') {
        alert('Please select client!')
        txtdeptcode.focus()
        return false
    }

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

    if (document.getElementById('txtholidesc').value == '') {
        alert('Please enter holidate description!')
        txtholidesc.focus()
        return false
    }

    $.ajax({
        type: 'POST',
        url: 'src/holidays.php',
        dataType: 'json',
        data: {
            load_data: 'save_data',
            page_mode: document.getElementById('txtpagemode').value,
            holi_code: document.getElementById('txtholicode').value,
            dept_code: document.getElementById('txtdeptcode').value,
            holi_date: document.getElementById('txtholidate').value,
            holi_desc: document.getElementById('txtholidesc').value,
        },
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            hide_process()
            if (data.errs == 'T') {
                alert(data.mesg)
            } else {
                alert(data.mesg)
                cncl_data()
                load_grid_data(20, 1)
            }
        },
        error: function (data) {
            $('#page-container-form').html('Error: ' + data)
        },
    })
}

function load_dept_data(load_type) {
    $.ajax({
        type: 'POST',
        url: 'src/holidays.php',
        data: {
            load_data: 'dept_data',
            load_type: load_type,
            holi_date: document.getElementById('txtholidate').value,
        },
        cache: false,
        success: function (data) {
            $('#txtdeptcode').html(data)
        },
    })
}