Bug 7688: Change subscription numbering pattern and frequencies
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / subscription-frequencies.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Serials &rsaquo; Frequencies</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <script type="text/javascript">
5 //<![CDATA[
6 function confirmDelete() {
7   return confirm(_("Are you sure you want to delete this subscription frequency?"));
8 }
9
10 function check_form() {
11     var description = $("#description").val();
12     var unit = $("#unit").val();
13     var issuesperunit = $("#issuesperunit").val();
14     var unitsperissue = $("#unitsperissue").val();
15     var alert_msg = _("Some fields are not valid:") + "\n";
16     var errors = 0;
17
18     if(description.length == 0) {
19         alert_msg += "\t - " + _("Description is required");
20         errors ++;
21     }
22     if(unit.length > 0) {
23         if(isNaN(issuesperunit) || issuesperunit == 0) {
24             alert_msg += "\n\t - " + _("Issues per unit is required")
25                 + " " + _("(must be a number greater than 0)");
26             errors ++;
27         }
28         if(isNaN(unitsperissue) || unitsperissue == 0) {
29             alert_msg += "\n\t - " + _("Units per issue is required")
30                 + " " + _("(must be a number greater than 0)");
31             errors ++;
32         }
33         if(issuesperunit > 1 && unitsperissue > 1) {
34             alert_msg += "\n\t - " + _("One of 'issues per unit' and 'units per issue' must be equal to 1");
35             errors ++;
36         }
37     }
38
39     if(errors == 0) {
40         return true;
41     }
42
43     alert(alert_msg);
44     return false;
45 }
46
47 function show_blocking_subs() {
48     $("#blocking_subs").show();
49 }
50
51 $(document).ready(function() {
52     $("#issuesperunit").change(function() {
53         var value = $(this).val();
54         if(!isNaN(value) && value > 1) {
55             $("#unitsperissue").val(1);
56         }
57     });
58     $("#unitsperissue").change(function() {
59         var value = $(this).val();
60         if(!isNaN(value) && value > 1) {
61             $("#issuesperunit").val(1);
62         }
63     });
64 });
65 //]]>
66 </script>
67 </head>
68
69 <body>
70 [% INCLUDE 'header.inc' %]
71 [% INCLUDE 'serials-search.inc' %]
72
73 <div id="breadcrumbs">
74     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
75     <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo;
76     <a href="/cgi-bin/koha/serials/subscription-frequencies.pl">Frequencies</a>
77 </div>
78
79 <div id="doc3" class="yui-t2">
80
81 <div id="bd">
82   <div id="yui-main">
83     <div class="yui-b">
84       [% IF (new or modify) %]
85         [% IF (new) %]
86           <h1>New frequency</h1>
87         [% ELSE %]
88           <h1>Modify frequency: [% description %]</h1>
89         [% END %]
90         <form action="/cgi-bin/koha/serials/subscription-frequencies.pl" method="post" onsubmit="return check_form();">
91           [% IF (modify) %]
92             <input type="hidden" name="id" value="[% id %]" />
93             <input type="hidden" name="op" value="savemod" />
94           [% ELSE %]
95             <input type="hidden" name="op" value="savenew" />
96           [% END %]
97           <fieldset class="rows">
98             <ol>
99               <li>
100                 <label for="description">Description:</label>
101                 <input type="text" id="description" name="description" value="[% description %]" />
102               </li>
103               <li>
104                 <label for="unit">Unit</label>
105                 <select id="unit" name="unit">
106                   <option value="">None</option>
107                   [% FOREACH unit IN units_loop %]
108                     [% IF (unit.selected) %]
109                       <option selected="selected" value="[% unit.val %]">
110                     [% ELSE %]
111                       <option value="[% unit.val %]">
112                     [% END %]
113                       [% unit.val %]
114                     </option>
115                   [% END %]
116                 </select>
117               </li>
118               <li><span class="hint">Note: one of the two following fields must be equal to 1</span></li>
119               <li>
120                 <label for="issuesperunit">Issues per unit</label>
121                 [% IF (new) %]
122                   <input type="text" id="issuesperunit" name="issuesperunit" value="1" size="3" />
123                 [% ELSE %]
124                   <input type="text" id="issuesperunit" name="issuesperunit" value="[% issuesperunit %]" size="3" />
125                 [% END %]
126               </li>
127               <li>
128                 <label for="unitsperissue">Units per issue</label>
129                 [% IF (new) %]
130                   <input type="text" id="unitsperissue" name="unitsperissue" value="1" size="3" />
131                 [% ELSE %]
132                   <input type="text" id="unitsperissue" name="unitsperissue" value="[% unitsperissue %]" size="3" />
133                 [% END %]
134               </li>
135               <li>
136                 <label for="displayorder">Display order</label>
137                 <input type="text" id="displayorder" name="displayorder" value="[% displayorder %]" size="3" />
138               </li>
139             </ol>
140           </fieldset>
141           <fieldset class="action">
142             <input type="submit" value="Save" />
143             <input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/serials/subscription-frequencies.pl'" />
144           </fieldset>
145         </form>
146       [% ELSE %]
147         <h1>Frequencies</h1>
148         [% IF still_used %]
149             <div class="dialog">
150                 <p>
151                     This frequency is still used by [% subscriptions.size %]
152                     subscription(s). Do you still want to delete it?
153                 </p>
154                 <p><a href="#" onclick="show_blocking_subs(); return false;">Show subscriptions</a></p>
155                 <ul id="blocking_subs" style="display:none">
156                     [% FOREACH sub IN subscriptions %]
157                         <li style="list-style-type:none">
158                             <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
159                         </li>
160                     [% END %]
161                 </ul>
162
163                 <form action="" method="get">
164                     <input type="hidden" name="op" value="del" />
165                     <input type="hidden" name="confirm" value="1" />
166                     <input type="hidden" name="frequencyid" value="[% frequencyid %]" />
167                     <input type="submit" class="approve" value="Yes, delete" />
168                 </form>
169                 <form action="" method="get">
170                     <input type="submit" class="deny" value="No, don't delete" />
171                 </form>
172             </div>
173         [% END %]
174         <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=new">New frenquency</a>
175
176         [% IF (frequencies_loop.size) %]
177           <table id="frequenciest">
178             <thead>
179               <tr>
180                 <th>Description</th>
181                 <th>Unit</th>
182                 <th>Issues per unit</th>
183                 <th>Units per issue</th>
184                 <th>Display order</th>
185                 <th>&nbsp;</th>
186               </tr>
187             </thead>
188             <tbody>
189               [% FOREACH frequency IN frequencies_loop %]
190                 <tr>
191                   <td>[% frequency.description %]</td>
192                   <td>[% frequency.unit %]</td>
193                   <td>[% frequency.issuesperunit %]</td>
194                   <td>[% frequency.unitsperissue %]</td>
195                   <td>[% frequency.displayorder %]</td>
196                   <td>
197                     <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=modify&frequencyid=[% frequency.id %]">Modify</a> |
198                     <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=del&frequencyid=[% frequency.id %]">Delete</a>
199                   </td>
200                 </tr>
201               [% END %]
202             </tbody>
203           </table>
204         [% ELSE %]
205           <p>There is no defined frequency.</p>
206         [% END %]
207       [% END %]
208
209     </div>
210   </div>
211   <div class="yui-b">
212     [% INCLUDE 'serials-menu.inc' %]
213   </div>
214 </div>
215 [% INCLUDE 'intranet-bottom.inc' %]