From dc85da1830bc06d7f016fd70aa3923eaeb05e880 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Thu, 29 Oct 2009 15:12:25 +0100 Subject: [PATCH] suggestions improvements and fixes - reindenting Suggestions.pm - removing useless code in acqui-home.pl & fixing # of pending suggestion display - add suggestion to order : displaying for selection suggestions accepted by the librarian (and reindenting) - XHTMLing acqui-home (& removed useless parts) NOTE ABOUT XHTML (could be useful) : must be BEFORE in a , even if, of course, it is displayed after. --- C4/Suggestions.pm | 157 +++++++++--------- acqui/acqui-home.pl | 78 +-------- acqui/newordersuggestion.pl | 14 +- .../prog/en/modules/acqui/acqui-home.tmpl | 94 +++-------- suggestion/suggestion.pl | 2 +- 5 files changed, 113 insertions(+), 232 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index d67f09a6eb..d5793513d4 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -46,30 +46,29 @@ use C4::Dates qw(format_date_in_iso); use vars qw($VERSION @ISA @EXPORT); BEGIN { - # set the version for version checking - $VERSION = 3.01; - require Exporter; - @ISA = qw(Exporter); - @EXPORT = qw( - &NewSuggestion - &SearchSuggestion - &GetSuggestion - &GetSuggestionByStatus - &DelSuggestion - &CountSuggestion - &ModSuggestion - &ConnectSuggestionAndBiblio - &GetSuggestionFromBiblionumber - &ConnectSuggestionAndBiblio - &CountSuggestion - &DelSuggestion - &GetSuggestion - &GetSuggestionByStatus - &GetSuggestionFromBiblionumber - &ModStatus - &ModSuggestion - &NewSuggestion - ); + # set the version for version checking + $VERSION = 3.01; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw( + &NewSuggestion + &SearchSuggestion + &GetSuggestion + &GetSuggestionByStatus + &DelSuggestion + &CountSuggestion + &ModSuggestion + &ConnectSuggestionAndBiblio + &GetSuggestionFromBiblionumber + &ConnectSuggestionAndBiblio + &DelSuggestion + &GetSuggestion + &GetSuggestionByStatus + &GetSuggestionFromBiblionumber + &ModStatus + &ModSuggestion + &NewSuggestion + ); } =head1 NAME @@ -116,63 +115,63 @@ sub SearchSuggestion { my $dbh = C4::Context->dbh; my @sql_params; my @query = ( - q{ SELECT suggestions.*, - U1.branchcode AS branchcodesuggestedby, - B1.branchname AS branchnamesuggestedby, - U1.surname AS surnamesuggestedby, - U1.firstname AS firstnamesuggestedby, - U1.email AS emailsuggestedby, - U1.borrowernumber AS borrnumsuggestedby, + q{ SELECT suggestions.*, + U1.branchcode AS branchcodesuggestedby, + B1.branchname AS branchnamesuggestedby, + U1.surname AS surnamesuggestedby, + U1.firstname AS firstnamesuggestedby, + U1.email AS emailsuggestedby, + U1.borrowernumber AS borrnumsuggestedby, U1.categorycode AS categorycodesuggestedby, C1.description AS categorydescriptionsuggestedby, - U2.surname AS surnamemanagedby, - U2.firstname AS firstnamemanagedby, - B2.branchname AS branchnamesuggestedby, - U2.email AS emailmanagedby, - U2.branchcode AS branchcodemanagedby, - U2.borrowernumber AS borrnummanagedby - FROM suggestions - LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber - LEFT JOIN branches AS B1 ON B1.branchcode=U1.branchcode + U2.surname AS surnamemanagedby, + U2.firstname AS firstnamemanagedby, + B2.branchname AS branchnamesuggestedby, + U2.email AS emailmanagedby, + U2.branchcode AS branchcodemanagedby, + U2.borrowernumber AS borrnummanagedby + FROM suggestions + LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber + LEFT JOIN branches AS B1 ON B1.branchcode=U1.branchcode LEFT JOIN categories AS C1 ON C1.categorycode = U1.categorycode - LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber - LEFT JOIN branches AS B2 ON B2.branchcode=U2.branchcode + LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber + LEFT JOIN branches AS B2 ON B2.branchcode=U2.branchcode LEFT JOIN categories AS C2 ON C2.categorycode = U2.categorycode - WHERE STATUS NOT IN ('CLAIMED') - } , map { - if ( my $s = $$suggestion{$_} ) { - push @sql_params,'%'.$s.'%'; - " and suggestions.$_ like ? "; - } else { () } - } qw( title author isbn publishercode collectiontitle ) - ); - - my $userenv = C4::Context->userenv; + WHERE STATUS NOT IN ('CLAIMED') + } , map { + if ( my $s = $$suggestion{$_} ) { + push @sql_params,'%'.$s.'%'; + " and suggestions.$_ like ? "; + } else { () } + } qw( title author isbn publishercode collectiontitle ) + ); + + my $userenv = C4::Context->userenv; if (C4::Context->preference('IndependantBranches')) { - if ($userenv) { - if (($userenv->{flags} % 2) != 1 && !$$suggestion{branchcode}){ - push @sql_params,$$userenv{branch}; - push @query,q{ and (branchcode = ? or branchcode ='')}; - } - } + if ($userenv) { + if (($userenv->{flags} % 2) != 1 && !$$suggestion{branchcode}){ + push @sql_params,$$userenv{branch}; + push @query,q{ and (branchcode = ? or branchcode ='')}; + } + } } foreach my $field (grep { my $fieldname=$_; - any {$fieldname eq $_ } qw< - STATUS branchcode itemtype suggestedby managedby acceptedby - bookfundid biblionumber - >} keys %$suggestion + any {$fieldname eq $_ } qw< + STATUS branchcode itemtype suggestedby managedby acceptedby + bookfundid biblionumber + >} keys %$suggestion ) { - if ($$suggestion{$field}){ - push @sql_params,$$suggestion{$field}; - push @query, " and suggestions.$field=?"; - } - else { - push @query, " and (suggestions.$field='' OR suggestions.$field IS NULL)"; - } + if ($$suggestion{$field}){ + push @sql_params,$$suggestion{$field}; + push @query, " and suggestions.$field=?"; + } + else { + push @query, " and (suggestions.$field='' OR suggestions.$field IS NULL)"; + } } - $debug && warn "@query"; + $debug && warn "@query"; my $sth=$dbh->prepare("@query"); $sth->execute(@sql_params); my @results; @@ -224,8 +223,8 @@ sub GetSuggestionFromBiblionumber { SELECT suggestionid FROM suggestions WHERE biblionumber=? - }; - my $dbh=C4::Context->dbh; + }; + my $dbh=C4::Context->dbh; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); my ($ordernumber) = $sth->fetchrow; @@ -253,8 +252,8 @@ sub GetSuggestionByStatus { U1.firstname AS firstnamesuggestedby, U1.branchcode AS branchcodesuggestedby, B1.branchname AS branchnamesuggestedby, - U1.borrowernumber AS borrnumsuggestedby, - U1.categorycode AS categorycodesuggestedby, + U1.borrowernumber AS borrnumsuggestedby, + U1.categorycode AS categorycodesuggestedby, C1.description AS categorydescriptionsuggestedby, U2.surname AS surnamemanagedby, U2.firstname AS firstnamemanagedby, @@ -343,7 +342,7 @@ sub CountSuggestion { FROM suggestions WHERE STATUS=? |; - $sth = $dbh->prepare($query); + $sth = $dbh->prepare($query); $sth->execute($status); } my ($result) = $sth->fetchrow; @@ -361,8 +360,8 @@ Insert a new suggestion on database with value given on input arg. sub NewSuggestion { my ($suggestion) = @_; - $suggestion->{STATUS}="ASKED" unless $suggestion->{STATUS}; - return InsertInTable("suggestions",$suggestion); + $suggestion->{STATUS}="ASKED" unless $suggestion->{STATUS}; + return InsertInTable("suggestions",$suggestion); } =head2 ModSuggestion @@ -380,7 +379,7 @@ Note that there is no function to modify a suggestion. sub ModSuggestion { my ($suggestion)=@_; - my $status_update_table=UpdateInTable("suggestions", $suggestion); + my $status_update_table=UpdateInTable("suggestions", $suggestion); # check mail sending. if ($$suggestion{STATUS}){ my $letter=C4::Letters::getletter('suggestions',$$suggestion{STATUS}); @@ -394,7 +393,7 @@ sub ModSuggestion { if (!$enqueued){warn "can't enqueue letter $letter";} } } - return $status_update_table; + return $status_update_table; } =head2 ConnectSuggestionAndBiblio diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl index a6d44c3746..291383e272 100755 --- a/acqui/acqui-home.pl +++ b/acqui/acqui-home.pl @@ -169,76 +169,6 @@ foreach my $result (@results) { push( @loop_budget, { %{$result}, toggle => $toggle++ % 2, } ); } - -# --------------------------------------------------- - -=c FIXME - - -### $cur - -## suggestions - -my $dbh = C4::Context->dbh; - - -## liste des domaines - -my $sth=$dbh->prepare(" -SELECT bookfundgroupnumber,bookfundgroupname -FROM `aq2bookfundgroups` -ORDER BY Bookfundgroupname -"); -$sth->execute; - -my @bookfundgroup_loop; ## liste des domaines - -while (my $row=$sth->fetchrow_hashref) { - push @bookfundgroup_loop,$row; -} -$sth->finish; - - -## liste des BFG ayant des suggestions à traiter - - -## nowsuggestions = Number Of Waiting Suggestions - -my $dbh = C4::Context->dbh; - -my $sth=$dbh->prepare(" -SELECT bookfundgroupnumber, count(*) AS nowsuggestions -FROM `aq2orders` -WHERE step=2 -AND STATUS='ASKED' -GROUP BY bookfundgroupnumber -"); -$sth->execute; - -my @nowsuggestionsneq0_loop; ## liste des BFG ayant des suggestions à traiter - -while (my $row=$sth->fetchrow_hashref) { - push @nowsuggestionsneq0_loop,$row; -} -$sth->finish; - - -## liste des BFG avec l'effectif des suggestions à traiter (effectif éventuellement nul) - -my @nowsuggestions_loop; - -foreach my $data1 (@bookfundgroup_loop) { - $data1->{'nowsuggestions'}=0; - foreach my $data2 (@nowsuggestionsneq0_loop) { - if ($data1->{'bookfundgroupnumber'}==$data2->{'bookfundgroupnumber'}) { - $data1->{'nowsuggestions'}=$data2->{'nowsuggestions'}; - } - } -} - -=cut - - $template->param( classlist => $classlist, type => 'intranet', @@ -251,13 +181,7 @@ $template->param( totspent => $num->format_price($totspent ), totcomtd => $num->format_price( $totcomtd ), totavail => $num->format_price( $totavail ), - - # nowsuggestions_loop => \@nowsuggestions_loop, - # bookfundgroup_loop => \@bookfundgroup_loop, - # numberofwaitingsuggestionsgpd => $numberofwaitingsuggestionsgpd, - # numberofwaitingsuggestionspd => $numberofwaitingsuggestionspd, - # suggestions_loop => $suggestions_loop, - + suggestion => $suggestion, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/acqui/newordersuggestion.pl b/acqui/newordersuggestion.pl index b5f2db0224..4697800f75 100755 --- a/acqui/newordersuggestion.pl +++ b/acqui/newordersuggestion.pl @@ -127,18 +127,18 @@ if ( $op eq 'connectDuplicate' ) { # getting all suggestions. my $suggestions_loop = - &SearchSuggestion( - { suggestedby => $borrowernumber, - author => $author, - title => $title, - publishercode => $publishercode, - status => 'ACCEPTED'}); + &SearchSuggestion( + { managedby => $borrowernumber, + author => $author, + title => $title, + publishercode => $publishercode, + status => 'ACCEPTED'}); my $vendor = GetBookSellerFromId($supplierid); $template->param( suggestions_loop => $suggestions_loop, basketno => $basketno, supplierid => $supplierid, - name => $vendor->{'name'}, + name => $vendor->{'name'}, "op_$op" => 1, ); 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 b77743d5ce..5d793c07a6 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 @@ -10,9 +10,9 @@
-
-
-
+
+
+
@@ -23,11 +23,11 @@
Manage orders - + You must define a budget in Administration - - Your administrator must define a budget in Administration - + + Your administrator must define a budget in Administration +

