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

(-)a/C4/Members.pm (+62 lines)
Lines 100-105 BEGIN { Link Here
100
        &GetMessagesCount
100
        &GetMessagesCount
101
101
102
        &IssueSlip
102
        &IssueSlip
103
        &FineSlip
103
        GetBorrowersWithEmail
104
        GetBorrowersWithEmail
104
105
105
        HasOverdues
106
        HasOverdues
Lines 2394-2399 sub IssueSlip { Link Here
2394
    );
2395
    );
2395
}
2396
}
2396
2397
2398
2399
sub GetBorrowerFines {
2400
    my ($borrowernumber) = @_;
2401
    my $dbh       = C4::Context->dbh;
2402
    my $query = qq{
2403
        SELECT * FROM accountlines
2404
        LEFT JOIN borrowers ON borrowers.borrowernumber = accountlines.borrowernumber
2405
        LEFT JOIN items ON accountlines.itemnumber = items.itemnumber
2406
        WHERE accountlines.borrowernumber = ?
2407
        ORDER BY accountlines.timestamp
2408
    };
2409
    my $sth = $dbh->prepare( $query );
2410
    $sth->execute( $borrowernumber );
2411
    my $data = $sth->fetchall_arrayref({});
2412
    return $data;
2413
}
2414
2415
sub FineSlip {
2416
    my ($borrowernumber, $branch) = @_;
2417
2418
    #my $now       = POSIX::strftime("%Y-%m-%d", localtime);
2419
2420
    my $issueslist = GetBorrowerFines($borrowernumber);
2421
2422
    my $total = 0.0;
2423
2424
    foreach my $it (@$issueslist){
2425
        my $dt = dt_from_string( $it->{'date'} );
2426
        $it->{'date_due'} = output_pref({ dt => $dt, dateonly => 1 });
2427
        $it->{'amount'} = sprintf('%.2f', $it->{'amount'});
2428
        $total = $total + $it->{'amount'};
2429
        $it->{'barcode'} = '-' if (!defined($it->{'barcode'}));
2430
    }
2431
    my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist;
2432
2433
    my %repeat = (
2434
        'fines' => [ map {
2435
            'fines' => $_,
2436
            'borrowers' => $_,
2437
            'items' => $_
2438
                     }, @issues ],
2439
        );
2440
2441
    return  C4::Letters::GetPreparedLetter (
2442
        module => 'circulation',
2443
        letter_code => 'FINESLIP',
2444
        branchcode => $branch,
2445
        tables => {
2446
            'branches'    => $branch,
2447
            'borrowers'   => $borrowernumber,
2448
        },
2449
        substitute => {
2450
            'total.amount' => sprintf('%.2f', $total),
2451
            'total.fines' => scalar(@issues)
2452
        },
2453
        repeat => \%repeat,
2454
        message_transport_type => 'print',
2455
    );
2456
}
2457
2458
2397
=head2 GetBorrowersWithEmail
2459
=head2 GetBorrowersWithEmail
2398
2460
2399
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
2461
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
(-)a/installer/data/mysql/en/mandatory/sample_notices.sql (+15 lines)
Lines 142-144 Thank you. Link Here
142
142
143
Your library.'
143
Your library.'
144
);
144
);
145
146
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content, message_transport_type)
147
VALUES ( 'circulation', 'FINESLIP', '', 'Patron fines -slip', '1', 'Fines', '<<borrowers.firstname>> <<borrowers.surname>><br>
148
<<borrowers.cardnumber>><br>
149
Fines: <<total.fines>>
150
<ul>
151
<fines>
152
<li><<fines.date_due>>, $<<fines.amount>><br>
153
Bar code: <<items.barcode>><br>
154
<<fines.description>>
155
</fines>
156
</ul>
157
Total: $<<total.amount>>
158
', 'print'
159
);
(-)a/installer/data/mysql/updatedatabase.pl (+21 lines)
Lines 8465-8470 if ( CheckVersion($DBversion) ) { Link Here
8465
    SetVersion($DBversion);
8465
    SetVersion($DBversion);
8466
}
8466
}
8467
8467
8468
$DBversion = "3.15.00.XXX";
8469
if ( CheckVersion($DBversion) ) {
8470
    $dbh->do("
8471
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content, message_transport_type)
8472
VALUES ( 'circulation', 'FINESLIP', '', 'Patron fines -slip', '1', 'Fines', '<<borrowers.firstname>> <<borrowers.surname>><br>
8473
<<borrowers.cardnumber>><br>
8474
Fines: <<total.fines>>
8475
<ul>
8476
<fines>
8477
<li><<fines.date_due>>, $<<fines.amount>><br>
8478
Bar code: <<items.barcode>><br>
8479
<<fines.description>>
8480
</fines>
8481
</ul>
8482
Total: $<<total.amount>>
8483
', 'print'
8484
);");
8485
    print "Upgrade to $DBversion done (Bug 12285 - Allow easy printing of patron fines slip)\n";
8486
    SetVersion($DBversion);
8487
}
8488
8468
=head1 FUNCTIONS
8489
=head1 FUNCTIONS
8469
8490
8470
=head2 TableExists($table)
8491
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (+6 lines)
Lines 38-43 $(document).ready(function(){ Link Here
38
        $(".btn-group").removeClass("open");
38
        $(".btn-group").removeClass("open");
39
        return false;
39
        return false;
40
    });
40
    });
41
    $("#printfineslip").click(function(){
42
        printx_window("fineslip");
43
        $(".btn-group").removeClass("open");
44
        return false;
45
    });
41
    $("#searchtohold").click(function(){
46
    $("#searchtohold").click(function(){
42
        searchToHold();
47
        searchToHold();
43
        return false;
48
        return false;
Lines 124-129 function searchToHold(){ Link Here
124
                [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %]
129
                [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %]
125
                <li><a id="printslip" href="#">Print slip</a></li>
130
                <li><a id="printslip" href="#">Print slip</a></li>
126
                <li><a id="printquickslip" href="#">Print quick slip</a></li>
131
                <li><a id="printquickslip" href="#">Print quick slip</a></li>
132
                <li><a id="printfineslip" href="#">Print fines</a></li>
127
            </ul>
133
            </ul>
128
    </div>
134
    </div>
129
    <a id="searchtohold" class="btn btn-small" href="#"><i class="icon-search"></i> Search to hold</a>
135
    <a id="searchtohold" class="btn btn-small" href="#"><i class="icon-search"></i> Search to hold</a>
(-)a/members/printslip.pl (-2 / +5 lines)
Lines 76-82 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
76
my $borrowernumber = $input->param('borrowernumber');
76
my $borrowernumber = $input->param('borrowernumber');
77
my $branch=C4::Context->userenv->{'branch'};
77
my $branch=C4::Context->userenv->{'branch'};
78
my ($slip, $is_html);
78
my ($slip, $is_html);
79
if (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
79
if ($print eq 'fineslip') {
80
    my $letter = FineSlip($borrowernumber, $session->param('branch') || $branch);
81
    $slip = $letter->{content};
82
    $is_html = $letter->{is_html};
83
} elsif (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
80
    $slip = $letter->{content};
84
    $slip = $letter->{content};
81
    $is_html = $letter->{is_html};
85
    $is_html = $letter->{is_html};
82
}
86
}
83
- 

Return to bug 12285