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

(-)a/C4/Output.pm (+25 lines)
Lines 50-55 BEGIN { Link Here
50
    );
50
    );
51
    push @EXPORT, qw(
51
    push @EXPORT, qw(
52
        &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers
52
        &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers
53
        &output_and_exit_if_error
53
    );
54
    );
54
55
55
}
56
}
Lines 306-311 sub is_ajax { Link Here
306
    return ( $x_req and $x_req =~ /XMLHttpRequest/i ) ? 1 : 0;
307
    return ( $x_req and $x_req =~ /XMLHttpRequest/i ) ? 1 : 0;
307
}
308
}
308
309
310
sub output_and_exit_if_error {
311
    my ( $query, $cookie, $template, $params ) = @_;
312
    my $error;
313
    if ( $params and exists $params->{module} ) {
314
        if ( $params->{module} eq 'members' ) {
315
            my $logged_in_user = $params->{logged_in_user};
316
            my $current_patron = $params->{current_patron};
317
            if ( not $current_patron ) {
318
                $error = 'unknown_patron';
319
            }
320
            elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) {
321
                $error = 'cannot_see_patron_infos';
322
            }
323
        }
324
    }
325
326
    if ( $error ) {
327
        $template->param( blocking_error => $error );
328
        output_html_with_http_headers ( $query, $cookie, $template->output );
329
        exit;
330
    }
331
    return;
