Bug 14233: Add logging support to notices and slips management
This enhancements adds support for logging changes to notices and slips. Features include: - a system preference (NoticesLog) which allows you to enable logging changes for notices and slips - logging new notices, changes to notices, and deletion of notices - filtering in the log viewer so you can show all changes for a specific notice - a comparison feature, so you can see what changes were made to a notice. Test plan: 1/ Add some 'Notice' action logs by adding a new notice or updateing an existing notice 2/ Go to the 'Log viewer' under 'Tools' 3/ Note you can filter by 'Notices' 4/ Confirm the changes you made appear in the logs and that the 'Object' field links back to the updated notice ready for editing. 1/ Make some changes to at least two different notices to trigger logs 2/ Go to the 'Log viewer' from 'Tools' and filter on 'Notices' 3/ Note, you can now see the 'Compare' checkbox option for these logs 4/ Select the checkbox on one of the notices and note that the results are now filtered by that specific notice. 5/ Select a second checkbox to expose the option to 'View comparison' 6/ Click 'View comparison' to see the 'Diff view' of the two notices. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
00ec2839ce
commit
058884ed4f
|
|
@ -96,6 +96,7 @@
|
|||
|
||||
[% CASE 'SEARCHENGINE' %]Search engine
|
||||
|
||||
[% CASE 'NOTICES' %]Notices[% UNLESS Koha.Preference('NoticesLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
|
||||
[% CASE %][% module | html %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
|
@ -190,7 +191,7 @@
|
|||
[% ELSE %]
|
||||
<label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value=""> All</label>
|
||||
[% END %]
|
||||
[% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE' ] %]
|
||||
[% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES' ] %]
|
||||
[% IF modules.grep(modx).size %]
|
||||
<label for="module[% modx | html %]" class="viewlog"><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked"> [% PROCESS translate_log_module module=modx %]</label>
|
||||
[% ELSE %]
|
||||
|
|
@ -324,27 +325,27 @@
|
|||
[% ELSE %]
|
||||
[% loopro.object | html %]
|
||||
[% END %]
|
||||
[% ELSIF ( loopro.module == 'CATALOGUING' ) %]
|
||||
[% IF ( loopro.info.substr(0, 4) == 'item' ) %]
|
||||
<a href="/cgi-bin/koha/catalogue/moredetail.pl?item=[% loopro.object | uri %]&biblionumber=[% loopro.biblionumber | uri %]&bi=[% loopro.biblioitemnumber | uri %]#item[% loopro.object | uri %]">Item [% loopro.object | html %]</a> from
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loopro.biblionumber | uri %]" title="Display detail for this biblio">Biblio [% loopro.biblionumber | html %]</a>
|
||||
[% ELSIF ( loopro.info.substr(0, 6) == 'biblio' ) %]
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loopro.object | uri %]" title="Display detail for this biblio">Biblio [% loopro.object | html %]</a>
|
||||
[% ELSE %]
|
||||
[% loopro.object | html %]
|
||||
[% END %]
|
||||
[% ELSIF ( loopro.module == 'SERIAL' ) %]
|
||||
<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% loopro.object | uri %]">Subscription [% loopro.object | html %] </a>
|
||||
[% ELSIF ( loopro.module == 'AUTHORITIES' ) %]
|
||||
<a href="/cgi-bin/koha/authorities/detail.pl?authid=[% loopro.object | uri %]" title="Display detail for this authority">Authority [% loopro.object | html %]</a>
|
||||
[% ELSIF ( loopro.module == 'NOTICES' ) %]
|
||||
[% IF ( loopro.notice ) %]
|
||||
<a href="/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=[% loopro.notice.branchcode | uri %]&module=[% loopro.notice.module | uri %]&code=[% loopro.notice.code | uri %]&lang=[% loopro.notice.lang | uri %]">Notice [% loopro.notice.title | html %] ([% loopro.notice.code | html %])</a>
|
||||
[% ELSE %]
|
||||
[% loopro.object | html %]
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
[% IF ( loopro.module == 'CATALOGUING' ) %]
|
||||
[% IF ( loopro.info.substr(0, 4) == 'item' ) %]
|
||||
<a href="/cgi-bin/koha/catalogue/moredetail.pl?item=[% loopro.object | uri %]&biblionumber=[% loopro.biblionumber | uri %]&bi=[% loopro.biblioitemnumber | uri %]#item[% loopro.object | uri %]">Item [% loopro.object | html %]</a> from
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loopro.biblionumber | uri %]" title="Display detail for this biblio">Biblio [% loopro.biblionumber | html %]</a>
|
||||
[% ELSIF ( loopro.info.substr(0, 6) == 'biblio' ) %]
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loopro.object | uri %]" title="Display detail for this biblio">Biblio [% loopro.object | html %]</a>
|
||||
[% ELSE %]
|
||||
[% loopro.object | html %]
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
[% IF ( loopro.module == 'SERIAL' ) %]
|
||||
<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% loopro.object | uri %]">Subscription [% loopro.object | html %] </a>
|
||||
[% ELSE %]
|
||||
[% IF ( loopro.module == 'AUTHORITIES' ) %]
|
||||
<a href="/cgi-bin/koha/authorities/detail.pl?authid=[% loopro.object | uri %]" title="Display detail for this authority">Authority [% loopro.object | html %]</a>
|
||||
[% ELSE %]
|
||||
[% loopro.object | html %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% loopro.object | html %]
|
||||
[% END %]
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -356,6 +357,11 @@
|
|||
<div class="compare_info" id="compare_info[% loopro.action_id | html %]">
|
||||
<label><input type="checkbox" name="diff" id="action_id[% loopro.action_id | html %]" data-actionid="[% loopro.action_id | html %]" data-filter="[% FOREACH info IN loopro.info.split(' \| ') %][% IF loop.first %][% info | html %][% END %][% END %]" class="compare" /> Compare</label>
|
||||
</div>
|
||||
[% ELSIF loopro.module == "NOTICES" %]
|
||||
<div class="loginfo" id="loginfo[% loopro.action_id | html %]">[% loopro.info | trim | html %]</div>
|
||||
<div class="compare_info" id="compare_info[% loopro.action_id | html %]">
|
||||
<label><input type="checkbox" name="diff" id="action_id[% loopro.action_id | html %]" data-actionid="[% loopro.action_id | html %]" data-filter="[% IF loopro.notice %][% loopro.notice.title | html %][% ELSE %][% loopro.object | html %][% END %]" class="compare" /> Compare</label>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<div class="loginfo" id="loginfo[% loopro.action_id | html %]">
|
||||
[% loopro.info | html %]
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ use C4::Auth;
|
|||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Letters;
|
||||
use C4::Log;
|
||||
|
||||
use Koha::Patron::Attribute::Types;
|
||||
|
||||
|
|
@ -315,6 +316,10 @@ sub add_validate {
|
|||
next;
|
||||
}
|
||||
elsif ( $letter and $letter->{message_transport_type} eq $mtt and $letter->{lang} eq $lang ) {
|
||||
logaction( 'NOTICES', 'MODIFY', $letter->{id}, $content,
|
||||
'Intranet' )
|
||||
if ( C4::Context->preference("NoticesLog")
|
||||
&& $content ne $letter->{content} );
|
||||
$dbh->do(
|
||||
q{
|
||||
UPDATE letter
|
||||
|
|
@ -326,11 +331,22 @@ sub add_validate {
|
|||
$branchcode, $oldmodule, $code, $mtt, $lang
|
||||
);
|
||||
} else {
|
||||
$dbh->do(
|
||||
q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type, lang) VALUES (?,?,?,?,?,?,?,?,?)},
|
||||
undef,
|
||||
$branchcode || '', $module, $code, $name, $is_html || 0, $title, $content, $mtt, $lang
|
||||
);
|
||||
my $letter = Koha::Notice::Template->new(
|
||||
{
|
||||
branchcode => $branchcode,
|
||||
module => $module,
|
||||
code => $code,
|
||||
name => $name,
|
||||
is_html => $is_html,
|
||||
title => $title,
|
||||
content => $content,
|
||||
message_transport_type => $mtt,
|
||||
lang => $lang
|
||||
}
|
||||
)->store;
|
||||
logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content,
|
||||
'Intranet' )
|
||||
if C4::Context->preference("NoticesLog");
|
||||
}
|
||||
}
|
||||
# set up default display
|
||||
|
|
@ -350,16 +366,23 @@ sub delete_confirm {
|
|||
}
|
||||
|
||||
sub delete_confirmed {
|
||||
my ($branchcode, $module, $code, $mtt, $lang) = @_;
|
||||
C4::Letters::DelLetter(
|
||||
my ( $branchcode, $module, $code, $mtt, $lang ) = @_;
|
||||
my $letters = Koha::Notice::Templates->search(
|
||||
{
|
||||
branchcode => $branchcode || '',
|
||||
module => $module,
|
||||
code => $code,
|
||||
mtt => $mtt,
|
||||
lang => $lang,
|
||||
( $mtt ? ( message_transport_type => $mtt ) : () ),
|
||||
( $lang ? ( lang => $lang ) : () ),
|
||||
}
|
||||
);
|
||||
while ( my $letter = $letters->next ) {
|
||||
logaction( 'NOTICES', 'DELETE', $letter->id, $letter->content,
|
||||
'Intranet' )
|
||||
if C4::Context->preference("NoticesLog");
|
||||
$letter->delete;
|
||||
}
|
||||
|
||||
# setup default display for screen
|
||||
default_display($branchcode);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -186,6 +186,16 @@ if ($do_it) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $log->module eq 'NOTICES' ) {
|
||||
if ( $log->object ) {
|
||||
my $notice = Koha::Notice::Templates->find( { id => $log->object } );
|
||||
if ($notice && $output eq 'screen') {
|
||||
$result->{notice} = $notice->unblessed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
push @data, $result;
|
||||
}
|
||||
if ( $output eq "screen" ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue