|
Lines 39-44
use Koha::Acquisition::Booksellers;
Link Here
|
| 39 |
use Koha::Acquisition::Currencies; |
39 |
use Koha::Acquisition::Currencies; |
| 40 |
use Koha::DateUtils; |
40 |
use Koha::DateUtils; |
| 41 |
use Koha::Misc::Files; |
41 |
use Koha::Misc::Files; |
|
|
42 |
use Koha::InvoiceAdjustments; |
| 43 |
use Koha::InvoiceAdjustment; |
| 42 |
|
44 |
|
| 43 |
my $input = new CGI; |
45 |
my $input = new CGI; |
| 44 |
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( |
46 |
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( |
|
Lines 109-115
elsif ( $op && $op eq 'delete' ) {
Link Here
|
| 109 |
exit 0; |
111 |
exit 0; |
| 110 |
} |
112 |
} |
| 111 |
} |
113 |
} |
|
|
114 |
elsif ( $op && $op eq 'mod_adj' ) { |
| 115 |
my @adjustment_id = $input->multi_param('adjustment_id'); |
| 116 |
my @adjustment = $input->multi_param('adjustment'); |
| 117 |
my @reason = $input->multi_param('reason'); |
| 118 |
my @budget_id = $input->multi_param('budget_id'); |
| 119 |
my @encumber_open = $input->multi_param('encumber_open'); |
| 120 |
my @delete = $input->multi_param('delete'); |
| 112 |
|
121 |
|
|
|
122 |
for( my $i=0; $i < scalar @adjustment; $i++ ){ |
| 123 |
warn "Delete is ".$delete[$i]; |
| 124 |
if( $adjustment_id[$i] eq 'new' ){ |
| 125 |
next unless ( $adjustment[$i] || $reason[$i] ); |
| 126 |
my $new_adj = Koha::InvoiceAdjustment->new({ |
| 127 |
invoiceid => $invoiceid, |
| 128 |
adjustment => $adjustment[$i], |
| 129 |
reason => $reason[$i], |
| 130 |
budget_id => $budget_id[$i] || undef, |
| 131 |
encumber_open => $encumber_open[$i], |
| 132 |
}); |
| 133 |
warn Data::Dumper::Dumper( $new_adj->unblessed ); |
| 134 |
$new_adj->store(); |
| 135 |
} |
| 136 |
elsif ( $delete[$i] == 1 ){ |
| 137 |
my $del_adj = Koha::InvoiceAdjustments->find( $adjustment_id[$i] ); |
| 138 |
$del_adj->delete(); |
| 139 |
} |
| 140 |
else { |
| 141 |
my $old_adj = Koha::InvoiceAdjustments->find( $adjustment_id[$i] ); |
| 142 |
unless ( 0 && $old_adj->adjustment == $adjustment[$i] && $old_adj->reason eq $reason[$i] && $old_adj->budget_id == $budget_id[$i] && $old_adj->encumber_open == $encumber_open[$i] ){ |
| 143 |
$old_adj->timestamp(undef); |
| 144 |
$old_adj->adjustment( $adjustment[$i] ); |
| 145 |
$old_adj->reason( $reason[$i] ); |
| 146 |
$old_adj->budget_id( $budget_id[$i] || undef ); |
| 147 |
$old_adj->encumber_open( $encumber_open[$i] ); |
| 148 |
$old_adj->update(); |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 113 |
|
153 |
|
| 114 |
my $details = GetInvoiceDetails($invoiceid); |
154 |
my $details = GetInvoiceDetails($invoiceid); |
| 115 |
my $bookseller = Koha::Acquisition::Booksellers->find( $details->{booksellerid} ); |
155 |
my $bookseller = Koha::Acquisition::Booksellers->find( $details->{booksellerid} ); |
|
Lines 160-165
foreach my $budget (@$budgets) {
Link Here
|
| 160 |
push @budgets_loop, \%line; |
200 |
push @budgets_loop, \%line; |
| 161 |
} |
201 |
} |
| 162 |
|
202 |
|
|
|
203 |
my $adjustments = Koha::InvoiceAdjustments->search({ invoiceid => $details->{'invoiceid'} }); |
| 204 |
if ( $adjustments ) { $template->param( adjustments => $adjustments ); } |
| 205 |
|
| 163 |
$template->param( |
206 |
$template->param( |
| 164 |
invoiceid => $details->{'invoiceid'}, |
207 |
invoiceid => $details->{'invoiceid'}, |
| 165 |
invoicenumber => $details->{'invoicenumber'}, |
208 |
invoicenumber => $details->{'invoicenumber'}, |