use Modern::Perl;
use CGI qw ( -utf8 );
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
use C4::Context;
-use C4::Output;
+use C4::Output qw( output_html_with_http_headers );
-use Koha::Acquisition::Currency;
+use Koha::Acquisition::Booksellers;
use Koha::Acquisition::Currencies;
+use Koha::Acquisition::Orders;
my $input = CGI->new;
my $searchfield = $input->param('searchfield') || $input->param('description') || q{};
{ template_name => 'admin/currency.tt',
query => $input,
type => 'intranet',
- authnotrequired => 0,
- flagsrequired => { parameters => 'parameters_remaining_permissions' },
+ flagsrequired => { acquisition => 'currencies_manage' },
}
);
my $isocode = $input->param('isocode');
my $rate = $input->param('rate');
my $active = $input->param('active');
+ my $p_sep_by_space = $input->param('p_sep_by_space');
my $is_a_modif = $input->param('is_a_modif');
if ($is_a_modif) {
$currency->isocode($isocode);
$currency->rate($rate);
$currency->active($active);
+ $currency->p_sep_by_space($p_sep_by_space);
eval { $currency->store; };
if ($@) {
push @messages, { type => 'error', code => 'error_on_update' };
isocode => $isocode,
rate => $rate,
active => $active,
+ p_sep_by_space => $p_sep_by_space,
}
);
eval { $currency->store; };
} elsif ( $op eq 'delete_confirm' ) {
my $currency = Koha::Acquisition::Currencies->find($currency_code);
- # TODO rewrite the following when Koha::Acquisition::Orders will use Koha::Objects
- my $schema = Koha::Database->schema;
- my $nb_of_orders = $schema->resultset('Aqorder')->search( { currency => $currency->currency } )->count;
+ my $nb_of_orders = Koha::Acquisition::Orders->search( { currency => $currency->currency } )->count;
+ my $nb_of_vendors = Koha::Acquisition::Booksellers->search( { -or => { listprice => $currency->currency, invoiceprice => $currency->currency } })->count;
$template->param(
currency => $currency,
nb_of_orders => $nb_of_orders,
+ nb_of_vendors => $nb_of_vendors,
);
-} elsif ( $op eq 'delete' ) {
+} elsif ( $op eq 'delete_confirmed' ) {
my $currency = Koha::Acquisition::Currencies->find($currency_code);
my $deleted = eval { $currency->delete; };