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

(-)a/admin/z3950servers.pl (-9 / +28 lines)
Lines 30-35 use C4::Auth qw( get_template_and_user ); Link Here
30
use C4::Output qw( output_html_with_http_headers );
30
use C4::Output qw( output_html_with_http_headers );
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::Z3950Servers;
32
use Koha::Z3950Servers;
33
use Try::Tiny qw( catch try );
33
34
34
# Initialize CGI, template, database
35
# Initialize CGI, template, database
35
36
Lines 67-84 if ( $op eq 'cud-delete_confirmed' && $id ) { Link Here
67
        recordtype checked servername servertype sru_options sru_fields attributes
68
        recordtype checked servername servertype sru_options sru_fields attributes
68
        add_xslt/;
69
        add_xslt/;
69
    my $formdata = _form_data_hashref( $input, \@fields );
70
    my $formdata = _form_data_hashref( $input, \@fields );
71
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
72
70
    if ($id) {
73
    if ($id) {
71
        my $server = Koha::Z3950Servers->find($id);
74
        my $server = Koha::Z3950Servers->find($id);
72
        if ($server) {
75
        if ($server) {
73
            $server->set($formdata)->store;
76
            try {
74
            $template->param( msg_updated => 1, msg_add => $formdata->{servername} );
77
                $server->set($formdata)->store;
78
                $server->replace_library_limits( \@branches );
79
                $template->param( msg_updated => 1, msg_add => $formdata->{servername} );
80
            } catch {
81
                $template->param( msg_error => 1, msg_add => $formdata->{servername} );
82
            };
75
        } else {
83
        } else {
76
            $template->param( msg_notfound => 1, msg_add => $id );
84
            $template->param( msg_notfound => 1, msg_add => $id );
77
        }
85
        }
78
        $id = 0;
86
        $id = 0;
79
    } else {
87
    } else {
80
        Koha::Z3950Server->new($formdata)->store;
88
        try {
81
        $template->param( msg_added => 1, msg_add => $formdata->{servername} );
89
            my $server = Koha::Z3950Server->new($formdata)->store;
90
            $server->replace_library_limits( \@branches );
91
            $template->param( msg_added => 1, msg_add => $formdata->{servername} );
92
        } catch {
93
            $template->param( msg_error => 1, msg_add => $formdata->{servername} );
94
        };
82
    }
95
    }
83
} elsif ( $op eq 'search' ) {
96
} elsif ( $op eq 'search' ) {
84
97
Lines 91-105 if ( $op eq 'cud-delete_confirmed' && $id ) { Link Here
91
my $data = [];
104
my $data = [];
92
if ( $op eq 'add' || $op eq 'edit' ) {
105
if ( $op eq 'add' || $op eq 'edit' ) {
93
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
106
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
94
    delete $data->[0]->{id}                            if @$data && $op eq 'add';    #cloning record
107
    my $server = $data ? $data->next : undef;
108
    if ( $server && $op eq 'add' ) {
109
110
        # Cloning record - remove id
111
        $server = $server->unblessed;
112
        delete $server->{id};
113
    }
95
    $template->param(
114
    $template->param(
96
        add_form => 1, server => @$data ? $data->[0] : undef,
115
        add_form => 1,   server => $server,
97
        op => $op, type => $op eq 'add' ? lc $type : ''
116
        op       => $op, type   => $op eq 'add' ? lc $type : ''
98
    );
117
    );
99
} else {
118
} else {
100
    $data = ServerSearch( $schema, $id, $searchfield );
119
    $data = ServerSearch( $schema, $id, $searchfield );
101
    $template->param(
120
    $template->param(
102
        loop => \@$data, searchfield => $searchfield, id => $id,
121
        loop => $data, searchfield => $searchfield, id => $id,
103
        op   => 'list'
122
        op   => 'list'
104
    );
123
    );
105
}
124
}
Lines 112-118 sub ServerSearch { #find server(s) by id or name Link Here
112
131
113
    return Koha::Z3950Servers->search(
132
    return Koha::Z3950Servers->search(
114
        $id ? { id => $id } : { servername => { like => $searchstring . '%' } },
133
        $id ? { id => $id } : { servername => { like => $searchstring . '%' } },
115
    )->unblessed;
134
    );
116
}
135
}
117
136
118
sub _form_data_hashref {
137
sub _form_data_hashref {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt (-2 / +31 lines)
Lines 2-7 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Asset %]
3
[% USE Asset %]
4
[% USE HtmlTags %]
4
[% USE HtmlTags %]
5
[% USE Branches %]
5
[% PROCESS 'i18n.inc' %]
6
[% PROCESS 'i18n.inc' %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
Lines 198-203 Link Here
198
                        <input type="text" name="add_xslt" id="add_xslt" size="100" value="[% server.add_xslt | html %]" />
199
                        <input type="text" name="add_xslt" id="add_xslt" size="100" value="[% server.add_xslt | html %]" />
199
                        <div class="hint">Separate multiple filenames by commas.</div>
200
                        <div class="hint">Separate multiple filenames by commas.</div>
200
                    </li>
201
                    </li>
202
                    <li>
203
                        <label for="library_limitation">Library limitation: </label>
204
                        <select id="library_limitation" name="branches" multiple size="10">
205
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => server.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
206
                        </select>
207
                        <div class="hint">Limits the use of this server to the selected libraries.</div>
208
                    </li>
201
                </ol>
209
                </ol>
202
            </fieldset>
210
            </fieldset>
203
211
Lines 220-226 Link Here
220
                <thead
228
                <thead
221
                    ><tr
229
                    ><tr
222
                        ><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>Attributes</th
230
                        ><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>Attributes</th
223
                        ><th class="no-export no-sort">Actions</th>
231
                        ><th>Library limitations</th><th class="no-export no-sort">Actions</th>
224
                    </tr></thead
232
                    </tr></thead
225
                >
233
                >
226
                <tbody>
234
                <tbody>
Lines 237-242 Link Here
237
                                [% END %]
245
                                [% END %]
238
                            </td>
246
                            </td>
239
                            <td>[% loo.attributes | html %]</td>
247
                            <td>[% loo.attributes | html %]</td>
248
                            <td>
249
                                [% SET library_limits = loo.library_limits %]
250
                                [% IF library_limits && library_limits.count > 0 %]
251
                                    [% library_str = "" %]
252
                                    [% FOREACH library IN library_limits %]
253
                                        [%- IF loop.first -%]
254
                                            [% library_str = library.branchname _ " (" _ library.branchcode _ ")" %]
255
                                        [% ELSE %]
256
                                            [% library_str = library_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
257
                                        [% END %]
258
                                    [% END %]
259
                                    <span class="library_limitation" data-bs-toggle="tooltip" title="[% library_str | html %]">
260
                                        [% IF library_limits.count > 1 %]
261
                                            <span>[% library_limits.count | html %] library limitations</span>
262
                                        [% ELSE %]
263
                                            <span>[% library_limits.count | html %] library limitation</span>
264
                                        [% END %]
265
                                    </span>
266
                                [% ELSE %]
267
                                    <span>No limitation</span>
268
                                [% END %]
269
                            </td>
240
                            <td>
270
                            <td>
241
                                <div class="btn-group dropup">
271
                                <div class="btn-group dropup">
242
                                    <a class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-bs-toggle="dropdown" href="#"> Actions </a>
272
                                    <a class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-bs-toggle="dropdown" href="#"> Actions </a>
243
- 

Return to bug 40481