Bugzilla – Attachment 95172 Details for
Bug 23991
Move SearchSuggestion to Koha::Suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23991: Move SearchSuggestion to Koha::Suggestions
Bug-23991-Move-SearchSuggestion-to-KohaSuggestions.patch (text/plain), 29.22 KB, created by
Jonathan Druart
on 2019-11-07 16:41:18 UTC
(
hide
)
Description:
Bug 23991: Move SearchSuggestion to Koha::Suggestions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-11-07 16:41:18 UTC
Size:
29.22 KB
patch
obsolete
>From e768f682c8a33aecba40e669c6fe329737bbad81 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 7 Nov 2019 17:41:02 +0100 >Subject: [PATCH] Bug 23991: Move SearchSuggestion to Koha::Suggestions > >--- > Koha/Suggestion.pm | 36 ++++++++++ > acqui/newordersuggestion.pl | 18 ++--- > .../prog/en/modules/acqui/newordersuggestion.tt | 50 ++++++------- > .../en/modules/members/purchase-suggestions.tt | 10 +-- > .../bootstrap/en/modules/opac-suggestions.tt | 62 ++++++++-------- > members/purchase-suggestions.pl | 5 +- > opac/opac-suggestions.pl | 82 ++++++++++------------ > 7 files changed, 138 insertions(+), 125 deletions(-) > >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index 2fef425197..cf47960382 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -53,6 +53,42 @@ sub store { > return $self->SUPER::store(); > } > >+sub manager { >+ my ($self) = @_; >+ my $manager_rs = $self->_result->managedby; >+ return unless $manager_rs; >+ return Koha::Patron->_new_from_dbic($manager_rs); >+} >+ >+sub suggester { >+ my ($self) = @_; >+ my $suggester_rs = $self->_result->managedby; >+ return unless $suggester_rs; >+ return Koha::Patron->_new_from_dbic($suggester_rs); >+} >+ >+sub rejecter { >+ my ($self) = @_; >+ my $rejecter_rs = $self->_result->managedby; >+ return unless $rejecter_rs; >+ return Koha::Patron->_new_from_dbic($rejecter_rs); >+} >+ >+sub last_modifier { >+ my ($self) = @_; >+ my $last_modifier_rs = $self->_result->managedby; >+ return unless $last_modifier_rs; >+ return Koha::Patron->_new_from_dbic($last_modifier_rs); >+} >+ >+sub fund { >+ my ($self) = @_; >+ my $fund_rs = $self->_result->budgetid; >+ return unless $fund_rs; >+ return Koha::Acquisition::Fund->_new_from_dbic($fund_rs); >+} >+ >+ > =head3 type > > =cut >diff --git a/acqui/newordersuggestion.pl b/acqui/newordersuggestion.pl >index 54934967ab..9220e5c55a 100755 >--- a/acqui/newordersuggestion.pl >+++ b/acqui/newordersuggestion.pl >@@ -98,6 +98,7 @@ use C4::Biblio; > use C4::Budgets; > > use Koha::Acquisition::Booksellers; >+use Koha::Suggestions; > > my $input = new CGI; > >@@ -128,23 +129,22 @@ if ( $op eq 'connectDuplicate' ) { > ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber ); > } > >-# getting all suggestions. >-my $suggestions_loop = SearchSuggestion( >+my $suggestions = Koha::Suggestions->search( > { >- author => $author, >- title => $title, >- publishercode => $publishercode, >- STATUS => 'ACCEPTED' >- } >+ ( $author ? ( author => $author ) : () ), >+ ( $title ? ( title => $title ) : () ), >+ ( $publishercode ? ( publishercode => $publishercode ) : () ), >+ STATUS => 'ACCEPTED' >+ }, >+ { prefetch => ['managedby', 'suggestedby'] }, > ); > > my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid ); > $template->param( >- suggestions_loop => $suggestions_loop, >+ suggestions => $suggestions, > basketno => $basketno, > booksellerid => $booksellerid, > name => $vendor->name, >- loggedinuser => $borrowernumber, > "op_$op" => 1, > ); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt >index cad0dd26e0..145c27f30a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt >@@ -20,7 +20,7 @@ > <main> > > <h1>Suggestions</h1> >- [% IF ( suggestions_loop ) %] >+ [% IF suggestions.count %] > <a href="#" id="show_only_mine">Show only mine</a> | <a href="#" id="show_all">Show all suggestions</a> > <table id="suggestionst"> > <thead> >@@ -38,49 +38,45 @@ > </tr> > </thead> > <tbody> >- [% FOREACH suggestions_loo IN suggestions_loop %] >+ [% FOREACH suggestion IN suggestions %] > <tr> >- <td>[% suggestions_loo.managedby | html %]</td> >+ <td>[% suggestion.managedby | html %]</td> > <td> >- <p>[% suggestions_loo.title | html %] - [% suggestions_loo.author | html %]</p> >+ <p>[% suggestion.title | html %] - [% suggestion.author | html %]</p> > <p> >- [% IF ( suggestions_loo.copyrightdate ) %]© [% suggestions_loo.copyrightdate | html %] [% END %] >- [% IF ( suggestions_loo.volumedesc ) %]volume: <i>[% suggestions_loo.volumedesc | html %]</i> [% END %] >- [% IF ( suggestions_loo.isbn ) %]ISBN: <i>[% suggestions_loo.isbn | html %]</i> [% END %] >- [% IF ( suggestions_loo.publishercode ) %]<br />published by: [% suggestions_loo.publishercode | html %] [% END %] >- [% IF ( suggestions_loo.publicationyear ) %] in <i>[% suggestions_loo.publicationyear | html %]</i> [% END %] >- [% IF ( suggestions_loo.place ) %] in <i>[% suggestions_loo.place | html %]</i> [% END %] >- [% IF ( suggestions_loo.note ) %]<p><i>([% suggestions_loo.note | html %])</i></p> [% END %] >+ [% IF ( suggestion.copyrightdate ) %]© [% suggestion.copyrightdate | html %] [% END %] >+ [% IF ( suggestion.volumedesc ) %]volume: <i>[% suggestion.volumedesc | html %]</i> [% END %] >+ [% IF ( suggestion.isbn ) %]ISBN: <i>[% suggestion.isbn | html %]</i> [% END %] >+ [% IF ( suggestion.publishercode ) %]<br />published by: [% suggestion.publishercode | html %] [% END %] >+ [% IF ( suggestion.publicationyear ) %] in <i>[% suggestion.publicationyear | html %]</i> [% END %] >+ [% IF ( suggestion.place ) %] in <i>[% suggestion.place | html %]</i> [% END %] >+ [% IF ( suggestion.note ) %]<p><i>([% suggestion.note | html %])</i></p> [% END %] > </p> > </td> >+ <td>[% INCLUDE 'patron-title.inc' patron => suggestion.suggester %]</td> >+ <td>[% INCLUDE 'patron-title.inc' patron => suggestion.manager %]</td> > <td> >- [% suggestions_loo.surnamesuggestedby | html %][% IF ( suggestions_loo.firstnamesuggestedby ) %],[% END %] [% suggestions_loo.firstnamesuggestedby | html %] >+ [% Branches.GetName(suggestion.branchcode) | html %] > </td> > <td> >- [% suggestions_loo.surnamemanagedby | html %][% IF ( suggestions_loo.firstnamemanagedby ) %],[% END %] [% suggestions_loo.firstnamemanagedby | html %] >+ [% suggestion.fund.budget_name | html %] > </td> > <td> >- [% Branches.GetName(suggestions_loo.branchcode) | html %] >+ [% suggestion.price | $Price %] > </td> > <td> >- [% suggestions_loo.budget_name | html %] >- </td> >- <td> >- [% suggestions_loo.price | $Price %] >- </td> >- <td> >- [% IF (suggestions_loo.quantity > 0) %] >- [% suggestions_loo.quantity | html %] >+ [% IF (suggestion.quantity > 0) %] >+ [% suggestion.quantity | html %] > [% END %] > </td> > <td> >- [% suggestions_loo.total | $Price %] >+ [% suggestion.total | $Price %] > </td> > <td class="actions"> >- [% IF ( suggestions_loo.biblionumber ) %] >- <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]&suggestionid=[% suggestions_loo.suggestionid | uri %]&biblio=[% suggestions_loo.biblionumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Order</a> >+ [% IF ( suggestion.biblionumber ) %] >+ <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]&suggestionid=[% suggestion.suggestionid | uri %]&biblio=[% suggestion.biblionumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Order</a> > [% ELSE %] >- <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]&suggestionid=[% suggestions_loo.suggestionid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Order</a> >+ <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]&suggestionid=[% suggestion.suggestionid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Order</a> > [% END %] > </td> > </tr> >@@ -114,7 +110,7 @@ > })); > $("#show_only_mine").on('click', function(e){ > e.preventDefault(); >- suggestionst.fnFilter('^[% loggedinuser | html %]$', 0, true); >+ suggestionst.fnFilter('^[% logged_in_user.borrowernumber | html %]$', 0, true); > }); > $("#show_all").on('click', function(e){ > e.preventDefault(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt >index dc8afa0283..7fb653dc91 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt >@@ -31,7 +31,7 @@ > <a class="btn btn-default" id="newsuggestion" href="/cgi-bin/koha/suggestion/suggestion.pl?op=add&suggestedby=[% patron.borrowernumber | html %]&redirect=purchase_suggestions&borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> New purchase suggestion</a> > </div> > >- [% IF suggestions %] >+ [% IF suggestions.count %] > <table id="suggestions"> > <thead> > <tr> >@@ -66,13 +66,7 @@ > </td> > <td>[% s.note | html %] > <td> >- [% IF ( s.surnamemanagedby ) %] >- [% s.surnamemanagedby | html %] >- [% IF ( s.firstnamemanagedby ) %],[% END %] >- [% s.firstnamemanagedby | html %] >- [% ELSE %] >- >- [% END %] >+ [% INCLUDE 'patron-title.inc' patron => s.manager %] > [% IF s.manageddate %] - [% s.manageddate | $KohaDates %][% END %] > </td> > <td> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >index 2f906637f6..86f2d69daa 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >@@ -250,7 +250,7 @@ > > [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %] > >- [% IF ( suggestions_loop ) %] >+ [% IF suggestions.count %] > <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" method="get"> > <fieldset> > <label for="title">Search for:</label> >@@ -309,66 +309,64 @@ > </tr> > </thead> > <tbody> >- [% FOREACH suggestions_loo IN suggestions_loop %] >+ [% FOREACH suggestion IN suggestions %] > <tr> >- [% IF ( loggedinusername ) %] >+ [% IF logged_in_user %] > <td> >- [% IF ( suggestions_loo.showcheckbox ) %] >- <input type="checkbox" class="cb" name="delete_field" value="[% suggestions_loo.suggestionid | html %]" /> >+ [% IF logged_in_user.borrowernumber == suggestion.suggestedby %] >+ <input type="checkbox" class="cb" name="delete_field" value="[% suggestion.suggestionid | html %]" /> > [% END %] > </td> > [% END %] > <td> >- <p><strong>[% suggestions_loo.title | html %]</strong></p> >- <p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author | html %],[% END %] >- [% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate | html %],[% END %] >- [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode | html %][% END %] >- [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place | html %])[% END %] >- [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle | html %][% END %] >- [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) | html %][% END %] >+ <p><strong>[% suggestion.title | html %]</strong></p> >+ <p>[% IF ( suggestion.author ) %][% suggestion.author | html %],[% END %] >+ [% IF ( suggestion.copyrightdate ) %] - [% suggestion.copyrightdate | html %],[% END %] >+ [% IF ( suggestion.publishercode ) %] - [% suggestion.publishercode | html %][% END %] >+ [% IF ( suggestion.place ) %]([% suggestion.place | html %])[% END %] >+ [% IF ( suggestion.collectiontitle ) %] , [% suggestion.collectiontitle | html %][% END %] >+ [% IF ( suggestion.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 1 ) | html %][% END %] > </p> > </td> > <td> >- [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %] >+ [% IF ( suggestion.suggesteddate ) %][% suggestion.suggesteddate |$KohaDates %][% END %] > </td> > <td> >- [% IF ( suggestions_loo.note ) %] >+ [% IF ( suggestion.note ) %] > <span class="tdlabel">Note: </span> >- [% suggestions_loo.note | html %] >+ [% suggestion.note | html %] > [% END %] > </td> > [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %] > <td> >- [% IF ( suggestions_loo.branchcodesuggestedby ) %] >+ [% IF suggestion.suggestedby %] > <span class="tdlabel">Suggested for:</span> >- [% suggestions_loo.branchcodesuggestedby | html %] >+ [% Branches.GetName(suggestion.suggester.branchcode) | html %] > [% END %] > </td> > [% END %] > [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %] > <td> >- [% IF ( suggestions_loo.surnamemanagedby ) %] >+ [% IF suggestion.managedby %] > <span class="tdlabel">Managed by:</span> >- [% suggestions_loo.surnamemanagedby | html %] >- [% IF ( suggestions_loo.firstnamemanagedby ) %] , [% suggestions_loo.firstnamemanagedby | html %] >- [% END %] >- [% IF ( suggestions_loo.manageddate ) %] - [% suggestions_loo.manageddate | $KohaDates %][% END %] >+ [% INCLUDE 'patron-title.inc' patron = suggestion.manager %] >+ [% IF ( suggestion.manageddate ) %] - [% suggestion.manageddate | $KohaDates %][% END %] > [% END %] > </td> > [% END %] > <td> > <span class="tdlabel">Status:</span> >- [% IF ( suggestions_loo.ASKED ) %]Requested >- [% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library >- [% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library >- [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library >- [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined >- [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library >- [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) | html %] [% END %] >- [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason | html %])[% END %] >+ [% IF ( suggestion.STATUS == 'ASKED' ) %]Requested >+ [% ELSIF ( suggestion.STATUS == 'CHECKED' ) %]Checked by the library >+ [% ELSIF ( suggestion.STATUS == 'ACCEPTED' ) %]Accepted by the library >+ [% ELSIF ( suggestion.STATUS == 'ORDERED' ) %]Ordered by the library >+ [% ELSIF ( suggestion.STATUS == 'REJECTED' ) %]Suggestion declined >+ [% ELSIF ( suggestion.STATUS == 'AVAILABLE' ) %]Available in the library >+ [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS, 1 ) | html %] [% END %] >+ [% IF ( suggestion.reason ) %]([% suggestion.reason | html %])[% END %] > </td> > </tr> >- [% END # / FOREACH suggestions_loo %] >+ [% END # / FOREACH suggestions %] > </tbody> > </table> > >@@ -391,7 +389,7 @@ > <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p> > [% END %] > [% END %] >- [% END # / IF suggestions_loop %] >+ [% END # / IF suggestions.count %] > > [% END # IF op_else %] > </div> <!-- / #usersuggestions --> >diff --git a/members/purchase-suggestions.pl b/members/purchase-suggestions.pl >index 67c021e020..5aa2315dca 100755 >--- a/members/purchase-suggestions.pl >+++ b/members/purchase-suggestions.pl >@@ -23,9 +23,8 @@ use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Context; > use C4::Output; >-use C4::Members; >-use C4::Suggestions; > use Koha::Patrons; >+use Koha::Suggestions; > > my $input = new CGI; > >@@ -51,7 +50,7 @@ $template->param( > suggestionsview => 1, > ); > >-my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } ); >+my $suggestions = Koha::Suggestions->search( { suggestedby => $borrowernumber }, { prefetch => 'managedby' } ); > > $template->param( suggestions => $suggestions ); > >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index b502e92737..39797487a3 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -38,7 +38,6 @@ use Koha::DateUtils qw( dt_from_string ); > my $input = new CGI; > my $op = $input->param('op'); > my $biblionumber = $input->param('biblionumber'); >-my $suggestion = $input->Vars; > my $negcaptcha = $input->param('negcap'); > my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0; > my $need_confirm = 0; >@@ -47,10 +46,6 @@ my $need_confirm = 0; > if ($negcaptcha ) { > print $input->redirect("/cgi-bin/koha/opac-suggestions.pl"); > exit; >-} else { >- # don't pass 'negcap' column to DB, else DBI::Class will error >- # DBIx::Class::Row::store_column(): No such column 'negcap' on Koha::Schema::Result::Suggestion at Koha/C4/Suggestions.pm >- delete $suggestion->{negcap}; > } > > #If suggestions are turned off we redirect to 404 error. This will also redirect guest suggestions >@@ -59,7 +54,6 @@ if ( ! C4::Context->preference('suggestion') ) { > exit; > } > >-delete $suggestion->{$_} foreach qw<op suggested_by_anyone confirm>; > $op = 'else' unless $op; > > my ( $template, $borrowernumber, $cookie, @messages ); >@@ -87,36 +81,44 @@ else { > ); > } > >+my $suggested_by; > if ( $op eq 'else' ) { > if ( C4::Context->preference("OPACViewOthersSuggestions") ) { > if ( $borrowernumber ) { > # A logged in user is able to see suggestions from others >- $suggestion->{suggestedby} = $suggested_by_anyone >+ $suggested_by = $suggested_by_anyone > ? undef > : $borrowernumber; > } >- else { >- # Non logged in user is able to see all suggestions >- $suggestion->{suggestedby} = undef; >- } >+ # else: Non logged in user is able to see all suggestions > } > else { > if ( $borrowernumber ) { >- $suggestion->{suggestedby} = $borrowernumber; >+ $suggested_by = $borrowernumber; > } > else { >- $suggestion->{suggestedby} = -1; >+ $suggested_by = -1; > } > } > } else { > if ( $borrowernumber ) { >- $suggestion->{suggestedby} = $borrowernumber; >+ $suggested_by = $borrowernumber; > } > else { >- $suggestion->{suggestedby} = C4::Context->preference("AnonymousPatron"); >+ $suggested_by = C4::Context->preference("AnonymousPatron"); > } > } > >+my @suggestion_fields = >+ qw( title author copyrightdate isbn publishercode collectiontitle place quantity itemtype patronreason note ); >+my $suggestion = { >+ map { >+ # Keep parameters that are not an empty string >+ my $p = $input->param($_); >+ ( defined $p && $p ne '' ? ( $_ => $p ) : () ) >+ } @suggestion_fields >+}; >+ > if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates > $op = 'add_confirm'; > my $biblio = MarcRecordFromNewSuggestion($suggestion); >@@ -129,24 +131,29 @@ if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the sug > > my $patrons_pending_suggestions_count = 0; > if ( $borrowernumber && C4::Context->preference("MaxOpenSuggestions") ne '' ) { >- $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ; >+ $patrons_pending_suggestions_count = Koha::Suggestions->search( >+ { >+ suggestedby => $borrowernumber, >+ STATUS => 'ASKED', >+ } >+ )->count; > } > > if ( $op eq "add_confirm" ) { >- my $suggestions_loop = &SearchSuggestion($suggestion); >+ my $suggestions = Koha::Suggestions->search($suggestion); > if ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers > { > push @messages, { type => 'error', code => 'too_many' }; > } >- elsif ( @$suggestions_loop >= 1 ) { >+ elsif ( $suggestions->count >= 1 ) { > > #some suggestion are answering the request Donot Add >- for my $suggestion (@$suggestions_loop) { >+ while ( my $suggestion = $suggestions->next ) { > push @messages, > { > type => 'error', > code => 'already_exists', >- id => $suggestion->{suggestionid} >+ id => $suggestion->suggestionid > }; > last; > } >@@ -165,19 +172,20 @@ if ( $op eq "add_confirm" ) { > &NewSuggestion($suggestion); > $patrons_pending_suggestions_count++; > >- # delete empty fields, to avoid filter in "SearchSuggestion" >- foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) { >- delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one >- } >- $suggestions_loop = &SearchSuggestion($suggestion); >- > push @messages, { type => 'info', code => 'success_on_inserted' }; > > } > $op = 'else'; > } > >-my $suggestions_loop = &SearchSuggestion({suggestedby => $suggestion->{suggestedby}}); >+my $suggestions = Koha::Suggestions->search( >+ { >+ $suggestion->{suggestedby} >+ ? ( suggestedby => $suggestion->{suggestedby} ) >+ : () >+ } >+); >+ > if ( $op eq "delete_confirm" ) { > my @delete_field = $input->multi_param("delete_field"); > foreach my $delete_field (@delete_field) { >@@ -188,24 +196,6 @@ if ( $op eq "delete_confirm" ) { > exit; > } > >-map{ >- my $s = $_; >- my $library = Koha::Libraries->find($s->{branchcodesuggestedby}); >- $library ? $s->{branchcodesuggestedby} = $library->branchname : () >-} @$suggestions_loop; >- >-foreach my $suggestion(@$suggestions_loop) { >- if($suggestion->{'suggestedby'} == $borrowernumber) { >- $suggestion->{'showcheckbox'} = $borrowernumber; >- } else { >- $suggestion->{'showcheckbox'} = 0; >- } >- if($suggestion->{'patronreason'}){ >- my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} }); >- $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : ''; >- } >-} >- > my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG"); > > # Is the person allowed to choose their branch >@@ -247,7 +237,7 @@ my @mandatoryfields; > > $template->param( > %$suggestion, >- suggestions_loop => $suggestions_loop, >+ suggestions => $suggestions, > patron_reason_loop => $patron_reason_loop, > "op_$op" => 1, > $op => 1, >-- >2.11.0
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 23991
:
95172
|
115203
|
115207
|
116639
|
118454
|
119256
|
127058
|
127100
|
128071
|
128072
|
128073
|
128074
|
128075
|
129511
|
129512
|
129513
|
129523
|
130049
|
131896
|
132026
|
132169
|
132170
|
132171
|
132172
|
132173
|
132174
|
132175
|
133874
|
134922
|
136441
|
136442
|
137201