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

(-)a/C4/Members.pm (+20 lines)
Lines 107-112 BEGIN { Link Here
107
        GetBorrowersWithEmail
107
        GetBorrowersWithEmail
108
108
109
        HasOverdues
109
        HasOverdues
110
        GetOverdues
110
    );
111
    );
111
112
112
    #Modify data
113
    #Modify data
Lines 2571-2576 WHERE borrowernumber = 0 AND DATEDIFF( NOW(), timestamp ) > ?|; Link Here
2571
    return $cnt eq '0E0'? 0: $cnt;
2572
    return $cnt eq '0E0'? 0: $cnt;
2572
}
2573
}
2573
2574
2575
sub GetOverdues {
2576
    my ( $borrowernumber ) = @_;
2577
2578
    my $sql = "
2579
        SELECT *
2580
        FROM issues, items, biblio, biblioitems
2581
        WHERE items.itemnumber=issues.itemnumber
2582
          AND biblio.biblionumber   = items.biblionumber
2583
          AND biblio.biblionumber   = biblioitems.biblionumber
2584
          AND issues.borrowernumber = ?
2585
          AND date_due < NOW()
2586
    ";
2587
2588
    my $sth = C4::Context->dbh->prepare( $sql );
2589
    $sth->execute( $borrowernumber );
2590
2591
    return $sth->fetchall_arrayref({});
2592
}
2593
2574
END { }    # module clean-up code here (global destructor)
2594
END { }    # module clean-up code here (global destructor)
2575
2595
2576
1;
2596
1;
(-)a/C4/Overdues.pm (+71 lines)
Lines 24-35 use strict; Link Here
24
use Date::Calc qw/Today Date_to_Days/;
24
use Date::Calc qw/Today Date_to_Days/;
25
use Date::Manip qw/UnixDate/;
25
use Date::Manip qw/UnixDate/;
26
use List::MoreUtils qw( uniq );
26
use List::MoreUtils qw( uniq );
27
use Locale::Currency::Format 1.28;
27
28
28
use C4::Circulation;
29
use C4::Circulation;
29
use C4::Context;
30
use C4::Context;
30
use C4::Accounts;
31
use C4::Accounts;
31
use C4::Log; # logaction
32
use C4::Log; # logaction
32
use C4::Debug;
33
use C4::Debug;
34
use C4::Budgets qw(GetCurrency);
33
35
34
use vars qw($VERSION @ISA @EXPORT);
36
use vars qw($VERSION @ISA @EXPORT);
35
37
Lines 53-58 BEGIN { Link Here
53
        &RemoveNotifyLine
55
        &RemoveNotifyLine
54
        &AddNotifyLine
56
        &AddNotifyLine
55
        &GetOverdueMessageTransportTypes
57
        &GetOverdueMessageTransportTypes
58
        &parse_letter
56
	);
59
	);
57
	# subs to remove
60
	# subs to remove
