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