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