58
	push @EXPORT, qw(
61
	push @EXPORT, qw(
Lines 949-954 sub GetOverdueMessageTransportTypes { Link Here
949
    return \@mtts;
952
    return \@mtts;
950
}
953
}
951
954
955
=head2 parse_letter
956
957
parses the letter template, replacing the placeholders with data
958
specific to this patron, biblio, or item for overdues
959
960
named parameters:
961
  letter - required hashref
962
  borrowernumber - required integer
963
  substitute - optional hashref of other key/value pairs that should
964
    be substituted in the letter content
965
966
returns the C<letter> hashref, with the content updated to reflect the
967
substituted keys and values.
968
969
=cut
970
971
sub parse_letter {
972
    my $params = shift;
973
    foreach my $required (qw( letter_code borrowernumber )) {
974
        return unless ( exists $params->{$required} && $params->{$required} );
975
    }
976
977
    my $substitute = $params->{'substitute'} || {};
978
    $substitute->{today} ||= C4::Dates->new()->output("syspref");
979
980
    my %tables = ( 'borrowers' => $params->{'borrowernumber'} );
981
    if ( my $p = $params->{'branchcode'} ) {
982
        $tables{'branches'} = $p;
983
    }
984
985
    my $currencies = GetCurrency();
986
    my $currency_format;
987
    $currency_format = $currencies->{currency} if defined($currencies);
988
989
    my @item_tables;
990
    if ( my $i = $params->{'items'} ) {
991
        my $item_format = '';
992
        foreach my $item (@$i) {
993
            my $fine = GetFine($item->{'itemnumber'}, $params->{'borrowernumber'});
994
            if ( !$item_format and defined $params->{'letter'}->{'content'} ) {
995
                $params->{'letter'}->{'content'} =~ m/(<item>.*<\/item>)/;
996
                $item_format = $1;
997
            }
998
999
            $item->{'fine'} = currency_format($currency_format, "$fine", FMT_SYMBOL);
1000
            # if active currency isn't correct ISO code fallback to sprintf
1001
            $item->{'fine'} = sprintf('%.2f', $fine) unless $item->{'fine'};
1002
1003
            push @item_tables, {
1004
                'biblio' => $item->{'biblionumber'},
1005
                'biblioitems' => $item->{'biblionumber'},
1006
                'items' => $item,
1007
                'issues' => $item->{'itemnumber'},
1008
            };
1009
        }
1010
    }
1011
1012
    return C4::Letters::GetPreparedLetter (
1013
        module => 'circulation',
1014
        letter_code => $params->{'letter_code'},
1015
        branchcode => $params->{'branchcode'},
1016
        tables => \%tables,
1017
        substitute => $substitute,
1018
        repeat => { item => \@item_tables },
1019
        message_transport_type => $params->{message_transport_type},
1020
    );
1021
}
1022
952
1;
1023
1;
953
__END__
1024
__END__
954
1025
(-)a/Koha/Template/Plugin/Borrowers.pm (-1 / +11 lines)
Lines 22-28 use Modern::Perl; Link Here
22
22
23
use base qw( Template::Plugin );
23
use base qw( Template::Plugin );
24
24
25
use Koha::Borrower::Debarments qw//;
25
use Koha::Borrower::Debarments qw();
26
use C4::Members qw(HasOverdues);
26
27
27
=pod
28
=pod
28
29
Lines 48-51 sub IsDebarred { Link Here
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
49
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
49
}
50
}
50
51
52
sub HasOverdues {
53
    my ( $self, $borrowernumber ) = @_;
54
55
    return unless $borrowernumber;
56
57
    return C4::Members::HasOverdues($borrowernumber);
58
}
59
60
51
1;
61
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +10 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Borrowers %]
2
[% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
3
[% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
3
<script type="text/javascript">
4
<script type="text/javascript">
4
//<![CDATA[
5
//<![CDATA[
Lines 58-63 $(document).ready(function(){ Link Here
58
        $(".btn-group").removeClass("open");
59
        $(".btn-group").removeClass("open");
59
        return false;
60
        return false;
60
    });
61
    });
62
    $("#print_overdues").click(function(){
63
        window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=[% borrowernumber %]", "printwindow");
64
        $(".btn-group").removeClass("open");
65
        return false;
66
    });
