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