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