From f4f0dc9aa213aee337ed8777d58740c7e8461627 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 --- C4/Members.pm | 1 - C4/Reserves.pm | 1 + Koha/Template/Plugin/Koha.pm | 1 + .../prog/en/modules/admin/preferences/opac.pref | 7 +++ .../prog/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 | 43 ++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-privacy.tt | 24 ++++++++- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 53 ++++++++++++++++++- members/moremember.pl | 1 + opac/opac-privacy.pl | 38 +++++++++----- opac/opac-user.pl | 32 +++++++++--- 13 files changed, 204 insertions(+), 29 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 3a99446..1c7d803 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -114,7 +114,6 @@ BEGIN { push @EXPORT, qw( &ModMember &changepassword - &ModPrivacy ); #Delete data diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 5874260..373f55c 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -268,6 +268,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/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm index 7d562e7..b741bfa 100644 --- a/Koha/Template/Plugin/Koha.pm +++ b/Koha/Template/Plugin/Koha.pm @@ -23,6 +23,7 @@ use Encode qw( encode ); use base qw( Template::Plugin ); use C4::Context; +use Koha::Database; =pod 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 c26d048..99cea1a 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 @@ -582,6 +582,13 @@ OPAC: 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 class: integer 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 ee908d2..a69c3fa 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 @@ -128,6 +128,12 @@ Patrons: 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 - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')." 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 330058f..1489f4a 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' %] @@ -465,6 +466,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 9fc1482..b38cf7c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -358,6 +358,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 566658e..b2b6311 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -54,6 +54,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') %] @@ -796,6 +823,22 @@ [% ELSE %] $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" }); [% END %] + + [% 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 7686000..6fc0c31 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt @@ -48,7 +48,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 85c985d..aa237fd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -104,6 +104,7 @@
    [% END # waiting_count && atdestination %] + [% 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 ) %]
    @@ -377,7 +423,7 @@ Title [% UNLESS ( item_level_itypes ) %]Item type [% END %] [% IF ( show_barcode ) %]Barcode[% END %] - Call no. + Call number Due [% IF ( OpacRenewalAllowed ) %] Renew @@ -692,7 +738,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 3a54ec9..5a360ac 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -355,6 +355,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 0f2c6c8..b697011 100755 --- a/opac/opac-privacy.pl +++ b/opac/opac-privacy.pl @@ -47,18 +47,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,14 +74,17 @@ if ($op eq "delete_record") { $template->param( 'err_history_not_deleted' => 1 ); } } + # get borrower privacy .... -my ( $borr ) = GetMemberDetails( $borrowernumber ); +my $borrower = GetMemberDetails( $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; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 18dfec6..29c4b03 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -36,6 +36,7 @@ use C4::Letters; use C4::Branch; # GetBranches use Koha::DateUtils; use Koha::Borrower::Debarments qw(IsDebarred); +use Koha::Database; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -383,18 +384,31 @@ 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( - bor_messages_loop => GetMessages( $borrowernumber, 'B', 'NONE' ), + borrower => $borr, + bor_messages_loop => GetMessages( $borrowernumber, 'B', 'NONE' ), waiting_count => $wcount, - patronupdate => $patronupdate, + patronupdate => $patronupdate, OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), - userview => 1, -); - -$template->param( - SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), - AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), - OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), + userview => 1, + SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), + OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), + AutoResumeSuspendedHolds => + C4::Context->preference('AutoResumeSuspendedHolds'), ); output_html_with_http_headers $query, $cookie, $template->output; -- 1.7.2.5