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

(-)a/Koha/Template/Plugin/Registers.pm (-2 / +6 lines)
Lines 44-50 sub session_register_name { Link Here
44
=head2
44
=head2
45
45
46
    [% SET registers = Registers.all() %]
46
    [% SET registers = Registers.all() %]
47
    [% SET registers = Registers.all( { branch => branchcode } );
47
    [% SET registers = Registers.all( { filters => { current_branch => 1 } } );
48
48
49
Returns a list of all cash registers available that adhere to the passed filters.
49
Returns a list of all cash registers available that adhere to the passed filters.
50
50
Lines 53-59 Returns a list of all cash registers available that adhere to the passed filters Link Here
53
sub all {
53
sub all {
54
    my ( $self, $params ) = @_;
54
    my ( $self, $params ) = @_;
55
55
56
    my $registers = Koha::Cash::Registers->search()->unblessed();
56
    my $filters = $params->{filters};
57
    my $where;
58
    $where->{branch} = C4::Context->userenv->{'branch'}
59
      if $filters->{current_branch};
60
    my $registers = Koha::Cash::Registers->search($where)->unblessed();
57
    for my $register ( @{$registers} ) {
61
    for my $register ( @{$registers} ) {
58
        $register->{selected} = ( defined( $self->session_register_id )
62
        $register->{selected} = ( defined( $self->session_register_id )
59
              && $register->{id} == $self->session_register_id ) ? 1 : 0;
63
              && $register->{id} == $self->session_register_id ) ? 1 : 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-3 / +2 lines)
Lines 24-33 Link Here
24
[% END %]
24
[% END %]
25
25
26
[% BLOCK options_for_registers %]
26
[% BLOCK options_for_registers %]
27
    <!-- <option hidden disabled selected value> -- select an option -- </option> -->
27
    <option id="noregister"[% IF register_required %] disabled [% END %] selected="selected" value="">[% IF register_required %]-- Select an option--[% ELSE %]-- None --[% END %]</option>
28
    <option id="noregister"[% IF register_required %] disabled selected [% END %] value="">-- None --</option>
29
    [% FOREACH r IN registers %]
28
    [% FOREACH r IN registers %]
30
        [% IF r.branch == branch %]
29
        [% IF r.branch == Branches.GetLoggedInBranchcode %]
31
            [% IF r.selected %]
30
            [% IF r.selected %]
32
                <option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]" selected="selected">[% r.name | html %]</option>
31
                <option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]" selected="selected">[% r.name | html %]</option>
33
            [% ELSE %]
32
            [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-20 / +10 lines)
Lines 2-12 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE Registers %]
5
[% USE Price %]
6
[% USE Price %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% PROCESS 'payments.inc' %]
8
[% PROCESS 'payments.inc' %]
8
[% PROCESS 'accounts.inc' %]
9
[% PROCESS 'accounts.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
[% INCLUDE 'doc-head-open.inc' %]
11
[% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
10
<title>Koha &rsaquo; Patrons &rsaquo;
12
<title>Koha &rsaquo; Patrons &rsaquo;
11
    [% IF type == 'WRITEOFF' %]
13
    [% IF type == 'WRITEOFF' %]
12
        Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
14
        Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
Lines 73-79 Link Here
73
[% END %]
75
[% END %]
74
76
75
[% IF ( pay_individual ) %]
77
[% IF ( pay_individual ) %]
76
    [% IF ( error_registers ) %]
78
    [% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) %]
77
    <div id="error_message" class="dialog alert">
79
    <div id="error_message" class="dialog alert">
78
        You must have at least one cash register associated with this branch before you can record payments.
80
        You must have at least one cash register associated with this branch before you can record payments.
79
    </div>
81
    </div>
Lines 140-154 Link Here
140
142
141
    [% IF Koha.Preference('UseCashRegisters') %]
143
    [% IF Koha.Preference('UseCashRegisters') %]
142
    <li>
144
    <li>
143
        <label for="cash_register">Cash register: </label>
145
        <label for="registerid">Cash register: </label>
144
        <select name="cash_register" id="cash_register">
146
        <select name="registerid" id="registerid">
145
            [% FOREACH register IN registers %]
147
            [% PROCESS options_for_registers register_required => 1 %]
146
              [% IF register.id == registerid %]
147
            <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
148
              [% ELSE %]
149
            <option value="[% register.id | html %]">[% register.name | html %]</option>
150
              [% END %]
151
            [% END %]
152
        </select>
148
        </select>
153
    </li>
149
    </li>
154
    [% END %]
150
    [% END %]
Lines 214-220 Link Here
214
        </div>
210
        </div>
215
    </form>
211
    </form>
216
[% ELSE %]
212
[% ELSE %]
217
    [% IF ( error_registers && type != 'writeoff' ) %]
213
    [% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) && ( type != 'writeoff' ) %]
218
    <div id="error_message" class="dialog alert">
214
    <div id="error_message" class="dialog alert">
219
        You must have at least one cash register associated with this branch before you can record payments.
215
        You must have at least one cash register associated with this branch before you can record payments.
220
    </div>
216
    </div>
Lines 278-292 Link Here
278
274
279
    [% IF Koha.Preference('UseCashRegisters') %]
275
    [% IF Koha.Preference('UseCashRegisters') %]
280
    <li>
276
    <li>
281
        <label for="cash_register">Cash register: </label>
277
        <label for="registerid">Cash register: </label>
282
        <select name="cash_register" id="cash_register">
278
        <select name="registerid" id="registerid">
283
            [% FOREACH register IN registers %]
279
            [% PROCESS options_for_registers register_required => 1 %]
284
              [% IF register.id == registerid %]
285
            <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
286
              [% ELSE %]
287
            <option value="[% register.id | html %]">[% register.name | html %]</option>
288
              [% END %]
289
            [% END %]
290
        </select>
280
        </select>
291
    </li>
281
    </li>
292
    [% END %]
282
    [% END %]
(-)a/members/paycollect.pl (-28 / +1 lines)
Lines 78-110 my $payment_note = uri_unescape scalar $input->param('payment_note'); Link Here
78
my $payment_type = scalar $input->param('payment_type');
78
my $payment_type = scalar $input->param('payment_type');
79
my $accountlines_id;
79
my $accountlines_id;
80
80
81
my $registerid;
81
my $registerid = $input->param('registerid');
82
if ( C4::Context->preference('UseCashRegisters') ) {
83
    $registerid = $input->param('registerid');
84
    my $registers  = Koha::Cash::Registers->search(
85
        { branch   => $library_id, archived => 0 },
86
        { order_by => { '-asc' => 'name' } }
87
    );
88
89
    if ( !$registers->count ) {
90
        $template->param( error_registers => 1 );
91
    }
92
    else {
93
94
        if ( !$registerid ) {
95
            my $default_register = Koha::Cash::Registers->find(
96
                { branch => $library_id, branch_default => 1 } );
97
            $registerid = $default_register->id if $default_register;
98
        }
99
        $registerid = $registers->next->id if !$registerid;
100
101
        $template->param(
102
            registerid => $registerid,
103
            registers  => $registers,
104
        );
105
    }
106
}
107
108
if ( $pay_individual || $writeoff_individual ) {
82
if ( $pay_individual || $writeoff_individual ) {
109
    if ($pay_individual) {
83
    if ($pay_individual) {
110
        $template->param( pay_individual => 1 );
84
        $template->param( pay_individual => 1 );
111
- 

Return to bug 24786