Bug 11265: ensure current locale is selected when editing a subscription
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / subscription-numberpatterns.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Serials &rsaquo; Number patterns</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 [% INCLUDE 'calendar.inc' %]
5 <script type="text/javascript">
6 //<![CDATA[
7 [% IF (new or modify) %]
8   function testPattern() {
9       var frequencyid = $("#frequency").val();
10       var firstacquidate = $("#firstacquidate").val();
11       var error = 0;
12       var error_msg = "";
13       if(frequencyid == undefined || frequencyid == "") {
14           error_msg += _("- Frequency is not defined\n");
15           error ++;
16       }
17       if(firstacquidate == undefined || firstacquidate == "") {
18           error_msg += _("- First publication date is not defined\n");
19           error ++;
20       }
21
22       if(error){
23           alert(_("Cannot test prediction pattern for the following reason(s):\n\n")
24               + error_msg);
25           return false;
26       }
27
28       var ajaxData = {
29           'custompattern': true,
30       };
31       var ajaxParams = [
32           'firstacquidate', 'subtype', 'sublength', 'frequency', 'numberingmethod',
33           'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
34           'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
35           'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
36           'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
37       ];
38       for(i in ajaxParams) {
39           var param = ajaxParams[i];
40           var value = $("#"+param).val();
41           if(value.length > 0)
42               ajaxData[param] = value;
43       }
44
45       $.ajax({
46           url: "/cgi-bin/koha/serials/showpredictionpattern.pl",
47           data: ajaxData,
48           async: false,
49           dataType: "text",
50           success: function(data) {
51               $("#predictionpattern").html(data);
52           }
53       });
54   }
55 [% END %]
56
57 function show_blocking_subs() {
58     $("#blocking_subs").show();
59 }
60 //]]>
61 </script>
62 </head>
63
64 <body>
65 [% INCLUDE 'header.inc' %]
66 [% INCLUDE 'serials-search.inc' %]
67
68 <div id="breadcrumbs">
69     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
70     <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo;
71     <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">Numbering patterns</a>
72 </div>
73
74 <div id="doc3" class="yui-t2">
75
76 <div id="bd">
77   <div id="yui-main">
78     <div class="yui-b">
79       [% IF (new or modify) %]
80         <div class="yui-g">
81           [% IF (new) %]
82             <h1>New number pattern</h1>
83             [% IF (error_existing_numberpattern) %]
84               <div class="dialog">
85                 <p>A pattern with this name already exists.</p>
86               </div>
87             [% END %]
88           [% ELSE %]
89             <h1>Modify pattern: [% label %]</h1>
90             [% IF (error_existing_numberpattern) %]
91               <div class="dialog">
92                 <p>Another pattern with this name already exists.</p>
93               </div>
94             [% END %]
95           [% END %]
96         </div>
97         <div class="yui-g">
98           <form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="post">
99             [% IF (new) %]
100               <input type="hidden" name="op" value="savenew" />
101             [% ELSE %]
102               <input type="hidden" name="op" value="savemod" />
103               <input type="hidden" name="id" value="[% id %]" />
104             [% END %]
105             <fieldset class="rows">
106               <ol>
107                 <li>
108                   <label for="label">Name:</label>
109                   <input type="text" id="label" name="label" value="[% label %]" />
110                 </li>
111                 <li>
112                   <label for="description">Description:</label>
113                   <input type="text" id="description" name="description" value="[% description %]" />
114                 </li>
115                 <li>
116                   <label for="numberingmethod">Numbering formula:</label>
117                   <input type="text" id="numberingmethod" name="numberingmethod" value="[% numberingmethod %]" />
118                 </li>
119                 <li>
120                   <label for="displayorder">Display order:</label>
121                   <input type="text" id="displayorder" name="displayorder" value="[% displayorder %]" />
122                 </li>
123               </ol>
124               <table>
125                 <thead>
126                   <tr>
127                     <th>&nbsp;</th>
128                     <th>X</th>
129                     <th>Y</th>
130                     <th>Z</th>
131                   </tr>
132                 </thead>
133                 <tbody>
134                   <tr>
135                     <td>Label</td>
136                     <td><input type="text" id="label1" name="label1" value="[% label1 %]" /></td>
137                     <td><input type="text" id="label2" name="label2" value="[% label2 %]" /></td>
138                     <td><input type="text" id="label3" name="label3" value="[% label3 %]" /></td>
139                   </tr>
140                   <tr>
141                     <td>Add</td>
142                     <td><input type="text" id="add1" name="add1" value="[% add1 %]" /></td>
143                     <td><input type="text" id="add2" name="add2" value="[% add2 %]" /></td>
144                     <td><input type="text" id="add3" name="add3" value="[% add3 %]" /></td>
145                   </tr>
146                   <tr>
147                     <td>Every</td>
148                     <td><input type="text" id="every1" name="every1" value="[% every1 %]" /></td>
149                     <td><input type="text" id="every2" name="every2" value="[% every2 %]" /></td>
150                     <td><input type="text" id="every3" name="every3" value="[% every3 %]" /></td>
151                   </tr>
152                   <tr>
153                     <td>Set back to</td>
154                     <td><input type="text" id="setto1" name="setto1" value="[% setto1 %]" /></td>
155                     <td><input type="text" id="setto2" name="setto2" value="[% setto2 %]" /></td>
156                     <td><input type="text" id="setto3" name="setto3" value="[% setto3 %]" /></td>
157                   </tr>
158                   <tr>
159                     <td>When more than</td>
160                     <td><input type="text" id="whenmorethan1" name="whenmorethan1" value="[% whenmorethan1 %]" /></td>
161                     <td><input type="text" id="whenmorethan2" name="whenmorethan2" value="[% whenmorethan2 %]" /></td>
162                     <td><input type="text" id="whenmorethan3" name="whenmorethan3" value="[% whenmorethan3 %]" /></td>
163                   </tr>
164                   <tr>
165                     [% BLOCK numbering_select %]
166                       <select id="[% name %]" name="[% name %]" />
167                         <option value=""></option>
168                         [% IF (value == "dayname") %]
169                             <option selected="selected" value="dayname">Name of day</option>
170                         [% ELSE %]
171                             <option value="dayname">Name of day</option>
172                         [% END %]
173                         [% IF (value == "monthname") %]
174                             <option selected="selected" value="monthname">Name of month</option>
175                         [% ELSE %]
176                             <option value="monthname">Name of month</option>
177                         [% END %]
178                         [% IF (value == "season") %]
179                             <option selected="selected" value="season">Name of season</option>
180                         [% ELSE %]
181                             <option value="season">Name of season</option>
182                         [% END %]
183                       </select>
184                     [% END %]
185                     <td>Formatting</td>
186                     <td>[% PROCESS numbering_select name="numbering1" value=numbering1 %]</td>
187                     <td>[% PROCESS numbering_select name="numbering2" value=numbering2 %]</td>
188                     <td>[% PROCESS numbering_select name="numbering3" value=numbering3 %]</td>
189                   </tr>
190                 </tbody>
191               </table>
192             </fieldset>
193             <fieldset class="action">
194               <input type="submit" value="Save" />
195               <input type="reset" value="Reset" />
196               <input type="button" value="Cancel" onclick="window.location = '/cgi-bin/koha/serials/subscription-numberpatterns.pl';" />
197             </fieldset>
198           </form>
199         </div>
200         <div class="yui-g">
201           <form>
202             <fieldset class="rows">
203               <legend>Test prediction pattern</legend>
204               <ol>
205                 <li>
206                   <label for="frequency">Frequency:</label>
207                   <select id="frequency">
208                     [% FOREACH frequency IN frequencies_loop %]
209                       <option value="[% frequency.id %]">[% frequency.description %]</option>
210                     [% END %]
211                   </select>
212                 </li>
213                 <li>
214                   <label for="firstacquidate">First issue publication date</label>
215                   <input type="text" id="firstacquidate" class="datepicker" size="10" />
216                 </li>
217                 <li>
218                   <label for="sublength">Subscription length:</label>
219                   <select id="subtype">
220                     [% FOREACH subtype IN subtypes_loop %]
221                       <option value="[% subtype.value %]">[% subtype.value %]</option>
222                     [% END %]
223                   </select>
224                   <input type="text" id="sublength" size="3" />
225                 </li>
226                 <li>
227                   <label for="locale">Locale:</label>
228                   <select id="locale" name="locale">
229                       <option value=""></option>
230                       [% FOREACH locale IN locales %]
231                         <option value="[% locale %]">[% locale %]</option>
232                       [% END %]
233                     </select>
234                   <span class="hint">If empty, system locale is used</span>
235                 </li>
236               </ol>
237               <table>
238                 <thead>
239                   <tr>
240                     <th>&nbsp;</th>
241                     <th>X</th>
242                     <th>Y</th>
243                     <th>Z</th>
244                   </tr>
245                 </thead>
246                 <tbody>
247                   <tr>
248                     <td>Begins with</td>
249                     <td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 %]" /></td>
250                     <td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 %]" /></td>
251                     <td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 %]" /></td>
252                   </tr>
253                   <tr>
254                     <td>Inner counter</td>
255                     <td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 %]" /></td>
256                     <td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 %]" /></td>
257                     <td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 %]" /></td>
258                   </tr>
259                 </tbody>
260               </table>
261               <fieldset class="action">
262               <input type="button" value="Test pattern" onclick="testPattern();" />
263               </fieldset>
264               <div id="predictionpattern"></div>
265             </fieldset>
266           </form>
267         </div>
268       [% ELSE %]
269         <h1>Number patterns</h1>
270         [% IF still_used %]
271             <div class="dialog">
272                 <p>
273                     This pattern is still used by [% subscriptions.size %]
274                     subscription(s). Do you still want to delete it?
275                 </p>
276                 <p><a href="#" onclick="show_blocking_subs(); return false;">Show subscriptions</a></p>
277                 <ul id="blocking_subs" style="display:none">
278                     [% FOREACH sub IN subscriptions %]
279                         <li style="list-style-type:none">
280                             <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
281                         </li>
282                     [% END %]
283                 </ul>
284
285                 <form action="" method="get">
286                     <input type="hidden" name="op" value="del" />
287                     <input type="hidden" name="confirm" value="1" />
288                     <input type="hidden" name="id" value="[% id %]" />
289                     <input type="submit" class="approve" value="Yes, delete" />
290                 </form>
291                 <form action="" method="get">
292                     <input type="submit" class="deny" value="No, don't delete" />
293                 </form>
294             </div>
295         [% END %]
296         <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=new">New numbering pattern</a>
297         [% IF (numberpatterns_loop.size) %]
298           <table id="numberpatternst">
299             <thead>
300               <tr>
301                 <th>Name</th>
302                 <th>Description</th>
303                 <th>Numbering formula</th>
304                 <th>Display order</th>
305                 <th>&nbsp;</th>
306               </tr>
307             </thead>
308             <tbody>
309               [% FOREACH numberpattern IN numberpatterns_loop %]
310                 <tr>
311                   <td>[% numberpattern.label %]</td>
312                   <td>[% numberpattern.description %]</td>
313                   <td>[% numberpattern.numberingmethod %]</td>
314                   <td>[% numberpattern.displayorder %]</td>
315                   <td>
316                     <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=modify&id=[% numberpattern.id %]">Edit</a> |
317                     <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=del&id=[% numberpattern.id %]">Delete</a>
318                   </td>
319                 </tr>
320               [% END %]
321             </tbody>
322           </table>
323         [% ELSE %]
324           <p>There is no existing patterns.</p>
325         [% END %]
326       [% END %]
327     </div>
328   </div>
329   <div class="yui-b">
330     [% INCLUDE 'serials-menu.inc' %]
331   </div>
332 </div>
333 [% INCLUDE 'intranet-bottom.inc' %]