Bugzilla – Attachment 93142 Details for
Bug 14973
Add an alert during purchase suggestion submissions to warn the user when an existing biblio appears to satisfy the request
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14973: Check existing biblio when submitting a purchase suggestion (staff side)
Bug-14973-Check-existing-biblio-when-submitting-a-.patch (text/plain), 10.05 KB, created by
Jonathan Druart
on 2019-09-24 14:05:29 UTC
(
hide
)
Description:
Bug 14973: Check existing biblio when submitting a purchase suggestion (staff side)
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-09-24 14:05:29 UTC
Size:
10.05 KB
patch
obsolete
>From 6382a863bf7a389548fe8658123b50c346073ccc Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 8 Mar 2017 11:23:12 +0000 >Subject: [PATCH] Bug 14973: Check existing biblio when submitting a purchase > suggestion (staff side) > >--- > C4/Suggestions.pm | 2 +- > .../prog/en/modules/suggestion/suggestion.tt | 32 ++++++- > suggestion/suggestion.pl | 98 +++++++++++++--------- > 3 files changed, 91 insertions(+), 41 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 24b5f9e984..04a809d1e5 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -682,7 +682,7 @@ sub MarcRecordFromNewSuggestion { > } > else { > $record->append_fields( >- MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{author}) >+ MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{itemtype}) > ); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >index bfad9299f3..86328356d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -233,6 +233,16 @@ > [% END %] > > [% IF ( op_save ) %] >+ [% FOR m IN messages %] >+ <div class="dialog [% m.type %]"> >+ [% SWITCH m.code %] >+ [% CASE 'biblio_exists' %] >+ A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id %]">[% m.title %]</a>. Click on "Confirm your suggestion" to ignore this message. >+ [% CASE %] >+ [% m.code %] >+ [% END %] >+ </div> >+ [% END %] > <form id="add_edit" action="suggestion.pl" method="post" class="validated"> > <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" /> > <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" /> >@@ -404,7 +414,25 @@ > <input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]"/> > </li></ol> > </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]noone[% END %]"/> >- <fieldset class="action"><input type="hidden" name="op" value="[% op | html %]" />[% IF ( suggestionid ) %]<input type="submit" value="Save" /> <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a>[% ELSE %]<input type="submit" value="Submit your suggestion" /> <a class="cancel" href="suggestion.pl">Cancel</a>[% END %] >+ <fieldset class="action"> >+ <input type="hidden" name="op" value="[% op | html %]" /> >+ [% IF ( suggestionid ) %] >+ [% IF ( need_confirm ) %] >+ <input type="hidden" name="save_confirmed" value="1" /> >+ <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" /> >+ [% ELSE %] >+ <input type="submit" value="Save" /> >+ [% END %] >+ <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a> >+ [% ELSE %] >+ [% IF ( need_confirm ) %] >+ <input type="hidden" name="save_confirmed" value="1" /> >+ <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" /> >+ [% ELSE %] >+ <input type="submit" value="Submit your suggestion" /> >+ [% END %] >+ <a class="cancel" href="suggestion.pl">Cancel</a> >+ [% END %] > </fieldset> > </form> > [% END %] >@@ -422,6 +450,8 @@ > [% SWITCH m.code %] > [% CASE 'already_exists' %] > The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id | html %]&op=show'>suggestion #[% m.id | html %]</a>) >+ [% CASE 'biblio_exists' %] >+ A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id %]">[% m.title %]</a>. Click on "Confirm your suggestion" to ignore this message. > [% CASE %] > [% m.code | html %] > [% END %] >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index ed043083bd..aafd68d23d 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -91,6 +91,8 @@ my $returnsuggested = $input->param('returnsuggested'); > my $managedby = $input->param('managedby'); > my $displayby = $input->param('displayby') || ''; > my $tabcode = $input->param('tabcode'); >+my $save_confirmed = $input->param('save_confirmed') || 0; >+ > my $reasonsloop = GetAuthorisedValues("SUGGEST"); > > # filter informations which are not suggestion related. >@@ -121,57 +123,75 @@ $template->param('borrowernumber' => $borrowernumber); > ######################################### > ## Operations > ## >+ > if ( $op =~ /save/i ) { >- $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} ) >- if $suggestion_only->{suggesteddate}; >+ my @messages; >+ my $biblio = MarcRecordFromNewSuggestion({ >+ title => $suggestion_only->{title}, >+ author => $suggestion_only->{author}, >+ itemtype => $suggestion_only->{itemtype}, >+ }); >+ >+ if ( ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) { >+ push @messages, { type => 'error', code => 'biblio_exists', id => $duplicatebiblionumber, title => $duplicatetitle }; >+ $template->param( >+ messages => \@messages, >+ need_confirm => 1 >+ ); >+ delete $suggestion_ref->{suggesteddate}; >+ Init($suggestion_ref); >+ } >+ else { >+ $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} ) >+ if $suggestion_only->{suggesteddate}; > >- if ( $suggestion_only->{"STATUS"} ) { >- if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { >- $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; >- $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; >+ if ( $suggestion_only->{"STATUS"} ) { >+ if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { >+ $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; >+ $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; >+ } >+ $suggestion_only->{manageddate} = dt_from_string; >+ $suggestion_only->{"managedby"} = C4::Context->userenv->{number}; > } >- $suggestion_only->{manageddate} = dt_from_string; >- $suggestion_only->{"managedby"} = C4::Context->userenv->{number}; >- } > >- my $otherreason = $input->param('other_reason'); >- if ($suggestion_only->{reason} eq 'other' && $otherreason) { >- $suggestion_only->{reason} = $otherreason; >- } >+ my $otherreason = $input->param('other_reason'); >+ if ($suggestion_only->{reason} eq 'other' && $otherreason) { >+ $suggestion_only->{reason} = $otherreason; >+ } > >- if ( $suggestion_only->{'suggestionid'} > 0 ) { >- &ModSuggestion($suggestion_only); >- } else { >- ###FIXME:Search here if suggestion already exists. >- my $suggestions_loop = >- SearchSuggestion( $suggestion_only ); >- if (@$suggestions_loop>=1){ >- #some suggestion are answering the request Donot Add >- my @messages; >- for my $suggestion ( @$suggestions_loop ) { >- push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; >+ if ( $suggestion_only->{'suggestionid'} > 0 ) { >+ &ModSuggestion($suggestion_only); >+ } else { >+ ###FIXME:Search here if suggestion already exists. >+ my $suggestions_loop = >+ SearchSuggestion( $suggestion_only ); >+ if (@$suggestions_loop>=1){ >+ #some suggestion are answering the request Donot Add >+ my @messages; >+ for my $suggestion ( @$suggestions_loop ) { >+ push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; >+ } >+ $template->param( messages => \@messages ); >+ } >+ else { >+ ## Adding some informations related to suggestion >+ &NewSuggestion($suggestion_only); > } >- $template->param( messages => \@messages ); >- } >- else { >- ## Adding some informations related to suggestion >- &NewSuggestion($suggestion_only); >- } >- # empty fields, to avoid filter in "SearchSuggestion" >- } >- map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; >- $op = 'else'; >+ # empty fields, to avoid filter in "SearchSuggestion" >+ } >+ map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; >+ $op = 'else'; > >- if( $redirect eq 'purchase_suggestions' ) { >- print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber"); >+ if( $redirect eq 'purchase_suggestions' ) { >+ print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber"); >+ } > } >- > } > elsif ($op=~/add/) { >- #Adds suggestion >+ #Adds suggestion > Init($suggestion_ref); > $op ='save'; >-} >+} > elsif ($op=~/edit/) { > #Edit suggestion > $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); >-- >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 14973
:
43193
|
44091
|
44319
|
44320
|
44334
|
44335
|
60877
|
60913
|
93141
|
93142
|
94297
|
94298
|
94301
|
94302
|
94303
|
94304
|
95113
|
95114
|
95517
|
96255
|
96256
|
96257
|
96258
|
96259
|
96260
|
96261
|
96325
|
96326
|
96327
|
96328
|
96329
|
96330
|
96331