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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (+82 lines)
Lines 84-89 Link Here
84
        [% IF account.is_credit %]
84
        [% IF account.is_credit %]
85
          <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id | uri %]&amp;borrowernumber=[% account.borrowernumber | uri %]" class="btn btn-default btn-xs void"><i class="fa fa-ban"></i> Void</a>
85
          <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id | uri %]&amp;borrowernumber=[% account.borrowernumber | uri %]" class="btn btn-default btn-xs void"><i class="fa fa-ban"></i> Void</a>
86
        [% END %]
86
        [% END %]
87
        [% IF CAN_user_updatecharges_payout && account.is_credit && ( account.amountoutstanding < 0 ) %]
88
          <button type="button" data-toggle="modal" data-target="#issuePayoutModal" data-account="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue payout</button>
89
        [% END %]
87
      </td>
90
      </td>
88
    </tr>
91
    </tr>
89
92
Lines 113-118 Link Here
113
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
116
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
114
     </div> <!-- /.row -->
117
     </div> <!-- /.row -->
115
118
119
    <!-- Issue payout modal -->
120
    <div class="modal" id="issuePayoutModal" tabindex="-1" role="dialog" aria-labelledby="issuePayoutLabel">
121
        <form  id="payout_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated">
122
            <input type="hidden" name="accountlines_id" value="" id="payoutline">
123
            <input type="hidden" name="action" value="payout">
124
            <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]">
125
            <div class="modal-dialog" role="document">
126
                <div class="modal-content">
127
                    <div class="modal-header">
128
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
129
                        <h4 class="modal-title" id="issuePayoutLabel">Issue payout</h4>
130
                    </div>
131
                    <div class="modal-body">
132
                        <fieldset class="rows">
133
                            <ol>
134
                                <li>
135
                                    <span id="item" class="label">Account: </span><span></span>
136
                                </li>
137
                                <li>
138
                                    <span id="paid" class="label">Amount outstanding: </span><span>[% payout.amount | $Price %]</span>
139
                                </li>
140
                                <li>
141
                                    <label class="required" for="amount">Returned to patron: </label>
142
                                    <input type="number" step="0.01" id="amount" name="amount" min="0.00" required="required">
143
                                    <span class="required">Required</span>
144
                                </li>
145
                                [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
146
                                [% IF payment_types %]
147
                                <li>
148
                                    <label for="transaction_type">Transaction type: </label>
149
                                    <select name="transaction_type" id="transaction_type">
150
                                        [% FOREACH pt IN payment_types %]
151
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
152
                                        [% END %]
153
                                    </select>
154
                                </li>
155
                                [% END %]
156
157
                                [% IF Koha.Preference('UseCashRegisters') %]
158
                                <li>
159
                                    <label for="cash_register">Cash register: </label>
160
                                    <select name="cash_register" id="cash_register">
161
                                        [% FOREACH register IN registers %]
162
                                          [% IF register.id == registerid %]
163
                                        <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
164
                                          [% ELSE %]
165
                                        <option value="[% register.id | html %]">[% register.name | html %]</option>
166
                                          [% END %]
167
                                        [% END %]
168
                                    </select>
169
                                </li>
170
                                [% END %]
171
172
                            </ol>
173
                        </fieldset> <!-- /.rows -->
174
                    </div> <!-- /.modal-body -->
175
                    <div class="modal-footer">
176
                        <input type="hidden" name="registerid" value="[% register.id | html %]">
177
                        <input type="hidden" name="op" value="payout">
178
                        <button type="submit" class="btn btn-default">Confirm</button>
179
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
180
                    </div> <!-- /.modal-footer -->
181
                </div> <!-- /.modal-content -->
182
            </div> <!-- /.modal-dialog -->
183
        </form> <!-- /#payout_form -->
184
    </div> <!-- /#issuePayoutModal -->
185
116
[% MACRO jsinclude BLOCK %]
186
[% MACRO jsinclude BLOCK %]
117
    [% INCLUDE 'datatables.inc' %]
187
    [% INCLUDE 'datatables.inc' %]
118
    [% INCLUDE 'columns_settings.inc' %]
188
    [% INCLUDE 'columns_settings.inc' %]
Lines 157-162 Link Here
157
                    e.preventDefault();
227
                    e.preventDefault();
158
                }
