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


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

function load_page_data(file_name) {
    file_name = file_name.replace('#', '')
    $.ajax({
        type: 'POST',
        url: 'src/sys_mainphp.php',
        data: {
            load_data: 'page_data',
            file_name: file_name,
        },
        cache: false,
        success: function (data) {
            var data = JSON.parse(data)
            $('#page-container-titl').html(data.titl)
            $('#page-container-link').html(data.lnks)
            $('#btn_addn').show()
            $('#btn_save').hide()
            $('#btn_cncl').hide()
        },
    })
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + '=')
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1
            c_end = document.cookie.indexOf(';', c_start)
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ''
}

function logout() {
    $.ajax({
        url: 'src/logout.php',
        type: 'POST',
        success: function () {
            document.cookie = 'modeid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'emplid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'deptid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'userid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'nameid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'typeid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'noteid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'workid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            document.cookie = 'apprid=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            window.location.href = ''
        },
    })
}

function get_today_date() {
    var today = new Date()
    var dd = today.getDate()
    var mm = today.getMonth() + 1 //January is 0!
    var yyyy = today.getFullYear()

    if (dd < 10) {
        dd = '0' + dd
    }
    if (mm < 10) {
        mm = '0' + mm
    }

    var today = dd + '/' + mm + '/' + yyyy
    return today
}

function get_format_date(date) {
    if (
        date == '0000-00-00' ||
        date == '1970-01-01' ||
        date == 'null' ||
        date == '' ||
        date == null
    ) {
        var date = '00' + '/' + '00' + '/' + '0000'
    } else {
        var date = new Date(date)
        var days = date.getDate()
        var mnth = date.getMonth() + 1 //January is 0!
        var year = date.getFullYear()

        if (days < 10) {
            days = '0' + days
        }
        if (mnth < 10) {
            mnth = '0' + mnth
        }

        var date = days + '/' + mnth + '/' + year
    }
    return date
}

function set_format_date(date) {
    if (
        date == '0000-00-00' ||
        date == '1970-01-01' ||
        date == 'null' ||
        date == '' ||
        date == null
    ) {
        var date = '00' + '/' + '00' + '/' + '0000'
    } else {
        var date = new Date(date)
        var days = date.getDate()
        var mnth = date.getMonth() + 1 //January is 0!
        var year = date.getFullYear()

        if (days < 10) {
            days = '0' + days
        }
        if (mnth < 10) {
            mnth = '0' + mnth
        }

        var date = days + '/' + mnth + '/' + year
    }
    return date
}

function numbers_only(event) {
    var key = event.keyCode

    if (key == 8 || key == 9 || key == 13) {
        //backspace, tab, enter
        return true
    } else if (key == 16 || key == 17 || key == 18 || key == 19) {
        //shift, contrl, alt, pause / break
        return true
    } else if (key == 27) {
        //escape
        return true
    } else if (key >= 33 && key <= 40) {
        //page up, page down, end, home, left arrow, up arrow, right arrow, down arrow
        return true
    } else if (key == 46) {
        //delete
        return true
    } else if (key >= 48 && key <= 57) {
        //numbers
        return true
    } else if (
        (key == 65 || key == 67 || key == 86) &&
        (event.ctrlkey === true || event.metakey === true)
    ) {
        //Ctrl+A,Ctrl+C,Ctrl+V, Command+A
        return true
    } else if (key >= 96 && key <= 105) {
        //num pad
        return true
    } else if (key >= 112 && key <= 123) {
        //function
        return true
    } else {
        return false
    }
}

function decimals_only(event) {
    var key = event.keyCode
    if (key == 8 || key == 9 || key == 13) {
        //backspace, tab, enter
        return true
    } else if (key == 16 || key == 17 || key == 18 || key == 19) {
        //shift, contrl, alt, pause / break
        return true
    } else if (key == 27) {
        //escape
        return true
    } else if (key >= 33 && key <= 40) {
        //page up, page down, end, home, left arrow, up arrow, right arrow, down arrow
        return true
    } else if (key == 46) {
        //delete
        return true
    } else if (key >= 48 && key <= 57) {
        //numbers
        return true
    } else if (key >= 96 && key <= 105) {
        //num pad
        return true
    } else if (key == 110) {
        //decimal
        return true
    } else if (key >= 112 && key <= 123) {
        //function
        return true
    } else {
        return false
    }
}

function show_password_change() {
    $('#user-password-change').load('user_password_change.php', function () {
        $('#txtusermail').focus()
        document.getElementById('txtusermail').value = ''
        document.getElementById('txtusercode').value = ''
    })
    $('#user-password-change').css('visibility', 'visible')
    $('#user-password-change').height($(document).height())
    $('#user-password-change').fadeIn('fast')
}

