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

(-)a/C4/Budgets.pm (-36 / +78 lines)
Lines 24-35 use Koha::Patrons; Link Here
24
use Koha::Acquisition::Invoice::Adjustments;
24
use Koha::Acquisition::Invoice::Adjustments;
25
use C4::Debug;
25
use C4::Debug;
26
use C4::Acquisition;
26
use C4::Acquisition;
27
use C4::Log qw(logaction);
27
use vars qw(@ISA @EXPORT);
28
use vars qw(@ISA @EXPORT);
28
29
29
BEGIN {
30
BEGIN {
30
	require Exporter;
31
    require Exporter;
31
	@ISA    = qw(Exporter);
32
    @ISA    = qw(Exporter);
32
	@EXPORT = qw(
33
    @EXPORT = qw(
33
34
34
        &GetBudget
35
        &GetBudget
35
        &GetBudgetByOrderNumber
36
        &GetBudgetByOrderNumber
Lines 39-45 BEGIN { Link Here
39
        &GetBudgetsReport
40
        &GetBudgetsReport
40
        &GetBudgetReport
41
        &GetBudgetReport
41
        &GetBudgetHierarchy
42
        &GetBudgetHierarchy
42
	    &AddBudget
43
        &AddBudget
43
        &ModBudget
44
        &ModBudget
44
        &DelBudget
45
        &DelBudget
45
        &GetBudgetSpent
46
        &GetBudgetSpent
Lines 54-68 BEGIN { Link Here
54
        &CanUserUseBudget
55
        &CanUserUseBudget
55
        &CanUserModifyBudget
56
        &CanUserModifyBudget
56
57
57
	    &GetBudgetPeriod
58
        &GetBudgetPeriod
58
        &GetBudgetPeriods
59
        &GetBudgetPeriods
59
        &ModBudgetPeriod
60
        &ModBudgetPeriod
60
        &AddBudgetPeriod
61
        &AddBudgetPeriod
61
	    &DelBudgetPeriod
62
        &DelBudgetPeriod
62
63
63
        &ModBudgetPlan
64
        &ModBudgetPlan
64
65
65
		&GetBudgetsPlanCell
66
        &GetBudgetsPlanCell
66
        &AddBudgetPlanValue
67
        &AddBudgetPlanValue
67
        &GetBudgetAuthCats
68
        &GetBudgetAuthCats
68
        &BudgetHasChildren
69
        &BudgetHasChildren
Lines 71-77 BEGIN { Link Here
71
72
72
        &HideCols
73
        &HideCols
73
        &GetCols
74
        &GetCols
74
	);
75
    );
75
}
76
}
76
77
77
# ----------------------------BUDGETS.PM-----------------------------";
78
# ----------------------------BUDGETS.PM-----------------------------";
Lines 341-347 sub GetBudgetSpent { Link Here
341
            quantityreceived > 0 AND
342
            quantityreceived > 0 AND
342
            datecancellationprinted IS NULL
343
            datecancellationprinted IS NULL
343
    |);
344
    |);
344
	$sth->execute($budget_id);
345
    $sth->execute($budget_id);
345
    my $sum = ( $sth->fetchrow_array || 0 ) + 0;
346
    my $sum = ( $sth->fetchrow_array || 0 ) + 0;
346
347
347
    $sth = $dbh->prepare(qq|
348
    $sth = $dbh->prepare(qq|
Lines 359-378 sub GetBudgetSpent { Link Here
359
        $sum += $adj->adjustment;
360
        $sum += $adj->adjustment;
360
    }
361
    }
361
362
362
	return $sum;
363
    return $sum;
363
}
364
}
364
365
365
# -------------------------------------------------------------------
366
# -------------------------------------------------------------------
366
sub GetBudgetOrdered {
367
sub GetBudgetOrdered {
367
	my ($budget_id) = @_;
368
    my ($budget_id) = @_;
368
	my $dbh = C4::Context->dbh;
369
    my $dbh = C4::Context->dbh;
369
	my $sth = $dbh->prepare(qq|
370
    my $sth = $dbh->prepare(qq|
370
        SELECT SUM(| . C4::Acquisition::get_rounding_sql(qq|ecost_tax_included|) . qq| *  quantity) AS sum FROM aqorders
371
        SELECT SUM(| . C4::Acquisition::get_rounding_sql(qq|ecost_tax_included|) . qq| *  quantity) AS sum FROM aqorders
371
            WHERE budget_id = ? AND
372
            WHERE budget_id = ? AND
372
            quantityreceived = 0 AND
373
            quantityreceived = 0 AND
373
            datecancellationprinted IS NULL
374
            datecancellationprinted IS NULL
374
    |);
375
    |);
375
	$sth->execute($budget_id);
376
    $sth->execute($budget_id);
376
    my $sum =  ( $sth->fetchrow_array || 0 ) + 0;
377
    my $sum =  ( $sth->fetchrow_array || 0 ) + 0;
377
378
378
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
379
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
Lines 380-386 sub GetBudgetOrdered { Link Here
380
        $sum += $adj->adjustment;
381
        $sum += $adj->adjustment;
381
    }
382
    }
382
383
383
	return $sum;
384
    return $sum;
384
}
385
}
385
386
386
=head2 GetBudgetName
387
=head2 GetBudgetName
Lines 430-436 sub GetBudgetAuthCats { Link Here
430
431
431
# -------------------------------------------------------------------
432
# -------------------------------------------------------------------
432
sub GetBudgetPeriods {
433
sub GetBudgetPeriods {
433
	my ($filters,$orderby) = @_;
434
    my ($filters,$orderby) = @_;
434
435
435
    my $rs = Koha::Database->new()->schema->resultset('Aqbudgetperiod');
436
    my $rs = Koha::Database->new()->schema->resultset('Aqbudgetperiod');
436
    $rs = $rs->search( $filters, { order_by => $orderby } );
437
    $rs = $rs->search( $filters, { order_by => $orderby } );
Lines 451-468 sub GetBudgetPeriod { Link Here
451
}
452
}
452
453
453
sub DelBudgetPeriod{
454
sub DelBudgetPeriod{
454
	my ($budget_period_id) = @_;
455
    my ($budget_period_id) = @_;
455
	my $dbh = C4::Context->dbh;
456
    my $dbh = C4::Context->dbh;
456
	  ; ## $total = number of records linked to the record that must be deleted
457
      ; ## $total = number of records linked to the record that must be deleted
457
    my $total = 0;
458
    my $total = 0;
458
459
459
	## get information about the record that will be deleted
460
    ## get information about the record that will be deleted
460
	my $sth = $dbh->prepare(qq|
461
    my $sth = $dbh->prepare(qq|
461
		DELETE 
462
        DELETE
462
         FROM aqbudgetperiods
463
         FROM aqbudgetperiods
463
         WHERE budget_period_id=? |
464
         WHERE budget_period_id=? |
464
	);
465
    );
465
	return $sth->execute($budget_period_id);
466
    return $sth->execute($budget_period_id);
466
}
467
}
467
468
468
# -------------------------------------------------------------------
469
# -------------------------------------------------------------------
Lines 487-499 sub GetBudgetHierarchy { Link Here
487
                    LEFT JOIN borrowers b on b.borrowernumber = aqbudgets.budget_owner_id
488
                    LEFT JOIN borrowers b on b.borrowernumber = aqbudgets.budget_owner_id
488
                    JOIN aqbudgetperiods USING (budget_period_id)|;
489
                    JOIN aqbudgetperiods USING (budget_period_id)|;
489
490
490
	my @where_strings;
491
    my @where_strings;
491
    # show only period X if requested
492
    # show only period X if requested
492
    if ($budget_period_id) {
493
    if ($budget_period_id) {
493
        push @where_strings," aqbudgets.budget_period_id = ?";
494
        push @where_strings," aqbudgets.budget_period_id = ?";
494
        push @bind_params, $budget_period_id;
495
        push @bind_params, $budget_period_id;
495
    }
496
    }
496
	# show only budgets owned by me, my branch or everyone
497
    # show only budgets owned by me, my branch or everyone
497
    if ($owner) {
498
    if ($owner) {
498
        if ($branchcode) {
499
        if ($branchcode) {
499
            push @where_strings,
500
            push @where_strings,
Lines 509-518 sub GetBudgetHierarchy { Link Here
509
            push @bind_params, $branchcode;
510
            push @bind_params, $branchcode;
510
        }
511
        }
511
    }
512
    }
512
	$query.=" WHERE ".join(' AND ', @where_strings) if @where_strings;
513
    $query.=" WHERE ".join(' AND ', @where_strings) if @where_strings;
513
	$debug && warn $query,join(",",@bind_params);
514
    $debug && warn $query,join(",",@bind_params);
514
	my $sth = $dbh->prepare($query);
515
    my $sth = $dbh->prepare($query);
515
	$sth->execute(@bind_params);
516
    $sth->execute(@bind_params);
516
517
517
    my %links;
518
    my %links;
518
    # create hash with budget_id has key
519
    # create hash with budget_id has key
Lines 644-650 sub AddBudget { Link Here
644
    undef $budget->{budget_encumb}   if defined $budget->{budget_encumb}   && $budget->{budget_encumb}   eq '';
645
    undef $budget->{budget_encumb}   if defined $budget->{budget_encumb}   && $budget->{budget_encumb}   eq '';
645
    undef $budget->{budget_owner_id} if defined $budget->{budget_owner_id} && $budget->{budget_owner_id} eq '';
646
    undef $budget->{budget_owner_id} if defined $budget->{budget_owner_id} && $budget->{budget_owner_id} eq '';
646
    my $resultset = Koha::Database->new()->schema->resultset('Aqbudget');
647
    my $resultset = Koha::Database->new()->schema->resultset('Aqbudget');
647
    return $resultset->create($budget)->id;
648
    my $id = $resultset->create($budget)->id;
649
650
    # Log the addition
651
    if (C4::Context->preference("AcqLog")) {
652
        my $infos =
653
            sprintf("%010d", $budget->{budget_amount}) .
654
            sprintf("%010d", $budget->{budget_encumb}) .
655
            sprintf("%010d", $budget->{budget_expend});
656
        logaction(
657
            'ACQUISITIONS',
658
            'CREATE_FUND',
659
            $id,
660
            $infos
661
        );
662
    }
663
    return $id;
648
}
664
}
649
665
650
# -------------------------------------------------------------------
666
# -------------------------------------------------------------------
Lines 654-659 sub ModBudget { Link Here
654
    my $result = Koha::Database->new()->schema->resultset('Aqbudget')->find($budget);
670
    my $result = Koha::Database->new()->schema->resultset('Aqbudget')->find($budget);
655
    return unless($result);
671
    return unless($result);
656
672
673
    # Log this modification
674
    if (C4::Context->preference("AcqLog")) {
675
        my $infos =
676
            sprintf("%010d", $budget->{budget_amount}) .
677
            sprintf("%010d", $budget->{budget_encumb}) .
678
            sprintf("%010d", $budget->{budget_expend}) .
679
            sprintf("%010d", $result->budget_amount) .
680
            sprintf("%010d", $result->budget_encumb) .
681
            sprintf("%010d", $result->budget_expend) .
682
            sprintf("%010d", 0 - ($result->budget_amount - $budget->{budget_amount}));
683
        logaction(
684
            'ACQUISITIONS',
685
            'MODIFY_FUND',
686
            $budget->{budget_id},
687
            $infos
688
        );
689
    }
690
657
    undef $budget->{budget_encumb}   if defined $budget->{budget_encumb}   && $budget->{budget_encumb}   eq '';
691
    undef $budget->{budget_encumb}   if defined $budget->{budget_encumb}   && $budget->{budget_encumb}   eq '';
658
    undef $budget->{budget_owner_id} if defined $budget->{budget_owner_id} && $budget->{budget_owner_id} eq '';
692
    undef $budget->{budget_owner_id} if defined $budget->{budget_owner_id} && $budget->{budget_owner_id} eq '';
659
    $result = $result->update($budget);
693
    $result = $result->update($budget);
Lines 663-673 sub ModBudget { Link Here
663
# -------------------------------------------------------------------
697
# -------------------------------------------------------------------
664
# FIXME Must be replaced by Koha::Acquisition::Fund->delete
698
# FIXME Must be replaced by Koha::Acquisition::Fund->delete
665
sub DelBudget {
699
sub DelBudget {
666
	my ($budget_id) = @_;
700
    my ($budget_id) = @_;
667
	my $dbh         = C4::Context->dbh;
701
    my $dbh         = C4::Context->dbh;
668
	my $sth         = $dbh->prepare("delete from aqbudgets where budget_id=?");
702
    my $sth         = $dbh->prepare("delete from aqbudgets where budget_id=?");
669
	my $rc          = $sth->execute($budget_id);
703
    my $rc          = $sth->execute($budget_id);
670
	return $rc;
704
    # Log the deletion
705
    if (C4::Context->preference("AcqLog")) {
706
        logaction(
707
            'ACQUISITIONS',
708
            'DELETE_FUND',
709
            $budget_id
710
        );
711
    }
712
    return $rc;
671
}
713
}
672
714
673
715
(-)a/acqui/addorder.pl (+43 lines)
Lines 231-236 my $user = $input->remote_user; Link Here
231
my $basketno = $$orderinfo{basketno};
231
my $basketno = $$orderinfo{basketno};
232
my $basket   = Koha::Acquisition::Baskets->find($basketno);
232
my $basket   = Koha::Acquisition::Baskets->find($basketno);
233
233
234
# Order related fields we're going to log
235
my @log_order_fields = (
236
    'quantity',
237
    'listprice',
238
    'unitprice',
239
    'unitprice_tax_excluded',
240
    'unitprice_tax_included',
241
    'rrp',
242
    'replacementprice',
243
    'rrp_tax_excluded',
244
    'rrp_tax_included',
245
    'ecost',
246
    'ecost_tax_excluded',
247
    'ecost_tax_included',
248
    'tax_rate_on_ordering'
249
);
250
234
# create, modify or delete biblio
251
# create, modify or delete biblio
235
# create if $quantity>0 and $existing='no'
252
# create if $quantity>0 and $existing='no'
236
# modify if $quantity>0 and $existing='yes'
253
# modify if $quantity>0 and $existing='yes'
Lines 295-303 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
295
    my $order = Koha::Acquisition::Order->new($orderinfo);
312
    my $order = Koha::Acquisition::Order->new($orderinfo);
296
    if ( $orderinfo->{ordernumber} ) {
313
    if ( $orderinfo->{ordernumber} ) {
297
        ModOrder($orderinfo);
314
        ModOrder($orderinfo);
315
        # Log the order modification
316
        if (C4::Context->preference("AcqLog")) {
317
            my $infos = '';
318
            foreach my $field(@log_order_fields) {
319
                $infos .= sprintf("%010d", $orderinfo->{$field});
320
            }
321
            logaction(
322
                'ACQUISITIONS',
323
                'MODIFY_ORDER',
324
                $orderinfo->{ordernumber},
325
                $infos
326
            );
327
        }
298
    }
328
    }
299
    else { # else, it's a new line
329
    else { # else, it's a new line
300
        $order->store;
330
        $order->store;
331
        # Log the order creation
332
        if (C4::Context->preference("AcqLog")) {
333
            my $infos = '';
334
            foreach my $field(@log_order_fields) {
335
                $infos .= sprintf("%010d", $orderinfo->{$field});
336
            }
337
            logaction(
338
                'ACQUISITIONS',
339
                'CREATE_ORDER',
340
                $order->ordernumber,
341
                $infos
342
            );
343
        }
301
    }
344
    }
302
    my $order_users_ids = $input->param('users_ids');
345
    my $order_users_ids = $input->param('users_ids');
303
    my @order_users = split( /:/, $order_users_ids );
346
    my @order_users = split( /:/, $order_users_ids );
(-)a/acqui/cancelorder.pl (+5 lines)
Lines 35-40 use CGI; Link Here
35
use C4::Auth;
35
use C4::Auth;
36
use C4::Output;
36
use C4::Output;
37
use C4::Acquisition;
37
use C4::Acquisition;
38
use C4::Log qw(logaction);
38
use Koha::Acquisition::Baskets;
39
use Koha::Acquisition::Baskets;
39
40
40
my $input = new CGI;
41
my $input = new CGI;
Lines 63-68 if($action and $action eq "confirmcancel") { Link Here
63
        $template->param(error_delbiblio => 1) if $error->{'delbiblio'};
64
        $template->param(error_delbiblio => 1) if $error->{'delbiblio'};
64
    } else {
65
    } else {
65
        $template->param(success_cancelorder => 1);
66
        $template->param(success_cancelorder => 1);
67
        # Log the cancellation of the order
68
        if (C4::Context->preference("AcqLog")) {
69
            logaction('ACQUISITIONS', 'CANCEL_ORDER', $ordernumber);
70
        }
66
    }
71
    }
67
    $template->param(confirmcancel => 1);
72
    $template->param(confirmcancel => 1);
68
}
73
}
(-)a/acqui/finishreceive.pl (+18 lines)
Lines 28-33 use C4::Context; Link Here
28
use C4::Acquisition;
28
use C4::Acquisition;
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Items;
30
use C4::Items;
31
use C4::Log qw(logaction);
31
use C4::Search;
32
use C4::Search;
32
33
33
use Koha::Number::Price;
34
use Koha::Number::Price;
Lines 190-193 if ($suggestion_id) { Link Here
190
    $suggestion->update( { reason => $reason } ) if $suggestion;
191
    $suggestion->update( { reason => $reason } ) if $suggestion;
191
}
192
}
192
193
194
# Log the receipt
195
if (C4::Context->preference("AcqLog")) {
196
    my $infos =
197
        sprintf("%010d", $quantityrec) .
198
        sprintf("%010d", $bookfund) .
199
        sprintf("%010.2f", $input->param("tax_rate")) .
200
        sprintf("%010.2f", $replacementprice) .
201
        sprintf("%010.2f", $unitprice);
202
203
    logaction(
204
        'ACQUISITIONS',
205
        'RECEIVE_ORDER',
206
        $ordernumber,
207
        $infos
208
    );
209
}
210
193
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&sticky_filters=1");
211
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&sticky_filters=1");
(-)a/acqui/invoice.pl (-4 / +85 lines)
Lines 33-38 use C4::Auth; Link Here
33
use C4::Output;
33
use C4::Output;
34
use C4::Acquisition;
34
use C4::Acquisition;
35
use C4::Budgets;
35
use C4::Budgets;
36
use C4::Log qw(logaction);
36
37
37
use Koha::Acquisition::Booksellers;
38
use Koha::Acquisition::Booksellers;
38
use Koha::Acquisition::Currencies;
39
use Koha::Acquisition::Currencies;
Lines 141-147 elsif ( $op && $op eq 'del_adj' ) { Link Here
141
142
142
    my $adjustment_id  = $input->param('adjustment_id');
143
    my $adjustment_id  = $input->param('adjustment_id');
143
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
144
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
144
    $del_adj->delete() if ($del_adj);
145
    if ($del_adj) {
146
        if (C4::Context->preference("AcqLog")) {
147
            my $reason_length = length $del_adj->reason;
148
            my $reason_padded = ( ' ' x (80 - $reason_length) ) . $del_adj->reason;
149
            my $infos =
150
                sprintf("%010d", $del_adj->invoiceid) .
151
                sprintf("%010d", $del_adj->budget_id) .
152
                sprintf("%010d", $del_adj->encumber_open) .
153
                sprintf("%010.2f", $del_adj->adjustment) .
154
                $reason_padded;
155
            logaction(
156
                'ACQUISITIONS',
157
                'DELETE_INVOICE_ADJUSTMENT',
158
                $adjustment_id,
159
                $infos
160
            );
161
        }
162
        $del_adj->delete();
163
    }
145
}
164
}
146
elsif ( $op && $op eq 'mod_adj' ) {
165
elsif ( $op && $op eq 'mod_adj' ) {
147
166
Lines 156-177 elsif ( $op && $op eq 'mod_adj' ) { Link Here
156
    my @encumber_open  = $input->multi_param('encumber_open');
175
    my @encumber_open  = $input->multi_param('encumber_open');
157
    my %e_open = map { $_ => 1 } @encumber_open;
176
    my %e_open = map { $_ => 1 } @encumber_open;
158
177
178
	my @keys = ('adjustment', 'reason', 'budget_id', 'encumber_open');
159
    for( my $i=0; $i < scalar @adjustment; $i++ ){
179
    for( my $i=0; $i < scalar @adjustment; $i++ ){
160
        if( $adjustment_id[$i] eq 'new' ){
180
        if( $adjustment_id[$i] eq 'new' ){
161
            next unless ( $adjustment[$i] || $reason[$i] );
181
            next unless ( $adjustment[$i] || $reason[$i] );
162
            my $new_adj = Koha::Acquisition::Invoice::Adjustment->new({
182
			my $adj = {
163
                invoiceid => $invoiceid,
183
				invoiceid => $invoiceid,
164
                adjustment => $adjustment[$i],
184
                adjustment => $adjustment[$i],
165
                reason => $reason[$i],
185
                reason => $reason[$i],
166
                note => $note[$i],
186
                note => $note[$i],
167
                budget_id => $budget_id[$i] || undef,
187
                budget_id => $budget_id[$i] || undef,
168
                encumber_open => defined $e_open{ $adjustment_id[$i] } ? 1 : 0,
188
                encumber_open => defined $e_open{ $adjustment_id[$i] } ? 1 : 0,
169
            });
189
            };
190
			my $new_adj = Koha::Acquisition::Invoice::Adjustment->new($adj);
170
            $new_adj->store();
191
            $new_adj->store();
192
            # Log this addition
193
            if (C4::Context->preference("AcqLog")) {
194
                my $infos = get_log_string($adj);
195
                logaction(
196
                    'ACQUISITIONS',
197
                    'CREATE_INVOICE_ADJUSTMENT',
198
                    $new_adj->adjustment_id,
199
                    $infos
200
                );
201
            }
171
        }
202
        }
172
        else {
203
        else {
173
            my $old_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id[$i] );
204
            my $old_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id[$i] );
174
            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] ){
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] ){
206
                # Log this modification
207
                if (C4::Context->preference("AcqLog")) {
208
                    my $infos = get_log_string({
209
                        adjustment        => $adjustment[$i],
210
                        reason            => $reason[$i],
211
                        budget_id         => $budget_id[$i],
212
                        encumber_open     => $e_open{$adjustment_id[$i]},
213
                        adjustment_old    => $old_adj->adjustment,
214
                        reason_old        => $old_adj->reason,
215
                        budget_id_old     => $old_adj->budget_id,
216
                        encumber_open_old => $old_adj->encumber_open
217
                    });
218
                    logaction(
219
                        'ACQUISITIONS',
220
                        'UPDATE_INVOICE_ADJUSTMENT',
221
                        $adjustment_id[$i],
222
                        $infos
223
                    );
224
                }
175
                $old_adj->timestamp(undef);
225
                $old_adj->timestamp(undef);
176
                $old_adj->adjustment( $adjustment[$i] );
226
                $old_adj->adjustment( $adjustment[$i] );
177
                $old_adj->reason( $reason[$i] );
227
                $old_adj->reason( $reason[$i] );
Lines 296-299 sub get_infos { Link Here
296
    return \%line;
346
    return \%line;
297
}
347
}
298
348
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
299
output_html_with_http_headers $input, $cookie, $template->output;
380
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/admin/aqbudgetperiods.pl (-8 / +29 lines)
Lines 57-62 use C4::Output; Link Here
57
use C4::Acquisition;
57
use C4::Acquisition;
58
use C4::Budgets;
58
use C4::Budgets;
59
use C4::Debug;
59
use C4::Debug;
60
use C4::Log qw(logaction);
60
use Koha::Acquisition::Currencies;
61
use Koha::Acquisition::Currencies;
61
62
62
my $dbh = C4::Context->dbh;
63
my $dbh = C4::Context->dbh;
Lines 115-128 elsif ( $op eq 'add_validate' ) { Link Here
115
## add or modify a budget period (confirmation)
116
## add or modify a budget period (confirmation)
116
117
117
    ## update budget period data
118
    ## update budget period data
118
	if ( $budget_period_id ne '' ) {
119
    if ( $budget_period_id ne '' ) {
119
		$$budget_period_hashref{$_}||=0 for qw(budget_period_active budget_period_locked);
120
        # Grab the previous values so we can log them
120
		my $status=ModBudgetPeriod($budget_period_hashref);
121
        my $budgetperiod_old=GetBudgetPeriod($budget_period_id);
121
	} 
122
        $$budget_period_hashref{$_}||=0 for qw(budget_period_active budget_period_locked);
122
	else {    # ELSE ITS AN ADD
123
        my $status=ModBudgetPeriod($budget_period_hashref);
123
		my $budget_period_id=AddBudgetPeriod($budget_period_hashref);
124
        # Log the budget modification
124
	}
125
        if (C4::Context->preference("AcqLog")) {
125
	$op='else';
126
            my $diff = 0 - ($budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total});
127
            my $infos =
128
                eval { output_pref({ dt => dt_from_string( $input->param('budget_period_startdate') ), dateformat => 'iso', dateonly => 1 } ); } .
129
                eval { output_pref({ dt => dt_from_string( $input->param('budget_period_enddate') ), dateformat => 'iso', dateonly => 1 } ); } .
130
                sprintf("%010d", $budget_period_hashref->{budget_period_total}) .
131
                eval { output_pref({ dt => dt_from_string( $budgetperiod_old->{budget_period_startdate} ), dateformat => 'iso', dateonly => 1 } ); } .
132
                eval { output_pref({ dt => dt_from_string( $budgetperiod_old->{budget_period_enddate} ), dateformat => 'iso', dateonly => 1 } ); } .
133
                sprintf("%010d", $budgetperiod_old->{budget_period_total}) .
134
                sprintf("%010d", $diff);
135
            logaction(
136
                'ACQUISITIONS',
137
                'MODIFY_BUDGET',
138
                $budget_period_id,
139
                $infos
140
            );
141
        }
142
    }
143
    else {    # ELSE ITS AN ADD
144
        my $budget_period_id=AddBudgetPeriod($budget_period_hashref);
145
    }
146
    $op='else';
126
}
147
}
127
148
128
#--------------------------------------------------
149
#--------------------------------------------------
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt (-2 / +12 lines)
Lines 109-114 Link Here
109
[%        CASE 'CLOSE_BASKET' %]Close an acquisitions basket
109
[%        CASE 'CLOSE_BASKET' %]Close an acquisitions basket
110
[%        CASE 'APPROVE_BASKET' %]Approve an acquisitions basket
110
[%        CASE 'APPROVE_BASKET' %]Approve an acquisitions basket
111
[%        CASE 'REOPEN_BASKET' %]Reopen an acquisitions basket
111
[%        CASE 'REOPEN_BASKET' %]Reopen an acquisitions basket
112
[%        CASE 'CANCEL_ORDER' %]Cancel an order
113
[%        CASE 'CREATE_ORDER' %]Create an order
114
[%        CASE 'MODIFY_ORDER' %]Modify an order
115
[%        CASE 'CREATE_INVOICE_ADJUSTMENT' %]Create an invoice adjustment
116
[%        CASE 'UPDATE_INVOICE_ADJUSTMENT' %]Modify an invoice adjustment
117
[%        CASE 'DELETE_INVOICE_ADJUSTMENT' %]Delete an invoice adjustment
118
[%        CASE 'RECEIVE_ORDER' %]Receive an order
119
[%        CASE 'MODIFY_BUDGET' %]Modify a budget
120
[%        CASE 'CREATE_FUND' %]Create a fund
121
[%        CASE 'MODIFY_FUND' %]Modify a fund
122
[%        CASE 'DELETE_FUND' %]Delete a fund
112
[%        CASE 'Run'    %]Run
123
[%        CASE 'Run'    %]Run
113
[%        CASE %][% action | html %]
124
[%        CASE %][% action | html %]
114
[%    END %]
125
[%    END %]
Lines 183-189 Link Here
183
                                        <label for="actionALL" class="viewlog"><input type="checkbox" id="actionALL" name="actions" value=""> All</label>
