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

(-)a/C4/Accounts.pm (-8 / +10 lines)
Lines 157-163 sub makepayment { Link Here
157
    #here we update both the accountoffsets and the account lines
157
    #here we update both the accountoffsets and the account lines
158
    #updated to check, if they are paying off a lost item, we return the item
158
    #updated to check, if they are paying off a lost item, we return the item
159
    # from their card, and put a note on the item record
159
    # from their card, and put a note on the item record
160
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
160
    my ( $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
161
    my $dbh = C4::Context->dbh;
161
    my $dbh = C4::Context->dbh;
162
    my $manager_id = 0;
162
    my $manager_id = 0;
163
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
163
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
Lines 197-210 sub makepayment { Link Here
197
197
198
         # create new line
198
         # create new line
199
        my $payment = 0 - $amount;
199
        my $payment = 0 - $amount;
200
        $payment_note = "" unless defined $payment_note;
200
        
201
        
201
        my $ins = 
202
        my $ins = 
202
            $dbh->prepare( 
203
            $dbh->prepare( 
203
                "INSERT 
204
                "INSERT 
204
                    INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding)
205
                    INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, note)
205
                    VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0)"
206
                    VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0, ?)"
206
            );
207
            );
207
        $ins->execute($borrowernumber, $nextaccntno, $payment);
208
        $ins->execute($borrowernumber, $nextaccntno, $payment, $payment_note);
208
        $ins->finish;
209
        $ins->finish;
209
    }
210
    }
