Bug 32628: Add 'page-section' to various serials pages
[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" class="btn btn-primary" 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             <div class="page-section">
140                 <table id="frequenciest">
141                     <thead>
142                         <tr>
143                             <th>Description</th>
144                             <th>Unit</th>
145                             <th>Issues per unit</th>
146                             <th>Units per issue</th>
147                             <th>Display order</th>
148                             <th class="noExport">Actions</th>
149                         </tr>
150                     </thead>
151                     <tbody>
152                         [% FOREACH frequency IN frequencies_loop %]
153                             <tr>
154                                 <td>[% frequency.description | html %]</td>
155                                 <td>[% PROCESS translate_frequnit frequnit=frequency.unit %]</td>
156                                 <td>[% frequency.issuesperunit | html %]</td>
157                                 <td>[% frequency.unitsperissue | html %]</td>
158                                 <td>[% frequency.displayorder | html %]</td>
159                                 <td class="actions">
160                                     <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>
161                                     <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>
162                                 </td>
163                             </tr>
164                         [% END %]
165                     </tbody>
166                 </table>
167             </div> <!-- /.page-section -->
168         [% ELSE %]
169             <p>There is no defined frequency.</p>
170         [% END %]
171       [% END %]
172
173             </main>
174         </div> <!-- /.col-sm-10.col-sm-push-2 -->
175
176         <div class="col-sm-2 col-sm-pull-10">
177             <aside>
178                 [% INCLUDE 'serials-menu.inc' %]
179             </aside>
180         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
181      </div> <!-- /.row -->
182
183 [% MACRO jsinclude BLOCK %]
184     <script>
185         function confirmDelete() {
186             return confirm(_("Are you sure you want to delete this subscription frequency?"));
187         }
188
189         function check_form() {
190             var description = $("#description").val();
191             var unit = $("#unit").val();
192             var issuesperunit = $("#issuesperunit").val();
193             var unitsperissue = $("#unitsperissue").val();
194             var alert_msg = _("Some fields are not valid:") + "\n";
195             var errors = 0;
196
197             if(description.length == 0) {
198                 alert_msg += "\t - " + _("Description is required");
199                 errors ++;
200             }
201             if(unit.length > 0) {
202                 if(isNaN(issuesperunit) || issuesperunit == 0) {
203                     alert_msg += "\n\t - " + _("Issues per unit is required")
204                         + " " + _("(must be a number greater than 0)");
205                     errors ++;
206                 }
207                 if(isNaN(unitsperissue) || unitsperissue == 0) {
208                     alert_msg += "\n\t - " + _("Units per issue is required")
209                         + " " + _("(must be a number greater than 0)");
210                     errors ++;
211                 }
212                 if(issuesperunit > 1 && unitsperissue > 1) {
213                     alert_msg += "\n\t - " + _("One of 'issues per unit' and 'units per issue' must be equal to 1");
214                     errors ++;
215                 }
216             }
217
218             if(errors == 0) {
219                 return true;
220             }
221
222             alert(alert_msg);
223             return false;
224         }
225
226         $(document).ready(function() {
227             $("#issuesperunit").change(function() {
228                 var value = $(this).val();
229                 if(!isNaN(value) && value > 1) {
230                     $("#unitsperissue").val(1);
231                 }
232             });
233             $("#unitsperissue").change(function() {
234                 var value = $(this).val();
235                 if(!isNaN(value) && value > 1) {
236                     $("#issuesperunit").val(1);
237                 }
238             });
239             $(".delete_frequency").on("click",function(){
240                 return confirmDelete();
241             });
242             $("#add_frequency_form").on("submit",function(){
243                 return check_form();
244             });
245             $("#show_blocking_subs").on("click",function(e){
246                 e.preventDefault();
247                 $("#blocking_subs").show();
248             });
249         });
250     </script>
251 [% END %]
252
253 [% INCLUDE 'intranet-bottom.inc' %]