Bug 10855: New fields on adding/updating a subscription
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / subscription-add.tt
1 [% USE KohaDates %]
2
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Serials &rsaquo; [% IF ( modify ) %][% bibliotitle |html %] &rsaquo; Modify subscription[% ELSE %]New subscription[% END %]</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% INCLUDE 'calendar.inc' %]
7 <style type="text/css">
8 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
9 .yui-u li p label.widelabel {
10     width: 300px;  /* not enough for IE7 apparently */
11 }
12 </style>
13 <script type="text/javascript">
14 //<![CDATA[
15
16 var globalnumpatterndata;
17 var globalfreqdata;
18 var advancedpatternlocked;
19 var patternneedtobetested = 0;
20
21 function check_issues(){
22     if (globalfreqdata.unit.length >0) {
23         if (document.f.subtype.value == globalfreqdata.unit){
24             document.f.issuelengthcount.value=(document.f.sublength.value*globalfreqdata.issuesperunit)/globalfreqdata.unitsperissue;
25         } else if (document.f.subtype.value != "issues"){
26             alert(_("Frequency and subscription length provided doesn't combine well. Please consider entering an issue count rather than a time period."));
27         }
28     }
29 }
30
31 function addbiblioPopup(biblionumber) {
32     var destination = "/cgi-bin/koha/cataloguing/addbiblio.pl?mode=popup";
33     if(biblionumber){
34         destination += "&biblionumber="+biblionumber;
35     }
36     window.open(destination,'AddBiblioPopup','width=1024,height=768,toolbar=no,scrollbars=yes');
37 }
38
39 function Plugin(f)
40 {
41     window.open('subscription-bib-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
42 }
43
44 function FindAcqui(f)
45 {
46     window.open('acqui-search.pl','FindASupplier','width=800,height=400,toolbar=no,scrollbars=yes');
47 }
48
49 function Find_ISSN(f)
50 {
51     window.open('issn-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
52 }
53
54 function Clear(id) {
55     $("#"+id).val('');
56 }
57
58 function Check_page1() {
59     if ( $("#aqbooksellerid").val().length == 0) {
60         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"));
61         if (input_box==false) {
62             return false;
63         }
64     }
65     if ($("#biblionumber").val().length == 0) {
66         alert(_("You must choose or create a biblio"));
67         return false;
68     }
69
70     return true;
71 }
72
73 function Check_page2(){
74     [% UNLESS (more_than_one_serial) %]
75       if($("#acqui_date").val().length == 0){
76           alert(_("You must choose a first publication date"));
77           return false;
78       }
79     [% END %]
80     if($("#sublength").val().length == 0 && $("input[name='enddate']").val().length == 0){
81         alert(_("You must choose a subscription length or an end date."));
82         return false;
83     }
84     if(advancedpatternlocked == 0){
85         alert(_("You have modified the advanced prediction pattern. Please save your work or cancel modifications."));
86         return false;
87     }
88     if(patternneedtobetested){
89         alert(_("Please click on 'Test prediction pattern' before saving subscription."));
90         return false;
91     }
92
93     return true;
94 }
95
96 function frequencyload(){
97     $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'},
98         function(freqdata){
99             globalfreqdata=freqdata;
100             if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) {
101                 var option = $("#subtype option[value='issues']");
102                 $(option).attr('selected', 'selected');
103                 $("#subtype option[value!='issues']").attr('disabled', 'disabled')
104             } else {
105                 $("#subtype option").attr('disabled', false)
106             }
107         }
108     )
109 }
110
111 function numberpatternload(){
112     $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'},
113         function(numpatterndata){
114             globalnumpatterndata=numpatterndata;
115             if (globalnumpatterndata==undefined){
116                 return false;
117             }
118             displaymoreoptions();
119             restoreAdvancedPattern();
120         }
121     );
122 }
123
124 function displaymoreoptions() {
125     if(globalnumpatterndata == undefined){
126         $("#moreoptionst").hide();
127         return false;
128     }
129
130     var X = 0, Y = 0, Z = 0;
131     var numberingmethod = globalnumpatterndata.numberingmethod;
132     if(numberingmethod.match(/{X}/)) X = 1;
133     if(numberingmethod.match(/{Y}/)) Y = 1;
134     if(numberingmethod.match(/{Z}/)) Z = 1;
135
136     if(X || Y || Z) {
137         $("#moreoptionst").show();
138     } else {
139         $("#moreoptionst").hide();
140     }
141
142     if(X) {
143         if(globalnumpatterndata.label1) {
144             $("#headerX").html(globalnumpatterndata.label1);
145         } else {
146             $("#headerX").html("X");
147         }
148         $("#headerX").show();
149         $("#beginsX").show();
150         $("#innerX").show();
151     } else {
152         $("#headerX").hide();
153         $("#beginsX").hide();
154         $("#innerX").hide();
155         $("#lastvaluetemp1").val('');
156         $("#innerlooptemp1").val('');
157     }
158     if(Y) {
159         if(globalnumpatterndata.label2) {
160             $("#headerY").html(globalnumpatterndata.label2);
161         } else {
162             $("#headerY").html("Y");
163         }
164         $("#headerY").show();
165         $("#beginsY").show();
166         $("#innerY").show();
167     } else {
168         $("#headerY").hide();
169         $("#beginsY").hide();
170         $("#innerY").hide();
171         $("#lastvaluetemp2").val('');
172         $("#innerlooptemp2").val('');
173     }
174     if(Z) {
175         if(globalnumpatterndata.label3) {
176             $("#headerZ").html(globalnumpatterndata.label3);
177         } else {
178             $("#headerZ").html("Z");
179         }
180         $("#headerZ").show();
181         $("#beginsZ").show();
182         $("#innerZ").show();
183     } else {
184         $("#headerZ").hide();
185         $("#beginsZ").hide();
186         $("#innerZ").hide();
187         $("#lastvaluetemp3").val('');
188         $("#innerlooptemp3").val('');
189     }
190 }
191
192 function toggleAdvancedPattern() {
193     $("#advancedpredictionpattern").toggle();
194 }
195
196 function modifyAdvancedPattern() {
197     $("#patternname").attr("readonly", false).val('');
198     $("#numberingmethod").attr("readonly", false);
199
200     $("#advancedpredictionpatternt input").each(function() {
201         $(this).attr("readonly", false);
202     });
203     $("#advancedpredictionpatternt select").each(function() {
204         $(this).attr("disabled", false);
205     });
206
207     $("#restoreadvancedpatternbutton").show();
208     $("#saveadvancedpatternbutton").show();
209     $("#modifyadvancedpatternbutton").hide();
210
211     advancedpatternlocked = 0;
212 }
213
214 function restoreAdvancedPattern() {
215     $("#patternname").attr("readonly", true).val(globalnumpatterndata.label);
216     $("#numberingmethod").attr("readonly", true).val(globalnumpatterndata.numberingmethod);
217
218     $("#advancedpredictionpatternt input").each(function() {
219         $(this).attr("readonly", true);
220         var id = $(this).attr('id');
221         if(id.match(/lastvalue/) || id.match(/innerloop/)) {
222             var tempid = id.replace(/(\d)/, "temp$1");
223             $(this).val($("#"+tempid).val());
224         } else {
225             $(this).val(globalnumpatterndata[id]);
226         }
227     });
228     $("#advancedpredictionpatternt select").each(function() {
229         $(this).attr("disabled", true);
230         var id = $(this).attr('id');
231         $(this).val(globalnumpatterndata[id]);
232     });
233
234     $("#restoreadvancedpatternbutton").hide();
235     $("#saveadvancedpatternbutton").hide();
236     $("#modifyadvancedpatternbutton").show();
237
238     advancedpatternlocked = 1;
239 }
240
241 function testPredictionPattern() {
242     var frequencyid = $("#frequency").val();
243     var acquidate;
244     var error = 0;
245     var error_msg = "";
246     if(frequencyid == undefined || frequencyid == ""){
247         error_msg += _("- Frequency is not defined") + "\n";
248         error ++;
249     }
250     acquidate = $("#acqui_date").val();
251     if(acquidate == undefined || acquidate == ""){
252         error_msg += _("- First publication date is not defined") + "\n";
253         error ++;
254     }
255     [% IF (more_than_one_serial) %]
256       var nextacquidate = $("#nextacquidate").val();
257       if(nextacquidate == undefined || nextacquidate == ""){
258         error_msg += _("- Next issue publication date is not defined") + "\n";
259         error ++;
260       }
261     [% END %]
262
263     if(error){
264         alert(_("Cannot test prediction pattern for the following reason(s): %s").format(error_msg));
265         return false;
266     }
267
268     var custompattern = 0;
269     if(advancedpatternlocked == 0) {
270         custompattern = 1;
271     }
272
273     var ajaxData = {
274         'custompattern': custompattern,
275         [% IF (subscriptionid) %]
276             'subscriptionid': [% subscriptionid %],
277         [% END %]
278         [% IF (more_than_one_serial) %]
279           'nextacquidate': nextacquidate,
280         [% END %]
281         'firstacquidate': acquidate
282     };
283     var ajaxParams = [
284         'to', 'subtype', 'sublength', 'frequency', 'numberingmethod',
285         'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
286         'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
287         'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
288         'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
289     ];
290     for(i in ajaxParams) {
291         var param = ajaxParams[i];
292         var value = $("#"+param).val();
293         if(value.length > 0)
294             ajaxData[param] = value;
295     }
296
297     $.ajax({
298         url:"/cgi-bin/koha/serials/showpredictionpattern.pl",
299         data: ajaxData,
300         success: function(data) {
301             $("#displayexample").html(data);
302             patternneedtobetested = 0;
303         }
304     });
305 }
306
307 function saveAdvancedPattern() {
308     if ($("#patternname").val().length == 0) {
309         alert(_("Please enter a name for this pattern"));
310         return false;
311     }
312
313     // Check if patternname already exists, and modify pattern
314     // instead of creating it if so
315     var found = 0;
316     $("#numberpattern option").each(function(){
317         if($(this).text() == $("#patternname").val()){
318             found = 1;
319             return false;
320         }
321     });
322     var cnfrm = 1;
323     if(found){
324         var msg = _("This pattern name already exists. Do you want to modify it?")
325             + "\n" + _("Warning: it will modify the pattern for all subscriptions that are using it.");
326         cnfrm = confirm(msg);
327     }
328
329     if(cnfrm) {
330         var ajaxData = {};
331         var ajaxParams = [
332             'patternname', 'numberingmethod', 'label1', 'label2', 'label3',
333             'add1', 'add2', 'add3', 'every1', 'every2', 'every3',
334             'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
335             'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
336         ];
337         for(i in ajaxParams) {
338             var param = ajaxParams[i];
339             var value = $("#"+param).val();
340             if(value.length > 0)
341                 ajaxData[param] = value;
342         }
343
344         $.getJSON(
345             "/cgi-bin/koha/serials/create-numberpattern.pl",
346             ajaxData,
347             function(data){
348                 if (data.numberpatternid) {
349                     if(found == 0){
350                         $("#numberpattern").append("<option value=\""+data.numberpatternid+"\">"+$("#patternname").val()+"</option>");
351                     }
352                     $("#numberpattern").val(data.numberpatternid);
353                     numberpatternload();
354                 } else {
355                     alert(_("Something went wrong. Unable to create a new numbering pattern."));
356                 }
357             }
358         );
359     }
360 }
361
362 function show_page_1() {
363     $("#page_1").show();
364     $("#page_2").hide();
365     $("#page_number").text("1/2");
366 }
367
368 function show_page_2() {
369     $("#page_1").hide();
370     $("#page_2").show();
371     $("#page_number").text("2/2");
372     displaymoreoptions();
373 }
374
375
376 $(document).ready(function() {
377     $("#aqbooksellerid").on('keypress', function(e) {
378         if (e.keyCode == 13) {
379             e.preventDefault();
380             FindAcqui();
381         }
382     });
383     $("#biblionumber").on('keypress', function(e) {
384         if (e.keyCode == 13) {
385             e.preventDefault();
386             Plugin();
387         }
388     });
389     $("select#frequency").change(function(){
390         patternneedtobetested = 1;
391         $("input[name='enddate']").val('');
392         frequencyload();
393     });
394     $("select#numberpattern").change(function(){
395         patternneedtobetested = 1;
396         numberpatternload();
397     });
398     $("#subtype").change(function(){
399         $("input[name='enddate']").val('');
400     });
401     $("#sublength").change(function(){
402         $("input[name='enddate']").val('');
403     });
404     $("#lastvaluetemp1").keyup(function(){
405         $("#lastvalue1").val($(this).val());
406     });
407     $("#lastvaluetemp2").keyup(function(){
408         $("#lastvalue2").val($(this).val());
409     });
410     $("#lastvaluetemp3").keyup(function(){
411         $("#lastvalue3").val($(this).val());
412     });
413     $("#lastvalue1").keyup(function(){
414         $("#lastvaluetemp1").val($(this).val());
415     });
416     $("#lastvalue2").keyup(function(){
417         $("#lastvaluetemp2").val($(this).val());
418     });
419     $("#lastvalue3").keyup(function(){
420         $("#lastvaluetemp3").val($(this).val());
421     });
422
423     $("#innerlooptemp1").keyup(function(){
424         $("#innerloop1").val($(this).val());
425     });
426     $("#innerlooptemp2").keyup(function(){
427         $("#innerloop2").val($(this).val());
428     });
429     $("#innerlooptemp3").keyup(function(){
430         $("#innerloop3").val($(this).val());
431     });
432     $("#innerloop1").keyup(function(){
433         $("#innerlooptemp1").val($(this).val());
434     });
435     $("#innerloop2").keyup(function(){
436         $("#innerlooptemp2").val($(this).val());
437     });
438     $("#innerloop3").keyup(function(){
439         $("#innerlooptemp3").val($(this).val());
440     });
441
442     if($("#frequency").val() != ""){
443         frequencyload();
444     }
445     if($("#numberpattern").val() != ""){
446         numberpatternload();
447     }
448
449     var node;
450     [% FOREACH field IN dont_export_field_loop %]
451         node = $("#[% field.fieldid %]");
452         if ( $(node).is('input') || $(node).is('textarea') ) {
453             $(node).val("");
454         } else if ( $(node).is('select') ) {
455             $(node).find("option:first").attr('selected','selected');
456         }
457     [% END %]
458
459     show_page_1();
460 });
461 //]]>
462 </script>
463 </head>
464 <body id="ser_subscription-add" class="ser">
465 [% INCLUDE 'header.inc' %]
466 [% INCLUDE 'serials-search.inc' %]
467
468 <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; [% IF ( modify ) %]<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscriptionid %]"><i>[% bibliotitle |html %]</i></a> &rsaquo; Modify subscription[% ELSE %]New subscription[% END %]</div>
469
470 <div id="doc3" class="yui-t7">
471     <div id="bd">
472         <div class="yui-g">
473             <h1>[% IF ( modify ) %] Modify subscription for <i>[% bibliotitle |html %]</i>[% ELSE %]Add a new subscription[% END %] (<span id="page_number">1/2</span>)</h1>
474             <form method="post" name="f" action="/cgi-bin/koha/serials/subscription-add.pl" class="validated" onsubmit="return Check_page2();" >
475                 [% IF ( modify ) %]
476                     <input type="hidden" name="op" value="modsubscription" />
477                     <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
478                 [% ELSE %]
479                         <input type="hidden" name="op" value="addsubscription" />
480                 [% END %]
481                 <input type="hidden" name="user" value="[% loggedinusername %]" />
482                 <input type="hidden" name="irreg_check" value="0" />
483
484                 <div id="page_1">
485                     <div class="yui-u first">
486                         <fieldset id="subscription_add_information" class="rows">
487                             <legend>Subscription details</legend>
488                             <ol>
489                                 [% IF ( subscriptionid ) %]
490                                     <li><span class="label">Subscription #</span> [% subscriptionid %]</li>
491                                 [% END %]
492                                 <li>
493                                     <label for="aqbooksellerid">Vendor: </label>
494                                     <input type="text" name="aqbooksellerid" id="aqbooksellerid" value="[% aqbooksellerid %]" size="8" /> (<input type="text" name="aqbooksellername" id="aqbooksellername" value="[% aqbooksellername %]" disabled="disabled" readonly="readonly" />) <a href="#" onclick="FindAcqui(f)">Search for a vendor</a>
495                                 </li>
496                                 <li>
497                                     <label for="biblionumber" class="required" title="Subscriptions must be associated with a bibliographic record">Record:</label>
498                                     <input type="text" name="biblionumber" id="biblionumber" value="[% bibnum %]" size="8" />
499                                     (<input type="text" name="title" value="[% bibliotitle %]" disabled="disabled" readonly="readonly" />) <span class="required" title="Subscriptions must be associated with a bibliographic record">Required</span>
500                                     <div class="inputnote"> <a href="#" onclick="Plugin(f)">Search for record</a>
501                                         [% IF ( CAN_user_editcatalogue ) %]
502                                             [% IF ( modify ) %]
503                                             | <a href="#" onclick="addbiblioPopup([% bibnum %]); return false;">Edit record</a>
504                                             [% ELSE %]
505                                             | <a href="#" onclick="addbiblioPopup(); return false;">Create record</a>
506                                             [% END %]
507                                         [% END %]
508                                     </div>
509                                 </li>
510                                 <li class="radio">
511                                     [% IF ( serialsadditems ) %]
512                                         <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>
513                                         <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>
514                                     [% ELSE %]
515                                         <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>
516                                         <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>
517                                     [% END %]
518                                 </li>
519                                 <li class="radio">
520                                   <p>When there is an irregular issue:</p>
521                                   [% IF (skip_serialseq) %]
522                                     <p>
523                                       <input type="radio" id="skip_serialseq_yes" name="skip_serialseq" value="1" checked="checked" />
524                                       <label for="skip_serialseq_yes">Skip issue number</label>
525                                     </p>
526                                     <p>
527                                       <input type="radio" id="skip_serialseq_no" name="skip_serialseq" value="0" />
528                                       <label for="skip_serialseq_no">Keep issue number</label>
529                                     </p>
530                                   [% ELSE %]
531                                     <p>
532                                       <input type="radio" id="skip_serialseq_yes" name="skip_serialseq" value="1" />
533                                       <label for="skip_serialseq_yes">Skip issue number</label>
534                                     </p>
535                                     <p>
536                                       <input type="radio" id="skip_serialseq_no" name="skip_serialseq" value="0" checked="checked" />
537                                       <label for="skip_serialseq_no">Keep issue number</label>
538                                     </p>
539                                   [% END %]
540                                 </li>
541                                 <li>
542                                     <label for="manualhistory">Manual history</label>
543                                     [% IF (manualhistory) %]
544                                         <input type="checkbox" id="manualhistory" name="manualhist" checked="checked" />
545                                     [% ELSE %]
546                                         <input type="checkbox" id="manualhistory" name="manualhist" />
547                                     [% END %]
548                                 </li>
549                                 <li>
550                                     <label for="callnumber">Call number</label>
551                                     <input type="text" name="callnumber" id="callnumber" value="[% callnumber %]" size="20" />
552                                 </li>
553                                 <li>
554                                     <label for="branchcode">Library:</label>
555                                     <select name="branchcode" id="branchcode" style="width: 20em;">
556                                         [% UNLESS ( Independentbranches ) %]
557                                             <option value="">None</option>
558                                         [% END %]
559                                         [% FOREACH branchloo IN branchloop %]
560                                             [% IF ( branchloo.selected ) %]
561                                                 <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
562                                             [% ELSE %]
563                                                 <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
564                                             [% END %]
565                                         [% END %]
566                                     </select> (select a library)
567                                 </li>
568                                 <li>
569                                     <label for="notes">Public note:</label>
570                                     <textarea name="notes" id="notes" cols="30" rows="2">[% notes %]</textarea>
571                                 </li>
572                                 <li>
573                                     <label for="internalnotes">Nonpublic note:</label>
574                                     <textarea name="internalnotes" id="internalnotes" cols="30" rows="2">[% internalnotes %]</textarea>
575                                 </li>
576                                 <li>
577                                     [% IF ( letterloop ) %]
578                                         <label for="letter">Patron notification: </label>
579                                         <select name="letter" id="letter">
580                                             <option value="">None</option>
581                                             [% FOREACH letterloo IN letterloop %]
582                                                 [% IF ( letterloo.selected ) %]
583                                                     <option value="[% letterloo.value %]" selected="selected">[% letterloo.lettername %]</option>
584                                                 [% ELSE %]
585                                                     <option value="[% letterloo.value %]">[% letterloo.lettername %]</option>
586                                                 [% END %]
587                                             [% END %]
588                                         </select>
589                                         <div class="hint">Selecting a notice will allow patrons to subscribe to notifications when a new issue is received.</div>
590                                     [% ELSE %]
591                                         <span class="label">Patron notification: </span>
592                                         <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>
593                                     [% END %]
594                                 </li>
595                                 <li>
596                                     <label for="location">Location:</label>
597                                     <select name="location" id="location">
598                                         <option value="">None</option>
599                                         [% FOREACH locations_loo IN locations_loop %]
600                                             [% IF ( locations_loo.selected ) %]
601                                                 <option value="[% locations_loo.authorised_value %]" selected="selected">[% locations_loo.lib %]</option>
602                                             [% ELSE %]
603                                                 <option value="[% locations_loo.authorised_value %]">[% locations_loo.lib %]</option>
604                                             [% END %]
605                                         [% END %]
606                                     </select>
607                                 </li>
608                                 <li>
609                                     <label for="graceperiod">Grace period:</label>
610                                     <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod %]" size="5"/> day(s)
611                                 </li>
612                                 <li>
613                                      <label class="widelabel" for="staffdisplaycount">Number of issues to display to staff: </label>
614                                      <input type="text" name="staffdisplaycount" id="staffdisplaycount" value="[% staffdisplaycount %]" size="4"/>
615                                  </li>
616                                  <li>
617                                     <label class="widelabel" for="opacdisplaycount">Number of issues to display to the public: </label>
618                                     <input type="text" name="opacdisplaycount" id="opacdisplaycount" value="[% opacdisplaycount %]" size="4"/>
619                                 </li>
620                             </ol>
621                         </fieldset>
622                         <fieldset class="action">
623                             <input type="button" value="Next >>" onclick="if ( Check_page1() ) show_page_2();" style="float:right;" />
624                         </fieldset>
625                     </div>
626                 </div>
627
628                 <div id="page_2">
629                     <div class="yui-u first">
630                         <div id="subscription_form_planning">
631                             <fieldset class="rows">
632                                 <legend>Serials planning</legend>
633                                 <ol>
634                                     <li>
635                                         <label for="firstacquidate" class="required">First issue publication date:</label>
636                                         [% UNLESS (more_than_one_serial) %]
637                                           <input type="text" size="10" id="acqui_date" name="firstacquidate" value="[% firstacquidate | $KohaDates %]" class="datepicker required" required="required" />
638                                         [% ELSE %]
639                                           [% firstacquidate | $KohaDates %]
640                                           <input type="hidden" size="10" id="acqui_date" name="firstacquidate" value="[% firstacquidate | $KohaDates %]"/>
641                                         [% END %]
642                                     </li>
643                                     [% IF (more_than_one_serial) %]
644                                       <li>
645                                         <label for="nextacquidate">Next issue publication date:</label>
646                                         <input type="text" size="10" id="nextacquidate" name="nextacquidate" value="[% nextacquidate | $KohaDates %]" class="datepicker" />
647                                       </li>
648                                     [% END %]
649                                     <li>
650                                         <label for="frequency" class="required">Frequency:</label>
651                                         <select name="frequency" size="1" id="frequency" class="required" required="required">
652                                             <option value="">-- please choose --</option>
653                                             [% FOREACH frequency IN frequencies %]
654                                                 [% IF (frequency.selected) %]
655                                                     <option value="[% frequency.id %]" selected="selected">
656                                                 [% ELSE %]
657                                                     <option value="[% frequency.id %]">
658                                                 [% END %]
659                                                     [% frequency.label %]
660                                                 </option>
661                                             [% END %]
662                                         </select>
663                                     </li>
664                                     <li>
665                                         <label for="subtype">Subscription length:</label>
666                                         <select name="subtype" id="subtype">
667                                             [% FOREACH st IN subtypes %]
668                                                 [% SWITCH st %]
669                                                     [% CASE 'numberlength' %]
670                                                         [% IF st == subtype %]
671                                                             <option value="issues" selected="selected">
672                                                         [% ELSE %]
673                                                             <option value="issues">
674                                                         [% END %]
675                                                         issues
676                                                     [% CASE 'weeklength' %]
677                                                         [% IF st == subtype %]
678                                                             <option value="weeks" selected="selected">
679                                                         [% ELSE %]
680                                                             <option value="weeks">
681                                                         [% END %]
682                                                         weeks
683                                                     [% CASE 'monthlength' %]
684                                                         [% IF st == subtype %]
685                                                             <option value="months" selected="selected">
686                                                         [% ELSE %]
687                                                             <option value="months">
688                                                         [% END %]
689                                                         months
690                                                     [% CASE %][% st %]
691                                                 [% END %]
692                                                 </option>
693                                             [% END %]
694                                         </select>
695                                         <input type="text" name="sublength" id="sublength" value="[% sublength %]" size="3" /> (enter amount in numerals)
696                                         <input type="hidden" name="issuelengthcount">
697                                     </li>
698                                     <li>
699                                         <label for="startdate" class="required"> Subscription start date:</label>
700                                         <input type="text" size="10" id="from" name="startdate" value="[% startdate | $KohaDates %]" class="datepickerfrom required" required="required" />
701                                     </li>
702                                     <li>
703                                         <label for="enddate">Subscription end date:</label>
704                                         <input type="text" size="10" id="to" name="enddate" value="[% enddate | $KohaDates %]" class="datepickerto" />
705                                     </li>
706                                     <li>
707                                         <label for="numberpattern" class="required">Numbering pattern:</label>
708                                         <select name="numbering_pattern" size="1" id="numberpattern" class="required" required="required">
709                                             <option value="">-- please choose --</option>
710                                             [% FOREACH numberpattern IN numberpatterns %]
711                                                 [% IF (numberpattern.selected) %]
712                                                     <option value="[% numberpattern.id %]" selected="selected">
713                                                 [% ELSE %]
714                                                     <option value="[% numberpattern.id %]">
715                                                 [% END %]
716                                                     [% numberpattern.label %]
717                                                 </option>
718                                             [% END %]
719                                         </select>
720                                     </li>
721                                     <li>
722                                         <label for="locale">Locale</label>
723                                         <select id="locale" name="locale">
724                                             <option value=""></option>
725                                             [% FOREACH l IN locales %]
726                                                 [% IF l.language == locale %]
727                                                     <option value="[% l.language %]" selected="selected">[% l.description %]</option>
728                                                 [% ELSE %]
729                                                     <option value="[% l.language %]">[% l.description %]</option>
730                                                 [% END %]
731                                             [% END %]
732                                         </select>
733                                         <span class="hint">If empty, English is used</span>
734                                     </li>
735                                     <li id="more_options">
736                                         <table id="moreoptionst">
737                                             <thead>
738                                                 <tr>
739                                                     <th>&nbsp;</th>
740                                                     <th id="headerX">&nbsp;</th>
741                                                     <th id="headerY">&nbsp;</th>
742                                                     <th id="headerZ">&nbsp;</th>
743                                                 </tr>
744                                             </thead>
745                                             <tbody>
746                                                 <tr>
747                                                     <td>
748                                                       [% IF (more_than_one_serial) %]
749                                                         Last value
750                                                       [% ELSE %]
751                                                         Begins with
752                                                       [% END %]
753                                                     </td>
754                                                     <td id="beginsX"><input type="text" id="lastvaluetemp1" name="lastvaluetemp1" value="[% lastvalue1 %]" /></td>
755                                                     <td id="beginsY"><input type="text" id="lastvaluetemp2" name="lastvaluetemp2" value="[% lastvalue2 %]" /></td>
756                                                     <td id="beginsZ"><input type="text" id="lastvaluetemp3" name="lastvaluetemp3" value="[% lastvalue3 %]" /></td>
757                                                 </tr>
758                                                 <tr>
759                                                     <td>Inner counter</td>
760                                                     <td id="innerX"><input type="text" id="innerlooptemp1" name="innerlooptemp1" value="[% innerloop1 %]" /></td>
761                                                     <td id="innerY"><input type="text" id="innerlooptemp2" name="innerlooptemp2" value="[% innerloop2 %]" /></td>
762                                                     <td id="innerZ"><input type="text" id="innerlooptemp3" name="innerlooptemp3" value="[% innerloop3 %]" /></td>
763                                                 </tr>
764                                             </tbody>
765                                         </table>
766                                     </li>
767                                     <li><a style="cursor:pointer" onclick="toggleAdvancedPattern();">Show/Hide advanced pattern</a></li>
768                                     <div id="advancedpredictionpattern" style="display:none">
769                                       <li>
770                                         <label for="patternname" class="required">Pattern name:</label>
771                                         <input id="patternname" name="patternname" type="text" readonly="readonly" class="required" required="required" />
772                                       </li>
773                                       <li>
774                                         <label for="numberingmethod">Numbering formula:</label>
775                                         <input readonly="readonly" type="text" name="numberingmethod" id="numberingmethod" size="50" value="[% numberingmethod %]" />
776                                       </li>
777                                         <table id="advancedpredictionpatternt">
778                                             <thead>
779                                                 <tr>
780                                                     <th colspan="4">Advanced prediction pattern</td>
781                                                 </tr>
782                                                 <tr>
783                                                     <th>&nbsp;</th>
784                                                     <th>X</th>
785                                                     <th>Y</th>
786                                                     <th>Z</th>
787                                                 </tr>
788                                             </thead>
789                                             <tbody>
790                                                 <tr>
791                                                     <td>Label</td>
792                                                     <td><input type="text" readonly="readonly" id="label1" name="label1" /></td>
793                                                     <td><input type="text" readonly="readonly" id="label2" name="label2" /></td>
794                                                     <td><input type="text" readonly="readonly" id="label3" name="label3" /></td>
795                                                 </tr>
796                                                 <tr>
797                                                     <td>Begins with</td>
798                                                     <td><input type="text" readonly="readonly" id="lastvalue1" name="lastvalue1" /></td>
799                                                     <td><input type="text" readonly="readonly" id="lastvalue2" name="lastvalue2" /></td>
800                                                     <td><input type="text" readonly="readonly" id="lastvalue3" name="lastvalue3" /></td>
801                                                 </tr>
802                                                 <tr>
803                                                     <td>Add</td>
804                                                     <td><input type="text" readonly="readonly" id="add1" name="add1" /></td>
805                                                     <td><input type="text" readonly="readonly" id="add2" name="add2" /></td>
806                                                     <td><input type="text" readonly="readonly" id="add3" name="add3" /></td>
807                                                 </tr>
808                                                 <tr>
809                                                     <td>Every</td>
810                                                     <td><input type="text" readonly="readonly" id="every1" name="every1" /></td>
811                                                     <td><input type="text" readonly="readonly" id="every2" name="every2" /></td>
812                                                     <td><input type="text" readonly="readonly" id="every3" name="every3" /></td>
813                                                 </tr>
814                                                 <tr>
815                                                     <td>Set back to</td>
816                                                     <td><input type="text" readonly="readonly" id="setto1" name="setto1" /></td>
817                                                     <td><input type="text" readonly="readonly" id="setto2" name="setto2" /></td>
818                                                     <td><input type="text" readonly="readonly" id="setto3" name="setto3" /></td>
819                                                 </tr>
820                                                 <tr>
821                                                     <td>When more than</td>
822                                                     <td><input type="text" readonly="readonly" id="whenmorethan1" name="whenmorethan1" /></td>
823                                                     <td><input type="text" readonly="readonly" id="whenmorethan2" name="whenmorethan2" /></td>
824                                                     <td><input type="text" readonly="readonly" id="whenmorethan3" name="whenmorethan3" /></td>
825                                                 </tr>
826                                                 <tr>
827                                                     <td>Inner counter</td>
828                                                     <td><input type="text" readonly="readonly" id="innerloop1" name="innerloop1" /></td>
829                                                     <td><input type="text" readonly="readonly" id="innerloop2" name="innerloop2" /></td>
830                                                     <td><input type="text" readonly="readonly" id="innerloop3" name="innerloop3" /></td>
831                                                 </tr>
832                                                 <tr>
833                                                     [% BLOCK numbering_select %]
834                                                         <select disabled="disabled" id="[% name %]" name="[% name %]" />
835                                                             <option value=""></option>
836                                                             <option value="dayname">Name of day</option>
837                                                             <option value="monthname">Name of month</option>
838                                                             <option value="season">Name of season</option>
839                                                         </select>
840                                                     [% END %]
841                                                     <td>Formatting</td>
842                                                     <td>[% PROCESS numbering_select name="numbering1" %]</td>
843                                                     <td>[% PROCESS numbering_select name="numbering2" %]</td>
844                                                     <td>[% PROCESS numbering_select name="numbering3" %]</td>
845                                                 </tr>
846                                             </tbody>
847                                         </table>
848                                         <input id="modifyadvancedpatternbutton" type="button" value="Modify pattern" onclick="modifyAdvancedPattern();" />
849                                         <input id="restoreadvancedpatternbutton" type="button" value="Cancel modifications" onclick="restoreAdvancedPattern();" style="display:none" />
850                                         <input id="saveadvancedpatternbutton" type="button" value="Save as new pattern" onclick="saveAdvancedPattern();" style="display:none" />
851                                     </div>
852                                 </ol>
853                             </fieldset>
854
855                             [% IF additional_fields_for_subscription %]
856                               <div id="subscription_additional_fields">
857                                 <fieldset class="rows">
858                                   <legend>Additional fields</legend>
859                                   <ol>
860                                     [% FOR field IN additional_fields_for_subscription %]
861                                       <li>
862                                         <label for="additional_fields_[% field.name %]"> [% field.name %]: </label>
863                                         [% IF field.authorised_value_choices %]
864                                           <select name="additional_fields_[% field.name %]">
865                                             [% FOREACH av IN field.authorised_value_choices %]
866                                               [% IF av.authorised_value == additional_fields.${field.name} %]
867                                                 <option value="[% av.authorised_value %]" selected="selected">[% av.lib %]</option>
868                                               [% ELSE %]
869                                                 <option value="[% av.authorised_value %]">[% av.lib %]</option>
870                                               [% END %]
871                                             [% END %]
872                                           </select> (Authorised values for [% field.authorised_value_category %])
873                                         [% ELSE %]
874                                           [% IF field.marcfield %]
875                                             <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" readonly="readonly" />
876                                             This value will be filled with the [% field.marcfield %] subfield of the selected biblio.
877                                           [% ELSE %]
878                                             <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" />
879                                           [% END %]
880                                         [% END %]
881                                       </li>
882                                     [% END %]
883                                   </ol>
884                                 </fieldset>
885                               </div>
886                             [% END %]
887
888                             <fieldset class="action">
889                                 <input type="button" value="<< Previous" onclick="show_page_1();" style="float:left;"/>
890                                 <input id="testpatternbutton" type="button" value="Test prediction pattern" onclick="testPredictionPattern();" />
891                                 <input type="submit" value="Save subscription" style="float:right;" accesskey="w" />
892                             </fieldset>
893                         </div>
894                     </div>
895                     <div class="yui-u">
896                         <li id="displayexample"></li>
897                     </div>
898                 </div>
899             </form>
900         </div>
901     </div>
902 </div>
903
904 [% INCLUDE 'intranet-bottom.inc' %]