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