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

(-)a/C4/Circulation.pm (-4 / +3 lines)
Lines 35-48 use C4::Message; Link Here
35
use C4::Debug;
35
use C4::Debug;
36
use C4::Branch; # GetBranches
36
use C4::Branch; # GetBranches
37
use C4::Log; # logaction
37
use C4::Log; # logaction
38
use C4::Koha qw(
39
    GetAuthorisedValueByCode
40
);
41
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
38
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
42
use C4::RotatingCollections qw(GetCollectionItemBranches);
39
use C4::RotatingCollections qw(GetCollectionItemBranches);
43
use Algorithm::CheckDigits;
40
use Algorithm::CheckDigits;
44
41
45
use Data::Dumper;
42
use Data::Dumper;
43
use Koha::AuthorisedValues;
46
use Koha::DateUtils;
44
use Koha::DateUtils;
47
use Koha::Calendar;
45
use Koha::Calendar;
48
use Koha::Items;
46
use Koha::Items;
Lines 890-896 sub CanBookBeIssued { Link Here
890
        $issuingimpossible{RESTRICTED} = 1;
888
        $issuingimpossible{RESTRICTED} = 1;
891
    }
889
    }
892
    if ( $item->{'itemlost'} && C4::Context->preference("IssueLostItem") ne 'nothing' ) {
890
    if ( $item->{'itemlost'} && C4::Context->preference("IssueLostItem") ne 'nothing' ) {
893
        my $code = GetAuthorisedValueByCode( 'LOST', $item->{'itemlost'} );
891
        my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->{itemlost} });
892
        my $code = $av->count ? $av->next->lib : '';
894
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
893
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
895
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
894
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
896
    }
895
    }
(-)a/C4/Koha.pm (-22 lines)
Lines 57-63 BEGIN { Link Here
57
		&GetAuthorisedValues
57
		&GetAuthorisedValues
58
		&GetAuthorisedValueCategories
58
		&GetAuthorisedValueCategories
59
		&GetKohaAuthorisedValues
59
		&GetKohaAuthorisedValues
60
    &GetAuthorisedValueByCode
61
		&GetNormalizedUPC
60
		&GetNormalizedUPC
62
		&GetNormalizedISBN
61
		&GetNormalizedISBN
63
		&GetNormalizedEAN
62
		&GetNormalizedEAN
Lines 1041-1067 sub GetAuthorisedValueCategories { Link Here
1041
    return \@results;
1040
    return \@results;
1042
}
1041
}
1043
1042
1044
=head2 GetAuthorisedValueByCode
1045
1046
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
1047
1048
Return the lib attribute from authorised_values from the row identified
1049
by the passed category and code
1050
1051
=cut
1052
1053
sub GetAuthorisedValueByCode {
1054
    my ( $category, $authvalcode, $opac ) = @_;
1055
1056
    my $field = $opac ? 'lib_opac' : 'lib';
1057
    my $dbh = C4::Context->dbh;
1058
    my $sth = $dbh->prepare("SELECT $field FROM authorised_values WHERE category=? AND authorised_value =?");
1059
    $sth->execute( $category, $authvalcode );
1060
    while ( my $data = $sth->fetchrow_hashref ) {
1061
        return $data->{ $field };
1062
    }
1063
}
1064
1065
=head2 GetKohaAuthorisedValues
1043
=head2 GetKohaAuthorisedValues
1066
1044
1067
Takes $kohafield, $fwcode as parameters.
1045
Takes $kohafield, $fwcode as parameters.
(-)a/C4/Letters.pm (-2 / +4 lines)
Lines 28-34 use Carp; Link Here
28
use Template;
28
use Template;
29
use Module::Load::Conditional qw(can_load);
29
use Module::Load::Conditional qw(can_load);
30
30
31
use C4::Koha qw(GetAuthorisedValueByCode);
32
use C4::Members;
31
use C4::Members;
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
32
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use C4::Branch;
33
use C4::Branch;
Lines 830-836 sub _parseletter { Link Here
830
            #Therefore adding the test on biblio. This includes biblioitems,
829
            #Therefore adding the test on biblio. This includes biblioitems,
831
            #but excludes items. Removed unneeded global and lookahead.
830
            #but excludes items. Removed unneeded global and lookahead.
832
831
833
        $val = GetAuthorisedValueByCode ('ROADTYPE', $val, 0) if $table=~/^borrowers$/ && $field=~/^streettype$/;
832
        if ( $table=~/^borrowers$/ && $field=~/^streettype$/ ) {
833
            my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $val });