210
211
Lines 724-733 sub recordpayment_selectaccts { Link Here
724
# makepayment needs to be fixed to handle partials till then this separate subroutine
725
# makepayment needs to be fixed to handle partials till then this separate subroutine
725
# fills in
726
# fills in
726
sub makepartialpayment {
727
sub makepartialpayment {
727
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
728
    my ( $borrowernumber, $accountno, $amount, $user, $branchm, $payment_note ) = @_;
728
    if (!$amount || $amount < 0) {
729
    if (!$amount || $amount < 0) {
729
        return;
730
        return;
730
    }
731
    }
732
    $payment_note = "" unless defined $payment_note;
731
    my $dbh = C4::Context->dbh;
733
    my $dbh = C4::Context->dbh;
732
734
733
    my $nextaccntno = getnextacctno($borrowernumber);
735
    my $nextaccntno = getnextacctno($borrowernumber);
Lines 743-753 sub makepartialpayment { Link Here
743
745
744
    # create new line
746
    # create new line
745
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
747
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
746
    .  'description, accounttype, amountoutstanding) '
748
    .  'description, accounttype, amountoutstanding, note) '
747
    . ' VALUES (?, ?, now(), ?, ?, ?, 0)';
749
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?)';
748
750
749
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
751
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
750
        "Payment, thanks - $user", 'Pay');
752
        "Payment, thanks - $user", 'Pay', $payment_note);
751
753
752
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
754
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
753
755
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+2 lines)
Lines 42-47 function confirmWriteoffAll() { Link Here
42
	<th>Fines &amp; Charges</th>
42
	<th>Fines &amp; Charges</th>
43
    <th>Sel</th>
43
    <th>Sel</th>
44
	<th>Description</th>
44
	<th>Description</th>
45
    <th>Payment Note</th>   
45
	<th>Account Type</th>
46
	<th>Account Type</th>
46
	<th>Notify id</th>
47
	<th>Notify id</th>
47
	<th>Level</th>
48
	<th>Level</th>
Lines 74-79 function confirmWriteoffAll() { Link Here
74
    [% END %]
75
    [% END %]
75
    </td>
76
    </td>
76
    <td>[% line.description %] [% line.title |html_entity %]</td>
77
    <td>[% line.description %] [% line.title |html_entity %]</td>
78
    <td><input type="text" name="payment_note_[% line.accountno %]"></input></td>
77
    <td>[% line.accounttype %]</td>
79
    <td>[% line.accounttype %]</td>
78
    <td>[% line.notify_id %]</td>
80
    <td>[% line.notify_id %]</td>
79
    <td>[% line.notify_level %]</td>
81
    <td>[% line.notify_level %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+2 lines)
Lines 103-108 function moneyFormat(textObj) { Link Here
103
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
103
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
104
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
104
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
105
    <input type="hidden" name="title" id="title" value="[% title %]" />
105
    <input type="hidden" name="title" id="title" value="[% title %]" />
106
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
106
    <table>
107
    <table>
107
    <tr>
108
    <tr>
108
        <th>Description</th>
109
        <th>Description</th>
Lines 158-163 function moneyFormat(textObj) { Link Here
158
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
159
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
159
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
160
    <input type="hidden" name="accountno" id="accountno" value="[% accountno %]" />
160
    <input type="hidden" name="title" id="title" value="[% title %]" />
161
    <input type="hidden" name="title" id="title" value="[% title %]" />
162
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
161
    <table>
163
    <table>
162
    <tr>
164
    <tr>
163
        <th>Description</th>
165
        <th>Description</th>
(-)a/members/pay.pl (-7 / +11 lines)
Lines 29-34 Link Here
29
use strict;
29
use strict;
30
use warnings;
30
use warnings;
31
31
32
use URI::Escape;
32
use C4::Context;
33
use C4::Context;
33
use C4::Auth;
34
use C4::Auth;
34
use C4::Output;
35
use C4::Output;
Lines 90-96 if ($writeoff_all) { Link Here
90
    my $itemno       = $input->param('itemnumber');
91
    my $itemno       = $input->param('itemnumber');
91
    my $account_type = $input->param('accounttype');
92
    my $account_type = $input->param('accounttype');
92
    my $amount       = $input->param('amount');
93
    my $amount       = $input->param('amount');
93
    writeoff( $accountno, $itemno, $account_type, $amount );
94
    my $payment_note = $input->param("payment_note");
95
    writeoff( $accountno, $itemno, $account_type, $amount, $payment_note );
94
}
96
}
95
97
96
for (@names) {
98
for (@names) {
Lines 110-116 add_accounts_to_template(); Link Here
110
output_html_with_http_headers $input, $cookie, $template->output;
112
output_html_with_http_headers $input, $cookie, $template->output;
111
113
112
sub writeoff {
114
sub writeoff {
113
    my ( $accountnum, $itemnum, $accounttype, $amount ) = @_;
115
    my ( $accountnum, $itemnum, $accounttype, $amount, $payment_note ) = @_;
116
    $payment_note = "" unless defined $payment_note;
114
117
115
    # if no item is attached to fine, make sure to store it as a NULL
118
    # if no item is attached to fine, make sure to store it as a NULL
116
    $itemnum ||= undef;
119
    $itemnum ||= undef;
Lines 118-124 sub writeoff { Link Here
118
    $writeoff_sth->execute( $accountnum, $borrowernumber );
121
    $writeoff_sth->execute( $accountnum, $borrowernumber );
119
122
120
    my $acct = getnextacctno($borrowernumber);
123
    my $acct = getnextacctno($borrowernumber);
121
    $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount );
124
    $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount, $payment_note);
122
125
123
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
126
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
124
127
Lines 180-190 sub redirect_to_paycollect { Link Here
180
    $redirect .=
183
    $redirect .=
181
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
184
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
182
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
185
    $redirect .= get_for_redirect( 'accountno',    "accountno$line_no",    0 );
183
    $redirect .= get_for_redirect( 'description',  "description$line_no",  0 );
184
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
186
    $redirect .= get_for_redirect( 'title',        "title$line_no",        0 );
185
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
187
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
186
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
188
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
187
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
189
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
190
    $redirect .= q{&} . 'payment_note' . q{=} . uri_escape $input->param("payment_note_$line_no");
188
    $redirect .= '&remote_user=';
191
    $redirect .= '&remote_user=';
189
    $redirect .= $user;
192
    $redirect .= $user;
190
    return print $input->redirect($redirect);
193
    return print $input->redirect($redirect);
Lines 202-208 sub writeoff_all { Link Here
202
            my $itemno    = $input->param("itemnumber$value");
205
            my $itemno    = $input->param("itemnumber$value");
203
            my $amount    = $input->param("amount$value");
206
            my $amount    = $input->param("amount$value");
204
            my $accountno = $input->param("accountno$value");
207
            my $accountno = $input->param("accountno$value");
205
            writeoff( $accountno, $itemno, $accounttype, $amount );
208
            my $payment_note = $input->param("payment_note_$value");
209
            writeoff( $accountno, $itemno, $accounttype, $amount, $payment_note );
206
        }
210
        }
207
    }
211
    }
208
212
Lines 282-289 sub get_writeoff_sth { Link Here
282
          . 'WHERE accountno=? and borrowernumber=?';
286
          . 'WHERE accountno=? and borrowernumber=?';
283
        $writeoff_sth = $dbh->prepare($sql);
287
        $writeoff_sth = $dbh->prepare($sql);
284
        my $insert =
288
        my $insert =
285
q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)}
289
q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,note)}
286
          . q{values (?,?,?,now(),?,'Writeoff','W')};
290
          . q{values (?,?,?,now(),?,'Writeoff','W',?)};
287
        $add_writeoff_sth = $dbh->prepare($insert);
291
        $add_writeoff_sth = $dbh->prepare($insert);
288
    }
