From 53093824677662206a05787553fd9fe07897f57f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 13 Dec 2013 12:41:54 -0500 Subject: [PATCH] Bug 9303 [3] - relative's checkouts in the opac Signed-off-by: Joel Sasse Signed-off-by: Heather Braum --- C4/Members.pm | 26 ---------- C4/Reserves.pm | 14 +++++- .../prog/en/modules/members/memberentrygen.tt | 13 +++++ .../opac-tmpl/bootstrap/en/modules/opac-privacy.tt | 18 ++++++- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 50 +++++++++++++++++++- .../opac-tmpl/prog/en/modules/opac-privacy.tt | 21 +++++++- koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt | 50 +++++++++++++++++++- opac/opac-privacy.pl | 38 +++++++++------ opac/opac-user.pl | 27 +++++++---- 9 files changed, 201 insertions(+), 56 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index f832495..0b84213 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -109,7 +109,6 @@ BEGIN { push @EXPORT, qw( &ModMember &changepassword - &ModPrivacy ); #Delete data @@ -2169,31 +2168,6 @@ sub GetBorrowersNamesAndLatestIssue { return $results; } -=head2 ModPrivacy - -=over 4 - -my $success = ModPrivacy( $borrowernumber, $privacy ); - -Update the privacy of a patron. - -return : -true on success, false on failure - -=back - -=cut - -sub ModPrivacy { - my $borrowernumber = shift; - my $privacy = shift; - return unless defined $borrowernumber; - return unless $borrowernumber =~ /^\d+$/; - - return ModMember( borrowernumber => $borrowernumber, - privacy => $privacy ); -} - =head2 AddMessage AddMessage( $borrowernumber, $message_type, $message, $branchcode ); diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d399ee0..feeb4a3 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -260,10 +260,22 @@ 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 ); - return $sth->fetchrow_hashref(); + my $res = $sth->fetchrow_hashref(); + + unless ($res) { + $query = "SELECT * FROM old_reserves WHERE reserve_id = ?"; + $sth = $dbh->prepare($query); + $sth->execute($reserve_id); + $res = $sth->fetchrow_hashref(); + } + + carp("No hold for for reserve_id $reserve_id") unless $res; + + return $res; } =head2 GetReservesFromBiblionumber 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 430543e..414b552 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1170,6 +1170,19 @@ [% END %] [% IF ( mandatorypassword ) %]Required[% END %][% IF ( ERROR_password_mismatch ) %]Passwords do not match[% END %] +
  • + + +
    Allow linked patron accounts to view this patron's checkouts from the OPAC
    +
  • [% END # hide fieldset %][% 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 bc731cd..7c894d5 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 @@
    -
    +
    -
    + +
    + + +
    + +

    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 50c66c1..378d35f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE KohaDates %] +[% USE EncodeUTF8 %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home @@ -104,6 +105,7 @@
    [% END # waiting_count && atdestination %] + [% IF relatives %] +
    + + + + + + + + + + + + + [% FOREACH r IN relatives %] + [% FOREACH i IN r.issues %] + + + + + + + + + + + + [% END %] + [% END %] + +
    TitleDueBarcodeCall No.Relative
    + + [% i.item.biblio.title | $EncodeUTF8 %] + + + [% i.date_due | $KohaDates %] + + [% i.item.barcode %] + + [% i.item.itemcallnumber | $EncodeUTF8 %] + + [% r.firstname | $EncodeUTF8 %] [% r.surname | $EncodeUTF8 %] +
    +
    + [% END %] [% IF ( overdues_count ) %]
    @@ -681,7 +728,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/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt index 1106973..632c9c7 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt @@ -35,7 +35,8 @@
    - + + - + +

    + + + + +

    + +

    Immediate deletion

    diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt index c3a4fe1..a159ecb 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE KohaDates %] +[% USE EncodeUTF8 %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home [% INCLUDE 'doc-head-close.inc' %] @@ -15,7 +16,7 @@ var MSG_CONFIRM_RESUME_HOLDS = _("Are you sure you want to resume all suspended $('#opac-user-views').tabs(); - 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, { @@ -146,6 +147,7 @@ var MSG_CONFIRM_RESUME_HOLDS = _("Are you sure you want to resume all suspended
    • Checked out
    • + [% IF relatives %]
    • Relatives' checkouts
    • [% END %] [% IF ( overdues_count ) %]
    • Overdue
    • [% END %] [% IF ( OPACFinesTab ) %] [% IF ( BORROWER_INF.amountoverfive ) %]
    • Fines
    • [% END %] @@ -325,6 +327,52 @@ var MSG_CONFIRM_RESUME_HOLDS = _("Are you sure you want to resume all suspended [% END %] [% END %] + [% IF relatives %] +
      + + + + + + + + + + + + + [% FOREACH r IN relatives %] + [% FOREACH i IN r.issues %] + + + + + + + + + + + + [% END %] + [% END %] + +
      TitleDueBarcodeCall No.Relative
      + + [% i.item.biblio.title | $EncodeUTF8 %] + + + [% i.date_due | $KohaDates %] + + [% i.item.barcode %] + + [% i.item.itemcallnumber | $EncodeUTF8 %] + + [% r.firstname | $EncodeUTF8 %] [% r.surname | $EncodeUTF8 %] +
      +
      + [% END %] + [% IF ( overdues_count ) %]
      diff --git a/opac/opac-privacy.pl b/opac/opac-privacy.pl index 22fe694..c41e394 100755 --- a/opac/opac-privacy.pl +++ b/opac/opac-privacy.pl @@ -40,18 +40,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_relative_checkouts = $query->param("privacy_relative_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_relative_checkouts => $privacy_relative_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 ); @@ -60,14 +67,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 ea363b1..58c2a62 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -35,6 +35,7 @@ use C4::Items; use C4::Letters; use C4::Branch; # GetBranches use Koha::DateUtils; +use Koha::Database; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -371,18 +372,26 @@ if ( $borr->{'opacnote'} ) { ); } +my @borrowernumbers = GetMemberRelatives($borrowernumber); +if ( @borrowernumbers ) { + my @relatives = Koha::Database->new()->schema()->resultset("Borrower")->search( + { privacy_relative_checkouts => 1, 'me.borrowernumber' => { -in => \@borrowernumbers, } }, + { 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
      Overdues ([% overdues_count %] total)