228
                }
159
            });
229
            });
230
231
            $("#issuePayoutModal").on("shown.bs.modal", function(e){
232
                var button = $(e.relatedTarget);
233
                var account = button.data('account');
234
                $("#account + span").replaceWith(account);
235
                var accountline = button.data('accountline');
236
                $('#payoutline').val(accountline);
237
                var amount = button.data('amount') * -1;
238
                $("#paid + span").replaceWith(amount);
239
                $("#amount").attr({ "value": amount, "max": amount });
240
                $("#amount, #transaction_type").focus();
241
            });
160
        });
242
        });
161
    </script>
243
    </script>
162
[% END %]
244
[% END %]
(-)a/members/boraccount.pl (-1 / +51 lines)
Lines 29-34 use C4::Output; Link Here
29
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
30
use C4::Members;
30
use C4::Members;
31
use C4::Accounts;
31
use C4::Accounts;
32
use Koha::Cash::Registers;
32
use Koha::Patrons;
33
use Koha::Patrons;
33
use Koha::Patron::Categories;
34
use Koha::Patron::Categories;
34
35
Lines 47-58 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
47
    }
48
    }
48
);
49
);
49
50
51
my $schema         = Koha::Database->new->schema;
50
my $borrowernumber = $input->param('borrowernumber');
52
my $borrowernumber = $input->param('borrowernumber');
51
my $payment_id     = $input->param('payment_id');
53
my $payment_id     = $input->param('payment_id');
52
my $change_given   = $input->param('change_given');
54
my $change_given   = $input->param('change_given');
53
my $action         = $input->param('action') || '';
55
my $action         = $input->param('action') || '';
54
56
55
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
57
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
58
my $library_id = C4::Context->userenv->{'branch'};
56
my $patron = Koha::Patrons->find( $borrowernumber );
59
my $patron = Koha::Patrons->find( $borrowernumber );
57
unless ( $patron ) {
60
unless ( $patron ) {
58
    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
61
    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
Lines 61-72 unless ( $patron ) { Link Here
61
64
62
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
65
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
63
66
67
my $registerid;
68
if ( C4::Context->preference('UseCashRegisters') ) {
69
    $registerid = scalar $input->param('registerid');
70
    my $registers  = Koha::Cash::Registers->search(
71
        { branch   => $library_id, archived => 0 },
72
        { order_by => { '-asc' => 'name' } }
73
    );
74
75
    if ( !$registers->count ) {
76
        $template->param( error_registers => 1 );
77
    }
78
    else {
79
80
        if ( !$registerid ) {
81
            my $default_register = Koha::Cash::Registers->find(
82
                { branch => $library_id, branch_default => 1 } );
83
            $registerid = $default_register->id if $default_register;
84
        }
85
        $registerid = $registers->next->id if !$registerid;
86
87
        $template->param(
88
            registerid => $registerid,
89
            registers  => $registers,
90
        );
91
    }
92
}
93
64
if ( $action eq 'void' ) {
94
if ( $action eq 'void' ) {
65
    my $payment_id = scalar $input->param('accountlines_id');
95
    my $payment_id = scalar $input->param('accountlines_id');
66
    my $payment    = Koha::Account::Lines->find( $payment_id );
96
    my $payment    = Koha::Account::Lines->find( $payment_id );
67
    $payment->void();
97
    $payment->void();
68
}
98
}
69
99
100
if ( $action eq 'payout' ) {
101
    my $payment_id        = scalar $input->param('accountlines_id');
102
    my $payment           = Koha::Account::Lines->find($payment_id);
103
    my $amount           = scalar $input->param('amount');
104
    my $transaction_type = scalar $input->param('transaction_type');
105
    $schema->txn_do(
106
        sub {
107
            my $payout = $payment->payout(
108
                {
109
                    payout_type   => $transaction_type,
110
                    branch        => $library_id,
111
                    staff_id      => $logged_in_user->id,
112
                    cash_register => $registerid,
113
                    interface     => 'intranet',
114
                    amount        => $amount
115
                }
116
            );
117
        }
118
    );
119
}
120
70
#get account details
121
#get account details
71
my $total = $patron->account->balance;
122
my $total = $patron->account->balance;
72
123
73
- 

Return to bug 24080