View | Details | Raw Unified | Return to bug 25288
Collapse All | Expand All

(-)a/admin/branches.pl (+3 lines)
Lines 147-152 if ( $op eq 'add_form' ) { Link Here
147
    $op = 'list';
147
    $op = 'list';
148
}
148
}
149
149
150
$template->param( libraries_count => Koha::Libraries->search->count )
151
    if $op eq 'list';
152
150
$template->param(
153
$template->param(
151
    messages => \@messages,
154
    messages => \@messages,
152
    op       => $op,
155
    op       => $op,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-31 / +44 lines)
Lines 183-201 Link Here
183
183
184
[% IF op == 'list' %]
184
[% IF op == 'list' %]
185
    <h3>Libraries</h3>
185
    <h3>Libraries</h3>
186
    <table id="libraries">
186
    [% IF libraries_count > 0 %]
187
        <thead>
187
        <table id="libraries">
188
            <tr>
188
            <thead>
189
                <th>Name</th>
189
                <tr>
190
                <th>Code</th>
190
                    <th>Name</th>
191
                <th>Address</th>
191
                    <th>Code</th>
192
                <th>MARC organization code</th>
192
                    <th>Address</th>
193
                <th>IP</th>
193
                    <th>MARC organization code</th>
194
                <th>Pickup location</th>
194
                    <th>IP</th>
195
                <th>Actions</th>
195
                    <th>Pickup location</th>
196
            </tr>
196
                    <th data-class-name="actions">Actions</th>
197
        </thead>
197
                </tr>
198
    </table>
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 %]
199
[% END %]
203
[% END %]
200
204
201
            </main>
205
            </main>
Lines 218-230 Link Here
218
        var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
222
        var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
219
        $(document).ready(function() {
223
        $(document).ready(function() {
220
224
225
            const to_html = (x) => $('<div/>').text(x).html();
226
221
            var libraries_url = '/api/v1/libraries';
227
            var libraries_url = '/api/v1/libraries';
222
            var libraries = $("#libraries").api({
228
            var libraries = $("#libraries").api({
223
                "ajax": {
229
                "ajax": {
224
                    "url": libraries_url
230
                    "url": libraries_url
225
                },
231
                },
226
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
227
                '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>',
232
                '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>',
233
                "columnDefs": [ {
234
                    "targets": [0,1,3,4,7,8,9,10,11,12,13,14,15],
235
                    "render": function (data, type, row, meta) {
236
                        if ( type == 'display' ) {
237
                            return to_html(data);
238
                        }
239
                        return data;
240
                    }
241
                } ],
228
                "columns": [
242
                "columns": [
229
                    {
243
                    {
230
                        "data": "name",
244
                        "data": "name",
Lines 239-265 Link Here
239
                    {
253
                    {
240
                        "data": function( row, type, val, meta ) {
254
                        "data": function( row, type, val, meta ) {
241
                            const library_info = [];
255
                            const library_info = [];
242
                            if ( row.address1 != null ) library_info.push(row.address1);
256
                            if ( row.address1 != null ) library_info.push(to_html(row.address1));
243
                            if ( row.address2 != null ) library_info.push(row.address2);
257
                            if ( row.address2 != null ) library_info.push(to_html(row.address2));
244
                            if ( row.address3 != null ) library_info.push(row.address3);
258
                            if ( row.address3 != null ) library_info.push(to_html(row.address3));
245
                            // geographical_location = city, state postal_code
259
                            // geographical_location = city, state postal_code
246
                            const locations = [];
260
                            const locations = [];
247
                            if ( row.city != null ) locations.push(row.city);
261
                            if ( row.city != null ) locations.push(to_html(row.city));
248
                            if ( row.state != null ) locations.push(row.state);
262
                            if ( row.state != null ) locations.push(to_html(row.state));
249
                            const geographical_location = locations.join(', ');
263
                            const geographical_location = locations.join(', ');
250
                            if ( geographical_location != '' && row.postal_code != null) {
264
                            if ( geographical_location != '' && row.postal_code != null) {
251
                                library_info.push(geographical_location+' '+row.postal_code);
265
                                library_info.push(geographical_location+' '+to_html(row.postal_code));
252
                            }
266
                            }
253
                            else {
267
                            else {
254
                                library_info.push(geographical_location);
268
                                library_info.push(geographical_location);
255
                            }
269
                            }
256
                            if ( row.country != null ) library_info.push(row.country);
270
                            if ( row.country != null ) library_info.push(to_html(row.country));
257
                            if ( row.phone != null ) library_info.push(_("Ph: ") + row.phone);
271
                            if ( row.phone != null ) library_info.push(_("Ph: ") + to_html(row.phone));
258
                            if ( row.fax != null ) library_info.push(_("Fax: ") + row.fax);
272
                            if ( row.fax != null ) library_info.push(_("Fax: ") + to_html(row.fax));
259
                            if ( row.email != null ) library_info.push('<a href="mailto:'+row.email+'">'+row.email+'</a>');
273
                            if ( row.email != null ) library_info.push('<a href="mailto:'+encodeURIComponent(row.email)+'">'+to_html(row.email)+'</a>');
260
                            if ( row.url != null ) library_info.push('<a href="'+row.url+'">'+row.url+'</a>');
274
                            if ( row.url != null ) library_info.push('<a href="'+encodeURIComponent(row.url)+'">'+to_html(row.url)+'</a>');
261
                            if ( row.opac_info != null ) library_info.push(_("OPAC Info") + ': <div>'+row.opac_info+'</div>');
275
                            if ( row.opac_info != null ) library_info.push(_("OPAC Info") + ': <div>'+to_html(row.opac_info)+'</div>');
262
                            if ( row.notes != null ) library_info.push(_("Notes")+': '+row.notes);
276
                            if ( row.notes != null ) library_info.push(_("Notes")+': '+to_html(row.notes));
263
                            return library_info.join('<br/>');
277
                            return library_info.join('<br/>');
264
                        },
278
                        },
265
                        "searchable": false,
279
                        "searchable": false,
Lines 286-296 Link Here
286
                    {
300
                    {
287
                        "data": function( row, type, val, meta ) {
301
                        "data": function( row, type, val, meta ) {
288
302
289
                            var result = '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?op=add_form&amp;branchcode='+row.library_id+'"><i class="fa fa-pencil"></i> '+_("Edit")+'</a>';
303
                            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>';
290
                            result += '<form action="/cgi-bin/koha/admin/branches.pl" method="post">';
304
                            result += '<form action="/cgi-bin/koha/admin/branches.pl" method="post">';
291
                            result += '<input type="hidden" name="branchcode" value="'+row.library_id+'" />';
305
                            result += '<input type="hidden" name="branchcode" value="'+to_html(row.library_id)+'" />'+"\n";
292
                            result += '<input type="hidden" name="op" value="delete_confirm" />';
306
                            result += '<input type="hidden" name="op" value="delete_confirm" />';
293
                            result += '<button type="submit" id="delete_library_'+row.library_id+'" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> '+_("Delete")+'</button></form>';
307
                            result += '<button type="submit" id="delete_library_'+to_html(row.library_id)+'" class="btn btn-default btn-xs" role="button"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</button></form>';
294
308
295
                            return result;
309
                            return result;
296
310
297
- 

Return to bug 25288