From 3ebf343af674269e924169625c5e8447215ae3fe Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 2 Mar 2015 03:09:38 -0800 Subject: [PATCH] Bug 9303 [3] - relative's checkouts in the opac Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Members.pm | 1 - C4/Reserves.pm | 1 + .../en/modules/admin/preferences/opac.pref | 7 +++ .../en/modules/admin/preferences/patrons.pref | 6 +++ .../prog/en/modules/members/memberentrygen.tt | 16 ++++++ .../prog/en/modules/members/moremember.tt | 10 ++++ .../bootstrap/en/modules/opac-memberentry.tt | 44 +++++++++++++++ .../bootstrap/en/modules/opac-privacy.tt | 24 ++++++++- .../bootstrap/en/modules/opac-user.tt | 54 +++++++++++++++++-- members/moremember.pl | 1 + opac/opac-privacy.pl | 37 ++++++++----- opac/opac-user.pl | 16 ++++++ 12 files changed, 197 insertions(+), 20 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index fafa02f97e..4ba1f1934c 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -115,7 +115,6 @@ BEGIN { push @EXPORT, qw( &ModMember &changepassword - &ModPrivacy ); #Delete data diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 529623a8e0..cde9c0a0b6 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -261,6 +261,7 @@ sub GetReserve { my ($reserve_id) = @_; my $dbh = C4::Context->dbh; + my $query = "SELECT * FROM reserves WHERE reserve_id = ?"; my $sth = $dbh->prepare( $query ); $sth->execute( $reserve_id ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 17d0b1a15b..252e884d72 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -588,6 +588,13 @@ OPAC: yes: Allow no: "Don't allow" - patrons to choose their own privacy settings for their reading history. This requires opacreadinghistory and AnonymousPatron + - + - pref: AllowPatronToSetCheckoutsVisibilityForGuarantor + default: 0 + choices: + yes: Allow + no: "Don't allow" + - patrons to choose their own privacy settings for showing the patron's checkouts to the patron's guarantor". - - Use borrowernumber - pref: AnonymousPatron diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 4274dc5d47..ee64970973 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -136,6 +136,12 @@ Patrons: yes: Do no: "Don't" - enable the ability to upload and attach arbitrary files to a borrower record. + - + - pref: AllowStaffToSetCheckoutsVisibilityForGuarantor + choices: + yes: Allow + no: "Don't allow" + - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC. - - Card numbers for patrons must be - pref: CardnumberLength diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 6b0111964f..de792c3fed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE KohaDates %] +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Koha › Patrons › [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %]) [% INCLUDE 'doc-head-close.inc' %] @@ -490,6 +491,21 @@ [% END %] + [% IF guarantorid && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %] +
  • + + +
    Allow guarantor of this patron to view this patron's checkouts from the OPAC
    +
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 802eeaf196..57bd588907 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -355,6 +355,16 @@ function validate1(date) { [% IF ( privacy1 ) %]Default[% END %] [% IF ( privacy2 ) %]Never[% END %] [% END %] + +
  • + Show checkouts to guarantor + [% IF privacy_guarantor_checkouts %] + Yes + [% ELSE %] + No + [% END %] +
  • + [% IF ( sort1 ) %]
  • Sort field 1:[% lib1 %]
  • [% END %] [% IF ( sort2 ) %]
  • Sort field 2:[% lib2 %]
  • [% END %]
  • Username: [% userid %]
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 6a894ab413..999fe496f9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -70,6 +70,33 @@
    You typed in the wrong characters in the box before submitting. Please try again.
    [% END %] + [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] +
    + Privacy +
      +
    1. + + + + Update + + + + [% SET g = Koha.Find('Borrower',borrower.guarantorid) %] + Your guarantor is [% g.firstname %] [% g.surname %] + +
    2. +
    +
    + [% END %] +
    [% UNLESS hidden.defined('branchcode') %] @@ -822,6 +849,7 @@ [% ELSE %] $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" }); [% END %] + $("#memberentry-form").validate({ rules: { borrower_email: { @@ -853,6 +881,22 @@ error.css('width', 'auto'); } }); + + [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] + $('#update_privacy_guarantor_checkouts').click( function() { + $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json') + .done(function( data ) { + var message; + if ( data.success ) { + message = _("Your setting has been updated!"); + } else { + message = _("Unable to update your setting!"); + } + + $('#update_privacy_guarantor_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow"); + }); + }); + [% END %] }); //]]> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt index 3b265ee010..d1ed47cde0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt @@ -49,7 +49,7 @@
    -
    +
    -
    + + [% SET b = Koha.Find('Borrower', borrower.borrowernumber) %] + [% IF b.guarantorid && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] +
    + + + + Your guarantor is [% b.guarantor.firstname %] [% b.guarantor.surname %] + +
    + [% END %] + +

    Immediate deletion

    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 68a1e87fd0..579a99a60f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -110,6 +110,7 @@
    • Checked out ([% issues_count %])
    • + [% IF relatives %]
    • Relatives' checkouts
    • [% END %] [% IF ( overdues_count ) %]
    • Overdue ([% overdues_count %])
    • [% END %] [% IF ( OPACFinesTab ) %] [% IF ( BORROWER_INF.amountoverfive ) %]
    • Fines ([% BORROWER_INF.amountoutstanding %])
    • [% END %] @@ -137,7 +138,7 @@ [% IF ( show_barcode ) %] Barcode [% END %] - Call No. + Call number [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] Renew [% END %] @@ -332,6 +333,52 @@ [% END %] [% END # / OPACFinesTab %] + [% IF relatives %] +
      + + + + + + + + + + + + + [% FOREACH r IN relatives %] + [% FOREACH i IN r.issues %] + + + + + + + + + + + + [% END %] + [% END %] + +
      TitleDueBarcodeCall numberRelative
      + + [% i.item.biblio.title %] + + + [% i.date_due | $KohaDates %] + + [% i.item.barcode %] + + [% i.item.itemcallnumber %] + + [% r.firstname %] [% r.surname %] +
      +
      + [% END %] + [% IF ( overdues_count ) %]
      @@ -343,7 +390,7 @@ [% UNLESS ( item_level_itypes ) %] [% END %] [% IF ( show_barcode ) %][% END %] - + [% IF ( OpacRenewalAllowed ) %] @@ -671,7 +718,8 @@ $(".js-hide").hide(); $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs"); $(".suspend-until").prop("readonly",1); - var dTables = $("#checkoutst,#holdst,#overduest"); + + var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table"); dTables.each(function(){ var thIndex = $(this).find("th.psort").index(); $(this).dataTable($.extend(true, {}, dataTablesDefaults, { diff --git a/members/moremember.pl b/members/moremember.pl index 6198d87c46..482f2a2305 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -348,6 +348,7 @@ $template->param( is_child => ($category_type eq 'C'), samebranch => $samebranch, quickslip => $quickslip, + privacy_guarantor_checkouts => $data->{'privacy_guarantor_checkouts'}, activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'), diff --git a/opac/opac-privacy.pl b/opac/opac-privacy.pl index 2a98d8f4d6..51fc7cd0bf 100755 --- a/opac/opac-privacy.pl +++ b/opac/opac-privacy.pl @@ -45,18 +45,25 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -my $op = $query->param("op"); -my $privacy = $query->param("privacy"); +my $op = $query->param("op"); +my $privacy = $query->param("privacy"); +my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts"); -if ($op eq "update_privacy") -{ - ModPrivacy($borrowernumber,$privacy); - $template->param('privacy_updated' => 1); +if ( $op eq "update_privacy" ) { + ModMember( + borrowernumber => $borrowernumber, + privacy => $privacy, + privacy_guarantor_checkouts => $privacy_guarantor_checkouts, + ); + $template->param( 'privacy_updated' => 1 ); } -if ($op eq "delete_record") { +elsif ( $op eq "delete_record" ) { + # delete all reading records for items returned # uses a hardcoded date ridiculously far in the future - my ($rows,$err_history_not_deleted) = AnonymiseIssueHistory('2999-12-12',$borrowernumber); + my ( $rows, $err_history_not_deleted ) = + AnonymiseIssueHistory( '2999-12-12', $borrowernumber ); + # confirm the user the deletion has been done if ( !$err_history_not_deleted ) { $template->param( 'deleted' => 1 ); @@ -67,13 +74,15 @@ if ($op eq "delete_record") { } # get borrower privacy .... -my $borr = C4::Members::GetMember( borrowernumber => $borrowernumber ); +my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ); -$template->param( 'Ask_data' => '1', - 'privacy'.$borr->{'privacy'} => 1, - 'firstname' => $borr->{'firstname'}, - 'surname' => $borr->{'surname'}, - 'privacyview' => 1, +$template->param( + 'Ask_data' => 1, + 'privacy' . $borrower->{'privacy'} => 1, + 'privacyview' => 1, + 'borrower' => $borrower, + 'surname' => $borrower->{surname}, + 'firstname' => $borrower->{firstname}, ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 8825b8455d..9d1f9b2dd8 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -37,6 +37,7 @@ use C4::Branch; # GetBranches use Koha::DateUtils; use Koha::Borrower::Debarments qw(IsDebarred); use Koha::Holds; +use Koha::Database; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -317,7 +318,22 @@ if ( $borr->{'opacnote'} ) { ); } +if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') + || C4::Context->preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') ) +{ + my @relatives = + Koha::Database->new()->schema()->resultset("Borrower")->search( + { + privacy_guarantor_checkouts => 1, + 'me.guarantorid' => $borrowernumber + }, + { prefetch => [ { 'issues' => { 'item' => 'biblio' } } ] } + ); + $template->param( relatives => \@relatives ); +} + $template->param( + borrower => $borr, bor_messages_loop => GetMessages( $borrowernumber, 'B', 'NONE' ), patronupdate => $patronupdate, OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), -- 2.39.5
      TitleItem typeBarcodeCall no.Call number DueRenew