Koha/koha-tmpl/intranet-tmpl/prog/js/categories.js
Julian Maurice 639591f072 Bug 20538: Move categories.js out of language directory
This was the last js/css file inside a language directory

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2018-04-13 11:49:44 -03:00

97 lines
2.6 KiB
JavaScript

jQuery.validator.addMethod( "letters_numbers", function(value,element){
var patt = /^[a-zA-Z0-9\-_]+$/g;
if (patt.test(element.value)) {
return true;
} else {
return false;
}
}, MSG_CATEGORYCODE_CHARS
);
jQuery.validator.addMethod( "enrollment_period", function(){
enrolmentperiod = $("#enrolmentperiod").val();
enrolmentperioddate = $("#enrolmentperioddate").val();
if ( $("#enrolmentperiod").val() !== "" && $("#enrolmentperioddate").val() !== "" ) {
return false;
} else {
return true;
}
}, MSG_ONE_ENROLLMENTPERIOD
);
$(document).ready(function() {
$("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [{
"aTargets": [-1],
"bSortable": false,
"bSearchable": false
}, {
"aTargets": [3, 4, 5],
"sType": "natural"
}, ],
"aaSorting": [
[1, "asc"]
],
"sPaginationType": "four_button"
}));
$("#enrolmentperioddate").datepicker({
minDate: 1
}); // Require that "until date" be in the future
if ($("#branches option:selected").length < 1) {
$("#branches option:first").attr("selected", "selected");
}
$("#categorycode").on("blur",function(){
toUC(this);
});
$("#category_form").validate({
rules: {
categorycode: {
required: true,
letters_numbers: true
},
description: "required",
enrolmentperiod: {
required: function(element){
return $("#enrolmentperioddate").val() === "";
},
digits: true,
enrollment_period: true
},
enrolmentperioddate: {
required: function(element){
return $("#enrolmentperiod").val() === "";
},
enrollment_period: true
},
dateofbirthrequired: {
digits: true
},
upperagelimit: {
digits: true
},
enrolmentfee: {
number: true
},
reservefee: {
number: true
},
category_type: {
required: true
}
},
messages: {
enrolmentperiod: {
required: MSG_ONE_ENROLLMENTPERIOD
},
enrolmentperioddate: {
required: MSG_ONE_ENROLLMENTPERIOD
}
}
});
});