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