834
            $val = $av->count ? $av->next->lib : '';
835
        }
834
836
835
        # Dates replacement
837
        # Dates replacement
836
        my $replacedby   = defined ($val) ? $val : '';
838
        my $replacedby   = defined ($val) ? $val : '';
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (-8 / +6 lines)
Lines 25-31 use C4::Koha; Link Here
25
25
26
sub GetByCode {
26
sub GetByCode {
27
    my ( $self, $category, $code, $opac ) = @_;
27
    my ( $self, $category, $code, $opac ) = @_;
28
    return GetAuthorisedValueByCode( $category, $code, $opac );
28
    my $av = Koha::AuthorisedValues->search({ category => $category, authorised_value => $code });
29
    return $av->count
30
            ? $opac
31
                ? $av->next->opac_description
32
                : $av->next->lib
33
            : '';
29
}
34
}
30
35
31
sub Get {
36
sub Get {
Lines 59-71 Koha::Template::Plugin::AuthorisedValues - TT Plugin for authorised values Link Here
59
In a template, you can get the description for an authorised value with
64
In a template, you can get the description for an authorised value with
60
the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %]
65
the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %]
61
66
62
The parameters are identical to those used by the subroutine C4::Koha::GetAuthorisedValueByCode.
63
64
sub GetByCode {
65
    my ( $self, $category, $code, $opac ) = @_;
66
    return GetAuthorisedValueByCode( $category, $code, $opac );
67
}
68
69
=head2 GetAuthValueDropbox
67
=head2 GetAuthValueDropbox
70
68
71
The parameters are identical to those used by the subroutine C4::Koha::GetAuthValueDropbox
69
The parameters are identical to those used by the subroutine C4::Koha::GetAuthValueDropbox
(-)a/admin/patron-attr-types.pl (-1 / +4 lines)
Lines 32-37 use C4::Koha; Link Here
32
use C4::Members qw/GetBorrowercategoryList/;
32
use C4::Members qw/GetBorrowercategoryList/;
33
use C4::Members::AttributeTypes;
33
use C4::Members::AttributeTypes;
34
34
35
use Koha::AuthorisedValues;
36
35
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
37
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
36
38
37
our $input = new CGI;
39
our $input = new CGI;
Lines 295-301 sub patron_attribute_type_list { Link Here
295
            $attr->{branches} = $attr_type->branches;
297
            $attr->{branches} = $attr_type->branches;
296
            push @items, $attr;
298
            push @items, $attr;
297
        }
299
        }
298
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
300
        my $av = Koha::AuthorisedValues->search({ category => 'PA_CLASS', authorised_value => $class });
301
        my $lib = $av->count ? $av->next->lib : $class;
299
        push @attributes_loop, {
302
        push @attributes_loop, {
300
            class => $class,
303
            class => $class,
301
            items => \@items,
304
            items => \@items,
(-)a/circ/circulation.pl (-1 / +2 lines)
Lines 607-613 my $relatives_issues_count = Link Here
607
  Koha::Database->new()->schema()->resultset('Issue')
607
  Koha::Database->new()->schema()->resultset('Issue')
608
  ->count( { borrowernumber => \@relatives } );
608
  ->count( { borrowernumber => \@relatives } );
609
609
610
my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $borrower->{streettype} );
610
my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $borrower->{streettype} });
611
my $roadtype = $av->count ? $av->next->lib : '';
611
612
612
$template->param(%$borrower);
613
$template->param(%$borrower);
613
614
(-)a/members/memberentry.pl (-1 / +3 lines)
Lines 39-44 use C4::Log; Link Here
39
use C4::Letters;
39
use C4::Letters;
40
use C4::Branch; # GetBranches
40
use C4::Branch; # GetBranches
41
use C4::Form::MessagingPreferences;
41
use C4::Form::MessagingPreferences;
42
use Koha::AuthorisedValues;
42
use Koha::Patron::Debarments;
43
use Koha::Patron::Debarments;
43
use Koha::Cities;
44
use Koha::Cities;
44
use Koha::DateUtils;
45
use Koha::DateUtils;
Lines 792-798 sub patron_attributes_form { Link Here
792
        }
