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