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 (-16 / +6 lines)
Lines 2-7 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' %]
Lines 20-25 Link Here
20
        [% END %]
21
        [% END %]
21
    </div>
22
    </div>
22
[% END %]
23
[% END %]
24
[% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
23
<title>Koha &rsaquo; Patrons &rsaquo;
25
<title>Koha &rsaquo; Patrons &rsaquo;
24
    [% IF type == 'WRITEOFF' %]
26
    [% IF type == 'WRITEOFF' %]
25
        Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
27
        Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
Lines 86-92 Link Here
86
[% END %]
88
[% END %]
87
89
88
[% IF ( pay_individual ) %]
90
[% IF ( pay_individual ) %]
89
    [% IF ( error_registers ) %]
91
    [% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) %]
90
        [% PROCESS 'cash_register_required' %]
92
        [% PROCESS 'cash_register_required' %]
91
    [% ELSE %]
93
    [% ELSE %]
92
94
Lines 153-165 Link Here
153
    <li>
155
    <li>
154
        <label for="cash_register">Cash register: </label>
156
        <label for="cash_register">Cash register: </label>
155
        <select name="cash_register" id="cash_register">
157
        <select name="cash_register" id="cash_register">
156
            [% FOREACH register IN registers %]
158
            [% PROCESS options_for_registers register_required => 1 %]
157
              [% IF register.id == default_register %]
158
            <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
159
              [% ELSE %]
160
            <option value="[% register.id | html %]">[% register.name | html %]</option>
161
              [% END %]
162
            [% END %]
163
        </select>
159
        </select>
164
    </li>
160
    </li>
165
    [% END %]
161
    [% END %]
Lines 225-231 Link Here
225
        </div>
221
        </div>
226
    </form>
222
    </form>
227
[% ELSE %]
223
[% ELSE %]
228
    [% IF ( error_registers && type != 'WRITEOFF' ) %]
224
    [% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) && ( type != 'WRITEOFF' ) %]
229
        [% PROCESS 'cash_register_required' %]
225
        [% PROCESS 'cash_register_required' %]
230
    [% ELSE %]
226
    [% ELSE %]
231
227
Lines 289-301 Link Here
289
    <li>
285
    <li>
290
        <label for="cash_register">Cash register: </label>
286
        <label for="cash_register">Cash register: </label>
291
        <select name="cash_register" id="cash_register">
287
        <select name="cash_register" id="cash_register">
292
            [% FOREACH register IN registers %]
288
            [% PROCESS options_for_registers register_required => 1 %]
293
              [% IF register.id == default_register %]
294
            <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
295
              [% ELSE %]
296
            <option value="[% register.id | html %]">[% register.name | html %]</option>
297
              [% END %]
298
            [% END %]
299
        </select>
289
        </select>
300
    </li>
290
    </li>
301
    [% END %]
291
    [% END %]
(-)a/members/paycollect.pl (-28 / +1 lines)
Lines 77-109 my $payment_note = uri_unescape scalar $input->param('payment_note'); Link Here
77
my $payment_type = scalar $input->param('payment_type');
77
my $payment_type = scalar $input->param('payment_type');
78
my $accountlines_id;
78
my $accountlines_id;
79
79
80
my $cash_register_id;
80
my $cash_register_id = $input->param('cash_register');
81
if ( C4::Context->preference('UseCashRegisters') ) {
82
    $cash_register_id = $input->param('cash_register');
83
    my $registers  = Koha::Cash::Registers->search(
84
        { branch   => $library_id, archived => 0 },
85
        { order_by => { '-asc' => 'name' } }
86
    );
87
88
    if ( !$registers->count ) {
89
        $template->param( error_registers => 1 );
90
    }
91
    else {
92
93
        if ( !$cash_register_id ) {
94
            my $default_register = Koha::Cash::Registers->find(
95
                { branch => $library_id, branch_default => 1 } );
96
            $cash_register_id = $default_register->id if $default_register;
97
        }
98
        $cash_register_id = $registers->next->id if !$cash_register_id;
99
100
        $template->param(
101
            default_register => $cash_register_id,
102
            registers        => $registers,
103
        );
104
    }
105
}
106
107
if ( $pay_individual || $writeoff_individual ) {
81
if ( $pay_individual || $writeoff_individual ) {
108
    if ($pay_individual) {
82
    if ($pay_individual) {
109
        $template->param( pay_individual => 1 );
83
        $template->param( pay_individual => 1 );
110
- 

Return to bug 24786