Bug 22191: Add column configuration to libraries administration
[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 [% Asset.css("css/datatables.css") | $raw %]
15 </head>
16
17 <body id="admin_branches" class="admin">
18 [% INCLUDE 'header.inc' %]
19 [% INCLUDE 'prefs-admin-search.inc' %]
20
21 <div id="breadcrumbs">
22     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
24 &rsaquo; <a href="/cgi-bin/koha/admin/branches.pl">Libraries</a>
25 [% IF op == 'add_form'  %]
26 &rsaquo; [% IF library %]Modify library[% ELSE %]New library [% library.branchcode | html %][% END %]
27 [% ELSIF op == 'delete_confirm' %]
28 &rsaquo; Confirm deletion of library '[% library.branchcode | html %]'
29 [% END %]
30 </div>
31
32 <div class="main container-fluid">
33     <div class="row">
34         <div class="col-sm-10 col-sm-push-2">
35             <main>
36
37 [% FOREACH m IN messages %]
38     <div class="dialog [% m.type | html %]">
39         [% SWITCH m.code %]
40         [% CASE 'error_on_update' %]
41             An error occurred when updating this library. Perhaps it already exists.
42         [% CASE 'error_on_insert' %]
43             An error occurred when adding this library. The branchcode might already exist.
44         [% CASE 'error_on_delete' %]
45             An error occurred when deleting this library. Check the logs.
46         [% CASE 'success_on_update' %]
47             Library updated successfully.
48         [% CASE 'success_on_insert' %]
49             Library added successfully.
50         [% CASE 'success_on_delete' %]
51             Library deleted successfully.
52         [% CASE 'cannot_delete_library' %]
53             This library cannot be deleted. Patrons or items are still using it
54             [% IF m.data.patrons_count and m.data.items_count %]
55                 ([% m.data.patrons_count | html %] patrons and [% m.data.items_count | html %] items).
56             [% ELSIF m.data.patrons_count %]
57                 ([% m.data.patrons_count | html %] patrons).
58             [% ELSIF m.data.items_count %]
59                 ([% m.data.items_count | html %] items).
60             [% END %]
61         [% CASE 'error_on_update_category' %]
62             An error occurred when updating this library category. Perhaps it already exists.
63         [% CASE 'error_on_insert_category' %]
64             An error occurred when adding this library category. The categorycode might already exist.
65         [% CASE 'error_on_delete_category' %]
66             An error occurred when deleting this library category. Check the logs.
67         [% CASE 'success_on_update_category' %]
68             Library category updated successfully.
69         [% CASE 'success_on_insert_category' %]
70             Library category added successfully.
71         [% CASE 'success_on_delete_category' %]
72             Library category deleted successfully.
73         [% CASE 'cannot_delete_category' %]
74             This library category cannot be deleted. [% m.data.libraries_count | html %] libraries are still using it.
75         [% CASE %]
76             [% m.code | html %]
77         [% END %]
78     </div>
79 [% END %]
80
81 [% IF op == 'list' %]
82     <div id="toolbar" class="btn-toolbar">
83         <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>
84     </div>
85 [% END %]
86
87 [% IF op == 'add_form' %]
88     <h3>[% IF library %]Modify library[% ELSE %]New library[% END %]</h3>
89     <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" class="validated" method="post">
90         <fieldset class="rows">
91             <input type="hidden" name="op" value="add_validate" />
92             [% IF library %]
93                 <input type="hidden" name="is_a_modif" value="1" />
94             [% END %]
95             <ol>
96                 <li>
97                     [% IF library %]
98                         <span class="label">Library code: </span>
99                         <input type="hidden" name="branchcode" value="[% library.branchcode | html %]" />
100                         [% library.branchcode | html %]
101                     [% ELSE %]
102                         <label for="branchcode" class="required">Library code: </label>
103                         <input type="text" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode | html %]" class="required" required="required" />
104                         <span class="required">Required</span>
105                     [% END %]
106                 </li>
107                 <li>
108                     <label for="branchname" class="required">Name: </label>
109                     <input type="text" name="branchname" id="branchname" size="80" value="[% library.branchname | html %]" class="required" required="required" />
110                     <span class="required">Required</span>
111                 </li>
112             </ol>
113         </fieldset>
114         [% IF categories %]
115             <fieldset class="rows"><legend>Group(s):</legend>
116                 <ol>
117                     [% FOREACH category IN categories %]
118                         <li>
119                             <label for="[% category.categorycode | html %]">[% category.categoryname | html %]: </label>
120                             [% IF category and selected_categorycodes.grep(category.categorycode).size %]
121                                 <input type="checkbox" id="[% category.categorycode | html %]" name="selected_categorycode_[% category.categorycode | html %]" checked="checked" />
122                             [% ELSE %]
123                                 <input type="checkbox" id="[% category.categorycode | html %]" name="selected_categorycode_[% category.categorycode | html %]" />
124                             [% END %]
125                             <span class="hint">[% category.codedescription | html %]</span>
126                         </li>
127                     [% END %]
128                 </ol>
129             </fieldset>
130         [% END %]
131         <fieldset class="rows">
132             <ol>
133                 <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% library.branchaddress1 | html %]" /></li>
134                 <li><label for="branchaddress2">Address line 2: </label><input type="text" name="branchaddress2" id="branchaddress2" size="60" value="[% library.branchaddress2 | html %]" /></li>
135                 <li><label for="branchaddress3">Address line 3: </label><input type="text" name="branchaddress3" id="branchaddress3" size="60" value="[% library.branchaddress3 | html %]" /></li>
136                 <li><label for="branchcity">City: </label><input type="text" name="branchcity" id="branchcity" size="60" value="[% library.branchcity | html %]" /></li>
137                 <li><label for="branchstate">State: </label><input type="text" name="branchstate" id="branchstate" size="60" value="[% library.branchstate | html %]" /></li>
138                 <li><label for="branchzip">ZIP/Postal code: </label><input type="text" name="branchzip" id="branchzip"  size="25" maxlength="25" value="[% library.branchzip | html %]" /></li>
139                 <li><label for="branchcountry">Country: </label><input type="text" name="branchcountry" id="branchcountry" size="60" value="[% library.branchcountry | html %]" /></li>
140                 <li><label for="branchphone">Phone: </label><input type="text" name="branchphone" id="branchphone" size="60" value="[% library.branchphone | html %]" /></li>
141                 <li><label for="branchfax">Fax: </label><input type="text" name="branchfax" id="branchfax" size="60" value="[% library.branchfax | html %]" /></li>
142                 <li><label for="branchemail">Email: </label><input type="text" name="branchemail" id="branchemail" class="email"  size="80" value="[% library.branchemail | html %]" /></li>
143                 <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>
144                 <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>
145                 <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% library.branchurl | html %]" class="url" /></li>
146                 <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% library.opac_info | $raw %]</textarea></li>
147                 <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>
148                 <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>
149                 <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% library.branchnotes | html %]" /></li>
150                 <li><label for="pickup_location">Pickup location: </label>
151                     <select name="pickup_location" id="pickup_location">
152                         [% IF !library || library.pickup_location == 1 %]
153                         <option value="1" selected="selected">Yes</option>
154                         <option value="0">No</option>
155                         [% ELSE %]
156                         <option value="1">Yes</option>
157                         <option value="0" selected="selected">No</option>
158                         [% END %]
159                     </select>
160                 </li>
161             </ol>
162         </fieldset>
163         <fieldset class="action">
164             <input type="submit" value="Submit" />
165             <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
166         </fieldset>
167     </form>
168 [% END %]
169
170 [% IF op == 'delete_confirm' and not ( items_count or patrons_count )%]
171     <div class="dialog alert">
172         <form action="/cgi-bin/koha/admin/branches.pl" method="post">
173             <h3>Are you sure you want to delete [% library.branchname | html %] ([% library.branchcode | html %])?</h3>
174             <input type="hidden" name="op" value="delete_confirmed" />
175             <input type="hidden" name="branchcode" value="[% library.branchcode | html %]" />
176             <input type="hidden" name="branchname" value="[% library.branchname | html %]">
177             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
178         </form>
179         <form action="/cgi-bin/koha/admin/branches.pl" method="get">
180             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
181         </form>
182     </div>
183 [% END %]
184
185 [% IF op == 'list' %]
186     <h3>Libraries</h3>
187     [% IF libraries.count %]
188         <table id="libraries">
189             <thead>
190                 <tr>
191                     <th>Name</th>
192                     <th>Code</th>
193                     <th>Address</th>
194                     <th>MARC organization code</th>
195                     <th>IP</th>
196                     <th>Pickup location</th>
197                     <th>Actions</th>
198                 </tr>
199             </thead>
200             <tbody>
201                 [% FOREACH library IN libraries %]
202                     <tr>
203                         <td>[% library.branchname | html %]</td>
204                         <td>[% library.branchcode | html %]</td>
205                         <td>
206                             [% IF library.branchaddress1 %]
207                                 [% library.branchaddress1 | html %][% END %]
208                             [% IF library.branchaddress2 %]
209                                 <br />[% library.branchaddress2 | html %][% END %]
210                             [% IF library.branchaddress3 %]
211                                 <br />[% library.branchaddress3 | html %][% END %]
212                             [% IF library.branchcity %]
213                                 <br />[% library.branchcity | html %][% END %][% IF ( library.branchstate ) %],
214                                 [% library.branchstate | html %][% END %]
215                             [% IF library.branchzip %]
216                                 [% library.branchzip | html %][% END %]
217                             [% IF library.branchcountry %]
218                                 <br />[% library.branchcountry | html %][% END %]
219                             [% IF library.branchphone %]
220                                 <br />Ph: [% library.branchphone | html %][% END %]
221                             [% IF library.branchfax %]
222                                 <br />Fax: [% library.branchfax | html %][% END %]
223                             [% IF library.branchemail %]
224                                 <br /><a href="mailto:[% library.branchemail | uri %]">[% library.branchemail | html %]</a>[% END %]
225                             [% IF library.branchurl %]
226                                 <br /><a href="[% library.branchurl | url %]">[% library.branchurl | html %]</a>[% END %]
227                             [% IF library.opac_info %]
228                                 <br />OPAC Info: <div>[% library.opac_info | $raw %]</div>[% END %]
229                             [% IF library.branchnotes %]
230                                 <br />Notes: [% library.branchnotes | html %][% END %]
231                         </td>
232                         <td>[% library.marcorgcode | html %]</td>
233                         <td>[% library.branchip | html %]</td>
234                         <td>[% IF library.pickup_location %]Yes[% ELSE %]No[% END %]</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 [% END %]
251
252             </main>
253         </div> <!-- /.col-sm-10.col-sm-push-2 -->
254
255         <div class="col-sm-2 col-sm-pull-10">
256             <aside>
257                 [% INCLUDE 'admin-menu.inc' %]
258             </aside>
259         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
260      </div> <!-- /.row -->
261
262 [% MACRO jsinclude BLOCK %]
263     [% Asset.js("js/admin-menu.js") | $raw %]
264     [% INCLUDE 'datatables.inc' %]
265     [% INCLUDE 'columns_settings.inc' %]
266     [% Asset.js("lib/tiny_mce/tiny_mce.js") | $raw %]
267     <script>
268         var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
269         $(document).ready(function() {
270             KohaTable("libraries", {
271                 "aoColumnDefs": [
272                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
273                 ],
274                 "sPaginationType": "four_button",
275                 "exportColumns": [0,1,2,3,4,5]
276             }, columns_settings);
277
278             [% UNLESS library %]
279                 $("#Aform").on("submit", function( event ) {
280                     if ( $("#branchcode").val().match(/\s/) ) {
281                         event.preventDefault();
282                         alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code"));
283                         return false;
284                     } else {
285                         return true;
286                     }
287                 });
288             [% END %]
289         });
290         tinyMCE.baseURL = "[% interface | html %]/lib/tiny_mce";
291         tinyMCE.init({
292             mode : "textareas",
293             theme : "advanced",
294             content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
295             plugins : "table,save,advhr,advlink,contextmenu",
296             theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,",
297             theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
298             // theme_advanced_buttons3 : "",
299             theme_advanced_toolbar_location : "top",
300             theme_advanced_toolbar_align : "left",
301             theme_advanced_path_location : "bottom",
302             theme_advanced_resizing : true,
303             apply_source_formatting : true
304         });
305     </script>
306 [% END %]
307
308 [% INCLUDE 'intranet-bottom.inc' %]