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 640-654 sub AddBudget { Link Here
640
641
641
    # Log the addition
642
    # Log the addition
642
    if (C4::Context->preference("AcqLog")) {
643
    if (C4::Context->preference("AcqLog")) {
643
        my $infos =
644
        my $infos = {
644
            sprintf("%010d", $budget->{budget_amount}) .
645
            budget_amount => $budget->{budget_amount},
645
            sprintf("%010d", $budget->{budget_encumb}) .
646
            budget_encumb => $budget->{budget_encumb},
646
            sprintf("%010d", $budget->{budget_expend});
647
            budget_expend => $budget->{budget_expend}
648
        };
647
        logaction(
649
        logaction(
648
            'ACQUISITIONS',
650
            'ACQUISITIONS',
649
            'CREATE_FUND',
651
            'CREATE_FUND',
650
            $id,
652
            $id,
651
            $infos
653
            encode_json($infos)
652
        );
654
        );
653
    }
655
    }
654
    return $id;
656
    return $id;
Lines 663-681 sub ModBudget { Link Here
663
665
664
    # Log this modification
666
    # Log this modification
665
    if (C4::Context->preference("AcqLog")) {
667
    if (C4::Context->preference("AcqLog")) {
666
        my $infos =
668
        my $infos = {
667
            sprintf("%010d", $budget->{budget_amount}) .
669
            budget_amount_new    => $budget->{budget_amount},
668
            sprintf("%010d", $budget->{budget_encumb}) .
670
            budget_encumb_new    => $budget->{budget_encumb},
669
            sprintf("%010d", $budget->{budget_expend}) .
671
            budget_expend_new    => $budget->{budget_expend},
670
            sprintf("%010d", $result->budget_amount) .
672
            budget_amount_old    => $result->budget_amount,
671
            sprintf("%010d", $result->budget_encumb) .
673
            budget_encumb_old    => $result->budget_encumb,
672
            sprintf("%010d", $result->budget_expend) .
674
            budget_expend_old    => $result->budget_expend,
673
            sprintf("%010d", 0 - ($result->budget_amount - $budget->{budget_amount}));
675
            budget_amount_change => 0 - ($result->budget_amount - $budget->{budget_amount})
676
        };
674
        logaction(
677
        logaction(
675
            'ACQUISITIONS',
678
            'ACQUISITIONS',
676
            'MODIFY_FUND',
679
            'MODIFY_FUND',
677
            $budget->{budget_id},
680
            $budget->{budget_id},
678
            $infos
681
            encode_json($infos)
679
        );
682
        );
680
    }
683
    }
681
684
(-)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 149-167 elsif ( $op && $op eq 'del_adj' ) { Link Here
149
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
150
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
150
    if ($del_adj) {
151
    if ($del_adj) {
151
        if (C4::Context->preference("AcqLog")) {
152
        if (C4::Context->preference("AcqLog")) {
152
            my $reason_length = length $del_adj->reason;
153
            my $infos = {
153
            my $reason_padded = ( ' ' x (80 - $reason_length) ) . $del_adj->reason;
154
                invoiceid     => $del_adj->invoiceid,
154
            my $infos =
155
                budget_id     => $del_adj->budget_id,
155
                sprintf("%010d", $del_adj->invoiceid) .
156
                encumber_open => $del_adj->encumber_open,
156
                sprintf("%010d", $del_adj->budget_id) .
157
                adjustment    => $del_adj->adjustment,
157
                sprintf("%010d", $del_adj->encumber_open) .
158
                reason        => $del_adj->reason
158
                sprintf("%010.2f", $del_adj->adjustment) .
159
            };
159
                $reason_padded;
160
            logaction(
160
            logaction(
161
                'ACQUISITIONS',
161
                'ACQUISITIONS',
162
                'DELETE_INVOICE_ADJUSTMENT',
162
                'DELETE_INVOICE_ADJUSTMENT',
163
                $adjustment_id,
163
                $adjustment_id,
164
                $infos
164
                encode_json($infos)
165
            );
165
            );
166
        }
166
        }
167
        $del_adj->delete();
167
        $del_adj->delete();
Lines 196-207 elsif ( $op && $op eq 'mod_adj' ) { Link Here
196
            $new_adj->store();
196
            $new_adj->store();
197
            # Log this addition
197
            # Log this addition
198
            if (C4::Context->preference("AcqLog")) {
198
            if (C4::Context->preference("AcqLog")) {
199
                my $infos = get_log_string($adj);
200
                logaction(
199
                logaction(
201
                    'ACQUISITIONS',
200
                    'ACQUISITIONS',
202
                    'CREATE_INVOICE_ADJUSTMENT',
201
                    'CREATE_INVOICE_ADJUSTMENT',
203
                    $new_adj->adjustment_id,
202
                    $new_adj->adjustment_id,
204
                    $infos
203
                    encode_json($adj)
205
                );
204
                );
206
            }
205
            }
207
        }
206
        }
Lines 210-216 elsif ( $op && $op eq 'mod_adj' ) { Link Here
210
            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] ){
209
            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] ){
211
                # Log this modification
210
                # Log this modification
212
                if (C4::Context->preference("AcqLog")) {
211
                if (C4::Context->preference("AcqLog")) {
213
                    my $infos = get_log_string({
212
                    my $infos = {
214
                        adjustment        => $adjustment[$i],
213
                        adjustment        => $adjustment[$i],
215
                        reason            => $reason[$i],
214
                        reason            => $reason[$i],
216
                        budget_id         => $budget_id[$i],
215
                        budget_id         => $budget_id[$i],
Lines 219-230 elsif ( $op && $op eq 'mod_adj' ) { Link Here
219
                        reason_old        => $old_adj->reason,
218
                        reason_old        => $old_adj->reason,
220
                        budget_id_old     => $old_adj->budget_id,
219
                        budget_id_old     => $old_adj->budget_id,
221
                        encumber_open_old => $old_adj->encumber_open
220
                        encumber_open_old => $old_adj->encumber_open
222
                    });
221
                    };
223
                    logaction(
222
                    logaction(
224
                        'ACQUISITIONS',
223
                        'ACQUISITIONS',
225
                        'UPDATE_INVOICE_ADJUSTMENT',
224
                        'UPDATE_INVOICE_ADJUSTMENT',
226
                        $adjustment_id[$i],
225
                        $adjustment_id[$i],
227
                        $infos
226
                        encode_json($infos)
228
                    );
227
                    );
229
                }
228
                }
230
                $old_adj->timestamp(undef);
229
                $old_adj->timestamp(undef);
Lines 351-385 sub get_infos { Link Here
351
    return \%line;
350
    return \%line;
352
}
351
}
353
352
354
sub get_log_string {
355
    my ($data) = @_;
356
357
    # We specify the keys we're dealing for logging within an array in order
358
    # to preserve order, if we just iterate the hash keys, we could get
359
    # the values in any order
360
    my @keys = (
361
        'budget_id',
362
        'encumber_open',
363
        'budget_id_old',
364
        'encumber_open_old'
365
    );
366
    # Adjustment amount
367
    my $return = sprintf("%010.2f", $data->{adjustment});
368
    # Left pad "reason" to the maximum length of aqinvoice_adjustments.reason
369
    # (80 characters)
370
    my $reason_len = length $data->{reason};
371
    $return .= ( ' ' x (80 - $reason_len) ) . $data->{reason};
372
    # Append the remaining fields
373
    foreach my $key(@keys) {
374
        $return .= sprintf("%010d", $data->{$key});
375
    }
376
    # Old adjustment amount
377
    $return .= sprintf("%010.2f", $data->{adjustment_old});
378
    # Left pad "reason_old" to the maximum length of aqinvoice_adjustments.reason
379
    # (80 characters)
380
    my $reason_old_len = length $data->{reason_old};
381
    $return .= ( ' ' x (80 - $reason_old_len) ) . $data->{reason_old};
382
    return $return;
383
}
384
385
output_html_with_http_headers $input, $cookie, $template->output;
353
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