Bug 23590: Add lastmodification by and date columns
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 Nov 2019 14:32:50 +0000 (15:32 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 25 Mar 2020 09:34:53 +0000 (09:34 +0000)
No tests are provided for the changes made to SearchSuggestion. It is
going to be remove very soon as it is super ugly...

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Suggestions.pm
installer/data/mysql/kohastructure.sql
koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
suggestion/suggestion.pl

index 86a8c90..8d53360 100644 (file)
@@ -111,6 +111,8 @@ sub SearchSuggestion {
             U2.email            AS emailmanagedby,
             U2.branchcode       AS branchcodemanagedby,
             U2.borrowernumber   AS borrnummanagedby,
+            U3.surname          AS surnamelastmodificationby,
+            U3.firstname        AS firstnamelastmodificationby,
             BU.budget_name      AS budget_name
         FROM suggestions
             LEFT JOIN borrowers     AS U1 ON suggestedby=U1.borrowernumber
@@ -119,6 +121,7 @@ sub SearchSuggestion {
             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
+            LEFT JOIN borrowers     AS U3 ON lastmodificationby=U3.borrowernumber
             LEFT JOIN aqbudgets     AS BU ON budgetid=BU.budget_id
         WHERE 1=1
     }
index 124c583..a7126a5 100644 (file)
@@ -3015,6 +3015,8 @@ CREATE TABLE `suggestions` ( -- purchase suggestions
    accepteddate date default NULL, -- date the suggestion was marked as accepted
    rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table
    rejecteddate date default NULL, -- date the suggestion was marked as rejected
+   lastmodificationby INT(11) default NULL, -- borrowernumber for the librarian who edit the suggestion for the last time
+   lastmodificationdate date default NULL, -- date of the last modification
   `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)
   `note` LONGTEXT, -- note entered on the suggestion
   `author` varchar(80) default NULL, -- author of the suggested item
@@ -3050,6 +3052,7 @@ CREATE TABLE `suggestions` ( -- purchase suggestions
   CONSTRAINT `suggestions_ibfk_managedby` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `suggestions_ibfk_acceptedby` FOREIGN KEY (`acceptedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `suggestions_ibfk_rejectedby` FOREIGN KEY (`rejectedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
+  CONSTRAINT `suggestions_ibfk_lastmodificationby` FOREIGN KEY (`lastmodificationby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `suggestions_ibfk_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `suggestions_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
index ec3798e..f758e1c 100644 (file)
                     [% END %]
                 </td>
             </tr>
+            <tr>
+                <th>Last modification on:</th>
+                <td>[% 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>
+                        [% Branches.GetName( lastmodificationby_patron.branchcode ) | html %] ([% lastmodificationby_patron.category.description | html %])
+                    [% END %]
+                </td>
+            </tr>
             </tbody>
         </table></li></ol>
     </fieldset>
                 <td><input type="text" id="accepteddate" name="accepteddate" class="datepicker" size="10" maxlength="10" value="[% accepteddate | $KohaDates %]" />[% 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 %] ([% suggestedby_patron.cardnumber | html %])</a> [% Branches.GetName( acceptedby_patron.branchcode ) | html %] ([% acceptedby_patron.category.description | html %])[% END %]</td>
             </tr>
+            <tr>
+                <th><label for="lastmodificationdate">Last modification on:</label> </th>
+                <td>[% lastmodificationdate | $KohaDates %]</td>
+                <td>[% INCLUDE 'patron-title.inc' patron=lastmodificationby_patron hide_patron_infos_if_needed=1 %] [% Branches.GetName( lastmodificationby_patron.branchcode ) | html %] ([% lastmodificationby_patron.category.description | html %])</td>
+            </tr>
             </tbody>
         </table></li>
 
                 <th>Suggested on</th>
                 <th>Managed by</th>
                 <th>Managed on</th>
+                <th>Last modification by</th>
+                <th>Last modification on</th>
                 <th>Library</th>
                 <th>Fund</th>
                 <th>Status</th>
                     [% IF ( suggestions_loo.manageddate ) %][% suggestions_loo.manageddate | $KohaDates %][% END %]
                 </td>
                 <td>
+                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestions_loo.lastmodificationby | uri %]">[% suggestions_loo.surnamelastmodificationby | html %][% IF ( suggestions_loo.firstnamelastmodificationby ) %], [% suggestions_loo.firstnamelastmodificationby | html %][% END %]</a>
+                </td>
+                <td data-order="[% suggestions_loo.lastmodificationdate | html %]">
+                    [% IF ( suggestions_loo.lastmodificationdate ) %] - [% suggestions_loo.lastmodificationdate | $KohaDates %][% END %]
+                </td>
+                <td>
                     [% Branches.GetName( suggestions_loo.branchcode ) | html %]
                 </td>
                 <td>
index 1dad30a..9f2e93e 100755 (executable)
@@ -165,6 +165,9 @@ if ( $op =~ /save/i ) {
 
         if ( $suggestion_only->{'suggestionid'} > 0 ) {
 
+            $suggestion_only->{lastmodificationdate} = dt_from_string;
+            $suggestion_only->{lastmodificationby}   = C4::Context->userenv->{number};
+
             &ModSuggestion($suggestion_only);
 
             if ( $notify ) {
@@ -371,7 +374,7 @@ if ($op=~/else/) {
 
 $template->param(
     "${_}_patron" => scalar Koha::Patrons->find( $suggestion_ref->{$_} ) )
-  for qw(managedby suggestedby acceptedby);
+  for qw(managedby suggestedby acceptedby lastmodificationby);
 
 $template->param(
     %$suggestion_ref,