Bug 3969: Budget search in acquisition does't work (search)
authorKatrin Fischer <Katrin.Fischer.83@web.de>
Sat, 14 Apr 2012 17:39:30 +0000 (19:39 +0200)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 20 Apr 2012 14:41:11 +0000 (16:41 +0200)
Search term was never evaluated.
Patch makes sure input param is correctly stored in the variable
and changes comparison to be case insensitive.

To test:
- Check search for fund codes (case insensitive) works
- Check search for fund code in combination with library works

The budgets to be shown can depend on your permissions.
Testing with with a superlibrarian should bring up all funds.

Also fixes warns in the logs that appeared when viewing the funds
for a budget without funds.

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Funds are now searchable.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>

admin/aqbudgets.pl

index db99759..d644892 100755 (executable)
@@ -74,9 +74,10 @@ my $budget_hash               = $input->Vars;
 my $budget_id                 = $$budget_hash{budget_id};
 my $budget_permission         = $input->param('budget_permission');
 my $filter_budgetbranch       = $input->param('filter_budgetbranch');
+my $filter_budgetname         = $input->param('filter_budgetname');
 #filtering non budget keys
 delete $$budget_hash{$_} foreach grep {/filter|^op$|show/} keys %$budget_hash;
-my $filter_budgetname         = $input->param('filter_budgetname');
+
 $template->param(
     notree => ($filter_budgetbranch or $show_mine)
 );
@@ -271,9 +272,10 @@ if ($op eq 'add_form') {
         }    # ...SUPER_LIB END
 
         # if a budget search doesnt match, next
-        if ($filter_budgetname ) {
-            next unless  $budget->{budget_code}  =~ m/$filter_budgetname/  ||
-            $budget->{name}  =~ m/$filter_budgetname/ ;
+        if ($filter_budgetname) {
+            next
+              unless $budget->{budget_code} =~ m/$filter_budgetname/i
+                  || $budget->{name} =~ m/$filter_budgetname/i;
         }
         if ($filter_budgetbranch ) {
             next unless  $budget->{budget_branchcode}  =~ m/$filter_budgetbranch/;
@@ -325,12 +327,21 @@ if ($op eq 'add_form') {
         $budget_period_total =
           $num->format_price( $period->{budget_period_total} );
     }
+
+    if ($period_alloc_total) {
+        $period_alloc_total = $num->format_price($period_alloc_total);
+    }
+
+    if ($base_spent_total) {
+        $base_spent_total = $num->format_price($base_spent_total);
+    }
+
     $template->param(
         else                   => 1,
         budget                 => \@loop,
         budget_period_total    => $budget_period_total,
-        period_alloc_total     => $num->format_price($period_alloc_total),
-        base_spent_total       => $num->format_price($base_spent_total),
+        period_alloc_total     => $period_alloc_total,
+        base_spent_total       => $base_spent_total,
         branchloop             => \@branchloop2,
     );