use C4::Output;
use C4::Context;
use C4::Search qw/enabled_staff_search_views/;
-use Koha::DateUtils;
+use Koha::AuthorisedValues;
+use Koha::DateUtils;
use Koha::Acquisition::Bookseller;
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
C4::Serials::ReopenSubscription( $subscriptionid );
}
-# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
+# the subscription must be deletable if there is NO issues for a reason or another (should not happened, but...)
# Permission needed if it is a deletion (del) : delete_subscription
# Permission needed otherwise : *
my $subs = GetSubscription($subscriptionid);
+
+output_and_exit( $query, $cookie, $template, 'unknown_subscription')
+ unless $subs;
+
$subs->{enddate} ||= GetExpirationDate($subscriptionid);
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
$subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } )
if $subs->{$date};
}
-$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
+my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} });
+$subs->{location} = $av->count ? $av->next->lib : '';
$subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid});
$template->param(%{ $subs });
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
my $default_bib_view = get_default_view();
-my ( $order, $bookseller, $tmpl_infos );
-if ( defined $subscriptionid ) {
- my $lastOrderNotReceived = GetLastOrderNotReceivedFromSubscriptionid $subscriptionid;
- my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid;
- if ( defined $lastOrderNotReceived ) {
- my $basket = GetBasket $lastOrderNotReceived->{basketno};
- my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
- ( $tmpl_infos->{valuegsti_ordered}, $tmpl_infos->{valuegste_ordered} ) = get_value_with_gst_params ( $lastOrderNotReceived->{ecost}, $lastOrderNotReceived->{gstrate}, $bookseller );
- $tmpl_infos->{valuegsti_ordered} = sprintf( "%.2f", $tmpl_infos->{valuegsti_ordered} );
- $tmpl_infos->{valuegste_ordered} = sprintf( "%.2f", $tmpl_infos->{valuegste_ordered} );
- $tmpl_infos->{budget_name_ordered} = GetBudgetName $lastOrderNotReceived->{budget_id};
- $tmpl_infos->{basketno} = $lastOrderNotReceived->{basketno};
- $tmpl_infos->{ordered_exists} = 1;
- }
- if ( defined $lastOrderReceived ) {
- my $basket = GetBasket $lastOrderReceived->{basketno};
- my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
- ( $tmpl_infos->{valuegsti_spent}, $tmpl_infos->{valuegste_spent} ) = get_value_with_gst_params ( $lastOrderReceived->{unitprice}, $lastOrderReceived->{gstrate}, $bookseller );
- $tmpl_infos->{valuegsti_spent} = sprintf( "%.2f", $tmpl_infos->{valuegsti_spent} );
- $tmpl_infos->{valuegste_spent} = sprintf( "%.2f", $tmpl_infos->{valuegste_spent} );
- $tmpl_infos->{budget_name_spent} = GetBudgetName $lastOrderReceived->{budget_id};
- $tmpl_infos->{invoiceid} = $lastOrderReceived->{invoiceid};
- $tmpl_infos->{spent_exists} = 1;
- }
-}
-
my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
for my $field ( @$additional_fields ) {
if ( $field->{authorised_value_category} ) {
}
$template->param( additional_fields_for_subscription => $additional_fields );
+# FIXME Do we want to hide canceled orders?
+my $orders = Koha::Acquisition::Orders->search( { subscriptionid => $subscriptionid }, { order_by => { -desc => 'parent_ordernumber' } } );
+
$template->param(
subscriptionid => $subscriptionid,
serialslist => \@serialslist,
intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'),
irregular_issues => scalar @irregular_issues,
default_bib_view => $default_bib_view,
+ orders => $orders,
(uc(C4::Context->preference("marcflavour"))) => 1,
- show_acquisition_details => defined $tmpl_infos->{ordered_exists} || defined $tmpl_infos->{spent_exists} ? 1 : 0,
- basketno => $order->{basketno},
- %$tmpl_infos,
);
output_html_with_http_headers $query, $cookie, $template->output;
}
return 'detail';
}
-
-sub get_value_with_gst_params {
- my $value = shift;
- my $gstrate = shift;
- my $bookseller = shift;
- if ( $bookseller->{listincgst} ) {
- return ( $value, $value / ( 1 + $gstrate ) );
- } else {
- return ( $value * ( 1 + $gstrate ), $value );
- }
-}
-
-sub get_gste {
- my $value = shift;
- my $gstrate = shift;
- my $bookseller = shift;
- if ( $bookseller->{invoiceincgst} ) {
- return $value / ( 1 + $gstrate );
- } else {
- return $value;
- }
-}
-
-sub get_gst {
- my $value = shift;
- my $gstrate = shift;
- my $bookseller = shift;
- if ( $bookseller->{invoiceincgst} ) {
- return $value / ( 1 + $gstrate ) * $gstrate;
- } else {
- return $value * ( 1 + $gstrate ) - $value;
- }
-}