1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha › Serials › <!-- TMPL_IF name="mod" --> Modify subscription to <!-- TMPL_VAR name="bibliotitle" --><!-- TMPL_ELSE -->New subscription<!-- /TMPL_IF --></title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
6 <script type="text/javascript">
9 // the english words used in display purposes
10 var text = new Array(_("Number"),_("Volume"),_("Issue"),_("Month"),_("Week"),_("Starting with:"),_("Rollover at:"),_("Choose Hemisphere:"),_("Northern"),_("Southern"),
11 _("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"),_("Season"),_("Year"));
13 var is_hemisphere = 1;
14 var irregular_issues; // will hold irregularity object.
16 <!-- TMPL_IF NAME="weekarrayjs" -->
17 var weeks = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->);
20 function formatDate(myDate) {
21 var d = new Array( myDate.getFullYear(), myDate.getMonth() + 1 ,myDate.getDate());
22 if(d[1].toString().length == 1) { d[1] = '0'+d[1] };
23 if(d[2].toString().length == 1) { d[2] = '0'+d[2] };
24 <!-- TMPL_IF NAME="dateformat_us" -->
25 return(d[1] + '/' + d[2] + '/' + d[0]) ;
26 <!-- TMPL_ELSIF NAME="dateformat_metric" -->
27 return(d[2] + '/' + d[1] + '/' + d[0]) ;
29 return(''+d[0] + '-' + d[1] + '-' + d[2]) ;
33 Date.prototype.addDays = function(days) {
34 this.setDate(this.getDate()+days);
37 function getWeeksArray(startDate) {
38 // returns a 52 element array with dates starting with startDate.
39 var weeksArray = new Array;
40 var myDate = new Date;
41 for(var i=0;i<52;i++) {
42 startDate.addDays( 7 );
43 weeksArray[i] = formatDate(startDate);
48 function YMDaToYWDa(S) {
49 with (new Date(Date.UTC(S[0], S[1] - 1, S[2]))) {
50 var DoW = getUTCDay();
51 setUTCDate(getUTCDate() - (DoW + 6) % 7 + 3);
54 var WN = Math.round((ms - valueOf()) / 604800000) + 1;
55 return [getUTCFullYear(), WN, DoW == 0 ? 7 : DoW];
58 function dayofyear(d) { // d is a Date object
59 var yn = d.getFullYear();
60 var mn = d.getMonth();
62 var d1 = new Date(yn,0,1,12,0,0); // noon on Jan. 1
63 var d2 = new Date(yn,mn,dn,12,0,0); // noon on input date
64 var ddiff = Math.round((d2-d1)/864e5);
69 // create irregularity object.
70 function IrregularPattern() {
71 this.months = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
72 this.seasons = new Array(_("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"));
73 this.daynames = new Array(_("Monday"),_("Tuesday"),_("Wednesday"),_("Thursday"),_("Friday"),_("Saturday"),_("Sunday"));
74 <!-- TMPL_IF NAME="weekarrayjs" -->
75 this.weeks = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->);
79 var irregular = '<!-- TMPL_VAR NAME="irregularity" -->';
80 // var periodicity = document.f.periodicity.value;
81 this.skipped = irregular.split(',');
84 IrregularPattern.prototype.update = function() {
85 this.skipped= new Array;
87 // daily periodicity, we interpret irregular array as which days of week to skip.
88 // else irregular array is list of issues to skip
91 if(document.f.irregularity_select) {
92 for( var i in document.f.irregularity_select.options ) {
93 if( document.f.irregularity_select.options[i].selected ) {
94 this.skipped[cnt] = document.f.irregularity_select.options[i].value ;
95 summary_str += document.f.irregularity_select.options[i].text + "\n" ;
100 var summary = document.getElementById("irregularity_summary");
102 summary.value = summary_str;
103 summary.rows= ( cnt > 6 ) ? cnt : 6 ;
108 IrregularPattern.prototype.irregular = function(index) {
109 for( var i in this.skipped) {
110 if( this.skipped[i] == index) {
117 function init_pattern() {
118 irregular_issues = new IrregularPattern();
120 function reset_pattern() {
121 document.getElementById("numberpattern").value = '';
122 // document.getElementById("numberpattern").value = '';
127 // common pre defined number patterns
128 function reset_num_pattern() {
129 var patternchoice = document.getElementById("numberpattern").value;
130 switch(patternchoice){
132 document.f.add1.value=1;
133 document.f.add2.value=1;
134 document.f.add3.value=1;
135 document.f.every1.value=12;
136 document.f.every2.value=1;
137 document.f.every3.value=1;
138 document.f.whenmorethan1.value=9999999;
139 document.f.whenmorethan2.value=12;
140 document.f.whenmorethan3.value=4;
141 document.f.setto1.value=0;
142 document.f.setto2.value=1;
143 document.f.setto3.value=1;
144 document.f.lastvalue1.value=1;
145 document.f.lastvalue2.value=1;
146 document.f.lastvalue3.value=1;
147 document.f.numberingmethod.value=_("Vol {X}, No {Y}, Issue {Z}");
148 moreoptions(text[1],text[0],text[2]);
149 display_table(0); // toggle info box on (1) or off (0)
152 document.f.add1.value=1;
153 document.f.add2.value=1;
154 document.f.add3.value='';
155 document.f.every1.value=12;
156 document.f.every2.value=1;
157 document.f.every3.value='';
158 document.f.whenmorethan1.value=9999999;
159 document.f.whenmorethan2.value=12;
160 document.f.whenmorethan3.value='';
161 document.f.setto1.value=0;
162 document.f.setto2.value=1;
163 document.f.setto3.value='';
164 document.f.lastvalue1.value=1;
165 document.f.lastvalue2.value=1;
166 document.f.lastvalue3.value='';
167 document.f.numberingmethod.value=_("Vol {X}, No {Y}");
168 moreoptions(text[1],text[0]);
172 document.f.add1.value=1;
173 document.f.add2.value=1;
174 document.f.add3.value='';
175 document.f.every1.value=12;
176 document.f.every2.value=1;
177 document.f.every3.value='';
178 document.f.whenmorethan1.value=9999999;
179 document.f.whenmorethan2.value=12;
180 document.f.whenmorethan3.value='';
181 document.f.setto1.value=0;
182 document.f.setto2.value=1;
183 document.f.setto3.value='';
184 document.f.lastvalue1.value=1;
185 document.f.lastvalue2.value=1;
186 document.f.lastvalue3.value='';
187 document.f.numberingmethod.value=_("Vol {X}, Issue {Y}");
188 moreoptions(text[1],text[2]);
192 // var d = new Date(document.f.firstacquidate.value);
193 // var smonth = d.getMonth();
194 document.f.add1.value=1;
195 document.f.add2.value=1;
196 document.f.add3.value='';
197 document.f.every1.value=12;
198 document.f.every2.value=1;
199 document.f.every3.value='';
200 document.f.whenmorethan1.value=9999999;
201 document.f.whenmorethan2.value=12;
202 document.f.whenmorethan3.value='';
203 document.f.setto1.value=0;
204 document.f.setto2.value=1;
205 document.f.setto3.value='';
206 document.f.numberingmethod.value=_("No {X}, Issue {Y}");
207 moreoptions(text[0],text[2]);
211 var d = new Date(document.f.firstacquidate.value);
212 var sYear = d.getFullYear();
213 moreoptions_seasons(text[15],sYear);
214 var d = new Date(document.f.firstacquidate.value);
215 var sYear = d.getFullYear();
216 document.f.add1.value=1;
217 document.f.add2.value='1';
218 document.f.add3.value='';
219 document.f.every1.value=4;
220 document.f.every2.value='1';
221 document.f.every3.value='';
222 document.f.whenmorethan1.value=9999999;
223 document.f.whenmorethan2.value='4';
224 document.f.whenmorethan3.value='';
225 document.f.setto1.value=0;
226 document.f.setto2.value='1';
227 document.f.setto3.value='';
228 document.f.lastvalue1temp.value=sYear;
229 document.f.periodicity.value='8';
230 document.f.numberingmethod.value=_("{Y} {X}");
231 moreoptions_seasons(text[15],sYear);
237 document.getElementById("more_options").innerHTML = '';
238 document.f.irreg_check.value=1;
241 var d = new Date(document.f.startdate.value);
242 var sYear = d.getFullYear();
243 document.f.add1.value=1;
244 document.f.add2.value=1;
245 document.f.add3.value='';
246 document.f.every1.value=12;
247 document.f.every2.value=1;
248 document.f.every3.value='';
249 document.f.whenmorethan1.value=9999999;
250 document.f.whenmorethan2.value=12;
251 document.f.whenmorethan3.value='';
252 document.f.setto1.value=0;
253 document.f.setto2.value=1;
254 document.f.setto3.value='';
255 if (document.f.lastvalue1.value==0){document.f.lastvalue1.value=sYear};
256 if (document.f.lastvalue2.value==0 ||document.f.lastvalue2.value=='' ){
257 switch (document.f.periodicity.value){
259 var doy = dayofyear(d);
260 //var Weeknumber=YWDA[1];
261 document.f.lastvalue2.value=doy;
264 var doy = dayofyear(d);
265 //var Weeknumber=YWDA[1];
266 document.f.lastvalue2.value=doy*2;
269 var doy = dayofyear(d);
270 //var Weeknumber=YWDA[1];
271 document.f.lastvalue2.value=doy/3;
276 var YWDa = YMDaToYWDa(d);
277 //var Weeknumber=YWDA[1];
278 document.f.lastvalue2.value=YWDA[1]/(document.f.periodicity.value-1);
281 var smonth = d.getMonth();
282 document.f.lastvalue2.value=smonth;
285 var smonth = d.getMonth();
286 document.f.lastvalue2.value=smonth/2;
290 var smonth = d.getMonth();
291 document.f.lastvalue2.value=smonth/3;
294 var smonth = d.getMonth();
295 document.f.lastvalue2.value=smonth/6;
300 // document.f.lastvalue2.value=document.f.lastvalue2temp.value;
301 document.f.lastvalue3.value='';
302 document.f.numberingmethod.value=_("{X}/{Y}");
303 moreoptions(text[16],text[0]);
307 document.f.add1.value=1;
308 document.f.add2.value='';
309 document.f.add3.value='';
310 document.f.every1.value=1;
311 document.f.every2.value='';
312 document.f.every3.value='';
313 document.f.whenmorethan1.value=9999999;
314 document.f.whenmorethan2.value='';
315 document.f.whenmorethan3.value='';
316 document.f.setto1.value=0;
317 document.f.setto2.value='';
318 document.f.setto3.value='';
319 document.f.lastvalue1.value=1;
320 document.f.lastvalue2.value='';
321 document.f.lastvalue3.value='';
322 document.f.numberingmethod.value='{X}';
323 // moreoptions_daily_check(text[0]);
324 moreoptions(text[0]);
325 document.f.irreg_check.value=1;
331 function display_table(n) {
333 document.getElementById("basetable").style.display = 'block';
335 document.getElementById("basetable").style.display = 'none';
337 var disp_val = ( document.getElementById("basetable").style.display == 'none' ) ? 'block' : 'none' ;
338 document.getElementById("basetable").style.display = disp_val;
342 function set_num_pattern_from_template_vars() {
343 if(!document.getElementById("numberpattern")){ return false; }
344 document.getElementById("numberpattern").value = '<!-- TMPL_VAR NAME="numberpattern" -->';
347 document.f.add1.value='<!-- TMPL_VAR NAME="add1" -->';
348 document.f.add2.value='<!-- TMPL_VAR NAME="add2" -->';
349 document.f.add3.value='<!-- TMPL_VAR NAME="add3" -->';
350 document.f.every1.value='<!-- TMPL_VAR NAME="every1" -->';
351 document.f.every2.value='<!-- TMPL_VAR NAME="every2" -->';
352 document.f.every3.value='<!-- TMPL_VAR NAME="every3" -->';
353 document.f.whenmorethan1.value='<!-- TMPL_VAR NAME="whenmorethan1" -->';
354 document.f.whenmorethan2.value='<!-- TMPL_VAR NAME="whenmorethan2" -->';
355 document.f.whenmorethan3.value='<!-- TMPL_VAR NAME="whenmorethan3" -->';
356 document.f.setto1.value='<!-- TMPL_VAR NAME="setto1" -->';
357 document.f.setto2.value='<!-- TMPL_VAR NAME="setto2" -->';
358 document.f.setto3.value='<!-- TMPL_VAR NAME="setto3" -->';
359 document.f.lastvalue1.value='<!-- TMPL_VAR NAME="lastvalue1" -->';
360 document.f.lastvalue2.value='<!-- TMPL_VAR NAME="lastvalue2" -->';
361 document.f.lastvalue3.value='<!-- TMPL_VAR NAME="lastvalue3" -->';
362 document.f.numberingmethod.value='<!-- TMPL_VAR NAME="numberingmethod" -->';
366 <!-- TMPL_IF NAME="add2" -->
367 if(<!-- TMPL_VAR NAME="add2" --> > 0){
371 <!-- TMPL_IF NAME="add3" -->
372 if(<!-- TMPL_VAR NAME="add3" --> > 0){
376 document.f.lastvalue1temp.value='<!-- TMPL_VAR NAME="lastvalue1" -->';
378 document.f.lastvalue2temp.value='<!-- TMPL_VAR NAME="lastvalue2" -->';
379 document.f.whenmorethan2temp.value='<!-- TMPL_VAR NAME="whenmorethan2" -->';
382 document.f.lastvalue3temp.value='<!-- TMPL_VAR NAME="lastvalue3" -->';
383 document.f.whenmorethan3temp.value='<!-- TMPL_VAR NAME="whenmorethan3" -->';
387 // a pre check with more options to see if 'number' and '1/day' are chosen
389 function moreoptions_daily_check(x) {
390 var periodicity = document.f.periodicity.value;
392 if(periodicity == 1){ // i.e. daily
393 document.getElementById("irregularity").innerHTML = '';
394 errortext =_("Please indicate which days of the week you <b>DO NOT<\/b> expect to receive issues.<br \/>");
395 for(var j=0;j<irregular_issues.daynames.length;j++){
396 errortext +="<input type='checkbox' name='irregular' id='irregular"+(j+1)+"' value='"+(j+1)+"' />"+irregular_issues.daynames[j]+" ";
398 var error = errortext;
400 document.getElementById("irregularity").innerHTML = error;
402 document.getElementById("irregularity").innerHTML = '';
403 document.getElementById("more_options").innerHTML = '';
409 // to dispaly the more options section
410 function moreoptions(x,y,z){
411 document.getElementById("irregularity").innerHTML = '';
412 document.getElementById("more_options").innerHTML = '';
414 // alert("X: "+x+"Y: "+y+"Z: "+z);
416 textbox +="<table>\n<tr><th> <\/th><th>"+x+"<\/th>";
418 textbox +="<th>"+y+"<\/th>";
420 textbox +="<th>"+z+"<\/th>";
423 textbox +="<\/tr>\n";
424 textbox +="<tr><th scope=\"row\">"+text[5]+"<\/td><td><input type='text' name='lastvalue1temp' id='lastvalue1temp' size='4' onkeyup='moreoptionsupdate(this)' value=\"" + document.f.lastvalue1.value + "\" /><\/td>\n";
426 textbox +="<td><input type='text' name='lastvalue2temp' id='lastvalue2temp' size='4' onkeyup='moreoptionsupdate(this)' value=\"" + document.f.lastvalue2.value + "\" /><\/td>\n";
428 textbox +="<td><input type='text' name='lastvalue3temp' id='lastvalue3temp' size='4' onkeyup='moreoptionsupdate(this)' value=\"" + document.f.lastvalue3.value + "\" /><\/td>\n";
431 textbox +="<\/tr>\n";
433 textbox +="<tr><th scope=\"row\">"+text[6]+"<\/th>";
434 textbox +="<td> <\/td>\n";
435 textbox +="<td><input type='text' name='whenmorethan2temp' id='whenmorethan2temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
437 textbox +="<td><input type='text' name='whenmorethan3temp' id='whenmorethan3temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
441 textbox +="<tr> <td>"+_("issues expected")+"</td><td><input type='text' name='issuesexpected1temp' id='issuesexpected1temp' size='4' onkeyup='moreoptionsupdate(this,0)' value=\"" + document.f.issuesexpected1.value + "\" ></td></tr>";
443 textbox +="<\/table>\n";
445 document.getElementById("more_options").innerHTML = textbox;
448 function hemispheres(chosen){
449 var selbox = document.getElementById("season1");
451 var selboxselected = selbox.options[selbox.selectedIndex].value;
452 selbox.options.length = 0;
454 if ( (chosen == "1") || ( ! (chosen) && is_hemisphere == 1 )) {
455 selbox.options[selbox.options.length] = new Option(text[11],'1');
456 selbox.options[selbox.options.length] = new Option(text[12],'2');
457 selbox.options[selbox.options.length] = new Option(text[13],'3');
458 selbox.options[selbox.options.length] = new Option(text[14],'4');
460 selbox.options[selboxselected-1].selected = true;
463 if ( (chosen == "2") || ( ! (chosen) && is_hemisphere == 2 )) {
464 selbox.options[selbox.options.length] = new Option(text[13],'1');
465 selbox.options[selbox.options.length] = new Option(text[10],'2');
466 selbox.options[selbox.options.length] = new Option(text[11],'3');
467 selbox.options[selbox.options.length] = new Option(text[12],'4');
469 selbox.options[selboxselected-1].selected = true;
474 // to display the more options section for seasons
475 function moreoptions_seasons(x,y){
476 document.getElementById("irregularity").innerHTML = '';
477 document.getElementById("more_options").innerHTML = '';
479 //alert("X: "+x+"Year: "+y);
481 var hemi_select = parseInt('<!-- TMPL_VAR NAME="hemisphere" -->');
482 textbox +="<li><label for=\"hemisphere\">"+ text[7] +"<\/label><select name='hemisphere' id=\"hemisphere\" onchange='hemispheres(this.options[this.selectedIndex].value)'>";
483 for(var i = 1; i <= 2; i++){
484 textbox +="<option value='"+i+"'";
485 if(i == hemi_select){
486 textbox += " selected "
488 textbox +=">"+text[i+7]+"<\/option>";
490 textbox +="<\/li>\n";
491 textbox +="<table><tr><th> <\/th><th>"+x+"<\/th>";
492 textbox +="<th>"+text[16]+"<\/th>";
493 textbox +="<\/tr>\n";
494 textbox +="<tr><th scope=\"row\">"+text[5]+"<\/th><td><select name='lastvalue2temp' id='lastvalue2temp' id='season1' onchange='moreoptionsupdate(this)'>";
495 for(var j = 1; j <= 4; j++){
496 textbox +="<option value='"+j+"'>"+text[j+10]+"<\/option>";
498 textbox +="<\/select><\/td><td><select name='lastvalue1temp' id='lastvalue1temp' onchange='moreoptionsupdate(this)'>";
499 for(var k = parseInt(y); k <= parseInt(y)+15; k++){
500 textbox +="<option value='"+k+"'>"+k+"<\/option>";
502 textbox +="<\/select><\/td><\/tr>\n";
503 textbox +="<tr><th scope=\"row\">"+text[6]+"<\/th>";
504 textbox +="<td><input type='text' name='whenmorethan2temp' id='whenmorethan2temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
505 textbox +="<\/tr><\/table>\n";
508 document.getElementById("more_options").innerHTML = textbox;
511 function irregularity_check(){
512 document.f.irreg_check.value = 1; // Irregularity button now pushed
513 var periodicity = document.f.periodicity.value;
514 var rollover = document.f.issuesexpected1.value;
515 if( (document.f.whenmorethan2) && ( document.f.whenmorethan2.value > 0) ){
516 rollover = document.f.whenmorethan2.value;
518 if((document.f.whenmorethan3) && document.f.whenmorethan3.value > 0 ){
519 // FIXME: Irregularity check assumes that the full prediction pattern repeats each year.
520 // In cases where the outermost periodicity is > 1 year,
521 // e.g. where a volume spans two years, the irregularity check will be incorrect,
522 // but you can safely ignore the check, submit the form, and the prediction pattern should be correct.
523 // a way to distinguish between these two cases is needed.
524 rollover = document.f.whenmorethan3.value * document.f.whenmorethan2.value;
529 var errortext = _("<b>Warning irregularity detected<\/b><br \/>");
532 if(rollover < 730) expected =730;
539 if(rollover < 365) expected =365;
546 if(rollover < 156) expected =156;
553 if(rollover < 52) expected =52;
560 if(rollover < 26) expected =26;
567 if(rollover < 17) expected =17;
574 if(rollover < 12) expected =12;
581 if(rollover < 6) expected =6;
588 if(rollover < 4) expected =4;
595 if(rollover < 4) expected =4;
602 if(rollover < 2) expected =2;
609 if(rollover < 1) expected =1;
619 if(expected == 365 || expected==730){ // what about leap years ?
620 // FIXME: We interpret irregularity as which days per week for periodicity==1.
621 // We need two cases: one in which we're published n days/week, in which case irregularity should be per week,
622 // and a regular daily pub, where irregularity should be per year.
623 errortext += _("Please indicate which days of the week you <b>DO NOT<\/b> expect to receive issues.<br \/>");
625 errortext +=expected+_(" issues expected, ")+rollover+_(" were entered. <br \/>Please indicate which date(s) an issue is not expected<br \/>");
626 irregular_issues.numskipped = expected - rollover;
628 errortext +="<select multiple id='irregularity_select' name='irregularity_select' onchange='irregular_issues.update();'>\n";
629 errortext +=irregular_options(periodicity);
630 errortext += "</select>\n <textarea rows='6' width='18' id='irregularity_summary' name='irregularity_summary' value='foo' />";
634 errortext +=expectedover+_(" issues expected, ")+rollover+_(" were entered.<br \/> You seem to have indicated more issues per year than expected.");
637 if(error.length ==0){
638 error=_("No irregularities noticed");
640 display_example(expected);
641 document.getElementById("irregularity").innerHTML = error;
642 irregular_issues.update();
645 function irregular_options(periodicity){
649 if(periodicity == 1) {
654 if(periodicity == 2 || periodicity == 3 || periodicity == 4) {
656 titles = irregular_issues.weeks;
657 <!-- TMPL_IF NAME="weekno" -->
658 count = 1; // This doesn't make sense given the behavior of the script.
659 // we should count from the first serial date, not from this week!
660 // <!-- TMPL_VAR NAME="weekno" -->;
665 if(periodicity == 5 || periodicity == 6 || periodicity == 7 || periodicity == 8 || periodicity == 9) {
666 if(periodicity == 8) {
667 is_season = 1; // setting up from edit page
670 titles = irregular_issues.seasons;
672 if(is_hemisphere == 2){
678 titles = irregular_issues.months;
684 return ''; // don't know how to deal with irregularity.
686 for(var j=1;j<=expected;j++){
689 count = count-expected;
691 if(is_season && is_hemisphere == 1){
692 errortext +="<option value='"+((count*3)-2)+"'>"+titles[j]+"<\/option>\n";
693 // alert("value: "+((count*3)-2)+" title: "+titles[j]);
694 } else if(is_season && is_hemisphere == 2){
695 errortext +="<option value='"+((count*3)-2)+"'>"+titles[j-1]+"<\/option>\n";
696 // alert("value: "+((count*3)-2)+" title: "+titles[j-1]);
698 errortext += "<option value='" + count ;
699 if(irregular_issues.irregular(j)) {
700 errortext += "' selected='selected" ;
702 errortext += "'>"+titles[j-1]+"<\/option>\n";
706 errortext +="<option value='"+j+"'>"+titles+" "+j+"<\/option>\n";
713 function display_example(expected){
714 var startfrom1 = parseInt(document.f.lastvalue1.value);
715 var startfrom2 = parseInt(document.f.lastvalue2.value);
716 var startfrom3 = parseInt(document.f.lastvalue3.value);
717 var every1 = parseInt(document.f.every1.value);
718 var every2 = parseInt(document.f.every2.value);
719 var every3 = parseInt(document.f.every3.value);
720 var numberpattern = document.f.numberingmethod.value;
721 var whenmorethan2 = parseInt(document.f.whenmorethan2.value);
722 var whenmorethan3 = parseInt(document.f.whenmorethan3.value);
723 var setto2 = parseInt(document.f.setto2.value);
724 var setto3 = parseInt(document.f.setto3.value);
725 var displaytext = _("Based on the information entered, the Numbering Pattern will look like this: <br \/><ul class=\"numpattern_preview\">");
727 var count=startfrom3-1;
728 var count2=startfrom2;
729 for(var i = 0 ; i < 12; i++){
730 if(count>=whenmorethan3){
732 if(count2>=whenmorethan2){
741 displaytext += '<li>' + numberpattern.replace(/{Z}/,count) + '</li>\n';
742 displaytext = displaytext.replace(/{Y}/,count2);
743 displaytext = displaytext.replace(/{X}/,startfrom1);
747 if(startfrom2>0 && !startfrom3){
748 var count=startfrom2-1;
749 for(var i=0;i<12;i++){
750 if(count>=whenmorethan2){
758 if(is_hemisphere == 2){
760 displaytext += numberpattern.replace(/{Y}/,text[count+12])+'\n';
762 displaytext += numberpattern.replace(/{Y}/,text[count+8])+'\n';
765 displaytext += numberpattern.replace(/{Y}/,text[count+10])+'\n';
768 displaytext += numberpattern.replace(/{Y}/,count)+'\n';
770 displaytext = displaytext.replace(/{X}/,startfrom1)+'<br \/>\n';
773 if(startfrom1>0 && !startfrom2 && !startfrom3){
774 var offset=eval(document.f.issuesexpected1.value);
778 for(var i=startfrom1;i<(startfrom1+offset);i+=every1){
779 displaytext += numberpattern.replace(/{X}/,i)+'<br \/>\n';
782 // displaytext = "<div style='padding: 5px; background-color: #CCCCCC'>"+displaytext+"<\/div>";
783 document.getElementById("displayexample").innerHTML = displaytext;
786 function isArray(obj) {
787 if (obj.constructor.toString().indexOf("Array") == -1)
793 function moreoptionsupdate(inputfield,rollover){
794 fieldname = inputfield.name;
795 // find parent element in base table by stripping 'temp' from element name.
796 basefield = document.getElementById(fieldname.slice(0,-4));
797 var fieldnumber = fieldname.slice(-5,-4);
799 // fieldnametemp = fieldname.slice(0,-1)+"temp"+fieldnametempnumber;
800 // eval("document.f."+fieldname+".value = document.f."+fieldnametemp+".value");
801 basefield.value = inputfield.value;
802 var patternchoice = document.getElementById("numberpattern").value;
803 switch(patternchoice){
808 if (document.f.lastvalue2temp.value>0){document.f.innerloop1.value = document.f.lastvalue2temp.value - 1;}
812 // eval("document.f.every"+(fieldnametempnumber-1)+".value = document.f."+fieldnametemp+".value");
813 // calculate rollover for higher level of periodicity.
814 // FIXME: This calculation only works if addN = 1 , that is, the X,Y,and Z each only increment by zero or one on each issue.
816 // if there are two levels of periodicity, (e.g. vol{X},num{Y},issue{Z}, then every1=every2*whenmorethan2
817 // otherwise, every2 == 1.
818 var addN = (document.getElementById('add'+fieldnumber)) ? document.getElementById('add'+fieldnumber).value : 1 ;
819 var everyN = (document.getElementById('every'+fieldnumber)) ? document.getElementById('every'+fieldnumber).value : 1 ;
820 document.getElementById('every'+(fieldnumber-1)).value = basefield.value * everyN / addN ;
825 function check_input(e){
826 var unicode=e.charCode? e.charCode : e.keyCode
827 if (unicode!=8 && unicode !=46 && unicode!=9 && unicode !=13){ // if key isn't backspace or delete
828 if (unicode<48||unicode>57) { // if not a number
829 alert(_("Needs to be entered in digit form -eg 10"));
830 return false // disable key press
835 function addbiblioPopup(biblionumber) {
836 var destination = "/cgi-bin/koha/cataloguing/addbiblio.pl?mode=popup";
837 if(biblionumber){ destination += "&biblionumber="+biblionumber; }
838 window.open(destination,'AddBiblioPopup','width=1024,height=768,toolbar=no,scrollbars=yes');
843 window.open('subscription-bib-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
846 function FindAcqui(f)
848 window.open('acqui-search.pl','FindASupplier','width=800,height=400,toolbar=no,scrollbars=yes');
851 function Find_ISSN(f)
853 window.open('issn-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
858 if (f.aqbooksellerid.value.length==0) {
859 input_box = confirm(_("If you wish to claim late or missing issues you must link this subscription to a vendor. Click OK to ignore or Cancel to return and enter a vendor"));
860 if (input_box==true) {
866 if (f.biblionumber.value.length==0) {
867 alert(_("You must choose or create a biblio"));
868 } else if(f.startdate.value.length != 0 && f.sublength.value > 0) {
869 if (f.irreg_check.value == 1) {
872 if(f.numbering_pattern.value == ''){
873 alert(_("Please choose a numbering pattern"));
875 alert(_("Please check for irregularity by clicking 'Test Prediction Pattern'"));
879 alert(_("You must choose a start date and a subscription length"));
881 if(irregular_issues.numskipped < irregular_issues.skipped.length ) {
882 alert(_("You have not accounted for all missing issues."));
887 $(document).ready(function() {
888 <!-- TMPL_IF name="mod" -->
889 set_num_pattern_from_template_vars();
890 <!-- TMPL_IF name="hemisphere" -->
891 is_hemisphere = <!-- TMPL_VAR NAME="hemisphere" --> ;
895 <!-- TMPL_IF name="irregularity" -->
896 irregularity_check();
899 $('#numberpattern').change( function() {
907 <!-- TMPL_INCLUDE NAME="header.inc" -->
908 <!-- TMPL_INCLUDE NAME="serials-search.inc" -->
910 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › <!-- TMPL_IF name="mod" --> Modify subscription for <span class="title"><!-- TMPL_VAR name="bibliotitle" --></span><!-- TMPL_ELSE -->New subscription<!-- /TMPL_IF --></div>
912 <div id="doc3" class="yui-t7">
916 <h1><!-- TMPL_IF name="mod" --> Modify subscription for <i><!-- TMPL_VAR name="bibliotitle" --></i><!-- TMPL_ELSE -->Add a new subscription<!-- /TMPL_IF --></h1>
917 <form method="post" name="f" action="/cgi-bin/koha/serials/subscription-add.pl">
918 <!-- TMPL_IF name="mod" -->
919 <input type="hidden" name="op" value="modsubscription" />
920 <input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->" />
922 <input type="hidden" name="op" value="addsubscription" />
924 <input type="hidden" name="user" value="<!-- TMPL_VAR name="loggedinusername" -->" />
925 <input type="hidden" name="irreg_check" value="0" />
926 <input type="hidden" name="issuesexpected1" id="issuesexpected1" value="0" />
928 <div class="yui-u first">
929 <fieldset id="subscription_add_information" class="rows">
930 <legend>Subscription details</legend>
932 <li><span class="label">Subscription #</span> <!--TMPL_VAR name="subscriptionid"--></li>
934 <span class="label">Librarian: </span> <!-- TMPL_VAR name="loggedinusername" -->
937 <label for="aqbooksellerid">Vendor: </label>
938 <input type="text" name="aqbooksellerid" id="aqbooksellerid" value="<!-- TMPL_VAR name="aqbooksellerid" -->" size="8" /> (<input type="text" name="aqbooksellername" value="<!-- TMPL_VAR name="aqbooksellername" -->" disabled="disabled" readonly="readonly" />) <div class="inputnote"><a href="#" onclick="FindAcqui(f)">Search for a vendor</a></div>
941 <label for="biblionumber" class="required" title="Subscriptions must be associated with a bibliographic record">Biblio:</label>
943 <input type="text" name="biblionumber" id="biblionumber" value="<!-- TMPL_VAR name="bibnum" -->" size="8" />
944 (<input type="text" name="title" value="<!-- TMPL_VAR name="bibliotitle" -->" disabled="disabled" readonly="readonly" />) <span class="required" title="Subscriptions must be associated with a bibliographic record">Required</span>
945 <div class="inputnote"> <a href="#" onclick="Plugin(f)">Search for Biblio</a> | <!--TMPL_IF Name="mod"--><a href="#" onclick="addbiblioPopup(<!-- TMPL_VAR NAME="bibnum" -->); return false;">Edit biblio</a><!-- TMPL_ELSE -->
946 <a href="#" onclick="addbiblioPopup(); return false;">Create Biblio</a><!--/TMPL_IF--></div>
950 <!-- TMPL_IF name="serialsadditems" -->
951 <p><input type="radio" id="serialsadditems-yes" name="serialsadditems" value="1" checked="checked" /><label for="serialsadditems-yes">create an item record when receiving this serial</label></p>
952 <p><input type="radio" id="serialsadditems-no" name="serialsadditems" value="0" /><label for="serialsadditems-no">do not create an item record when receiving this serial </label></p>
954 <p><input type="radio" id="serialsadditems-yes" name="serialsadditems" value="1"/><label for="serialsadditems-yes">create an item record when receiving this serial</label></p>
955 <p><input type="radio" id="serialsadditems-no" name="serialsadditems" value="0" checked="checked" /><label for="serialsadditems-no">do not create an item record when receiving this serial</label></p>
959 <label for="callnumber">Call Number:</label>
960 <input type="text" name="callnumber" id="callnumber" value="<!-- TMPL_VAR name="callnumber" -->" size="20" />
963 <label for="branchcode">Library:</label>
965 <select name="branchcode" id="branchcode" style="width: 20em;">
966 <!-- TMPL_UNLESS NAME="Independantbranches" --><option value="">None</option><!-- /TMPL_UNLESS -->
967 <!-- TMPL_LOOP name="branchloop" --><!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
969 <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
972 </select> (select a library)
976 <label for="notes">Public note:</label>
977 <textarea name="notes" id="notes" cols="30" rows="2"><!-- TMPL_VAR name="notes" --></textarea>
980 <label for="internalnotes">Nonpublic note:</label>
981 <textarea name="internalnotes" id="internalnotes" cols="30" rows="2"><!-- TMPL_VAR name="internalnotes" --></textarea>
984 <label for="letter">Patron notification: </label>
986 <!-- TMPL_IF NAME="letterloop" -->
987 <select name="letter" id="letter">
988 <option value="">None</option>
989 <!-- TMPL_LOOP name="letterloop" -->
990 <!-- TMPL_IF name="selected" -->
991 <option value="<!-- TMPL_VAR name="value" -->" selected="selected"><!-- TMPL_VAR name="lettername" --></option>
993 <option value="<!-- TMPL_VAR name="value" -->"><!-- TMPL_VAR name="lettername" --></option>
997 <div class="hint">Select a notice and patrons on the routing list will be notified when new issues are received.</div>
999 <div class="hint">To notify patrons of new serial issues, you must <a href="/cgi-bin/koha/tools/letter.pl">define a notice</a>.</div>
1004 <div style="float:left;clear:left;margin:1em;"><strong>Note:</strong>
1007 <li>The subscription <strong>must</strong> be associated with a bibliographic record.</li>
1008 <li>You <strong>must</strong> select a vendor if you wish to generate claims.</li>
1016 <div id="subscription_form_planning">
1017 <fieldset class="rows">
1018 <legend>Serials planning</legend>
1021 <label for="firstacquidate"> First issue publication date:</label>
1023 <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="button2" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
1024 <input type="text" name="firstacquidate" value="<!-- TMPL_VAR name="firstacquidate" -->" size="13" maxlength="10" id="acqui_date" style="border-width: 0px;" />
1025 <!-- both scripts for calendar must follow the input field -->
1026 <script type="text/javascript">
1028 inputField:"acqui_date",
1029 ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1034 <script type="text/javascript">
1036 inputField : "acqui_date",
1037 ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1038 button : "acqui_date",
1040 onUpdate : function(cal) { weeks = getWeeksArray(cal.date);
1047 <label for="periodicity" class="required">Frequency:</label>
1049 <select name="periodicity" size="1" id="periodicity" onchange="javascript:document.getElementsByName('manualhist')[0].checked=(this.value==1); reset_num_pattern();">
1050 <option value="" selected="selected">-- please choose --</option>
1051 <!-- TMPL_IF name="periodicity16" -->
1052 <option value="16" selected="selected">Without periodicity</option>
1054 <option value="16">Without periodicity</option>
1056 <!-- TMPL_IF name="periodicity48" -->
1057 <option value="48" selected="selected">Unknown</option>
1059 <option value="48">Unknown</option>
1061 <!-- TMPL_IF name="periodicity32" -->
1062 <option value="32" selected="selected">Irregular</option>
1064 <option value="32">Irregular</option>
1067 <!-- TMPL_IF name="periodicity12" -->
1068 <option value="12" selected="selected">2/day</option>
1070 <option value="12">2/day</option>
1072 <!-- TMPL_IF name="periodicity1" -->
1073 <option value="1" selected="selected">1/day</option>
1075 <option value="1">1/day</option>
1077 <!-- TMPL_IF name="periodicity13" -->
1078 <option value="13" selected="selected">3/week</option>
1080 <option value="13">3/week</option>
1082 <!-- TMPL_IF name="periodicity2" -->
1083 <option value="2" selected="selected">1/week</option>
1085 <option value="2">1/week</option>
1087 <!-- TMPL_IF name="periodicity3" -->
1088 <option value="3" selected="selected">1/2 weeks </option>
1090 <option value="3">1/2 weeks </option>
1092 <!-- TMPL_IF name="periodicity4" -->
1093 <option value="4" selected="selected">1/3 weeks</option>
1095 <option value="4">1/3 weeks</option>
1097 <!-- TMPL_IF name="periodicity5" -->
1098 <option value="5" selected="selected">1/month</option>
1100 <option value="5">1/month</option>
1102 <!-- TMPL_IF name="periodicity6" -->
1103 <option value="6" selected="selected">1/2 months (6/year)</option>
1105 <option value="6">1/2 months (6/year)</option>
1107 <!-- TMPL_IF name="periodicity7" -->
1108 <option value="7" selected="selected">1/3 months (1/quarter)</option>
1110 <option value="7">1/3 months (1/quarter)</option>
1112 <!-- periodicity8 is 1/quarter, exactly like periodicity7 but will use it for seasonal option -->
1113 <!-- TMPL_IF name="periodicity8" -->
1114 <option value="8" selected="selected">1/quarter (seasonal)</option>
1116 <option value="8">1/quarter (seasonal)</option>
1119 <!-- TMPL_IF name="periodicity9" -->
1120 <option value="9" selected="selected">2/years</option>
1122 <option value="9">2/year</option>
1124 <!-- TMPL_IF name="periodicity10" -->
1125 <option value="10" selected="selected">1/year</option>
1127 <option value="10">1/year</option>
1129 <!-- TMPL_IF name="periodicity11" -->
1130 <option value="11" selected="selected">1/2 years</option>
1132 <option value="11">1/2 years</option>
1134 </select> <span class="required">Required</span></li>
1135 <li><label for="manuallist"> Manual history:</label> <input type="checkbox" name="manualhist" id="manuallist" value="1" /></li>
1137 <label for="numberpattern"> Numbering pattern:</label>
1139 <select name="numbering_pattern" size="1" id="numberpattern" onchange="reset_num_pattern()">
1140 <option value="" selected="selected">-- please choose --</option>
1141 <!-- TMPL_IF name="numberpattern1" -->
1142 <option value="1" selected="selected">Number</option>
1144 <option value="1">Number</option>
1146 <!-- TMPL_IF name="numberpattern2" -->
1147 <option value="2" selected="selected">Volume, Number, Issue</option>
1149 <option value="2">Volume, Number, Issue</option>
1151 <!-- TMPL_IF name="numberpattern3" -->
1152 <option value="3" selected="selected">Volume, Number</option>
1154 <option value="3">Volume, Number</option>
1156 <!-- TMPL_IF name="numberpattern4" -->
1157 <option value="4" selected="selected">Volume, Issue</option>
1159 <option value="4">Volume, Issue</option>
1161 <!-- TMPL_IF name="numberpattern5" -->
1162 <option value="5" selected="selected">Number, Issue</option>
1164 <option value="5">Number, Issue</option>
1166 <!-- TMPL_IF name="numberpattern6" -->
1167 <option value="6" selected="selected">Seasonal only</option>
1169 <option value="6">Seasonal only</option>
1171 <!-- TMPL_IF name="numberpattern8" -->
1172 <option value="8" selected="selected">Year/Number</option>
1174 <option value="8">Year/Number</option>
1176 <!-- TMPL_IF name="numberpattern7" -->
1177 <option value="7" selected="selected">None of the above</option>
1179 <option value="7">None of the above</option>
1183 <li id="more_options"></li>
1184 <li id="irregularity"></li>
1185 <li id="displayexample"></li>
1187 <label for="startdate" class="required"> Subscription start date:</label>
1189 <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="button1" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
1190 <input type="text" name="startdate" value="<!-- TMPL_VAR name="startdate" -->" size="13" maxlength="10" id="beginning_date" style="border-width: 0px;" />
1191 <!-- both scripts for calendar must follow the input field -->
1192 <script type="text/javascript">
1194 inputField : "beginning_date",
1195 ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1200 <script type="text/javascript">
1202 inputField : "beginning_date",
1203 ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1204 button : "beginning_date",
1208 <span class="required">Required</span>
1211 <label for="subtype" class="required">Subscription length:</label>
1213 <select name="subtype" id="subtype">
1214 <!-- TMPL_LOOP NAME="subtype" -->
1215 <!-- TMPL_IF NAME="selected" -->
1216 <option value="<!-- TMPL_VAR NAME="name" -->" selected="selected">
1218 <option value="<!-- TMPL_VAR NAME="name" -->">
1220 <!-- TMPL_VAR NAME="name" -->
1224 <input type="text" name="sublength" value="<!-- TMPL_VAR name="sublength" -->" size="3" onkeypress="return check_input(event)" /> (enter amount in numerals)
1225 <span class="required">Required</span>
1227 <li><label for="numberingmethod">Numbering formula:</label> <input type="text" name="numberingmethod" id="numberingmethod" value="<!-- TMPL_VAR name="numberingmethod" -->" />
1232 <fieldset class="action">
1233 <input type="button" class="action_test" value="Test Prediction Pattern" onclick="javascript:irregularity_check()" />
1234 <input type="button" class="action_reset" value="Reset Pattern" onclick="javascript:reset_pattern()" />
1235 <input type="button" class="action_save" value="Save subscription" onclick="Check(this.form)" accesskey="w" />
1237 <fieldset class="action">
1238 <input type="button" class="action_advanced" value="Show/Hide Advanced Pattern" onclick="javascript:display_table()" />
1240 <div id="basetable" style="display: none;">
1241 <table class="small">
1242 <tr><th colspan="4">Advanced Prediction Pattern</th></tr>
1252 <input type="text" name="add1" id="add1" value="<!-- TMPL_VAR name="add1" -->" />
1255 <input type="text" name="add2" id="add2" value="<!-- TMPL_VAR name="add2" -->" />
1258 <input type="text" name="add3" id="add3" value="<!-- TMPL_VAR name="add3" -->" />
1263 <td><input type="text" name="every1" id="every1" value="<!-- TMPL_VAR name="every1" -->" /></td>
1264 <td><input type="text" name="every2" id="every2" value="<!-- TMPL_VAR name="every2" -->" /></td>
1265 <td><input type="text" name="every3" id="every3" value="<!-- TMPL_VAR name="every3" -->" /></td>
1268 <td>When more than</td>
1269 <td><input type="text" name="whenmorethan1" id="whenmorethan1" value="<!-- TMPL_VAR name="whenmorethan1" -->" /></td>
1270 <td><input type="text" name="whenmorethan2" id="whenmorethan2" value="<!-- TMPL_VAR name="whenmorethan2" -->" /></td>
1271 <td><input type="text" name="whenmorethan3" id="whenmorethan3" value="<!-- TMPL_VAR name="whenmorethan3" -->" /></td>
1274 <td>inner counter</td>
1275 <td><input type="text" name="innerloop1" id="innerloop1" value="<!-- TMPL_VAR name="innerloop1" -->" /></td>
1276 <td><input type="text" name="innerloop2" id="innerloop2" value="<!-- TMPL_VAR name="innerloop2" -->" /></td>
1277 <td><input type="text" name="innerloop3" id="innerloop3" value="<!-- TMPL_VAR name="innerloop3" -->" /></td>
1280 <td>Set back to</td>
1281 <td><input type="text" name="setto1" id="setto1" value="<!-- TMPL_VAR name="setto1" -->" /></td>
1282 <td><input type="text" name="setto2" id="setto2" value="<!-- TMPL_VAR name="setto2" -->" /></td>
1283 <td><input type="text" name="setto3" id="setto3" value="<!-- TMPL_VAR name="setto3" -->" /></td>
1287 <!-- TMPL_IF name="mod" -->
1293 <td><input type="text" name="lastvalue1" id="lastvalue1" value="<!-- TMPL_VAR name="lastvalue1" -->" /></td>
1294 <td><input type="text" name="lastvalue2" id="lastvalue2" value="<!-- TMPL_VAR name="lastvalue2" -->" /></td>
1295 <td><input type="text" name="lastvalue3" id="lastvalue3" value="<!-- TMPL_VAR name="lastvalue3" -->" /></td>
1305 <!--TMPL_IF Name="history"-->
1306 <div id="subscription_form_history">
1307 <h2>Subscription history</h2>
1308 <form method="post" action="/cgi-bin/koha/serials/subscription-add.pl">
1309 <input type="hidden" name="op" value="modsubscription" />
1310 <input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->" />
1311 <input type="hidden" name="history_only" value="1" />
1312 <p>Hint : you can update the serial history manually. This can be useful for an old subscription or to clean the existing history. Modify these fields with care, as future serial receive will continue to update them automatically.</p>
1315 <td>Subscription start date</td>
1316 <td><input type="text" name="histstartdate" value="<!-- TMPL_VAR name="histstartdate" -->" /> (start date of the 1st subscription)</td>
1319 <td>Subscription end date</td>
1320 <td><input type="text" name="histenddate" value="<!-- TMPL_VAR name="histenddate" -->" />(if empty, subscription is still active)</td>
1323 <td>Received issues</td>
1324 <td><textarea name="recievedlist" cols="60" rows="5"><!-- TMPL_VAR name="recievedlist" --></textarea></td>
1327 <td>Missing issues</td>
1328 <td><textarea name="missinglist" cols="60" rows="5"><!-- TMPL_VAR name="missinglist" --></textarea></td>
1331 <td>Note for OPAC</td>
1332 <td><textarea name="opacnote" cols="60" rows="5"><!-- TMPL_VAR name="opacnote" --></textarea></td>
1335 <td>Note for staff</td>
1336 <td><textarea name="librariannote" cols="60" rows="5"><!-- TMPL_VAR name="librariannote" --></textarea></td>
1339 <input type="submit" value="Save subscription history" />
1346 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->