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

(-)a/Koha/Template/Plugin/AuthorisedValues.pm (+12 lines)
Lines 26-31 use Encode qw{encode decode}; Link Here
26
26
27
use C4::Koha;
27
use C4::Koha;
28
28
29
=pod
30
31
To use, first, include the line '[% USE AuthorisedValues %]' at the top
32
of the template to enable the plugin.
33
34
Now, in a template, you can get the description for an authorised value with
35
the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %]
36
37
The parameters are identical to those used by the subroutine C4::Koha::GetAuthorisedValueByCode.
38
39
=cut
40
29
sub GetByCode {
41
sub GetByCode {
30
    my ( $self, $category, $code, $opac ) = @_;
42
    my ( $self, $category, $code, $opac ) = @_;
31
    return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) );
43
    return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) );
(-)a/Koha/Template/Plugin/KohaAuthorisedValues.pm (-50 lines)
Lines 1-50 Link Here
1
package Koha::Template::Plugin::KohaAuthorisedValues;
2
3
# Copyright ByWater Solutions 2012
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
27
=pod
28
29
This plugin allows one to get the description for an authorised value
30
from within a template.
31
32
First, include the line '[% USE KohaAuthorisedValues %]' at the top
33
of the template to enable the plugin.
34
35
To use, call KohaAuthorisedValues.GetByCode with the category
36
of the authorised value, the code to look up, and optionally,
37
the OPAC flag ( if set, it will return the OPAC description rather
38
than the Intranet description ).
39
40
For example: [% KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %]
41
will print the OPAC description for the LOST value stored in item.itemlost.
42
43
=cut
44
45
sub GetByCode {
46
    my ( $self, $category, $code, $opac ) = @_;
47
    return GetAuthorisedValueByCode( $category, $code, $opac );
48
}
49
50
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-9 / +9 lines)
Lines 3-9 Link Here
3
[% IF ( export_remove_fields OR export_with_csv_profile ) %]
3
[% IF ( export_remove_fields OR export_with_csv_profile ) %]
4
   [% SET exports_enabled = 1 %]
4
   [% SET exports_enabled = 1 %]
