Changing pattern Number to Number only.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / serials / subscription-add.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Serials</title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4
5 <!-- TMPL_INCLUDE NAME="menus.inc" -->
6 <!--TMPL_INCLUDE NAME="menu-serials.inc" -->
7
8 <!-- Additions to enable Calendar system -->
9 <link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/includes/calendar/calendar-system.css">
10 <!-- End of additions -->
11
12 <!-- Additions to enable Calendar system -->
13 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/includes/calendar/calendar.js"></script>
14 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/includes/calendar/calendar-en.js"></script>
15 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/includes/calendar/calendar-setup.js"></script>
16 <!-- End of additions -->
17
18 <script type="text/javascript" language="javascript">
19 <!--
20     function _(s) { return s } // dummy function for gettext
21
22 // the english words used in display purposes
23 var text = new Array(_('Number'),_('Volume'),_('Issue'),_('Month'),_('Week'),_('Starting with:'),_('Rollover at:'),_('Choose Hemisphere:'),_('Northern'),_('Southern'),
24 _('Autumn'),_('Winter'),_('Spring'),_('Summer'),_('Fall'),_('Season'),_('Year'));
25 var is_season = 0;
26 var is_hemisphere = 1;
27
28 // common pre defined number patterns
29 function num_pattern() {
30 var patternchoice = document.getElementById("numberpattern").value;
31     switch(patternchoice){
32     case "2":
33         document.f.add1.value=1;
34         document.f.add2.value=1;
35         document.f.add3.value=1;
36         document.f.every1.value=12;
37         document.f.every2.value=1;
38         document.f.every3.value=1;
39         document.f.whenmorethan1.value=9999999;
40         document.f.whenmorethan2.value=12;
41         document.f.whenmorethan3.value=4;
42         document.f.setto1.value=0;
43         document.f.setto2.value=1;
44         document.f.setto3.value=1;
45         document.f.lastvalue1.value=1;
46         document.f.lastvalue2.value=1;
47         document.f.lastvalue3.value=1;
48         document.f.numberingmethod.value=_('Vol {X}, No {Y}, Issue {Z}');
49         moreoptions(text[1],text[0],text[2]);
50         display_table(0); // toggle info box on (1) or off (0)
51         break;
52     case "3":
53         document.f.add1.value=1;
54         document.f.add2.value=1;
55         document.f.add3.value='';
56         document.f.every1.value=12;
57         document.f.every2.value=1;
58         document.f.every3.value='';
59         document.f.whenmorethan1.value=9999999;
60         document.f.whenmorethan2.value=12;
61         document.f.whenmorethan3.value='';
62         document.f.setto1.value=0;
63         document.f.setto2.value=1;
64         document.f.setto3.value='';
65         document.f.lastvalue1.value=1;
66         document.f.lastvalue2.value=1;
67         document.f.lastvalue3.value='';
68         document.f.numberingmethod.value=_('Vol {X}, No {Y}');
69         moreoptions(text[1],text[0]);
70         display_table(0);
71         break;
72     case "4":
73         document.f.add1.value=1;
74         document.f.add2.value=1;
75         document.f.add3.value='';
76         document.f.every1.value=12;
77         document.f.every2.value=1;
78         document.f.every3.value='';
79         document.f.whenmorethan1.value=9999999;
80         document.f.whenmorethan2.value=12;
81         document.f.whenmorethan3.value='';
82         document.f.setto1.value=0;
83         document.f.setto2.value=1;
84         document.f.setto3.value='';
85         document.f.lastvalue1.value=1;
86         document.f.lastvalue2.value=1;
87         document.f.lastvalue3.value='';
88         document.f.numberingmethod.value=_('Vol {X}, Issue {Y}');
89         moreoptions(text[1],text[2]);
90         display_table(0);
91         break;
92     case "5":
93         document.f.add1.value=1;
94         document.f.add2.value=1;
95         document.f.add3.value='';
96         document.f.every1.value=12;
97         document.f.every2.value=1;
98         document.f.every3.value='';
99         document.f.whenmorethan1.value=9999999;
100         document.f.whenmorethan2.value=12;
101         document.f.whenmorethan3.value='';
102         document.f.setto1.value=0;
103         document.f.setto2.value=1;
104         document.f.setto3.value='';
105         document.f.lastvalue1.value=1;
106         document.f.lastvalue2.value=1;
107         document.f.lastvalue3.value='';
108         document.f.numberingmethod.value=_('No {X}, Issue {Y}');
109         moreoptions(text[0],text[2]);
110         display_table(0);
111         break;
112     case "6":
113         var d = new Date();
114         var sYear = d.getFullYear();
115         document.f.add1.value=1;
116         document.f.add2.value='1';
117         document.f.add3.value='';
118         document.f.every1.value=4;
119         document.f.every2.value='1';
120         document.f.every3.value='';
121         document.f.whenmorethan1.value=9999999;
122         document.f.whenmorethan2.value='4';
123         document.f.whenmorethan3.value='';
124         document.f.setto1.value=0;
125         document.f.setto2.value='1';
126         document.f.setto3.value='';
127         document.f.lastvalue1.value=sYear;
128         document.f.lastvalue2.value='1';
129         document.f.lastvalue3.value='';
130         document.f.periodicity.value='8';
131         document.f.numberingmethod.value=_('{Y} {X}');
132         moreoptions_seasons(text[15],sYear);
133         display_table(0);
134         is_season = 1;
135         break;
136     case "7":
137         display_table(1);
138         document.getElementById("more_options").innerHTML = '';
139         document.f.irreg_check.value=1; 
140         break;
141     default:
142         document.f.add1.value=1;
143         document.f.add2.value='';
144         document.f.add3.value='';
145         document.f.every1.value=1;
146         document.f.every2.value='';
147         document.f.every3.value='';
148         document.f.whenmorethan1.value=9999999;
149         document.f.whenmorethan2.value='';
150         document.f.whenmorethan3.value='';
151         document.f.setto1.value=0;
152         document.f.setto2.value='';
153         document.f.setto3.value='';
154         document.f.lastvalue1.value=1;
155         document.f.lastvalue2.value='';
156         document.f.lastvalue3.value='';
157         document.f.numberingmethod.value='{X}';
158         moreoptions_daily_check(text[0]);
159         document.f.irreg_check.value=1;
160         display_table(0);
161         break;
162     }
163 }
164
165 function display_table(n) {
166     if(n==1){
167         document.getElementById("basetable").style.display = 'block';
168     } else {
169         document.getElementById("basetable").style.display = 'none';
170     }
171 }
172
173 function modify_num_pattern() {
174     document.getElementById("numberpattern").value = '<!-- TMPL_VAR NAME="numberpattern" -->';
175     num_pattern();
176     
177     document.f.add1.value='<!-- TMPL_VAR NAME="add1" -->';
178     document.f.add2.value='<!-- TMPL_VAR NAME="add2" -->';
179     document.f.add3.value='<!-- TMPL_VAR NAME="add3" -->';
180     document.f.every1.value='<!-- TMPL_VAR NAME="every1" -->';
181     document.f.every2.value='<!-- TMPL_VAR NAME="every2" -->';
182     document.f.every3.value='<!-- TMPL_VAR NAME="every3" -->';
183     document.f.whenmorethan1.value='<!-- TMPL_VAR NAME="whenmorethan1" -->';
184     document.f.whenmorethan2.value='<!-- TMPL_VAR NAME="whenmorethan2" -->';
185     document.f.whenmorethan3.value='<!-- TMPL_VAR NAME="whenmorethan3" -->';
186     document.f.setto1.value='<!-- TMPL_VAR NAME="setto1" -->';
187     document.f.setto2.value='<!-- TMPL_VAR NAME="setto2" -->';
188     document.f.setto3.value='<!-- TMPL_VAR NAME="setto3" -->';
189     document.f.lastvalue1.value='<!-- TMPL_VAR NAME="lastvalue1" -->';
190     document.f.lastvalue2.value='<!-- TMPL_VAR NAME="lastvalue2" -->';
191     document.f.lastvalue3.value='<!-- TMPL_VAR NAME="lastvalue3" -->';
192     document.f.numberingmethod.value='<!-- TMPL_VAR NAME="numberingmethod" -->';
193
194     var more_strY;
195     var more_strZ;
196     <!-- TMPL_IF NAME="add2" -->
197     if(<!-- TMPL_VAR NAME="add2" --> > 0){
198         more_strY="Y";
199     }
200     <!-- /TMPL_IF -->
201     <!-- TMPL_IF NAME="add3" -->
202     if(<!-- TMPL_VAR NAME="add3" --> > 0){
203         more_strZ="Z";
204     }
205     <!-- /TMPL_IF -->
206
207     document.f.lastvaluetemp1.value='<!-- TMPL_VAR NAME="lastvalue1" -->';
208     if(more_strY){
209         document.f.lastvaluetemp2.value='<!-- TMPL_VAR NAME="lastvalue2" -->';
210     document.f.whenmorethantemp2.value='<!-- TMPL_VAR NAME="whenmorethan2" -->';
211     }
212     if(more_strZ){
213         document.f.lastvaluetemp3.value='<!-- TMPL_VAR NAME="lastvalue3" -->';
214     document.f.whenmorethantemp3.value='<!-- TMPL_VAR NAME="whenmorethan3" -->';
215     }
216 }
217
218 // a pre check with more options to see if 'number' and '1/day' are chosen
219 function moreoptions_daily_check(x) {
220     var periodicity = document.f.periodicity.value;
221     var errortext='';
222     if(periodicity == 1){
223         document.getElementById("irregularity").innerHTML = '';
224         var daynames = new Array(_('Monday'),_('Tuesday'),_('Wednesday'),_('Thursday'),_('Friday'),_('Saturday'),_('Sunday'));
225         errortext =_("Please indicate which days of the week you <b>DO NOT<\/b> expect to receive issues.<br \/>");
226         for(var j=0;j<daynames.length;j++){
227             errortext +="<input type='checkbox' name='irregular' id='irregular"+(j+1)+"' value='"+(j+1)+"' />"+daynames[j]+" &nbsp; ";
228         }
229         var error = errortext;
230         moreoptions(x);
231         document.getElementById("irregularity").innerHTML = error;
232     } else {
233         document.getElementById("irregularity").innerHTML = '';
234         document.getElementById("more_options").innerHTML = '';
235         moreoptions(x);
236     }
237 }
238
239 // to dispaly the more options section
240 function moreoptions(x,y,z){
241 document.getElementById("irregularity").innerHTML = '';
242 document.getElementById("more_options").innerHTML = '';
243 var textbox = '';
244     // alert("X: "+x+"Y: "+y+"Z: "+z);
245     if(x){
246         textbox +="<table>\n<tr><td>&nbsp;<\/td><td>"+x+"<\/td>";
247         if(y){
248             textbox +="<td>"+y+"<\/td>";
249             if(z){
250                 textbox +="<td>"+z+"<\/td>";
251             }
252         }
253         textbox +="<\/tr>\n";
254         textbox +="<tr><td>"+text[5]+"<\/td><td><input type='text' name='lastvaluetemp1' size='4' onkeyup='moreoptionsupdate(\"lastvalue1\")'><\/td>\n";
255         if(y){
256             textbox +="<td><input type='text' name='lastvaluetemp2' size='4' onkeyup='moreoptionsupdate(\"lastvalue2\")'><\/td>\n";
257             if(z){
258                 textbox +="<td><input type='text' name='lastvaluetemp3' size='4' onkeyup='moreoptionsupdate(\"lastvalue3\")'><\/td>\n";
259             }
260         }
261         textbox +="<\/tr>\n";
262         if(y){
263             textbox +="<tr><td>"+text[6]+"<\/td>";
264             textbox +="<td><a href='javascript:irregularity_check()'>"+_('Irregularity?')+"<\/a><\/td>\n";
265             textbox +="<td><input type='text' name='whenmorethantemp2' size='4' onkeyup='moreoptionsupdate(\"whenmorethan2\",1)'><\/td>\n";
266             if(z){
267                 textbox +="<td><input type='text' name='whenmorethantemp3' size='4' onkeyup='moreoptionsupdate(\"whenmorethan3\",1)'><\/td>\n";
268             }
269             textbox +="<\/tr>";
270         } else {
271           textbox +="<tr> <td>"+_('issues expected')+"</td><td><input type='text' name='issuesexpectedtemp1' size='4' onkeyup='moreoptionsupdate(\"issuesexpected1\",0)'><br/><a href='javascript:irregularity_check()'>"+_('Irregularity?')+"</a></td></tr>";
272         }
273         textbox +="<\/table>\n";
274     }
275     document.getElementById("more_options").innerHTML = textbox;
276 }
277
278 function hemispheres(chosen){
279 var selbox = document.getElementById("season1");
280     if(selbox){
281     var selboxselected = selbox.options[selbox.selectedIndex].value;
282     selbox.options.length = 0;
283
284     if (chosen == "1") {
285         selbox.options[selbox.options.length] = new Option(text[11],'1');
286         selbox.options[selbox.options.length] = new Option(text[12],'2');
287         selbox.options[selbox.options.length] = new Option(text[13],'3');
288         selbox.options[selbox.options.length] = new Option(text[14],'4');
289         is_hemisphere = 1;
290         selbox.options[selboxselected-1].selected = true;
291     }
292
293     if (chosen == "2") {
294         selbox.options[selbox.options.length] = new Option(text[13],'1');
295         selbox.options[selbox.options.length] = new Option(text[10],'2');
296         selbox.options[selbox.options.length] = new Option(text[11],'3');
297         selbox.options[selbox.options.length] = new Option(text[12],'4');
298         is_hemisphere = 2;
299         selbox.options[selboxselected-1].selected = true;
300     }
301     }
302 }
303
304 // to dispaly the more options section for seasons
305 function moreoptions_seasons(x,y){
306 document.getElementById("irregularity").innerHTML = '';
307 document.getElementById("more_options").innerHTML = '';
308 var textbox = '';
309     // alert("X: "+x+"Year: "+y);
310     if(x){
311         var hemi_select = parseInt('<!-- TMPL_VAR NAME="hemisphere" -->');
312         textbox +="<table>\n<tr><td>"+ text[7]  +"<\/td><td colspan='2'><select name='hemisphere' onchange='hemispheres(this.options[this.selectedIndex].value)'>";
313         for(var i = 1; i <= 2; i++){
314             textbox +="<option value='"+i+"'";
315             if(i == hemi_select){
316                 textbox += " selected "
317             }
318             textbox +=">"+text[i+7]+"<\/option>";
319         }
320         textbox +="<\/select><\/td><\/tr>\n";
321         textbox +="<tr><td>&nbsp;<\/td><td>"+x+"<\/td>";
322         textbox +="<td>"+text[16]+"<\/td>";
323         textbox +="<\/tr>\n";
324         textbox +="<tr><td>"+text[5]+"<\/td><td><select name='lastvaluetemp2' id='season1' onchange='moreoptionsupdate(\"lastvalue2\")'>";
325         for(var j = 1; j <= 4; j++){
326             textbox +="<option value='"+j+"'>"+text[j+10]+"<\/option>";
327         }
328         textbox +="<\/select><\/td><td><select name='lastvaluetemp1' onchange='moreoptionsupdate(\"lastvalue1\")'>";
329         for(var k = parseInt(y); k <= parseInt(y)+15; k++){
330             textbox +="<option value='"+k+"'>"+k+"<\/option>";
331         }
332         textbox +="<\/select><\/td><\/tr>\n";
333         textbox +="<tr><td>"+text[6]+"<\/td>";
334         textbox +="<td><a href='javascript:irregularity_check()'>"+_('Irregularity?')+"<\/a><\/td>\n";
335         textbox +="<td><input type='text' name='whenmorethantemp2' size='4' onkeyup='moreoptionsupdate(\"whenmorethan2\",1)'><\/td>\n";
336                 textbox +="<\/tr><\/table>\n";
337     }
338     document.getElementById("more_options").innerHTML = textbox;
339 }
340
341 function irregularity_check(){
342     document.f.irreg_check.value = 1; // Irregularity button now pushed
343     var periodicity = document.f.periodicity.value;
344     var rollover = document.f.issuesexpected1.value;
345     if(document.f.whenmorethantemp2){
346       rollover = document.f.whenmorethantemp2.value;
347     }
348     if(document.f.whenmorethantemp3){
349         rollover = document.f.whenmorethantemp3.value;
350     }
351     var error='';
352     var toobig;
353     var expected; 
354     var errortext = _("<b>Warning irregularity detected<\/b><br \/>");
355     switch(periodicity){
356     case "1":
357         if(rollover < 365) expected =365;
358         if(rollover > 365) {
359             expectedover=365;
360             toobig=1;
361         }
362         break;
363     case "2":
364         if(rollover < 52) expected =52;
365         if(rollover > 52){
366             expectedover=52;
367             toobig=1;
368         }
369         break;
370     case "3":
371         if(rollover < 26) expected =26;
372         if(rollover > 26){
373             expectedover=26;
374             toobig=1;
375         }
376         break;
377     case "4":
378         if(rollover < 17) expected =17;
379         if(rollover > 17){
380             expectedover=17;
381             toobig=1;
382         }
383         break;
384     case "5":
385         if(rollover < 12) expected =12;
386         if(rollover > 12){
387             expectedover=12;
388             toobig=1;
389         }
390         break;
391     case "6":
392         if(rollover < 6) expected =6;
393         if(rollover > 6){
394             expectedover=6;
395             toobig=1;
396         }
397         break;
398     case "7":
399         if(rollover < 4) expected =4;
400         if(rollover > 4){
401             expectedover=4;
402             toobig=1;
403         }
404         break;
405     case "8":
406         if(rollover < 4) expected =4;
407         if(rollover > 4){
408             expectedover=4;
409             toobig=1;
410         }
411         break;
412     case "9":
413         if(rollover < 2) expected =2;
414         if(rollover > 2){
415             expectedover=2;
416             toobig=1;
417         }
418         break;
419     case "10":
420         if(rollover < 1) expected =1;
421         if(rollover > 1){
422             expectedover=1;
423             toobig=1;
424         }
425         break;
426     default:
427         break;
428     }
429     if(expected){
430         if(expected == 365){
431             var daynames = new Array(_('Monday'),_('Tuesday'),_('Wednesday'),_('Thursday'),_('Friday'),_('Saturday'),_('Sunday'));
432             errortext += _("Please indicate which days of the week you <b>DO NOT<\/b> expect to receive issues.<br \/>");
433             for(var j=0;j<daynames.length;j++){
434                 errortext +="<input type='checkbox' name='irregular' id='irregular"+(j+1)+"' value='"+(j+1)+"' />"+daynames[j]+" &nbsp; ";
435             }
436             error=errortext;
437         } else {
438             errortext +=expected+_(" issues expected ")+rollover+_(" were entered. <br \/>Please indicate which date(s) an issue is not expected<br \/>");
439             var count=0;
440             for(var i=rollover;i<expected;i++){
441                 errortext +="<select name='irregular' id='irregular"+count+"' onchange='display_example(expected)'>\n";
442                 errortext +=irregular_options(periodicity);
443                 errortext +="<\/select>\n";
444                 count++;
445             }
446             error=errortext;
447         }
448     }
449     if(toobig){
450         errortext +=expectedover+_(" issues expected ")+rollover+_(" were entered.<br \/> You seem to have indicated more issues per year than expected.");
451         error=errortext;
452     }
453     if(error.length ==0){
454         error=_('No irregularities noticed');
455     }
456     display_example(expected);
457     document.getElementById("irregularity").innerHTML = error;
458 }
459
460 function irregular_options(periodicity){
461     var titles;
462     var count;
463 <!-- TMPL_IF NAME="weekarrayjs" -->
464     var weeks = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->); 
465 <!-- /TMPL_IF -->
466     var months = new Array(_('January'),_('February'),_('March'),_('April'),_('May'),_('June'),_('July'),_('August'),_('September'),_('October'),_('November'),_('December'));
467     var seasons = new Array(_('Autumn'),_('Winter'),_('Spring'),_('Summer'),_('Fall'));
468     var errortext='';
469     if(periodicity == 1) {
470         expected = 366;
471         titles = "Day";
472         count = 1;
473     }
474     if(periodicity == 2 || periodicity == 3 || periodicity == 4) { 
475         expected = 52;
476     <!-- TMPL_IF NAME="weekarrayjs" -->
477         titles = weeks;
478         count = <!-- TMPL_VAR NAME="weekno" -->;
479     <!-- TMPL_ELSE -->
480         titles = "Week";
481         count = 1;
482     <!-- /TMPL_IF -->
483     }
484     if(periodicity == 5 || periodicity == 6 || periodicity == 7 || periodicity == 8 || periodicity == 9) {
485         if(periodicity == 8) {
486             is_season = 1; // setting up from edit page
487         } 
488         if(is_season){
489             titles = seasons;
490             expected = 4;
491             if(is_hemisphere == 2){
492                 count = 2;
493             } else {
494                 count = 1;
495             }
496         } else {
497             titles = months;
498             expected = 12;
499             count = 1;
500         }
501     }
502     for(var j=1;j<=expected;j++){
503         if(isArray(titles)){
504             if(count>expected){
505                 count = count-expected;
506             }
507             if(is_season && is_hemisphere == 1){
508                 errortext +="<option value='"+((count*3)-2)+"'>"+titles[j]+"<\/option>\n";
509 // alert("value: "+((count*3)-2)+" title: "+titles[j]);
510             } else if(is_season && is_hemisphere == 2){
511                 errortext +="<option value='"+((count*3)-2)+"'>"+titles[j-1]+"<\/option>\n";
512 // alert("value: "+((count*3)-2)+" title: "+titles[j-1]);
513             } else {
514                 errortext +="<option value='"+count+"'>"+titles[j-1]+"<\/option>\n";
515             }
516             count++;
517         } else {
518             errortext +="<option value='"+j+"'>"+titles+" "+j+"<\/option>\n";
519         }
520     }
521     return errortext;
522 }
523
524 function irregular_order(){
525     var irregular = '<!-- TMPL_VAR NAME="irregularity" -->';
526     var periodicity = document.f.periodicity.value;
527     var irregarray = irregular.split(',');
528     if(periodicity ==1){
529         for(j=0;j<irregarray.length;j++){
530         document.getElementById("irregular"+irregarray[j]).checked = true; 
531         }
532     } else {
533         for(i=0;i<irregarray.length;i++){    
534             document.getElementById("irregular"+i).value = irregarray[i];
535         }
536     }
537 }
538
539 function display_example(expected){
540     var startfrom1 = parseInt(document.f.lastvalue1.value);
541     var startfrom2 = parseInt(document.f.lastvalue2.value);
542     var startfrom3 = parseInt(document.f.lastvalue3.value);
543     var every1 = parseInt(document.f.every1.value);
544     var every2 = parseInt(document.f.every2.value);
545     var every3 = parseInt(document.f.every3.value);
546     var numberpattern = document.f.numberingmethod.value;
547     var whenmorethan2 = parseInt(document.f.whenmorethan2.value);
548     var whenmorethan3 = parseInt(document.f.whenmorethan3.value);
549     var setto2 = parseInt(document.f.setto2.value);
550     var setto3 = parseInt(document.f.setto3.value);
551     var displaytext = _('Based on the information<br \/>entered the Numbering Pattern<br \/>will look like this<br \/>\n');
552     if(startfrom3>0){
553         var count=startfrom3-1;
554         var count2=startfrom2;
555         for(var i=0;i<12;i++){
556             if(count>=whenmorethan3){
557                 count=setto3;
558                 if(count2>=whenmorethan2){
559                     startfrom1++;
560                     count2=setto2;
561                 } else {
562                     count2++;
563                 }
564             } else {
565                 count++;
566             }
567             displaytext += numberpattern.replace(/{Z}/,count)+'\n';
568             displaytext = displaytext.replace(/{Y}/,count2)+'<br \/>\n';
569             displaytext = displaytext.replace(/{X}/,startfrom1)+'<br \/>\n';
570
571         }
572     }
573     if(startfrom2>0 && !startfrom3){
574         var count=startfrom2-1;
575         for(var i=0;i<12;i++){
576             if(count>=whenmorethan2){
577                 startfrom1++;
578                 count=setto2;
579             } else {
580                 count++;
581             }
582
583             if(is_season){
584                 if(is_hemisphere == 2){
585                     if(count == 1) {
586                         displaytext += numberpattern.replace(/{Y}/,text[count+12])+'\n';
587                     } else {
588                         displaytext += numberpattern.replace(/{Y}/,text[count+8])+'\n';
589                     }
590                 } else {
591                 displaytext += numberpattern.replace(/{Y}/,text[count+10])+'\n';
592                 }
593             } else {
594                 displaytext += numberpattern.replace(/{Y}/,count)+'\n';
595             }
596             displaytext = displaytext.replace(/{X}/,startfrom1)+'<br \/>\n';
597         }
598     }
599     if(startfrom1>0 && !startfrom2 && !startfrom3){
600         var offset=eval(document.f.issuesexpected1.value);
601         if (!offset){
602             offset = 12 
603         }
604         for(var i=startfrom1;i<(startfrom1+offset);i+=every1){
605             displaytext += numberpattern.replace(/{X}/,i)+'<br \/>\n';
606         }
607     }
608     displaytext = "<div style='padding: 5px; background-color: #CCCCCC'>"+displaytext+"<\/div>";
609     document.getElementById("displayexample").innerHTML = displaytext;
610 }
611
612 function isArray(obj) {
613 if (obj.constructor.toString().indexOf("Array") == -1)
614     return false;
615 else
616     return true;
617 }
618
619 function moreoptionsupdate(fieldnames,rollover){
620     fieldname = fieldnames;
621     fld = fieldname.length;
622     fld = fld-1;
623     fieldnametempnumber = fieldname.substr(fld);
624     //alert(fieldnametempnumber);
625     fieldnametemp = fieldname.slice(0,-1)+"temp"+fieldnametempnumber;
626     // alert(fieldnametemp);
627     eval("document.f."+fieldname+".value = document.f."+fieldnametemp+".value");
628 //     alert (fieldname+" : "+eval("document.f."+fieldname+".value") +' '+fieldnametemp+' : ' +eval("document.f."+fieldnametemp+".value"));
629     if(rollover){
630         eval("document.f.every"+(fieldnametempnumber-1)+".value = document.f."+fieldnametemp+".value");
631     }
632 }
633
634
635 function check_input(e){
636     var unicode=e.charCode? e.charCode : e.keyCode
637     if (unicode!=8 && unicode !=46 && unicode!=9 && unicode !=13){ // if key isn't backspace or delete
638         if (unicode<48||unicode>57) { // if not a number
639             alert(_("Needs to be entered in digit form -eg 10"));
640             return false // disable key press
641         }
642     }
643 }
644
645 -->
646 </script>
647
648 <!-- TMPL_IF name="mod" -->
649     <h1>Modify a subscription</h1>
650     <form method="post" name="f">
651         <input type="hidden" name="op" value="modsubscription">
652         <input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->">
653 <!-- TMPL_ELSE -->
654     <h1>Add a subscription (Serial Holdings Record)</h1>
655     <form method="post" name="f">
656         <input type="hidden" name="op" value="addsubscription">
657 <!-- /TMPL_IF -->
658 <input type="hidden" name="user" value="<!-- TMPL_VAR name="loggedinusername" -->">
659 <input type="hidden" name="irreg_check" value="0">
660 <input type="hidden" name="issuesexpected1" value="0">
661
662
663 <div id="subscription_form">
664     <h2>Subscription information for subscription #<!--TMPL_VAR name="subscriptionid"--></h2>
665     <table>
666         <tr>
667             <td>Librarian:</td>
668             <td><!-- TMPL_VAR name="loggedinusername" --></td>
669         </tr>
670         <tr>
671             <td><label>Supplier:</label></td>
672             <td><input type="text" name="aqbooksellerid" value="<!-- TMPL_VAR name="aqbooksellerid" -->" size="8"> (<input type="text" name="aqbooksellername" value="<!-- TMPL_VAR name="aqbooksellername" -->" disabled readonly>) <a href="#" onClick="FindAcqui(f)">Search for a Supplier</a></td>
673         </tr>
674         <tr>
675             <td><label>Biblio</label></td>
676             <td>
677                 <input type="text" name="biblionumber" value="<!-- TMPL_VAR name="biblionumber" -->" size="8"> 
678                 (<input type="text" name="title" value="<!-- TMPL_VAR name="bibliotitle" -->" disabled readonly>)
679                 <a href="#" onClick="Plugin(f)">Search for Biblio</a> <!--TMPL_UNLESS Name="mod"--> |
680                 <a href="/cgi-bin/koha/cataloguing/addbiblio.pl">Create Biblio</a><!--/TMPL_UNLESS-->
681             </td>
682         </tr>
683         <tr>
684             <td><label>Call Number</label></td>
685             <td><input type="text" name="callnumber" value="<!-- TMPL_VAR name="callnumber" -->" size="20"></td>
686         </tr>
687         <tr>
688             <td>Branch</td>
689             <td>
690                 <select name="branchcode">
691                     <option value="">Any branch</option>
692                     <!-- TMPL_LOOP name="branchloop" -->
693                         <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
694                     <!-- /TMPL_LOOP -->
695                 </select> (select a branch)
696             </td>
697         </tr>
698         <tr>
699             <td><label>Notes</label></td>
700             <td><textarea name="notes" cols="30" rows="2"><!-- TMPL_VAR name="notes" --></textarea></td>
701         </tr>
702         <tr>
703             <td><label>Management Notes</label></td>
704             <td><textarea name="internalnotes" cols="30" rows="2"><!-- TMPL_VAR name="internalnotes" --></textarea></td>
705         </tr>
706         <tr>
707             <td>Patron alert with </td>
708             <td>
709                 <select name="letter">
710                     <option value="">un-activated</option>
711                 <!-- TMPL_LOOP name="letterloop" -->
712                     <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="lettername" --></option>
713                 <!-- /TMPL_LOOP -->
714                 </select> (select a letter &amp; patrons will be able to "follow" this subscription and recieve a mail on every new issue)
715             </td>
716         </tr>
717         <tr>
718             <td><b>Warning:</b></td>
719             <td>
720                 <ul>
721                     <li>Remember you <b>must</b> have created a biblio <b>before</b> creating a subscription</li>
722                     <li>You also must have selected a supplier if you want to ask for late issues</li>
723                 </ul>
724             </td>
725         </tr>
726     </table>
727 <div>
728 <div id="subscription_form_planning">
729     <h2>Planning</h2>
730     <table>
731         <tr>
732             <td>First Issue ETA:</td>
733             <td>
734                 <img src="<!-- TMPL_VAR Name="themelang" -->/includes/calendar/cal.gif" id="button2" style="cursor: pointer;"  />
735                 <input type="text" name="firstacquidate" value="<!-- TMPL_VAR name="startdate" -->" size=13 maxlength=10 id="acqui_date" style="border-width: 0px;" />
736                 <!-- both scripts for calendar must follow the input field --> 
737                 <script type="text/javascript">
738                     Calendar.setup({
739                         inputField:"acqui_date",
740                         ifFormat       :   "%d/%m/%Y",
741                         button         :   "button2",
742                         align          :   "Tl"
743                     });
744                 </script>
745                 <script type="text/javascript">
746                     Calendar.setup({
747                         inputField     :   "acqui_date",
748                         ifFormat       :   "%d/%m/%Y",
749                         button         :   "acqui_date",
750                         align          :   "Tl"
751                     });
752                 </script>
753             </td>
754             <td rowspan="5">
755                 <div id="displayexample"></div>
756             </td>
757         </tr>
758         <tr>
759             <td>Frequency: (*)</td>
760             <td>
761                 <select name="periodicity" size="1" onchange="javascript:document.getElementsByName('manualhist')[0].checked=(this.value==1);num_pattern;">
762                 <option value="" selected>-- please choose --</option>
763                 <option value="">Unknown</option>
764
765                 <!-- TMPL_IF name="periodicity1" -->
766                     <option value="1" selected>1/day</option>
767                 <!-- TMPL_ELSE -->
768                     <option value="1">1/day</option>
769                 <!-- /TMPL_IF -->
770                 <!-- TMPL_IF name="periodicity2" -->
771                     <option value="2" selected>1/week</option>
772                 <!-- TMPL_ELSE -->
773                     <option value="2">1/week</option>
774                 <!-- /TMPL_IF -->
775                 <!-- TMPL_IF name="periodicity3" -->
776                     <option value="3" selected>1/2 weeks (2/month)</option>
777                 <!-- TMPL_ELSE -->
778                     <option value="3">1/2 weeks (2/months)</option>
779                 <!-- /TMPL_IF -->
780                 <!-- TMPL_IF name="periodicity4" -->
781                     <option value="4" selected>1/3 weeks</option>
782                 <!-- TMPL_ELSE -->
783                     <option value="4">1/3 weeks</option>
784                 <!-- /TMPL_IF -->
785                 <!-- TMPL_IF name="periodicity5" -->
786                     <option value="5" selected>1/month</option>
787                 <!-- TMPL_ELSE -->
788                     <option value="5">1/month</option>
789                 <!-- /TMPL_IF -->
790                 <!-- TMPL_IF name="periodicity6" -->
791                     <option value="6" selected>1/2 months (6/year)</option>
792                 <!-- TMPL_ELSE -->
793                     <option value="6">1/2 months (6/year)</option>
794                 <!-- /TMPL_IF -->
795                 <!-- TMPL_IF name="periodicity7" -->
796                     <option value="7" selected>1/3 months (1/quarter)</option>
797                 <!-- TMPL_ELSE -->
798                     <option value="7">1/3 months (1/quarter)</option>
799                 <!-- /TMPL_IF -->
800                 <!-- periodicity8 is 1/quarter, exactly like periodicity7 but will use it for seasonal option -->
801                 <!-- TMPL_IF name="periodicity8" -->
802                     <option value="8" selected>1/quarter (seasonal)</option>
803                 <!-- TMPL_ELSE -->
804                     <option value="8">1/quarter (seasonal)</option>
805                 <!-- /TMPL_IF -->
806
807                 <!-- TMPL_IF name="periodicity9" -->
808                     <option value="9" selected>2/years</option>
809                 <!-- TMPL_ELSE -->
810                     <option value="9">2/year</option>
811                 <!-- /TMPL_IF -->
812                 <!-- TMPL_IF name="periodicity10" -->
813                     <option value="10" selected>1/year</option>
814                 <!-- TMPL_ELSE -->
815                     <option value="10">1/year</option>
816                 <!-- /TMPL_IF -->
817                 <!-- TMPL_IF name="periodicity11" -->
818                     <option value="11" selected>1/2 years</option>
819                 <!-- TMPL_ELSE -->
820                     <option value="11">1/2 years</option>
821                 <!-- /TMPL_IF -->
822                 </select>
823                 Manual History :<input type="checkbox" name="manualhist" value="1" />
824             </td>
825         </tr>
826         <tr>
827             <td>Numbering Pattern:</td>
828             <td>
829                 <select name="numbering_pattern" size="1" id="numberpattern" onchange="num_pattern()">
830                     <option value="" selected>-- please choose --</option>
831                     <!-- TMPL_IF name="numberpattern1" -->
832                         <option value="1" selected>Number</option>
833                     <!-- TMPL_ELSE -->
834                         <option value="1">Number</option>
835                     <!-- /TMPL_IF -->
836                     <!-- TMPL_IF name="numberpattern2" -->
837                         <option value="2" selected>Volume, Number, Issue</option>
838                     <!-- TMPL_ELSE -->
839                         <option value="2">Volume, Number, Issue</option>
840                     <!-- /TMPL_IF -->
841                     <!-- TMPL_IF name="numberpattern3" -->
842                         <option value="3" selected>Volume, Number</option>
843                     <!-- TMPL_ELSE -->
844                         <option value="3">Volume, Number</option>
845                     <!-- /TMPL_IF -->
846                     <!-- TMPL_IF name="numberpattern4" -->
847                         <option value="4" selected>Volume, Issue</option>
848                     <!-- TMPL_ELSE -->
849                         <option value="4">Volume, Issue</option>
850                     <!-- /TMPL_IF -->
851                     <!-- TMPL_IF name="numberpattern5" -->
852                         <option value="5" selected>Number, Issue</option>
853                     <!-- TMPL_ELSE -->
854                         <option value="5">Number, Issue</option>
855                     <!-- /TMPL_IF -->
856                     <!-- TMPL_IF name="numberpattern6" -->
857                         <option value="6" selected>Seasonal only</option>
858                     <!-- TMPL_ELSE -->
859                         <option value="6">Seasonal only</option>
860                     <!-- /TMPL_IF -->
861                     <!-- TMPL_IF name="numberpattern7" -->
862                         <option value="7" selected>None of the above</option>
863                     <!-- TMPL_ELSE -->
864                         <option value="7">None of the above</option>
865                     <!-- /TMPL_IF -->
866                 </select>
867                 <div id="more_options"></div>
868                 <div id="irregularity"></div>
869             </td>
870         </tr>
871         <tr>
872             <td>Begins On: (*)</td>
873             <td>
874                 <img src="<!-- TMPL_VAR Name="themelang" -->/includes/calendar/cal.gif" id="button1" style="cursor: pointer;"  />
875                 <input type="text" name="startdate" value="<!-- TMPL_VAR name="startdate" -->" size=13 maxlength=10 id="beginning_date" style="border-width: 0px;">
876                 <!-- both scripts for calendar must follow the input field --> 
877                 <script type="text/javascript">
878                     Calendar.setup({
879                         inputField   : "beginning_date",
880                         ifFormat     : "%d/%m/%Y",
881                         button       : "button1",
882                         align        : "Tl"
883                     });
884                 </script>
885                 <script type="text/javascript">
886                     Calendar.setup({
887                         inputField   : "beginning_date",
888                         ifFormat     : "%d/%m/%Y",
889                         button       : "beginning_date",
890                         align        : "Tl"
891                     });
892                 </script>
893             </td>
894         </tr>
895         <tr>
896             <td>Subscription length</td>
897             <td>
898                 <select name="subtype">
899                     <!-- TMPL_LOOP NAME="subtype" -->
900                         <!-- TMPL_IF NAME="selected" -->
901                         <option value="<!-- TMPL_VAR NAME="name" -->"  selected="SELECTED">
902                         <!-- TMPL_ELSE -->
903                         <option value="<!-- TMPL_VAR NAME="name" -->">
904                         <!-- /TMPL_IF -->
905                         <!-- TMPL_VAR NAME="name" -->
906                         </option>
907                     <!-- /TMPL_LOOP -->
908                 </select>
909                 <input type="text" name="sublength" value="<!-- TMPL_VAR name="sublength" -->" size="3" onkeypress="return check_input(event)"> (*) (enter amount in numerals)
910             </td>
911         </tr>
912     <tr>
913         <td>Numbering calculation</td>
914         <td>Numbering formula: <input type="text" name="numberingmethod" value="<!-- TMPL_VAR name="numberingmethod" -->"></td>
915     </tr>
916     <tr>
917     <td colspan=3>
918         <div id="basetable" style="display: none;">
919             <table class="small">
920                 <tr>
921                     <th>&nbsp;</th>
922                     <th>X</th>
923                     <th>Y</th>
924                     <th>Z</th>
925                 </tr>
926                 <tr>
927                     <td>Add</td>
928                     <td>
929                         <input type="text" name="add1" value="<!-- TMPL_VAR name="add1" -->">
930                     </td>
931                     <td>
932                         <input type="text" name="add2" value="<!-- TMPL_VAR name="add2" -->">
933                     </td>
934                     <td>
935                         <input type="text" name="add3" value="<!-- TMPL_VAR name="add3" -->">
936                     </td>
937                 </tr>
938                 <tr>
939                     <td>once every</td>
940                     <td><input type="text" name="every1" value="<!-- TMPL_VAR name="every1" -->"></td>
941                     <td><input type="text" name="every2" value="<!-- TMPL_VAR name="every2" -->"></td>
942                     <td><input type="text" name="every3" value="<!-- TMPL_VAR name="every3" -->"></td>
943                 </tr>
944                 <tr>
945                     <td>When more than</td>
946                     <td><input type="text" name="whenmorethan1" value="<!-- TMPL_VAR name="whenmorethan1" -->"></td>
947                     <td><input type="text" name="whenmorethan2" value="<!-- TMPL_VAR name="whenmorethan2" -->"></td>
948                     <td><input type="text" name="whenmorethan3" value="<!-- TMPL_VAR name="whenmorethan3" -->"></td>
949                 </tr>
950                 <!-- TMPL_IF name="mod" -->
951                 <tr>
952                     <td>The loop is for instance</td>
953                     <td><input type="text" name="innerloop1" value="<!-- TMPL_VAR name="innerloop1" -->"></td>
954                     <td><input type="text" name="innerloop2" value="<!-- TMPL_VAR name="innerloop2" -->"></td>
955                     <td><input type="text" name="innerloop3" value="<!-- TMPL_VAR name="innerloop3" -->"></td>
956                 </tr>
957                 <!-- /TMPL_IF -->
958                 <tr>
959                     <td>Set back to</td>
960                     <td><input type="text" name="setto1" value="<!-- TMPL_VAR name="setto1" -->"></td>
961                     <td><input type="text" name="setto2" value="<!-- TMPL_VAR name="setto2" -->"></td>
962                     <td><input type="text" name="setto3" value="<!-- TMPL_VAR name="setto3" -->"></td>
963                 </tr>
964                 <tr>
965                     <td>
966                         <!-- TMPL_IF name="mod" -->
967                             Last value
968                         <!-- TMPL_ELSE -->
969                             Begins with
970                         <!-- /TMPL_IF -->
971                     </td>
972                     <td><input type="text" name="lastvalue1" value="<!-- TMPL_VAR name="lastvalue1" -->"></td>
973                     <td><input type="text" name="lastvalue2" value="<!-- TMPL_VAR name="lastvalue2" -->"></td>
974                     <td><input type="text" name="lastvalue3" value="<!-- TMPL_VAR name="lastvalue3" -->"></td>
975                 </tr>
976             </table>
977         </div>
978         </td></tr>
979     </table>
980 </div>
981 <!--TMPL_IF Name="history"-->
982 <div id="subscription_form_history">
983     <h2>History</h2>
984     <table>
985         <tr>
986           <td>Starting date:</td>
987           <td><input type="text" name="histstartdate" value="<!-- TMPL_VAR name="histstartdate" -->"> (the date of the 1st subscription)</td>
988         </tr>
989         <tr>
990           <td>Ending date:</td>
991           <td><input type="text" name="enddate" value="<!-- TMPL_VAR name="enddate" -->">(if empty : subscription still active)</td>
992         </tr>
993         <tr>
994             <td>Recieved issues</td>
995             <td><textarea name="recievedlist" cols="60" rows="5"><!-- TMPL_VAR name="recievedlist" --></textarea></td>
996         </tr>
997         <tr>
998             <td>Missing issues</td>
999             <td><textarea name="missinglist" cols="60" rows="5"><!-- TMPL_VAR name="missinglist" --></textarea></td>
1000         </tr>
1001         <tr>
1002             <td>Opac's notes</td>
1003             <td><textarea name="opacnote" cols="60" rows="5"><!-- TMPL_VAR name="opacnote" --></textarea></td>
1004         </tr>
1005         <tr>
1006             <td>Librarian notes</td>
1007             <td><textarea name="librariannote" cols="60" rows="5"><!-- TMPL_VAR name="librariannote" --></textarea></td>
1008         </tr>
1009     </table>
1010 </div>
1011 <!--/TMPL_IF-->
1012 <!-- TMPL_IF name="mod" -->
1013     <input type="button" value="Save subscription" onclick="Check(this.form)" accesskey="w">
1014 <!-- TMPL_ELSE -->
1015     <input type="button" value="Add subscription" onclick="Check(this.form)" accesskey="w">
1016 <!-- /TMPL_IF -->
1017 </form>
1018 </div>
1019
1020
1021 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
1022
1023 <script language="JavaScript" type="text/javascript">
1024
1025 function Plugin(f)
1026 {
1027          window.open('subscription-bib-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
1028 }
1029
1030 function FindAcqui(f)
1031 {
1032          window.open('acqui-search.pl','FindASupplier','width=800,height=400,toolbar=no,scrollbars=yes');
1033 }
1034
1035 function Find_ISSN(f)
1036 {
1037          window.open('issn-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
1038 }
1039
1040
1041 function Check(f) {
1042     if (f.startdate.value.length != 0 && f.sublength.value > 0) {
1043         if (f.irreg_check.value == 1) {
1044             document.f.submit();
1045         } else {
1046             if(f.numbering_pattern.value == ''){
1047                 alert(_("need to choose a numbering pattern"));
1048             } else {
1049                 alert(_("need to check for irregularity by clicking 'Irregularity?'"));
1050             }
1051         }
1052     } else {
1053         alert(_('field marked with * are mandatory'));
1054     }
1055     return false;
1056 }
1057 </script>
1058 <!-- TMPL_IF name="mod" -->
1059 <script type="text/javascript">
1060 window.onload = modify_num_pattern();
1061     <!-- TMPL_IF name="hemisphere" -->
1062     window.onload = hemispheres(<!-- TMPL_VAR NAME="hemisphere" -->);
1063     <!-- /TMPL_IF -->
1064 </script>
1065 <!-- /TMPL_IF -->
1066 <!-- TMPL_IF name="irregularity" -->
1067 <script type="text/javascript">
1068 window.onload = irregularity_check();
1069 window.onload = irregular_order();
1070 </script>
1071 <!-- /TMPL_IF -->