194
                                        <label for="actionALL" class="viewlog"><input type="checkbox" id="actionALL" name="actions" value=""> All</label>
184
                                    [% END %]
195
                                    [% END %]
185
196
186
                                    [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'CHANGE PASS' 'Run' 'ADD_BASKET' 'MODIFY_BASKET' 'MODIFY_BASKET_HEADER' 'MODIFY_BASKET_USERS' 'CLOSE_BASKET' 'APPROVE_BASKET' 'REOPEN_BASKET' ] %]
197
									[% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'CHANGE PASS' 'Run' 'ADD_BASKET' 'MODIFY_BASKET' 'MODIFY_BASKET_HEADER' 'MODIFY_BASKET_USERS' 'CLOSE_BASKET' 'APPROVE_BASKET' 'REOPEN_BASKET' 'CANCEL_ORDER' 'CREATE_ORDER' 'MODIFY_ORDER' 'CREATE_INVOICE_ADJUSTMENT' 'UPDATE_INVOICE_ADJUSTMENT' 'DELETE_INVOICE_ADJUSTMENT' 'RECEIVE_ORDER' 'MODIFY_BUDGET' 'MODIFY_FUND' 'CREATE_FUND' 'DELETE_FUND' ] %]
187
                                        [% IF actions.grep(actx).size %]
198
                                        [% IF actions.grep(actx).size %]
188
                                            <label for="action[% actx | html %]" class="viewlog"><input type="checkbox" id="action[% actx | html %]" name="actions" value="[% actx | html %]" checked="checked"> [% PROCESS translate_log_action action=actx %]</label>
199
                                            <label for="action[% actx | html %]" class="viewlog"><input type="checkbox" id="action[% actx | html %]" name="actions" value="[% actx | html %]" checked="checked"> [% PROCESS translate_log_action action=actx %]</label>
189
                                        [% ELSE %]
200
                                        [% ELSE %]
190
- 

Return to bug 24190