function send_password_change() {
    if (document.getElementById('txtusermail').value == '') {
        alert('Please enter your mail id!')
        txtusermail.focus()
        return false
    }

    if (document.getElementById('txtusercode').value == '') {
        alert('Please enter verification code!')
        txtusercode.focus()
        return false
    }

    if (
        document.getElementById('txtusercode').value !=
        document.getElementById('txtvericode').value
    ) {
        alert('Invalid verification code!')
        txtusercode.focus()
        return false
    }

    $('#user-password-change').fadeOut('slow')
}

function cncl_password_change() {
    $('#user-password-change').fadeOut('slow')
}

function load_home_page() {
    if (!getCookie('userid')) {
        alert('Please login again!')
        window.location.href = 'index.html'
    } else {
        // if (!getCookie("modeid")) {
        // 	popup_mode_page();
        // }

        if (!getCookie('workid')) {
            popup_work_entry()
            popup_work_review()
        }

        if (!getCookie('noteid')) {
            popup_empl_events()
        }

        if (!getCookie('apprid')) {
            const d = new Date()
            if (d.getDate() > 24) {
                popup_empl_salary()
            }

            if (d.getDate() < 15) {
                popup_empl_salary()
            }
        }
        load_note_count()
        load_home_dashboard()
    }
}

// function load_empl_fields() {
// 	$("#home-page-modal-body").load("src/home_flash.php", function () {
// 		$("#home-page-modal-title").html("Update mandatory fields");
// 		$("#myModal").modal({ show: true });
// 		document.cookie = "noteid=noteid; max-age=" + 1 * 12 * 60 * 60;
// 	});
// }

function popup_mode_page() {
    $('#home-page-modal-body1').load('src/sys_module.php', function () {
        $('#home-page-modal-title1').html('Select Module')
        $('#myModal1').modal({ show: true })
    })
}

function popup_empl_events() {
    $('#home-page-modal-body2').load('src/popup_empl_events.php', function () {
        $('#home-page-modal-title2').html("Today's Events")
        $('#myModal2').modal({ show: true })
        document.cookie = 'noteid=noteid; max-age=' + 1 * 12 * 60 * 60
    })
}

function popup_work_entry() {
    $('#home-page-modal-body3').load('src/popup_work_entry.php', function () {
        $('#home-page-modal-title3').html('Work Entry Pending')
        $('#myModal3').modal({ show: true })
        document.cookie = 'workid=workid; max-age=' + 1 * 12 * 60 * 60
    })
}

function popup_empl_salary() {
    $('#home-page-modal-body4').load('src/popup_empl_salary.php', function () {
        $('#home-page-modal-title4').html('Salary Appraisal')
        $('#myModal4').modal({ show: true })
        document.cookie = 'apprid=apprid; max-age=' + 1 * 12 * 60 * 60
    })
}
function popup_work_review() {
    $('#home-page-modal-body5').load('src/popup_work_review.php', function () {
        $('#home-page-modal-title5').html('Work Entry Review Pending')
        $('#myModal5').modal({ show: true })
        document.cookie = 'workid=workid; max-age=' + 1 * 12 * 60 * 60
    })
}

function cncl_mode_page() {
    $('#page-header-mode').fadeOut('slow')
}

function sele_mode_page(mode_code) {
    document.cookie = 'modeid=' + mode_code
    $('#page-header-mode').fadeOut('fast')
    window.location.href = 'mainpage.php'
}

function show_process() {
    $('#page-process').css('visibility', 'visible')
    $('#page-process').height($(document).height())
    $('#page-process').fadeIn('slow')
}

function hide_process() {
    $('#page-process').css('visibility', 'hidden')
    $('#page-process').height(0)
    $('#page-process').fadeOut('slow')
}

function load_note_count() {
    $.ajax({
        type: 'POST',
        url: 'src/home_note_count.php',
        dataType: 'json',
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            $('#home_attn_entr').html(data.attn)
            $('#home_expn_stat').html(data.expn)
            $('#home_task_remn').html(data.task)
            $('#home_work_entr').html(data.work)
            $('#home_work_view').html(data.view)
            $('#home_empl_move').html(data.move)
            $('#home_empl_salr').html(data.salr)
            $('#home_evnt_remn').html(data.bday)

            hide_process()
        },
        error: function (data) {
            $('#home-content-note').html('Error: ' + data)
        },
    })
}

function load_home_dashboard() {
    //var mydash =  setInterval(() => $("#home-content-page").load("src/home_dashboard.php"), 5000);

    $('#home-content-page').load('src/home_dashboard.php')
}

function load_home_clnt() {
    $('#home-content-page').load('src/home_clients.php')
}

function load_home_attn() {
    $('#home-content-page').load('src/home_attendance.php')
}

function load_home_empl() {
    $('#home-content-page').load('src/home_employees.php')
}

function load_home_expn() {
    $('#home-content-page').load('src/home_expenses.php')
}

function load_home_work() {
    $('#home-content-page').load('src/home_work_entry.php')
}

function load_home_work_view() {
    $('#home-content-page').load('src/home_work_view.php')
}

function load_home_remn() {
    $('#home-content-page').load('src/home_events.php')
}

