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