Bug 35650: (follow-up) Other cases found
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / restrictions.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% PROCESS 'restriction-types.inc' %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>[% FILTER collapse %]
8     [% IF op == 'add_form' %]
9         [% IF ( restriction ) %]
10             [% t("Modify restriction type") | html %] '[% PROCESS restriction_type_description restriction_type=restriction %]' &rsaquo;
11         [% ELSE %]
12             [% t("New restriction type") | html %] &rsaquo;
13         [% END %]
14     [% END %]
15     [% IF op == 'delete_confirm' %]
16         [% t("Confirm deletion of restriction type") | html %] '[% PROCESS restriction_type_description restriction_type=restriction %]' &rsaquo;
17     [% END %]
18     [% t("Patron restriction types") | html %] &rsaquo;
19     [% t("Administration") | html %] &rsaquo;
20     [% t("Koha") | html %]
21 [% END %]</title>
22 [% INCLUDE 'doc-head-close.inc' %]
23 </head>
24
25 <body id="admin_restrictions" class="admin">
26 [% WRAPPER 'header.inc' %]
27     [% INCLUDE 'prefs-admin-search.inc' %]
28 [% END %]
29
30 [% WRAPPER 'sub-header.inc' %]
31     [% WRAPPER breadcrumbs %]
32         [% WRAPPER breadcrumb_item %]
33             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
34         [% END %]
35
36         [% IF op == 'list' %]
37             [% WRAPPER breadcrumb_item bc_active= 1 %]
38                 <span>Patron restriction types</span>
39             [% END %]
40         [% ELSE %]
41             [% WRAPPER breadcrumb_item %]
42                 <a href="/cgi-bin/koha/admin/restrictions.pl">Patron restriction types</a>
43             [% END %]
44         [% END %]
45
46         [% IF op == 'add_form' %]
47             [% IF restriction %]
48                 [% WRAPPER breadcrumb_item bc_active= 1 %]
49                     <span>Modify restriction type '[% PROCESS restriction_type_description %]'</span>
50                 [% END %]
51             [% ELSE %]
52                 [% WRAPPER breadcrumb_item bc_active= 1 %]
53                     <span>New restriction type</span>
54                 [% END %]
55             [% END %]
56         [% END %]
57
58         [% IF op == 'delete_confirm' %]
59             [% WRAPPER breadcrumb_item bc_active= 1 %]
60                 <span>Delete restriction type '[% PROCESS restriction_type_description %]'</span>
61             [% END %]
62         [% END %]
63     [% END #/ WRAPPER breadcrumbs %]
64 [% END #/ WRAPPER sub-header.inc %]
65
66 <div class="main container-fluid">
67     <div class="row">
68         <div class="col-sm-10 col-sm-push-2">
69             <main>
70
71 [% FOR m IN messages %]
72     <div class="dialog message [% m.code | html %]">
73         [% SWITCH m.code %]
74         [% CASE 'add_success' %]
75             Restriction type added.
76         [% CASE 'update_success' %]
77             Restriction type updated.
78         [% CASE 'duplicate_display_text' %]
79             Another restriction type already has this label.
80         [% CASE 'duplicate_code' %]
81             Another restriction type already has this code.
82         [% CASE 'delete_success' %]
83             Restriction type deleted.
84         [% CASE 'delete_default' %]
85             Cannot delete the default restriction type.
86         [% CASE 'delete_system' %]
87             Cannot delete a system restriction type.
88         [% CASE %]
89             [% m.code | html %]
90         [% END %]
91     </div>
92 [% END %]
93
94 [% IF op == 'add_form' %]
95     <form id="restriction_form" action="/cgi-bin/koha/admin/restrictions.pl" method="post">
96         <input type="hidden" name="op" value="add_validate" />
97         <input type="hidden" name="checked" value="0" />
98         [% IF restriction %]
99             <h1>Modify restriction type '[% PROCESS restriction_type_description restriction_type=restriction %]'</h1>
100             <input type="hidden" name="is_a_modif" value="1" />
101         [% ELSE %]
102             <h1>New restriction type</h1>
103         [% END %]
104         <fieldset class="rows">
105             <ol>
106                 [% IF restriction %]
107                     <li>
108                         <span class="label">Code: </span>[% restriction.code | html %]
109                         <input type="hidden" name="code" value="[% restriction.code | html %]" />
110                     </li>
111                     <li>
112                         <label for="display_text" class="required">Label: </label>
113                         <input type="text" value="[% restriction.display_text | html %]" name="display_text" id="display_text" size="50" maxlength="50" class="required" required="required" />
114                         <span class="required">Required</span>
115                     </li>
116                     <li>
117                         <label for="lift_after_payment" class="required">Lift after payment: </label>
118                         <select type="text" name="lift_after_payment" id="lift_after_payment"/>
119                         [% IF restriction.lift_after_payment %]
120                             <option value="0">No</option>
121                             <option value="1" selected="selected">Yes</option>
122                         [% ELSE %]
123                             <option value="0" selected="selected">No</option>
124                             <option value="1">Yes</option>
125                         [% END %]
126                         </select>
127                     </li>
128                     <li>
129                         <label for="fee_limit">Fee limit: </label>
130                         <input type="text" value="[% restriction.fee_limit | html %]" inputmode="decimal" pattern="^\d+(\.\d{2})?$" min="0" name="fee_limit" id="fee_limit" />
131                     </li>
132                 [% ELSE %]
133                     <li>
134                         <label for="code" class="required">Code: </label>
135                         <input type="text" name="code" id="code" size="50" maxlength="50" class="focus required type_input " required="required" />
136                         <span class="required">Required</span>
137                     </li>
138                     <li>
139                         <label for="display_text" class="required">Label: </label>
140                         <input type="text" name="display_text" id="display_text" size="50" maxlength="50" class="required" required="required" />
141                         <span class="required">Required</span>
142                     </li>
143                     <li>
144                         <label for="lift_after_payment">Lift after payment: </label>
145                         <select type="text" name="lift_after_payment" id="lift_after_payment" />
146                             <option value="0" selected="selected">No</option>
147                             <option value="1">Yes</option>
148                         </select>
149                     </li>
150                     <li>
151                         <label for="fee_limit">Fee limit: </label>
152                         <input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" min="0" name="fee_limit" id="fee_limit" />
153                     </li>
154                 [% END %]
155             </ol>
156         </fieldset>
157
158         <fieldset class="action">
159             <input type="submit" class="btn btn-primary" value="Save" />
160             <a href="/cgi-bin/koha/admin/restrictions.pl" class="cancel">Cancel</a>
161         </fieldset>
162     </form>
163 [% END %]
164
165 [% IF op == 'delete_confirm' %]
166     <div class="dialog alert">
167         <h1>Confirm restriction type deletion</h1>
168         <p>Are you sure you want to delete '[% PROCESS restriction_type_description restriction_type=restriction %]'?</p>
169         <form action="/cgi-bin/koha/admin/restrictions.pl" method="post">
170             <input type="hidden" name="op" value="delete_confirmed" />
171             <input type="hidden" name="code" value="[% restriction.code | html %]" />
172             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
173         </form>
174         <form action="/cgi-bin/koha/admin/restrictions.pl" method="get">
175             <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button>
176         </form>
177     </div>
178 [% END %]
179
180 [% IF op == 'list' %]
181
182     <div id="toolbar" class="btn-toolbar">
183         <a class="btn btn-default" id="newrestriction" href="/cgi-bin/koha/admin/restrictions.pl?op=add_form"><i class="fa fa-plus"></i> New restriction type</a>
184     </div>
185
186     <h1>Patron restriction types</h1>
187
188     [% IF restrictions %]
189         <div class="page-section">
190             <table id="restriction_types">
191                 <thead>
192                     <tr>
193                         <th scope="col">Code</th>
194                         <th scope="col">Label</th>
195                         <th scope="col">Default</th>
196                         <th scope="col">Lift after payment?</th>
197                         <th scope="col">Fee limit</th>
198                         <th scope="col">Actions</th>
199                     </tr>
200                 </thead>
201                 <tbody>
202                     [% FOREACH restriction IN restrictions %]
203                         <tr>
204                             <td>
205                                 [% restriction.code | html %]
206                             </td>
207                             <td>
208                                 [% PROCESS restriction_type_description restriction_type=restriction %]
209                             </td>
210                             <td>
211                                 [% IF restriction.is_default %]Yes[% END %]
212                             </td>
213                             <td>
214                                 [% IF restriction.lift_after_payment %]Yes[% END %]
215                             </td>
216                             <td>
217                                 [% IF restriction.fee_limit %][% restriction.fee_limit | html %][% END %]
218                             </td>
219                             <td class="actions">
220                                 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/restrictions.pl?op=add_form&amp;code=[% restriction.code | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
221                                 [% IF !restriction.is_system && !restriction.is_default %]
222                                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/restrictions.pl?op=delete_confirm&amp;code=[% restriction.code | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
223                                 [% END %]
224                                 [% IF !restriction.is_system && !restriction.is_default %]
225                                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/restrictions.pl?op=make_default&amp;code=[% restriction.code | uri %]"><i class="fa fa-archive"></i> Make default</a>
226                                 [% END %]
227                             </td>
228                         </tr>
229                     [% END %]
230                 </tbody>
231             </table>
232         </div><!-- /.page-section -->
233     [% ELSE %]
234         <div class="dialog alert">No restriction types have been defined. <a href="/cgi-bin/koha/admin/restrictions.pl?op=add_form">Create a new restriction type</a>.</div>
235     [% END %]
236 [% END %]
237
238             </main>
239         </div> <!-- /.col-sm-10.col-sm-push-2 -->
240
241         <div class="col-sm-2 col-sm-pull-10">
242             <aside>
243                 [% INCLUDE 'admin-menu.inc' %]
244             </aside>
245         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
246      </div> <!-- /.row -->
247
248 [% MACRO jsinclude BLOCK %]
249     [% Asset.js("js/admin-menu.js") | $raw %]
250     [% INCLUDE 'datatables.inc' %]
251     [% INCLUDE 'columns_settings.inc' %]
252     <script>
253         var MSG_DUPLICATE_CODE = _("Restriction type code is already in use");
254         var MSG_DUPLICATE_DISPLAY_TEXT = _("Restriction type label is already in use");
255         var existing = {
256         [% FOREACH ex IN existing %]
257             [% NEXT IF ex.code == restriction.code %]
258             [% ex.code | $raw %]: '[% ex.display_text | $raw %]',
259         [% END %]
260         };
261
262         //Require fee limit if "Lift after payment" is set true
263         $("#lift_after_payment").on("change", function(){
264             if($(this).val() == 1){
265                 $("#fee_limit").prop("required",true).after('<span class="required">Required</span>');
266             } else {
267                 $("#fee_limit").prop("required",false).nextAll().remove();
268             }
269         });
270     </script>
271     [% Asset.js("js/restrictiontypes.js") | $raw %]
272 [% END %]
273 [% INCLUDE 'intranet-bottom.inc' %]