Lines 1-4
Link Here
|
1 |
<!--Pragmas for using and including packages for create patron category--> |
|
|
2 |
[% USE Koha %] |
1 |
[% USE Koha %] |
3 |
[% USE KohaDates %] |
2 |
[% USE KohaDates %] |
4 |
[% USE Price %] |
3 |
[% USE Price %] |
Lines 6-186
Link Here
|
6 |
<title> Add a patron category</title> |
5 |
<title> Add a patron category</title> |
7 |
[% INCLUDE 'installer-doc-head-close.inc' %] |
6 |
[% INCLUDE 'installer-doc-head-close.inc' %] |
8 |
[% INCLUDE 'calendar.inc' %] |
7 |
[% INCLUDE 'calendar.inc' %] |
9 |
|
8 |
[% INCLUDE 'js_includes.inc' %] |
10 |
<script type="text/javascript"> |
9 |
[% INCLUDE 'datatables.inc' %] |
11 |
//<![CDATA[ |
|
|
12 |
|
13 |
var debug = ""; |
14 |
var dformat = "us"; |
15 |
var sentmsg = 0; |
16 |
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} |
17 |
var MSG_PLEASE_ENTER_A_VALID_DATE = (_("Please enter a valid date (should match %s).")); |
18 |
|
19 |
function is_valid_date(date) { |
20 |
// An empty string is considered as a valid date for convenient reasons. |
21 |
if ( date === '' ) return 1; |
22 |
var dateformat = dateformat_str = 'us'; |
23 |
if ( dateformat == 'us' ) { |
24 |
if ( date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1 ) return 0; |
25 |
dateformat = 'mm/dd/yy'; |
26 |
} else if ( dateformat == 'metric' ) { |
27 |
if ( date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1 ) return 0; |
28 |
dateformat = 'dd/mm/yy'; |
29 |
} else if (dateformat == 'iso' ) { |
30 |
if ( date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1 ) return 0; |
31 |
dateformat = 'yy-mm-dd'; |
32 |
} else if ( dateformat == 'dmydot' ) { |
33 |
if ( date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1 ) return 0; |
34 |
dateformat = 'dd.mm.yy'; |
35 |
} |
36 |
try { |
37 |
$.datepicker.parseDate(dateformat, date); |
38 |
} catch (e) { |
39 |
return 0; |
40 |
}; |
41 |
return 1; |
42 |
}function get_dateformat_str(dateformat) { |
43 |
var dateformat_str; |
44 |
if ( dateformat == 'us' ) { |
45 |
dateformat_str = 'mm/dd/yyyy'; |
46 |
} else if ( dateformat == 'metric' ) { |
47 |
dateformat_str = 'dd/mm/yyyy'; |
48 |
} else if (dateformat == 'iso' ) { |
49 |
dateformat_str = 'yyyy-mm-dd'; |
50 |
} else if ( dateformat == 'dmydot' ) { |
51 |
dateformat_str = 'dd.mm.yyyy'; |
52 |
} |
53 |
return dateformat_str; |
54 |
} |
55 |
|
56 |
function validate_date (dateText, inst) { |
57 |
if ( !is_valid_date(dateText) ) { |
58 |
var dateformat_str = get_dateformat_str( 'us' ); |
59 |
alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str)); |
60 |
$('#'+inst.id).val(''); |
61 |
} |
62 |
} |
63 |
function Date_from_syspref(dstring) { |
64 |
var dateX = dstring.split(/[-/.]/); |
65 |
if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));} |
66 |
if (dformat === "iso") { |
67 |
return new Date(dateX[0], (dateX[1] - 1), dateX[2]); // YYYY-MM-DD to (YYYY,m(0-11),d) |
68 |
} else if (dformat === "us") { |
69 |
return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d) |
70 |
} else if (dformat === "metric") { |
71 |
return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY to (YYYY,m(0-11),d) |
72 |
} else if (dformat === "dmydot") { |
73 |
return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD.MM.YYYY to (YYYY,m(0-11),d) |
74 |
} else { |
75 |
if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);} |
76 |
return 0; |
77 |
} |
78 |
} |
79 |
|
80 |
function DateTime_from_syspref(date_time) { |
81 |
var parts = date_time.split(" "); |
82 |
var date = parts[0]; |
83 |
var time = parts[1]; |
84 |
parts = time.split(":"); |
85 |
var hour = parts[0]; |
86 |
var minute = parts[1]; |
87 |
if ( hour < 0 || hour > 23 ) { |
88 |
return 0; |
89 |
} |
90 |
if ( minute < 0 || minute > 59 ) { |
91 |
return 0; |
92 |
} |
93 |
var datetime = Date_from_syspref( date ); |
94 |
if ( isNaN( datetime.getTime() ) ) { |
95 |
return 0; |
96 |
} |
97 |
datetime.setHours( hour ); |
98 |
datetime.setMinutes( minute ); |
99 |
return datetime; |
100 |
} |
101 |
|
102 |
/* Instead of including multiple localization files as you would normally see with |
103 |
jQueryUI we expose the localization strings in the default configuration */ |
104 |
jQuery(function($){ |
105 |
$.datepicker.regional[''] = { |
106 |
closeText: _("Done"), |
107 |
prevText: _("Prev"), |
108 |
nextText: _("Next"), |
109 |
currentText: _("Today"), |
110 |
monthNames: [_("January"),_("February"),_("March"),_("April"),_("May"),_("June"), |
111 |
_("July"),_("August"),_("September"),_("October"),_("November"),_("December")], |
112 |
monthNamesShort: [_("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"), |
113 |
_("Jul"), _("Aug"), _("Sep"), _("Oct"), _("Nov"), _("Dec")], |
114 |
dayNames: [_("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")], |
115 |
dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")], |
116 |
dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")], |
117 |
weekHeader: _("Wk"), |
118 |
dateFormat: "mm/dd/yy", |
119 |
firstDay: 0, |
120 |
isRTL: false, |
121 |
showMonthAfterYear: false, |
122 |
yearSuffix: ''}; |
123 |
$.datepicker.setDefaults($.datepicker.regional['']); |
124 |
}); |
125 |
|
126 |
$(document).ready(function(){ |
127 |
$.datepicker.setDefaults({ |
128 |
showOn: "both", |
129 |
changeMonth: true, |
130 |
changeYear: true, |
131 |
buttonImage: '/[% interface %]/prog/img/famfamfam/silk/calendar.png', |
132 |
buttonImageOnly: true, |
133 |
showButtonPanel: true, |
134 |
showOtherMonths: true, |
135 |
selectOtherMonths: true |
136 |
}); |
137 |
$( ".datepicker" ).datepicker({ |
138 |
onClose: function(dateText, inst) { |
139 |
validate_date(dateText, inst); |
140 |
}, |
141 |
}).on("change", function(e, value) { |
142 |
if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} |
143 |
}); |
144 |
// http://jqueryui.com/demos/datepicker/#date-range |
145 |
var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({ |
146 |
changeMonth: true, |
147 |
numberOfMonths: 1, |
148 |
onSelect: function( selectedDate ) { |
149 |
var option = this.id == "from" ? "minDate" : "maxDate", |
150 |
instance = $( this ).data( "datepicker" ); |
151 |
date = $.datepicker.parseDate( |
152 |
instance.settings.dateFormat || |
153 |
$.datepicker._defaults.dateFormat, |
154 |
selectedDate, instance.settings ); |
155 |
dates.not( this ).datepicker( "option", option, date ); |
156 |
}, |
157 |
onClose: function(dateText, inst) { |
158 |
validate_date(dateText, inst); |
159 |
}, |
160 |
}).on("change", function(e, value) { |
161 |
if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} |
162 |
}); |
163 |
}); |
164 |
//]]> |
165 |
</script> |
166 |
|
167 |
|
168 |
<script type="text/javascript"> |
10 |
<script type="text/javascript"> |
169 |
var MSG_CATEGORYCODE_CHARS=(_("Please only enter letters into this field.")); |
11 |
var MSG_CATEGORYCODE_CHARS=(_("Please only enter letters into this field.")); |
170 |
var MSG_ONE_ENROLLMENTPERIOD =(_("Please choose an enrollment period in months OR by date.")); |
12 |
var MSG_ONE_ENROLLMENTPERIOD =(_("Please choose an enrollment period in months OR by date.")); |
171 |
var MSG_ONLY_ONE_ENROLLMENTPERIOD=(_("Please only choose one enrolment period.")); |
13 |
var MSG_ONLY_ONE_ENROLLMENTPERIOD=(_("Please only choose one enrolment period.")); |
172 |
</script> |
|
|
173 |
|
174 |
<script type="text/javascript"> |
175 |
jQuery.validator.addMethod( "category_code_check", function(value,element){ |
176 |
var patt = /[0-9A-Za-z]{1,10}$/g; |
177 |
if (patt.test(element.value)) { |
178 |
return true; |
179 |
} else { |
180 |
return false; |
181 |
} |
182 |
}, MSG_CATEGORYCODE_CHARS |
183 |
); |
184 |
|
14 |
|
185 |
jQuery.validator.addMethod( "enrollment_period", function(){ |
15 |
jQuery.validator.addMethod( "enrollment_period", function(){ |
186 |
enrolmentperiod = $("#enrolmentperiod").val(); |
16 |
enrolmentperiod = $("#enrolmentperiod").val(); |
Lines 190-261
jQuery.validator.addMethod( "enrollment_period", function(){
Link Here
|
190 |
} else { |
20 |
} else { |
191 |
return true; |
21 |
return true; |
192 |
} |
22 |
} |
193 |
}, MSG_ONLY_ONE_ENROLLMENTPERIOD |
23 |
}, MSG_ONE_ENROLLMENTPERIOD |
194 |
); |
24 |
); |
195 |
|
|
|
196 |
$(document).ready(function() { |
197 |
$("#enrolmentperioddate").datepicker({ |
198 |
minDate: 1 |
199 |
}); // Require that "until date" be in the future |
200 |
if ($("#branches option:selected").length < 1) { |
201 |
$("#branches option:first").attr("selected", "selected"); |
202 |
} |
203 |
$("#categorycode").on("blur",function(){ |
204 |
toUC(this); |
205 |
}); |
206 |
$("#category_form").validate({ |
207 |
rules: { |
208 |
categorycode: { |
209 |
required: true, |
210 |
category_code_check: true |
211 |
}, |
212 |
description: { |
213 |
required:true, |
214 |
}, |
215 |
enrolmentperiod: { |
216 |
required: function(element){ |
217 |
return $("#enrolmentperioddate").val() === ""; |
218 |
}, |
219 |
digits: true, |
220 |
enrollment_period: true, |
221 |
}, |
222 |
enrolmentperioddate: { |
223 |
required: function(element){ |
224 |
return $("#enrolmentperiod").val() === ""; |
225 |
}, |
226 |
enrollment_period: true, |
227 |
}, |
228 |
dateofbirthrequired: { |
229 |
digits: true |
230 |
}, |
231 |
upperagelimit: { |
232 |
digits: true |
233 |
}, |
234 |
enrolmentfee: { |
235 |
number: true |
236 |
}, |
237 |
reservefee: { |
238 |
number: true |
239 |
}, |
240 |
category_type: { |
241 |
required: true |
242 |
} |
243 |
}, |
244 |
messages: { |
245 |
categorycode: { |
246 |
required: MSG_CATEGORYCODE_CHARS |
247 |
}, |
248 |
enrolmentperiod: { |
249 |
required: MSG_ONE_ENROLLMENTPERIOD |
250 |
}, |
251 |
enrolmentperioddate: { |
252 |
required: MSG_ONE_ENROLLMENTPERIOD |
253 |
} |
254 |
} |
255 |
}); |
256 |
}); |
257 |
|
258 |
</script> |
25 |
</script> |
|
|
26 |
<script type="text/javascript" src="[% themelang %]/js/categories.js"></script> |
259 |
</head> |
27 |
</head> |
260 |
|
28 |
|
261 |
[% IF (categories && categories.count > 1 ) %] <!--This if statement checks if the categories variable handed to this template by onboarding.pl has data in it. If the categories variable does have data in it this means that the user has previously imported sample patron category data and so we do not need to show them the create patron category screen 1, instead we can display a screen with ubtton redirecting the user to step 3--> |
29 |
[% IF (categories && categories.count > 1 ) %] <!--This if statement checks if the categories variable handed to this template by onboarding.pl has data in it. If the categories variable does have data in it this means that the user has previously imported sample patron category data and so we do not need to show them the create patron category screen 1, instead we can display a screen with ubtton redirecting the user to step 3--> |