Bug 9303 [3] - relative's checkouts in the opac
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 2 Mar 2015 11:09:38 +0000 (03:09 -0800)
committerKyle M Hall <kyle@bywatersolutions.com>
Thu, 31 Dec 2015 13:08:06 +0000 (13:08 +0000)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@quecheelibrary.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
12 files changed:
C4/Members.pm
C4/Reserves.pm
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
members/moremember.pl
opac/opac-privacy.pl
opac/opac-user.pl

index fafa02f..4ba1f19 100644 (file)
@@ -115,7 +115,6 @@ BEGIN {
     push @EXPORT, qw(
         &ModMember
         &changepassword
-         &ModPrivacy
     );
 
     #Delete data
index 529623a..cde9c0a 100644 (file)
@@ -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 );
index 17d0b1a..252e884 100644 (file)
@@ -589,6 +589,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
index 4274dc5..ee64970 100644 (file)
@@ -137,6 +137,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')."
index 6b01119..de792c3 100644 (file)
@@ -1,5 +1,6 @@
 [% USE Koha %]
 [% USE KohaDates %]
+[% USE Koha %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; [% 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 %])</title>
 [% INCLUDE 'doc-head-close.inc' %]
             [% END %]
             <input id="guarantordelete" type="button" value="Delete" />
         </li>
