Bugzilla – Attachment 7285 Details for
Bug 5346
Linking suggestions & orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5346: Linking suggestions and orders.
Bug-5346-Linking-suggestions-and-orders.patch (text/plain), 16.09 KB, created by
Katrin Fischer
on 2012-01-23 06:53:37 UTC
(
hide
)
Description:
Bug 5346: Linking suggestions and orders.
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2012-01-23 06:53:37 UTC
Size:
16.09 KB
patch
obsolete
>From 54791b428efae9e4f264bc2c0a53028471104e76 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 18 Jan 2012 14:16:16 +0100 >Subject: [PATCH] Bug 5346: Linking suggestions and orders. > >Display suggestion info in acquisition module: > basket.pl > neworderempty.pl > orderreceive.pl > parcel.pl > >To Test: >Create a suggestion and accept it. >Create a new order from this suggestion >Receive this order > >For each step, check if suggestion info are visible. > >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Test provides more unit tests, all complete successfully. >perl t/db_dependent/Suggestions.t >Note: test case should be cleaned up after running tests. > >Display changes are consistent and information about the suggestion >is shown on every important screen now. > >I created an order from a suggestion and one from an existing record. > >No problems found. >--- > C4/Suggestions.pm | 60 +++++++++++++++++++- > acqui/basket.pl | 9 +++ > acqui/neworderempty.pl | 7 ++- > acqui/orderreceive.pl | 8 ++- > acqui/parcel.pl | 13 ++++- > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 6 ++ > .../prog/en/modules/acqui/neworderempty.tt | 14 ++++- > .../prog/en/modules/acqui/orderreceive.tt | 13 ++++ > .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 12 ++++ > t/db_dependent/Suggestions.t | 8 ++- > 10 files changed, 141 insertions(+), 9 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index ccc0c8e..c9461f5 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -40,6 +40,8 @@ our @EXPORT = qw< > GetSuggestion > GetSuggestionByStatus > GetSuggestionFromBiblionumber >+ GetSuggestionInfoFromBiblionumber >+ GetSuggestionInfo > ModStatus > ModSuggestion > NewSuggestion >@@ -209,13 +211,65 @@ sub GetSuggestionFromBiblionumber { > my $query = q{ > SELECT suggestionid > FROM suggestions >- WHERE biblionumber=? >+ WHERE biblionumber=? LIMIT 1 > }; > my $dbh=C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute($biblionumber); >- my ($ordernumber) = $sth->fetchrow; >- return $ordernumber; >+ my ($suggestionid) = $sth->fetchrow; >+ return $suggestionid; >+} >+ >+=head2 GetSuggestionInfoFromBiblionumber >+ >+Get a suggestion and borrower's informations from it's biblionumber. >+ >+return : >+all informations (suggestion and borrower) of the suggestion which is related to the biblionumber given. >+ >+=cut >+ >+sub GetSuggestionInfoFromBiblionumber { >+ my ($biblionumber) = @_; >+ my $query = qq{ >+ SELECT suggestions.*, >+ U1.surname AS surnamesuggestedby, >+ U1.firstname AS firstnamesuggestedby, >+ U1.borrowernumber AS borrnumsuggestedby >+ FROM suggestions >+ LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber >+ WHERE biblionumber = ? LIMIT 1 >+ }; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($biblionumber); >+ return $sth->fetchrow_hashref; >+} >+ >+=head2 GetSuggestionInfo >+ >+Get a suggestion and borrower's informations from it's suggestionid >+ >+return : >+all informations (suggestion and borrower) of the suggestion which is related to the suggestionid given. >+ >+=cut >+ >+sub GetSuggestionInfo { >+ my ($suggestionid) = @_; >+ my $query = qq{ >+ SELECT suggestions.*, >+ U1.surname AS surnamesuggestedby, >+ U1.firstname AS firstnamesuggestedby, >+ U1.borrowernumber AS borrnumsuggestedby >+ FROM suggestions >+ LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber >+ WHERE suggestionid = ? LIMIT 1 >+ }; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($suggestionid); >+ return $sth->fetchrow_hashref; > } > > =head2 GetSuggestionByStatus >diff --git a/acqui/basket.pl b/acqui/basket.pl >index c528156..5d4faa3 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -34,6 +34,8 @@ use C4::Debug; > use C4::Biblio; > use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket > use C4::Items; >+use C4::Suggestions; >+ > =head1 NAME > > basket.pl >@@ -237,6 +239,7 @@ if ( $op eq 'delete_confirm' ) { > > my $qty_total; > my @books_loop; >+ my $suggestion; > > for my $order ( @results ) { > my $rrp = $order->{'listprice'} || 0; >@@ -303,6 +306,12 @@ if ( $op eq 'delete_confirm' ) { > } else { > $line{'title'} = "Deleted bibliographic notice, can't find title."; > } >+ >+ $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >+ $line{suggestionid} = $suggestion->{suggestionid}; >+ $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; >+ $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; >+ > push @books_loop, \%line; > } > >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 459dfe8..4c3daaf 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -204,6 +204,9 @@ else { #modify order > $booksellerid = $data2->{'booksellerid'}; > } > >+my $suggestion; >+$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid; >+ > # get currencies (for change rates calcs if needed) > my $active_currency = GetCurrency(); > my $default_currency; >@@ -359,7 +362,9 @@ $template->param( > authorisedbyname => $basket->{'authorisedbyname'}, > closedate => C4::Dates->new($basket->{'closedate'},'iso')->output, > # order details >- suggestionid => $suggestionid, >+ suggestionid => $suggestion->{suggestionid}, >+ surnamesuggestedby => $suggestion->{surnamesuggestedby}, >+ firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, > biblionumber => $biblionumber, > uncertainprice => $data->{'uncertainprice'}, > authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'}, >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 753071d..451f858 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -75,6 +75,7 @@ use C4::Members; > use C4::Branch; # GetBranches > use C4::Items; > use C4::Biblio; >+use C4::Suggestions; > > > my $input = new CGI; >@@ -135,6 +136,8 @@ if ( $count == 1 ) { > @$results[0]->{'unitprice'} = ''; > } > >+ my $suggestion = GetSuggestionInfoFromBiblionumber(@$results[0]->{'biblionumber'}); >+ > my $authorisedby = @$results[0]->{'authorisedby'}; > my $member = GetMember( borrowernumber => $authorisedby ); > >@@ -167,7 +170,10 @@ if ( $count == 1 ) { > invoice => $invoice, > datereceived => $datereceived->output(), > datereceived_iso => $datereceived->output('iso'), >- notes => $order->{notes} >+ notes => $order->{notes}, >+ suggestionid => $suggestion->{suggestionid}, >+ surnamesuggestedby => $suggestion->{surnamesuggestedby}, >+ firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, > ); > } > else { >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index c256c60..46582d3 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -67,6 +67,7 @@ use C4::Items; > use CGI; > use C4::Output; > use C4::Dates qw/format_date format_date_in_iso/; >+use C4::Suggestions; > use JSON; > > my $input=new CGI; >@@ -178,6 +179,11 @@ for (my $i = 0 ; $i < $countlines ; $i++) { > $totalprice += $parcelitems[$i]->{'unitprice'}; > $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); > >+ my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >+ $line{suggestionid} = $suggestion->{suggestionid}; >+ $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; >+ $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; >+ > #double FIXME - totalfreight is redefined later. > > # FIXME - each order in a parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget.. >@@ -230,7 +236,12 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { > $itemholds += $nb; > } > } >- >+ >+ my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >+ $line{suggestionid} = $suggestion->{suggestionid}; >+ $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; >+ $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; >+ > # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 > $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); > $line{items} = ($itemcount) - (scalar @items); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index aaea6c0..1632278 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -283,6 +283,12 @@ > [% IF ( books_loo.issn ) %] - [% books_loo.issn %][% END %] > [% IF ( books_loo.publishercode ) %], [% books_loo.publishercode %][% END %] > [% IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear %][% END %] >+ [% IF ( books_loo.suggestionid ) %] >+ <br/> >+ Suggested by [% books_loo.surnamesuggestedby %] >+ [% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby %] [% END %] >+ (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid %]">suggestion #[% books_loo.suggestionid %]</a>) >+ [% END %] > </p> > </td> > <td class="number">[% books_loo.rrp %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index a6f26c4..411980a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -166,7 +166,6 @@ $(document).ready(function() > [% ELSE %] > New order > [% END %] >- [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %] > </h2> > > [% IF ( basketno ) %] >@@ -310,6 +309,19 @@ $(document).ready(function() > [% END %] > </ol> > </fieldset> >+ >+ [% IF ( suggestionid ) %] >+ <fieldset class="rows"> >+ <legend>Suggestion</legend> >+ <ol> >+ <li> >+ <span class="label">Suggested by </span> >+ [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>) >+ </li> >+ </ol> >+ </fieldset> >+ [% END %] >+ > [% IF ( items ) %] > <fieldset class="rows"> > <legend>Item</legend> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index ea422c8..fe8287d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -35,6 +35,19 @@ > [% seriestitle %]</li> > </ol> > </fieldset> >+ >+ [% IF ( suggestionid ) %] >+ <fieldset class="rows"> >+ <legend>Suggestion</legend> >+ <ol> >+ <li> >+ <span class="label">Suggested by </span> >+ [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>) >+ </li> >+ </ol> >+ </fieldset> >+ [% END %] >+ > [% IF ( items ) %] > <fieldset class="rows"> > <legend>Item</legend> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index eb5492e..34a55b0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -241,6 +241,12 @@ > [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %] > [% IF ( loop_order.isbn ) %] – [% loop_order.isbn %][% END %] > [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %] >+ [% IF ( loop_order.suggestionid ) %] >+ <br/> >+ Suggested by [% loop_order.surnamesuggestedby %] >+ [% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %] >+ (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]">suggestion #[% loop_order.suggestionid %]</a>) >+ [% END %] > </td> > <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td> > <td>[% loop_order.quantity %]</td> >@@ -361,6 +367,12 @@ > [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %] > [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %] > [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %] >+ [% IF ( loop_receive.suggestionid ) %] >+ <br/> >+ Suggested by [% loop_receive.surnamesuggestedby %] >+ [% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %] >+ (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]">suggestion #[% loop_receive.suggestionid %]</a> >+ [% END %] > </td> > <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td> > <td>[% loop_receive.quantityreceived %]</td> >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 001dc24..f285929 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -9,16 +9,20 @@ use Data::Dumper; > > use C4::Suggestions; > >-use Test::More tests =>6; >+use Test::More tests =>9; > > BEGIN { > use_ok('C4::Suggestions'); > } > >-my ($suggestionid, $suggestion, $status); >+my ($suggestionid, $suggestion, $status, $biblionumber); >+$biblionumber = 1; > ok($suggestionid= NewSuggestion( {title=>'Petit traité de philosohpie',author=>'Hubert de Chardassé',publishercode=>'Albin Michel'} ), "NewSuggestion OK"); > ok($suggestion= GetSuggestion( $suggestionid), "GetSuggestion OK"); > ok($status= ModSuggestion( {title=>'test Modif Simple', suggestionid=>$suggestionid} ), "ModSuggestion Simple OK"); > ok($status= ModSuggestion( {STATUS=>'STALLED', suggestionid=>$suggestionid} ), "ModSuggestion Status OK"); >+ok($status= ModSuggestion( {suggestionid => $suggestionid, biblionumber => $biblionumber } ), "ModSuggestion, set biblionumber OK" ); >+ok($suggestion= GetSuggestionFromBiblionumber( $biblionumber ), "GetSuggestionFromBiblionumber OK"); >+ok($suggestion= GetSuggestionInfoFromBiblionumber( $biblionumber ), "GetSuggestionInfoFromBiblionumber OK"); > ok(@{SearchSuggestion( {STATUS=>'STALLED'} )}>0, "SearchSuggestion Status OK"); > >-- >1.7.5.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5346
:
7216
| 7285 |
7286
|
7560