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

(-)a/Koha/Account/Line.pm (-1 / +1 lines)
Lines 30-36 use Koha::DateUtils qw( dt_from_string ); Link Here
30
use Koha::Exceptions::Account;
30
use Koha::Exceptions::Account;
31
use Koha::Items;
31
use Koha::Items;
32
32
33
use base qw(Koha::Object);
33
use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields);
34
34
35
=encoding utf8
35
=encoding utf8
36
36
(-)a/Koha/Schema/Result/Accountline.pm (+16 lines)
Lines 419-424 __PACKAGE__->belongs_to( Link Here
419
  },
419
  },
420
);
420
);
421
421
422
__PACKAGE__->has_many(
423
  "additional_field_values",
424
  "Koha::Schema::Result::AdditionalFieldValue",
425
  sub {
426
    my ($args) = @_;
427
428
    return {
429
        "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.accountlines_id" },
430
431
        "$args->{foreign_alias}.field_id" =>
432
            { -in => \'(SELECT id FROM additional_fields WHERE tablename LIKE "accountlines:%")' },
433
    };
434
  },
435
  { cascade_copy => 0, cascade_delete => 0 },
436
);
437
422
sub koha_objects_class {
438
sub koha_objects_class {
423
    'Koha::Account::Lines';
439
    'Koha::Account::Lines';
424
}
440
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc (-1 / +1 lines)
Lines 9-15 Link Here
9
                <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
9
                <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
10
                [% IF field.authorised_value_category %]
10
                [% IF field.authorised_value_category %]
11
                    <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]">
11
                    <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]">
12
                        <option value="">All</option>
12
                        <option value=""></option>
13
                        [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox( field.authorised_value_category ) %]
13
                        [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox( field.authorised_value_category ) %]
14
                            [% IF av.authorised_value == values.${field.id} %]
14
                            [% IF av.authorised_value == values.${field.id} %]
15
                                <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
15
                                <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt (-14 / +26 lines)
