Bug 23013: Upgrade DataTables in the staff client
[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 %]
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>Actions</th>
197                 </tr>
198             </thead>
199             <tbody>
200                 [% FOREACH library IN libraries %]
201                     <tr>
202                         <td>[% library.branchname | html %]</td>
203                         <td>[% library.branchcode | html %]</td>
204                         <td>
205                             [% IF library.branchaddress1 %]
206                                 [% library.branchaddress1 | html %][% END %]
207                             [% IF library.branchaddress2 %]
208                                 <br />[% library.branchaddress2 | html %][% END %]
209                             [% IF library.branchaddress3 %]
210                                 <br />[% library.branchaddress3 | html %][% END %]
211                             [% IF library.branchcity %]
212                                 <br />[% library.branchcity | html %][% END %][% IF ( library.branchstate ) %],
213                                 [% library.branchstate | html %][% END %]
214                             [% IF library.branchzip %]
215                                 [% library.branchzip | html %][% END %]
216                             [% IF library.branchcountry %]
217                                 <br />[% library.branchcountry | html %][% END %]
218                             [% IF library.branchphone %]
219                                 <br />Ph: [% library.branchphone | html %][% END %]
220                             [% IF library.branchfax %]
221                                 <br />Fax: [% library.branchfax | html %][% END %]
222                             [% IF library.branchemail %]
223                                 <br /><a href="mailto:[% library.branchemail | uri %]">[% library.branchemail | html %]</a>[% END %]
224                             [% IF library.branchurl %]
225                                 <br /><a href="[% library.branchurl | url %]">[% library.branchurl | html %]</a>[% END %]
226                             [% IF library.opac_info %]
227                                 <br />OPAC Info: <div>[% library.opac_info | $raw %]</div>[% END %]
228                             [% IF library.branchnotes %]
229                                 <br />Notes: [% library.branchnotes | html %][% END %]
230                         </td>
231                         <td>[% library.marcorgcode | html %]</td>
232                         <td>[% library.branchip | html %]</td>
233                         <td>[% IF library.pickup_location %]Yes[% ELSE %]No[% END %]</td>
234                         <td class="actions">
235                             <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>
236                             <form action="/cgi-bin/koha/admin/branches.pl" method="post">
237                                 <input type="hidden" name="branchcode" value="[% library.branchcode | html %]" />
238                                 <input type="hidden" name="op" value="delete_confirm" />
239                                 <button type="submit" id="delete_library_[% library.branchcode | html %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
240                             </form>
241                         </td>
242                     </tr>
243                 [% END %]
244             </tbody>
245         </table>
246     [% ELSE %]
247         <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>
248     [% END %]
249 [% END %]
250
251             </main>
252         </div> <!-- /.col-sm-10.col-sm-push-2 -->
253
254         <div class="col-sm-2 col-sm-pull-10">
255             <aside>
256                 [% INCLUDE 'admin-menu.inc' %]
257             </aside>
258         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
259      </div> <!-- /.row -->
260
261 [% MACRO jsinclude BLOCK %]
262     [% Asset.js("js/admin-menu.js") | $raw %]
263     [% INCLUDE 'datatables.inc' %]
264     [% INCLUDE 'columns_settings.inc' %]
265     [% Asset.js("lib/tiny_mce/tiny_mce.js") | $raw %]
266     <script>
267         var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
268         $(document).ready(function() {
269             KohaTable("libraries", {
270                 "aoColumnDefs": [
271                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
272                 ],
273                 "sPaginationType": "full",
274                 "exportColumns": [0,1,2,3,4,5]
275             }, columns_settings);
276
277             [% UNLESS library %]
278                 $("#Aform").on("submit", function( event ) {
279                     if ( $("#branchcode").val().match(/\s/) ) {
280                         event.preventDefault();
281                         alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code"));
282                         return false;
283                     } else {
284                         return true;
285                     }
286                 });
287             [% END %]
288         });
289         tinyMCE.baseURL = "[% interface | html %]/lib/tiny_mce";
290         tinyMCE.init({
291             mode : "textareas",
292             theme : "advanced",
293             content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
294             plugins : "table,save,advhr,advlink,contextmenu",
295             theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,",
296             theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
297             // theme_advanced_buttons3 : "",
298             theme_advanced_toolbar_location : "top",
299             theme_advanced_toolbar_align : "left",
300             theme_advanced_path_location : "bottom",
301             theme_advanced_resizing : true,
302             apply_source_formatting : true
303         });
304     </script>
305 [% END %]
306
307 [% INCLUDE 'intranet-bottom.inc' %]