Bug 19560: Correctly escape branchcode in admin/branches.pl
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / branches.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Libraries and groups
3 [% IF op == 'editcategory' %]
4     &rsaquo; [% IF category.categorycode %] Edit group [% category.categorycode%] [% ELSE %] New group [% END %]
5 [% ELSIF op == 'delete_confirm_category' %]
6     &rsaquo; Confirm deletion of group [% category.categorycode %]
7 [% ELSIF op == 'add_form' %]
8     &rsaquo; [% IF library %] Modify library [% library.branchcode | html %] [% ELSE %] New library [% END %]
9 [% ELSIF op == 'delete_confirm' %]
10     &rsaquo; Confirm deletion of library '[% library.branchcode | html %]'
11 [% END %]
12 </title>
13 [% INCLUDE 'doc-head-close.inc' %]
14 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
15 [% INCLUDE 'datatables.inc' %]
16 <script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
17 <script type="text/javascript">
18 //<![CDATA[
19     $(document).ready(function() {
20         $("#branchest").dataTable($.extend(true, {}, dataTablesDefaults, {
21             "aoColumnDefs": [
22                 { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
23             ],
24             "iDisplayLength": 10,
25             "sPaginationType": "four_button"
26         }));
27
28         [% UNLESS library %]
29             $("#Aform").on("submit", function( event ) {
30                 if ( $("#branchcode").val().match(/\s/) ) {
31                     event.preventDefault();
32                     alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code"));
33                     return false;
34                 } else {
35                     return true;
36                 }
37             });
38         [% END %]
39     });
40 tinyMCE.init({
41     mode : "textareas",
42     theme : "advanced",
43     content_css : "[% interface %]/[% theme %]/css/tinymce.css",
44     plugins : "table,save,advhr,advlink,contextmenu",
45     theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,",
46     theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
47     // theme_advanced_buttons3 : "",
48     theme_advanced_toolbar_location : "top",
49     theme_advanced_toolbar_align : "left",
50     theme_advanced_path_location : "bottom",
51     theme_advanced_resizing : true,
52     apply_source_formatting : true
53 });
54 //]]>
55 </script>
56 </head>
57 <body id="admin_branches" class="admin">
58 [% INCLUDE 'header.inc' %]
59 [% INCLUDE 'prefs-admin-search.inc' %]
60
61 <div id="breadcrumbs">
62     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
63 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
64 &rsaquo; <a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a>
65 [% IF op == 'add_form_category' %]
66 &rsaquo; [% IF category.categorycode %] Edit group [% category.categorycode %] [% ELSE %] New group [% END %]
67 [% ELSIF op == 'delete_confirm_category' %]
68 &rsaquo; Confirm deletion of group [% category.categorycode %]
69 [% ELSIF op == 'add_form'  %]
70 &rsaquo; [% IF library %] Modify library [% library.branchcode | html %] [% ELSE %] New library [% END %]
71 [% ELSIF op == 'delete_confirm' %]
72 &rsaquo; Confirm deletion of library '[% library.branchcode | html %]'
73 [% END %]
74 </div>
75
76 <div id="doc3" class="yui-t2">
77
78    <div id="bd">
79     <div id="yui-main">
80     <div class="yui-b">
81
82 [% FOREACH m IN messages %]
83     <div class="dialog [% m.type %]">
84         [% SWITCH m.code %]
85         [% CASE 'error_on_update' %]
86             An error occurred when updating this library. Perhaps it already exists.
87         [% CASE 'error_on_insert' %]
88             An error occurred when adding this library. The branchcode might already exist.
89         [% CASE 'error_on_delete' %]
90             An error occurred when deleting this library. Check the logs.
91         [% CASE 'success_on_update' %]
92             Library updated successfully.
93         [% CASE 'success_on_insert' %]
94             Library added successfully.
95         [% CASE 'success_on_delete' %]
96             Library deleted successfully.
97         [% CASE 'cannot_delete_library' %]
98             This library cannot be deleted. Patrons or items are still using it
99             [% IF m.data.patrons_count and m.data.items_count %]
100                 ([% m.data.patrons_count %] patrons and [% m.data.items_count %] items).
101             [% ELSIF m.data.patrons_count %]
102                 ([% m.data.patrons_count %] patrons).
103             [% ELSIF m.data.items_count %]
104                 ([% m.data.items_count %] items).
105             [% END %]
106         [% CASE 'error_on_update_category' %]
107             An error occurred when updating this library category. Perhaps it already exists.
108         [% CASE 'error_on_insert_category' %]
109             An error occurred when adding this library category. The categorycode might already exist.
110         [% CASE 'error_on_delete_category' %]
111             An error occurred when deleting this library category. Check the logs.
112         [% CASE 'success_on_update_category' %]
113             Library category updated successfully.
114         [% CASE 'success_on_insert_category' %]
115             Library category added successfully.
116         [% CASE 'success_on_delete_category' %]
117             Library category deleted successfully.
118         [% CASE 'cannot_delete_category' %]
119             This library category cannot be deleted. [% m.data.libraries_count %] libraries are still using it.
120         [% CASE %]
121             [% m.code %]
122         [% END %]
123     </div>
124 [% END %]
125
126 [% IF op == 'list' %]
127     <div id="toolbar" class="btn-toolbar">
128         <a class="btn btn-default btn-sm" id="newbranch" href="/cgi-bin/koha/admin/branches.pl?op=add_form"><i class="fa fa-plus"></i> New library</a>
129         <a class="btn btn-default btn-sm" id="newcategory" href="/cgi-bin/koha/admin/branches.pl?op=add_form_category"><i class="fa fa-plus"></i> New group</a>
130     </div>
131 [% END %]
132
133 [% IF op == 'add_form' %]
134     <h3>[% IF library %]Modify library[% ELSE %]New library[% END %]</h3>
135     <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" class="validated" method="post">
136         <fieldset class="rows">
137             <input type="hidden" name="op" value="add_validate" />
138             [% IF library %]
139                 <input type="hidden" name="is_a_modif" value="1" />
140             [% END %]
141             <ol>
142                 <li>
143                     [% IF library %]
144                         <span class="label">Library code: </span>
145                         <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
146                         [% library.branchcode | html %]
147                     [% ELSE %]
148                         <label for="branchcode" class="required">Library code: </label>
149                         <input type="text" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
150                         <span class="required">Required</span>
151                     [% END %]
152                 </li>
153                 <li>
154                     <label for="branchname" class="required">Name: </label>
155                     <input type="text" name="branchname" id="branchname" size="80" value="[% library.branchname |html %]" class="required" required="required" />
156                     <span class="required">Required</span>
157                 </li>
158             </ol>
159         </fieldset>
160         [% IF categories %]
161             <fieldset class="rows"><legend>Group(s):</legend>
162                 <ol>
163                     [% FOREACH category IN categories %]
164                         <li>
165                             <label for="[% category.categorycode %]">[% category.categoryname |html %]: </label>
166                             [% IF category and selected_categorycodes.grep(category.categorycode).size %]
167                                 <input type="checkbox" id="[% category.categorycode %]" name="selected_categorycode_[% category.categorycode %]" checked="checked" />
168                             [% ELSE %]
169                                 <input type="checkbox" id="[% category.categorycode %]" name="selected_categorycode_[% category.categorycode %]" />
170                             [% END %]
171                             <span class="hint">[% category.codedescription |html %]</span>
172                         </li>
173                     [% END %]
174                 </ol>
175             </fieldset>
176         [% END %]
177         <fieldset class="rows">
178             <ol>
179                 <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% library.branchaddress1 |html %]" /></li>
180                 <li><label for="branchaddress2">Address line 2: </label><input type="text" name="branchaddress2" id="branchaddress2" size="60" value="[% library.branchaddress2 |html %]" /></li>
181                 <li><label for="branchaddress3">Address line 3: </label><input type="text" name="branchaddress3" id="branchaddress3" size="60" value="[% library.branchaddress3 |html %]" /></li>
182                 <li><label for="branchcity">City: </label><input type="text" name="branchcity" id="branchcity" size="60" value="[% library.branchcity |html %]" /></li>
183                 <li><label for="branchstate">State: </label><input type="text" name="branchstate" id="branchstate" size="60" value="[% library.branchstate |html %]" /></li>
184                 <li><label for="branchzip">ZIP/Postal code: </label><input type="text" name="branchzip" id="branchzip"  size="25" maxlength="25" value="[% library.branchzip |html %]" /></li>
185                 <li><label for="branchcountry">Country: </label><input type="text" name="branchcountry" id="branchcountry" size="60" value="[% library.branchcountry |html %]" /></li>
186                 <li><label for="branchphone">Phone: </label><input type="text" name="branchphone" id="branchphone" size="60" value="[% library.branchphone |html %]" /></li>
187                 <li><label for="branchfax">Fax: </label><input type="text" name="branchfax" id="branchfax" size="60" value="[% library.branchfax |html %]" /></li>
188                 <li><label for="branchemail">Email: </label><input type="text" name="branchemail" id="branchemail" class="email"  size="80" value="[% library.branchemail |html %]" /></li>
189                 <li><label for="branchreplyto">Reply-To: </label> <input type="text" name="branchreplyto" id="branchreplyto" class="email"  size="80" value="[% library.branchreplyto |html %]" /><br /><span class="hint">Default: ReplyToDefault system preference</span></li>
190                 <li><label for="branchreturnpath">Return-Path: </label> <input type="text" name="branchreturnpath" id="branchreturnpath" class="email"  size="80" value="[% library.branchreturnpath |html %]" /><br /><span class="hint">Default: ReturnpathDefault system preference</span></li>
191                 <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% library.branchurl |html %]" class="url" /></li>
192                 <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% library.opac_info |html %]</textarea></li>
193                 <li><label for="branchip">IP: </label><input type="text" name="branchip" id="branchip"  size="15" maxlength="15" value="[% library.branchip |html %]" /> <span class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</span></li>
194                 <li><label for="marcorgccode">MARC organization code</label> <input type="text" name="marcorgcode" id="marcorgcode" size="16" value="[% library.marcorgcode |html %]" /> <span class="hint">If not filled in defaults to system preference MARCOrgCode. You can obtain your code from <a href="http://www.loc.gov/marc/organizations/orgshome.html" target="_blank">Library of Congress</a>.</span>
195                 <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% library.branchnotes |html %]" /></li>
196             </ol>
197         </fieldset>
198         <fieldset class="action">
199             <input type="submit" value="Submit" />
200             <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
201         </fieldset>
202     </form>
203 [% END %]
204
205 [% IF op == 'delete_confirm' and not ( items_count or patrons_count )%]
206     <div class="dialog alert">
207         <form action="/cgi-bin/koha/admin/branches.pl" method="post">
208             <h3>Are you sure you want to delete [% library.branchname |html %] ([% library.branchcode | html %])?</h3>
209             <input type="hidden" name="op" value="delete_confirmed" />
210             <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
211             <input type="hidden" name="branchname" value="[% library.branchname |html %]">
212             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
213         </form>
214         <form action="/cgi-bin/koha/admin/branches.pl" method="get">
215             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
216         </form>
217     </div>
218 [% END %]
219
220 [% IF op == 'list' %]
221     <h3>Libraries</h3>
222     [% IF libraries.count %]
223         <table id="branchest">
224             <thead>
225                 <tr>
226                     <th>Name</th>
227                     <th>Code</th>
228                     <th>Address</th>
229                     <th>Properties</th>
230                     <th>MARC organization code</th>
231                     <th>IP</th>
232                     <th>Actions</th>
233                 </tr>
234             </thead>
235             <tbody>
236                 [% FOREACH library IN libraries %]
237                     <tr>
238                         <td>[% library.branchname |html %]</td>
239                         <td>[% library.branchcode |html %]</td>
240                         <td>
241                             [% IF library.branchaddress1 %]
242                                 [% library.branchaddress1 |html %][% END %]
243                             [% IF library.branchaddress2 %]
244                                 <br />[% library.branchaddress2 |html %][% END %]
245                             [% IF library.branchaddress3 %]
246                                 <br />[% library.branchaddress3 |html %][% END %]
247                             [% IF library.branchcity %]
248                                 <br />[% library.branchcity |html %][% END %][% IF ( library.branchstate ) %],
249                                 [% library.branchstate |html %][% END %]
250                             [% IF library.branchzip %]
251                                 [% library.branchzip |html %][% END %]
252                             [% IF library.branchcountry %]
253                                 <br />[% library.branchcountry |html %][% END %]
254                             [% IF library.branchphone %]
255                                 <br />Ph: [% library.branchphone |html %][% END %]
256                             [% IF library.branchfax %]
257                                 <br />Fax: [% library.branchfax |html %][% END %]
258                             [% IF library.branchemail %]
259                                 <br /><a href="mailto:[% library.branchemail %]">[% library.branchemail |html %]</a>[% END %]
260                             [% IF library.branchurl %]
261                                 <br /><a href="[% library.branchurl %]">[% library.branchurl |html %]</a>[% END %]
262                             [% IF library.opac_info %]
263                                 <br />OPAC Info: <div>[% library.opac_info %]</div>[% END %]
264                             [% IF library.branchnotes %]
265                                 <br />Notes: [% library.branchnotes |html %][% END %]
266                         </td>
267                         <td>
268                             [% FOREACH category IN library.get_categories %]
269                                 [% category.categoryname |html %]<br />
270                             [% END %]
271                         </td>
272                         <td>[% library.marcorgcode %]</td>
273                         <td>[% library.branchip %]</td>
274                         <td class="actions">
275                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?op=add_form&amp;branchcode=[% library.branchcode |uri %]"><i class="fa fa-pencil"></i> Edit</a>
276                             <form action="/cgi-bin/koha/admin/branches.pl" method="post">
277                                 <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
278                                 <input type="hidden" name="op" value="delete_confirm" />
279                                 <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
280                             </form>
281                         </td>
282                     </tr>
283                 [% END %]
284             </tbody>
285         </table>
286     [% ELSE %]
287         <div class="dialog message">There are no libraries defined. <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">Start defining libraries</a>.</div>
288     [% END %]
289
290     [% IF group_types %]
291         [% FOREACH group_type IN group_types %]
292             <h3>[% IF group_type.categorytype == 'properties' %]Properties[% ELSIF group_type.categorytype == 'searchdomain' %]Search domain[% END %]</h3>
293             [% IF group_type.categories.size %]
294                 <table>
295                     <thead>
296                         <tr>
297                             <th>Name</th>
298                             <th>Code</th>
299                             <th>Description</th>
300                             <th>Actions</th>
301                         </tr>
302                     </thead>
303                     <tbody>
304                         [% FOREACH category IN group_type.categories %]
305                             <tr>
306                                 <td>[% category.categoryname |html %]</td>
307                                 <td>[% category.categorycode %]</td>
308                                 <td>[% category.codedescription |html %]</td>
309                                 <td class="actions">
310                                   <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&amp;op=add_form_category"><i class="fa fa-pencil"></i> Edit</a>
311                                   <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&amp;op=delete_confirm_category"><i class="fa fa-trash"></i> Delete</a>
312                                 </td>
313                             </tr>
314                         [% END %]
315                     </tbody>
316                 </table>
317             [% ELSE %]
318                 [% IF group_type.categorytype == 'properties' %]
319                     No properties defined.
320                 [% ELSIF group_type.categorytype == 'searchdomain' %]
321                     No search domain defined.
322                 [% END %]
323                 <a href="/cgi-bin/koha/admin/branches.pl?op=add_form_category">Add a new group</a>.
324             [% END %]
325         [% END %]
326     [% ELSE %]
327         <p>No groups defined.</p>
328     [% END %]
329 [% END %]
330
331 [% IF op == 'add_form_category' %]
332     <h3>[% IF category.categorycode %]Edit group [% category.categorycode %][% ELSE %]Add group[% END %]</h3>
333     <form action="/cgi-bin/koha/admin/branches.pl" name="Aform" method="post" class="validated">
334         <input type="hidden" name="op" value="add_validate_category" />
335         [% IF category.categorycode %]
336             <input type="hidden" name="is_a_modif" value="1" />
337         [% END %]
338         <fieldset class="rows">
339             <ol>
340                 <li>
341                     [% IF category.categorycode %]
342                         <span class="label">Category code: </span>
343                         <input type="hidden" name="categorycode" id="categorycode" value="[% category.categorycode |html %]" />
344                         [% category.categorycode %]
345                     [% ELSE %]
346                         <label for="categorycode" class="required">Category code:</label>
347                         <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" class="required" required="required" />
348                         <span class="required">Required</span>
349                     [% END %]
350                 </li>
351                 <li>
352                     <label for="categoryname" class="required">Name: </label>
353                     <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% category.categoryname |html %]" class="required" required="required" />
354                     <span class="required">Required</span>
355                 </li>
356                 <li>
357                     <label for="codedescription">Description: </label>
358                     <input type="text" name="codedescription" id="codedescription" size="70" value="[% category.codedescription |html %]" />
359                 </li>
360                 <li>
361                     <label for="categorytype">Category type: </label>
362                     <select id="categorytype" name="categorytype">
363                         [% IF category.categorytype == 'properties' %]
364                             <option value="searchdomain">Search domain</option>
365                             <option value="properties" selected="selected">Properties</option>
366                         [% ELSE %]
367                             <option value="searchdomain">Search domain</option>
368                             <option value="properties">Properties</option>
369
370                         [% END %]
371                     </select>
372                 </li>
373                 <li>
374                     <label for="show_in_pulldown">Show in search pulldown: </label>
375                     [% IF category.show_in_pulldown %]
376                         <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
377                     [% ELSE %]
378                         <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
379                     [% END %]
380                 </li>
381             </ol>
382         </fieldset>
383         <fieldset class="action">
384             <input type="submit" value="Submit" />
385             <a href="/cgi-bin/koha/admin/branches.pl" class="cancel">Cancel</a>
386         </fieldset>
387     </form>
388 [% END %]
389
390 [% IF op == 'delete_confirm_category' %]
391     <div class="dialog alert">
392     <h3>Are you sure you want to delete the group '[% category.codedescription |html %]' ([% category.categorycode %])?</h3>
393     <form action="/cgi-bin/koha/admin/branches.pl" method="post">
394         <input type="hidden" name="op" value="delete_confirmed_category" />
395         <input type="hidden" name="categorycode" value="[% category.categorycode |html %]" />
396         <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
397     </form>
398     <form action="/cgi-bin/koha/admin/branches.pl" method="get">
399         <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
400     </form>
401     </div>
402 [% END %]
403
404 </div>
405 </div>
406 <div class="yui-b">
407 [% INCLUDE 'admin-menu.inc' %]
408 </div>
409 </div>
410 [% INCLUDE 'intranet-bottom.inc' %]