Bug 27360: Add hint to input field
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / branches.tt
1 [% USE Koha %]
2 [% USE raw %]
3 [% USE Asset %]
4 [% SET footerjs = 1 %]
5 [% USE TablesSettings %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>
8 [% IF op == 'add_form' %]
9     [% IF library %]
10         Modify library
11     [% ELSE %]
12         New library [% library.branchcode | html %]
13     [% END %] &rsaquo; [% ELSIF op == 'delete_confirm' %]
14     Confirm deletion of library '[% library.branchcode | html %]' &rsaquo; [% END %]
15 Libraries &rsaquo; Administration &rsaquo; Koha
16 </title>
17 [% INCLUDE 'doc-head-close.inc' %]
18 </head>
19
20 <body id="admin_branches" class="admin">
21 [% INCLUDE 'header.inc' %]
22 [% INCLUDE 'prefs-admin-search.inc' %]
23
24 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
25     <ol>
26         <li>
27             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
28         </li>
29         <li>
30             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
31         </li>
32
33         [% IF op == 'add_form'  %]
34             <li>
35                 <a href="/cgi-bin/koha/admin/branches.pl">Libraries</a>
36             </li>
37             [% IF library %]
38                 <li>
39                     <a href="#" aria-current="page">
40                         Modify library
41                     </a>
42                 </li>
43             [% ELSE %]
44                 <li>
45                     <a href="#" aria-current="page">
46                         New library [% library.branchcode | html %]
47                     </a>
48                 </li>
49             [% END %]
50
51         [% ELSIF op == 'delete_confirm' %]
52             <li>
53                 <a href="/cgi-bin/koha/admin/branches.pl">Libraries</a>
54             </li>
55             <li>
56                 <a href="#" aria-current="page">
57                     Confirm deletion of library '[% library.branchcode | html %]'
58                 </a>
59             </li>
60
61         [% ELSE %]
62             <li>
63                 <a href="#" aria-current="page">
64                     Libraries
65                 </a>
66             </li>
67         [% END %]
68     </ol>
69 </nav>
70
71 <div class="main container-fluid">
72     <div class="row">
73         <div class="col-sm-10 col-sm-push-2">
74             <main>
75
76 [% FOREACH m IN messages %]
77     <div class="dialog [% m.type | html %]">
78         [% SWITCH m.code %]
79         [% CASE 'error_on_update' %]
80             An error occurred when updating this library. Perhaps it already exists.
81         [% CASE 'error_on_insert' %]
82             An error occurred when adding this library. The branchcode might already exist.
83         [% CASE 'error_on_delete' %]
84             An error occurred when deleting this library. Check the logs.
85         [% CASE 'success_on_update' %]
86             Library updated successfully.
87         [% CASE 'success_on_insert' %]
88             Library added successfully.
89         [% CASE 'success_on_delete' %]
90             Library deleted successfully.
91         [% CASE 'cannot_delete_library' %]
92             This library cannot be deleted. Patrons or items are still using it
93             [% IF m.data.patrons_count and m.data.items_count %]
94                 ([% m.data.patrons_count | html %] patrons and [% m.data.items_count | html %] items).
95             [% ELSIF m.data.patrons_count %]
96                 ([% m.data.patrons_count | html %] patrons).
97             [% ELSIF m.data.items_count %]
98                 ([% m.data.items_count | html %] items).
99             [% END %]
100         [% CASE 'error_on_update_category' %]
101             An error occurred when updating this library category. Perhaps it already exists.
102         [% CASE 'error_on_insert_category' %]
103             An error occurred when adding this library category. The categorycode might already exist.
104         [% CASE 'error_on_delete_category' %]
105             An error occurred when deleting this library category. Check the logs.
106         [% CASE 'success_on_update_category' %]
107             Library category updated successfully.
108         [% CASE 'success_on_insert_category' %]
109             Library category added successfully.
110         [% CASE 'success_on_delete_category' %]
111             Library category deleted successfully.
112         [% CASE 'cannot_delete_category' %]
113             This library category cannot be deleted. [% m.data.libraries_count | html %] libraries are still using it.
114         [% CASE %]
115             [% m.code | html %]
116         [% END %]
117     </div>
118 [% END %]
119
120 [% IF op == 'list' %]
121     <div id="toolbar" class="btn-toolbar">
122         <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>
123     </div>
124 [% END %]
125
126 [% IF op == 'add_form' %]
127     <h3>[% IF library %]Modify library[% ELSE %]New library[% END %]</h3>
128     <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" class="validated" method="post">
129         <fieldset class="rows">
130             <input type="hidden" name="op" value="add_validate" />
131             [% IF library %]
132                 <input type="hidden" name="is_a_modif" value="1" />
133             [% END %]
134             <ol>
135                 <li>
136                     [% IF library %]
137                         <span class="label">Library code: </span>
138                         <input type="hidden" name="branchcode" value="[% library.branchcode | html %]" />
139                         [% library.branchcode | html %]
140                     [% ELSE %]
141                         <label for="branchcode" class="required">Library code: </label>
142                         <input type="text" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode | html %]" class="required focus" required="required" />
143                         <span class="required">Required</span>
144                     [% END %]
145                 </li>
146                 <li>
147                     <label for="branchname" class="required">Name: </label>
148                     [% IF library %]
149                         <input type="text" name="branchname" id="branchname" size="80" value="[% library.branchname | html %]" class="required focus" required="required" />
150                     [% ELSE %]
151                         <input type="text" name="branchname" id="branchname" size="80" value="[% library.branchname | html %]" class="required" required="required" />
152                     [% END %]
153                     <span class="required">Required</span>
154                 </li>
155             </ol>
156         </fieldset>
157         [% IF categories %]
158             <fieldset class="rows"><legend>Group(s):</legend>
159                 <ol>
160                     [% FOREACH category IN categories %]
161                         <li>
162                             <label for="[% category.categorycode | html %]">[% category.categoryname | html %]: </label>
163                             [% IF category and selected_categorycodes.grep(category.categorycode).size %]
164                                 <input type="checkbox" id="[% category.categorycode | html %]" name="selected_categorycode_[% category.categorycode | html %]" checked="checked" />
165                             [% ELSE %]
166                                 <input type="checkbox" id="[% category.categorycode | html %]" name="selected_categorycode_[% category.categorycode | html %]" />
167                             [% END %]
168                             <div class="hint">[% category.codedescription | html %]</div>
169                         </li>
170                     [% END %]
171                 </ol>
172             </fieldset>
173         [% END %]
174         <fieldset class="rows">
175             <ol>
176                 <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% library.branchaddress1 | html %]" /></li>
177                 <li><label for="branchaddress2">Address line 2: </label><input type="text" name="branchaddress2" id="branchaddress2" size="60" value="[% library.branchaddress2 | html %]" /></li>
178                 <li><label for="branchaddress3">Address line 3: </label><input type="text" name="branchaddress3" id="branchaddress3" size="60" value="[% library.branchaddress3 | html %]" /></li>
179                 <li><label for="branchcity">City: </label><input type="text" name="branchcity" id="branchcity" size="60" value="[% library.branchcity | html %]" /></li>
180                 <li><label for="branchstate">State: </label><input type="text" name="branchstate" id="branchstate" size="60" value="[% library.branchstate | html %]" /></li>
181                 <li><label for="branchzip">ZIP/Postal code: </label><input type="text" name="branchzip" id="branchzip"  size="25" maxlength="25" value="[% library.branchzip | html %]" /></li>
182                 <li><label for="branchcountry">Country: </label><input type="text" name="branchcountry" id="branchcountry" size="60" value="[% library.branchcountry | html %]" /></li>
183                 <li><label for="branchphone">Phone: </label><input type="text" name="branchphone" id="branchphone" size="60" value="[% library.branchphone | html %]" /></li>
184                 <li><label for="branchfax">Fax: </label><input type="text" name="branchfax" id="branchfax" size="60" value="[% library.branchfax | html %]" /></li>
185                 <li><label for="branchemail">Email: </label><input type="text" name="branchemail" id="branchemail" class="email"  size="80" value="[% library.branchemail | html %]" /></li>
186                 [% IF (Koha.Preference('ILLModule')) %]
187                 <li>
188                     <label for="branchillemail">ILL staff email: </label>
189                     <input type="text" name="branchillemail" id="branchillemail" class="email"  size="80" value="[% library.branchillemail | html %]" />
190                     <div class="hint">
191                         [% IF ( CAN_user_parameters_manage_sysprefs ) %]
192                             Default: <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ILLDefaultStaffEmail">ILLDefaultStaffEmail</a> system preference
193                         [% ELSE %]
194                             Default: ILLDefaultStaffEmail system preference
195                         [% END %]
196                     </div>
197                 </li>
198                 [% END %]
199                 <li>
200                     <label for="branchreplyto">Reply-To: </label>
201                     <input type="text" name="branchreplyto" id="branchreplyto" class="email"  size="80" value="[% library.branchreplyto | html %]" />
202                     <div class="hint">
203                          [% IF ( CAN_user_parameters_manage_sysprefs ) %]
204                             Default: <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ReplyToDefault">ReplyToDefault</a> system preference
205                         [% ELSE %]
206                             Default: ReplyToDefault system preference
207                         [% END %]
208                     </div>
209                 </li>
210                 <li>
211                     <label for="branchreturnpath">Return-Path: </label>
212                     <input type="text" name="branchreturnpath" id="branchreturnpath" class="email"  size="80" value="[% library.branchreturnpath | html %]" />
213                     <div class="hint">
214                          [% IF ( CAN_user_parameters_manage_sysprefs ) %]
215                             Default: <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ReturnpathDefault">ReturnpathDefault</a> system preference
216                         [% ELSE %]
217                             Default: ReturnpathDefault system preference
218                         [% END %]
219                     </div>
220                 </li>
221                 <li><label for="smtp_server">SMTP server: </label>
222                     <select name="smtp_server" id="smtp_server">
223                     [% IF selected_smtp_server.is_system_default %]
224                         <option value="*" selected="selected">Default</option>
225                     [% ELSE %]
226                         <option value="*">Default</option>
227                     [% END %]
228                     [% FOREACH smtp_server IN smtp_servers %]
229                         [% IF smtp_server.id == selected_smtp_server.id %]
230                             <option value="[% smtp_server.id | html %]" selected="selected">[% smtp_server.name | html %]</option>
231                         [% ELSE %]
232                             <option value="[% smtp_server.id | html %]">[% smtp_server.name | html %]</option>
233                         [% END %]
234                     [% END %]
235                     </select>
236                 </li>
237                 <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% library.branchurl | html %]" class="url" /></li>
238                 <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% library.opac_info | $raw %]</textarea></li>
239                 <li>
240                     <label for="branchip">IP: </label>
241                     <input type="text" name="branchip" id="branchip"  size="15" maxlength="15" value="[% library.branchip | html %]" />
242                     <div class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</div>
243                 </li>
244                 <li>
245                     <label for="marcorgcode">MARC organization code</label>
246                     <input type="text" name="marcorgcode" id="marcorgcode" size="16" maxlength="16" value="[% library.marcorgcode | html %]" />
247                     <div class="hint">
248                         [% IF ( CAN_user_parameters_manage_sysprefs ) %]
249                             If not filled in defaults to system preference <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=MARCOrgCode">MARCOrgCode</a>.
250                         [% ELSE %]
251                             If not filled in defaults to system preference MARCOrgCode.
252                         [% END %]
253                         You can obtain your code from <a href="http://www.loc.gov/marc/organizations/orgshome.html" target="_blank">Library of Congress</a>.
254                     </div>
255                 </li>
256                 <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% library.branchnotes | html %]" /></li>
257                 <li><label for="pickup_location">Pickup location: </label>
258                     <select name="pickup_location" id="pickup_location">
259                         [% IF !library || library.pickup_location == 1 %]
260                         <option value="1" selected="selected">Yes</option>
261                         <option value="0">No</option>
262                         [% ELSE %]
263                         <option value="1">Yes</option>
264                         <option value="0" selected="selected">No</option>
265                         [% END %]
266                     </select>
267                 </li>
268                 <li><label for="public">Public: </label>
269                     <select name="public" id="public">
270                         [% IF !library || library.public == 1 %]
271                         <option value="1" selected="selected">Yes</option>
272                         <option value="0">No</option>
273                         [% ELSE %]
274                         <option value="1">Yes</option>
275                         <option value="0" selected="selected">No</option>
276                         [% END %]
277                     </select>
278                     <div class="hint">Set to 'yes' to show this library on the Libraries page in the OPAC.</div>
279                 </li>
280             </ol>
281         </fieldset>
282         <fieldset class="action">
283             <input type="submit" value="Submit" />
284             <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
285         </fieldset>
286     </form>
287 [% END %]
288
289 [% IF op == 'delete_confirm' and not ( items_count or patrons_count )%]
290     <div class="dialog alert">
291         <form action="/cgi-bin/koha/admin/branches.pl" method="post">
292             <h3>Are you sure you want to delete [% library.branchname | html %] ([% library.branchcode | html %])?</h3>
293             <input type="hidden" name="op" value="delete_confirmed" />
294             <input type="hidden" name="branchcode" value="[% library.branchcode | html %]" />
295             <input type="hidden" name="branchname" value="[% library.branchname | html %]">
296             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
297         </form>
298         <form action="/cgi-bin/koha/admin/branches.pl" method="get">
299             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
300         </form>
301     </div>
302 [% END %]
303
304 [% IF op == 'list' %]
305     <h3>Libraries</h3>
306     [% IF libraries_count > 0 %]
307         <table id="libraries">
308             <thead>
309                 <tr>
310                     <th>Name</th>
311                     <th>Code</th>
312                     <th>Address</th>
313                     <th>MARC organization code</th>
314                     <th>IP</th>
315                     <th>Pickup location</th>
316                     <th>Public</th>
317                     <th>SMTP server</th>
318                     <th data-class-name="actions noExport">Actions</th>
319                 </tr>
320             </thead>
321         </table>
322     [% ELSE %]
323         <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>
324     [% END %]
325 [% END %]
326
327             </main>
328         </div> <!-- /.col-sm-10.col-sm-push-2 -->
329
330         <div class="col-sm-2 col-sm-pull-10">
331             <aside>
332                 [% INCLUDE 'admin-menu.inc' %]
333             </aside>
334         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
335      </div> <!-- /.row -->
336
337 [% MACRO jsinclude BLOCK %]
338     [% Asset.js("js/admin-menu.js") | $raw %]
339     [% INCLUDE 'datatables.inc' %]
340     [% INCLUDE 'columns_settings.inc' %]
341     [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
342     [% INCLUDE 'str/tinymce_i18n.inc' %]
343     <script>
344         var columns_settings = [% TablesSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
345         $(document).ready(function() {
346
347             var libraries_url = '/api/v1/libraries';
348             var libraries = $("#libraries").api({
349                 "ajax": {
350                     "url": libraries_url
351                 },
352                 'embed': [ 'smtp_server' ],
353                 '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>',
354                 "columnDefs": [ {
355                     "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
356                     "render": function (data, type, row, meta) {
357                         if ( type == 'display' ) {
358                             if ( data != null ) {
359                                 return data.escapeHtml();
360                             }
361                             else {
362                                 return "";
363                             }
364                         }
365                         return data;
366                     }
367                 } ],
368                 "columns": [
369                     {
370                         "data": "name",
371                         "searchable": true,
372                         "orderable": true
373                     },
374                     {
375                         "data": "library_id",
376                         "searchable": true,
377                         "orderable": true
378                     },
379                     {
380                         "data": function( row, type, val, meta ) {
381                             const library_info = [];
382                             if ( row.address1 != null ) library_info.push(row.address1.escapeHtml());
383                             if ( row.address2 != null ) library_info.push(row.address2.escapeHtml());
384                             if ( row.address3 != null ) library_info.push(row.address3.escapeHtml());
385                             // geographical_location = city, state postal_code
386                             const locations = [];
387                             if ( row.city != null ) locations.push(row.city.escapeHtml());
388                             if ( row.state != null ) locations.push(row.state.escapeHtml());
389                             const geographical_location = locations.join(', ');
390                             if ( geographical_location != '' && row.postal_code != null) {
391                                 library_info.push(geographical_location+' '+row.postal_code.escapeHtml());
392                             }
393                             else {
394                                 library_info.push(geographical_location);
395                             }
396                             if ( row.country != null ) library_info.push(row.country.escapeHtml());
397                             if ( row.phone != null ) library_info.push(_("Ph: ") + row.phone.escapeHtml());
398                             if ( row.fax != null ) library_info.push(_("Fax: ") + row.fax.escapeHtml());
399                             if ( row.email != null ) library_info.push('<a href="mailto:'+encodeURIComponent(row.email)+'">'+row.email.escapeHtml()+'</a>');
400                             if ( row.url != null ) library_info.push('<a href="'+encodeURIComponent(row.url)+'">'+row.url.escapeHtml()+'</a>');
401                             if ( row.notes != null ) library_info.push(_("Notes")+': '+row.notes.escapeHtml());
402                             return library_info.join('<br/>');
403                         },
404                         "searchable": false,
405                         "orderable": false
406                     },
407                     {
408                         "data": "marc_org_code",
409                         "searchable": true,
410                         "orderable": true
411                     },
412                     {
413                         "data": "ip",
414                         "searchable": true,
415                         "orderable": true
416                     },
417                     {
418                         "data": "pickup_location",
419                         "searchable": true,
420                         "orderable": true,
421                         "render": function( data, type, row, meta ) {
422                             return (data) ? _("Yes") : _("No");
423                         }
424                     },
425                     {
426                         "data": "public",
427                         "searchable": true,
428                         "orderable": true,
429                         "render": function( data, type, row, meta ) {
430                             return (data) ? _("Yes") : _("No");
431                         }
432                     },
433                     {
434                         "data": "smtp_server",
435                         "render": function( data, type, row, meta ) {
436                             if ( data.smtp_server_id ) {
437                                 return '<a href="/cgi-bin/koha/admin/smtp_servers.pl?op=edit_form&smtp_server_id='+encodeURIComponent(data.smtp_server_id)+'">'+data.name.escapeHtml()+'</a>';
438                             }
439                             else {
440                                 return _("Default");
441                             }
442                         },
443                         "searchable": false,
444                         "visible": true,
445                         "orderable": false
446                     },
447                     {
448                         "data": function( row, type, val, meta ) {
449
450                             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>';
451                             result += '<form action="/cgi-bin/koha/admin/branches.pl" method="post">';
452                             result += '<input type="hidden" name="branchcode" value="'+row.library_id.escapeHtml()+'" />'+"\n";
453                             result += '<input type="hidden" name="op" value="delete_confirm" />';
454                             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>';
455
456                             return result;
457
458                         },
459                         "searchable": false,
460                         "orderable": false
461                     },
462                     {
463                         "data": "address1",
464                         "searchable": true,
465                         "visible": false,
466                         "orderable": false
467                     },
468                     {
469                         "data": "address2",
470                         "searchable": true,
471                         "visible": false,
472                         "orderable": false
473                     },
474                     {
475                         "data": "address3",
476                         "searchable": true,
477                         "visible": false,
478                         "orderable": false
479                     },
480                     {
481                         "data": "city",
482                         "searchable": true,
483                         "visible": false,
484                         "orderable": false
485                     },
486                     {
487                         "data": "state",
488                         "searchable": true,
489                         "visible": false,
490                         "orderable": false
491                     },
492                     {
493                         "data": "postal_code",
494                         "searchable": true,
495                         "visible": false,
496                         "orderable": false
497                     },
498                     {
499                         "data": "country",
500                         "searchable": true,
501                         "visible": false,
502                         "orderable": false
503                     },
504                     {
505                         "data": "opac_info",
506                         "searchable": true,
507                         "visible": false,
508                         "orderable": false
509                     },
510                     {
511                         "data": "notes",
512                         "searchable": true,
513                         "visible": false,
514                         "orderable": false
515                     }
516                 ]
517             }, columns_settings);
518
519             [% UNLESS library %]
520                 $("#Aform").on("submit", function( event ) {
521                     if ( $("#branchcode").val().match(/\s/) ) {
522                         event.preventDefault();
523                         alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code"));
524                         return false;
525                     } else {
526                         return true;
527                     }
528                 });
529             [% END %]
530         });
531
532         tinyMCE.init({
533             branding : false,
534             relative_urls : false,
535             content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
536             menubar : "file edit view insert format tools table",
537             mode : "specific_textareas",
538             plugins : "autoresize table hr link image charmap lists code emoticons",
539             toolbar : [
540                 "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
541                 "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code"
542             ],
543         });
544     </script>
545 [% END %]
546
547 [% INCLUDE 'intranet-bottom.inc' %]