Bug 19950: Update popup window templates to use Bootstrap grid: Serials
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / subscription-numberpatterns.tt
1 [% SET footerjs = 1 %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Serials &rsaquo; Numbering patterns</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
6 </head>
7
8 <body id="ser_subscription_numberpatterns" class="ser">
9 [% INCLUDE 'header.inc' %]
10 [% INCLUDE 'serials-search.inc' %]
11
12 <div id="breadcrumbs">
13     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
14     <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo;
15     <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">Numbering patterns</a>
16     [% IF ( new ) %]
17         &rsaquo; New numbering pattern
18     [% ELSIF ( modify ) %]
19         &rsaquo; Modifying numbering pattern '[% label %]'
20     [% END %]
21 </div>
22
23 <div id="doc3" class="yui-t2">
24
25 <div id="bd">
26   <div id="yui-main">
27     <div class="yui-b">
28       [% IF (new or modify) %]
29         <div class="yui-g">
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 %]</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         </div>
46         <div class="yui-g">
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 %]" />
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 %]" />
59                 </li>
60                 <li>
61                   <label for="description">Description:</label>
62                   <input type="text" id="description" name="description" value="[% description %]" />
63                 </li>
64                 <li>
65                   <label for="numberingmethod">Numbering formula:</label>
66                   <input type="text" id="numberingmethod" name="numberingmethod" value="[% numberingmethod %]" />
67                 </li>
68                 <li>
69                   <label for="displayorder">Display order:</label>
70                   <input type="text" id="displayorder" name="displayorder" value="[% displayorder %]" />
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 %]" /></td>
86                     <td><input type="text" id="label2" name="label2" value="[% label2 %]" /></td>
87                     <td><input type="text" id="label3" name="label3" value="[% label3 %]" /></td>
88                   </tr>
89                   <tr>
90                     <td>Add</td>
91                     <td><input type="text" id="add1" name="add1" value="[% add1 %]" /></td>
92                     <td><input type="text" id="add2" name="add2" value="[% add2 %]" /></td>
93                     <td><input type="text" id="add3" name="add3" value="[% add3 %]" /></td>
94                   </tr>
95                   <tr>
96                     <td>Every</td>
97                     <td><input type="text" id="every1" name="every1" value="[% every1 %]" /></td>
98                     <td><input type="text" id="every2" name="every2" value="[% every2 %]" /></td>
99                     <td><input type="text" id="every3" name="every3" value="[% every3 %]" /></td>
100                   </tr>
101                   <tr>
102                     <td>Set back to</td>
103                     <td><input type="text" id="setto1" name="setto1" value="[% setto1 %]" /></td>
104                     <td><input type="text" id="setto2" name="setto2" value="[% setto2 %]" /></td>
105                     <td><input type="text" id="setto3" name="setto3" value="[% setto3 %]" /></td>
106                   </tr>
107                   <tr>
108                     <td>When more than</td>
109                     <td><input type="text" id="whenmorethan1" name="whenmorethan1" value="[% whenmorethan1 %]" /></td>
110                     <td><input type="text" id="whenmorethan2" name="whenmorethan2" value="[% whenmorethan2 %]" /></td>
111                     <td><input type="text" id="whenmorethan3" name="whenmorethan3" value="[% whenmorethan3 %]" /></td>
112                   </tr>
113                   <tr>
114                     [% BLOCK numbering_select %]
115                       <select id="[% name %]" name="[% name %]">
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         </div>
164         <div class="yui-g">
165           <form>
166             <fieldset class="rows">
167               <legend>Test prediction pattern</legend>
168               <ol>
169                 <li>
170                   <label for="frequency">Frequency: </label>
171                   <select id="frequency">
172                     [% FOREACH frequency IN frequencies_loop %]
173                       <option value="[% frequency.id %]">[% frequency.description %]</option>
174                     [% END %]
175                   </select>
176                 </li>
177                 <li>
178                   <label for="firstacquidate">First issue publication date: </label>
179                   <input type="text" id="firstacquidate" class="datepicker" size="10" />
180                 </li>
181                 <li>
182                   <label for="sublength">Subscription length:</label>
183                   <select id="subtype">
184                     [% FOREACH subtype IN subtypes_loop %]
185                       <option value="[% subtype.value %]">[% subtype.value %]</option>
186                     [% END %]
187                   </select>
188                   <input type="text" id="sublength" size="3" />
189                 </li>
190                 <li>
191                   <label for="locale">Locale: </label>
192                   <select id="locale" name="locale">
193                       <option value=""></option>
194                       [% FOREACH locale IN locales %]
195                         <option value="[% locale.language %]">[% locale.description %]</option>
196                       [% END %]
197                     </select>
198                   <span class="hint">If empty, English is used</span>
199                 </li>
200               </ol>
201               <table>
202                 <thead>
203                   <tr>
204                     <th>&nbsp;</th>
205                     <th>X</th>
206                     <th>Y</th>
207                     <th>Z</th>
208                   </tr>
209                 </thead>
210                 <tbody>
211                   <tr>
212                     <td>Begins with</td>
213                     <td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 %]" /></td>
214                     <td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 %]" /></td>
215                     <td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 %]" /></td>
216                   </tr>
217                   <tr>
218                     <td>Inner counter</td>
219                     <td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 %]" /></td>
220                     <td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 %]" /></td>
221                     <td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 %]" /></td>
222                   </tr>
223                 </tbody>
224               </table>
225               <fieldset class="action">
226                   <button type="button" id="test_pattern" class="btn btn-default btn-sm">Test pattern</button>
227               </fieldset>
228               <div id="predictionpattern"></div>
229             </fieldset>
230           </form>
231         </div>
232       [% ELSE %]
233         <h1>Numbering patterns</h1>
234         [% IF still_used %]
235             <div class="dialog alert">
236                 <p>
237                     This pattern is still used by [% subscriptions.size %]
238                     subscription(s). Do you still want to delete it?
239                 </p>
240                 <p><a href="#" id="show_blocking_subs">Show subscriptions</a></p>
241                 <ul id="blocking_subs" style="display:none">
242                     [% FOREACH sub IN subscriptions %]
243                         <li style="list-style-type:none">
244                             <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
245                         </li>
246                     [% END %]
247                 </ul>
248
249                 <form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="get">
250                     <input type="hidden" name="op" value="del" />
251                     <input type="hidden" name="confirm" value="1" />
252                     <input type="hidden" name="id" value="[% id %]" />
253                     <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
254                 </form>
255                 <form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="get">
256                     <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
257                 </form>
258             </div>
259         [% END %]
260
261         <div id="toolbar" class="btn-toolbar">
262             <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>
263         </div>
264
265         [% IF (numberpatterns_loop.size) %]
266           <table id="numberpatternst">
267             <thead>
268               <tr>
269                 <th>Name</th>
270                 <th>Description</th>
271                 <th>Numbering formula</th>
272                 <th>Display order</th>
273                 <th>Actions</th>
274               </tr>
275             </thead>
276             <tbody>
277               [% FOREACH numberpattern IN numberpatterns_loop %]
278                 <tr>
279                   <td>[% numberpattern.label %]</td>
280                   <td>[% numberpattern.description %]</td>
281                   <td>[% numberpattern.numberingmethod %]</td>
282                   <td>[% numberpattern.displayorder %]</td>
283                   <td class="actions">
284                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=modify&id=[% numberpattern.id %]"><i class="fa fa-pencil"></i> Edit</a>
285                     <a class="delete_pattern btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=del&id=[% numberpattern.id %]"><i class="fa fa-trash"></i> Delete</a>
286                   </td>
287                 </tr>
288               [% END %]
289             </tbody>
290           </table>
291         [% ELSE %]
292           <p>There are no existing numbering patterns.</p>
293         [% END %]
294       [% END %]
295     </div>
296   </div>
297   <div class="yui-b">
298     [% INCLUDE 'serials-menu.inc' %]
299   </div>
300 </div>
301
302 [% MACRO jsinclude BLOCK %]
303     [% IF (daily_options) %]
304         <script type="text/javascript" src="[% interface %]/[% theme %]/js/showpredictionpattern_[% KOHA_VERSION %].js"></script>
305     [% END %]
306     [% INCLUDE 'calendar.inc' %]
307     [% INCLUDE 'datatables.inc' %]
308     <script type="text/javascript">
309         function confirmDelete() {
310             return confirm(_("Are you sure you want to delete this numbering pattern?"));
311         }
312
313         [% IF (new or modify) %]
314             function testPattern() {
315                 var frequencyid = $("#frequency").val();
316                 var firstacquidate = $("#firstacquidate").val();
317                 var error = 0;
318                 var error_msg = "";
319                 if(frequencyid == undefined || frequencyid == "") {
320                     error_msg += _("- Frequency is not defined") + "\n";
321                     error ++;
322                 }
323                 if(firstacquidate == undefined || firstacquidate == "") {
324                     error_msg += _("- First publication date is not defined") + "\n";
325                     error ++;
326                 }
327
328                 if(error){
329                     alert(_("Cannot test prediction pattern for the following reason(s):") + "\n\n"
330                         + error_msg);
331                     return false;
332                 }
333
334                 var ajaxData = {
335                     'custompattern': true,
336                 };
337                 var ajaxParams = [
338                     'firstacquidate', 'subtype', 'sublength', 'frequency', 'numberingmethod',
339                     'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
340                     'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
341                     'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
342                     'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
343                 ];
344                 for(i in ajaxParams) {
345                     var param = ajaxParams[i];
346                     var value = $("#"+param).val();
347                     if(value.length > 0)
348                         ajaxData[param] = value;
349                 }
350
351                 $.ajax({
352                     url: "/cgi-bin/koha/serials/showpredictionpattern.pl",
353                     data: ajaxData,
354                     async: false,
355                     dataType: "text",
356                     success: function(data) {
357                         $("#predictionpattern").html(data);
358                     }
359                 });
360             }
361         [% END %]
362
363         function show_blocking_subs() {
364             $("#blocking_subs").show();
365         }
366         $(document).ready(function(){
367
368             $("#numberpatternst").dataTable($.extend(true, {}, dataTablesDefaults, {
369                 "aoColumnDefs": [
370                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
371                 ],
372                 "sPaginationType": "four_button"
373             }));
374
375             $(".delete_pattern").on("click",function(){
376                 return confirmDelete();
377             });
378             $("#show_blocking_subs").on("click",function(e){
379                 e.preventDefault();
380                 $("#blocking_subs").show();
381             });
382             $("#test_pattern").on("click",function(){
383                  testPattern();
384             });
385         });
386     </script>
387 [% END %]
388
389 [% INCLUDE 'intranet-bottom.inc' %]