793
        }
793
    }
794
    }
794
    while ( my ($class, @items) = each %items_by_class ) {
795
    while ( my ($class, @items) = each %items_by_class ) {
795
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
796
        my $av = Koha::AuthorisedValues->search({ category => 'PA_CLASS', authorised_value => $class });
797
        my $lib = $av->count ? $av->next->lib : $class;
796
        push @attribute_loop, {
798
        push @attribute_loop, {
797
            class => $class,
799
            class => $class,
798
            items => @items,
800
            items => @items,
(-)a/members/moremember.pl (-1 / +4 lines)
Lines 51-56 use C4::Branch; # GetBranchName Link Here
51
use C4::Form::MessagingPreferences;
51
use C4::Form::MessagingPreferences;
52
use List::MoreUtils qw/uniq/;
52
use List::MoreUtils qw/uniq/;
53
use C4::Members::Attributes qw(GetBorrowerAttributes);
53
use C4::Members::Attributes qw(GetBorrowerAttributes);
54
use Koha::AuthorisedValues;
54
use Koha::Patron::Debarments qw(GetDebarments);
55
use Koha::Patron::Debarments qw(GetDebarments);
55
use Koha::Patron::Images;
56
use Koha::Patron::Images;
56
use Module::Load;
57
use Module::Load;
Lines 290-296 if (C4::Context->preference('ExtendedPatronAttributes')) { Link Here
290
        for my $attr (@$attributes) {
291
        for my $attr (@$attributes) {
291
            push @items, $attr if $attr->{class} eq $class
292
            push @items, $attr if $attr->{class} eq $class
292
        }
293
        }
293
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
294
        my $av = Koha::AuthorisedValues->search({ category => 'PA_CLASS', authorised_value => $class });
295
        my $lib = $av->count ? $av->next->lib : $class;
296
294
        push @attributes_loop, {
297
        push @attributes_loop, {
295
            class => $class,
298
            class => $class,
296
            items => \@items,
299
            items => \@items,
(-)a/reports/borrowers_stats.pl (-2 / +6 lines)
Lines 25-36 use C4::Auth; Link Here
25
use C4::Context;
25
use C4::Context;
26
use C4::Branch; # GetBranches
26
use C4::Branch; # GetBranches
27
use C4::Koha;
27
use C4::Koha;
28
use Koha::DateUtils;
29
use C4::Acquisition;
28
use C4::Acquisition;
30
use C4::Output;
29
use C4::Output;
31
use C4::Reports;
30
use C4::Reports;
32
use C4::Circulation;
31
use C4::Circulation;
33
use C4::Members::AttributeTypes;
32
use C4::Members::AttributeTypes;
33
34
use Koha::AuthorisedValues;
35
use Koha::DateUtils;
36
34
use Date::Calc qw(
37
use Date::Calc qw(
35
  Today
38
  Today
36
  Add_Delta_YM
39
  Add_Delta_YM
Lines 549-555 sub patron_attributes_form { Link Here
549
552
550
    my @attribute_loop;
553
    my @attribute_loop;
551
    foreach my $class ( sort keys %items_by_class ) {
554
    foreach my $class ( sort keys %items_by_class ) {
552
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
555
        my $av = Koha::AuthorisedValues->search({ category => 'PA_CLASS', authorised_value => $class });
556
        my $lib = $av->count ? $av->next->lib : $class;
553
        push @attribute_loop, {
557
        push @attribute_loop, {
554
            class => $class,
558
            class => $class,
555
            items => $items_by_class{$class},
559
            items => $items_by_class{$class},
(-)a/suggestion/suggestion.pl (-2 / +7 lines)
Lines 32-37 use C4::Members; Link Here
32
use C4::Debug;
32
use C4::Debug;
33
33
34
use Koha::DateUtils qw( dt_from_string );
34
use Koha::DateUtils qw( dt_from_string );
35
use Koha::AuthorisedValues;
35
use Koha::Acquisition::Currencies;
36
use Koha::Acquisition::Currencies;
36
37
37
use URI::Escape;
38
use URI::Escape;
Lines 56-67 sub GetCriteriumDesc{ Link Here
56
    my ($criteriumvalue,$displayby)=@_;
57
    my ($criteriumvalue,$displayby)=@_;
57
    if ($displayby =~ /status/i) {
58
    if ($displayby =~ /status/i) {
58
        unless ( grep { /$criteriumvalue/ } qw(ASKED ACCEPTED REJECTED CHECKED ORDERED AVAILABLE) ) {
59
        unless ( grep { /$criteriumvalue/ } qw(ASKED ACCEPTED REJECTED CHECKED ORDERED AVAILABLE) ) {
59
            return GetAuthorisedValueByCode('SUGGEST_STATUS', $criteriumvalue ) || "Unknown";
60
            my $av = Koha::AuthorisedValues->search({ category => 'SUGGEST_STATUS', authorised_value => $criteriumvalue });
61
            return $av->count ? $av->next->lib : 'Unkown';
60
        }
62
        }
61
        return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
63
        return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
62
    }
64
    }
63
    return (GetBranchName($criteriumvalue)) if ($displayby =~/branchcode/);
65
    return (GetBranchName($criteriumvalue)) if ($displayby =~/branchcode/);
64
    return GetAuthorisedValueByCode('SUGGEST_FORMAT', $criteriumvalue) || "Unknown" if ($displayby =~/itemtype/);
66
    if ( $displayby =~ /itemtype/ ) {
67
        my $av = Koha::AuthorisedValues->search({ category => 'SUGGEST_FORMAT', authorised_value => $criteriumvalue });
68
        return $av->count ? $av->next->lib : 'Unkown';
69
    }
65
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
70
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
66
        my $borr=C4::Members::GetMember(borrowernumber=>$criteriumvalue);
71
        my $borr=C4::Members::GetMember(borrowernumber=>$criteriumvalue);
67
        return "" unless $borr;
72
        return "" unless $borr;
(-)a/svc/checkouts (-4 / +19 lines)
Lines 26-35 use JSON qw(to_json); Link Here
26
use C4::Auth qw(check_cookie_auth haspermission get_session);
26
use C4::Auth qw(check_cookie_auth haspermission get_session);
27
use C4::Biblio qw(GetMarcBiblio GetFrameworkCode GetRecordValue );
27
use C4::Biblio qw(GetMarcBiblio GetFrameworkCode GetRecordValue );
28
use C4::Circulation qw(GetIssuingCharges CanBookBeRenewed GetRenewCount GetSoonestRenewDate);
28
use C4::Circulation qw(GetIssuingCharges CanBookBeRenewed GetRenewCount GetSoonestRenewDate);
29
use C4::Koha qw(GetAuthorisedValueByCode);
30
use C4::Overdues qw(GetFine);
29
use C4::Overdues qw(GetFine);
31
use C4::Context;
30
use C4::Context;
32
31
32
use Koha::AuthorisedValues;
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
34
35
my $input = new CGI;
35
my $input = new CGI;
Lines 146-151 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
146
      GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
146
      GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
147
147
148
    my $itemtype = C4::Koha::getitemtypeinfo( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
148
    my $itemtype = C4::Koha::getitemtypeinfo( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
149
    my $location;
150
    if ( $c->{location} ) {
151
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} });
152
        $location = $av->count ? $av->next->lib : '';
153
    }
154
    my $lost;
155
    if ( $c->{itemlost} ) {
156
        my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $c->{itemlost} });
157
        $lost = $av->count ? $av->next->lib : '';
158
    }
159
    my $damaged;
160
    if ( $c->{damaged} ) {
161
        my $av = Koha::AuthorisedValues->search({ category => 'DAMAGED', authorised_value => $c->{damaged} });
162
        $damaged = $av->count ? $av->next->lib : '';
163
    }
149
    my $checkout = {
164
    my $checkout = {
150
        DT_RowId             => $c->{itemnumber} . '-' . $c->{borrowernumber},
165
        DT_RowId             => $c->{itemnumber} . '-' . $c->{borrowernumber},
151
        title                => $c->{title},
166
        title                => $c->{title},
Lines 153-159 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
153
        barcode              => $c->{barcode},
168
        barcode              => $c->{barcode},
154
        itemtype             => $item_level_itypes ? $c->{itype} : $c->{itemtype},
169
        itemtype             => $item_level_itypes ? $c->{itype} : $c->{itemtype},
155
        itemtype_description => $itemtype->{translated_description},
170
        itemtype_description => $itemtype->{translated_description},
156
        location             => $c->{location} ? GetAuthorisedValueByCode( 'LOC', $c->{location} ) : q{},
171
        location             => $location
157
        itemnotes            => $c->{itemnotes},
172
        itemnotes            => $c->{itemnotes},
158
        itemnotes_nonpublic  => $c->{itemnotes_nonpublic},
173
        itemnotes_nonpublic  => $c->{itemnotes_nonpublic},
159
        branchcode           => $c->{branchcode},
174
        branchcode           => $c->{branchcode},
Lines 190-197 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
190
        ),
205
        ),
191
        subtitle =>
206
        subtitle =>
192
          GetRecordValue( 'subtitle', GetMarcBiblio( $c->{biblionumber} ), GetFrameworkCode( $c->{biblionumber} ) ),
207
          GetRecordValue( 'subtitle', GetMarcBiblio( $c->{biblionumber} ), GetFrameworkCode( $c->{biblionumber} ) ),
193
        lost    => $c->{itemlost} ? GetAuthorisedValueByCode( 'LOST',    $c->{itemlost} ) : undef,
208
        lost    => $lost,
194
        damaged => $c->{damaged}  ? GetAuthorisedValueByCode( 'DAMAGED', $c->{damaged} )  : undef,
209
        damaged => $damaged,
195
        borrower => {
210
        borrower => {
196
            surname    => $c->{surname},
211
            surname    => $c->{surname},
197
            firstname  => $c->{firstname},
212
            firstname  => $c->{firstname},
(-)a/t/db_dependent/Koha.t (-5 / +2 lines)
Lines 9-15 use Koha::DateUtils qw(dt_from_string); Link Here
9
use Koha::AuthorisedValue;
9
use Koha::AuthorisedValue;
10
use Koha::AuthorisedValueCategories;
10
use Koha::AuthorisedValueCategories;
11
11
12
use Test::More tests => 9;
12
use Test::More tests => 8;
13
use DateTime::Format::MySQL;
13
use DateTime::Format::MySQL;
14
14
15
BEGIN {
15
BEGIN {
Lines 48-56 subtest 'Authorized Values Tests' => sub { Link Here
48
48
49
# Tests
49
# Tests
50
    SKIP: {
50
    SKIP: {
51
        skip "INSERT failed", 4 unless $insert_success;
51
        skip "INSERT failed", 3 unless $insert_success;
52
53
        is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" );
54
52
55
        my $sortdet=C4::Members::GetSortDetails("lost", "3");
53
        my $sortdet=C4::Members::GetSortDetails("lost", "3");
56
        is ($sortdet, "Lost and Paid For", "lost and paid works");
54
        is ($sortdet, "Lost and Paid For", "lost and paid works");
57
- 

Return to bug 17252