Bug 29526: Add a way for patrons to delete their hold history
The same way we have a button to immediately delete the checkouts history in the OPAC, we should have a similar option for the holds history. This patch implements that. To test: 1. Have a patron with some old checkouts and old holds. 2. Have OPACPrivacy, OPACHoldsHistory and opacreadinghistory enabled. 3. Notice in the OPAC the patron has some old checkouts and holds. 4. Use the Privacy tab to clean checkouts => SUCCESS: They are still cleaned as before this patch 5. Try to clean the old holds => SUCCESS: They are cleaned! 6. Add some old checkouts and holds 7. Use the new 'All' button => SUCCESS: All cleaned 8. Sign off :-D Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
4c2f4a302e
commit
7f13f49ff9
2 changed files with 90 additions and 33 deletions
|
@ -37,12 +37,26 @@
|
|||
<div id="userprivacy" class="maincontent">
|
||||
<h1>Your privacy management</h1>
|
||||
|
||||
[% IF deleted %]
|
||||
<div class="alert alert-success">Your checkout history has been deleted.</div>
|
||||
[% ELSIF history_not_deleted %]
|
||||
<div class="alert alert-warning">The deletion of your checkout history failed, because there is a problem with the configuration of this feature. Please help to fix the system by informing your library of this error</div>
|
||||
[% ELSIF nothing_to_delete %]
|
||||
<div class="alert alert-warning">No checkout history to delete</div>
|
||||
[% IF delete_all_requested || delete_checkouts_requested || delete_holds_requested %]
|
||||
[% IF delete_all_requested || delete_checkouts_requested %]
|
||||
[% IF deleted_checkouts %]
|
||||
<div class="alert alert-success">Your checkout history has been deleted.</div>
|
||||
[% ELSIF error_deleting_checkouts_history %]
|
||||
<div class="alert alert-warning">The deletion of your checkout history failed, because there is a problem with the configuration of this feature. Please help to fix the system by informing your library of this error</div>
|
||||
[% ELSIF no_checkouts_to_delete %]
|
||||
<div class="alert alert-warning">No checkout history to delete</div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF delete_all_requested || delete_holds_requested %]
|
||||
[% IF deleted_holds %]
|
||||
<div class="alert alert-success">Your hold history has been deleted.</div>
|
||||
[% ELSIF error_deleting_holds_history %]
|
||||
<div class="alert alert-warning">The deletion of your hold history failed. Please help to fix the system by informing your library of this error</div>
|
||||
[% ELSIF no_holds_to_delete %]
|
||||
<div class="alert alert-warning">No hold history to delete</div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF ( privacy_updated ) %]
|
||||
|
@ -140,12 +154,32 @@
|
|||
|
||||
<h2>Immediate deletion</h2>
|
||||
|
||||
<p>Whatever your privacy rule you choose, you can delete all your checkout and hold history immediately by clicking here. <strong>BE CAREFUL</strong>. Once you've confirmed the deletion, no one can retrieve the list!</p>
|
||||
|
||||
<form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
|
||||
<legend class="sr-only">Immediate deletion</legend>
|
||||
<legend class="sr-only">Checkout history deletion</legend>
|
||||
<input type="hidden" name="op" value="delete_record" />
|
||||
<p>Whatever your privacy rule you choose, you can delete all your checkout history immediately by clicking here. <strong>BE CAREFUL</strong>. Once you've confirmed the deletion, no one can retrieve the list!</p>
|
||||
<input type="hidden" name="checkouts" value="1" />
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Immediate deletion" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
|
||||
<input type="submit" value="Checkout history" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
|
||||
<legend class="sr-only">Hold history deletion</legend>
|
||||
<input type="hidden" name="op" value="delete_record" />
|
||||
<input type="hidden" name="holds" value="1" />
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Hold history" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
|
||||
<legend class="sr-only">Checkout and hold history deletion</legend>
|
||||
<input type="hidden" name="op" value="delete_record" />
|
||||
<input type="hidden" name="all" value="1" />
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Checkout and hold history" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ if ( ! C4::Context->preference('OPACPrivacy') || ! C4::Context->preference('opac
|
|||
exit;
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "opac-privacy.tt",
|
||||
|
@ -42,13 +40,14 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
}
|
||||
);
|
||||
|
||||
my $patron = Koha::Patrons->find( $borrowernumber );
|
||||
|
||||
my $op = $query->param("op");
|
||||
my $privacy = $query->param("privacy");
|
||||
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
|
||||
my $privacy_guarantor_fines = $query->param("privacy_guarantor_fines");
|
||||
|
||||
if ( $op eq "update_privacy" ) {
|
||||
my $patron = Koha::Patrons->find( $borrowernumber );
|
||||
if ( $patron ) {
|
||||
$patron->set({
|
||||
privacy => $privacy,
|
||||
|
@ -60,30 +59,54 @@ if ( $op eq "update_privacy" ) {
|
|||
}
|
||||
elsif ( $op eq "delete_record" ) {
|
||||
|
||||
# delete all reading records for items returned
|
||||
my $rows = eval {
|
||||
Koha::Patrons->search({ 'me.borrowernumber' => $borrowernumber })->anonymise_issue_history;
|
||||
};
|
||||
$template->param(
|
||||
(
|
||||
$@ ? ( history_not_deleted => 1 )
|
||||
: $rows ? ( deleted => int($rows) )
|
||||
: ( nothing_to_delete => 1 )
|
||||
)
|
||||
);
|
||||
my $holds = $query->param('holds');
|
||||
my $checkouts = $query->param('checkouts');
|
||||
my $all = $query->param('all');
|
||||
|
||||
$template->param( delete_all_quested => 1 )
|
||||
if $all;
|
||||
|
||||
if ( $all or $checkouts ) {
|
||||
|
||||
# delete all reading records for items returned
|
||||
my $rows = eval {
|
||||
Koha::Patrons->search( { 'me.borrowernumber' => $borrowernumber } )
|
||||
->anonymise_issue_history;
|
||||
};
|
||||
|
||||
$template->param(
|
||||
(
|
||||
$@ ? ( error_deleting_checkouts_history => 1 )
|
||||
: $rows ? ( deleted_checkouts => int($rows) )
|
||||
: ( no_checkouts_to_delete => 1 )
|
||||
),
|
||||
delete_checkouts_requested => 1,
|
||||
);
|
||||
}
|
||||
|
||||
if ( $all or $holds ) {
|
||||
|
||||
my $rows = eval { $patron->old_holds->anonymize + 0 };
|
||||
|
||||
$template->param(
|
||||
(
|
||||
$@ ? ( error_deleting_holds_history => 1 )
|
||||
: $rows ? ( deleted_holds => int($rows) )
|
||||
: ( no_holds_to_delete => 1 )
|
||||
),
|
||||
delete_holds_requested => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# get borrower privacy ....
|
||||
my $borrower = Koha::Patrons->find( $borrowernumber );;
|
||||
|
||||
$template->param(
|
||||
'Ask_data' => 1,
|
||||
'privacy' . $borrower->privacy() => 1,
|
||||
'privacyview' => 1,
|
||||
'borrower' => $borrower,
|
||||
'surname' => $borrower->surname,
|
||||
'firstname' => $borrower->firstname,
|
||||
'has_guarantor_flag' => $borrower->guarantor_relationships->guarantors->_resultset->count
|
||||
'Ask_data' => 1,
|
||||
'privacy' . $patron->privacy() => 1,
|
||||
'privacyview' => 1,
|
||||
'borrower' => $patron,
|
||||
'surname' => $patron->surname,
|
||||
'firstname' => $patron->firstname,
|
||||
'has_guarantor_flag' => $patron->guarantor_relationships->guarantors->_resultset->count
|
||||
);
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
|
||||
|
|
Loading…
Reference in a new issue