Bug 5861: items.stocknumber not saved correctly
[koha_fer] / suggestion / suggestion.pl
index 9023cd2..26863f3 100755 (executable)
@@ -16,6 +16,7 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+#use warnings; FIXME - Bug 2505
 require Exporter;
 use CGI;
 use C4::Auth;    # get_template_and_user
@@ -56,9 +57,13 @@ sub GetCriteriumDesc{
     if ($displayby =~/managedby/||$displayby =~/acceptedby/){
         my $borr=C4::Members::GetMember(borrowernumber=>$criteriumvalue);
         return "" unless $borr;
-#              warn '$borr : ',Data::Dumper::Dumper($borr);
-        return $$borr{firstname}.", ".$$borr{surname};
-    }  
+        return $$borr{firstname} . ", " . $$borr{surname};
+    }
+    if ( $displayby =~ /budgetid/) {
+        my $budget = GetBudget($criteriumvalue);
+        return "" unless $budget;
+        return $$budget{budget_name};
+    }
 }
 
 my $input           = CGI->new;
@@ -244,7 +249,7 @@ $template->param( branchloop => \@branchloop,
 # the index parameter is different for item-level itemtypes
 my $supportlist=GetSupportList();                              
 foreach my $support(@$supportlist){
-    $$support{'selected'}= $$support{'code'} eq $$suggestion_ref{'itemtype'};
+    $$support{'selected'}= $$support{'itemtype'} eq $$suggestion_ref{'itemtype'};
     if ($$support{'imageurl'}){
         $$support{'imageurl'}= getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
     }
@@ -254,6 +259,9 @@ foreach my $support(@$supportlist){
 }
 $template->param(itemtypeloop=>$supportlist);
 
+my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
+$template->param(patron_reason_loop=>$patron_reason_loop);
+
 #Budgets management
 my $searchbudgets={ budget_branchcode=>$branchfilter} if $branchfilter;
 my $budgets = GetBudgets($searchbudgets);
@@ -264,8 +272,28 @@ foreach my $budget (@$budgets){
 
 $template->param( budgetsloop => $budgets);
 
-my %hashlists; 
-foreach my $field qw(managedby acceptedby suggestedby STATUS){
+# get currencies and rates
+my @rates = GetCurrencies();
+my $count = scalar @rates;
+
+my @loop_currency = ();
+for ( my $i = 0 ; $i < $count ; $i++ ) {
+    my %line;
+    $line{currcode} = $rates[$i]->{'currency'};
+    $line{rate}     = $rates[$i]->{'rate'};
+       $line{selected} = 1 if ($$suggestion_ref{'currency'} && $line{'currcode'} eq $$suggestion_ref{'currency'});
+    push @loop_currency, \%line;
+}
+
+$template->param(loop_currency => \@loop_currency);
+
+$template->param(
+       price        => sprintf("%.2f", $$suggestion_ref{'price'}||0),
+       total            => sprintf("%.2f", $$suggestion_ref{'total'}||0),
+);
+
+my %hashlists;
+foreach my $field qw(managedby acceptedby suggestedby budgetid STATUS) {
     my $values_list;
     $values_list=GetDistinctValues("suggestions.".$field) ;
     my @codes_list = map{
@@ -277,5 +305,5 @@ foreach my $field qw(managedby acceptedby suggestedby STATUS){
     $hashlists{lc($field)."_loop"}=\@codes_list;
 }
 $template->param(%hashlists);
-
+$template->param(DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),);
 output_html_with_http_headers $input, $cookie, $template->output;