Fix an unstranslatable string in JavaScript
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / subscription-add.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Serials &rsaquo; <!-- TMPL_IF name="mod" --><!-- TMPL_VAR name="bibliotitle" escape="html" --> &rsaquo; Modify subscription<!-- TMPL_ELSE -->New subscription<!-- /TMPL_IF --></title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
5
6 <style type="text/css">
7 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
8 .yui-u li p label.widelabel {
9     width: 300px;  /* not enough for IE7 apparently */
10     /* height: 2.4em; background-color: pink; */
11 }
12 </style>
13 <script type="text/javascript">
14 //<![CDATA[
15
16 // the english words used in display purposes
17 var text = new Array(_("Number"),_("Volume"),_("Issue"),_("Month"),_("Week"),_("Starting with:"),_("Rollover at:"),_("Choose Hemisphere:"),_("Northern"),_("Southern"),
18 _("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"),_("Season"),_("Year"));
19 var weekno_label = _("Week # ");
20 var is_season = 0;
21 var is_hemisphere = 1;
22 var irregular_issues;   // will hold irregularity object.
23
24 function formatDate(myDate) {
25     var d = new Array( myDate.getFullYear(), myDate.getMonth() + 1 ,myDate.getDate());
26     if(d[1].toString().length == 1) { d[1] = '0'+d[1] };
27     if(d[2].toString().length == 1) { d[2] = '0'+d[2] };
28     <!-- TMPL_IF NAME="dateformat_us" -->
29         return(d[1] + '/' + d[2] + '/' + d[0]) ;
30     <!-- TMPL_ELSIF NAME="dateformat_metric" -->
31         return(d[2] + '/' + d[1] + '/' + d[0]) ;
32     <!-- TMPL_ELSE -->
33         return(''+d[0] + '-' + d[1] + '-' + d[2]) ;
34     <!-- /TMPL_IF -->    
35 }
36
37 Date.prototype.addDays = function(days) {
38     this.setDate(this.getDate()+days);
39 }
40
41 function getWeeksArray(startDate,periodicity) {
42 // returns an array of syspref-formatted dates starting at the first day of startDate's year.
43 // This prediction method will not accurately predict irregularites beyond the first year.
44 // FIXME : Should replace with ajax query to get the first Monday of the year so that week numbers have correct dates.
45     var incr=1;
46     if(periodicity==3) {  // 1/2 wks
47         incr=2;
48     } else if(periodicity == 4) { // 1/3 wks
49         incr=3;
50     }
51     var weeksArray = new Array;
52     var jan01 = new Date();
53     jan01.setDate(1);
54     jan01.setMonth(0);
55     jan01.setFullYear(startDate.getFullYear());
56     for(var i=0;i<52;i++) {
57         weeksArray[i] = formatDate(jan01) + ' ' + weekno_label + (i + 1);
58         jan01.addDays( 7 ); 
59     }
60     return weeksArray;
61 }
62
63 function YMDaToYWDa(S) {
64     with (new Date(Date.UTC(S[0], S[1] - 1, S[2]))) {
65         var DoW = getUTCDay();
66         setUTCDate(getUTCDate() - (DoW + 6) % 7 + 3);
67         var ms = valueOf();
68         setUTCMonth(0, 4);
69         var WN = Math.round((ms - valueOf()) / 604800000) + 1;
70         return [getUTCFullYear(), WN, DoW == 0 ? 7 : DoW];
71     }
72 }
73 function dayofyear(d) { // d is a Date object
74 var yn = d.getFullYear();
75 var mn = d.getMonth();
76 var dn = d.getDate();
77 var d1 = new Date(yn,0,1,12,0,0); // noon on Jan. 1
78 var d2 = new Date(yn,mn,dn,12,0,0); // noon on input date
79 var ddiff = Math.round((d2-d1)/864e5);
80 return ddiff+1;
81 }
82
83
84 // create irregularity object.
85 function IrregularPattern() {
86         this.months = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
87         this.seasons = new Array(_("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"));
88     this.daynames = new Array(_("Monday"),_("Tuesday"),_("Wednesday"),_("Thursday"),_("Friday"),_("Saturday"),_("Sunday"));
89     // create weeks irregularity selection array:
90     this.firstissue = new Date();
91     this.firstissue.setDate(1);
92     this.firstissue.setMonth(0);
93     <!-- TMPL_IF NAME='firstacquiyear' --> // it's a mod, we already have a start date.
94         this.firstissue.setFullYear( <!-- TMPL_VAR NAME="firstacquiyear" --> );
95     <!-- /TMPL_IF -->
96         this.weeks = getWeeksArray(this.firstissue); 
97
98     this.numskipped = 0;
99     // init:
100         var irregular = '<!-- TMPL_VAR NAME="irregularity" -->';
101     this.skipped = irregular.split(',');
102 }
103
104 IrregularPattern.prototype.update = function() {
105                 this.skipped= new Array;
106                 var cnt = 0;
107                 // daily periodicity, we interpret irregular array as which days of week to skip.
108                 // else if weekly periodicity, week numbers (starting from 01 Jan) to skip.
109         // else  irregular array is list of issues to skip
110                 var summary_str = '';
111                 this.numskipped = 0;
112         if(document.f.irregularity_select) {
113             //$("#irregularity_select option:selected").each(...); //jquery can combine both conditionals and the for loop
114             for( var i in document.f.irregularity_select.options ) {
115                 if( document.f.irregularity_select.options[i].selected ) {
116                     this.skipped[cnt] = document.f.irregularity_select.options[i].value ;
117                     summary_str += document.f.irregularity_select.options[i].text + "\n" ;
118                                     cnt++;
119                                     this.numskipped++;
120                             }
121                     }
122                     var summary = document.getElementById("irregularity_summary");
123                     if(summary) {
124                             summary.value = summary_str;
125                             summary.rows= ( cnt > 6 ) ? cnt : 6 ; // textarea will bre resized, but not more than 6 lines will show.
126                     }
127         }
128 }
129
130 IrregularPattern.prototype.irregular = function(index) { 
131         for( var i in this.skipped) {
132                         if( this.skipped[i] == index) {
133                                 return true;
134                         }
135         }
136         return false;
137 }
138
139 function init_pattern() {
140         irregular_issues = new IrregularPattern();
141 }
142 function reset_pattern() {
143         document.getElementById("numberpattern").value = '';
144     document.getElementById("irregularity").innerHTML = '';
145         init_pattern();
146         reset_num_pattern();
147 }
148
149 // common pre defined number patterns
150 function reset_num_pattern() {
151 var patternchoice = document.getElementById("numberpattern").value;
152     switch(patternchoice){
153     case "2":
154         document.f.add1.value=1;
155         document.f.add2.value=1;
156         document.f.add3.value=1;
157         document.f.every1.value=12;
158         document.f.every2.value=1;
159         document.f.every3.value=1;
160         document.f.whenmorethan1.value=9999999;
161         document.f.whenmorethan2.value=12;
162         document.f.whenmorethan3.value=4;
163         document.f.setto1.value=0;
164         document.f.setto2.value=1;
165         document.f.setto3.value=1;
166         document.f.lastvalue1.value=1;
167         document.f.lastvalue2.value=1;
168         document.f.lastvalue3.value=1;
169         document.f.numberingmethod.value=_("Vol {X}, No {Y}, Issue {Z}");
170         moreoptions(text[1],text[0],text[2]);
171         display_table(0); // toggle info box on (1) or off (0)
172         break;
173     case "3":
174         document.f.add1.value=1;
175         document.f.add2.value=1;
176         document.f.add3.value='';
177         document.f.every1.value=12;
178         document.f.every2.value=1;
179         document.f.every3.value='';
180         document.f.whenmorethan1.value=9999999;
181         document.f.whenmorethan2.value=12;
182         document.f.whenmorethan3.value='';
183         document.f.setto1.value=0;
184         document.f.setto2.value=1;
185         document.f.setto3.value='';
186         document.f.lastvalue1.value=1;
187         document.f.lastvalue2.value=1;
188         document.f.lastvalue3.value='';
189         document.f.numberingmethod.value=_("Vol {X}, No {Y}");
190         moreoptions(text[1],text[0]);
191         display_table(0);
192         break;
193     case "4":
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.lastvalue1.value=1;
207         document.f.lastvalue2.value=1;
208         document.f.lastvalue3.value='';
209         document.f.numberingmethod.value=_("Vol {X}, Issue {Y}");
210         moreoptions(text[1],text[2]);
211         display_table(0);
212         break;
213     case "5":
214 //        var d = new Date(document.f.firstacquidate.value);
215 //        var smonth = d.getMonth();
216         document.f.add1.value=1;
217         document.f.add2.value=1;
218         document.f.add3.value='';
219         document.f.every1.value=12;
220         document.f.every2.value=1;
221         document.f.every3.value='';
222         document.f.whenmorethan1.value=9999999;
223         document.f.whenmorethan2.value=12;
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.numberingmethod.value=_("No {X}, Issue {Y}");
229         moreoptions(text[0],text[2]);
230         display_table(0);
231         break;
232     case "6":
233         var d = new Date(document.f.firstacquidate.value);
234         var sYear = d.getFullYear();
235         moreoptions_seasons(text[15],sYear);
236         var d = new Date(document.f.firstacquidate.value);
237         var sYear = d.getFullYear();
238         document.f.add1.value=1;
239         document.f.add2.value='1';
240         document.f.add3.value='';
241         document.f.every1.value=4;
242         document.f.every2.value='1';
243         document.f.every3.value='';
244         document.f.whenmorethan1.value=9999999;
245         document.f.whenmorethan2.value='4';
246         document.f.whenmorethan3.value='';
247         document.f.setto1.value=0;
248         document.f.setto2.value='1';
249         document.f.setto3.value='';
250         document.f.periodicity.value='8';
251         document.f.numberingmethod.value=_("{Y} {X}");
252         moreoptions_seasons(text[15],sYear);
253         document.f.lastvalue1temp.value=document.f.lastvalue1.value=sYear;
254         display_table(0);
255         is_season = 1;
256         break;
257     case "7":
258         display_table(1);
259         document.getElementById("more_options").innerHTML = '';
260         document.f.irreg_check.value=1; 
261         break;
262     case "8":  // Year/Number
263         var d = (document.f.firstacquidate.value) ? new Date( document.f.firstacquidate.value) : new Date() ;
264         var sYear = d.getFullYear();
265         document.f.add1.value=1;
266         document.f.add2.value=1;
267         document.f.add3.value='';
268         document.f.every1.value=12;
269         document.f.every2.value=1;
270         document.f.every3.value='';
271         document.f.whenmorethan1.value=9999999;
272         document.f.whenmorethan2.value=12;
273         document.f.whenmorethan3.value='';
274         document.f.setto1.value=0;
275         document.f.setto2.value=1;
276         document.f.setto3.value='';
277         document.f.lastvalue1.value=sYear;
278           switch (document.f.periodicity.value){
279             case 1:              
280               var doy = dayofyear(d);
281               document.f.lastvalue2.value=doy; 
282               document.f.whenmorethan2.value=365; 
283               break;      
284             case 12:     
285               var doy = dayofyear(d);
286               document.f.lastvalue2.value=doy*2; 
287               document.f.whenmorethan2.value=730; 
288               break;      
289             case 2:
290             case 3:
291             case 4:
292               var YWDa = YMDaToYWDa(d);
293               document.f.lastvalue2.value=YWDA[1]/(document.f.periodicity.value-1); 
294               break;      
295             case 5:
296               var smonth = d.getMonth();
297               document.f.lastvalue2.value=smonth;
298               break;      
299             case 6:
300               var smonth = d.getMonth();
301               document.f.lastvalue2.value=smonth/2;
302               document.f.whenmorethan2.value=6;
303               break;      
304             case 7:
305             case 8:      
306               var smonth = d.getMonth();
307               document.f.lastvalue2.value=smonth/3;
308               document.f.whenmorethan2.value=4;
309               break;      
310             case 9:                        
311               var smonth = d.getMonth();
312               document.f.lastvalue2.value=smonth/6;
313               document.f.whenmorethan2.value=2;
314               break;      
315             default:
316           } 
317         document.f.lastvalue3.value='';
318         document.f.numberingmethod.value=_("{X} / {Y}");
319         moreoptions(text[16],text[0]);
320      //   document.f.lastvalue1temp.value=sYear;
321      //   document.f.lastvalue2temp.value=document.f.lastvalue2.value;
322         display_table(0);
323         break;
324     default:
325         document.f.add1.value=1;
326         document.f.add2.value='';
327         document.f.add3.value='';
328         document.f.every1.value=1;
329         document.f.every2.value='';
330         document.f.every3.value='';
331         document.f.whenmorethan1.value=9999999;
332         document.f.whenmorethan2.value='';
333         document.f.whenmorethan3.value='';
334         document.f.setto1.value=0;
335         document.f.setto2.value='';
336         document.f.setto3.value='';
337         document.f.lastvalue1.value=1;
338         document.f.lastvalue2.value='';
339         document.f.lastvalue3.value='';
340         document.f.numberingmethod.value='{X}';
341 //        moreoptions_daily_check(text[0]);
342         moreoptions(text[0]);
343         document.f.irreg_check.value=1;
344         display_table(0);
345         break;
346     }
347 }
348
349 function display_table(n) {
350     if(n==1){
351         document.getElementById("basetable").style.display = 'block';
352     } else if(n==0){
353         document.getElementById("basetable").style.display = 'none';
354     } else {
355                 var disp_val = ( document.getElementById("basetable").style.display == 'none' ) ? 'block' : 'none' ;
356                         document.getElementById("basetable").style.display = disp_val;
357         }
358 }
359
360 function set_num_pattern_from_template_vars() {
361         if(!document.getElementById("numberpattern")){ return false; }
362     document.getElementById("numberpattern").value = '<!-- TMPL_VAR NAME="numberpattern" -->';
363     reset_num_pattern();
364     
365     document.f.add1.value='<!-- TMPL_VAR NAME="add1" -->';
366     document.f.add2.value='<!-- TMPL_VAR NAME="add2" -->';
367     document.f.add3.value='<!-- TMPL_VAR NAME="add3" -->';
368     document.f.every1.value='<!-- TMPL_VAR NAME="every1" -->';
369     document.f.every2.value='<!-- TMPL_VAR NAME="every2" -->';
370     document.f.every3.value='<!-- TMPL_VAR NAME="every3" -->';
371     document.f.whenmorethan1.value='<!-- TMPL_VAR NAME="whenmorethan1" -->';
372     document.f.whenmorethan2.value='<!-- TMPL_VAR NAME="whenmorethan2" -->';
373     document.f.whenmorethan3.value='<!-- TMPL_VAR NAME="whenmorethan3" -->';
374     document.f.setto1.value='<!-- TMPL_VAR NAME="setto1" -->';
375     document.f.setto2.value='<!-- TMPL_VAR NAME="setto2" -->';
376     document.f.setto3.value='<!-- TMPL_VAR NAME="setto3" -->';
377     document.f.lastvalue1.value='<!-- TMPL_VAR NAME="lastvalue1" -->';
378     document.f.lastvalue2.value='<!-- TMPL_VAR NAME="lastvalue2" -->';
379     document.f.lastvalue3.value='<!-- TMPL_VAR NAME="lastvalue3" -->';
380     document.f.numberingmethod.value='<!-- TMPL_VAR NAME="numberingmethod" -->';
381
382     var more_strY;
383     var more_strZ;
384     <!-- TMPL_IF NAME="add2" -->
385     if(<!-- TMPL_VAR NAME="add2" --> > 0){
386         more_strY="Y";
387     }
388     <!-- /TMPL_IF -->
389     <!-- TMPL_IF NAME="add3" -->
390     if(<!-- TMPL_VAR NAME="add3" --> > 0){
391         more_strZ="Z";
392     }
393     <!-- /TMPL_IF -->
394     document.f.lastvalue1temp.value='<!-- TMPL_VAR NAME="lastvalue1" -->';
395     if(more_strY){
396         document.f.lastvalue2temp.value='<!-- TMPL_VAR NAME="lastvalue2" -->';
397     document.f.whenmorethan2temp.value='<!-- TMPL_VAR NAME="whenmorethan2" -->';
398     }
399     if(more_strZ){
400         document.f.lastvalue3temp.value='<!-- TMPL_VAR NAME="lastvalue3" -->';
401     document.f.whenmorethan3temp.value='<!-- TMPL_VAR NAME="whenmorethan3" -->';
402     }
403 }
404
405 // a pre check with more options to see if 'number' and '1/day' are chosen
406 function moreoptions_daily_check(x) {
407     var periodicity = document.f.periodicity.value;
408     var errortext='';
409     if(periodicity == 1){ // i.e. daily
410         document.getElementById("irregularity").innerHTML = '';
411         errortext =_("Please indicate which days of the week you <b>DO NOT<\/b> expect to receive issues.<br \/>");
412         for(var j=0;j<irregular_issues.daynames.length;j++){
413             errortext +="<input type='checkbox' name='irregular' id='irregular"+(j+1)+"' value='"+(j+1)+"' />"+irregular_issues.daynames[j]+" &nbsp; ";
414         }
415         var error = errortext;
416         moreoptions(x);
417         document.getElementById("irregularity").innerHTML = error;
418     } else {
419         document.getElementById("irregularity").innerHTML = '';
420         document.getElementById("more_options").innerHTML = '';
421         moreoptions(x);
422     }
423 }
424
425 // to dispaly the more options section
426 function moreoptions(x,y,z){
427 document.getElementById("irregularity").innerHTML = '';
428 document.getElementById("more_options").innerHTML = '';
429 var textbox = '';
430     // alert("X: "+x+"Y: "+y+"Z: "+z);
431     if(x){
432         textbox +="<table id='irregularity_table'>\n<tr><th>&nbsp;<\/th><th>"+x+"<\/th>";
433         if(y){
434             textbox +="<th>"+y+"<\/th>";
435             if(z){
436                 textbox +="<th>"+z+"<\/th>";
437             }
438         }
439         textbox +="<\/tr>\n";
440         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";
441         if(y){
442             textbox +="<td><input type='text' name='lastvalue2temp' id='lastvalue2temp' size='4' onkeyup='moreoptionsupdate(this)' value=\"" + document.f.lastvalue2.value + "\" /><\/td>\n";
443             if(z){
444                 textbox +="<td><input type='text' name='lastvalue3temp' id='lastvalue3temp' size='4' onkeyup='moreoptionsupdate(this)' value=\"" + document.f.lastvalue3.value + "\" /><\/td>\n";
445             }
446         }
447         textbox +="<\/tr>\n";
448         if(y){
449             textbox +="<tr><th scope=\"row\">"+text[6]+"<\/th>";
450             textbox +="<td>&nbsp;<\/td>\n";
451             textbox +="<td><input type='text' name='whenmorethan2temp' id='whenmorethan2temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
452             if(z){
453                 textbox +="<td><input type='text' name='whenmorethan3temp' id='whenmorethan3temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
454             }
455             textbox +="<\/tr>";
456         } else {
457           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>";
458         }
459         textbox +="<\/table>\n";
460     }
461     document.getElementById("more_options").innerHTML = textbox;
462 }
463
464 function hemispheres(chosen){
465 var selbox = document.getElementById("season1");
466     if(selbox){
467     var selboxselected = selbox.options[selbox.selectedIndex].value;
468     selbox.options.length = 0;
469
470     if ( (chosen == "1") || ( ! (chosen) && is_hemisphere == 1 )) {
471         selbox.options[selbox.options.length] = new Option(text[11],'1');
472         selbox.options[selbox.options.length] = new Option(text[12],'2');
473         selbox.options[selbox.options.length] = new Option(text[13],'3');
474         selbox.options[selbox.options.length] = new Option(text[14],'4');
475         is_hemisphere = 1;
476         selbox.options[selboxselected-1].selected = true;
477     }
478
479     if ( (chosen == "2") || ( ! (chosen) && is_hemisphere == 2 )) {
480         selbox.options[selbox.options.length] = new Option(text[13],'1');
481         selbox.options[selbox.options.length] = new Option(text[10],'2');
482         selbox.options[selbox.options.length] = new Option(text[11],'3');
483         selbox.options[selbox.options.length] = new Option(text[12],'4');
484         is_hemisphere = 2;
485         selbox.options[selboxselected-1].selected = true;
486     }
487     }
488 }
489
490 // to display the more options section for seasons
491 function moreoptions_seasons(x,y){
492 // x = 'Season'.  y = 'Year'.
493 document.getElementById("irregularity").innerHTML = '';
494 document.getElementById("more_options").innerHTML = '';
495 var textbox = '';
496     //alert("X: "+x+"Year: "+y);
497     if(x){
498         var hemi_select = parseInt('<!-- TMPL_VAR NAME="hemisphere" -->');
499         textbox +="<li><label for=\"hemisphere\">"+ text[7]  +"<\/label><select name='hemisphere' id=\"hemisphere\" onchange='hemispheres(this.options[this.selectedIndex].value)'>";
500         for(var i = 1; i <= 2; i++){
501             textbox +="<option value='"+i+"'";
502             if(i == hemi_select){
503                 textbox += " selected "
504             }
505             textbox +=">"+text[i+7]+"<\/option>";
506         }
507         textbox +="<\/li>\n";
508         textbox +="<table id='seasonal_irregularity'><tr><th>&nbsp;<\/th><th>"+x+"<\/th>";
509         textbox +="<th>"+text[16]+"<\/th>";
510         textbox +="<\/tr>\n";
511         textbox +="<tr><th scope=\"row\">"+text[5]+"<\/th><td><select name='lastvalue2temp' id='lastvalue2temp' id='season1' onchange='moreoptionsupdate(this)'>";
512         for(var j = 1; j <= 4; j++){
513             textbox +="<option value='"+j+"'>"+text[j+9]+"<\/option>";
514         }
515         textbox +="<\/select><\/td>";
516         var isyr = irregular_issues.firstissue;
517         textbox += "<td>" + irregular_issues.firstissue.getFullYear() + "<\/td><\/tr>\n";
518         textbox +="<tr><th scope=\"row\">"+text[6]+"<\/th>";
519         textbox +="<td><input type='text' name='whenmorethan2temp' id='whenmorethan2temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
520         textbox +="<\/tr><\/table>\n";
521     }
522     document.getElementById("more_options").innerHTML = textbox;
523 }
524
525 function irregularity_check(){
526     document.f.irreg_check.value = 1; // Irregularity button now pushed
527     var periodicity = document.f.periodicity.value;
528         var rollover = document.f.issuesexpected1.value;
529     if( (document.f.whenmorethan2) && ( document.f.whenmorethan2.value > 0) ){
530       rollover = document.f.whenmorethan2.value;
531     }
532     if((document.f.whenmorethan3) && document.f.whenmorethan3.value > 0 ){
533         // FIXME: Irregularity check assumes that the full prediction pattern repeats each year.
534                 //  In cases where the outermost periodicity is > 1 year,  
535                 //  e.g. where a volume spans two years, the irregularity check will be incorrect, 
536         // but you can safely ignore the check, submit the form, and the prediction pattern should be correct.
537                 //  a way to distinguish between these two cases is needed.
538                 rollover = document.f.whenmorethan3.value * document.f.whenmorethan2.value;
539     }
540     var error='';
541     var toobig;
542     var expected; 
543     var errortext = _("<b>Warning irregularity detected<\/b><br \/>");
544     switch(periodicity){
545     case "12":
546         if(rollover < 730) expected =730;
547         if(rollover > 730) {
548             expectedover=730;
549             toobig=1;
550         }
551         break;
552     case "1":
553         if(rollover < 365) expected =365;
554         if(rollover > 365) {
555             expectedover=365;
556             toobig=1;
557         }
558         break;
559     case "2":
560         if(rollover < 52) expected =52;
561         if(rollover > 52){
562             expectedover=52;
563             toobig=1;
564         }
565         break;
566     case "3":
567         if(rollover < 26) expected =26;
568         if(rollover > 26){
569             expectedover=26;
570             toobig=1;
571         }
572         break;
573     case "4":
574         if(rollover < 17) expected =17;
575         if(rollover > 17){
576             expectedover=17;
577             toobig=1;
578         }
579         break;
580     case "5":
581         if(rollover < 12) expected =12;
582         if(rollover > 12){
583             expectedover=12;
584             toobig=1;
585         }
586         break;
587     case "6":
588         if(rollover < 6) expected =6;
589         if(rollover > 6){
590             expectedover=6;
591             toobig=1;
592         }
593         break;
594     case "7":
595         if(rollover < 4) expected =4;
596         if(rollover > 4){
597             expectedover=4;
598             toobig=1;
599         }
600         break;
601     case "8":
602         if(rollover < 4) expected =4;
603         if(rollover > 4){
604             expectedover=4;
605             toobig=1;
606         }
607         break;
608     case "9":
609         if(rollover < 2) expected =2;
610         if(rollover > 2){
611             expectedover=2;
612             toobig=1;
613         }
614         break;
615     case "10":
616         if(rollover < 1) expected =1;
617         if(rollover > 1){
618             expectedover=1;
619             toobig=1;
620         }
621         break;
622     default:
623         break;
624     }
625     if(expected){
626         if(expected == 365 || expected==730){  // what about leap years ?
627                         // FIXME:  We interpret irregularity as which days per week for periodicity==1.
628                         //  We need two cases: one in which we're published n days/week, in which case irregularity should be per week,
629                         //  and a regular daily pub, where irregularity should be per year.
630             errortext += _("Please indicate which days of the week you <b>DO NOT<\/b> expect to receive issues.<br \/>");
631         } else {
632             errortext +=expected+_(" issues expected, ")+rollover+_(" were entered. <br \/>Please indicate which date(s) an issue is not expected<br \/>");
633             irregular_issues.numskipped = expected - rollover;
634                 }
635         errortext +="<select multiple id='irregularity_select' name='irregularity_select' onchange='irregular_issues.update();'>\n";
636                 errortext +=irregular_options(periodicity);
637                 errortext += "<\/select>\n <textarea rows='6' width='18' id='irregularity_summary' name='irregularity_summary' value='foo' />";
638         error=errortext;
639     }
640     if(toobig){
641         errortext +=expectedover+_(" issues expected, ")+rollover+_(" were entered.<p class='warning'> You seem to have indicated more issues per year than expected.<\/p>");
642         error=errortext;
643     }
644     if(error.length ==0){
645         error=_("No irregularities noticed");
646     }
647         display_example(expected);
648     document.getElementById("irregularity").innerHTML = error;
649         irregular_issues.update();
650 }
651
652 function irregular_options(periodicity){
653     var titles;
654     var count;
655     var errortext='';
656     var numberpattern = document.getElementById('numberpattern').value;
657     if(periodicity == 1) {
658         expected = 7;
659         titles = irregular_issues.daynames;
660         count = 1;
661     }
662     if(periodicity == 2 || periodicity == 3 || periodicity == 4) { 
663         titles = irregular_issues.weeks;
664                 count = 1;
665         if(periodicity==3) {  // 1/2 wks
666             expected = 26;
667         } else if(periodicity == 4) { // 1/3 wks
668             expected = 17;
669         } else {
670             expected = 52;
671         }
672     }
673     if(periodicity == 5 || periodicity == 6 || periodicity == 7 || periodicity == 8 || periodicity == 9) {
674         if(periodicity == 8 && numberpattern==8) {
675             is_season = 1; // setting up from edit page
676         } 
677         if(is_season){
678             titles = irregular_issues.seasons;
679             expected = 4;
680             if(is_hemisphere == 2){
681                 count = 2;
682             } else {
683                 count = 1;
684             }
685         } else {
686             titles = irregular_issues.months;
687             expected = 12;
688             count = 1;
689         }
690     }
691         if( !expected) {
692                 return '';   // don't know how to deal with irregularity.
693         }       
694     for(var j=0;j<expected;j++){   // rch - changed frrom (1..expected).
695         if(isArray(titles)){
696             if(count>expected){
697                 count = count-expected;
698             }
699             if(is_season && is_hemisphere == 1){
700                 errortext +="<option value='"+((count*3)-2)+"'>"+titles[j]+"<\/option>\n";
701 // alert("value: "+((count*3)-2)+" title: "+titles[j]);
702             } else if(is_season && is_hemisphere == 2){
703                 errortext +="<option value='"+((count*3)-2)+"'>"+titles[j-1]+"<\/option>\n";
704 // alert("value: "+((count*3)-2)+" title: "+titles[j-1]);
705             } else {  // all non-seasonal periodicities:
706                 var incr=1; // multiplier for ( 1/n weeks)  patterns; in this case the irreg calc relies on the week# , not the issue#.
707                 if(periodicity==3) {  // 1/2 wks
708                     incr=2;
709                 } else if(periodicity == 4) { // 1/3 wks
710                     incr=3;
711                 }
712                 errortext += "<option value='" + (1+j*incr) ;  
713                                 if(irregular_issues.irregular(1+incr*j)) {
714                                         errortext += "' selected='selected" ;
715                                 }
716                                 errortext += "'>"+titles[incr*j]+"<\/option>\n";
717             }
718             count++;
719         } else { 
720             errortext +="<option value='"+j+"'>"+titles+" "+j+"<\/option>\n";
721         }
722     }
723     return errortext;
724 }
725
726
727 function display_example(expected){
728     var startfrom1 = parseInt(document.f.lastvalue1.value);
729     var startfrom2 = parseInt(document.f.lastvalue2.value);
730     var startfrom3 = parseInt(document.f.lastvalue3.value);
731     var every1 = parseInt(document.f.every1.value);
732     var every2 = parseInt(document.f.every2.value);
733     var every3 = parseInt(document.f.every3.value);
734     var numberpattern = document.f.numberingmethod.value;
735     var whenmorethan2 = parseInt(document.f.whenmorethan2.value);
736     var whenmorethan3 = parseInt(document.f.whenmorethan3.value);
737     var setto2 = parseInt(document.f.setto2.value);
738     var setto3 = parseInt(document.f.setto3.value);
739     var displaytext = _("Based on the information entered, the Numbering Pattern will look like this: ") + "<br \/><ul class=\"numpattern_preview\">";
740     if(startfrom3>0){
741         var count=startfrom3-1;
742         var count2=startfrom2;
743         for(var i = 0 ; i < 12; i++){
744             if(count>=whenmorethan3){
745                 count=setto3;
746                 if(count2>=whenmorethan2){
747                     startfrom1++;
748                     count2=setto2;
749                 } else {
750                     count2++;
751                 }
752             } else {
753                 count++;
754             }
755             displaytext += '<li>' + numberpattern.replace(/{Z}/,count) + '<\/li>\n';
756             displaytext = displaytext.replace(/{Y}/,count2);
757             displaytext = displaytext.replace(/{X}/,startfrom1);
758
759         }
760     }
761     if(startfrom2>0 && !startfrom3){
762         var count=startfrom2-1;
763         for(var i=0;i<12;i++){
764             if(count>=whenmorethan2){
765                 startfrom1++;
766                 count=setto2;
767             } else {
768                 count++;
769             }
770
771             if(is_season){
772                 if(is_hemisphere == 2){
773                     if(count == 1) {
774                         displaytext += numberpattern.replace(/{Y}/,text[count+12])+'\n';
775                     } else {
776                         displaytext += numberpattern.replace(/{Y}/,text[count+8])+'\n';
777                     }
778                 } else {
779                 displaytext += numberpattern.replace(/{Y}/,text[count+10])+'\n';
780                 }
781             } else {
782                 displaytext += numberpattern.replace(/{Y}/,count)+'\n';
783             }
784             displaytext = displaytext.replace(/{X}/,startfrom1)+'<br \/>\n';
785         }
786     }
787     if(startfrom1>0 && !startfrom2 && !startfrom3){
788         var offset=eval(document.f.issuesexpected1.value);
789         if (!offset){
790             offset = 12 
791         }
792         for(var i=startfrom1;i<(startfrom1+offset);i+=every1){
793             displaytext += numberpattern.replace(/{X}/,i)+'<br \/>\n';
794         }
795     }
796    //  displaytext = "<div style='padding: 5px; background-color: #CCCCCC'>"+displaytext+"<\/div>";
797     document.getElementById("displayexample").innerHTML = displaytext;
798 }
799
800 function isArray(obj) {
801 if (obj.constructor.toString().indexOf("Array") == -1)
802     return false;
803 else
804     return true;
805 }
806
807 function moreoptionsupdate(inputfield,rollover){
808     fieldname = inputfield.name;
809     // find parent element in base table by stripping 'temp' from element name.
810     basefield = document.getElementById(fieldname.slice(0,-4));
811     var fieldnumber = fieldname.slice(-5,-4);
812
813     basefield.value = inputfield.value;
814     var patternchoice = document.getElementById("numberpattern").value;
815     switch(patternchoice){
816     case "2":
817     case "4":
818     case "5":
819     case "8": // Year, Number.  -- Why not just use Vol, Number withvol==year??
820                 //  FIXME: this my conflict with innerloop calc below.
821        if (document.f.lastvalue2temp.value > 0){document.f.innerloop1.value = document.f.lastvalue2temp.value - 1;}
822       break;   
823     }  
824     if(basefield.name.slice(0,-1) == 'lastvalue' || 'whenmorethan' ) {
825         // The enumeration string is held in a positional numeral notation with three positions, X,Y,Z.
826         // The last values lastvalue1, lastvalue2,lastvalue3 should match the last received serial's X,Y,Z enumeration.
827         // make array indexes start with 1 for consistency with variable names.
828         var innerloop = new Array( undefined, document.getElementById('innerloop1'), document.getElementById('innerloop2'), document.getElementById('innerloop3') );
829         var lastvalue = new Array( undefined, document.getElementById('lastvalue1').value *1 , document.getElementById('lastvalue2').value *1 , document.getElementById('lastvalue3').value *1  );
830         var every = new Array( undefined, document.getElementById('every1').value *1 , document.getElementById('every2').value *1 , document.getElementById('every3').value *1  );
831         var add = new Array( undefined, document.getElementById('add1').value *1 , document.getElementById('add2').value *1 , document.getElementById('add3').value *1  );
832         var whenmorethan = new Array( undefined, document.getElementById('whenmorethan1').value *1 , document.getElementById('whenmorethan2').value *1 , document.getElementById('whenmorethan3').value *1  );
833         
834        if(rollover){
835        // calculate rollover  for higher level of periodicity.
836        // if there are two levels of periodicity, (e.g. vol{X},num{Y},issue{Z}, then every1=every2*whenmorethan2 / add2 .
837           for(var N=3;N>1;N--){
838             if( add[N] > 0){
839                 var addN = (add[N]) ? add[N] : 1 ;
840                 var everyN = (document.getElementById('every'+N)) ? document.getElementById('every'+N).value : 1 ;
841                 document.getElementById('every'+(N-1)).value = whenmorethan[N] * everyN / addN ;
842             }
843           }
844         }
845         innerloop[3].value = ( every[3] > 1 ) ? lastvalue[3] % every[3] : 0 ;
846         innerloop[2].value = ( every[2] > 1 ) ? lastvalue[3] - 1 : 0 ;
847         innerloop[1].value = ( every[1] > 1 ) ? 
848                                     ( whenmorethan[3] > 0 ) ?  (lastvalue[2] - 1) * every[2] + 1* innerloop[2].value 
849                                                             : lastvalue[2] - 1
850                                                : 0 ;
851     }
852      //FIXME : add checks for innerloop || lastvalue .gt. rollover  
853 }
854
855
856 function check_input(e){
857     var unicode=e.charCode? e.charCode : e.keyCode
858     if (unicode!=8 && unicode !=46 && unicode!=9 && unicode !=13){ // if key isn't backspace or delete
859         if (unicode<48||unicode>57) { // if not a number
860             alert(_("Needs to be entered in digit form -eg 10"));
861             return false // disable key press
862         }
863     }
864 }
865
866 function addbiblioPopup(biblionumber) {
867         var destination = "/cgi-bin/koha/cataloguing/addbiblio.pl?mode=popup";
868         if(biblionumber){ destination += "&biblionumber="+biblionumber; }
869  window.open(destination,'AddBiblioPopup','width=1024,height=768,toolbar=no,scrollbars=yes');
870 }
871
872 function Plugin(f)
873 {
874          window.open('subscription-bib-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
875 }
876
877 function FindAcqui(f)
878 {
879          window.open('acqui-search.pl','FindASupplier','width=800,height=400,toolbar=no,scrollbars=yes');
880 }
881
882 function Find_ISSN(f)
883 {
884          window.open('issn-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
885 }
886
887
888 function Check(f) {
889     if (f.aqbooksellerid.value.length==0) {
890         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"));
891                 if (input_box==true) {
892                 }
893                 else {
894                         return false;
895                 }
896     }
897         if (f.biblionumber.value.length==0) {
898         alert(_("You must choose or create a biblio"));
899     } else if(f.startdate.value.length != 0 && f.sublength.value > 0) {
900         if (f.irreg_check.value == 1) {
901             document.f.submit();
902         } else {
903             if(f.numbering_pattern.value == ''){
904                 alert(_("Please choose a numbering pattern"));
905             } else {
906                 alert(_("Please check for irregularity by clicking 'Test Prediction Pattern'"));
907             }
908         }
909     } else {
910         alert(_("You must choose a start date and a subscription length"));
911     }
912         if(irregular_issues.numskipped < irregular_issues.skipped.length ) {
913                 alert(_("You have not accounted for all missing issues."));
914         }
915     return false;
916 }
917
918 $(document).ready(function() {
919     init_pattern();
920 <!-- TMPL_IF name="mod" -->
921     set_num_pattern_from_template_vars();
922     <!-- TMPL_IF name="hemisphere" -->
923         is_hemisphere = <!-- TMPL_VAR NAME="hemisphere" --> ;
924     hemispheres();
925     <!-- /TMPL_IF -->
926 <!-- /TMPL_IF -->
927 <!-- TMPL_IF name="irregularity" -->
928     irregularity_check();
929 <!-- /TMPL_IF -->
930     $('#numberpattern').change( function() { 
931         reset_num_pattern(); 
932     });
933 });
934 //]]>
935 </script>
936 </head>
937 <body>
938 <!-- TMPL_INCLUDE NAME="header.inc" -->
939 <!-- TMPL_INCLUDE NAME="serials-search.inc" -->
940
941 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo; <!-- TMPL_IF name="mod" --><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=<!-- TMPL_VAR NAME="subscriptionid" -->"><i><!-- TMPL_VAR NAME="bibliotitle" escape="html" --></i></a> &rsaquo; Modify subscription<!-- TMPL_ELSE -->New subscription<!-- /TMPL_IF --></div>
942
943 <div id="doc3" class="yui-t7">
944    
945    <div id="bd">
946    <div class="yui-g">
947 <h1><!-- TMPL_IF name="mod" --> Modify subscription for <i><!-- TMPL_VAR name="bibliotitle" escape="html" --></i><!-- TMPL_ELSE -->Add a new subscription<!-- /TMPL_IF --></h1>
948     <form method="post" name="f" action="/cgi-bin/koha/serials/subscription-add.pl">
949 <!-- TMPL_IF name="mod" -->
950         <input type="hidden" name="op" value="modsubscription" />
951         <input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->" />
952 <!-- TMPL_ELSE -->
953         <input type="hidden" name="op" value="addsubscription" />
954 <!-- /TMPL_IF -->
955 <input type="hidden" name="user" value="<!-- TMPL_VAR name="loggedinusername" -->" />
956 <input type="hidden" name="irreg_check" value="0" />
957 <input type="hidden" name="issuesexpected1" id="issuesexpected1" value="0" />
958
959         <div class="yui-u first">
960     <fieldset id="subscription_add_information" class="rows">
961         <legend>Subscription details</legend>
962         <ol>
963         <li><span class="label">Subscription #</span> <!--TMPL_VAR name="subscriptionid"--></li>
964         <li><span class="label">Librarian: </span> <!-- TMPL_VAR name="loggedinusername" --></li>
965         <li>
966             <label for="aqbooksellerid">Vendor: </label>
967             <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>
968         </li>
969         <li>
970             <label for="biblionumber" class="required" title="Subscriptions must be associated with a bibliographic record">Biblio:</label>
971             
972                 <input type="text" name="biblionumber" id="biblionumber" value="<!-- TMPL_VAR name="bibnum" -->" size="8" /> 
973                 (<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>
974                <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 -->
975                 <a href="#" onclick="addbiblioPopup(); return false;">Create Biblio</a><!--/TMPL_IF--></div>
976             
977         </li>
978         <li class="radio">
979             <!-- TMPL_IF name="serialsadditems" -->
980                 <p><input type="radio" id="serialsadditems-yes" name="serialsadditems" value="1" checked="checked" /><label class="widelabel" for="serialsadditems-yes">create an item record when receiving this serial</label></p>
981                 <p><input type="radio" id="serialsadditems-no" name="serialsadditems" value="0" /><label class="widelabel" for="serialsadditems-no">do not create an item record when receiving this serial </label></p>
982             <!-- TMPL_ELSE -->
983                 <p><input type="radio" id="serialsadditems-yes" name="serialsadditems" value="1"/><label class="widelabel" for="serialsadditems-yes">create an item record when receiving this serial</label></p>
984                 <p><input type="radio" id="serialsadditems-no" name="serialsadditems" value="0" checked="checked" /><label class="widelabel" for="serialsadditems-no">do not create an item record when receiving this serial</label></p>
985             <!-- /TMPL_IF -->
986         </li>
987         <li>
988             <label for="location">Location:</label>
989             <input type="text" name="location" id="location" value="<!-- TMPL_VAR name="location" -->" size="30" />
990         </li>
991          <li>
992             <label for="callnumber">Call Number:</label>
993             <input type="text" name="callnumber" id="callnumber" value="<!-- TMPL_VAR name="callnumber" -->" size="20" />
994         </li>
995         <li>
996             <label for="branchcode">Library:</label>
997             
998                 <select name="branchcode" id="branchcode" style="width: 20em;">
999                     <!-- TMPL_UNLESS NAME="Independantbranches" --><option value="">None</option><!-- /TMPL_UNLESS -->
1000                     <!-- TMPL_LOOP name="branchloop" --><!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
1001                                 <!-- TMPL_ELSE -->
1002                                 <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
1003                                 <!-- /TMPL_IF -->
1004                     <!-- /TMPL_LOOP -->
1005                 </select> (select a library)
1006             
1007         </li>
1008         <li>
1009                 <label for="graceperiod">Grace period:</label> <input type="text" name="graceperiod" id="graceperiod" value="<!-- TMPL_VAR name="graceperiod" -->" /> day(s)
1010             </li>
1011         <li>
1012             <label for="notes">Public note:</label>
1013             <textarea name="notes" id="notes" cols="30" rows="2"><!-- TMPL_VAR name="notes" --></textarea>
1014         </li>
1015         <li>
1016             <label for="internalnotes">Nonpublic note:</label>
1017             <textarea name="internalnotes" id="internalnotes" cols="30" rows="2"><!-- TMPL_VAR name="internalnotes" --></textarea>
1018         </li>
1019         <li>
1020             <label for="letter">Patron notification: </label>
1021             
1022                <!-- TMPL_IF NAME="letterloop" -->
1023                            <select name="letter" id="letter">
1024                     <option value="">None</option>
1025                 <!-- TMPL_LOOP name="letterloop" -->
1026                                 <!-- TMPL_IF name="selected" -->
1027                     <option value="<!-- TMPL_VAR name="value" -->" selected="selected"><!-- TMPL_VAR name="lettername" --></option>
1028 <!-- TMPL_ELSE -->
1029                     <option value="<!-- TMPL_VAR name="value" -->"><!-- TMPL_VAR name="lettername" --></option>
1030 <!-- /TMPL_IF -->
1031                 <!-- /TMPL_LOOP -->
1032                 </select> 
1033                                 <div class="hint">Select a notice and patrons on the routing list will be notified when new issues are received.</div>
1034                 <!-- TMPL_ELSE -->
1035                                 <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>
1036                                 <!-- /TMPL_IF -->
1037         </li>
1038                 <li class="radio">
1039                         <label for="staffdisplaycount">Staff and Public Display</label>
1040                         <p>
1041                          <label class="widelabel" for="staffdisplaycount">Number of issues to display to staff: </label>
1042                          <input type="text" name="staffdisplaycount" id="staffdisplaycount" value="<!-- TMPL_VAR NAME="staffdisplaycount" -->" size="4"/>
1043                         </p>
1044                         <p>
1045                         <label class="widelabel" for="opacdisplaycount">Number of issues to display to the public: </label>
1046                         <input type="text" name="opacdisplaycount" id="opacdisplaycount" value="<!-- TMPL_VAR NAME="opacdisplaycount" -->" size="4"/>
1047                         </p>
1048                 </li>
1049         </ol>
1050
1051             <div style="float:left;clear:left;margin:1em;"><strong>Note:</strong>
1052             
1053                 <ul>
1054                     <li>The subscription <strong>must</strong> be associated with a bibliographic record.</li>
1055                     <li>You <strong>must</strong> select a vendor if you wish to generate claims.</li>
1056                 </ul></div>
1057             
1058             
1059         </fieldset>
1060         </div>
1061         
1062 <div class="yui-u">
1063 <div id="subscription_form_planning">
1064         <fieldset class="rows">
1065         <legend>Serials planning</legend>
1066     <ol>
1067         <li>
1068            <label for="acqui_date"> First issue publication date:</label>
1069                 <!-- TMPL_UNLESS NAME="mod" --><img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="acqui_button" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" /><!-- /TMPL_UNLESS -->
1070                 <input type="text" name="firstacquidate" value="<!-- TMPL_VAR name="firstacquidate" -->"  size="13" maxlength="10" id="acqui_date" <!-- TMPL_IF NAME="mod" -->disabled="disabled"<!-- /TMPL_IF --> style="border-width: 0px;"  />
1071         </li>
1072            <!-- TMPL_IF NAME="mod" --><li><label for="next_acqui_date"> Next issue publication date:</label>
1073                 <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="next_acqui_button" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
1074                 <input type="text" name="nextacquidate" value="<!-- TMPL_VAR name="nextacquidate" -->" size="13" maxlength="10" id="next_acqui_date" style="border-width: 0px;"  />
1075                 </li><!-- /TMPL_IF -->
1076                 
1077         <li><!-- both scripts for calendar must follow the input field --> 
1078                 <script type="text/javascript">
1079                     Calendar.setup({
1080                         inputField      :   "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_date",
1081                         ifFormat       :   "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1082                         button         :   "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_button",
1083                         align          :   "Tl",
1084                         onUpdate        :    function(cal) { 
1085                                                              irregular_issues.weeks = getWeeksArray(cal.date);
1086                                                             irregular_issues.firstissue = cal.date;
1087                                                             if(document.irregularity_summary) {
1088                                                                 irregular_issues.update();
1089                                                             }
1090                                                             if(document.getElementById("seasonal_irregularity")) {
1091                                                                 moreoptions_seasons(text[15]);
1092                                                             }
1093                                                         } 
1094                         });
1095                     Calendar.setup({
1096                         inputField      :   "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_date",
1097                         ifFormat       :   "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1098                         button         :   "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_date",
1099                         align          :   "Tl",
1100                         onUpdate        :    function(cal) { irregular_issues.weeks = getWeeksArray(cal.date);
1101                                                             irregular_issues.firstissue = cal.date;
1102                                                             if(document.irregularity_summary) {
1103                                                                 irregular_issues.update();
1104                                                             }
1105                                                             if(document.getElementById("seasonal_irregularity")) {
1106                                                                 moreoptions_seasons(text[15]);
1107                                                             }
1108                                                         } 
1109                         });
1110                 </script>
1111             <label for="periodicity" class="required">Frequency:</label>
1112             
1113                 <select name="periodicity" size="1" id="periodicity" onchange="javascript:document.getElementsByName('manualhist')[0].checked=(this.value==1); reset_num_pattern();">
1114                 <option value="" selected="selected">-- please choose --</option>
1115                 <!-- TMPL_IF name="periodicity16" -->
1116                 <option value="16" selected="selected">Without periodicity</option>
1117                 <!-- TMPL_ELSE -->
1118                     <option value="16">Without periodicity</option>
1119                 <!-- /TMPL_IF -->
1120                 <!-- TMPL_IF name="periodicity48" -->
1121                 <option value="48" selected="selected">Unknown</option>
1122                 <!-- TMPL_ELSE -->
1123                 <option value="48">Unknown</option>
1124                 <!-- /TMPL_IF -->
1125                 <!-- TMPL_IF name="periodicity32" -->
1126                 <option value="32" selected="selected">Irregular</option>
1127                 <!-- TMPL_ELSE -->
1128                     <option value="32">Irregular</option>
1129                 <!-- /TMPL_IF -->
1130
1131                 <!-- TMPL_IF name="periodicity12" -->
1132                     <option value="12" selected="selected">2/day</option>
1133                 <!-- TMPL_ELSE -->
1134                     <option value="12">2/day</option>
1135                 <!-- /TMPL_IF -->
1136                 <!-- TMPL_IF name="periodicity1" -->
1137                     <option value="1" selected="selected">daily (n/week)</option>
1138                 <!-- TMPL_ELSE -->
1139                     <option value="1">daily (n/week)</option>
1140                 <!-- /TMPL_IF -->
1141                 <!-- TMPL_IF name="periodicity2" -->
1142                     <option value="2" selected="selected">1/week</option>
1143                 <!-- TMPL_ELSE -->
1144                     <option value="2">1/week</option>
1145                 <!-- /TMPL_IF -->
1146                 <!-- TMPL_IF name="periodicity3" -->
1147                     <option value="3" selected="selected">1/2 weeks </option>
1148                 <!-- TMPL_ELSE -->
1149                     <option value="3">1/2 weeks </option>
1150                 <!-- /TMPL_IF -->
1151                 <!-- TMPL_IF name="periodicity4" -->
1152                     <option value="4" selected="selected">1/3 weeks</option>
1153                 <!-- TMPL_ELSE -->
1154                     <option value="4">1/3 weeks</option>
1155                 <!-- /TMPL_IF -->
1156                 <!-- TMPL_IF name="periodicity5" -->
1157                     <option value="5" selected="selected">1/month</option>
1158                 <!-- TMPL_ELSE -->
1159                     <option value="5">1/month</option>
1160                 <!-- /TMPL_IF -->
1161                 <!-- TMPL_IF name="periodicity6" -->
1162                     <option value="6" selected="selected">1/2 months (6/year)</option>
1163                 <!-- TMPL_ELSE -->
1164                     <option value="6">1/2 months (6/year)</option>
1165                 <!-- /TMPL_IF -->
1166                 <!-- TMPL_IF name="periodicity7" -->
1167                     <option value="7" selected="selected">1/3 months (1/quarter)</option>
1168                 <!-- TMPL_ELSE -->
1169                     <option value="7">1/3 months (1/quarter)</option>
1170                 <!-- /TMPL_IF -->
1171                 <!-- periodicity8 is 1/quarter, exactly like periodicity7 but will use it for seasonal option -->
1172                 <!-- TMPL_IF name="periodicity8" -->
1173                     <option value="8" selected="selected">1/quarter (seasonal)</option>
1174                 <!-- TMPL_ELSE -->
1175                     <option value="8">1/quarter (seasonal)</option>
1176                 <!-- /TMPL_IF -->
1177
1178                 <!-- TMPL_IF name="periodicity9" -->
1179                     <option value="9" selected="selected">2/years</option>
1180                 <!-- TMPL_ELSE -->
1181                     <option value="9">2/year</option>
1182                 <!-- /TMPL_IF -->
1183                 <!-- TMPL_IF name="periodicity10" -->
1184                     <option value="10" selected="selected">1/year</option>
1185                 <!-- TMPL_ELSE -->
1186                     <option value="10">1/year</option>
1187                 <!-- /TMPL_IF -->
1188                 <!-- TMPL_IF name="periodicity11" -->
1189                     <option value="11" selected="selected">1/2 years</option>
1190                 <!-- TMPL_ELSE -->
1191                     <option value="11">1/2 years</option>
1192                 <!-- /TMPL_IF -->
1193                 </select> <span class="required">Required</span></li>
1194                 <li>
1195                     <label for="manuallist"> Manual history:</label>
1196                     <!-- TMPL_IF name="manualhistory" -->
1197                         <input type="checkbox" name="manualhist" id="manuallist" value="1" checked="checked" />
1198                     <!-- TMPL_ELSE -->
1199                         <input type="checkbox" name="manualhist" id="manuallist" value="1" />
1200                     <!-- /TMPL_IF -->
1201                 </li>
1202         <li>
1203            <label for="numberpattern"> Numbering pattern:</label>
1204             
1205                 <select name="numbering_pattern" size="1" id="numberpattern" >
1206                     <option value="" selected="selected">-- please choose --</option>
1207                     <!-- TMPL_IF name="numberpattern1" -->
1208                         <option value="1" selected="selected">Number</option>
1209                     <!-- TMPL_ELSE -->
1210                         <option value="1">Number</option>
1211                     <!-- /TMPL_IF -->
1212                     <!-- TMPL_IF name="numberpattern2" -->
1213                         <option value="2" selected="selected">Volume, Number, Issue</option>
1214                     <!-- TMPL_ELSE -->
1215                         <option value="2">Volume, Number, Issue</option>
1216                     <!-- /TMPL_IF -->
1217                     <!-- TMPL_IF name="numberpattern3" -->
1218                         <option value="3" selected="selected">Volume, Number</option>
1219                     <!-- TMPL_ELSE -->
1220                         <option value="3">Volume, Number</option>
1221                     <!-- /TMPL_IF -->
1222                     <!-- TMPL_IF name="numberpattern4" -->
1223                         <option value="4" selected="selected">Volume, Issue</option>
1224                     <!-- TMPL_ELSE -->
1225                         <option value="4">Volume, Issue</option>
1226                     <!-- /TMPL_IF -->
1227                     <!-- TMPL_IF name="numberpattern5" -->
1228                         <option value="5" selected="selected">Number, Issue</option>
1229                     <!-- TMPL_ELSE -->
1230                         <option value="5">Number, Issue</option>
1231                     <!-- /TMPL_IF -->
1232                     <!-- TMPL_IF name="numberpattern6" -->
1233                         <option value="6" selected="selected">Seasonal only</option>
1234                     <!-- TMPL_ELSE -->
1235                         <option value="6">Seasonal only</option>
1236                     <!-- /TMPL_IF -->
1237                     <!-- TMPL_IF name="numberpattern8" -->
1238                         <option value="8" selected="selected">Year/Number</option>
1239                     <!-- TMPL_ELSE -->
1240                         <option value="8">Year/Number</option>
1241                     <!-- /TMPL_IF -->          
1242                     <!-- TMPL_IF name="numberpattern7" -->
1243                         <option value="7" selected="selected">None of the above</option>
1244                     <!-- TMPL_ELSE -->
1245                         <option value="7">None of the above</option>
1246                     <!-- /TMPL_IF -->
1247                 </select>
1248         </li>
1249                 <li id="more_options"></li>
1250                 <li id="irregularity"></li>
1251                    <li id="displayexample"></li>
1252         <li>
1253            <label for="beginning_date" class="required"> Subscription start date:</label>
1254             
1255                 <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="button1" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
1256                 <input type="text" name="startdate" value="<!-- TMPL_VAR name="startdate" -->" size="13" maxlength="10" id="beginning_date" style="border-width: 0px;" />
1257                 <!-- both scripts for calendar must follow the input field --> 
1258                 <script type="text/javascript">
1259                     Calendar.setup({
1260                         inputField   : "beginning_date",
1261                         ifFormat     : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1262                         button       : "button1",
1263                         align        : "Tl"
1264                     });
1265                     Calendar.setup({
1266                         inputField   : "beginning_date",
1267                         ifFormat     : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
1268                         button       : "beginning_date",
1269                         align        : "Tl"
1270                     });
1271                 </script>
1272             <span class="required">Required</span>
1273         </li>
1274         <li>
1275             <label for="subtype" class="required">Subscription length:</label>
1276             
1277                 <select name="subtype" id="subtype">
1278                     <!-- TMPL_LOOP NAME="subtype" -->
1279                         <!-- TMPL_IF NAME="selected" -->
1280                         <option value="<!-- TMPL_VAR NAME="name" -->" selected="selected">
1281                         <!-- TMPL_ELSE -->
1282                         <option value="<!-- TMPL_VAR NAME="name" -->">
1283                         <!-- /TMPL_IF -->
1284                         <!-- TMPL_VAR NAME="name" -->
1285                         </option>
1286                     <!-- /TMPL_LOOP -->
1287                 </select>
1288                 <input type="text" name="sublength" value="<!-- TMPL_VAR name="sublength" -->" size="3" onkeypress="return check_input(event)" /> (enter amount in numerals)
1289             <span class="required">Required</span>
1290         </li>
1291     <li><label for="numberingmethod">Numbering formula:</label> <input type="text" name="numberingmethod" id="numberingmethod" value="<!-- TMPL_VAR name="numberingmethod" -->" />
1292     </li>
1293     </ol>
1294         </fieldset>
1295 </div>
1296         <fieldset class="action">
1297         <input type="button" class="action_test" value="Test Prediction Pattern" onclick="javascript:irregularity_check()" />
1298         <input type="button" class="action_reset" value="Reset Pattern" onclick="javascript:reset_pattern()" />
1299     <input type="button" class="action_save"  value="Save subscription" onclick="Check(this.form)" accesskey="w" />
1300         </fieldset>
1301     <fieldset class="action">
1302     <input type="button" class="action_advanced" value="Show/Hide Advanced Pattern" onclick="javascript:display_table()" />
1303     </fieldset>
1304            <div id="basetable"  style="display: none;">
1305             <table class="small">
1306                 <tr><th colspan="4">Advanced Prediction Pattern</th></tr>
1307                                 <tr>
1308                     <th>&nbsp;</th>
1309                     <th>X</th>
1310                     <th>Y</th>
1311                     <th>Z</th>
1312                 </tr>
1313                 <tr>
1314                     <td>Add</td>
1315                     <td>
1316                         <input type="text" name="add1" id="add1" value="<!-- TMPL_VAR name="add1" -->" />
1317                     </td>
1318                     <td>
1319                         <input type="text" name="add2" id="add2" value="<!-- TMPL_VAR name="add2" -->" />
1320                     </td>
1321                     <td>
1322                         <input type="text" name="add3" id="add3" value="<!-- TMPL_VAR name="add3" -->" />
1323                     </td>
1324                 </tr>
1325                 <tr>
1326                     <td>once every</td>
1327                     <td><input type="text" name="every1" id="every1" value="<!-- TMPL_VAR name="every1" -->" /></td>
1328                     <td><input type="text" name="every2" id="every2" value="<!-- TMPL_VAR name="every2" -->" /></td>
1329                     <td><input type="text" name="every3" id="every3" value="<!-- TMPL_VAR name="every3" -->" /></td>
1330                 </tr>
1331                 <tr>
1332                     <td>When more than</td>
1333                     <td><input type="text" name="whenmorethan1" id="whenmorethan1" value="<!-- TMPL_VAR name="whenmorethan1" -->" /></td>
1334                     <td><input type="text" name="whenmorethan2" id="whenmorethan2" value="<!-- TMPL_VAR name="whenmorethan2" -->" /></td>
1335                     <td><input type="text" name="whenmorethan3" id="whenmorethan3" value="<!-- TMPL_VAR name="whenmorethan3" -->" /></td>
1336                 </tr>
1337                 <tr>
1338                     <td>inner counter</td>
1339                     <td><input type="text" name="innerloop1" id="innerloop1" value="<!-- TMPL_VAR name="innerloop1" -->" /></td>
1340                     <td><input type="text" name="innerloop2" id="innerloop2" value="<!-- TMPL_VAR name="innerloop2" -->" /></td>
1341                     <td><input type="text" name="innerloop3" id="innerloop3" value="<!-- TMPL_VAR name="innerloop3" -->" /></td>
1342                 </tr>
1343                 <tr>
1344                     <td>Set back to</td>
1345                     <td><input type="text" name="setto1" id="setto1" value="<!-- TMPL_VAR name="setto1" -->" /></td>
1346                     <td><input type="text" name="setto2" id="setto2" value="<!-- TMPL_VAR name="setto2" -->" /></td>
1347                     <td><input type="text" name="setto3" id="setto3" value="<!-- TMPL_VAR name="setto3" -->" /></td>
1348                 </tr>
1349                 <tr>
1350                     <td>
1351                         <!-- TMPL_IF name="mod" -->
1352                             Last value
1353                         <!-- TMPL_ELSE -->
1354                             Begins with
1355                         <!-- /TMPL_IF -->
1356                     </td>
1357                     <td><input type="text" name="lastvalue1" id="lastvalue1" value="<!-- TMPL_VAR name="lastvalue1" -->" /></td>
1358                     <td><input type="text" name="lastvalue2" id="lastvalue2" value="<!-- TMPL_VAR name="lastvalue2" -->" /></td>
1359                     <td><input type="text" name="lastvalue3" id="lastvalue3" value="<!-- TMPL_VAR name="lastvalue3" -->" /></td>
1360                 </tr>
1361             </table>
1362         </div>
1363
1364 </div>
1365
1366 </form>
1367 </div>
1368
1369 <!--TMPL_IF Name="history"-->
1370 <div id="subscription_form_history">
1371     <h2>Subscription history</h2>
1372     <form method="post" action="/cgi-bin/koha/serials/subscription-add.pl">
1373         <input type="hidden" name="op" value="modsubscription" />
1374         <input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->" />
1375         <input type="hidden" name="history_only" value="1" />
1376         <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>
1377         <fieldset class="rows">
1378                 <ol>
1379             <li>
1380             <label for="histstartdate">Subscription start date</label>
1381             <input type="text" name="histstartdate" id="histstartdate" value="<!-- TMPL_VAR name="histstartdate" -->" /><div class="hint"> (start date of the 1st subscription)</div>
1382             </li>
1383             <li>
1384             <label for="histenddate">Subscription end date</label>
1385             <input type="text" name="histenddate" id="histenddate" value="<!-- TMPL_VAR name="histenddate" -->" /> <div class="hint">(if empty, subscription is still active)</div>
1386             </li>
1387             <li>
1388                 <label for="recievedlist">Received issues</label>
1389             <textarea name="recievedlist" id="recievedlist" cols="60" rows="5"><!-- TMPL_VAR name="recievedlist" --></textarea>
1390             </li>
1391             <li>
1392                 <label for="missinglist">Missing issues</label>
1393             <textarea name="missinglist" id="missinglist" cols="60" rows="5"><!-- TMPL_VAR name="missinglist" --></textarea>
1394             </li>
1395             <li>
1396                 <label for="opacnote">Note for OPAC</label>
1397             <textarea name="opacnote" id="opacnote" cols="60" rows="5"><!-- TMPL_VAR name="opacnote" --></textarea>
1398             </li>
1399             <li>
1400                 <label for="librariannote">Note for staff</label>
1401             <textarea name="librariannote" id="librariannote" cols="60" rows="5"><!-- TMPL_VAR name="librariannote" --></textarea>
1402             </li>
1403                 </ol>
1404         </fieldset>
1405     <fieldset class="action"><input type="submit" value="Save subscription history"  /></fieldset>
1406     </form>
1407 </div>
1408 <!--/TMPL_IF-->
1409
1410 </div>
1411
1412 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->