332
}
333
309
sub parametrized_url {
334
sub parametrized_url {
310
    my $url = shift || ''; # ie page.pl?ln={LANG}
335
    my $url = shift || ''; # ie page.pl?ln={LANG}
311
    my $vars = shift || {}; # ie { LANG => en }
336
    my $vars = shift || {}; # ie { LANG => en }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<script type="text/javascript">
2
<script type="text/javascript">
2
//<![CDATA[
3
//<![CDATA[
3
function confirm_deletion() {
4
function confirm_deletion() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<script type="text/javascript">
2
<script type="text/javascript">
2
//<![CDATA[
3
//<![CDATA[
3
    $(document).ready(function() {
4
    $(document).ready(function() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc (+10 lines)
Line 0 Link Here
1
[% IF blocking_error %]
2
    [% SWITCH blocking_error %]
3
    [% CASE 'unknown_patron' %]
4
        <div class="dialog message">This patron does not exist. <a href="/cgi-bin/koha/members/members-home.pl">Find another patron?</a></div>
5
    [% CASE 'cannot_see_patron_infos' %]You are not allowed to see the information of this patron.
6
    [% CASE %][% blocking_error %]
7
    [% END %]
8
9
    [% STOP %] [%# Will stop gracefully without processing any more of the template document.%]
10
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
2
    [% IF ( budget_period_id ) %]
3
    [% IF ( budget_period_id ) %]
3
        <div class="btn-group">
4
        <div class="btn-group">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 / +2 lines)
Lines 1-4 Link Here
1
	<script type="text/javascript">
1
[% INCLUDE 'blocking_errors.inc' %]
2
<script type="text/javascript">
2
	//<![CDATA[
3
	//<![CDATA[
3
	[% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
4
	[% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
4
	/* this function open a popup to search on z3950 server.  */
5
	/* this function open a popup to search on z3950 server.  */
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
2
    <div class="btn-group">
3
    <div class="btn-group">
3
        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
4
        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% USE Koha %]
2
[% USE Koha %]
2
[% USE Borrowers %]
3
[% USE Borrowers %]
3
[% USE Branches %]
4
[% USE Branches %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% USE Categories %]
2
[% USE Categories %]
2
[% USE Koha %]
3
[% USE Koha %]
3
[% SET categories = Categories.all %]
4
[% SET categories = Categories.all %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
2
    <div class="btn-group">
3
    <div class="btn-group">
3
        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
4
        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
2
    [% IF ( CAN_user_reports_create_reports ) %]
3
    [% IF ( CAN_user_reports_create_reports ) %]
3
        <div class="btn-group">
4
        <div class="btn-group">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<script type="text/javascript">
2
<script type="text/javascript">
2
    $(document).ready(function(){
3
    $(document).ready(function(){
3
        $(".confirmdelete").click(function(){
4
        $(".confirmdelete").click(function(){
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<script type="text/javascript">
2
<script type="text/javascript">
2
	//<![CDATA[
3
	//<![CDATA[
3
4
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc (+1 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
<script type="text/javascript">
2
<script type="text/javascript">
2
//<![CDATA[
3
//<![CDATA[
3
4
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt (-2 / +2 lines)
Lines 2-8 Link Here
2
[% USE AuthorisedValues %]
2
[% USE AuthorisedValues %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Patrons &rsaquo; [% IF (unknowuser) %]Patron does not exist[% ELSE %]Discharge for [% firstname %] [% surname %] ([% cardnumber %])[% END %]</title>
5
<title>Koha &rsaquo; Patrons &rsaquo; [% UNLESS blocking_error  %]Discharge for [% firstname %] [% surname %] ([% cardnumber %])[% END %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
7
</head>
8
<body id="discharge" class="discharge">
8
<body id="discharge" class="discharge">
Lines 12-18 Link Here
12
<div id="breadcrumbs">
12
<div id="breadcrumbs">
13
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
13
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
14
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
14
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
15
&rsaquo; [% IF (unknowuser) %]Patron does not exist[% ELSE %]Discharge for [% firstname %] [% surname %] ([% cardnumber %])[% END %]
15
&rsaquo; [% UNLESS blocking_error  %]Discharge for [% firstname %] [% surname %] ([% cardnumber %])[% END %]
16
</div>
16
</div>
17
17
18
<div id="doc3" class="yui-t1">
18
<div id="doc3" class="yui-t1">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt (-4 lines)
Lines 30-38 Link Here
30
    <div id="yui-main">
30
    <div id="yui-main">
31
      <div class="yui-b">
31
      <div class="yui-b">
32
32
33
        [% UNLESS ( unknowuser ) %]
34
        [% INCLUDE 'members-toolbar.inc' %]
33
        [% INCLUDE 'members-toolbar.inc' %]
35
        [% END %]
36
34
37
        <div class="yui-g">
35
        <div class="yui-g">
38
36
Lines 43-50 Link Here
43
            [% FOR m IN messages %]
41
            [% FOR m IN messages %]
44
                <div class="dialog [% m.type %]">
42
                <div class="dialog [% m.type %]">
45
                    [% SWITCH m.code %]
43
                    [% SWITCH m.code %]
46
                    [% CASE 'error_on_patron_load' %]
47
                        An error occurred whilst loading the patron details.
48
                    [% CASE 'error_on_profile_store' %]
44
                    [% CASE 'error_on_profile_store' %]
49
                        An error occurred whilst updating this housebound profile.
45
                        An error occurred whilst updating this housebound profile.
50
                    [% CASE 'error_on_profile_create' %]
46
                    [% CASE 'error_on_profile_create' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-11 / +2 lines)
Lines 5-13 Link Here
5
[% USE ColumnsSettings %]
5
[% USE ColumnsSettings %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; Patrons &rsaquo;
7
<title>Koha &rsaquo; Patrons &rsaquo;
8
[% IF ( unknowuser ) %]
8
[% UNLESS blocking_error %]
9
    Patron does not exist
10
[% ELSE %]
11
    Patron details for [% INCLUDE 'patron-title.inc' %]
9
    Patron details for [% INCLUDE 'patron-title.inc' %]
12
[% END %]
10
[% END %]
13
</title>
11
</title>
Lines 136-142 function validate1(date) { Link Here
136
<div id="breadcrumbs">
134
<div id="breadcrumbs">
137
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
135
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
138
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
136
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
139
&rsaquo; [% IF ( unknowuser ) %]Patron does not exist[% ELSE %]Patron details for [% INCLUDE 'patron-title.inc' %][% END %]
137
&rsaquo; [% UNLESS blocking_error %]Patron details for [% INCLUDE 'patron-title.inc' %][% END %]
140
</div>
138
</div>
141
139
142
<div id="doc3" class="yui-t2">
140
<div id="doc3" class="yui-t2">
Lines 145-153 function validate1(date) { Link Here
145
	<div id="yui-main">
143
	<div id="yui-main">
146
	<div class="yui-b">
144
	<div class="yui-b">
147
145
148
[% UNLESS ( unknowuser ) %]
149
[% INCLUDE 'members-toolbar.inc' %]
146
[% INCLUDE 'members-toolbar.inc' %]
150
[% END %]
151
147
152
[% IF ( error ) %]
148
[% IF ( error ) %]
153
<div class="dialog alert">
149
<div class="dialog alert">
Lines 171-179 function validate1(date) { Link Here
171
[% END %]
167
[% END %]
172
<div class="yui-g">
168
<div class="yui-g">
173
169
174
[% IF ( unknowuser ) %]
175
   <div class="dialog message">This patron does not exist. <a href="/cgi-bin/koha/members/members-home.pl">Find another patron?</a></div>
176
[% ELSE %]
177
    [% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% dateexpiry | $KohaDates %]</div>[% END %]
170
    [% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% dateexpiry | $KohaDates %]</div>[% END %]
178
171
179
    [% IF fines %]
172
    [% IF fines %]
Lines 612-619 function validate1(date) { Link Here
612
[% END %]
605
[% END %]
613
606
614
</div>
607
</div>
615
[% END %] <!-- unknowuser -->
616
617
608
618
</div>
609
</div>
619
</div>
610
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/statistics.tt (-4 / +2 lines)
Lines 3-11 Link Here
3
[% USE Branches %]
3
[% USE Branches %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Patrons &rsaquo;
5
<title>Koha &rsaquo; Patrons &rsaquo;
6
[% IF ( unknowuser ) %]
6
[% UNLESS blocking_error %]
7
    Patron does not exist
8
[% ELSE %]
9
    Statistics for [% INCLUDE 'patron-title.inc' %]
7
    Statistics for [% INCLUDE 'patron-title.inc' %]
10
[% END %]
8
[% END %]
11
</title>
9
</title>
Lines 30-36 Link Here
30
<div id="breadcrumbs">
28
<div id="breadcrumbs">
31
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
29
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
30
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
33
&rsaquo; [% IF ( unknowuser ) %]Patron does not exist[% ELSE %]Statistics for [% firstname %] [% surname %] ([% cardnumber %])[% END %]
31
&rsaquo; [% UNLESS blocking_error  %]Statistics for [% firstname %] [% surname %] ([% cardnumber %])[% END %]
34
</div>
32
</div>
35
33
36
<div id="doc3" class="yui-t1">
34
<div id="doc3" class="yui-t1">
(-)a/members/boraccount.pl (-1 / +3 lines)
Lines 52-60 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
52
my $borrowernumber=$input->param('borrowernumber');
52
my $borrowernumber=$input->param('borrowernumber');
53
my $action = $input->param('action') || '';
53
my $action = $input->param('action') || '';
54
54
55
#get patron details
55
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
56
my $patron = Koha::Patrons->find( $borrowernumber );
56
my $patron = Koha::Patrons->find( $borrowernumber );
57
57
58
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
59
58
if ( $action eq 'reverse' ) {
60
if ( $action eq 'reverse' ) {
59
  ReversePayment( $input->param('accountlines_id') );
61
  ReversePayment( $input->param('accountlines_id') );
60
}
62
}
(-)a/members/deletemem.pl (-3 / +6 lines)
Lines 39-45 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
39
39
40
my $input = new CGI;
40
my $input = new CGI;
41
41
42
my ($template, $borrowernumber, $cookie)
42
my ($template, $loggedinuser, $cookie)
43
                = get_template_and_user({template_name => "members/deletemem.tt",
43
                = get_template_and_user({template_name => "members/deletemem.tt",
44
                                        query => $input,
44
                                        query => $input,
45
                                        type => "intranet",
45
                                        type => "intranet",
Lines 52-62 my ($template, $borrowernumber, $cookie) Link Here
52
my $member       = $input->param('member');
52
my $member       = $input->param('member');
53
53
54
#Do not delete yourself...
54
#Do not delete yourself...
55
if ($borrowernumber == $member ) {
55
if ( $loggedinuser == $member ) {
56
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_YOURSELF");
56
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_YOURSELF");
57
    exit 0; # Exit without error
57
    exit 0; # Exit without error
58
}
58
}
59
59
60
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
61
my $patron         = Koha::Patrons->find( $member );
62
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
63
60
# Handle deletion from the Norwegian national patron database, if it is enabled
64
# Handle deletion from the Norwegian national patron database, if it is enabled
61
# If the "deletelocal" parameter is set to "false", the regular deletion will be
65
# If the "deletelocal" parameter is set to "false", the regular deletion will be
62
# short circuited, and only a deletion from the national database can be carried
66
# short circuited, and only a deletion from the national database can be carried
Lines 74-80 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
74
my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
78
my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
75
my $countissues = scalar(@$issues);
79
my $countissues = scalar(@$issues);
76
80
77
my $patron = Koha::Patrons->find( $member );
78
my $flags = C4::Members::patronflags( $patron->unblessed );
81
my $flags = C4::Members::patronflags( $patron->unblessed );
79
my $userenv = C4::Context->userenv;
82
my $userenv = C4::Context->userenv;
80
83
(-)a/members/discharge.pl (-72 / +69 lines)
Lines 58-142 unless ( C4::Context->preference('useDischarge') ) { Link Here
58
   exit;
58
   exit;
59
}
59
}
60
60
61
if ( $input->param('borrowernumber') ) {
61
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
62
    $borrowernumber = $input->param('borrowernumber');
62
my $patron = Koha::Patrons->find( $borrowernumber );
63
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
63
64
64
    # Getting member data
65
my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
65
    my $patron = Koha::Patrons->find( $borrowernumber );
66
    borrowernumber => $borrowernumber
66
67
});
67
    my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
68
        borrowernumber => $borrowernumber
69
    });
70
68
71
    my $holds = $patron->holds;
69
my $holds = $patron->holds;
72
    my $has_reserves = $holds->count;
70
my $has_reserves = $holds->count;
73
71
74
    # Generating discharge if needed
72
# Generating discharge if needed
75
    if ( $input->param('discharge') and $can_be_discharged ) {
73
if ( $input->param('discharge') and $can_be_discharged ) {
76
        my $is_discharged = Koha::Patron::Discharge::is_discharged({
74
    my $is_discharged = Koha::Patron::Discharge::is_discharged({
77
            borrowernumber => $borrowernumber,
75
        borrowernumber => $borrowernumber,
76
    });
77
    unless ($is_discharged) {
78
        Koha::Patron::Discharge::discharge({
79
            borrowernumber => $borrowernumber
78
        });
80
        });
79
        unless ($is_discharged) {
80
            Koha::Patron::Discharge::discharge({
81
                borrowernumber => $borrowernumber
82
            });
83
        }
84
        eval {
85
            my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
86
                { borrowernumber => $borrowernumber, branchcode => $patron->branchcode } );
87
88
            binmode(STDOUT);
89
            print $input->header(
90
                -type       => 'application/pdf',
91
                -charset    => 'utf-8',
92
                -attachment => "discharge_$borrowernumber.pdf",
93
            );
94
            open my $fh, '<', $pdf_path;
95
            my @lines = <$fh>;
96
            close $fh;
97
            print @lines;
98
            exit;
99
        };
100
        if ( $@ ) {
101
            carp $@;
102
            $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
103
        }
104
    }
81
    }
82
    eval {
83
        my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
84
            { borrowernumber => $borrowernumber, branchcode => $patron->branchcode } );
85
86
        binmode(STDOUT);
87
        print $input->header(
88
            -type       => 'application/pdf',
89
            -charset    => 'utf-8',
90
            -attachment => "discharge_$borrowernumber.pdf",
91
        );
92
        open my $fh, '<', $pdf_path;
93
        my @lines = <$fh>;
94
        close $fh;
95
        print @lines;
96
        exit;
97
    };
98
    if ( $@ ) {
99
        carp $@;
100
        $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
101
    }
102
}
105
103
106
    # Already generated discharges
104
# Already generated discharges
107
    my $validated_discharges = Koha::Patron::Discharge::get_validated({
105
my $validated_discharges = Koha::Patron::Discharge::get_validated({
108
        borrowernumber => $borrowernumber,
106
    borrowernumber => $borrowernumber,
109
    });
107
});
110
108
111
    $template->param( picture => 1 ) if $patron->image;
109
$template->param( picture => 1 ) if $patron->image;
112
110
113
    $template->param(
111
$template->param(
114
        # FIXME The patron object should be passed to the template
112
    # FIXME The patron object should be passed to the template
115
        borrowernumber    => $borrowernumber,
113
    borrowernumber    => $borrowernumber,
116
        title             => $patron->title,
114
    title             => $patron->title,
117
        initials          => $patron->initials,
115
    initials          => $patron->initials,
118
        surname           => $patron->surname,
116
    surname           => $patron->surname,
119
        borrowernumber    => $borrowernumber,
117
    borrowernumber    => $borrowernumber,
120
        firstname         => $patron->firstname,
118
    firstname         => $patron->firstname,
121
        cardnumber        => $patron->cardnumber,
119
    cardnumber        => $patron->cardnumber,
122
        categorycode      => $patron->categorycode,
120
    categorycode      => $patron->categorycode,
123
        category_type     => $patron->category->category_type,
121
    category_type     => $patron->category->category_type,
124
        categoryname      => $patron->category->description,
122
    categoryname      => $patron->category->description,
125
        address           => $patron->address,
123
    address           => $patron->address,
126
        streetnumber      => $patron->streetnumber,
124
    streetnumber      => $patron->streetnumber,
127
        streettype        => $patron->streettype,
125
    streettype        => $patron->streettype,
128
        address2          => $patron->address2,
126
    address2          => $patron->address2,
129
        city              => $patron->city,
127
    city              => $patron->city,
130
        zipcode           => $patron->zipcode,
128
    zipcode           => $patron->zipcode,
131
        country           => $patron->country,
129
    country           => $patron->country,
132
        phone             => $patron->phone,
130
    phone             => $patron->phone,
133
        email             => $patron->email,
131
    email             => $patron->email,
134
        branchcode        => $patron->branchcode,
132
    branchcode        => $patron->branchcode,
135
        has_reserves      => $has_reserves,
133
    has_reserves      => $has_reserves,
136
        can_be_discharged => $can_be_discharged,
134
    can_be_discharged => $can_be_discharged,
137
        validated_discharges => $validated_discharges,
135
    validated_discharges => $validated_discharges,
138
    );
136
);
139
}
140
137
141
$template->param( dischargeview => 1, );
138
$template->param( dischargeview => 1, );
142
139
(-)a/members/discharges.pl (+3 lines)
Lines 44-49 my $branchcode = Link Here
44
44
45
if( $op eq 'allow' ) {
45
if( $op eq 'allow' ) {
46
    my $borrowernumber = $input->param('borrowernumber');
46
    my $borrowernumber = $input->param('borrowernumber');
47
    my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
48
    my $patron         = Koha::Patrons->find($borrowernumber);
49
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
47
    Koha::Patron::Discharge::discharge({
50
    Koha::Patron::Discharge::discharge({
48
        borrowernumber => $borrowernumber
51
        borrowernumber => $borrowernumber
49
    }) if $borrowernumber;
52
    }) if $borrowernumber;
(-)a/members/files.pl (-2 / +6 lines)
Lines 47-53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
47
$template->param( 'borrower_files' => 1 );
47
$template->param( 'borrower_files' => 1 );
48
48
49
my $borrowernumber = $cgi->param('borrowernumber');
49
my $borrowernumber = $cgi->param('borrowernumber');
50
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
50
51
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
52
my $patron         = Koha::Patrons->find($borrowernumber);
53
output_and_exit_if_error( $cgi, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
54
55
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber ); # FIXME Should be $patron->get_files. Koha::Patron::Files needs to be Koha::Objects based first
51
56
52
my $op = $cgi->param('op') || '';
57
my $op = $cgi->param('op') || '';
53
58
Lines 63-69 if ( $op eq 'download' ) { Link Here
63
    print $file->{'file_content'};
68
    print $file->{'file_content'};
64
}
69
}
65
else {
70
else {
66
    my $patron = Koha::Patrons->find( $borrowernumber );
67
    $template->param(%{ $patron->unblessed});
71
    $template->param(%{ $patron->unblessed});
68
72
69
    my %errors;
73
    my %errors;
(-)a/members/housebound.pl (-6 / +4 lines)
Lines 56-67 my $method = $input->param('method') // q{}; Link Here
56
my $visit_id = $input->param('visit_id') // q{};
56
my $visit_id = $input->param('visit_id') // q{};
57
57
58
# Get patron
58
# Get patron
59
my $patron = eval {
59
my $borrowernumber = $input->param('borrowernumber');
60
    my $borrowernumber = $input->param('borrowernumber') // q{};
60
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
61
    return Koha::Patrons->find($borrowernumber);
61
my $patron = Koha::Patrons->find($borrowernumber);
62
};
62
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
63
push @messages, { type => 'error', code => 'error_on_patron_load' }
64
    if ( $@ or !$patron );
65
63
66
# Get supporting cast
64
# Get supporting cast
67
my ( $branch, $category, $houseboundprofile, $visit, $patron_image );
65
my ( $branch, $category, $houseboundprofile, $visit, $patron_image );
(-)a/members/mancredit.pl (-1 / +4 lines)
Lines 47-52 my $add=$input->param('add'); Link Here
47
47
48
if ($add){
48
if ($add){
49
    if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
49
    if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
50
        # Note: If the logged in user is not allowed to see this patron an invoice can be forced
51
        # Here we are trusting librarians not to hack the system
50
        my $barcode = $input->param('barcode');
52
        my $barcode = $input->param('barcode');
51
        my $itemnum;
53
        my $itemnum;
52
        if ($barcode) {
54
        if ($barcode) {
Lines 72-78 if ($add){ Link Here
72
            debug           => 1,
74
            debug           => 1,
73
        }
75
        }
74
    );
76
    );
75
					  
77
    my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
78
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
76
    if ( $patron->category->category_type eq 'C') {
79
    if ( $patron->category->category_type eq 'C') {
77
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
80
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
78
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
81
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
(-)a/members/maninvoice.pl (-2 / +7 lines)
Lines 46-52 my $patron = Koha::Patrons->find( $borrowernumber ); Link Here
46
my $add=$input->param('add');
46
my $add=$input->param('add');
47
if ($add){
47
if ($add){
48
    if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
48
    if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
49
        #  print $input->header;
49
        # Note: If the logged in user is not allowed to see this patron an invoice can be forced
50
        # Here we are trusting librarians not to hack the system
50
        my $barcode=$input->param('barcode');
51
        my $barcode=$input->param('barcode');
51
        my $itemnum;
52
        my $itemnum;
52
        if ($barcode) {
53
        if ($barcode) {
Lines 88-94 if ($add){ Link Here
88
                             updatecharges => 'remaining_permissions' },
89
                             updatecharges => 'remaining_permissions' },
89
        debug           => 1,
90
        debug           => 1,
90
    });
91
    });
91
					
92
93
    my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
94
    my $patron         = Koha::Patrons->find($borrowernumber);
95
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
96
92
  # get authorised values with type of MANUAL_INV
97
  # get authorised values with type of MANUAL_INV
93
  my @invoice_types;
98
  my @invoice_types;
94
  my $dbh = C4::Context->dbh;
99
  my $dbh = C4::Context->dbh;
(-)a/members/member-flags.pl (-1 / +3 lines)
Lines 29-35 my $member=$input->param('member'); Link Here
29
my $patron = Koha::Patrons->find( $member );
29
my $patron = Koha::Patrons->find( $member );
30
my $category_type = $patron->category->category_type;
30
my $category_type = $patron->category->category_type;
31
my $bor = $patron->unblessed;
31
my $bor = $patron->unblessed;
32
if( $category_type eq 'S' )  {
32
if( $category_type eq 'S' )  { # FIXME Is this really needed?
33
	$flagsrequired->{'staffaccess'} = 1;
33
	$flagsrequired->{'staffaccess'} = 1;
34
}
34
}
35
my ($template, $loggedinuser, $cookie) = get_template_and_user({
35
my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 41-46 my ($template, $loggedinuser, $cookie) = get_template_and_user({ Link Here
41
        debug           => 1,
41
        debug           => 1,
42
});
42
});
43
43
44
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
45
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
44
46
45
my %member2;
47
my %member2;
46
$member2{'borrowernumber'}=$member;
48
$member2{'borrowernumber'}=$member;
(-)a/members/member-password.pl (+3 lines)
Lines 45-51 my $newpassword2 = $input->param('newpassword2'); Link Here
45
45
46
my @errors;
46
my @errors;
47
47
48
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
48
my $patron = Koha::Patrons->find( $member );
49
my $patron = Koha::Patrons->find( $member );
50
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
51
49
my $category_type = $patron->category->category_type;
52
my $category_type = $patron->category->category_type;
50
my $bor = $patron->unblessed;
53
my $bor = $patron->unblessed;
51
54
(-)a/members/memberentry.pl (-3 / +5 lines)
Lines 75-87 my ($template, $loggedinuser, $cookie) Link Here
75
           debug => ($debug) ? 1 : 0,
75
           debug => ($debug) ? 1 : 0,
76
       });
76
       });
77
77
78
my $borrowernumber = $input->param('borrowernumber');
79
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
80
my $patron         = Koha::Patrons->find($borrowernumber);
81
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
82
78
if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) {
83
if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) {
79
    my @providers = Koha::SMS::Providers->search();
84
    my @providers = Koha::SMS::Providers->search();
80
    $template->param( sms_providers => \@providers );
85
    $template->param( sms_providers => \@providers );
81
}
86
}
82
87
83
my $guarantorid    = $input->param('guarantorid');
88
my $guarantorid    = $input->param('guarantorid');
84
my $borrowernumber = $input->param('borrowernumber');
85
my $actionType     = $input->param('actionType') || '';
89
my $actionType     = $input->param('actionType') || '';
86
my $modify         = $input->param('modify');
90
my $modify         = $input->param('modify');
87
my $delete         = $input->param('delete');
91
my $delete         = $input->param('delete');
Lines 154-160 $template->param( "quickadd" => 1 ) if ( $quickadd ); Link Here
154
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
158
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
155
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
159
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
156
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
160
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
157
    my $patron = Koha::Patrons->find( $borrowernumber );
158
    $borrower_data = $patron->unblessed;
161
    $borrower_data = $patron->unblessed;
159
    $borrower_data->{category_type} = $patron->category->category_type;
162
    $borrower_data->{category_type} = $patron->category->category_type;
160
}
163
}
Lines 311-317 if ($op eq 'save' || $op eq 'insert'){ Link Here
311
314
312
    my $dateofbirth;
315
    my $dateofbirth;
313
    if ($op eq 'save' && $step == 3) {
316
    if ($op eq 'save' && $step == 3) {
314
        my $patron = Koha::Patrons->find( $borrowernumber );
315
        $dateofbirth = $patron->dateofbirth;
317
        $dateofbirth = $patron->dateofbirth;
316
    }
318
    }
317
    else {
319
    else {
(-)a/members/members-update-do.pl (+6 lines)
Lines 28-33 use Koha::Patron::Modifications; Link Here
28
28
29
my $query = new CGI;
29
my $query = new CGI;
30
30
31
# FIXME Should be a checkauth call
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
    {
33
        template_name   => "about.tt",
34
        template_name   => "about.tt",
Lines 39-50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
39
    }
40
    }
40
);
41
);
41
42
43
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
44
42
my @params = $query->param;
45
my @params = $query->param;
43
46
44
foreach my $param (@params) {
47
foreach my $param (@params) {
45
    if ( $param =~ "^modify_" ) {
48
    if ( $param =~ "^modify_" ) {
46
        my (undef, $borrowernumber) = split( /_/, $param );
49
        my (undef, $borrowernumber) = split( /_/, $param );
47
50
51
        my $patron = Koha::Patrons->find($borrowernumber);
52
        next unless $logged_in_user->can_see_patron_infos( $patron );
53
48
        my $action = $query->param($param);
54
        my $action = $query->param($param);
49
55
50
        if ( $action eq 'approve' ) {
56
        if ( $action eq 'approve' ) {
(-)a/members/mod_debarment.pl (+8 lines)
Lines 32-37 my ( $loggedinuser, $cookie, $sessionID ) = checkauth( $cgi, 0, { borrowers => ' Link Here
32
my $borrowernumber = $cgi->param('borrowernumber');
32
my $borrowernumber = $cgi->param('borrowernumber');
33
my $action         = $cgi->param('action');
33
my $action         = $cgi->param('action');
34
34
35
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
36
my $patron         = Koha::Patrons->find($borrowernumber);
37
38
# Ideally we should display a warning on the interface if the patron is not allowed
39
# to modify a debarment
40
# But a librarian is not supposed to hack the system
41
$action = '' unless $logged_in_user->can_see_patron_infos( $patron );
42
35
if ( $action eq 'del' ) {
43
if ( $action eq 'del' ) {
36
    DelDebarment( $cgi->param('borrower_debarment_id') );
44
    DelDebarment( $cgi->param('borrower_debarment_id') );
37
} elsif ( $action eq 'add' ) {
45
} elsif ( $action eq 'add' ) {
(-)a/members/moremember.pl (-6 / +3 lines)
Lines 119-130 my $borrowernumber = $input->param('borrowernumber'); Link Here
119
my $error = $input->param('error');
119
my $error = $input->param('error');
120
$template->param( error => $error ) if ( $error );
120
$template->param( error => $error ) if ( $error );
121
121
122
my $patron        = Koha::Patrons->find($borrowernumber);
122
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
123
unless ( $patron ) {
123
my $patron         = Koha::Patrons->find( $borrowernumber );
124
    $template->param (unknowuser => 1);
124
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
125
    output_html_with_http_headers $input, $cookie, $template->output;
126
    exit;
127
}
128
125
129
my $issues        = $patron->checkouts;
126
my $issues        = $patron->checkouts;
130
my $balance       = $patron->account->balance;
127
my $balance       = $patron->account->balance;
(-)a/members/notices.pl (+3 lines)
Lines 45-50 my ($template, $loggedinuser, $cookie) Link Here
45
				debug => 1,
45
				debug => 1,
46
				});
46
				});
47
47
48
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
49
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
50
48
$template->param( $borrower );
51
$template->param( $borrower );
49
$template->param( picture => 1 ) if $patron->image;
52
$template->param( picture => 1 ) if $patron->image;
50
53
(-)a/members/pay.pl (-1 / +4 lines)
Lines 67-73 if ( !$borrowernumber ) { Link Here
67
}
67
}
68
68
69
# get borrower details
69
# get borrower details
70
my $patron = Koha::Patrons->find( $borrowernumber );
70
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
71
my $patron         = Koha::Patrons->find($borrowernumber);
72
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
73
71
my $category = $patron->category;
74
my $category = $patron->category;
72
our $borrower = $patron->unblessed;
75
our $borrower = $patron->unblessed;
73
$borrower->{description} = $category->description;
76
$borrower->{description} = $category->description;
(-)a/members/paycollect.pl (+4 lines)
Lines 50-55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
50
# get borrower details
50
# get borrower details
51
my $borrowernumber = $input->param('borrowernumber');
51
my $borrowernumber = $input->param('borrowernumber');
52
my $patron         = Koha::Patrons->find( $borrowernumber );
52
my $patron         = Koha::Patrons->find( $borrowernumber );
53
54
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
55
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
56
53
my $borrower       = $patron->unblessed;
57
my $borrower       = $patron->unblessed;
54
my $category       = $patron->category;
58
my $category       = $patron->category;
55
$borrower->{description} = $category->description;
59
$borrower->{description} = $category->description;
(-)a/members/print_overdues.pl (+6 lines)
Lines 27-32 use C4::Output; Link Here
27
use C4::Members qw(GetOverduesForPatron);
27
use C4::Members qw(GetOverduesForPatron);
28
use C4::Overdues qw(parse_overdues_letter);
28
use C4::Overdues qw(parse_overdues_letter);
29
29
30
use Koha::Patrons;
31
30
my $input = new CGI;
32
my $input = new CGI;
31
33
32
my $flagsrequired = { circulate => "circulate_remaining_permissions" };
34
my $flagsrequired = { circulate => "circulate_remaining_permissions" };
Lines 45-50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
45
my $borrowernumber = $input->param('borrowernumber');
47
my $borrowernumber = $input->param('borrowernumber');
46
my $branchcode     = C4::Context->userenv->{'branch'};
48
my $branchcode     = C4::Context->userenv->{'branch'};
47
49
50
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
51
my $patron         = Koha::Patrons->find( $borrowernumber );
52
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
53
48
my $overdues = GetOverduesForPatron($borrowernumber);
54
my $overdues = GetOverduesForPatron($borrowernumber);
49
55
50
my $letter = parse_overdues_letter(
56
my $letter = parse_overdues_letter(
(-)a/members/printfeercpt.pl (-1 / +4 lines)
Lines 50-56 my $borrowernumber=$input->param('borrowernumber'); Link Here
50
my $action = $input->param('action') || '';
50
my $action = $input->param('action') || '';
51
my $accountlines_id = $input->param('accountlines_id');
51
my $accountlines_id = $input->param('accountlines_id');
52
52
53
my $patron = Koha::Patrons->find( $borrowernumber );
53
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
54
my $patron         = Koha::Patrons->find( $borrowernumber );
55
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
56
54
my $category = $patron->category;
57
my $category = $patron->category;
55
my $data = $patron->unblessed;
58
my $data = $patron->unblessed;
56
$data->{description} = $category->description;
59
$data->{description} = $category->description;
(-)a/members/printinvoice.pl (-1 / +4 lines)
Lines 49-55 my $borrowernumber = $input->param('borrowernumber'); Link Here
49
my $action          = $input->param('action') || '';
49
my $action          = $input->param('action') || '';
50
my $accountlines_id = $input->param('accountlines_id');
50
my $accountlines_id = $input->param('accountlines_id');
51
51
52
my $patron = Koha::Patrons->find( $borrowernumber );
52
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
53
my $patron         = Koha::Patrons->find( $borrowernumber );
54
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
55
53
my $category = $patron->category;
56
my $category = $patron->category;
54
my $data = $patron->unblessed;
57
my $data = $patron->unblessed;
55
$data->{description} = $category->description;
58
$data->{description} = $category->description;
(-)a/members/printslip.pl (+5 lines)
Lines 74-79 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
74
);
74
);
75
75
76
my $borrowernumber = $input->param('borrowernumber');
76
my $borrowernumber = $input->param('borrowernumber');
77
78
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
79
my $patron         = Koha::Patrons->find( $borrowernumber );
80
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
81
77
my $branch=C4::Context->userenv->{'branch'};
82
my $branch=C4::Context->userenv->{'branch'};
78
my ($slip, $is_html);
83
my ($slip, $is_html);
79
if (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
84
if (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
(-)a/members/purchase-suggestions.pl (-2 / +4 lines)
Lines 42-49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
42
42
43
my $borrowernumber = $input->param('borrowernumber');
43
my $borrowernumber = $input->param('borrowernumber');
44
44
45
# Set informations for the patron
45
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
46
my $patron = Koha::Patrons->find( $borrowernumber );
46
my $patron         = Koha::Patrons->find( $borrowernumber );
47
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
48
47
my $category = $patron->category;
49
my $category = $patron->category;
48
my $data = $patron->unblessed;
50
my $data = $patron->unblessed;
49
$data->{description} = $category->description;
51
$data->{description} = $category->description;
(-)a/members/readingrec.pl (+4 lines)
Lines 64-69 if ($input->param('borrowernumber')) { Link Here
64
    $data = $patron->unblessed;
64
    $data = $patron->unblessed;
65
}
65
}
66
66
67
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
68
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
69
67
my $order = 'date_due desc';
70
my $order = 'date_due desc';
68
my $limit = 0;
71
my $limit = 0;
69
my $issues = ();
72
my $issues = ();
Lines 78-83 if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){ Link Here
78
81
79
#   barcode export
82
#   barcode export
80
if ( $op eq 'export_barcodes' ) {
83
if ( $op eq 'export_barcodes' ) {
84
    # FIXME This should be moved out of this script
81
    if ( $data->{'privacy'} < 2) {
85
    if ( $data->{'privacy'} < 2) {
82
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
86
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
83
        my @barcodes =
87
        my @barcodes =
(-)a/members/routing-lists.pl (-29 / +27 lines)
Lines 1-4 Link Here
1
#!/usr/bin/perl
2
1
3
# Copyright 2012 Prosentient Systems
2
# Copyright 2012 Prosentient Systems
4
#
3
#
Lines 48-83 my $borrowernumber = $query->param('borrowernumber'); Link Here
48
47
49
my $branch = C4::Context->userenv->{'branch'};
48
my $branch = C4::Context->userenv->{'branch'};
50
49
51
# get the borrower information.....
50
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
52
my ( $patron, $patron_info );
51
my $patron         = Koha::Patrons->find( $borrowernumber );
53
if ($borrowernumber) {
52
output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
54
    $patron = Koha::Patrons->find( $borrowernumber );
53
55
    my $category = $patron->category;
54
my $category = $patron->category;
56
    my $patron_info = $patron->unblessed;
55
my $patron_info = $patron->unblessed;
57
    $patron_info->{description} = $category->description;
56
$patron_info->{description} = $category->description;
58
    $patron_info->{category_type} = $category->category_type;
57
$patron_info->{category_type} = $category->category_type;
59
58
60
  my $count;
59
my $count;
61
  my @borrowerSubscriptions;
60
my @borrowerSubscriptions;
62
  ($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
61
($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
63
  my @subscripLoop;
62
my @subscripLoop;
64
63
65
    foreach my $num_res (@borrowerSubscriptions) {
64
foreach my $num_res (@borrowerSubscriptions) {
66
        my %getSubscrip;
65
    my %getSubscrip;
67
        $getSubscrip{subscriptionid}	= $num_res->{'subscriptionid'};
66
    $getSubscrip{subscriptionid} = $num_res->{'subscriptionid'};
68
        $getSubscrip{title}			= $num_res->{'title'};
67
    $getSubscrip{title}          = $num_res->{'title'};
69
        $getSubscrip{borrowernumber}		= $num_res->{'borrowernumber'};
68
    $getSubscrip{borrowernumber} = $num_res->{'borrowernumber'};
70
        push( @subscripLoop, \%getSubscrip );
69
    push( @subscripLoop, \%getSubscrip );
71
    }
70
}
72
71
73
    $template->param(
72
$template->param(
74
        countSubscrip => scalar @subscripLoop,
73
    countSubscrip => scalar @subscripLoop,
75
        subscripLoop  => \@subscripLoop,
74
    subscripLoop  => \@subscripLoop,
76
        routinglistview => 1
75
    routinglistview => 1
77
    );
76
);
78
77
79
    $template->param( adultborrower => 1 ) if ( $patron_info->{category_type} eq 'A' );
78
$template->param( adultborrower => 1 ) if ( $patron_info->{category_type} eq 'A' );
80
}
81
79
82
##################################################################################
80
##################################################################################
83
81
(-)a/members/setstatus.pl (-9 / +17 lines)
Lines 35-41 use Koha::Patrons; Link Here
35
35
36
my $input = new CGI;
36
my $input = new CGI;
37
37
38
checkauth($input, 0, { borrowers => 'edit_borrowers' }, 'intranet');
38
my ( $loggedinuser ) = checkauth($input, 0, { borrowers => 'edit_borrowers' }, 'intranet');
39
39
40
my $destination = $input->param("destination") || '';
40
my $destination = $input->param("destination") || '';
41
my $borrowernumber=$input->param('borrowernumber');
41
my $borrowernumber=$input->param('borrowernumber');
Lines 45-58 my $reregistration = $input->param('reregistration') || ''; Link Here
45
my $dbh = C4::Context->dbh;
45
my $dbh = C4::Context->dbh;
46
my $dateexpiry;
46
my $dateexpiry;
47
47
48
if ( $reregistration eq 'y' ) {
48
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
49
    # re-reregistration function to automatic calcul of date expiry
49
my $patron         = Koha::Patrons->find( $borrowernumber );
50
    $dateexpiry = Koha::Patrons->find( $borrowernumber )->renew_account;
50
51
} else {
51
# Ideally we should display a warning on the interface if the logged in user is
52
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
52
# not allowed to modify this patron.
53
    $sth->execute( $status, $borrowernumber );
53
# But a librarian is not supposed to hack the system
54
	$sth->finish;
54
unless ( $logged_in_user->can_see_patron_infos($patron) ) {
55
	}
55
    if ( $reregistration eq 'y' ) {
56
        # re-reregistration function to automatic calcul of date expiry
57
        $dateexpiry = $patron->renew_account;
58
    } else {
59
        my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
60
        $sth->execute( $status, $borrowernumber );
61
        $sth->finish;
62
    }
63
}
56
64
57
if($destination eq "circ"){
65
if($destination eq "circ"){
58
    if($dateexpiry){
66
    if($dateexpiry){
(-)a/members/statistics.pl (-7 / +3 lines)
Lines 47-59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
47
47
48
my $borrowernumber = $input->param('borrowernumber');
48
my $borrowernumber = $input->param('borrowernumber');
49
49
50
# Set informations for the patron
50
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
51
my $patron = Koha::Patrons->find( $borrowernumber );
51
my $patron         = Koha::Patrons->find( $borrowernumber );
52
unless ( $patron ) {
52
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
53
    $template->param (unknowuser => 1);
54
    output_html_with_http_headers $input, $cookie, $template->output;
55
    exit;
56
}
57
53
58
my $category = $patron->category;
54
my $category = $patron->category;
59
my $borrower= $patron->unblessed;
55
my $borrower= $patron->unblessed;
(-)a/members/summary-print.pl (-1 / +4 lines)
Lines 43-49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
43
    }
43
    }
44
);
44
);
45
45
46
my $patron = Koha::Patrons->find( $borrowernumber );
46
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
47
my $patron         = Koha::Patrons->find( $borrowernumber );
48
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
49
47
my $category = $patron->category;
50
my $category = $patron->category;
48
my $data = $patron->unblessed;
51
my $data = $patron->unblessed;
49
$data->{description} = $category->description;
52
$data->{description} = $category->description;
(-)a/members/update-child.pl (-2 / +4 lines)
Lines 58-63 my $cattype = $input->param('cattype'); Link Here
58
my $catcode_multi = $input->param('catcode_multi');
58
my $catcode_multi = $input->param('catcode_multi');
59
my $op             = $input->param('op');
59
my $op             = $input->param('op');
60
60
61
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
62
my $patron         = Koha::Patrons->find( $borrowernumber );
63
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
64
61
if ( $op eq 'multi' ) {
65
if ( $op eq 'multi' ) {
62
    # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
66
    # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
63
    #   currently just allowing C -> A
67
    #   currently just allowing C -> A
Lines 72-78 if ( $op eq 'multi' ) { Link Here
72
}
76
}
73
77
74
elsif ( $op eq 'update' ) {
78
elsif ( $op eq 'update' ) {
75
    my $patron = Koha::Patrons->find( $borrowernumber );
76
    my $member = $patron->unblessed;
79
    my $member = $patron->unblessed;
77
    $member->{'guarantorid'}  = 0;
80
    $member->{'guarantorid'}  = 0;
78
    $member->{'categorycode'} = $catcode;
81
    $member->{'categorycode'} = $catcode;
79
- 

Return to bug 18403