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 482-488 function validate1(date) { Link Here
482
            [% IF ( itemtype_notforloan ) %]
482
            [% IF ( itemtype_notforloan ) %]
483
                Item type not for loan.
483
                Item type not for loan.
484
            [% ELSIF ( item_notforloan ) %]
484
            [% ELSIF ( item_notforloan ) %]
485
                [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
485
                [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
486
                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
486
                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
487
            [% END %]
487
            [% END %]
488
            </li>
488
            </li>
Lines 825-834 No patron matched <span class="ex">[% message %]</span> Link Here
825
        <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span>
825
        <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span>
826
826
827
            [% IF ( todayissue.itemlost ) %]
827
            [% IF ( todayissue.itemlost ) %]
828
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span>
828
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span>
829
            [% END %]
829
            [% END %]
830
            [% IF ( todayissue.damaged ) %]
830
            [% IF ( todayissue.damaged ) %]
831
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span>
831
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span>
832
            [% END %]
832
            [% END %]
833
        </td>
833
        </td>
834
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&amp;type=intra"><strong>[% todayissue.title |html %]</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>
834
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&amp;type=intra"><strong>[% todayissue.title |html %]</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 912-921 No patron matched <span class="ex">[% message %]</span> Link Here
912
        <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span>
912
        <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span>
913
913
914
            [% IF ( previssue.itemlost ) %]
914
            [% IF ( previssue.itemlost ) %]
915
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span>
915
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span>
916
            [% END %]
916
            [% END %]
917
            [% IF ( previssue.damaged ) %]
917
            [% IF ( previssue.damaged ) %]
918
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span>
918
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span>
919
            [% END %]
919
            [% END %]
920
        </td>
920
        </td>
921
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&amp;type=intra"><strong>[% previssue.title |html %]</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>
921
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&amp;type=intra"><strong>[% previssue.title |html %]</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 1050-1059 No patron matched <span class="ex">[% message %]</span> Link Here
1050
            <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td>
1050
            <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td>
1051
1051
1052
            [% IF ( relissue.itemlost ) %]
1052
            [% IF ( relissue.itemlost ) %]
1053
                <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span>
1053
                <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span>
1054
            [% END %]
1054
            [% END %]
1055
            [% IF ( relissue.damaged ) %]
1055
            [% IF ( relissue.damaged ) %]
1056
                <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span>
1056
                <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span>
1057
            [% END %]
1057
            [% END %]
1058
        </td>
1058
        </td>
1059
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% relissue.biblionumber %]&amp;type=intra"><strong>[% relissue.title |html %]</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>
1059
        <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% relissue.biblionumber %]&amp;type=intra"><strong>[% relissue.title |html %]</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