Bug 34571: Remove use of "onclick" for ExpandField in cataloguing editors
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / subscription-frequencies.tt
1 [% USE raw %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Frequencies &rsaquo; Serials &rsaquo; Koha</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 </head>
7
8 <body id="ser_subscription_frequencies" class="ser">
9 [% WRAPPER 'header.inc' %]
10     [% INCLUDE 'serials-search.inc' %]
11 [% END %]
12
13 [% BLOCK translate_frequnit %]
14 [%  SWITCH frequnit %]
15 [%   CASE 'day'   %]<span> day</span>
16 [%   CASE 'week'  %]<span> week</span>
17 [%   CASE 'month' %]<span> month</span>
18 [%   CASE 'year'  %]<span> year</span>
19 [%  END %]
20 [% END %]
21
22 [% WRAPPER 'sub-header.inc' %]
23     [% WRAPPER breadcrumbs %]
24         [% WRAPPER breadcrumb_item %]
25             <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a>
26         [% END %]
27         [% WRAPPER breadcrumb_item bc_active= 1 %]
28             <span>Frequencies</span>
29         [% END %]
30     [% END #/ WRAPPER breadcrumbs %]
31 [% END #/ WRAPPER sub-header.inc %]
32
33 <div class="main container-fluid">
34     <div class="row">
35         <div class="col-sm-10 col-sm-push-2">
36             <main>
37
38       [% IF (new or modify) %]
39         [% IF (new) %]
40           <h1>New frequency</h1>
41         [% ELSE %]
42           <h1>Edit frequency: [% description | html %]</h1>
43         [% END %]
44         <form action="/cgi-bin/koha/serials/subscription-frequencies.pl" id="add_frequency_form" method="post">
45           [% IF (modify) %]
46             <input type="hidden" name="id" value="[% id | html %]" />
47             <input type="hidden" name="op" value="savemod" />
48           [% ELSE %]
49             <input type="hidden" name="op" value="savenew" />
50           [% END %]
51           <fieldset class="rows">
52             <ol>
53               <li>
54                 <label class="required" for="description">Description: </label>
55                 <input type="text" id="description" name="description" value="[% description | html %]" class="required" required="required" /> <span class="required">Required</span>
56               </li>
57               <li>
58                 <label for="unit">Unit: </label>
59                 <select id="unit" name="unit">
60                   <option value="">None</option>
61                   [% FOREACH unit IN units_loop %]
62                     [% IF (unit.selected) %]
63                       <option selected="selected" value="[% unit.val | html %]">
64                     [% ELSE %]
65                       <option value="[% unit.val | html %]">
66                     [% END %]
67                       [% PROCESS translate_frequnit frequnit=unit.val %]
68                     </option>
69                   [% END %]
70                 </select>
71               </li>
72               <li><span class="hint">Note: one of the two following fields must be equal to 1</span></li>
73               <li>
74                 <label for="issuesperunit">Issues per unit: </label>
75                 [% IF (new) %]
76                   <input type="text" id="issuesperunit" name="issuesperunit" value="1" size="3" />
77                 [% ELSE %]
78                   <input type="text" id="issuesperunit" name="issuesperunit" value="[% issuesperunit | html %]" size="3" />
79                 [% END %]
80               </li>
81               <li>
82                 <label for="unitsperissue">Units per issue: </label>
83                 [% IF (new) %]
84                   <input type="text" id="unitsperissue" name="unitsperissue" value="1" size="3" />
85                 [% ELSE %]
86                   <input type="text" id="unitsperissue" name="unitsperissue" value="[% unitsperissue | html %]" size="3" />
87                 [% END %]
88               </li>
89               <li>
90                 <label for="displayorder">Display order: </label>
91                 <input type="text" id="displayorder" name="displayorder" value="[% displayorder | html %]" size="3" />
92               </li>
93             </ol>
94           </fieldset>
95           <fieldset class="action">
96             <input type="submit" class="btn btn-primary" value="Save" />
97             <a href="/cgi-bin/koha/serials/subscription-frequencies.pl" class="cancel">Cancel</a>
98           </fieldset>
99         </form>
100       [% ELSE %]
101
102         <div id="toolbar" class="btn-toolbar">
103             <a class="btn btn-default" id="newfrequency" href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=new"><i class="fa fa-plus"></i> New frequency</a>
104         </div>
105
106         <h1>Frequencies</h1>
107         [% IF still_used %]
108             <div class="dialog alert">
109                 <p>
110                     This frequency is still used by [% subscriptions.size | html %]
111                     subscription(s). Do you still want to delete it?
112                 </p>
113                 <p><a href="#" id="show_blocking_subs">Show subscriptions</a></p>
114                 <ul id="blocking_subs" style="display:none">
115                     [% FOREACH sub IN subscriptions %]
116                         <li style="list-style-type:none">
117                             <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid | uri %]">[% sub.title | html %]</a>
118                         </li>
119                     [% END %]
120                 </ul>
121
122                 <form action="/cgi-bin/koha/serials/subscription-frequencies.pl" method="get">
123                     <input type="hidden" name="op" value="del" />
124                     <input type="hidden" name="confirm" value="1" />
125                     <input type="hidden" name="frequencyid" value="[% frequencyid | html %]" />
126                     <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
127                 </form>
128                 <form action="/cgi-bin/koha/serials/subscription-frequencies.pl" method="get">
129                     <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button>
130                 </form>
131             </div>
132         [% END %]
133
134         [% IF (frequencies_loop.size) %]
135             <div class="page-section">
136                 <table id="frequenciest">
137                     <thead>
138                         <tr>
139                             <th>Description</th>
140                             <th>Unit</th>
141                             <th>Issues per unit</th>
142                             <th>Units per issue</th>
143                             <th>Display order</th>
144                             <th class="noExport">Actions</th>
145                         </tr>
146                     </thead>
147                     <tbody>
148                         [% FOREACH frequency IN frequencies_loop %]
149                             <tr>
150                                 <td>[% frequency.description | html %]</td>
151                                 <td>[% PROCESS translate_frequnit frequnit=frequency.unit %]</td>
152                                 <td>[% frequency.issuesperunit | html %]</td>
153                                 <td>[% frequency.unitsperissue | html %]</td>
154                                 <td>[% frequency.displayorder | html %]</td>
155                                 <td class="actions">
156                                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=modify&frequencyid=[% frequency.id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
157                                     <a class="delete_frequency btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=del&frequencyid=[% frequency.id | html %]"><i class="fa fa-trash-can"></i> Delete</a>
158                                 </td>
159                             </tr>
160                         [% END %]
161                     </tbody>
162                 </table>
163             </div> <!-- /.page-section -->
164         [% ELSE %]
165             <p>There is no defined frequency.</p>
166         [% END %]
167       [% END %]
168
169             </main>
170         </div> <!-- /.col-sm-10.col-sm-push-2 -->
171
172         <div class="col-sm-2 col-sm-pull-10">
173             <aside>
174                 [% INCLUDE 'serials-menu.inc' %]
175             </aside>
176         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
177      </div> <!-- /.row -->
178
179 [% MACRO jsinclude BLOCK %]
180     <script>
181         function confirmDelete() {
182             return confirm(_("Are you sure you want to delete this subscription frequency?"));
183         }
184
185         function check_form() {
186             var description = $("#description").val();
187             var unit = $("#unit").val();
188             var issuesperunit = $("#issuesperunit").val();
189             var unitsperissue = $("#unitsperissue").val();
190             var alert_msg = _("Some fields are not valid:") + "\n";
191             var errors = 0;
192
193             if(description.length == 0) {
194                 alert_msg += "\t - " + _("Description is required");
195                 errors ++;
196             }
197             if(unit.length > 0) {
198                 if(isNaN(issuesperunit) || issuesperunit == 0) {
199                     alert_msg += "\n\t - " + _("Issues per unit is required")
200                         + " " + _("(must be a number greater than 0)");
201                     errors ++;
202                 }
203                 if(isNaN(unitsperissue) || unitsperissue == 0) {
204                     alert_msg += "\n\t - " + _("Units per issue is required")
205                         + " " + _("(must be a number greater than 0)");
206                     errors ++;
207                 }
208                 if(issuesperunit > 1 && unitsperissue > 1) {
209                     alert_msg += "\n\t - " + _("One of 'issues per unit' and 'units per issue' must be equal to 1");
210                     errors ++;
211                 }
212             }
213
214             if(errors == 0) {
215                 return true;
216             }
217
218             alert(alert_msg);
219             return false;
220         }
221
222         $(document).ready(function() {
223             $("#issuesperunit").change(function() {
224                 var value = $(this).val();
225                 if(!isNaN(value) && value > 1) {
226                     $("#unitsperissue").val(1);
227                 }
228             });
229             $("#unitsperissue").change(function() {
230                 var value = $(this).val();
231                 if(!isNaN(value) && value > 1) {
232                     $("#issuesperunit").val(1);
233                 }
234             });
235             $(".delete_frequency").on("click",function(){
236                 return confirmDelete();
237             });
238             $("#add_frequency_form").on("submit",function(){
239                 return check_form();
240             });
241             $("#show_blocking_subs").on("click",function(e){
242                 e.preventDefault();
243                 $("#blocking_subs").show();
244             });
245         });
246     </script>
247 [% END %]
248
249 [% INCLUDE 'intranet-bottom.inc' %]