Lines 12-18 Link Here
12
</head>
12
</head>
13
13
14
[% marcfield_tables = ['subscription'] %]
14
[% marcfield_tables = ['subscription'] %]
15
[% searchable_tables = ['subscription', 'aqbasket'] %]
15
[% show_marcfield = marcfield_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
16
[% show_marcfield = marcfield_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
17
[% show_searchable = searchable_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
16
18
17
<body id="ser_add_fields" class="ser">
19
<body id="ser_add_fields" class="ser">
18
    [% INCLUDE 'header.inc' %]
20
    [% INCLUDE 'header.inc' %]
Lines 102-108 Link Here
102
    [% END %]
104
    [% END %]
103
105
104
    [% IF op == 'list_tables' %]
106
    [% IF op == 'list_tables' %]
105
        [% IF CAN_user_acquisitions_order_manage || CAN_user_serials_edit_subscription %]
107
        [% IF CAN_user_acquisitions_order_manage || CAN_user_serials_edit_subscription || CAN_user_updatecharges_remaining_permissions %]
106
        <h1>Additional fields</h1>
108
        <h1>Additional fields</h1>
107
        <p>Select a table:</p>
109
        <p>Select a table:</p>
108
        [% BLOCK table_option %]
110
        [% BLOCK table_option %]
Lines 115-123 Link Here
115
            [% IF CAN_user_serials_edit_subscription %]
117
            [% IF CAN_user_serials_edit_subscription %]
116
                [% WRAPPER table_option value="subscription" %]<span>Subscriptions</span>[% END %]
118
                [% WRAPPER table_option value="subscription" %]<span>Subscriptions</span>[% END %]
117
            [% END %]
119
            [% END %]
120
            [% IF CAN_user_updatecharges_remaining_permissions %]
121
                [% WRAPPER table_option value="accountlines:credit" %]Account lines (credit)[% END %]
122
                [% WRAPPER table_option value="accountlines:debit" %]Account lines (debit)[% END %]
123
            [% END %]
118
        </ul>
124
        </ul>
119
        [% ELSE %]
125
        [% ELSE %]
120
            Additional permissions in the acquisitions or serials modules are required for editing additional fields
126
            Additional permissions are required for editing additional fields
121
        [% END %]
127
        [% END %]
122
    [% ELSIF op == 'list' %]
128
    [% ELSIF op == 'list' %]
123
        <h1>Additional fields for '[% tablename | html %]'</h1>
129
        <h1>Additional fields for '[% tablename | html %]'</h1>
Lines 130-136 Link Here
130
                        [% IF show_marcfield %]
136
                        [% IF show_marcfield %]
131
                            <th>MARC field</th>
137
                            <th>MARC field</th>
132
                        [% END %]
138
                        [% END %]
133
                        <th>Searchable</th>
139
                        [% IF show_searchable %]
140
                            <th>Searchable</th>
141
                        [% END %]
134
                        <th class="noExport">Actions</th>
142
                        <th class="noExport">Actions</th>
135
                    </tr>
143
                    </tr>
136
                </thead>
144
                </thead>
Lines 142-150 Link Here
142
                            [% IF show_marcfield %]
150
                            [% IF show_marcfield %]
143
                                <td>[% field.marcfield | html %]</td>
151
                                <td>[% field.marcfield | html %]</td>
144
                            [% END %]
152
                            [% END %]
145
                            <td>
153
                            [% IF show_searchable %]
146
                                [% IF field.searchable %]Yes[% ELSE %]No[% END %]
154
                                <td>
147
                            </td>
155
                                    [% IF field.searchable %]Yes[% ELSE %]No[% END %]
156
                                </td>
157
                            [% END %]
148
                            <td class="actions">
158
                            <td class="actions">
149
                                <a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa fa-pencil"></i> Edit</a>
159
                                <a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa fa-pencil"></i> Edit</a>
150
                                <a class="confirmdelete btn btn-default btn-xs" href="?op=delete&amp;field_id=[% field.id | uri %]&amp;tablename=[% tablename | uri %]"><i class="fa fa-trash"></i> Delete</a>
160
                                <a class="confirmdelete btn btn-default btn-xs" href="?op=delete&amp;field_id=[% field.id | uri %]&amp;tablename=[% tablename | uri %]"><i class="fa fa-trash"></i> Delete</a>
Lines 183-196 Link Here
183
                            <input type="text" name="marcfield" id="marcfield" value="[% field.marcfield | html %]" />
193
                            <input type="text" name="marcfield" id="marcfield" value="[% field.marcfield | html %]" />
184
                        </li>
194
                        </li>
185
                    [% END %]
195
                    [% END %]
186
                    <li>
196
                    [% IF show_searchable %]
187
                        <label for="searchable">Searchable: </label>
197
                        <li>
188
                        [% IF field.searchable %]
198
                            <label for="searchable">Searchable: </label>
189
                            <input type="checkbox" name="searchable" id="searchable" checked="checked" />
199
                            [% IF field.searchable %]
190
                        [% ELSE %]
200
                                <input type="checkbox" name="searchable" id="searchable" checked="checked" />
191
                            <input type="checkbox" name="searchable" id="searchable" />
201
                            [% ELSE %]
192
                        [% END %]
202
                                <input type="checkbox" name="searchable" id="searchable" />
193
                    </li>
203
                            [% END %]
204
                        </li>
205
                    [% END %]
194
                </ol>
206
                </ol>
195
            </fieldset>
207
            </fieldset>
196
            <fieldset class="action">
208
            <fieldset class="action">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt (+14 lines)
Lines 71-76 Link Here
71
            [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
71
            [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
72
72
73
            [% IF accountline %]
73
            [% IF accountline %]
74
                [% af_values = accountline.additional_field_values %]
74
                [% IF accountline.credit_type_code %]
75
                [% IF accountline.credit_type_code %]
75
                    <h2>Details of credit</h2>
76
                    <h2>Details of credit</h2>
76
                [% ELSIF accountline.debit_type_code %]
77
                [% ELSIF accountline.debit_type_code %]
Lines 86-91 Link Here
86
                            <th>Due date</th>
87
                            <th>Due date</th>
87
                            <th>Return date</th>
88
                            <th>Return date</th>
88
                            <th>Note</th>
89
                            <th>Note</th>
90
                            [% FOREACH value IN af_values %]
91
                                <th>[% value.field.name | html %]</th>
92
                            [% END %]
89
                            <th>Amount</th>
93
                            <th>Amount</th>
90
                            <th>Outstanding</th>
94
                            <th>Outstanding</th>
91
                        </tr>
95
                        </tr>
Lines 134-139 Link Here
134
                                [% accountline.note | html_line_break %]
138
                                [% accountline.note | html_line_break %]
135
                            </td>
139
                            </td>
136
140
141
                            [% FOREACH value IN af_values %]
142
                                <td>
143
                                    [% IF value.field.authorised_value_category %]
144
                                        [% AuthorisedValues.GetByCode( value.field.authorised_value_category, value.value ) | html %]
145
                                    [% ELSE %]
146
                                        [% value.value | html %]
147
                                    [% END %]
148
                                </td>
149
                            [% END %]
150
137
                            <td>
151
                            <td>
138
                                [% accountline.amount | $Price %]
152
                                [% accountline.amount | $Price %]
139
                            </td>
153
                            </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (+4 lines)
Lines 72-77 Link Here
72
                        </ol>
72
                        </ol>
73
                    </fieldset>
73
                    </fieldset>
74
74
75
                    [% IF available_additional_fields %]
76
                        [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
77
                    [% END %]
78
75
                    <fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
79
                    <fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
76
                </form>
80
                </form>
77
81
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt (+5 lines)
Lines 85-90 Link Here
85
                            <li><label for="amount">Amount: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="amount" id="amount" required="required" min="0" value="[% amount | $Price on_editing => 1 %]" /> Example: 5.00</li>
85
                            <li><label for="amount">Amount: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="amount" id="amount" required="required" min="0" value="[% amount | $Price on_editing => 1 %]" /> Example: 5.00</li>
86
                        </ol>
86
                        </ol>
87
                    </fieldset>
87
                    </fieldset>
88
89
                    [% IF available_additional_fields %]
90
                        [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
91
                    [% END %]
92
88
                    <fieldset class="action">
93
                    <fieldset class="action">
89
                        <button type="submit" name="add" value="save">Save</button>
94
                        <button type="submit" name="add" value="save">Save</button>
90
                        <button type="submit" name="add" value="save and pay">Save and pay</button>
95
                        <button type="submit" name="add" value="save and pay">Save and pay</button>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+14 lines)
Lines 211-216 Link Here
211
</ol>
211
</ol>
212
</fieldset>
212
</fieldset>
213
213
214
[% IF available_additional_fields %]
215
    [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
216
[% END %]
217
214
        <div class="action">
218
        <div class="action">
215
            <input type="submit" name="submitbutton" value="Confirm" />
219
            <input type="submit" name="submitbutton" value="Confirm" />
216
            <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
220
            <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
Lines 263-268 Link Here
263
                </li>
267
                </li>
264
            </ol>
268
            </ol>
265
        </fieldset>
269
        </fieldset>
270
271
        [% IF available_additional_fields %]
272
            [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
273
        [% END %]
274
266
        <div class="action">
275
        <div class="action">
267
            <input type="submit" value="Write off this charge" />
276
            <input type="submit" value="Write off this charge" />
268
            <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
277
            <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
Lines 346-351 Link Here
346
    </li>
355
    </li>
347
    </ol>
356
    </ol>
348
    </fieldset>
357
    </fieldset>
358
359
    [% IF available_additional_fields %]
360
        [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
361
    [% END %]
362
349
    <div class="action">
363
    <div class="action">
350
        <input type="submit" name="submitbutton" value="Confirm" />
364
        <input type="submit" name="submitbutton" value="Confirm" />
351
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
365
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
(-)a/members/mancredit.pl (-1 / +18 lines)
Lines 34-39 use Koha::Items; Link Here
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::Account::CreditTypes;
36
use Koha::Account::CreditTypes;
37
use Koha::AdditionalFields;
37
38
38
use Koha::Token;
39
use Koha::Token;
39
40
Lines 90-96 if ($add) { Link Here
90
    my $amount      = $input->param('amount') || 0;
91
    my $amount      = $input->param('amount') || 0;
91
    my $type        = $input->param('type');
92
    my $type        = $input->param('type');
92
93
93
    $patron->account->add_credit(
94
    my $line = $patron->account->add_credit(
94
        {
95
        {
95
            amount      => $amount,
96
            amount      => $amount,
96
            description => $description,
97
            description => $description,
Lines 103-108 if ($add) { Link Here
103
        }
104
        }
104
    );
105
    );
105
106
107
    my @additional_fields;
108
    my $accountline_fields = Koha::AdditionalFields->search({ tablename => 'accountlines:credit' });
109
    while ( my $field = $accountline_fields->next ) {
110
        my $value = $input->param('additional_field_' . $field->id);
111
        if (defined $value) {
112
            push @additional_fields, {
113
                id => $field->id,
114
                value => $value,
115
            };
116
        }
117
    }
118
    if (@additional_fields) {
119
        $line->set_additional_fields(\@additional_fields);
120
    }
121
106
    if ( C4::Context->preference('AccountAutoReconcile') ) {
122
    if ( C4::Context->preference('AccountAutoReconcile') ) {
107
        $patron->account->reconcile_balance;
123
        $patron->account->reconcile_balance;
108
    }
124
    }
Lines 124-129 else { Link Here
124
        csrf_token   => Koha::Token->new->generate_csrf(
140
        csrf_token   => Koha::Token->new->generate_csrf(
125
            { session_id => scalar $input->cookie('CGISESSID') }
141
            { session_id => scalar $input->cookie('CGISESSID') }
126
        ),
142
        ),
143
        available_additional_fields => [ Koha::AdditionalFields->search({ tablename => 'accountlines:credit' })->as_list ],
127
    );
144
    );
128
    output_html_with_http_headers $input, $cookie, $template->output;
145
    output_html_with_http_headers $input, $cookie, $template->output;
129
}
146
}
(-)a/members/maninvoice.pl (+17 lines)
Lines 41-46 use Koha::Old::Checkouts; Link Here
41
41
42
use Koha::Patron::Categories;
42
use Koha::Patron::Categories;
43
use Koha::Account::DebitTypes;
43
use Koha::Account::DebitTypes;
44
use Koha::AdditionalFields;
44
45
45
my $input = CGI->new;
46
my $input = CGI->new;
46
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 165-170 if ($add) { Link Here
165
                }
166
                }
166
            );
167
            );
167
168
169
            my @additional_fields;
170
            my $accountline_fields = Koha::AdditionalFields->search({ tablename => 'accountlines:debit' });
171
            while ( my $field = $accountline_fields->next ) {
172
                my $value = $input->param('additional_field_' . $field->id);
173
                if (defined $value) {
174
                    push @additional_fields, {
175
                        id => $field->id,
176
                        value => $value,
177
                    };
178
                }
179
            }
180
            if (@additional_fields) {
181
                $line->set_additional_fields(\@additional_fields);
182
            }
183
168
            if ( C4::Context->preference('AccountAutoReconcile') ) {
184
            if ( C4::Context->preference('AccountAutoReconcile') ) {
169
                $patron->account->reconcile_balance;
185
                $patron->account->reconcile_balance;
170
            }
186
            }
Lines 216-220 $template->param( Link Here
216
  ),
232
  ),
217
  patron    => $patron,
233
  patron    => $patron,
218
  finesview => 1,
234
  finesview => 1,
235
  available_additional_fields => [ Koha::AdditionalFields->search({ tablename => 'accountlines:debit' })->as_list ],
219
  );
236
  );
220
output_html_with_http_headers $input, $cookie, $template->output;
237
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/paycollect.pl (-1 / +36 lines)
Lines 32-37 use Koha::Patrons; Link Here
32
use Koha::Patron::Categories;
32
use Koha::Patron::Categories;
33
use Koha::AuthorisedValues;
33
use Koha::AuthorisedValues;
34
use Koha::Account;
34
use Koha::Account;
35
use Koha::Account::Lines;
36
use Koha::AdditionalFields;
35
use Koha::Token;
37
use Koha::Token;
36
use Koha::DateUtils qw( output_pref );
38
use Koha::DateUtils qw( output_pref );
37
39
Lines 170-175 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
170
            );
172
            );
