// JavaScript Document

jQuery.fn.forcepositiveNum = function () {

    return this.each(function () {
        $(this).keydown(function (e) {
            var key = e.which || e.keyCode;
            //alert(key);
            if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
                    // numbers
                    key >= 48 && key <= 57 ||
                    // Numeric keypad
                    key >= 96 && key <= 105 ||
                    // comma, period and minus, . on keypad
                    //key == 190 || key == 188 || key == 109 || key == 110 ||
                    // Backspace and Tab and Enter
                    key == 8 || key == 9 || key == 13 ||
                    // Home and End
                    key == 35 || key == 36 ||
                    // left and right arrows
                    key == 37 || key == 39 ||
                    // Del and Ins
                    key == 46 || key == 45)
                return true;

            return false;
        });
    });
}

jQuery.fn.forcepositivefloat = function () {

    return this.each(function () {
        $(this).keydown(function (e) {
            var presedval = e.key;
            var key = e.which || e.keyCode;
            //alert(key);
            if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
                    // numbers
                    key >= 48 && key <= 57 ||
                    // Numeric keypad
                    key >= 96 && key <= 105 ||
                    // comma, period and minus, . on keypad
                    //key == 190 || key == 188 || key == 109 || key == 110 ||
                    // Backspace and Tab and Enter
                    key == 8 || key == 9 || key == 13 ||
                    // Home and End
                    key == 35 || key == 36 ||
                    // left and right arrows
                    key == 37 || key == 39 ||
                    //dot or point  .  on keyboard  for one time
                            (key == 110 && $(this).val().indexOf(".") < 0) ||
                            (key == 190 && $(this).val().indexOf(".") < 0 && presedval == ".") ||
                            // Del and Ins
                            key == 46 || key == 45)
                return true;

            return false;
        });
    });
}

$(document).ready(function (e) {
    $(".positiveNo").forcepositiveNum();
    $(".positivefloat").forcepositivefloat();

    $('.delthis').live('click', function () {
        var go = $(this).attr('data-go');
        $('#delThisBtn').attr('data-go', go);
        $('#confirmThis').modal('show');
    });

    $('#delThisBtn').live('click', function () {
        var go = $(this).attr('data-go');
        window.location.href = go;

    });
    $.post('dailyentryajax.php?do=cashheader', {mymenu: $('#mymenu').html()}, function (data) {
    });

});



$(document).ready(function () {
    $('.dataTableClass').dataTable({
        "bPaginate": true,
        "bStateSave": true,
        "sDom": 'TCR<"clear">lfrtip',
        "oTableTools": {
            "aButtons": [
                "copy",
                "print",
                {
                    "sExtends": "collection",
                    "sButtonText": "حفظ",
                    "aButtons": ["csv", "xls"]
                }
            ]
        }
    });
    $('.dataTableClass td').css("height", "30px");
});

