Bugzilla – Attachment 185281 Details for
Bug 39721
Remove GetSuggestion from C4/Suggestions.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39721: Changes suggestion_ref in order to remove it
Bug-39721-Changes-suggestionref-in-order-to-remove.patch (text/plain), 57.34 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-08-08 14:38:28 UTC
(
hide
)
Description:
Bug 39721: Changes suggestion_ref in order to remove it
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-08-08 14:38:28 UTC
Size:
57.34 KB
patch
obsolete
>From 842cdbde6bac0a0f8cc6fa0c685843bf4c098b26 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Fri, 8 Aug 2025 15:43:50 +0200 >Subject: [PATCH] Bug 39721: Changes suggestion_ref in order to remove it > >suggestion_ref is quite messy, it needs to be reworked in order to use >objects in suggestion.pl. > >As far as I studied, it is used as >- the whole input from forms, >- the default content to input in a form >- the content that will be amended in order to propose another hash to > modSuggestion. However, ModSuggestion will be removed so we don't need > such a hash >- every suggestion that need to be updated using the "change selected > suggestion" tool >- create the object suggestion_only, whose purpose is still unclear to > me. > >As a result it is created by : >> 25 my $suggestion_ref = { $input->Vars }; >And by removing a number of keys depending on the use of suggestion_ref >in the script. > >In this patch, we remove every code made to use suggestion_ref as the >source object for form and use another variable, $stored_suggestion which is an object. > >In next patch we aim at fully removing $suggestion_ref, which is still >used by ModSuggestion >--- > Koha/Suggestion.pm | 15 ++ > .../prog/en/modules/suggestion/suggestion.tt | 247 +++++++++--------- > suggestion/suggestion.pl | 70 ++--- > 3 files changed, 160 insertions(+), 172 deletions(-) > >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index f44342c687..6f441d174a 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -170,6 +170,21 @@ sub manager { > return Koha::Patron->_new_from_dbic($manager_rs); > } > >+=head3 accepter >+ >+my $accepter = $suggestion->accepter; >+ >+Returns the accepter of the suggestion (Koha::Patron for acceptedby field) >+ >+=cut >+ >+sub accepter { >+ my ($self) = @_; >+ my $manager_rs = $self->_result->acceptedby; >+ return unless $manager_rs; >+ return Koha::Patron->_new_from_dbic($manager_rs); >+} >+ > =head3 rejecter > > my $rejecter = $suggestion->rejecter; >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 c6b25551d2..f146e1e5c9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -13,7 +13,7 @@ > <title > >[% FILTER collapse %] > [% IF op == 'save' %] >- [% IF ( suggestionid ) %] >+ [% IF ( suggestion.suggestionid ) %] > [% tx("Edit suggestion #{suggestion_number}", { suggestion_number = suggestionid }) | html %] > › > [% ELSE %] >@@ -74,9 +74,9 @@ > [% END %] > [% END %] > [% IF op == 'save' %] >- [% IF ( suggestionid ) %] >+ [% IF ( suggestion.suggestionid ) %] > [% WRAPPER breadcrumb_item bc_active= 1 %] >- <span>Edit suggestion #[% suggestionid | html %]</span> >+ <span>Edit suggestion #[% suggestion.suggestionid | html %]</span> > [% END %] > [% ELSE %] > [% WRAPPER breadcrumb_item bc_active= 1 %] >@@ -85,7 +85,7 @@ > [% END %] > [% ELSIF ( op == 'show' ) %] > [% WRAPPER breadcrumb_item bc_active= 1 %] >- <span>Show suggestion #[% suggestionid | html %]</span> >+ <span>Show suggestion #[% suggestion.suggestionid | html %]</span> > [% END %] > [% ELSE %] > [% WRAPPER breadcrumb_item bc_active= 1 %] >@@ -103,13 +103,13 @@ > > <div id="toolbar" class="btn-toolbar"> > [% IF CAN_user_suggestions_suggestions_manage %] >- <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit_form&suggestionid=[% suggestionid | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> >+ <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit_form&suggestionid=[% suggestion.suggestionid | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> > [% END %] > [% IF CAN_user_suggestions_suggestions_delete %] > <form class="delete_form" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl"> > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="op" value="cud-delete" /> >- <input type="hidden" name="suggestionid" value="[% suggestionid | html %]" /> >+ <input type="hidden" name="suggestionid" value="[% suggestion.suggestionid | html %]" /> > <button type="submit" class="btn btn-default deletesuggestion"><i class="fa fa-trash-can"></i> Delete</button> > </form> > [% END %] >@@ -118,78 +118,78 @@ > <fieldset class="rows"> > <legend>Bibliographic information</legend> > <ol> >- [% IF ( title ) %] >+ [% IF ( suggestion.title ) %] > <li> > <span class="label">Title:</span> > [% IF suggestion.biblionumber %] > <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% suggestion.biblionumber | uri %]">[% suggestion.title | html %]</a> > [% ELSE %] >- [% title | html %] >+ [% suggestion.title | html %] > [% END %] > </li> > [% END %] >- [% IF ( author ) %] >+ [% IF ( suggestion.author ) %] > <li> > <span class="label">Author:</span> >- [% author | html %] >+ [% suggestion.author | html %] > </li> > [% END %] >- [% IF ( copyrightdate ) %] >+ [% IF ( suggestion.copyrightdate ) %] > <li> > <span class="label">Copyright date:</span> >- [% copyrightdate | html %] >+ [% suggestion.copyrightdate | html %] > </li> > [% END %] >- [% IF ( isbn ) %] >+ [% IF ( suggestion.isbn ) %] > <li> > <span class="label">ISBN or ISSN or other standard number:</span> >- [% isbn | html %] >+ [% suggestion.isbn | html %] > </li> > [% END %] >- [% IF ( publishercode ) %] >+ [% IF ( suggestion.publishercode ) %] > <li> > <span class="label">Publisher:</span> >- [% publishercode | html %] >+ [% suggestion.publishercode | html %] > </li> > [% END %] >- [% IF ( place ) %] >+ [% IF ( suggestion.place ) %] > <li> > <span class="label">Publication place:</span> >- [% place | html %] >+ [% suggestion.place | html %] > </li> > [% END %] >- [% IF ( collectiontitle ) %] >+ [% IF ( suggestion.collectiontitle ) %] > <li> > <span class="label">Collection title:</span> >- [% collectiontitle | html %] >+ [% suggestion.collectiontitle | html %] > </li> > [% END %] >- [% IF ( itemtype ) %] >+ [% IF ( suggestion.itemtype ) %] > <li> > <span class="label">Document type:</span> >- [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', itemtype, 0 ) | html %] >+ [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 0 ) | html %] > </li> > [% END %] > [% IF ( patron_reason_loop ) %] > <li> > <span class="label">Reason for suggestion: </span> > [% FOREACH patron_reason_loo IN patron_reason_loop %] >- [% IF patron_reason_loo.authorised_value == patronreason %] >+ [% IF patron_reason_loo.authorised_value == suggestion.patronreason %] > [% patron_reason_loo.lib | html %] > [% END %] > [% END %] > </li> > [% END %] >- [% IF ( note ) %] >+ [% IF ( suggestion.note ) %] > <li> > <span class="label">Notes:</span> >- [% note | html %] >+ [% suggestion.note | html %] > </li> > [% END %] >- [% IF ( staff_note ) %] >+ [% IF ( suggestion.staff_note ) %] > <li> > <span class="label">Notes:</span> >- [% staff_note | html %] >+ [% suggestion.staff_note | html %] > </li> > [% END %] > </ol> >@@ -201,27 +201,27 @@ > <li> > <span class="label">Status:</span> > [% SET status_found = 0 %] >- [% IF ( STATUS == 'ASKED' ) %] >+ [% IF ( suggestion.STATUS == 'ASKED' ) %] > <span>Pending</span> > [% SET status_found = 1 %] >- [% ELSIF ( STATUS == 'ACCEPTED' ) %] >+ [% ELSIF ( suggestion.STATUS == 'ACCEPTED' ) %] > <span>Accepted</span> > [% SET status_found = 1 %] >- [% ELSIF ( STATUS == 'CHECKED' ) %] >+ [% ELSIF ( suggestion.STATUS == 'CHECKED' ) %] > <span>Checked</span> > [% SET status_found = 1 %] >- [% ELSIF ( STATUS == 'REJECTED' ) %] >+ [% ELSIF ( suggestion.STATUS == 'REJECTED' ) %] > <span>Rejected</span> > [% SET status_found = 1 %] >- [% ELSIF ( STATUS == 'ORDERED' ) %] >+ [% ELSIF ( suggestion.STATUS == 'ORDERED' ) %] > <span>Ordered</span> > [% SET status_found = 1 %] >- [% ELSIF ( STATUS == 'AVAILABLE' ) %] >+ [% ELSIF ( suggestion.STATUS == 'AVAILABLE' ) %] > <span>Available</span> > [% SET status_found = 1 %] > [% ELSE %] > [% FOREACH s IN SuggestionStatuses %] >- [% IF STATUS == s.authorised_value %] >+ [% IF suggestion.STATUS == s.authorised_value %] > [% s.lib | html %] > [% SET status_found = 1 %] > [% END %] >@@ -247,49 +247,49 @@ > <tbody> > <tr> > <th>[% tp('purchase suggestion created by', 'Created by:') | html %]</th> >- <td>[% suggesteddate | $KohaDates %]</td> >+ <td>[% suggestion.suggesteddate | $KohaDates %]</td> > <td> >- [% IF ( suggestedby_patron.borrowernumber ) %] >- <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_patron.borrowernumber | uri %]" >- >[% suggestedby_patron.surname | html %], [% suggestedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a >+ [% IF ( suggestion.suggester.borrowernumber ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.suggester.borrowernumber | uri %]" >+ >[% suggestion.suggester.surname | html %], [% suggestion.suggester.firstname | html %] ([% suggestion.suggester.cardnumber | html %])</a > > >- [% Branches.GetName( suggestedby_patron.branchcode ) | html %] ([% suggestedby_patron.category.description | html %]) >+ [% Branches.GetName( suggestion.suggester.branchcode ) | html %] ([% suggestion.suggester.category.description | html %]) > [% END %] > </td> > </tr> > <tr> > <th>Managed by:</th> >- <td>[% manageddate | $KohaDates %]</td> >+ <td>[% suggestion.manageddate | $KohaDates %]</td> > <td> >- [% IF ( managedby_patron.borrowernumber ) %] >- <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_patron.borrowernumber | uri %]" >- >[% managedby_patron.surname | html %], [% managedby_patron.firstname | html %] ([% managedby_patron.cardnumber | html %])</a >+ [% IF ( suggestion.manager.borrowernumber ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.manager.borrowernumber | uri %]" >+ >[% suggestion.manager.surname | html %], [% suggestion.manager.firstname | html %] ([% suggestion.manager.cardnumber | html %])</a > > >- [% Branches.GetName( managedby_patron.branchcode ) | html %] ([% managedby_patron.category.description | html %]) >+ [% Branches.GetName( suggestion.manager.branchcode ) | html %] ([% suggestion.manager.category.description | html %]) > [% END %] > </td> > </tr> > <tr> > <th>Accepted on:</th> >- <td>[% accepteddate | $KohaDates %]</td> >+ <td>[% suggestion.accepteddate | $KohaDates %]</td> > <td> >- [% IF ( acceptedby_patron.borrowernumber ) %] >- <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_patron.borrowernumber | uri %]" >- >[% acceptedby_patron.surname | html %], [% acceptedby_patron.firstname | html %] ([% acceptedby_patron.cardnumber | html %])</a >+ [% IF ( suggestion.accepter.borrowernumber ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.accepter.borrowernumber | uri %]" >+ >[% suggestion.accepter.surname | html %], [% suggestion.accepter.firstname | html %] ([% suggestion.accepter.cardnumber | html %])</a > > >- [% Branches.GetName( acceptedby_patron.branchcode ) | html %] ([% acceptedby_patron.category.description | html %]) >+ [% Branches.GetName( suggestion.accepter.branchcode ) | html %] ([% suggestion.accepter.category.description | html %]) > [% END %] > </td> > </tr> > <tr> > <th>Last modification on:</th> >- <td>[% lastmodificationdate | $KohaDates %]</td> >+ <td>[% suggestion.lastmodificationdate | $KohaDates %]</td> > <td> >- [% IF ( lastmodificationby_patron.borrowernumber ) %] >- <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% lastmodificationby_patron.borrowernumber | uri %]" >- >[% lastmodificationby_patron.surname | html %], [% lastmodificationby_patron.firstname | html %] ([% lastmodificationby_patron.cardnumber | html %])</a >+ [% IF ( suggestion.last_modifier.borrowernumber ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.last_modifier.borrowernumber | uri %]" >+ >[% suggestion.last_modifier.surname | html %], [% suggestion.last_modifier.firstname | html %] ([% suggestion.last_modifier.cardnumber | html %])</a > > >- [% Branches.GetName( lastmodificationby_patron.branchcode ) | html %] ([% lastmodificationby_patron.category.description | html %]) >+ [% Branches.GetName( suggestion.last_modifier.branchcode ) | html %] ([% suggestion.last_modifier.category.description | html %]) > [% END %] > </td> > </tr> >@@ -302,27 +302,27 @@ > <ol> > <li> > <span class="label">Library:</span> >- [% Branches.GetName( branchcode ) | html %] >+ [% Branches.GetName( suggestion.branchcode ) | html %] > </li> > <li> > <span class="label">Fund:</span> >- [% budgetname | html %] >+ [% suggestion.fund.budget_name | html %] > </li> > <li> > <span class="label">Copies:</span> >- [% quantity | html %] >+ [% suggestion.quantity | html %] > </li> > <li> > <span class="label">Currency:</span> >- [% currency | html %] >+ [% suggestion.currency | html %] > </li> > <li> > <span class="label">Price:</span> >- [% price | $Price %] >+ [% suggestion.price | $Price %] > </li> > <li> > <span class="label">Total</span> >- [% total | $Price %] >+ [% suggestion.total | $Price %] > </li> > </ol> > </fieldset> >@@ -373,9 +373,9 @@ > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" /> > <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" /> >- [% IF ( suggestionid ) %] >- <h1>Edit purchase suggestion #[% suggestionid | html %]</h1> >- <input type="hidden" name="suggestionid" value="[% suggestionid | html %]" /> >+ [% IF ( suggestion.suggestionid ) %] >+ <h1>Edit purchase suggestion #[% suggestion.suggestionid | html %]</h1> >+ <input type="hidden" name="suggestionid" value="[% suggestion.suggestionid | html %]" /> > [% ELSE %] > <h1>Enter a new purchase suggestion</h1> > [% END %] >@@ -385,36 +385,36 @@ > <ol> > <li> > <label for="title" class="required">Title:</label> >- <input type="text" id="title" name="title" size="80" maxlength="255" value="[% title | html %]" required="required" class="required" /> >+ <input type="text" id="title" name="title" size="80" maxlength="255" value="[% suggestion.title | html %]" required="required" class="required" /> > <span class="required">Required</span> > </li> > <li> > <label for="author">Author:</label> >- <input type="text" id="author" name="author" size="50" maxlength="80" value="[% author | html %]" /> >+ <input type="text" id="author" name="author" size="50" maxlength="80" value="[% suggestion.author | html %]" /> > </li> > <li> > <label for="copyrightdate">Copyright date:</label> >- <input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" value="[% copyrightdate | html %]" /> >+ <input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" value="[% suggestion.copyrightdate | html %]" /> > </li> > <li> > <label for="isbn">ISBN or ISSN or other standard number:</label> >- <input type="text" id="isbn" name="isbn" size="50" maxlength="80" value="[% isbn | html %]" /> >+ <input type="text" id="isbn" name="isbn" size="50" maxlength="80" value="[% suggestion.isbn | html %]" /> > </li> > <li> > <label for="publishercode">Publisher:</label> >- <input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" value="[% publishercode | html %]" /> >+ <input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" value="[% suggestion.publishercode | html %]" /> > </li> > <li> > <label for="place">Publication place:</label> >- <input type="text" id="place" name="place" size="50" maxlength="80" value="[% place | html %]" /> >+ <input type="text" id="place" name="place" size="50" maxlength="80" value="[% suggestion.place | html %]" /> > </li> > <li> > <label for="collectiontitle">Collection title:</label> >- <input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle | html %]" /> >+ <input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% suggestion.collectiontitle | html %]" /> > </li> > <li> > <label for="itemtype">Document type:</label> >- [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size=20, default=itemtype, empty=1 %] >+ [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size=20, default=suggestion.itemtype, empty=1 %] > </li> > [% IF patron_reason_loop %] > <li> >@@ -422,7 +422,7 @@ > <select name="patronreason" id="patronreason"> > <option value=""> -- Choose -- </option> > [% FOREACH patron_reason_loo IN patron_reason_loop %] >- [% IF patron_reason_loo.authorised_value == patronreason %] >+ [% IF patron_reason_loo.authorised_value == suggestion.patronreason %] > <option value="[% patron_reason_loo.authorised_value | html %]" selected="selected">[% patron_reason_loo.lib | html %]</option> > [% ELSE %] > <option value="[% patron_reason_loo.authorised_value | html %]">[% patron_reason_loo.lib | html %]</option> >@@ -433,11 +433,11 @@ > [% END # /IF patron_reason_loop %] > <li> > <label for="note">Notes:</label> >- <textarea name="note" id="note" rows="5" cols="40">[% note | html %]</textarea> >+ <textarea name="note" id="note" rows="5" cols="40">[% suggestion.note | html %]</textarea> > </li> > <li> > <label for="note">Non-public notes:</label> >- <textarea name="staff_note" id="staff_note" rows="5" cols="40">[% staff_note | html %]</textarea> >+ <textarea name="staff_note" id="staff_note" rows="5" cols="40">[% suggestion.staff_note | html %]</textarea> > </li> > </ol> > </fieldset> >@@ -445,7 +445,7 @@ > <fieldset class="rows"> > <legend>Suggestion management</legend> > <ol> >- [% IF ( suggestionid ) %] >+ [% IF ( suggestion.suggestionid ) %] > <li> > <label for="STATUS">Status:</label> > <select id="STATUS" name="STATUS"> >@@ -500,7 +500,7 @@ > <label for="reason">Reason:</label> > <select class="select-reason" id="reason" name="reason"> > <option value=""> -- Choose a reason -- </option> >- [% FOREACH reasonsloo IN suggestion.reasonsloop %] >+ [% FOREACH reasonsloo IN reasonsloop %] > [% IF (reasonsloo.lib == suggestion.reason) %] > <option value="[% reasonsloo.lib | html %]" selected="selected">[% reasonsloo.lib | html %]</option> > [% ELSE %] >@@ -535,14 +535,19 @@ > <th> > <label for="suggesteddate">[% tp('purchase suggestion created by', 'Created by:') | html %]</label> > </th> >- <td> <input type="text" id="suggesteddate" name="suggesteddate" class="flatpickr" size="10" maxlength="10" value="[% suggesteddate | html %]" /> [% INCLUDE 'date-format.inc' %] </td> >+ <td> <input type="text" id="suggesteddate" name="suggesteddate" class="flatpickr" size="10" maxlength="10" value="[% default_suggesteddate ? default_suggesteddate : suggestion.suggesteddate | html %]" /> [% INCLUDE 'date-format.inc' %] </td> > <td id="tdsuggestedby"> >- <input type="hidden" id="suggestedby" name="suggestedby" value="[% suggestedby | html %]" /> >- [% IF ( suggestedby_patron.borrowernumber ) %] >- <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_patron.borrowernumber | uri %]" >- >[% suggestedby_patron.surname | html %], [% suggestedby_patron.firstname | html %] ([% suggestedby_patron.cardnumber | html %])</a >+ <input type="hidden" id="suggestedby" name="suggestedby" value="[% suggestion.suggestedby | html %]" /> >+ [% IF ( suggestion.suggester.borrowernumber ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.suggester.borrowernumber | uri %]" >+ >[% suggestion.suggester.surname | html %], [% suggestion.suggester.firstname | html %] ([% suggestion.suggester.cardnumber | html %])</a > > >- [% Branches.GetName( suggestedby_patron.branchcode ) | html %] ([% suggestedby_patron.category.description | html %]) >+ [% Branches.GetName( suggestion.suggester.branchcode ) | html %] ([% suggestion.suggester.category.description | html %]) >+ [% ELSIF ( default_suggester ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% default_suggester.borrowernumber | uri %]" >+ >[% default_suggester.surname | html %], [% default_suggester.firstname | html %] ([% default_suggester.cardnumber | html %])</a >+ > >+ [% Branches.GetName( default_suggester.branchcode ) | html %] ([% default_suggester.category.description | html %]) > [% END %] > </td> > <td> >@@ -553,14 +558,14 @@ > <th> > <label for="accepteddate">Accepted on:</label> > </th> >- <td> <input type="text" id="accepteddate" name="accepteddate" class="flatpickr" size="10" maxlength="10" value="[% accepteddate | html %]" />[% INCLUDE 'date-format.inc' %] </td> >+ <td> <input type="text" id="accepteddate" name="accepteddate" class="flatpickr" size="10" maxlength="10" value="[% suggestion.accepteddate | html %]" />[% INCLUDE 'date-format.inc' %] </td> > <td> >- <input type="hidden" id="acceptedby" name="acceptedby" value="[% acceptedby | html %]" /> >- [% IF ( acceptedby_patron.borrowernumber ) %] >- <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_patron.borrowernumber | uri %]" >- >[% acceptedby_patron.surname | html %], [% acceptedby_patron.firstname | html %] ([% acceptedby_patron.cardnumber | html %])</a >+ <input type="hidden" id="acceptedby" name="acceptedby" value="[% suggestion.acceptedby | html %]" /> >+ [% IF ( suggestion.accepter.borrowernumber ) %] >+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.accepter.borrowernumber | uri %]" >+ >[% suggestion.accepter.surname | html %], [% suggestion.accepter.firstname | html %] ([% suggestion.accepter.cardnumber | html %])</a > > >- [% Branches.GetName( acceptedby_patron.branchcode ) | html %] ([% acceptedby_patron.category.description | html %]) >+ [% Branches.GetName( suggestion.accepter.branchcode ) | html %] ([% suggestion.accepter.category.description | html %]) > [% END %] > </td> > <td></td> >@@ -569,12 +574,12 @@ > <th> > <label for="lastmodificationdate">Last modification on:</label> > </th> >- <td> [% lastmodificationdate | $KohaDates %] </td> >+ <td> [% suggestion.lastmodificationdate | $KohaDates %] </td> > <td> >- [% IF lastmodificationby_patron %] >- [% INCLUDE 'patron-title.inc' patron=lastmodificationby_patron hide_patron_infos_if_needed=1 %] >- [% Branches.GetName( lastmodificationby_patron.branchcode ) | html %] >- ([% lastmodificationby_patron.category.description | html %]) >+ [% IF suggestion.last_modifier %] >+ [% INCLUDE 'patron-title.inc' patron=suggestion.last_modifier hide_patron_infos_if_needed=1 %] >+ [% Branches.GetName( suggestion.last_modifier.branchcode ) | html %] >+ ([% suggestion.last_modifier.category.description | html %]) > [% END %] > </td> > <td></td> >@@ -584,7 +589,7 @@ > </li> > <li> > <label for="managedon">Managed on:</label> >- <input type="text" id="managedon" name="manageddate" class="flatpickr" size="10" maxlength="10" value="[% manageddate | html %]" />[% INCLUDE 'date-format.inc' %] >+ <input type="text" id="managedon" name="manageddate" class="flatpickr" size="10" maxlength="10" value="[% default_manageddate | html %]" />[% INCLUDE 'date-format.inc' %] > </li> > <li> > <label for="managedby_name">by:</label> >@@ -596,13 +601,13 @@ > Nobody > [% END %] > </span> >- [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %] >- | Previously was [% INCLUDE 'patron-title.inc' patron=managedby_patron hide_patron_infos_if_needed=1 %] [% Branches.GetName( managedby_patron.branchcode ) | html %] >- ([% managedby_patron.category.description | html %]) >+ [% IF suggestion.manager.borrowernumber && logged_in_user.borrowernumber != suggestion.manager.borrowernumber %] >+ | Previously was [% INCLUDE 'patron-title.inc' patron=suggestion.manager hide_patron_infos_if_needed=1 %] [% Branches.GetName( suggestion.manager.branchcode ) | html %] >+ ([% suggestion.manager.category.description | html %]) > [% END %] > <br /> > <a href="#patron_search_modal_manager" id="edit_manager" data-bs-toggle="modal"><i class="fa fa-search"></i> Select manager</a> >- [% IF managedby_patron.borrowernumber && logged_in_user.borrowernumber != managedby_patron.borrowernumber %] >+ [% IF suggestion.manager.borrowernumber && logged_in_user.borrowernumber != suggestion.manager.borrowernumber %] > <a id="restore_previous_manager" href="#"><i class="fa fa-trash-can"></i> Keep existing manager</a> > [% END %] > [% IF CAN_user_suggestions_suggestions_manage %] >@@ -632,13 +637,13 @@ > <label for="branchcode">Library:</label> > <select name="branchcode" id="branchcode"> > <option value="">Any</option> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => suggestion.branchcode ) %] > </select> > </li> > <li> [% PROCESS funds_dropdown %] </li> > <li> > <label for="quantity">Copies:</label> >- <input type="text" size="10" id="quantity" name="quantity" value="[% quantity | html %]" /> >+ <input type="text" size="10" id="quantity" name="quantity" value="[% suggestion.quantity | html %]" /> > </li> > <li> > <label for="currency">Currency:</label> >@@ -648,7 +653,7 @@ > [% END %] > <select name="currency" id="currency"> > [% FOREACH c IN currencies %] >- [% IF suggestionid and suggestion.currency == c.currency or not suggestionid and c.active %] >+ [% IF suggestion.suggestionid and suggestion.currency == c.currency or not suggestion.suggestionid and c.active %] > <option value="[% c.currency | html %]" selected="selected">[% c.currency | html %]</option> > [% ELSIF not c.archived %] > <option value="[% c.currency | html %]">[% c.currency | html %]</option> >@@ -658,11 +663,11 @@ > </li> > <li> > <label for="price">Price:</label> >- <input class="decimal" type="text" size="20" name="price" id="price" value="[% price | $Price on_editing => 1 %]" /> >+ <input class="decimal" type="text" size="20" name="price" id="price" value="[% suggestion.price | $Price on_editing => 1 %]" /> > </li> > <li> > <label for="total">Total: </label> >- <input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]" /> >+ <input type="text" readonly="readonly" id="total" name="total" size="10" value="[% suggestion.total | html %]" /> > </li> > </ol> > </fieldset> >@@ -670,7 +675,7 @@ > > <fieldset class="action"> > <input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]no_one[% END %]" /> >- [% IF ( suggestionid ) %] >+ [% IF ( suggestion.suggestionid ) %] > <input type="hidden" name="op" value="cud-save" /> > [% IF ( need_confirm ) %] > <input type="hidden" name="save_confirmed" value="1" /> >@@ -698,7 +703,7 @@ > [% IF op == 'else' %] > <div id="toolbar" class="btn-toolbar"> > [% IF CAN_user_suggestions_suggestions_create %] >- <a class="btn btn-default" id="newsuggestion" href="suggestion.pl?op=add_form&branchcode=[% branchcode | uri %]"><i class="fa fa-plus"></i> New purchase suggestion</a> >+ <a class="btn btn-default" id="newsuggestion" href="suggestion.pl?op=add_form&branchcode=[% suggestion.branchcode | uri %]"><i class="fa fa-plus"></i> New purchase suggestion</a> > [% END %] > </div> > >@@ -862,7 +867,7 @@ > <label for="choosereason-[% suggestion.suggestiontype | html %]">with this reason:</label> > <select name="reason" id="choosereason-[% suggestion.suggestiontype | html %]"> > <option value=""> -- Choose a reason -- </option> >- [% FOREACH reasonsloo IN suggestion.reasonsloop %] >+ [% FOREACH reasonsloo IN reasonsloop %] > <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option> > [% END %] > <option value="other">Others...</option> >@@ -972,7 +977,7 @@ > <li> > <label for="displayby" class="sr-only">Organize by: </label> > <select name="displayby" id="displayby"> >- [% IF ( displayby == "STATUS" ) %] >+ [% IF ( displayby == "suggestion.STATUS" ) %] > <option value="STATUS" selected="selected">Status</option> > [% ELSE %] > <option value="STATUS">Status</option> >@@ -1015,27 +1020,27 @@ > <ol> > <li> > <label for="title"> Title:</label> >- <input type="text" id="title" name="title" value="[% title | html %]" /> >+ <input type="text" id="title" name="title" value="[% suggestion.title | html %]" /> > </li> > <li> > <label for="author"> Author:</label> >- <input type="text" id="author" name="author" value="[% author | html %]" /> >+ <input type="text" id="author" name="author" value="[% suggestion.author | html %]" /> > </li> > <li> > <label for="isbn"> ISBN:</label> >- <input type="text" id="isbn" name="isbn" value="[% isbn | html %]" /> >+ <input type="text" id="isbn" name="isbn" value="[% suggestion.isbn | html %]" /> > </li> > <li> > <label for="publishercode"> Publisher:</label> >- <input type="text" id="publishercode" name="publishercode" value="[% publishercode | html %]" /> >+ <input type="text" id="publishercode" name="publishercode" value="[% suggestion.publishercode | html %]" /> > </li> > <li> > <label for="copyrightdate_filter"> Copyright date:</label> >- <input type="text" id="copyrightdate_filter" name="copyrightdate" value="[% copyrightdate | html %]" /> >+ <input type="text" id="copyrightdate_filter" name="copyrightdate" value="[% suggestion.copyrightdate | html %]" /> > </li> > <li> > <label for="collectiontitle"> Collection title:</label> >- <input type="text" id="collectiontitle" name="collectiontitle" value="[% collectiontitle | html %]" /> >+ <input type="text" id="collectiontitle" name="collectiontitle" value="[% suggestion.collectiontitle | html %]" /> > </li> > </ol> > </fieldset> >@@ -1106,11 +1111,11 @@ > </li> > <li> > <label for="suggesteddate_from">Suggested date from:</label> >- <input type="text" id="suggesteddate_from" size="10" name="suggesteddate_from" value="[% suggesteddate_from | html %]" data-date_to="suggesteddate_to" class="flatpickr" /> >+ <input type="text" id="suggesteddate_from" size="10" name="suggesteddate_from" value="[% suggestion.suggesteddate_from | html %]" data-date_to="suggesteddate_to" class="flatpickr" /> > </li> > <li> > <label for="suggesteddate_to">To:</label> >- <input type="text" id="suggesteddate_to" size="10" name="suggesteddate_to" value="[% suggesteddate_to | html %]" class="flatpickr" /> >+ <input type="text" id="suggesteddate_to" size="10" name="suggesteddate_to" value="[% suggestion.suggesteddate_to | html %]" class="flatpickr" /> > </li> > <li> > <label for="managedby"> Managed by:</label> >@@ -1213,7 +1218,7 @@ > [% UNLESS op == 'save' %] > <option value="">Any</option> > [% END %] >- [% IF budgetid == '__NONE__' %] >+ [% IF suggestion.budgetid == '__NONE__' %] > <option value="__NONE__" selected="selected">None</option> > [% ELSE %] > <option value="__NONE__">None</option> >@@ -1259,8 +1264,8 @@ > [% IF op == "save" %] > var notify = $('#notify'); > if ( notify.length ) { >- [% IF managedby_patron %] >- if ( borrowernumber == [% logged_in_user.borrowernumber | html %] || borrowernumber == [% managedby_patron.borrowernumber | html %] ) { >+ [% IF suggestion.manager %] >+ if ( borrowernumber == [% logged_in_user.borrowernumber | html %] || borrowernumber == [% suggestion.manager.borrowernumber | html %] ) { > [% ELSE %] > if ( borrowernumber == [% logged_in_user.borrowernumber | html %] ) { > [% END %] >@@ -1666,12 +1671,12 @@ > > $("#managedby_name").empty(); > $("#managedby").val(''); >- var borrowername = "[% managedby_patron.firstname | html %] [% managedby_patron.surname | html %]"; >+ var borrowername = "[% suggestion.manager.firstname | html %] [% suggestion.manager.surname | html %]"; > var managerlink = '<a href="/cgi-bin/koha/members/moremember.pl' >- + '?borrowernumber=[% managedby_patron.borrowernumber | html %]">' >+ + '?borrowernumber=[% suggestion.manager.borrowernumber | html %]">' > + borrowername + '</a>'; > $('#managedby_name').html(managerlink); >- $('#managedby').val([% managedby_patron.borrowernumber | html %]); >+ $('#managedby').val([% suggestion.manager.borrowernumber | html %]); > $('#notify').prop('checked', false).prop('disabled', true); > }); > >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index 0949348b12..e4009a9e33 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -37,24 +37,6 @@ use Koha::Token; > > use URI::Escape qw( uri_escape ); > >-sub Init { >- my $suggestion = shift @_; >- >- # "Managed by" is used only when a suggestion is being edited (not when created) >- if ( $suggestion->{'suggesteddate'} eq "" ) { >- >- # new suggestion >- $suggestion->{suggesteddate} = dt_from_string; >- $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ( $suggestion->{'suggestedby'} ); >- } else { >- >- # editing of an existing suggestion >- $suggestion->{manageddate} = dt_from_string; >- $suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ( $suggestion->{'managedby'} ); >- } >- $suggestion->{'branchcode'} = C4::Context->userenv->{"branch"} unless ( $suggestion->{'branchcode'} ); >-} >- > sub GetCriteriumDesc { > my ( $criteriumvalue, $displayby ) = @_; > if ( $displayby =~ /status/i ) { >@@ -106,6 +88,9 @@ my $sugg_managedby = $input->param('suggestion_managedby'); > my $reasonsloop = GetAuthorisedValues("SUGGEST"); > > my $suggestion_ref = { $input->Vars }; >+my $stored_suggestion; >+$stored_suggestion = Koha::Suggestions->find( $input->param('suggestionid') ) if $input->param('suggestionid'); >+ > delete $suggestion_ref->{$_} for qw(csrf_token suggestion_itemtype suggestion_managedby table_1_length); > > # get only the columns of Suggestion >@@ -114,14 +99,8 @@ my $columns = ' ' . join( ' ', $schema->source('Suggestion')->columns ) > my $suggestion_only = { map { $columns =~ / $_ / ? ( $_ => $suggestion_ref->{$_} ) : () } keys %$suggestion_ref }; > $suggestion_only->{STATUS} = $suggestion_ref->{STATUS}; > >-delete $$suggestion_ref{$_} >- foreach > qw( suggestedbyme op displayby tabcode notify filter_archived koha_login_context auth_forwarded_hash password userid ); > >-foreach my $key ( keys %$suggestion_ref ) { >- delete $suggestion_ref->{$key} if ( !$suggestion_ref->{$key} && ( $op eq 'else' ) ); >- delete $suggestion_ref->{$key} if $key =~ m{^DataTables_acqui_suggestions_suggestions}; >-} > delete $suggestion_only->{branchcode} if $suggestion_only->{branchcode} eq '__ANY__'; > delete $suggestion_only->{budgetid} if $suggestion_only->{budgetid} eq '__ANY__'; > >@@ -171,10 +150,6 @@ if ( $op =~ /cud-save/ ) { > $template->param( > messages => \@messages, > ); >- delete $suggestion_ref->{suggesteddate}; >- delete $suggestion_ref->{manageddate}; >- delete $suggestion_ref->{managedby}; >- Init($suggestion_ref); > } elsif ( !$suggestion_only->{suggestionid} > && ( my ( $duplicatebiblionumber, $duplicatetitle ) = FindDuplicate($biblio) ) > && !$save_confirmed ) >@@ -185,9 +160,6 @@ if ( $op =~ /cud-save/ ) { > messages => \@messages, > need_confirm => 1 > ); >- delete $suggestion_ref->{suggesteddate}; >- delete $suggestion_ref->{manageddate}; >- Init($suggestion_ref); > $op = 'save'; > } else { > >@@ -275,7 +247,6 @@ if ( $op =~ /cud-save/ ) { > > # empty fields, to avoid filter in "SearchSuggestion" > } >- map { delete $$suggestion_ref{$_} unless $_ eq 'branchcode' } keys %$suggestion_ref; > $op = 'else'; > > if ( $redirect eq 'purchase_suggestions' ) { >@@ -284,23 +255,27 @@ if ( $op =~ /cud-save/ ) { > } > } elsif ( $op eq 'add_form' ) { > >- #Adds suggestion >- Init($suggestion_ref); >+ $template->param( >+ default_suggester => $librarian, >+ default_suggesteddate => dt_from_string, >+ default_branch => C4::Context->userenv->{"branch"}, >+ ); > $op = 'save'; > } elsif ( $op eq 'edit_form' ) { > > #Edit suggestion >- $suggestion_ref = Koha::Suggestions->find( $suggestion_ref->{suggestionid} )->unblessed(); >- $suggestion_ref->{reasonsloop} = $reasonsloop; > my $other_reason = 1; > foreach my $reason ( @{$reasonsloop} ) { >- if ( $suggestion_ref->{reason} eq $reason->{lib} ) { >+ if ( $stored_suggestion->reason eq $reason->{lib} ) { > $other_reason = 0; > } > } >- $other_reason = 0 unless $suggestion_ref->{reason}; >- $template->param( other_reason => $other_reason ); >- Init($suggestion_ref); >+ $other_reason = 0 unless $stored_suggestion->reason; >+ $template->param( >+ other_reason => $other_reason, >+ default_manageddate => dt_from_string, >+ default_branch => C4::Context->userenv->{"branch"}, >+ ); > $op = 'save'; > } elsif ( $op eq "cud-update_status" ) { > my $suggestion; >@@ -382,11 +357,6 @@ if ( $op =~ /cud-save/ ) { > push @messages, { type => 'error', code => 'no_manage_permission' }; > $template->param( messages => \@messages, ); > } >-} elsif ( $op eq 'show' ) { >- $suggestion_ref = Koha::Suggestions->find( $suggestion_ref->{suggestionid} )->unblessed(); >- my $budget = GetBudget $$suggestion_ref{budgetid}; >- $$suggestion_ref{budgetname} = $$budget{budget_name}; >- Init($suggestion_ref); > } > > if ( $op eq 'else' ) { >@@ -506,7 +476,6 @@ if ( $op eq 'else' ) { > { > "suggestiontype" => $criteriumvalue || "suggest", > "suggestiontypelabel" => GetCriteriumDesc( $criteriumvalue, $displayby ) || "", >- 'reasonsloop' => $reasonsloop, > 'search_params' => $criterium_search_params, > 'tab_count' => $tab_counts->{$criteriumvalue}, > } >@@ -522,15 +491,14 @@ if ( $op eq 'else' ) { > ); > } > >-$template->param( "${_}_patron" => scalar Koha::Patrons->find( $suggestion_ref->{$_} ) ) >- for qw(managedby suggestedby acceptedby lastmodificationby); >- > $template->param( >- %$suggestion_ref, >+ suggestion => $stored_suggestion, > filter_archived => $filter_archived, > "op" => $op, >+ reasonsloop => $reasonsloop, > ); > >+ > if ( defined($returnsuggested) and $returnsuggested ne "no_one" ) { > print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $returnsuggested . "#suggestions" ); > } >@@ -572,7 +540,7 @@ if ( $suggestion_ref->{STATUS} ) { > my $currencies = Koha::Acquisition::Currencies->search; > $template->param( > currencies => $currencies, >- suggestion => $suggestion_ref, >+ suggestion => $stored_suggestion, > price => sprintf( "%.2f", $$suggestion_ref{'price'} || 0 ), > total => sprintf( "%.2f", $$suggestion_ref{'total'} || 0 ), > ); >-- >2.43.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 39721
:
181402
|
181416
|
182810
|
185280
| 185281 |
185282
|
185283