diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm
index 14c6b203c1..fae1c650a3 100644
--- a/C4/Suggestions.pm
+++ b/C4/Suggestions.pm
@@ -27,6 +27,7 @@ use C4::Letters;
use C4::Biblio qw( GetMarcFromKohaField );
use Koha::DateUtils qw( dt_from_string );
use Koha::Suggestions;
+use C4::Log qw(logaction);
use base qw(Exporter);
@@ -290,6 +291,9 @@ sub ModSuggestion {
) or warn "can't enqueue letter $letter";
}
}
+ if (C4::Context->preference("SuggestionsLog")) {
+ logaction('SUGGESTION', 'MODIFY', $suggestion->{suggestionid}, $suggestion_object );
+ }
return 1; # No useful if the exception is raised earlier
}
@@ -343,6 +347,9 @@ sub DelSuggestion {
};
$sth = $dbh->prepare($queryDelete);
my $suggestiondeleted = $sth->execute($suggestionid);
+ if (C4::Context->preference("SuggestionsLog")) {
+ logaction('SUGGESTION', 'DELETE', $suggestionid, '' );
+ }
return $suggestiondeleted;
}
}
diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm
index b14c1123ca..a6dd307671 100644
--- a/Koha/Suggestion.pm
+++ b/Koha/Suggestion.pm
@@ -28,6 +28,7 @@ use Koha::DateUtils qw( dt_from_string );
use Koha::Patrons;
use Koha::AuthorisedValues;
use Koha::Exceptions::Suggestion;
+use C4::Log qw(logaction);
use base qw(Koha::Object);
@@ -111,7 +112,9 @@ sub store {
) or warn "can't enqueue letter $letter";
}
}
-
+ if (C4::Context->preference("NewsLog")) {
+ logaction('SUGGESTION', 'CREATE', $result->suggestionid, '' );
+ }
return $result;
}
diff --git a/installer/data/mysql/atomicupdate/bug_35597.pl b/installer/data/mysql/atomicupdate/bug_35597.pl
new file mode 100755
index 0000000000..3101b2fcc8
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_35597.pl
@@ -0,0 +1,19 @@
+use Modern::Perl;
+
+return {
+ bug_number => "35597",
+ description => "Add SuggestionsLog system preference ",
+ up => sub {
+ my ($args) = @_;
+ my ( $dbh, $out ) = @$args{qw(dbh out)};
+
+ # sysprefs
+ $dbh->do(
+ q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
+ VALUES ('SuggestionsLog', '0', 'If enabled, log purchase suggestion changes', '' , 'YesNo')
+ }
+ );
+ say $out "Added new system preference 'SuggestionsLog'";
+ },
+};
diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
index d6a450e514..df70c69def 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -755,6 +755,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('SubscriptionLog','1',NULL,'If ON, enables subscriptions log','YesNo'),
('suggestion','1','','If ON, enables patron suggestions feature in OPAC','YesNo'),
('suggestionPatronCategoryExceptions', '', '', 'List the patron categories not affected by suggestion system preference if on', 'Free'),
+('SuggestionsLog','0',NULL,'If ON, log pirchase suggestion changes','YesNo'),
('SuspendHoldsIntranet','1','Allow holds to be suspended from the intranet.',NULL,'YesNo'),
('SuspendHoldsOpac','1','Allow holds to be suspended from the OPAC.',NULL,'YesNo'),
('SuspensionsCalendar','noSuspensionsWhenClosed','ignoreCalendar|noSuspensionsWhenClosed','Specify whether to use the Calendar in calculating suspension expiration','Choice'),
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref
index f947270dde..985089a9ac 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref
@@ -114,6 +114,12 @@ Logging:
1: Log
0: "Don't log"
- any actions on recalls (create, cancel, expire, fulfill).
+ -
+ - pref: SuggestionsLog
+ choices:
+ 1: Log
+ 0: "Don't log"
+ - any changes to purchase suggestions (create, modify, delete ).
Debugging:
-
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
index 7c10c55b65..10b65cfdb3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
@@ -101,6 +101,7 @@
[% CASE 'NOTICES' %]Notices[% UNLESS Koha.Preference('NoticesLog') %] [% END %]
[% CASE 'NEWS' %]News[% UNLESS Koha.Preference('NewsLog') %] [% END %]
[% CASE 'RECALLS' %]Recalls[% UNLESS Koha.Preference('RecallsLog') %] [% END %]
+[% CASE 'SUGGESTION' %]Suggestions[% UNLESS Koha.Preference('SuggestionsLog') %] [% END %]
[% CASE %][% module | html %]
[% END %]
@@ -221,7 +222,7 @@
[% ELSE %]
[% END %]
- [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS' ] %]
+ [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'SUGGESTION' ] %]
[% IF modules.grep(modx).size %]
[% ELSE %]
@@ -387,6 +388,8 @@
[% ELSE %]
Basket [% loopro.object | html %]
[% END %]
+ [% ELSIF ( loopro.module == "SUGGESTION" ) %]
+ [% loopro.object | html %]
[% ELSE %]
[% loopro.object | html %]
[% END %]