X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=acqui%2Fneworderempty.pl;h=bd06b0cf0e232a343c05a19bb3efba3dceb43c4b;hb=21c8a87b781c1e13f98de5dc26d6e5a7f3dc69fd;hp=1cba13ecac33dc9b6494932c88d80d4f29c49718;hpb=554c77569d5afe52912c085d0603b9d87a062d9b;p=koha_gimpoz diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 1cba13ecac..bd06b0cf0e 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -132,6 +132,11 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){ my ($marcrecord, $encoding) = MARCfindbreeding($params->{'breedingid'}); die("Could not find the selected record in the reservoir, bailing") unless $marcrecord; + # Remove all the items (952) from the imported record + foreach my $item ($marcrecord->field('952')) { + $marcrecord->delete_field($item); + } + my $duplicatetitle; #look for duplicates ($biblionumber,$duplicatetitle) = FindDuplicate($marcrecord); @@ -173,7 +178,6 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){ } -my $cur = GetCurrency(); if ( $ordernumber eq '' ) { # create order $new = 'yes'; @@ -201,17 +205,35 @@ else { #modify order } # get currencies (for change rates calcs if needed) +my $active_currency = GetCurrency(); +my $default_currency; +if (! $data->{currency} ) { # New order no currency set + if ( $bookseller->{listprice} ) { + $default_currency = $bookseller->{listprice}; + } + else { + $default_currency = $active_currency->{currency}; + } +} + my @rates = GetCurrencies(); -my $count = scalar @rates; # ## @rates my @loop_currency = (); -for ( my $i = 0 ; $i < $count ; $i++ ) { - my %line; - $line{currency} = $rates[$i]->{'currency'}; - $line{rate} = $rates[$i]->{'rate'}; - push @loop_currency, \%line; +for my $curr ( @rates ) { + my $selected; + if ($data->{currency} ) { + $selected = $curr->{currency} eq $data->{currency}; + } + else { + $selected = $curr->{currency} eq $default_currency; + } + push @loop_currency, { + currcode => $curr->{currency}, + rate => $curr->{rate}, + selected => $selected, + } } # build branches list @@ -226,7 +248,7 @@ foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$ value => $thisbranch, branchname => $branches->{$thisbranch}->{'branchname'}, ); - $row{'selected'} = 1 if( $thisbranch eq $data->{branchcode}) ; + $row{'selected'} = 1 if( $thisbranch && $data->{branchcode} && $thisbranch eq $data->{branchcode}) ; push @branchloop, \%row; } $template->param( branchloop => \@branchloop ); @@ -246,6 +268,7 @@ foreach my $r (@{$budgets}) { push @{$budget_loop}, { b_id => $r->{budget_id}, b_txt => $r->{budget_name}, + b_active => $r->{budget_period_active}, b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, }; } @@ -340,9 +363,8 @@ $template->param( listincgst => $bookseller->{'listincgst'}, invoiceincgst => $bookseller->{'invoiceincgst'}, name => $bookseller->{'name'}, - cur_active_sym => $cur->{'symbol'}, - cur_active => $cur->{'currency'}, - currency => $bookseller->{'listprice'} || $cur->{'currency'}, # eg: 'EUR' + cur_active_sym => $active_currency->{'symbol'}, + cur_active => $active_currency->{'currency'}, loop_currencies => \@loop_currency, orderexists => ( $new eq 'yes' ) ? 0 : 1, title => $data->{'title'}, @@ -354,7 +376,7 @@ $template->param( quantity => $data->{'quantity'}, quantityrec => $data->{'quantity'}, rrp => $data->{'rrp'}, - listprice => sprintf("%.2f", $data->{'listprice'}||$listprice), + listprice => sprintf("%.2f", $data->{'listprice'}||$data->{'price'}||$listprice), total => sprintf("%.2f", ($data->{'ecost'}||0)*($data->{'quantity'}||0) ), ecost => $data->{'ecost'}, notes => $data->{'notes'},