+    [% IF guarantorid && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
+        <li>
+            <label for="privacy_guarantor_checkouts">Show checkouts to guarantor</label>
+            <select name="privacy_guarantor_checkouts" id="privacy_guarantor_checkouts">
+                [% IF privacy_guarantor_checkouts %]
+                    <option value="0">No</option>
+                    <option value="1" selected>Yes</option>
+                [% ELSE %]
+                    <option value="0" selected>No</option>
+                    <option value="1">Yes</option>
+                [% END %]
+            </select>
+            <div class="hint">Allow guarantor of this patron to view this patron's checkouts from the OPAC</div>
+        </li>
+    [% END %]
         </ol>
     </fieldset>
 
index 802eeaf..57bd588 100644 (file)
@@ -355,6 +355,16 @@ function validate1(date) {
          [% IF ( privacy1 ) %]Default[% END %]
          [% IF ( privacy2 ) %]Never[% END %]
     </li>[% END %]
+
+    <li>
+        <span class="label">Show checkouts to guarantor</span>
+        [% IF privacy_guarantor_checkouts %]
+            Yes
+        [% ELSE %]
+            No
+        [% END %]
+    </li>
+
     [% IF ( sort1 ) %]<li><span class="label">Sort field 1:</span>[% lib1 %]</li>[% END %]
     [% IF ( sort2 ) %]<li><span class="label">Sort field 2:</span>[% lib2 %]</li>[% END %]
     <li><span class="label">Username: </span>[% userid %]</li>
index 6a894ab..999fe49 100644 (file)
                     <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
                 [% END %]
 
+                [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
+                    <fieldset class="rows" id="memberentry_privacy">
+                        <legend id="privacy_legend">Privacy</legend>
+                        <ol>
+                            <li>
+                                <label>Allow your guarantor to view your current checkouts?</label>
+                                <select id="privacy_guarantor_checkouts">
+                                    <option value="0">No</option>
+                                    [% IF borrower.privacy_guarantor_checkouts %]
+                                        <option value="1" selected="selected">Yes</option>
+                                    [% ELSE %]
+                                        <option value="1">Yes</option>
+                                    [% END %]
+                                </select>
+                                <span class="hint">
+                                    <a id="update_privacy_guarantor_checkouts" href="#" class="btn">Update</a>
+                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
+                                </span>
+                                <span class="hint">
+                                    [% SET g = Koha.Find('Borrower',borrower.guarantorid) %]
+                                    Your guarantor is <i>[% g.firstname %] [% g.surname %]</i>
+                                </span>
+                            </li>
+                        </ol>
+                    </fieldset>
+                [% END %]
+
                 <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form">
 
                 [% UNLESS hidden.defined('branchcode') %]
             [% ELSE %]
                 $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
             [% END %]
+
             $("#memberentry-form").validate({
                 rules: {
                     borrower_email: {
                     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 %]
         });
     //]]>
     </script>
index 3b265ee..d1ed47c 100644 (file)
@@ -49,7 +49,7 @@
                                 <input type="hidden" name="op" value="update_privacy" />
                                     <fieldset>
                                     <label for="privacy">Please choose your privacy rule:</label>
-                                    <div class="input-append">
+                                    <div>
                                         <select name="privacy" id="privacy">
                                             [% IF ( privacy0 ) %]
                                                 <option value="0" selected="selected" class="privacy0">Forever</option>
                                                 <option value="2" class="privacy2">Never</option>
                                             [% END %]
                                         </select>
-                                        <button type="Submit" class="btn">Submit</button>
                                     </div>
+
+                                    [% SET b = Koha.Find('Borrower', borrower.borrowernumber) %]
+                                    [% IF b.guarantorid && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
+                                        <div>
+                                            <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
+                                            <select name="privacy_guarantor_checkouts">
+                                                [% IF borrower.privacy_guarantor_checkouts %]
+                                                    <option value="0">No</option>
+                                                    <option value="1" selected>Yes</option>
+                                                [% ELSE %]
+                                                    <option value="0" selected>No</option>
+                                                    <option value="1">Yes</option>
+                                                [% END %]
+                                            </select>
+                                            <span class="hint">
+                                                Your guarantor is <i>[% b.guarantor.firstname %] [% b.guarantor.surname %]</i>
+                                            </span>
+                                        </div>
+                                    [% END %]
+
+                                    <button type="Submit" class="btn">Save</button>
                                 </fieldset>
                             </form>
                         <h2>Immediate deletion</h2>
index 68a1e87..579a99a 100644 (file)
                     <div id="opac-user-views" class="toptabs">
                         <ul>
                             <li><a href="#opac-user-checkouts">Checked out ([% issues_count %])</a></li>
+                            [% IF relatives %]<li><a href="#opac-user-relative-issues">Relatives' checkouts</a></li>[% END %]
                             [% IF ( overdues_count ) %]<li><a href="#opac-user-overdues">Overdue ([% overdues_count %])</a></li>[% END %]
                             [% IF ( OPACFinesTab ) %]
                                 [% IF ( BORROWER_INF.amountoverfive ) %]<li><a href="#opac-user-fines">Fines ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
                                                 [% IF ( show_barcode ) %]
                                                     <th>Barcode</th>
                                                 [% END %]
-                                                    <th>Call No.</th>
+                                                    <th>Call number</th>
                                                 [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %]
                                                     <th class="nosort">Renew</th>
                                                 [% END %]
                             [% END %]
                         [% END # / OPACFinesTab %]
 
+                        [% IF relatives %]
+                            <div id="opac-user-relative-issues">
+                                <table id="opac-user-relative-issues-table" class="table table-bordered table-striped">
+                                    <thead>
+                                        <tr>
+                                            <th class="anti-the">Title</th>
+                                            <th>Due</th>
+                                            <th>Barcode</th>
+                                            <th>Call number</th>
+                                            <th class="psort">Relative</th>
+                                        </tr>
+                                    </thead>
+
+                                    <tbody>
+                                        [% FOREACH r IN relatives %]
+                                            [% FOREACH i IN r.issues %]
+                                                <tr>
+                                                    <td>
+                                                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% i.item.biblio.biblionumber %]">
+                                                            [% i.item.biblio.title %]
+                                                        </a>
+                                                    </td>
+
+                                                    <td>
+                                                        [% i.date_due | $KohaDates %]
+                                                    </td>
+
+                                                    <td>
+                                                        [% i.item.barcode %]
+                                                    </td>
+
+                                                    <td>
+                                                        [% i.item.itemcallnumber %]
+                                                    </td>
+
+                                                    <td>
+                                                        [% r.firstname %] [% r.surname %]
+                                                    </td>
+                                                </tr>
+                                            [% END %]
+                                        [% END %]
+                                    </tbody>
+                                </table>
+                            </div>
+                        [% END %]
+
                         [% IF ( overdues_count ) %]
                             <div id="opac-user-overdues">
                                 <table id="overduest" class="table table-bordered table-striped">
                                             <th class="anti-the">Title</th>
                                             [% UNLESS ( item_level_itypes ) %]<th>Item type</th> [% END %]
                                             [% IF ( show_barcode ) %]<th>Barcode</th>[% END %]
-                                            <th>Call no.</th>
+                                            <th>Call number</th>
                                             <th class="title-string psort">Due</th>
                                             [% IF ( OpacRenewalAllowed ) %]
                                                 <th class="nosort">Renew</th>
             $(".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, {
index 6198d87..482f2a2 100755 (executable)
@@ -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'),
index 2a98d8f..51fc7cd 100755 (executable)
@@ -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 };
index 8825b84..9d1f9b2 100755 (executable)
@@ -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"),