View | Details | Raw Unified | Return to bug 9303
Collapse All | Expand All

(-)a/installer/data/mysql/updatedatabase.pl (-2 / +10 lines)
Lines 8570-8579 if(CheckVersion($DBversion)) { Link Here
8570
        ALTER TABLE deletedborrowers ADD privacy_relative_checkouts BOOLEAN NOT NULL DEFAULT '0'
8570
        ALTER TABLE deletedborrowers ADD privacy_relative_checkouts BOOLEAN NOT NULL DEFAULT '0'
8571
    });
8571
    });
8572
    $dbh->do(q{
8572
    $dbh->do(q{
8573
        ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
8573
        ALTER TABLE old_issues
8574
            DROP PRIMARY KEY,
8575
            ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
8576
            DROP INDEX itemnumber_idx,
8577
            ADD UNIQUE itemnumber_idx (itemnumber);
8574
    });
8578
    });
8575
    $dbh->do(q{
8579
    $dbh->do(q{
8576
        ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
8580
        ALTER TABLE issues
8581
            DROP PRIMARY KEY,
8582
            ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
8583
            DROP INDEX itemnumber_idx,
8584
            ADD UNIQUE itemnumber_idx (itemnumber);
8577
    });
8585
    });
8578
    $dbh->do(qq{
8586
    $dbh->do(qq{
8579
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
8587
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (+35 lines)
Lines 54-59 Link Here
54
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
54
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
55
                [% END %]
55
                [% END %]
56
56
57
                <fieldset class="rows" id="memberentry_privacy">
58
                    <legend id="privacy_legend">Privacy</legend>
59
                    <ol>
60
                        <li>
61
                            <label>Allow relatives to view your current checkouts?</label>
62
                            <select id="privacy_relative_checkouts">
63
                                <option value="0">No</option>
64
                                [% IF borrower.privacy_relative_checkouts %]
65
                                    <option value="1" selected="selected">Yes</option>
66
                                [% ELSE %]
67
                                    <option value="1">Yes</option>
68
                                [% END %]
69
                            </select>
70
                            <span class="hint">
71
                                <a id="update_privacy_relative_checkouts" href="#" class="btn">Update</a>
72
                                <span id="update_privacy_relative_checkouts_message" class="alert" style="display:none"></span>
73
                            </span>
74
                        </li>
75
                    </ol>
76
                </fieldset>
77
57
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form">
78
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form">
58
79
59
                [% UNLESS hidden.defined('branchcode') %]
80
                [% UNLESS hidden.defined('branchcode') %]
Lines 777-782 Link Here
777
            [% ELSE %]
798
            [% ELSE %]
778
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
799
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
779
            [% END %]
800
            [% END %]
801
802
            $('#update_privacy_relative_checkouts').click( function() {
803
                $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_relative_checkouts: $('#privacy_relative_checkouts').val() })
804
                 .done(function( data ) {
805
                     var message;
806
                     if ( data.success ) {
807
                         message = _("Your setting has been updated!");
808
                     } else {
809
                         message = _("Unable to update your setting!");
810
                     }
811
812
                     $('#update_privacy_relative_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
813
                 });
814
            });
780
        });
815
        });
781
    //]]>
816
    //]]>
782
    </script>
817
    </script>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt (+35 lines)
Lines 20-25 Link Here
20
            [% ELSE %]
20
            [% ELSE %]
21
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
21
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
22
            [% END %]
22
            [% END %]
23
24
            $('#update_privacy_relative_checkouts').click( function() {
25
                $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_relative_checkouts: $('#privacy_relative_checkouts').val() })
26
                 .done(function( data ) {
27
                     var message;
28
                     if ( data.success ) {
29
                         message = _("Your setting has been updated!");
30
                     } else {
31
                         message = _("Unable to update your setting!");
32
                     }
33
34
                     $('#update_privacy_relative_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
35
                 });
36
            });
23
        });
37
        });
24
    //]]>
38
    //]]>
25
    </script>
39
    </script>
Lines 62-67 Link Here
62
                                <div class="dialog alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
76
                                <div class="dialog alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
63
                            [% END %]
77
                            [% END %]
64
78
79
                            <fieldset class="rows" id="memberentry_privacy">
80
                                <legend id="privacy_legend">Privacy</legend>
81
                                <ol>
82
                                    <li>
83
                                        <label>Show checkouts to relatives</label>
84
                                        <select id="privacy_relative_checkouts">
85
                                            <option value="0">No</option>
86
                                            [% IF borrower.privacy_relative_checkouts %]
87
                                                <option value="1" selected="selected">Yes</option>
88
                                            [% ELSE %]
89
                                                <option value="1">Yes</option>
90
                                            [% END %]
91
                                        </select>
92
                                        <span class="hint">
93
                                            <button id="update_privacy_relative_checkouts" onclick="return false;">Update</button>
94
                                            <span id="update_privacy_relative_checkouts_message" class="alert" style="display:none"></span>
95
                                        </span>
96
                                    </li>
97
                                </ol>
98
                            </fieldset>
99
65
                                [% UNLESS
100
                                [% UNLESS
66
                                    hidden.defined('branchcode')
101
                                    hidden.defined('branchcode')
67
                                %]
102
                                %]
(-)a/opac/svc/patron/show_checkouts_to_relatives (-1 / +60 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Context;
26
use Koha::Database;
27
28
use JSON qw( to_json );
29
30
my $cgi = CGI->new();
31
32
my $privacy_relative_checkouts = $cgi->param('privacy_relative_checkouts');
33
34
my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 1, {}, 'opac' );
35
36
my $borrowernumber =
37
  C4::Context->userenv ? C4::Context->userenv->{number} : undef;
38
39
my $success = 0;
40
if ( $borrowernumber && defined($privacy_relative_checkouts) ) {
41
    my $patron =
42
      Koha::Database->new()->schema()->resultset('Borrower')
43
      ->find($borrowernumber);
44
45
    $success = $patron->update(
46
        { privacy_relative_checkouts => $privacy_relative_checkouts } );
47
}
48
49
binmode STDOUT, ":encoding(UTF-8)";
50
print $cgi->header(
51
    -type    => 'application/json',
52
    -charset => 'UTF-8'
53
);
54
55
print to_json(
56
    {
57
        success => $success ? 1 : 0,
58
        privacy_relative_checkouts => $privacy_relative_checkouts,
59
    }
60
);

Return to bug 9303