92d495437eaec64aabbe91f7d73b90f467b16d4c
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / branches.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% USE ColumnsSettings %]
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="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% library.branchurl | html %]" class="url" /></li>
145                 <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% library.opac_info | $raw %]</textarea></li>
146                 <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>
147                 <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>
148                 <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% library.branchnotes | html %]" /></li>
149                 <li><label for="pickup_location">Pickup location: </label>
150                     <select name="pickup_location" id="pickup_location">
151                         [% IF !library || library.pickup_location == 1 %]
152                         <option value="1" selected="selected">Yes</option>
153                         <option value="0">No</option>
154                         [% ELSE %]
155                         <option value="1">Yes</option>
156                         <option value="0" selected="selected">No</option>
157                         [% END %]
158                     </select>
159                 </li>
160             </ol>
161         </fieldset>
162         <fieldset class="action">
163             <input type="submit" value="Submit" />
164             <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
165         </fieldset>
166     </form>
167 [% END %]
168
169 [% IF op == 'delete_confirm' and not ( items_count or patrons_count )%]
170     <div class="dialog alert">
171         <form action="/cgi-bin/koha/admin/branches.pl" method="post">
172             <h3>Are you sure you want to delete [% library.branchname | html %] ([% library.branchcode | html %])?</h3>
173             <input type="hidden" name="op" value="delete_confirmed" />
174             <input type="hidden" name="branchcode" value="[% library.branchcode | html %]" />
175             <input type="hidden" name="branchname" value="[% library.branchname | html %]">
176             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
177         </form>
178         <form action="/cgi-bin/koha/admin/branches.pl" method="get">
179             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
180         </form>
181     </div>
182 [% END %]
183
184 [% IF op == 'list' %]
185     <h3>Libraries</h3>
186     [% IF libraries_count > 0 %]
187         <table id="libraries">
188             <thead>
189                 <tr>
190                     <th>Name</th>
191                     <th>Code</th>
192                     <th>Address</th>
193                     <th>MARC organization code</th>
194                     <th>IP</th>
195                     <th>Pickup location</th>
196                     <th data-class-name="actions">Actions</th>
197                 </tr>
198             </thead>
199         </table>
200     [% ELSE %]
201         <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>
202     [% END %]
203 [% END %]
204
205             </main>
206         </div> <!-- /.col-sm-10.col-sm-push-2 -->
207
208         <div class="col-sm-2 col-sm-pull-10">
209             <aside>
210                 [% INCLUDE 'admin-menu.inc' %]
211             </aside>
212         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
213      </div> <!-- /.row -->
214
215 [% MACRO jsinclude BLOCK %]
216     [% Asset.js("js/admin-menu.js") | $raw %]
217     [% INCLUDE 'datatables.inc' %]
218     [% INCLUDE 'columns_settings.inc' %]
219     [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
220     [% INCLUDE 'str/tinymce_i18n.inc' %]
221     <script>
222         var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
223         $(document).ready(function() {
224
225             var libraries_url = '/api/v1/libraries';
226             var libraries = $("#libraries").api({
227                 "ajax": {
228                     "url": libraries_url
229                 },
230                 '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>',
231                 "columnDefs": [ {
232                     "targets": [0,1,3,4,7,8,9,10,11,12,13,14,15],
233                     "render": function (data, type, row, meta) {
234                         if ( type == 'display' ) {
235                             if ( data != null ) {
236                                 return data.escapeHtml();
237                             }
238                             else {
239                                 return "";
240                             }
241                         }
242                         return data;
243                     }
244                 } ],
245                 "columns": [
246                     {
247                         "data": "name",
248                         "searchable": true,
249                         "orderable": true
250                     },
251                     {
252                         "data": "library_id",
253                         "searchable": true,
254                         "orderable": true
255                     },
256                     {
257                         "data": function( row, type, val, meta ) {
258                             const library_info = [];
259                             if ( row.address1 != null ) library_info.push(row.address1.escapeHtml());
260                             if ( row.address2 != null ) library_info.push(row.address2.escapeHtml());
261                             if ( row.address3 != null ) library_info.push(row.address3.escapeHtml());
262                             // geographical_location = city, state postal_code
263                             const locations = [];
264                             if ( row.city != null ) locations.push(row.city.escapeHtml());
265                             if ( row.state != null ) locations.push(row.state.escapeHtml());
266                             const geographical_location = locations.join(', ');
267                             if ( geographical_location != '' && row.postal_code != null) {
268                                 library_info.push(geographical_location+' '+row.postal_code.escapeHtml());
269                             }
270                             else {
271                                 library_info.push(geographical_location);
272                             }
273                             if ( row.country != null ) library_info.push(row.country.escapeHtml());
274                             if ( row.phone != null ) library_info.push(_("Ph: ") + row.phone.escapeHtml());
275                             if ( row.fax != null ) library_info.push(_("Fax: ") + row.fax.escapeHtml());
276                             if ( row.email != null ) library_info.push('<a href="mailto:'+encodeURIComponent(row.email)+'">'+row.email.escapeHtml()+'</a>');
277                             if ( row.url != null ) library_info.push('<a href="'+encodeURIComponent(row.url)+'">'+row.url.escapeHtml()+'</a>');
278                             if ( row.opac_info != null ) library_info.push(_("OPAC Info") + ': <div>'+row.opac_info.escapeHtml()+'</div>');
279                             if ( row.notes != null ) library_info.push(_("Notes")+': '+row.notes.escapeHtml());
280                             return library_info.join('<br/>');
281                         },
282                         "searchable": false,
283                         "orderable": false
284                     },
285                     {
286                         "data": "marc_org_code",
287                         "searchable": true,
288                         "orderable": true
289                     },
290                     {
291                         "data": "ip",
292                         "searchable": true,
293                         "orderable": true
294                     },
295                     {
296                         "data": "pickup_location",
297                         "searchable": true,
298                         "orderable": true,
299                         "render": function( data, type, row, meta ) {
300                             return (data) ? _("Yes") : _("No");
301                         }
302                     },
303                     {
304                         "data": function( row, type, val, meta ) {
305
306                             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>';
307                             result += '<form action="/cgi-bin/koha/admin/branches.pl" method="post">';
308                             result += '<input type="hidden" name="branchcode" value="'+row.library_id.escapeHtml()+'" />'+"\n";
309                             result += '<input type="hidden" name="op" value="delete_confirm" />';
310                             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>';
311
312                             return result;
313
314                         },
315                         "searchable": false,
316                         "orderable": false
317                     },
318                     {
319                         "data": "address1",
320                         "searchable": true,
321                         "visible": false,
322                         "orderable": false
323                     },
324                     {
325                         "data": "address2",
326                         "searchable": true,
327                         "visible": false,
328                         "orderable": false
329                     },
330                     {
331                         "data": "address3",
332                         "searchable": true,
333                         "visible": false,
334                         "orderable": false
335                     },
336                     {
337                         "data": "city",
338                         "searchable": true,
339                         "visible": false,
340                         "orderable": false
341                     },
342                     {
343                         "data": "state",
344                         "searchable": true,
345                         "visible": false,
346                         "orderable": false
347                     },
348                     {
349                         "data": "postal_code",
350                         "searchable": true,
351                         "visible": false,
352                         "orderable": false
353                     },
354                     {
355                         "data": "country",
356                         "searchable": true,
357                         "visible": false,
358                         "orderable": false
359                     },
360                     {
361                         "data": "opac_info",
362                         "searchable": true,
363                         "visible": false,
364                         "orderable": false
365                     },
366                     {
367                         "data": "notes",
368                         "searchable": true,
369                         "visible": false,
370                         "orderable": false
371                     },
372                 ]
373             }, columns_settings);
374
375             [% UNLESS library %]
376                 $("#Aform").on("submit", function( event ) {
377                     if ( $("#branchcode").val().match(/\s/) ) {
378                         event.preventDefault();
379                         alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code"));
380                         return false;
381                     } else {
382                         return true;
383                     }
384                 });
385             [% END %]
386         });
387
388         tinyMCE.init({
389             branding : false,
390             content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
391             menubar : "file edit view insert format tools table",
392             mode : "specific_textareas",
393             plugins : "autoresize table hr link image charmap lists code emoticons",
394             toolbar : [
395                 "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
396                 "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code visualaid help"
397             ],
398         });
399     </script>
400 [% END %]
401
402 [% INCLUDE 'intranet-bottom.inc' %]