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