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

(-)a/C4/Budgets.pm (-14 / +17 lines)
Lines 18-23 package C4::Budgets; Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use JSON;
21
use C4::Context;
22
use C4::Context;
22
use Koha::Database;
23
use Koha::Database;
23
use Koha::Patrons;
24
use Koha::Patrons;
Lines 649-663 sub AddBudget { Link Here
649
650
650
    # Log the addition
651
    # Log the addition
651
    if (C4::Context->preference("AcqLog")) {
652
    if (C4::Context->preference("AcqLog")) {
652
        my $infos =
653
        my $infos = {
653
            sprintf("%010d", $budget->{budget_amount}) .
654
            budget_amount => $budget->{budget_amount},
654
            sprintf("%010d", $budget->{budget_encumb}) .
655
            budget_encumb => $budget->{budget_encumb},
655
            sprintf("%010d", $budget->{budget_expend});
656
            budget_expend => $budget->{budget_expend}
657
        };
656
        logaction(
658
        logaction(
657
            'ACQUISITIONS',
659
            'ACQUISITIONS',
658
            'CREATE_FUND',
660
            'CREATE_FUND',
659
            $id,
661
            $id,
660
            $infos
662
            encode_json($infos)
661
        );
663
        );
662
    }
664
    }
663
    return $id;
665
    return $id;
Lines 672-690 sub ModBudget { Link Here
672
674
673
    # Log this modification
675
    # Log this modification
674
    if (C4::Context->preference("AcqLog")) {
676
    if (C4::Context->preference("AcqLog")) {
675
        my $infos =
677
        my $infos = {
676
            sprintf("%010d", $budget->{budget_amount}) .
678
            budget_amount_new    => $budget->{budget_amount},
677
            sprintf("%010d", $budget->{budget_encumb}) .
679
            budget_encumb_new    => $budget->{budget_encumb},
678
            sprintf("%010d", $budget->{budget_expend}) .
680
            budget_expend_new    => $budget->{budget_expend},
679
            sprintf("%010d", $result->budget_amount) .
681
            budget_amount_old    => $result->budget_amount,
680
            sprintf("%010d", $result->budget_encumb) .
682
            budget_encumb_old    => $result->budget_encumb,
681
            sprintf("%010d", $result->budget_expend) .
683
            budget_expend_old    => $result->budget_expend,
682
            sprintf("%010d", 0 - ($result->budget_amount - $budget->{budget_amount}));
684
            budget_amount_change => 0 - ($result->budget_amount - $budget->{budget_amount})
685
        };
683
        logaction(
686
        logaction(
684
            'ACQUISITIONS',
687
            'ACQUISITIONS',
685
            'MODIFY_FUND',
688
            'MODIFY_FUND',
686
            $budget->{budget_id},
689
            $budget->{budget_id},
687
            $infos
690
            encode_json($infos)
688
        );
691
        );
689
    }
692
    }
690
693
(-)a/acqui/addorder.pl (-7 / +7 lines)
Lines 119-125 if it is an order from an existing suggestion : the id of this suggestion. Link Here
119
119
120
use Modern::Perl;
120
use Modern::Perl;
121
use CGI qw ( -utf8 );
121
use CGI qw ( -utf8 );
122
use JSON qw ( to_json );
122
use JSON qw ( to_json encode_json );
123
use C4::Auth;           # get_template_and_user
123
use C4::Auth;           # get_template_and_user
124
use C4::Acquisition;    # ModOrder
124
use C4::Acquisition;    # ModOrder
125
use C4::Suggestions;    # ModStatus
125
use C4::Suggestions;    # ModStatus
Lines 316-330 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
316
        ModOrder($orderinfo);
316
        ModOrder($orderinfo);
317
        # Log the order modification
317
        # Log the order modification
318
        if (C4::Context->preference("AcqLog")) {
318
        if (C4::Context->preference("AcqLog")) {
319
            my $infos = '';
319
            my $infos = {};
320
            foreach my $field(@log_order_fields) {
320
            foreach my $field(@log_order_fields) {
321
                $infos .= sprintf("%010d", $orderinfo->{$field});
321
                $infos->{$field} = $orderinfo->{$field};
322
            }
322
            }
323
            logaction(
323
            logaction(
324
                'ACQUISITIONS',
324
                'ACQUISITIONS',
325
                'MODIFY_ORDER',
325
                'MODIFY_ORDER',
326
                $orderinfo->{ordernumber},
326
                $orderinfo->{ordernumber},
327
                $infos
327
                encode_json($infos)
328
            );
328
            );
329
        }
329
        }
330
    }
330
    }
