Bug 20538: Remove the need of writing [% KOHA_VERSION %] everywhere
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / branches.tt
1 [% USE Asset %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Administration &rsaquo; Libraries
5 [% IF op == 'add_form' %]
6     &rsaquo;[% IF library %]Modify library[% ELSE %]New library [% library.branchcode | html %][% END %]
7 [% ELSIF op == 'delete_confirm' %]
8     &rsaquo; Confirm deletion of library '[% library.branchcode | html %]'
9 [% END %]
10 </title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("css/datatables.css") %]
13 </head>
14
15 <body id="admin_branches" class="admin">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'prefs-admin-search.inc' %]
18
19 <div id="breadcrumbs">
20     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
21 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
22 &rsaquo; <a href="/cgi-bin/koha/admin/branches.pl">Libraries</a>
23 [% IF op == 'add_form'  %]
24 &rsaquo; [% IF library %]Modify library[% ELSE %]New library [% library.branchcode | html %][% END %]
25 [% ELSIF op == 'delete_confirm' %]
26 &rsaquo; Confirm deletion of library '[% library.branchcode | html %]'
27 [% END %]
28 </div>
29
30 <div id="doc3" class="yui-t2">
31
32    <div id="bd">
33     <div id="yui-main">
34     <div class="yui-b">
35
36 [% FOREACH m IN messages %]
37     <div class="dialog [% m.type %]">
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 %] patrons and [% m.data.items_count %] items).
55             [% ELSIF m.data.patrons_count %]
56                 ([% m.data.patrons_count %] patrons).
57             [% ELSIF m.data.items_count %]
58                 ([% m.data.items_count %] 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 %] libraries are still using it.
74         [% CASE %]
75             [% m.code %]
76         [% END %]
77     </div>
78 [% END %]
79
80 [% IF op == 'list' %]
81     <div id="toolbar" class="btn-toolbar">
82         <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>
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 %]">[% category.categoryname |html %]: </label>
119                             [% IF category and selected_categorycodes.grep(category.categorycode).size %]
120                                 <input type="checkbox" id="[% category.categorycode %]" name="selected_categorycode_[% category.categorycode %]" checked="checked" />
121                             [% ELSE %]
122                                 <input type="checkbox" id="[% category.categorycode %]" name="selected_categorycode_[% category.categorycode %]" />
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 |html %]</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             </ol>
150         </fieldset>
151         <fieldset class="action">
152             <input type="submit" value="Submit" />
153             <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
154         </fieldset>
155     </form>
156 [% END %]
157
158 [% IF op == 'delete_confirm' and not ( items_count or patrons_count )%]
159     <div class="dialog alert">
160         <form action="/cgi-bin/koha/admin/branches.pl" method="post">
161             <h3>Are you sure you want to delete [% library.branchname |html %] ([% library.branchcode | html %])?</h3>
162             <input type="hidden" name="op" value="delete_confirmed" />
163             <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
164             <input type="hidden" name="branchname" value="[% library.branchname |html %]">
165             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
166         </form>
167         <form action="/cgi-bin/koha/admin/branches.pl" method="get">
168             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
169         </form>
170     </div>
171 [% END %]
172
173 [% IF op == 'list' %]
174     <h3>Libraries</h3>
175     [% IF libraries.count %]
176         <table id="branchest">
177             <thead>
178                 <tr>
179                     <th>Name</th>
180                     <th>Code</th>
181                     <th>Address</th>
182                     <th>MARC organization code</th>
183                     <th>IP</th>
184                     <th>Actions</th>
185                 </tr>
186             </thead>
187             <tbody>
188                 [% FOREACH library IN libraries %]
189                     <tr>
190                         <td>[% library.branchname |html %]</td>
191                         <td>[% library.branchcode |html %]</td>
192                         <td>
193                             [% IF library.branchaddress1 %]
194                                 [% library.branchaddress1 |html %][% END %]
195                             [% IF library.branchaddress2 %]
196                                 <br />[% library.branchaddress2 |html %][% END %]
197                             [% IF library.branchaddress3 %]
198                                 <br />[% library.branchaddress3 |html %][% END %]
199                             [% IF library.branchcity %]
200                                 <br />[% library.branchcity |html %][% END %][% IF ( library.branchstate ) %],
201                                 [% library.branchstate |html %][% END %]
202                             [% IF library.branchzip %]
203                                 [% library.branchzip |html %][% END %]
204                             [% IF library.branchcountry %]
205                                 <br />[% library.branchcountry |html %][% END %]
206                             [% IF library.branchphone %]
207                                 <br />Ph: [% library.branchphone |html %][% END %]
208                             [% IF library.branchfax %]
209                                 <br />Fax: [% library.branchfax |html %][% END %]
210                             [% IF library.branchemail %]
211                                 <br /><a href="mailto:[% library.branchemail %]">[% library.branchemail |html %]</a>[% END %]
212                             [% IF library.branchurl %]
213                                 <br /><a href="[% library.branchurl %]">[% library.branchurl |html %]</a>[% END %]
214                             [% IF library.opac_info %]
215                                 <br />OPAC Info: <div>[% library.opac_info %]</div>[% END %]
216                             [% IF library.branchnotes %]
217                                 <br />Notes: [% library.branchnotes |html %][% END %]
218                         </td>
219                         <td>[% library.marcorgcode %]</td>
220                         <td>[% library.branchip %]</td>
221                         <td class="actions">
222                             <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>
223                             <form action="/cgi-bin/koha/admin/branches.pl" method="post">
224                                 <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
225                                 <input type="hidden" name="op" value="delete_confirm" />
226                                 <button type="submit" id="delete_library_[% library.branchcode | html %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>
227                             </form>
228                         </td>
229                     </tr>
230                 [% END %]
231             </tbody>
232         </table>
233     [% ELSE %]
234         <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>
235     [% END %]
236 [% END %]
237
238 </div>
239 </div>
240 <div class="yui-b">
241 [% INCLUDE 'admin-menu.inc' %]
242 </div>
243 </div>
244
245 [% MACRO jsinclude BLOCK %]
246     [% Asset.js("js/admin-menu.js") %]
247     [% INCLUDE 'datatables.inc' %]
248     [% Asset.js("lib/tiny_mce/tiny_mce.js") %]
249     <script type="text/javascript">
250         $(document).ready(function() {
251             $("#branchest").dataTable($.extend(true, {}, dataTablesDefaults, {
252                 "aoColumnDefs": [
253                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
254                 ],
255                 "iDisplayLength": 10,
256                 "sPaginationType": "four_button"
257             }));
258
259             [% UNLESS library %]
260                 $("#Aform").on("submit", function( event ) {
261                     if ( $("#branchcode").val().match(/\s/) ) {
262                         event.preventDefault();
263                         alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code"));
264                         return false;
265                     } else {
266                         return true;
267                     }
268                 });
269             [% END %]
270         });
271         tinyMCE.baseURL = "[% interface %]/lib/tiny_mce";
272         tinyMCE.init({
273             mode : "textareas",
274             theme : "advanced",
275             content_css : "[% interface %]/[% theme %]/css/tinymce.css",
276             plugins : "table,save,advhr,advlink,contextmenu",
277             theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,",
278             theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
279             // theme_advanced_buttons3 : "",
280             theme_advanced_toolbar_location : "top",
281             theme_advanced_toolbar_align : "left",
282             theme_advanced_path_location : "bottom",
283             theme_advanced_resizing : true,
284             apply_source_formatting : true
285         });
286     </script>
287 [% END %]
288
289 [% INCLUDE 'intranet-bottom.inc' %]