292
    }
289
    return;
293
    return;
(-)a/members/paycollect.pl (-4 / +6 lines)
Lines 19-24 Link Here
19
19
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use URI::Escape;
22
use C4::Context;
23
use C4::Context;
23
use C4::Auth;
24
use C4::Auth;
24
use C4::Output;
25
use C4::Output;
Lines 55-60 my $individual = $input->param('pay_individual'); Link Here
55
my $writeoff     = $input->param('writeoff_individual');
56
my $writeoff     = $input->param('writeoff_individual');
56
my $select_lines = $input->param('selected');
57
my $select_lines = $input->param('selected');
57
my $select       = $input->param('selected_accts');
58
my $select       = $input->param('selected_accts');
59
my $payment_note = uri_unescape $input->param('payment_note');
58
my $accountno;
60
my $accountno;
59
61
60
if ( $individual || $writeoff ) {
62
if ( $individual || $writeoff ) {
Lines 83-88 if ( $individual || $writeoff ) { Link Here
83
        description       => $description,
85
        description       => $description,
84
        notify_id         => $notify_id,
86
        notify_id         => $notify_id,
85
        notify_level      => $notify_level,
87
        notify_level      => $notify_level,
88
        payment_note    => $payment_note,
86
    );
89
    );
87
} elsif ($select_lines) {
90
} elsif ($select_lines) {
88
    $total_due = $input->param('amt');
91
    $total_due = $input->param('amt');
Lines 100-111 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
100
        );
103
        );
101
    } else {
104
    } else {
102
        if ($individual) {
105
        if ($individual) {
103
            if ( $total_paid == $total_due ) {
106
            if ( $total_paid == $total_due ) { 
104
                makepayment( $borrowernumber, $accountno, $total_paid, $user,
107
                makepayment( $borrowernumber, $accountno, $total_paid, $user,
105
                    $branch );
108
                    $branch, $payment_note );
106
            } else {
109
            } else {
107
                makepartialpayment( $borrowernumber, $accountno, $total_paid,
110
                makepartialpayment( $borrowernumber, $accountno, $total_paid,
108
                    $user, $branch );
111
                    $user, $branch, $payment_note );
109
            }
112
            }
110
            print $input->redirect(
113
            print $input->redirect(
111
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
114
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
112
- 

Return to bug 6413