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