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

(-)a/admin/authorised_values.pl (-15 / +23 lines)
Lines 124-141 if ($op eq 'add_form') { Link Here
124
	$imageurl = '' if $imageurl =~ /removeImage/;
124
	$imageurl = '' if $imageurl =~ /removeImage/;
125
    my $duplicate_entry = 0;
125
    my $duplicate_entry = 0;
126
    my @branches = $input->param('branches');
126
    my @branches = $input->param('branches');
127
    my $lib = $input->param('lib');
128
    my $lib_opac = $input->param('lib_opac');
129
    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
130
    undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
131
    my $category = $input->param('category');
132
    my $authorised_value;
127
133
128
    if ( $id ) { # Update
134
    if ( $id ) { # Update
129
        my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id = ? ");
135
        my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id = ? ");
130
        $sth->execute($id);
136
        $sth->execute($id);
131
        my ($category, $authorised_value) = $sth->fetchrow_array();
137
        ($category, $authorised_value) = $sth->fetchrow_array();
132
        if ( $authorised_value ne $new_authorised_value ) {
138
        if ( $authorised_value ne $new_authorised_value ) {
133
            my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " .
139
            my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " .
134
                "WHERE category = ? AND authorised_value = ? and id <> ? ");
140
                "WHERE category = ? AND authorised_value = ? and id <> ? ");
135
            $sth->execute($new_category, $new_authorised_value, $id);
141
            $sth->execute($new_category, $new_authorised_value, $id);
136
            ($duplicate_entry) = $sth->fetchrow_array();
142
            ($duplicate_entry) = $sth->fetchrow_array();
137
        }
143
        }
138
        unless ( $duplicate_entry ) {
144
145
        if ( !$duplicate_entry  && defined($lib)  && defined($lib_opac)) {
139
            my $sth=$dbh->prepare( 'UPDATE authorised_values
146
            my $sth=$dbh->prepare( 'UPDATE authorised_values
140
                                      SET category         = ?,
147
                                      SET category         = ?,
141
                                          authorised_value = ?,
148
                                          authorised_value = ?,
Lines 143-152 if ($op eq 'add_form') { Link Here
143
                                          lib_opac         = ?,
150
                                          lib_opac         = ?,
144
                                          imageurl         = ?
151
                                          imageurl         = ?
145
                                      WHERE id=?' );
152
                                      WHERE id=?' );
146
            my $lib = $input->param('lib');
147
            my $lib_opac = $input->param('lib_opac');
148
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
149
            undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
150
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id);
153
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id);
151
            if ( @branches ) {
154
            if ( @branches ) {
152
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
155
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
Lines 171-184 if ($op eq 'add_form') { Link Here
171
            "WHERE category = ? AND authorised_value = ? ");
174
            "WHERE category = ? AND authorised_value = ? ");
172
        $sth->execute($new_category, $new_authorised_value);
175
        $sth->execute($new_category, $new_authorised_value);
173
        ($duplicate_entry) = $sth->fetchrow_array();
176
        ($duplicate_entry) = $sth->fetchrow_array();
174
        unless ( $duplicate_entry ) {
177
178
        if ( !$duplicate_entry  && defined($lib)  && defined($lib_opac)) {
175
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
179
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
176
                                    ( category, authorised_value, lib, lib_opac, imageurl )
180
                                    ( category, authorised_value, lib, lib_opac, imageurl )
177
                                    values (?, ?, ?, ?, ?)' );
181
                                    values (?, ?, ?, ?, ?)' );
178
    	    my $lib = $input->param('lib');
179
    	    my $lib_opac = $input->param('lib_opac');
180
    	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
181
    	    undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
182
            $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl );
182
            $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl );
183
            $id = $dbh->{'mysql_insertid'};
183
            $id = $dbh->{'mysql_insertid'};
184
            if ( @branches ) {
184
            if ( @branches ) {
Lines 192-198 if ($op eq 'add_form') { Link Here
192
                    $sth->execute($id, $branchcode);
192
                    $sth->execute($id, $branchcode);
193
                }
193
                }
194
            }
194
            }
195
            my $category = $input->param('category');
196
            print $input->redirect("/cgi-bin/koha/admin/authorised_values.pl?searchfield=$category&amp;offset=$offset");
195
            print $input->redirect("/cgi-bin/koha/admin/authorised_values.pl?searchfield=$category&amp;offset=$offset");
197
            exit;
196
            exit;
198
        }
197
        }
Lines 201-209 if ($op eq 'add_form') { Link Here
201
        $template->param(duplicate_category => $new_category,
200
        $template->param(duplicate_category => $new_category,
202
                         duplicate_value =>  $new_authorised_value,
201
                         duplicate_value =>  $new_authorised_value,
203
                         else => 1);
202
                         else => 1);
204
        default_form();
203
    }
205
     }           
204
    if ( !defined($lib) ) {
206
	
205
        $template->param(BadLib => 1,
206
                         else => 1);
207
    }
208
    if ( !defined($lib_opac) ) {
209
        $template->param(BadLibOpac => 1,
210
                         else => 1);
211
    }
212
    $searchfield=$category;
213
    default_form();
214
207
################## DELETE_CONFIRM ##################################
215
################## DELETE_CONFIRM ##################################
208
# called by default form, used to confirm deletion of data in DB
216
# called by default form, used to confirm deletion of data in DB
209
} elsif ($op eq 'delete_confirm') {
217
} elsif ($op eq 'delete_confirm') {
(-)a/installer/data/mysql/atomicupdate/bug-13399-fix-empty-authorised-value-descriptions.sql (+39 lines)
Line 0 Link Here
1
-- Attempt to correct the OPAC and Staff Client authorised value
2
-- descriptions from each other.
3
-- Update staff client authorised values description
4
UPDATE authorised_values
5
    SET    lib=lib_opac
6
    WHERE (lib IS NULL OR lib='');
7
8
-- Update OPAC authorised values description
9
UPDATE authorised_values
10
    SET    lib_opac=lib
11
    WHERE (lib_opac IS NULL OR lib_opac='');
12
13
-- However, they might both be blank, so attempt authorised_value
14
-- Update staff client authorised values description
15
UPDATE authorised_values
16
    SET    lib=authorised_value
17
    WHERE (lib IS NULL OR lib='');
18
19
-- Update OPAC authorised values description
20
UPDATE authorised_values
21
    SET    lib_opac=authorised_value
22
    WHERE (lib_opac IS NULL OR lib_opac='');
23
24
-- In the extremely unlikely event they are still blank, attempt
25
-- category
26
-- Update staff client authorised values description
27
UPDATE authorised_values
28
    SET    lib=category
29
    WHERE (lib IS NULL OR lib='');
30
31
-- Update OPAC authorised values description
32
UPDATE authorised_values
33
    SET    lib_opac=category
34
    WHERE (lib_opac IS NULL OR lib_opac='');
35
36
-- Update authorised values code, in the case it is blank.
37
UPDATE authorised_values
38
    SET    authorised_value=category
39
    WHERE (authorised_value IS NULL OR authorised_value='');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-2 / +7 lines)
