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