Koha/koha-tmpl/intranet-tmpl/prog/js/categories.js
Nick Clemens 60b0d9439b Bug 20781: Set a minimum enrollemnt period 'in months' of 1
To test:
 1 - Browse to Admin->Patron Categories
 2 - Click '+ New category'
 3 - Enter data as required, however, enter 0 in 'Enrolment period' ->
'in months'
 4 - Save
 5 - View the list of categories, the new category has 'Enrolment period'
= 'until'
 6 - Create a patron in this category, note their dateexipry is
'0000-00-00'
 7 - Search for them
 8 - internal server error
 9 - Delete that patron
10 - Apply patch
11 - Edit the category, note you cannot save with 0 months
12 - Set 1 month and save
13 - Create a patron in this cateogry
14 - Note they have a valid dateexpiry
15 - Search for them
16 - All works
17 - Create a new category and verify you cannot add with 0 months

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-05-29 13:56:00 +00:00

98 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,
min: 1
},
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
}
}
});
});