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 2-8 Link Here
2
[% IF ( export_remove_fields OR export_with_csv_profile ) %]
2
[% IF ( export_remove_fields OR export_with_csv_profile ) %]
3
   [% SET exports_enabled = 1 %]
3
   [% SET exports_enabled = 1 %]
4
[% END %]
4
[% END %]
5
[% USE KohaAuthorisedValues %]
5
[% USE AuthorisedValues %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% SET destination = "circ" %]
7
[% SET destination = "circ" %]
8
<title>Koha &rsaquo; Circulation
8
<title>Koha &rsaquo; Circulation
Lines 370-376 function validate1(date) { Link Here
370
    [% IF ( itemtype_notforloan ) %]
370
    [% IF ( itemtype_notforloan ) %]
371
        Item type is normally not for loan.
371
        Item type is normally not for loan.
372
    [% ELSIF ( item_notforloan ) %]
372
    [% ELSIF ( item_notforloan ) %]
373
        [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
373
        [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
374
        Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
374
        Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
375
    [% END %]
375
    [% END %]
376
        Check out anyway?
376
        Check out anyway?
Lines 503-509 function validate1(date) { Link Here
503
            [% IF ( itemtype_notforloan ) %]
503
            [% IF ( itemtype_notforloan ) %]
504
                Item type not for loan.
504
                Item type not for loan.
505
            [% ELSIF ( item_notforloan ) %]
505
            [% ELSIF ( item_notforloan ) %]
506
                [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
506
                [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
507
                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
507
                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
508
            [% END %]
508
            [% END %]
509
            </li>
509
            </li>
Lines 846-855 No patron matched <span class="ex">[% message %]</span> Link Here
846
        <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span>
846
        <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span>
847
847
848
            [% IF ( todayissue.itemlost ) %]
848
            [% IF ( todayissue.itemlost ) %]
849
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span>
849
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span>
850
            [% END %]
850
            [% END %]
851
            [% IF ( todayissue.damaged ) %]
851
            [% IF ( todayissue.damaged ) %]
852
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span>
852
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span>
853
            [% END %]
853
            [% END %]
854
        </td>
854
        </td>
855
        <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>
855
        <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 933-942 No patron matched <span class="ex">[% message %]</span> Link Here
933
        <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span>
933
        <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span>
934
934
935
            [% IF ( previssue.itemlost ) %]
935
            [% IF ( previssue.itemlost ) %]
936
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span>
936
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span>
937
            [% END %]
937
            [% END %]
938
            [% IF ( previssue.damaged ) %]
938
            [% IF ( previssue.damaged ) %]
939
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span>
939
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span>
940
            [% END %]
940
            [% END %]
941
        </td>
941
        </td>
942
        <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>
942
        <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 1071-1080 No patron matched <span class="ex">[% message %]</span> Link Here
1071
            <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td>
1071
            <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td>
1072
1072
1073
            [% IF ( relissue.itemlost ) %]
1073
            [% IF ( relissue.itemlost ) %]
1074
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span>
1074
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span>
1075
            [% END %]
1075
            [% END %]
1076
            [% IF ( relissue.damaged ) %]
1076
            [% IF ( relissue.damaged ) %]
1077
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span>
1077
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span>
1078
            [% END %]
1078
            [% END %]
1079
        </td>
1079
        </td>
1080
        <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>
1080
        <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 224-230 $.tablesorter.addParser({ Link Here
224
                    [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
224
                    [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
225
                    [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
225
                    [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
226
                    [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
226
                    [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
227
                    [% ELSE %] [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %]
227
                    [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %]
228
228
229
                    [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %]
229
                    [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %]
230
                </td>
230
                </td>
231
- 

Return to bug 10626