Lines 332-346 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
332
        $order->store;
332
        $order->store;
333
        # Log the order creation
333
        # Log the order creation
334
        if (C4::Context->preference("AcqLog")) {
334
        if (C4::Context->preference("AcqLog")) {
335
            my $infos = '';
335
            my $infos = {};
336
            foreach my $field(@log_order_fields) {
336
            foreach my $field(@log_order_fields) {
337
                $infos .= sprintf("%010d", $orderinfo->{$field});
337
                $infos->{$field} = $orderinfo->{$field};
338
            }
338
            }
339
            logaction(
339
            logaction(
340
                'ACQUISITIONS',
340
                'ACQUISITIONS',
341
                'CREATE_ORDER',
341
                'CREATE_ORDER',
342
                $order->ordernumber,
342
                $order->ordernumber,
343
                $infos
343
                encode_json($infos)
344
            );
344
            );
345
        }
345
        }
346
    }
346
    }
(-)a/acqui/finishreceive.pl (-7 / +9 lines)
Lines 22-27 Link Here
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use JSON;
25
use C4::Auth;
26
use C4::Auth;
26
use C4::Output;
27
use C4::Output;
27
use C4::Context;
28
use C4::Context;
Lines 193-210 if ($suggestion_id) { Link Here
193
194
194
# Log the receipt
195
# Log the receipt
195
if (C4::Context->preference("AcqLog")) {
196
if (C4::Context->preference("AcqLog")) {
196
    my $infos =
197
    my $infos = {
197
        sprintf("%010d", $quantityrec) .
198
        quantityrec      => $quantityrec,
198
        sprintf("%010d", $bookfund) .
199
        bookfund         => $bookfund,
199
        sprintf("%010.2f", $input->param("tax_rate")) .
200
        tax_rate         => $input->param("tax_rate"),
200
        sprintf("%010.2f", $replacementprice) .
201
        replacementprice => $replacementprice,
201
        sprintf("%010.2f", $unitprice);
202
        unitprice        => $unitprice
203
    };
202
204
203
    logaction(
205
    logaction(
204
        'ACQUISITIONS',
206
        'ACQUISITIONS',
205
        'RECEIVE_ORDER',
207
        'RECEIVE_ORDER',
206
        $ordernumber,
208
        $ordernumber,
207
        $infos
209
        encode_json($infos)
208
    );
210
    );
209
}
211
}
210
212
(-)a/acqui/invoice.pl (-45 / +13 lines)
Lines 29-34 Invoice details Link Here
29
use Modern::Perl;
29
use Modern::Perl;
30
30
31
use CGI qw ( -utf8 );
31
use CGI qw ( -utf8 );
32
use JSON;
32
use C4::Auth;
33
use C4::Auth;
33
use C4::Output;
34
use C4::Output;
34
use C4::Acquisition;
35
use C4::Acquisition;
Lines 144-162 elsif ( $op && $op eq 'del_adj' ) { Link Here
144
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
145
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
145
    if ($del_adj) {
146
    if ($del_adj) {
146
        if (C4::Context->preference("AcqLog")) {
147
        if (C4::Context->preference("AcqLog")) {
147
            my $reason_length = length $del_adj->reason;
148
            my $infos = {
148
            my $reason_padded = ( ' ' x (80 - $reason_length) ) . $del_adj->reason;
149
                invoiceid     => $del_adj->invoiceid,
149
            my $infos =
150
                budget_id     => $del_adj->budget_id,
150
                sprintf("%010d", $del_adj->invoiceid) .
151
                encumber_open => $del_adj->encumber_open,
151
                sprintf("%010d", $del_adj->budget_id) .
152
                adjustment    => $del_adj->adjustment,
152
                sprintf("%010d", $del_adj->encumber_open) .
153
                reason        => $del_adj->reason
153
                sprintf("%010.2f", $del_adj->adjustment) .
154
            };
154
                $reason_padded;
155
            logaction(
155
            logaction(
156
                'ACQUISITIONS',
156
                'ACQUISITIONS',
157
                'DELETE_INVOICE_ADJUSTMENT',
157
                'DELETE_INVOICE_ADJUSTMENT',
158
                $adjustment_id,
158
                $adjustment_id,
159
                $infos
159
                encode_json($infos)
160
            );
160
            );
161
        }
161
        }
162
        $del_adj->delete();
162
        $del_adj->delete();
Lines 191-202 elsif ( $op && $op eq 'mod_adj' ) { Link Here
191
            $new_adj->store();
191
            $new_adj->store();
192
            # Log this addition
192
            # Log this addition
193
            if (C4::Context->preference("AcqLog")) {
193
            if (C4::Context->preference("AcqLog")) {
194
                my $infos = get_log_string($adj);
195
                logaction(
194
                logaction(
196
                    'ACQUISITIONS',
195
                    'ACQUISITIONS',
197
                    'CREATE_INVOICE_ADJUSTMENT',
196
                    'CREATE_INVOICE_ADJUSTMENT',
198
                    $new_adj->adjustment_id,
197
                    $new_adj->adjustment_id,
199
                    $infos
198
                    encode_json($adj)
200
                );
199
                );
201
            }
200
            }
202
        }
201
        }
Lines 205-211 elsif ( $op && $op eq 'mod_adj' ) { Link Here
205
            unless ( $old_adj->adjustment == $adjustment[$i] && $old_adj->reason eq $reason[$i] && $old_adj->budget_id == $budget_id[$i] && $old_adj->encumber_open == $e_open{$adjustment_id[$i]} && $old_adj->note eq $note[$i] ){
204
            unless ( $old_adj->adjustment == $adjustment[$i] && $old_adj->reason eq $reason[$i] && $old_adj->budget_id == $budget_id[$i] && $old_adj->encumber_open == $e_open{$adjustment_id[$i]} && $old_adj->note eq $note[$i] ){
206
                # Log this modification
205
                # Log this modification
207
                if (C4::Context->preference("AcqLog")) {
206
                if (C4::Context->preference("AcqLog")) {
208
                    my $infos = get_log_string({
207
                    my $infos = {
209
                        adjustment        => $adjustment[$i],
208
                        adjustment        => $adjustment[$i],
210
                        reason            => $reason[$i],
209
                        reason            => $reason[$i],
211
                        budget_id         => $budget_id[$i],
210
                        budget_id         => $budget_id[$i],
Lines 214-225 elsif ( $op && $op eq 'mod_adj' ) { Link Here
214
                        reason_old        => $old_adj->reason,
213
                        reason_old        => $old_adj->reason,
215
                        budget_id_old     => $old_adj->budget_id,
214
                        budget_id_old     => $old_adj->budget_id,
216
                        encumber_open_old => $old_adj->encumber_open
215
                        encumber_open_old => $old_adj->encumber_open
217
                    });
216
                    };
218
                    logaction(
217
                    logaction(
219
                        'ACQUISITIONS',
218
                        'ACQUISITIONS',
220
                        'UPDATE_INVOICE_ADJUSTMENT',
219
                        'UPDATE_INVOICE_ADJUSTMENT',
221
                        $adjustment_id[$i],
220
                        $adjustment_id[$i],
222
                        $infos
221
                        encode_json($infos)
223
                    );
222
                    );
224
                }
223
                }
225
                $old_adj->timestamp(undef);
224
                $old_adj->timestamp(undef);
Lines 346-380 sub get_infos { Link Here
346
    return \%line;
345
    return \%line;
347
}
346
}
348
347
349
sub get_log_string {
350
    my ($data) = @_;
351
352
    # We specify the keys we're dealing for logging within an array in order
353
    # to preserve order, if we just iterate the hash keys, we could get
354
    # the values in any order
355
    my @keys = (
356
        'budget_id',
357
        'encumber_open',
358
        'budget_id_old',
359
        'encumber_open_old'
360
    );
361
    # Adjustment amount
362
    my $return = sprintf("%010.2f", $data->{adjustment});
363
    # Left pad "reason" to the maximum length of aqinvoice_adjustments.reason
364
    # (80 characters)
365
    my $reason_len = length $data->{reason};
366
    $return .= ( ' ' x (80 - $reason_len) ) . $data->{reason};
367
    # Append the remaining fields
368
    foreach my $key(@keys) {
369
        $return .= sprintf("%010d", $data->{$key});
370
    }
371
    # Old adjustment amount
372
    $return .= sprintf("%010.2f", $data->{adjustment_old});
373
    # Left pad "reason_old" to the maximum length of aqinvoice_adjustments.reason
374
    # (80 characters)
375
    my $reason_old_len = length $data->{reason_old};
376
    $return .= ( ' ' x (80 - $reason_old_len) ) . $data->{reason_old};
377
    return $return;
378
}
379
380
output_html_with_http_headers $input, $cookie, $template->output;
348
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/admin/aqbudgetperiods.pl (-10 / +11 lines)
Lines 48-53 use Modern::Perl; Link Here
48
48
49
use CGI qw ( -utf8 );
49
use CGI qw ( -utf8 );
50
use List::Util qw/min/;
50
use List::Util qw/min/;
51
use JSON;
51
use Koha::DateUtils;
52
use Koha::DateUtils;
52
use Koha::Database;
53
use Koha::Database;
53
use C4::Koha;
54
use C4::Koha;
Lines 124-142 elsif ( $op eq 'add_validate' ) { Link Here
124
        # Log the budget modification
125
        # Log the budget modification
125
        if (C4::Context->preference("AcqLog")) {
126
        if (C4::Context->preference("AcqLog")) {
126
            my $diff = 0 - ($budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total});
127
            my $diff = 0 - ($budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total});
127
            my $infos =
128
            my $infos = {
128
                eval { output_pref({ dt => dt_from_string( $input->param('budget_period_startdate') ), dateformat => 'iso', dateonly => 1 } ); } .
129
                budget_period_startdate     => $input->param('budget_period_startdate'),
129
                eval { output_pref({ dt => dt_from_string( $input->param('budget_period_enddate') ), dateformat => 'iso', dateonly => 1 } ); } .
130
                budget_period_enddate       => $input->param('budget_period_enddate'),
130
                sprintf("%010d", $budget_period_hashref->{budget_period_total}) .
131
                budget_period_total         => $budget_period_hashref->{budget_period_total},
131
                eval { output_pref({ dt => dt_from_string( $budgetperiod_old->{budget_period_startdate} ), dateformat => 'iso', dateonly => 1 } ); } .
132
                budget_period_startdate_old => $budgetperiod_old->{budget_period_startdate},
132
                eval { output_pref({ dt => dt_from_string( $budgetperiod_old->{budget_period_enddate} ), dateformat => 'iso', dateonly => 1 } ); } .
133
                budget_period_enddate_old   => $budgetperiod_old->{budget_period_enddate},
133
                sprintf("%010d", $budgetperiod_old->{budget_period_total}) .
134
                budget_period_total_old     => $budgetperiod_old->{budget_period_total},
134
                sprintf("%010d", $diff);
135
                budget_period_total_change  => $diff
136
            };
135
            logaction(
137
            logaction(
136
                'ACQUISITIONS',
138
                'ACQUISITIONS',
137
                'MODIFY_BUDGET',
139
                'MODIFY_BUDGET',
138
                $budget_period_id,
140
                $budget_period_id,
139
                $infos
141
                encode_json($infos)
140
            );
142
            );
141
        }
143
        }
142
    }
144
    }
143
- 

Return to bug 24190