@@ -47,32 +47,10 @@

Pending suggestions - suggestions waiting Manage suggestions + suggestions waiting Manage suggestions

No suggestions waiting

-
-
-
- - - - - - - - - - - - - - - - - -
Book fund groupnumber of
waiting sugg.
">manage
- @@ -100,48 +78,36 @@ Avail + + + Total +   +   + + + + + - - - - - - - - - + + + + + -

-

-

- + + + - - - - Total - - -

-

-

- - - - -

Use your reload button [ctrl + r] to get the most recent figures. - Committed figures are approximate only, as exchange rates will affect the amount actually paid.

- -

Exchange rates

@@ -180,14 +146,6 @@
- -
-

Help

-

To begin an order, local purchase or donation, search for the vendor or benefactor, and then you can create a new Basket.

-

A Basket is a collection of orders.

-

To order an item you need to establish whether a biblio already exists for it, and either add an item, or set up a new biblio and then add the item.

-
-
diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index c455e3f786..bac81ac95a 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -71,7 +71,7 @@ my $tabcode = $input->param('tabcode'); # filter informations which are not suggestion related. my $suggestion_ref = $input->Vars; -delete $$suggestion_ref{$_} foreach qw; +delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); foreach (keys %$suggestion_ref){ delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change')); } -- 2.39.5