5
[% END %]
5
[% END %]
6
[% USE KohaAuthorisedValues %]
6
[% USE AuthorisedValues %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
[% SET destination = "circ" %]
8
[% SET destination = "circ" %]
9
<title>Koha &rsaquo; Circulation
9
<title>Koha &rsaquo; Circulation
Lines 371-377 function validate1(date) { Link Here
371
    [% IF ( itemtype_notforloan ) %]
371
    [% IF ( itemtype_notforloan ) %]
372
        Item type is normally not for loan.
372
        Item type is normally not for loan.
373
    [% ELSIF ( item_notforloan ) %]
373
    [% ELSIF ( item_notforloan ) %]
374
        [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
374
        [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
375
        Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
375
        Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
376
    [% END %]
376
    [% END %]
377
        Check out anyway?
377
        Check out anyway?
Lines 504-510 function validate1(date) { Link Here
504
            [% IF ( itemtype_notforloan ) %]
504
            [% IF ( itemtype_notforloan ) %]
505
                Item type not for loan.
505
                Item type not for loan.
506
            [% ELSIF ( item_notforloan ) %]
506
            [% ELSIF ( item_notforloan ) %]
507
                [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
507
                [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
508
                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
508
                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
509
            [% END %]
509
            [% END %]
510
            </li>
510
            </li>
Lines 847-856 No patron matched <span class="ex">[% message %]</span> Link Here
847
        <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span>
847
        <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span>
848
848
849
            [% IF ( todayissue.itemlost ) %]
849
            [% IF ( todayissue.itemlost ) %]
850
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span>
850
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span>
851
            [% END %]
851
            [% END %]
852
            [% IF ( todayissue.damaged ) %]
852
            [% IF ( todayissue.damaged ) %]
853
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span>
853
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span>
854
            [% END %]
854
            [% END %]
855
        </td>
855
        </td>
856
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&amp;type=intra"><strong>[% todayissue.title |html %][% FOREACH subtitl IN todayissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- <span class="circ-hlt">[% todayissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% todayissue.biblionumber %]&amp;itemnumber=[% todayissue.itemnumber %]#item[% todayissue.itemnumber %]">[% todayissue.barcode %]</a></td>
856
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&amp;type=intra"><strong>[% todayissue.title |html %][% FOREACH subtitl IN todayissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- <span class="circ-hlt">[% todayissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% todayissue.biblionumber %]&amp;itemnumber=[% todayissue.itemnumber %]#item[% todayissue.itemnumber %]">[% todayissue.barcode %]</a></td>
Lines 934-943 No patron matched <span class="ex">[% message %]</span> Link Here
934
        <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span>
934
        <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span>
935
935
936
            [% IF ( previssue.itemlost ) %]
936
            [% IF ( previssue.itemlost ) %]
937
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span>
937
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span>
938
            [% END %]
938
            [% END %]
939
            [% IF ( previssue.damaged ) %]
939
            [% IF ( previssue.damaged ) %]
940
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span>
940
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span>
941
            [% END %]
941
            [% END %]
942
        </td>
942
        </td>
943
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&amp;type=intra"><strong>[% previssue.title |html %][% FOREACH subtitl IN previssue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% previssue.biblionumber %]&amp;itemnumber=[% previssue.itemnumber %]#item[% previssue.itemnumber %]">[% previssue.barcode %]</a></td>
943
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&amp;type=intra"><strong>[% previssue.title |html %][% FOREACH subtitl IN previssue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% previssue.biblionumber %]&amp;itemnumber=[% previssue.itemnumber %]#item[% previssue.itemnumber %]">[% previssue.barcode %]</a></td>
Lines 1072-1081 No patron matched <span class="ex">[% message %]</span> Link Here
1072
            <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td>
1072
            <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td>
1073
1073
1074
            [% IF ( relissue.itemlost ) %]
1074
            [% IF ( relissue.itemlost ) %]
1075
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span>
1075
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span>
1076
            [% END %]
1076
            [% END %]
1077
            [% IF ( relissue.damaged ) %]
1077
            [% IF ( relissue.damaged ) %]
1078
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span>
1078
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span>
1079
            [% END %]
1079
            [% END %]
1080
        </td>
1080
        </td>
1081
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% relissue.biblionumber %]&amp;type=intra"><strong>[% relissue.title |html %][% FOREACH subtitl IN relissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( relissue.author ) %], by [% relissue.author %][% END %][% IF ( relissue.itemnotes ) %]- <span class="circ-hlt">[% relissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% relissue.biblionumber %]&amp;itemnumber=[% relissue.itemnumber %]#item[% relissue.itemnumber %]">[% relissue.barcode %]</a></td>
1081
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% relissue.biblionumber %]&amp;type=intra"><strong>[% relissue.title |html %][% FOREACH subtitl IN relissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( relissue.author ) %], by [% relissue.author %][% END %][% IF ( relissue.itemnotes ) %]- <span class="circ-hlt">[% relissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% relissue.biblionumber %]&amp;itemnumber=[% relissue.itemnumber %]#item[% relissue.itemnumber %]">[% relissue.barcode %]</a></td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-4 / +4 lines)
Lines 1-4 Link Here
1
[% USE KohaAuthorisedValues %]
1
[% USE AuthorisedValues %]
2
[% USE KohaBranchName %]
2
[% USE KohaBranchName %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions  &rsaquo;
4
<title>Koha &rsaquo; Acquisitions  &rsaquo;
Lines 431-437 $(document).ready(function() { calcNewsuggTotal(); }); Link Here
431
                [% ELSE %][% suggestion.suggestiontypelabel %][% END %]
431
                [% ELSE %][% suggestion.suggestiontypelabel %][% END %]
432
            [% ELSE %]
432
            [% ELSE %]
433
                [% IF ( suggestion.suggestiontype ) %]
433
                [% IF ( suggestion.suggestiontype ) %]
434
                    [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) %]
434
                    [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) %]
435
                [% ELSE %]
435
                [% ELSE %]
436
                    No name
436
                    No name
437
                [% END %]
437
                [% END %]
Lines 498-505 $(document).ready(function() { calcNewsuggTotal(); }); Link Here
498
                        Rejected
498
                        Rejected
499
                    [% ELSIF ( suggestions_loo.CHECKED ) %]
499
                    [% ELSIF ( suggestions_loo.CHECKED ) %]
500
                        Checked
500
                        Checked
501
                    [% ELSIF KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
501
                    [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
502
                        [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
502
                        [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
503
                    [% END %]
503
                    [% END %]
504
504
505
                    [% IF ( suggestions_loo.reason ) %]
505
                    [% IF ( suggestions_loo.reason ) %]
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc (-3 / +3 lines)
Lines 1-4 Link Here
1
[% USE KohaAuthorisedValues %]
1
[% USE AuthorisedValues %]
2
2
3
[% IF ( item.datedue ) %]
3
[% IF ( item.datedue ) %]
4
    [% IF ( OPACShowCheckoutName ) %]
4
    [% IF ( OPACShowCheckoutName ) %]
Lines 14-20 Link Here
14
[% ELSIF ( item.wthdrawn ) %]
14
[% ELSIF ( item.wthdrawn ) %]
15
    Item withdrawn
15
    Item withdrawn
16
[% ELSIF ( item.itemlost ) %]
16
[% ELSIF ( item.itemlost ) %]
17
    [% av_lib_include = KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %]
17
    [% av_lib_include = AuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %]
18
    [% IF ( av_lib_include ) %]
18
    [% IF ( av_lib_include ) %]
19
        [% av_lib_include %]
19
        [% av_lib_include %]
20
    [% ELSE %]
20
    [% ELSE %]
Lines 33-39 Link Here
33
[% ELSIF ( item.notforloan_per_itemtype ) %]
33
[% ELSIF ( item.notforloan_per_itemtype ) %]
34
    Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
34
    Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
35
[% ELSIF ( item.damaged ) %]
35
[% ELSIF ( item.damaged ) %]
36
    [% av_lib_include = KohaAuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %]
36
    [% av_lib_include = AuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %]
37
    [% IF av_lib_include %]
37
    [% IF av_lib_include %]
38
        [% av_lib_include %]
38
        [% av_lib_include %]
39
    [% ELSE %]
39
    [% ELSE %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt (-3 / +2 lines)
Lines 1-5 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaAuthorisedValues %]
2
[% USE AuthorisedValues %]
3
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo;
3
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo;
4
[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
4
[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
5
[% IF ( op_else ) %]Purchase Suggestions[% END %]
5
[% IF ( op_else ) %]Purchase Suggestions[% END %]
Lines 213-219 Link Here
213
                    [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
213
                    [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
214
                    [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
214
                    [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
215
                    [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
215
                    [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
216
                    [% ELSE %] [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %]
216
                    [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %]
217
217
218
                    [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %]
218
                    [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %]
219
                </td>
219
                </td>
220
- 

Return to bug 10626