@@ -, +, @@ parcel.pl --- C4/Acquisition.pm | 3 +- C4/Budgets.pm | 25 ++++++++++ C4/Reserves.pm | 12 ++++- acqui/parcel.pl | 7 ++- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 50 +++++++++++++++----- 5 files changed, 81 insertions(+), 16 deletions(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -2460,11 +2460,12 @@ sub GetInvoiceDetails { my $invoice = $sth->fetchrow_hashref; $query = qq{ - SELECT aqorders.*, biblio.*, + SELECT aqorders.*, biblio.*, aqorders_items.itemnumber, aqbasket.basketname FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber + LEFT JOIN aqorders_items ON aqorders.ordernumber = aqorders_items.ordernumber WHERE invoiceid = ? }; $sth = $dbh->prepare($query); --- a/C4/Budgets.pm +++ a/C4/Budgets.pm @@ -34,6 +34,7 @@ BEGIN { @EXPORT = qw( &GetBudget + &GetBudgetByOrderNumber &GetBudgets &GetBudgetHierarchy &AddBudget @@ -672,6 +673,30 @@ sub GetBudget { return $result; } +=head2 GetBudgetByOrderNumber + + &GetBudgetByOrderNumber($ordernumber); + +get a specific budget by order number + +=cut + +# ------------------------------------------------------------------- +sub GetBudgetByOrderNumber { + my ( $ordernumber ) = @_; + my $dbh = C4::Context->dbh; + my $query = " + SELECT aqbudgets.* + FROM aqbudgets, aqorders + WHERE ordernumber=? + AND aqorders.budget_id = aqbudgets.budget_id + "; + my $sth = $dbh->prepare($query); + $sth->execute( $ordernumber ); + my $result = $sth->fetchrow_hashref; + return $result; +} + =head2 GetChildBudgetsSpent &GetChildBudgetsSpent($budget-id); --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -277,9 +277,12 @@ of the reserves and an arrayref pointing to the reserves for C<$biblionumber>. sub GetReservesFromBiblionumber { my ($biblionumber) = shift or return (0, []); my ($all_dates) = shift; + my ($itemnumber) = shift; + warn "ITEMNUMBER: $itemnumber"; my $dbh = C4::Context->dbh; # Find the desired items in the reserves + my @params; my $query = " SELECT reserve_id, branchcode, @@ -298,12 +301,17 @@ sub GetReservesFromBiblionumber { suspend_until FROM reserves WHERE biblionumber = ? "; + push( @params, $biblionumber ); unless ( $all_dates ) { - $query .= "AND reservedate <= CURRENT_DATE()"; + $query .= " AND reservedate <= CURRENT_DATE() "; + } + if ( $itemnumber ) { + $query .= " AND ( itemnumber IS NULL OR itemnumber = ? )"; + push( @params, $itemnumber ); } $query .= "ORDER BY priority"; my $sth = $dbh->prepare($query); - $sth->execute($biblionumber); + $sth->execute( @params ); my @results; my $i = 0; while ( my $data = $sth->fetchrow_hashref ) { --- a/acqui/parcel.pl +++ a/acqui/parcel.pl @@ -67,6 +67,7 @@ use CGI; use C4::Output; use C4::Dates qw/format_date format_date_in_iso/; use C4::Suggestions; +use C4::Reserves qw/GetReservesFromBiblionumber/; use JSON; my $input=new CGI; @@ -170,6 +171,9 @@ for my $item ( @parcelitems ) { $line{invoice} = $invoice->{invoicenumber}; $line{total} = sprintf($cfstr, $total); $line{booksellerid} = $invoice->{booksellerid}; + my ($count) = &GetReservesFromBiblionumber($line{biblionumber},undef,$item->{itemnumber}); + $line{holds} = $count; + $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} ); $totalprice += $item->{'unitprice'}; $line{unitprice} = sprintf( $cfstr, $item->{'unitprice'} ); my $gste = get_gste( $line{total}, $line{gstrate}, $bookseller ); @@ -187,7 +191,8 @@ for my $item ( @parcelitems ) { if ( $line{parent_ordernumber} != $line{ordernumber} ) { if ( grep { $_->{ordernumber} == $line{parent_ordernumber} } - @parcelitems ) + @parcelitems + ) { $line{cannot_cancel} = 1; } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -1,3 +1,4 @@ +[% USE currency = format('%.2f') -%] [% INCLUDE 'doc-head-open.inc' %]