From 022978d4f4dd8750a44587cb507636a9d07a5a58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 4 Jan 2010 15:35:43 +0100 Subject: [PATCH] [MT2593] Added "ordered" column in acqui-home budget display --- C4/Budgets.pm | 22 ++++++++++++-- acqui/acqui-home.pl | 30 +++++++++---------- .../prog/en/includes/acquisitions-toolbar.inc | 2 +- .../prog/en/modules/acqui/acqui-home.tmpl | 3 ++ 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 8ef85edbf9..4a8b3b6487 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -39,6 +39,7 @@ BEGIN { &ModBudget &DelBudget &GetBudgetSpent + &GetBudgetOrdered &GetPeriodsCount &GetBudgetPeriod @@ -300,9 +301,26 @@ sub GetBudgetSpent { my ($budget_id) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare(qq| - SELECT SUM(ecost * quantity ) AS sum FROM aqorders + SELECT SUM(ecost * quantity) AS sum FROM aqorders WHERE budget_id = ? AND - datecancellationprinted IS NULL + quantityreceived > 0 AND + datecancellationprinted IS NULL + |); + + $sth->execute($budget_id); + my $sum = $sth->fetchrow_array; + return $sum; +} + +# ------------------------------------------------------------------- +sub GetBudgetOrdered { + my ($budget_id) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare(qq| + SELECT SUM(ecost * quantity) AS sum FROM aqorders + WHERE budget_id = ? AND + quantityreceived = 0 AND + datecancellationprinted IS NULL |); $sth->execute($budget_id); diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl index 8c6fcc8d74..ef457b7b52 100755 --- a/acqui/acqui-home.pl +++ b/acqui/acqui-home.pl @@ -78,6 +78,7 @@ my $branchname = GetBranchName($homebranch); my $classlist = ''; my $total = 0; my $totspent = 0; +my $totordered = 0; my $totcomtd = 0; my $totavail = 0; my @loop_budget = (); @@ -149,22 +150,20 @@ foreach my $result (@results) { my $member = GetMember( $result->{'budget_owner_id'} ); my $member_full = $member->{'firstname'} . ' ' . $member->{'surname'} if $member; - $result->{'budget_owner'} = $member_full; - if ($result->{'budget_spent'}){ - $result->{'budget_avail'} = $result->{'budget_amount'} - $result->{'budget_spent'}; - } - else { - $result->{'budget_avail'} = $result->{'budget_amount'}; - } - $result->{'budget_spent'} = GetBudgetSpent( $result->{'budget_id'} ); + $result->{'budget_owner'} = $member_full; + $result->{'budget_ordered'} = GetBudgetOrdered( $result->{'budget_id'} ); + $result->{'budget_avail'} = $result->{'budget_amount'} - $result->{'budget_spent'} - $result->{'budget_ordered'}; + $result->{'budget_spent'} = GetBudgetSpent( $result->{'budget_id'} ); - $total += $result->{'budget_amount'}; - $totspent += $result->{'budget_spent'} if $result->{'budget_spent'}; - $totavail += $result->{'budget_avail'}; + $total += $result->{'budget_amount'}; + $totspent += $result->{'budget_spent'}; + $totordered += $result->{'budget_ordered'}; + $totavail += $result->{'budget_avail'}; - $result->{'budget_amount'} = $num->format_price( $result->{'budget_amount'} ); - $result->{'budget_spent'} = $num->format_price( $result->{'budget_spent'} ); - $result->{'budget_avail'} = $num->format_price( $result->{'budget_avail'} ); + $result->{'budget_amount'} = $num->format_price( $result->{'budget_amount'} ); + $result->{'budget_spent'} = $num->format_price( $result->{'budget_spent'} ); + $result->{'budget_ordered'} = $num->format_price( $result->{'budget_ordered'} ); + $result->{'budget_avail'} = $num->format_price( $result->{'budget_avail'} ); # my $spent_percent = ( $result->{'budget_spent'} / $result->{'budget_amount'} ) * 100; # $result->{'budget_spent_percent'} = sprintf( "%00d", $spent_percent ); @@ -184,7 +183,8 @@ $template->param( branchname => $branchname, budget => $period->{budget_name}, total => $num->format_price( $total ), - totspent => $num->format_price($totspent ), + totspent => $num->format_price( $totspent ), + totordered => $num->format_price( $totordered ), totcomtd => $num->format_price( $totcomtd ), totavail => $num->format_price( $totavail ), suggestion => $suggestion, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc index c3376fefc5..df9ff2fa68 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc @@ -45,7 +45,7 @@
  • &op=enter">Edit
  • ">New Contract
  • -
  • ">New Basket
  • +
  • &op=add_form">New Basket
  • New Vendor
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tmpl index 5d793c07a6..697443317f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tmpl @@ -74,6 +74,7 @@ Owner Branch Amount + Ordered Spent Avail @@ -84,6 +85,7 @@     + @@ -99,6 +101,7 @@ + -- 2.20.1