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

(-)a/C4/Members.pm (+60 lines)
Lines 50-55 BEGIN { Link Here
50
      GetBorrowersToExpunge
50
      GetBorrowersToExpunge
51
51
52
      IssueSlip
52
      IssueSlip
53
      &FineSlip
53
54
54
      checkuserpassword
55
      checkuserpassword
55
      get_cardnumber_length
56
      get_cardnumber_length
Lines 683-688 WHERE borrowernumber = 0 AND DATEDIFF( NOW(), timestamp ) > ?|; Link Here
683
    return $cnt eq '0E0'? 0: $cnt;
684
    return $cnt eq '0E0'? 0: $cnt;
684
}
685
}
685
686
687
sub GetBorrowerFines {
688
    my ($borrowernumber) = @_;
689
    my $dbh       = C4::Context->dbh;
690
    my $query = qq{
691
        SELECT * FROM accountlines
692
        LEFT JOIN borrowers ON borrowers.borrowernumber = accountlines.borrowernumber
693
        LEFT JOIN items ON accountlines.itemnumber = items.itemnumber
694
        WHERE accountlines.borrowernumber = ?
695
        ORDER BY accountlines.timestamp
696
    };
697
    my $sth = $dbh->prepare( $query );
698
    $sth->execute( $borrowernumber );
699
    my $data = $sth->fetchall_arrayref({});
700
    return $data;
701
}
702
703
sub FineSlip {
704
    my ($borrowernumber, $branch) = @_;
705
706
    #my $now       = POSIX::strftime("%Y-%m-%d", localtime);
707
708
    my $issueslist = GetBorrowerFines($borrowernumber);
709
710
    my $total = 0.0;
711
712
    foreach my $it (@$issueslist){
713
        my $dt = dt_from_string( $it->{'date'} );
714
        $it->{'date_due'} = output_pref({ dt => $dt, dateonly => 1 });
715
        $it->{'amount'} = sprintf('%.2f', $it->{'amount'});
716
        $total = $total + $it->{'amount'};
717
        $it->{'barcode'} = '-' if (!defined($it->{'barcode'}));
718
    }
719
    my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist;
720
721
    my %repeat = (
722
        'fines' => [ map {
723
            'fines' => $_,
724
            'borrowers' => $_,
725
            'items' => $_
726
                     }, @issues ],
727
        );
728
729
    return  C4::Letters::GetPreparedLetter (
730
        module => 'circulation',
731
        letter_code => 'FINESLIP',
732
        branchcode => $branch,
733
        tables => {
734
            'branches'    => $branch,
735
            'borrowers'   => $borrowernumber,
736
        },
737
        substitute => {
738
            'total.amount' => sprintf('%.2f', $total),
739
            'total.fines' => scalar(@issues)
740
        },
741
        repeat => \%repeat,
742
        message_transport_type => 'print',
743
    );
744
}
745
686
END { }    # module clean-up code here (global destructor)
746
END { }    # module clean-up code here (global destructor)
687
747
688
1;
748
1;
(-)a/installer/data/mysql/atomicupdate/bug_12285-allow_easy_printing_of_patrons_fines.perl (+10 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
4
    # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
5
6
    $dbh->do( qq| INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ( "circulation", "FINESLIP", "", "Patron fines -slip", "1", "Fines and fees slip", "<<borrowers.firstname>> <<borrowers.surname>><br><<borrowers.cardnumber>><br>Fines: <<total.fines>><ul><fines><li><<fines.date_due>>, <<fines.amount>><br>Barcode: <<items.barcode>><br><<fines.description>></li></fines></ul>Total: <<total.amount>>", "print")| );
7
8
    # Always end with this (adjust the bug info)
9
    NewVersion( $DBversion, 12285, "Allow easy printing of patron's fines");
10
}
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (+23 lines)
Lines 1576-1578 tables: Link Here
1576
            - "This item must be renewed at the library."
1576
            - "This item must be renewed at the library."
1577
            - "[% END %]"
1577
            - "[% END %]"
1578
            - "[% END %]"
1578
            - "[% END %]"
1579
1580
        - module: circulation
1581
          code: FINESLIP
1582
          branchcode: ""
1583
          name: "Patron fines -slip"
1584
          is_html: 1
1585
          title: "Fines and fees slip"
1586
          message_transport_type: pront
1587
          lang: default
1588
          content:
1589
            - "<<borrowers.firstname>> <<borrowers.surname>><br>"
1590
            - "<<borrowers.cardnumber>><br>"
1591
            - "Fines: <<total.fines>>"
1592
            - "<ul>"
1593
            - "<fines>"
1594
            - "<li>""
1595
            - "<<fines.date_due>>, <<fines.amount>><br>"
1596
            - "Barcode: <<items.barcode>><br>"
1597
            - "<<fines.description>>"
1598
            - "</li>"
1599
            - "</fines>"
1600
            - "</ul>"
1601
            - "Total: <<total.amount>>"
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (+1 lines)
Lines 24-29 Link Here
24
                <li><a id="printsummary" href="#">Print summary</a></li>
24
                <li><a id="printsummary" href="#">Print summary</a></li>
25
                <li><a id="printslip" href="#">Print slip</a></li>
25
                <li><a id="printslip" href="#">Print slip</a></li>
26
                <li><a id="printquickslip" href="#">Print quick slip</a></li>
26
                <li><a id="printquickslip" href="#">Print quick slip</a></li>
27
                <li><a id="printfineslip" href="#">Print fines</a></li>
27
                [% IF patron.has_overdues %]
28
                [% IF patron.has_overdues %]
28
                    <li><a id="print_overdues" href="#">Print overdues</a></li>
29
                    <li><a id="print_overdues" href="#">Print overdues</a></li>
29
                [% END %]
30
                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js (+5 lines)
Lines 78-83 $(document).ready(function(){ Link Here
78
        $(".btn-group").removeClass("open");
78
        $(".btn-group").removeClass("open");
79
        return false;
79
        return false;
80
    });
80
    });
81
    $("#printfineslip").click(function(){
82
        printx_window("fineslip");
83
        $(".btn-group").removeClass("open");
84
        return false;
85
    });
81
    $("#printclearscreen").click(function(){
86
    $("#printclearscreen").click(function(){
82
        printx_window("slip");
87
        printx_window("slip");
83
        window.location.replace("/cgi-bin/koha/circ/circulation.pl");
88
        window.location.replace("/cgi-bin/koha/circ/circulation.pl");
(-)a/members/printslip.pl (-1 / +4 lines)
Lines 94-99 if ( $print eq 'checkinslip' ) { Link Here
94
    $slip    = $letter->{content};
94
    $slip    = $letter->{content};
95
    $is_html = $letter->{is_html};
95
    $is_html = $letter->{is_html};
96
96
97
} elsif ($print eq 'fineslip') {
98
    my $letter = C4::Members::FineSlip($borrowernumber, $session->param('branch') || $branch);
99
    $slip = $letter->{content};
100
    $is_html = $letter->{is_html};
97
} elsif (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
101
} elsif (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
98
    $slip = $letter->{content};
102
    $slip = $letter->{content};
99
    $is_html = $letter->{is_html};
103
    $is_html = $letter->{is_html};
100
- 

Return to bug 12285