function load_home_salr() {
    $('#home-content-page').load('src/home_salary.php')
}

function load_home_task() {
    $('#home-content-page').load('src/home_task.php')
}

function load_home_move() {
    $('#home-content-page').load('src/home_movements.php')
}

function load_home_appr() {
    $('#home-content-page').load('src/home_appraisals.php')
}

function load_home_invn() {
    $('#home-content-page').load('src/home_inventory.php')
}

function load_home_userlogs() {
    $('#home-content-page').load('src/home_userlogs.php')
}

function attn_status_report() {
    var r = confirm('Send Attendance Status?')
    if (r == true) {
        $.ajax({
            type: 'POST',
            url: 'src/attendance_status.php',
            //dataType:"json",
            cache: false,
            beforeSend: function () {
                show_process()
            },
            success: function (data) {
                hide_process()
                if (data.stat != 'F') {
                    //window.location.href="src/"+data.file;
                }
                //$("#home-content-note").html(data);
            },
            error: function (data) {
                hide_process()
                $('#home-content-note').html('Error: ' + data)
            },
        })
    }
}

function grev_status_report() {
    var r = confirm('Send Greivance Status?')
    if (r == true) {
        $.ajax({
            type: 'POST',
            url: 'src/grievance_status.php',
            //dataType:"json",
            cache: false,
            beforeSend: function () {
                show_process()
            },
            success: function (data) {
                hide_process()
                if (data.stat != 'F') {
                    //window.location.href="src/"+data.file;
                }
                //$("#home-content-note").html(data);
            },
            error: function (data) {
                hide_process()
                $('#home-content-note').html('Error: ' + data)
            },
        })
    }
}

function mcf_status_report() {
    var r = confirm('Send MCF Status?')
    if (r == true) {
        $.ajax({
            type: 'POST',
            url: 'src/mcf_status.php',
            //dataType:"json",
            cache: false,
            beforeSend: function () {
                show_process()
            },
            success: function (data) {
                hide_process()
                if (data.stat != 'F') {
                    //window.location.href="src/"+data.file;
                }
                //$("#home-content-note").html(data);
            },
            error: function (data) {
                hide_process()
                $('#home-content-note').html('Error: ' + data)
            },
        })
    }
}

function view_work_details_empl() {
    $.ajax({
        type: 'POST',
        url: 'src/home_note_work_list.php',
        data: {
            load_data: 'empl_list',
            strt_date: document.getElementById('txtstrtdate').value,
            last_date: document.getElementById('txtlastdate').value,
            sele_empl: document.getElementById('selemplcode').value,
            sele_stat: document.getElementById('selworkstat').value,
        },
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            hide_process()
            $('#home-content-note-work').html(data)
        },
        error: function (data) {
            hide_process()
            $('#home-content-note-work').html('Error: ' + data)
        },
    })
}

function backup_data() {
    $.ajax({
        type: 'POST',
        url: 'src/backup_data.php',
        dataType: 'json',
        cache: false,
        beforeSend: function () {
            show_process()
        },
        success: function (data) {
            hide_process()
            window.location.href = 'src/' + data.file
        },
        error: function (data) {
            hide_process()
            alert('Error occurred')
        },
    })
}

function validate_mobile(input_id, input_val) {
    if (input_val.length != 10) {
        alert('Please enter mobile number!')
        return false
    } else {
        if (/^\d{10}$/.test(input_val) == false) {
            alert('Invalid mobile number, must be 10 digit number!')
            document.getElementById(input_id).focus()
            return false
        }
    }
}

function validate_aadhar(input_id, input_val) {
    if (input_val.length != 12) {
        alert('Please enter aadhar number!')
        return false
    } else {
        if (/^\d{12}$/.test(input_val) == false) {
            alert('Invalid aadhar number, must be 12 digit number!')
            document.getElementById(input_id).focus()
            return false
        }
    }
}

function validate_pan(input_id, input_val) {
    if (input_val.length == 0) {
        alert('Please enter 10 digit PAN!')
        return false
        // } else {
        // 	if (/^[0-9a-z]+$/.test(input_val) == false) {
        // 		alert("Invalid PAN, must be 10 digit!");
        // 		document.getElementById(input_id).focus();
        // 		return false;
        // 	}
    }
}

function validate_email(input_id, input_val) {
    if (input_val == '') {
        alert('Please enter email ID!')
        return false
    } else {
        // var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        // if (reg.test(input_val) == false) {
        // 	alert("Invalid Email Address!");
        // 	document.getElementById(input_id).focus();
        // 	return false;
        // }
        return true
    }
}

function ackn_note(prim_data) {
    var r = confirm('Acknowledge work notification?')
    if (r == true) {
        $.ajax({
            type: 'POST',
            url: 'src/work_entry.php',
            data: {
                load_data: 'ackn_note',
                prim_code: prim_data,
            },
            success: function (data) {
                popup_work_entry()
            },
        })
    }
}