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