Lines 194-202 $(document).ready(function() { Link Here
194
<div class="dialog alert">Could not add value &quot;[% duplicate_value %]&quot; for category &quot;[% duplicate_category %]&quot; &mdash; value already present.
194
<div class="dialog alert">Could not add value &quot;[% duplicate_value %]&quot; for category &quot;[% duplicate_category %]&quot; &mdash; value already present.
195
</div>
195
</div>
196
[% END %]
196
[% END %]
197
[% IF ( BadLib ) %]
198
<div class="dialog alert">Staff client authorized value missing description</div>
199
[% END %]
200
[% IF ( BadLibOpac ) %]
201
<div class="dialog alert">OPAC authorized value missing description</div>
202
[% END %]
197
<form action="/cgi-bin/koha/admin/authorised_values.pl" method="post" id="category">
203
<form action="/cgi-bin/koha/admin/authorised_values.pl" method="post" id="category">
198
    <label for="searchfield">Show category: </label>
204
    <label for="searchfield">Show category: </label>
199
    <select name="searchfield" id="searchfield" size="1">
205
    <select name="searchfield" id="searchfield" value="[% tab_list.default %]">
200
    [% FOREACH value IN tab_list.values %]
206
    [% FOREACH value IN tab_list.values %]
201
    [% IF ( value == tab_list.default ) %]
207
    [% IF ( value == tab_list.default ) %]
202
        <option value="[% value %]" selected="selected">[% value %]</option>
208
        <option value="[% value %]" selected="selected">[% value %]</option>
203
- 

Return to bug 13399