Bug 18906: Display all funds the logged in user can use
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 6 Jul 2017 21:10:10 +0000 (18:10 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 9 Aug 2017 19:51:40 +0000 (16:51 -0300)
There are complex conditions to know if a librarian can use a fund, we
cannot do that with a SQL query, we need to use C4::Budgets::CanUserUseBudget

When this patch is applied then all funds are visible to both
superlibrarian patrons and patrons with all acq permissions

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
admin/aqbudgets.pl

index 0dce9dd..7e85254 100755 (executable)
@@ -234,7 +234,7 @@ if ( $op eq 'list' ) {
     );
 
     my @budgets = @{
-        GetBudgetHierarchy( $$period{budget_period_id}, C4::Context->userenv->{branch}, ( $show_mine ? $borrower_id : 0 ))
+        GetBudgetHierarchy( $$period{budget_period_id}, undef, ( $show_mine ? $borrower_id : 0 ))
     };
 
     my $period_total = 0;
@@ -245,6 +245,7 @@ if ( $op eq 'list' ) {
     my @budgets_to_display;
     foreach my $budget (@budgets) {
         # PERMISSIONS
+        next unless CanUserUseBudget($borrowernumber, $budget, $staffflags);
         unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
             $budget->{'budget_lock'} = 1;
         }