61
    $("#searchtohold").click(function(){
67
    $("#searchtohold").click(function(){
62
        searchToHold();
68
        searchToHold();
63
        return false;
69
        return false;
Lines 153-159 function searchToHold(){ Link Here
153
            <ul class="dropdown-menu">
159
            <ul class="dropdown-menu">
154
                [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %]
160
                [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %]
155
                <li><a id="printslip" href="#">Print slip</a></li>
161
                <li><a id="printslip" href="#">Print slip</a></li>
156
                <li><a id="printquickslip" href="#">Print quick slip</a></li>
162
                <li><a id="printquickslip" href="#">Print quick slip[%  Borrowers.HasOverdues( borrowernumber ) %]</a></li>
163
                [% IF Borrowers.HasOverdues( borrowernumber ) %]
164
                    <li><a id="print_overdues" href="#">Print overdues</a></li>
165
                [% END %]
157
            </ul>
166
            </ul>
158
    </div>
167
    </div>
159
    <a id="searchtohold" class="btn btn-small" href="#"><i class="icon-search"></i> Search to hold</a>
168
    <a id="searchtohold" class="btn btn-small" href="#"><i class="icon-search"></i> Search to hold</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt (-1 / +3 lines)
Lines 1-11 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% IF ( caller = 'hold-transfer' ) %]
3
[% IF ( caller == 'hold-transfer' ) %]
4
<title>Koha &rsaquo; Circulation &rsaquo; Hold transfer print receipt</title>
4
<title>Koha &rsaquo; Circulation &rsaquo; Hold transfer print receipt</title>
5
[% ELSIF ( caller == 'transfer' ) %]
5
[% ELSIF ( caller == 'transfer' ) %]
6
<title>Koha &rsaquo; Circulation &rsaquo; Transfers print receipt</title>
6
<title>Koha &rsaquo; Circulation &rsaquo; Transfers print receipt</title>
7
[% ELSIF ( caller == 'members' ) %]
7
[% ELSIF ( caller == 'members' ) %]
8
<title>Koha &rsaquo; Members &rsaquo; Print receipt for [% borrowernumber %]</title>
8
<title>Koha &rsaquo; Members &rsaquo; Print receipt for [% borrowernumber %]</title>
9
[% ELSIF ( title ) %]
10
<title>Koha &rsaquo; Members &rsaquo; [% title %]</title>
9
[% END %]
11
[% END %]
10
12
11
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
(-)a/members/print_overdues.pl (+67 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
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 3 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 CGI;
23
24
use C4::Context;
25
use C4::Auth;
26
use C4::Output;
27
use C4::Members qw(GetOverdues);
28
use C4::Overdues qw(parse_letter);
29
30
my $input = new CGI;
31
32
my $flagsrequired = { circulate => "circulate_remaining_permissions" };
33
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
    {
36
        template_name   => "circ/printslip.tt",
37
        query           => $input,
38
        type            => "intranet",
39
        authnotrequired => 0,
40
        flagsrequired   => $flagsrequired,
41
        debug           => 1,
42
    }
43
);
44
45
my $borrowernumber = $input->param('borrowernumber');
46
my $branchcode     = C4::Context->userenv->{'branch'};
47
48
my $overdues = GetOverdues($borrowernumber);
49
50
my $letter = parse_letter(
51
    {
52
        letter_code            => 'OVERDUES_SLIP',
53
        borrowernumber         => $borrowernumber,
54
        branchcode             => $branchcode,
55
        items                  => $overdues,
56
        message_transport_type => 'print',
57
    }
58
);
59
60
$template->param(
61
    slip           => $letter->{content},
62
    title          => $letter->{name},
63
    plain          => !$letter->{is_html},
64
    borrowernumber => $borrowernumber,
65
);
66
67
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/misc/cronjobs/overdue_notices.pl (-71 / +1 lines)
Lines 43-52 use C4::Debug; Link Here
43
use C4::Letters;
43
use C4::Letters;
44
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
44
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
45
use C4::Budgets qw(GetCurrency);
45
use C4::Budgets qw(GetCurrency);
46
use C4::Log;
46
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
47
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
47
use Koha::DateUtils;
48
use Koha::DateUtils;
48
use Koha::Calendar;
49
use Koha::Calendar;
49
use C4::Log;
50
50
51
=head1 NAME
51
=head1 NAME
52
52
Lines 829-903 if ( defined $htmlfilename ) { Link Here
829
829
830
These methods are internal to the operation of overdue_notices.pl.
830
These methods are internal to the operation of overdue_notices.pl.
831
831
832
=head2 parse_letter
833
834
parses the letter template, replacing the placeholders with data
835
specific to this patron, biblio, or item
836
837
named parameters:
838
  letter - required hashref
839
  borrowernumber - required integer
840
  substitute - optional hashref of other key/value pairs that should
841
    be substituted in the letter content
842
843
returns the C<letter> hashref, with the content updated to reflect the
844
substituted keys and values.
845
846
847
=cut
848
849
sub parse_letter {
850
    my $params = shift;
851
    foreach my $required (qw( letter_code borrowernumber )) {
852
        return unless ( exists $params->{$required} && $params->{$required} );
853
    }
854
855
    my $substitute = $params->{'substitute'} || {};
856
    $substitute->{today} ||= C4::Dates->new()->output("syspref");
857
858
    my %tables = ( 'borrowers' => $params->{'borrowernumber'} );
859
    if ( my $p = $params->{'branchcode'} ) {
860
        $tables{'branches'} = $p;
861
    }
862
863
    my $currencies = GetCurrency();
864
    my $currency_format;
865
    $currency_format = $currencies->{currency} if defined($currencies);
866
867
    my @item_tables;
868
    if ( my $i = $params->{'items'} ) {
869
        my $item_format = '';
870
        foreach my $item (@$i) {
871
            my $fine = GetFine($item->{'itemnumber'}, $params->{'borrowernumber'});
872
            if ( !$item_format and defined $params->{'letter'}->{'content'} ) {
873
                $params->{'letter'}->{'content'} =~ m/(<item>.*<\/item>)/;
874
                $item_format = $1;
875
            }
876
877
            $item->{'fine'} = currency_format($currency_format, "$fine", FMT_SYMBOL);
878
            # if active currency isn't correct ISO code fallback to sprintf
879
            $item->{'fine'} = sprintf('%.2f', $fine) unless $item->{'fine'};
880
881
            push @item_tables, {
882
                'biblio' => $item->{'biblionumber'},
883
                'biblioitems' => $item->{'biblionumber'},
884
                'items' => $item,
885
                'issues' => $item->{'itemnumber'},
886
            };
887
        }
888
    }
889
890
    return C4::Letters::GetPreparedLetter (
891
        module => 'circulation',
892
        letter_code => $params->{'letter_code'},
893
        branchcode => $params->{'branchcode'},
894
        tables => \%tables,
895
        substitute => $substitute,
896
        repeat => { item => \@item_tables },
897
        message_transport_type => $params->{message_transport_type},
898
    );
899
}
900
901
=head2 prepare_letter_for_printing
832
=head2 prepare_letter_for_printing
902
833
903
returns a string of text appropriate for printing in the event that an
834
returns a string of text appropriate for printing in the event that an
904
- 

Return to bug 12933