View | Details | Raw Unified | Return to bug 14060
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (-5 / +16 lines)
Lines 8-16 var sentmsg = 0; Link Here
8
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
8
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
9
var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s).");
9
var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s).");
10
10
11
function validate_date (dateText, inst) {
11
function is_valid_date(date) {
12
    var dateformat = '[% Koha.Preference('dateformat') %]';
12
    var dateformat = dateformat_str = '[% Koha.Preference('dateformat') %]';
13
    var dateformat_str = dateformat
14
    if ( dateformat == 'us' ) {
13
    if ( dateformat == 'us' ) {
15
        dateformat = 'mm/dd/yy';
14
        dateformat = 'mm/dd/yy';
16
        dateformat_str = 'mm/dd/yyyy';
15
        dateformat_str = 'mm/dd/yyyy';
Lines 22-32 function validate_date (dateText, inst) { Link Here
22
        dateformat_str = 'yyyy-mm-dd';
21
        dateformat_str = 'yyyy-mm-dd';
23
    }
22
    }
24
    try {
23
    try {
25
        $.datepicker.parseDate(dateformat, dateText);
24
        $.datepicker.parseDate(dateformat, date);
26
    } catch (e) {
25
    } catch (e) {
26
        return 0;
27
    };
28
    return 1;
29
}
30
31
function validate_date (dateText, inst) {
32
    if ( !is_valid_date(dateText) ) {
33
        var dateformat_str = '[% Koha.Preference('dateformat') %]';
27
        alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str));
34
        alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str));
28
        $('#'+inst.id).val('');
35
        $('#'+inst.id).val('');
29
    };
36
    }
30
}
37
}
31
38
32
function Date_from_syspref(dstring) {
39
function Date_from_syspref(dstring) {
Lines 115-120 $.datepicker.setDefaults({ Link Here
115
        onClose: function(dateText, inst) {
122
        onClose: function(dateText, inst) {
116
            validate_date(dateText, inst);
123
            validate_date(dateText, inst);
117
        },
124
        },
125
    }).on("change", function(e, value) {
126
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
118
    });
127
    });
119
    // http://jqueryui.com/demos/datepicker/#date-range
128
    // http://jqueryui.com/demos/datepicker/#date-range
120
    var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
129
    var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
Lines 132-137 $.datepicker.setDefaults({ Link Here
132
        onClose: function(dateText, inst) {
141
        onClose: function(dateText, inst) {
133
            validate_date(dateText, inst);
142
            validate_date(dateText, inst);
134
        },
143
        },
144
    }).on("change", function(e, value) {
145
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
135
    });
146
    });
136
});
147
});
137
//]]>
148
//]]>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+2 lines)
Lines 78-83 function toggle_onsite_checkout(){ Link Here
78
            },
78
            },
79
            hour: 23,
79
            hour: 23,
80
            minute: 59
80
            minute: 59
81
        }).on("change", function(e, value) {
82
            if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
81
        });
83
        });
82
    }
84
    }
83
}
85
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt (+2 lines)
Lines 560-565 $(document).ready(function () { Link Here
560
        },
560
        },
561
        hour: 23,
561
        hour: 23,
562
        minute: 59
562
        minute: 59
563
    }).on("change", function(e, value) {
564
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
563
    });
565
    });
564
    $('#mainform').submit(function (event) {
566
    $('#mainform').submit(function (event) {
565
        event.preventDefault();
567
        event.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (+2 lines)
Lines 62-67 $(document).ready(function () { Link Here
62
        hour: 23,
62
        hour: 23,
63
        minute: 59,
63
        minute: 59,
64
        maxDate: 0
64
        maxDate: 0
65
    }).on("change", function(e, value) {
66
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
65
    });
67
    });
66
    $("#return_date_override").on("blur", function() {
68
    $("#return_date_override").on("blur", function() {
67
            check_valid_return_date();
69
            check_valid_return_date();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+2 lines)
Lines 88-93 $(document).ready(function() { Link Here
88
            validate_date(dateText, inst);
88
            validate_date(dateText, inst);
89
        },
89
        },
90
        minDate: 1, // require that hold suspended until date is after today
90
        minDate: 1, // require that hold suspended until date is after today
91
    }).on("change", function(e, value) {
92
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
91
    });
93
    });
92
94
93
    $("#view_restrictions").on("click",function(){
95
    $("#view_restrictions").on("click",function(){
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js (-1 / +4 lines)
Lines 35-40 $(document).ready(function() { Link Here
35
        minDate: 1, // require that renewal date is after today
35
        minDate: 1, // require that renewal date is after today
36
        hour: 23,
36
        hour: 23,
37
        minute: 59
37
        minute: 59
38
    }).on("change", function(e) {
39
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
38
    });
40
    });
39
    $("#duedatespec").datetimepicker({
41
    $("#duedatespec").datetimepicker({
40
        onClose: function(dateText, inst) {
42
        onClose: function(dateText, inst) {
Lines 44-49 $(document).ready(function() { Link Here
44
        },
46
        },
45
        hour: 23,
47
        hour: 23,
46
        minute: 59
48
        minute: 59
49
    }).on("change", function(e, value) {
50
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
47
    });
51
    });
48
    $("#export_submit").on("click",function(){
52
    $("#export_submit").on("click",function(){
49
        var output_format = $("#output_format").val();
53
        var output_format = $("#output_format").val();
50
- 

Return to bug 14060