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