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