[Koha-patches] [PATCH 1/2] [SIGNED-OFF] Bug 5072 - prevent creating new orders if there are no valid budgets
Katrin Fischer
Katrin.Fischer.83 at web.de
Tue Aug 2 00:03:56 CEST 2011
From: Robin Sheat <robin at catalyst.net.nz>
On the basket editing screen, the links to add orders to a basket are
hidden unless a valid fund is available.
Signed-off-by: Katrin Fischer <Katrin.Fischer.83 at web.de>
---
C4/Budgets.pm | 12 ++++++------
acqui/basket.pl | 13 +++++++++++++
acqui/neworderempty.pl | 2 +-
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/C4/Budgets.pm b/C4/Budgets.pm
index d516a12..98e5d63 100644
--- a/C4/Budgets.pm
+++ b/C4/Budgets.pm
@@ -666,11 +666,11 @@ sub GetBudget {
return $result;
}
-=head2 GetBudgets
+=head2 GetChildBudgetsSpent
- &GetBudgets($filter, $order_by);
+ &GetChildBudgetsSpent($budget-id);
-gets all budgets
+gets the total spent of the level and sublevels of $budget_id
=cut
@@ -693,11 +693,11 @@ sub GetChildBudgetsSpent {
return $total_spent;
}
-=head2 GetChildBudgetsSpent
+=head2 GetBudgets
- &GetChildBudgetsSpent($budget-id);
+ &GetBudgets($filter, $order_by);
-gets the total spent of the level and sublevels of $budget_id
+gets all budgets
=cut
diff --git a/acqui/basket.pl b/acqui/basket.pl
index 0261e86..fbe16cb 100755
--- a/acqui/basket.pl
+++ b/acqui/basket.pl
@@ -291,6 +291,18 @@ if ( $op eq 'delete_confirm' ) {
my $contract = &GetContract($basket->{contractnumber});
my @orders = GetOrders($basketno);
+
+ my $borrower= GetMember('borrowernumber' => $loggedinuser);
+ my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
+ my $has_budgets = 0;
+ foreach my $r (@{$budgets}) {
+ if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
+ next;
+ }
+ $has_budgets = 1;
+ last;
+ }
+
$template->param(
basketno => $basketno,
basketname => $basket->{'basketname'},
@@ -321,6 +333,7 @@ if ( $op eq 'delete_confirm' ) {
basketgroups => $basketgroups,
grouped => $basket->{basketgroupid},
unclosable => @orders ? 0 : 1,
+ has_budgets => $has_budgets,
);
}
diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index db3e852..c7d6083 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -93,7 +93,7 @@ use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
my $input = new CGI;
my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR!
-my $budget_id = $input->param('budget_id') || 0; # FIXME: else ERROR!
+my $budget_id = $input->param('budget_id') || 0;
my $title = $input->param('title');
my $author = $input->param('author');
my $publicationyear = $input->param('publicationyear');
--
1.7.4.1
More information about the Koha-patches
mailing list