171
            $payment_id = $pay_result->{payment_id};
173
            $payment_id = $pay_result->{payment_id};
172
174
175
            my @additional_fields;
176
            my $accountline_fields = Koha::AdditionalFields->search({ tablename => 'accountlines:credit' });
177
            while ( my $field = $accountline_fields->next ) {
178
                my $value = $input->param('additional_field_' . $field->id);
179
                if (defined $value) {
180
                    push @additional_fields, {
181
                        id => $field->id,
182
                        value => $value,
183
                    };
184
                }
185
            }
186
            if (@additional_fields) {
187
                my $payment = Koha::Account::Lines->find($payment_id);
188
                $payment->set_additional_fields(\@additional_fields);
189
            }
190
191
173
            $url = "/cgi-bin/koha/members/pay.pl";
192
            $url = "/cgi-bin/koha/members/pay.pl";
174
        } else {
193
        } else {
175
            if ($selected_accts) {
194
            if ($selected_accts) {
Lines 213-218 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
213
            }
232
            }
214
            $payment_id = $pay_result->{payment_id};
233
            $payment_id = $pay_result->{payment_id};
215
234
235
            my @additional_fields;
236
            my $accountline_fields = Koha::AdditionalFields->search({ tablename => 'accountlines:credit' });
237
            while ( my $field = $accountline_fields->next ) {
238
                my $value = $input->param('additional_field_' . $field->id);
239
                if (defined $value) {
240
                    push @additional_fields, {
241
                        id => $field->id,
242
                        value => $value,
243
                    };
244
                }
245
            }
246
            if (@additional_fields) {
247
                my $payment = Koha::Account::Lines->find($payment_id);
248
                $payment->set_additional_fields(\@additional_fields);
249
            }
250
216
            $url = "/cgi-bin/koha/members/boraccount.pl";
251
            $url = "/cgi-bin/koha/members/boraccount.pl";
217
        }
252
        }
218
        # It's possible renewals took place, parse any renew results
253
        # It's possible renewals took place, parse any renew results
Lines 249-254 $template->param( Link Here
249
    total          => $total_due,
284
    total          => $total_due,
250
285
251
    csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID') } ),
286
    csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID') } ),
287
    available_additional_fields => [ Koha::AdditionalFields->search({ tablename => 'accountlines:credit' })->as_list ],
252
);
288
);
253
289
254
output_html_with_http_headers $input, $cookie, $template->output;
290
output_html_with_http_headers $input, $cookie, $template->output;
255
- 

Return to bug 31254