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

(-)a/C4/Acquisition.pm (-9 / +10 lines)
Lines 34-39 use Koha::Biblios; Link Here
34
use Koha::Number::Price;
34
use Koha::Number::Price;
35
use Koha::Libraries;
35
use Koha::Libraries;
36
use Koha::CsvProfiles;
36
use Koha::CsvProfiles;
37
use Koha::Patrons;
37
38
38
use C4::Koha;
39
use C4::Koha;
39
40
Lines 804-810 AcqViewBaskets, user permissions and basket properties (creator, users list, Link Here
804
branch).
805
branch).
805
806
806
First parameter can be either a borrowernumber or a hashref as returned by
807
First parameter can be either a borrowernumber or a hashref as returned by
807
C4::Members::GetMember.
808
Koha::Patron->unblessed
808
809
809
Second parameter can be either a basketno or a hashref as returned by
810
Second parameter can be either a basketno or a hashref as returned by
810
C4::Acquisition::GetBasket.
811
C4::Acquisition::GetBasket.
Lines 821-827 sub CanUserManageBasket { Link Here
821
    my ($borrower, $basket, $userflags) = @_;
822
    my ($borrower, $basket, $userflags) = @_;
822
823
823
    if (!ref $borrower) {
824
    if (!ref $borrower) {
824
        $borrower = C4::Members::GetMember(borrowernumber => $borrower);
825
        $borrower = Koha::Patrons->find( $borrower );
825
    }
826
    }
826
    if (!ref $basket) {
827
    if (!ref $basket) {
827
        $basket = GetBasket($basket);
828
        $basket = GetBasket($basket);
Lines 829-835 sub CanUserManageBasket { Link Here
829
830
830
    return 0 unless ($basket and $borrower);
831
    return 0 unless ($basket and $borrower);
831
832
832
    my $borrowernumber = $borrower->{borrowernumber};
833
    my $borrowernumber = $borrower->borrowernumber;
833
    my $basketno = $basket->{basketno};
834
    my $basketno = $basket->{basketno};
834
835
835
    my $AcqViewBaskets = C4::Context->preference('AcqViewBaskets');
836
    my $AcqViewBaskets = C4::Context->preference('AcqViewBaskets');
Lines 841-847 sub CanUserManageBasket { Link Here
841
        my ($flags) = $sth->fetchrow_array;
842
        my ($flags) = $sth->fetchrow_array;
842
        $sth->finish;
843
        $sth->finish;
843
844
844
        $userflags = C4::Auth::getuserflags($flags, $borrower->{userid}, $dbh);
845
        $userflags = C4::Auth::getuserflags($flags, $borrower->userid, $dbh);
845
    }
846
    }
846
847
847
    unless ($userflags->{superlibrarian}
848
    unless ($userflags->{superlibrarian}
Lines 864-870 sub CanUserManageBasket { Link Here
864
        }
865
        }
865
866
866
        if ($AcqViewBaskets eq 'branch' && defined $basket->{branch}
867
        if ($AcqViewBaskets eq 'branch' && defined $basket->{branch}
867
        && $basket->{branch} ne $borrower->{branchcode}) {
868
        && $basket->{branch} ne $borrower->branchcode) {
868
            return 0;
869
            return 0;
869
        }
870
        }
870
    }
871
    }
Lines 3081-3097 sub NotifyOrderUsers { Link Here
3081
3082
3082
    my $order = GetOrder( $ordernumber );
3083
    my $order = GetOrder( $ordernumber );
3083
    for my $borrowernumber (@borrowernumbers) {
3084
    for my $borrowernumber (@borrowernumbers) {
3084
        my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
3085
        my $patron = Koha::Patrons->find( $borrowernumber );
3085
        my $library = Koha::Libraries->find( $borrower->{branchcode} )->unblessed;
3086
        my $library = $patron->library->unblessed;
3086
        my $biblio = C4::Biblio::GetBiblio( $order->{biblionumber} );
3087
        my $biblio = C4::Biblio::GetBiblio( $order->{biblionumber} );
3087
        my $letter = C4::Letters::GetPreparedLetter(
3088
        my $letter = C4::Letters::GetPreparedLetter(
3088
            module      => 'acquisition',
3089
            module      => 'acquisition',
3089
            letter_code => 'ACQ_NOTIF_ON_RECEIV',
3090
            letter_code => 'ACQ_NOTIF_ON_RECEIV',
3090
            branchcode  => $library->{branchcode},
3091
            branchcode  => $library->{branchcode},
3091
            lang        => $borrower->{lang},
3092
            lang        => $patron->lang,
3092
            tables      => {
3093
            tables      => {
3093
                'branches'    => $library,
3094
                'branches'    => $library,
3094
                'borrowers'   => $borrower,
3095
                'borrowers'   => $patron->unblessed,
3095
                'biblio'      => $biblio,
3096
                'biblio'      => $biblio,
3096
                'aqorders'    => $order,
3097
                'aqorders'    => $order,
3097
            },
3098
            },
(-)a/C4/Auth.pm (-3 / +4 lines)
Lines 211-217 sub get_template_and_user { Link Here
211
211
212
    my $borrowernumber;
212
    my $borrowernumber;
213
    if ($user) {
213
    if ($user) {
214
        require C4::Members;
215
214
216
        # It's possible for $user to be the borrowernumber if they don't have a
215
        # It's possible for $user to be the borrowernumber if they don't have a
217
        # userid defined (and are logging in through some other method, such
216
        # userid defined (and are logging in through some other method, such
Lines 219-226 sub get_template_and_user { Link Here
219
        my $borrower;
218
        my $borrower;
220
        $borrowernumber = getborrowernumber($user) if defined($user);
219
        $borrowernumber = getborrowernumber($user) if defined($user);
221
        if ( !defined($borrowernumber) && defined($user) ) {
220
        if ( !defined($borrowernumber) && defined($user) ) {
222
            $borrower = C4::Members::GetMember( borrowernumber => $user );
221
            $borrower = Koha::Patrons->find( $user );
223
            if ($borrower) {
222
            if ($borrower) {
223
                $borrower = $borrower->unblessed;
224
                $borrowernumber = $user;
224
                $borrowernumber = $user;
225
225
226
                # A bit of a hack, but I don't know there's a nicer way
226
                # A bit of a hack, but I don't know there's a nicer way
Lines 228-234 sub get_template_and_user { Link Here
228
                $user = $borrower->{firstname} . ' ' . $borrower->{surname};
228
                $user = $borrower->{firstname} . ' ' . $borrower->{surname};
229
            }
229
            }
230
        } else {
230
        } else {
231
            $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
231
            $borrower = Koha::Patrons->find( $borrowernumber );
232
            $borrower->unblessed if $borrower; # FIXME Otherwise, what to do?
232
        }
233
        }
233
234
234
        # user info
235
        # user info
(-)a/C4/Budgets.pm (-2 / +3 lines)
Lines 21-26 use strict; Link Here
21
#use warnings; FIXME - Bug 2505
21
#use warnings; FIXME - Bug 2505
22
use C4::Context;
22
use C4::Context;
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::Patrons;
24
use C4::Debug;
25
use C4::Debug;
25
use vars qw(@ISA @EXPORT);
26
use vars qw(@ISA @EXPORT);
26
27
Lines 915-921 sub CanUserUseBudget { Link Here
915
    my ($borrower, $budget, $userflags) = @_;
916
    my ($borrower, $budget, $userflags) = @_;
916
917
917
    if (not ref $borrower) {
918
    if (not ref $borrower) {
918
        $borrower = C4::Members::GetMember(borrowernumber => $borrower);
919
        $borrower = Koha::Patrons->find( $borrower )->unblessed;
919
    }
920
    }
920
    if (not ref $budget) {
921
    if (not ref $budget) {
921
        $budget = GetBudget($budget);
922
        $budget = GetBudget($budget);
Lines 998-1004 sub CanUserModifyBudget { Link Here
998
    my ($borrower, $budget, $userflags) = @_;
999
    my ($borrower, $budget, $userflags) = @_;
999
1000
1000
    if (not ref $borrower) {
1001
    if (not ref $borrower) {
1001
        $borrower = C4::Members::GetMember(borrowernumber => $borrower);
1002
        $borrower = Koha::Patrons->find( $borrower )->unblessed;
1002
    }
1003
    }
1003
    if (not ref $budget) {
1004
    if (not ref $budget) {
1004
        $budget = GetBudget($budget);
1005
        $budget = GetBudget($budget);
(-)a/C4/Circulation.pm (-92 / +96 lines)
Lines 572-578 C<$issuingimpossible> and C<$needsconfirmation> are some hashref. Link Here
572
572
573
=over 4
573
=over 4
574
574
575
=item C<$borrower> hash with borrower informations (from GetMember)
575
=item C<$borrower> hash with borrower informations (from Koha::Patron->unblessed)
576
576
577
=item C<$barcode> is the bar code of the book being issued.
577
=item C<$barcode> is the bar code of the book being issued.
578
578
Lines 970-977 sub CanBookBeIssued { Link Here
970
    elsif ( $issue ) {
970
    elsif ( $issue ) {
971
971
972
        # issued to someone else
972
        # issued to someone else
973
        my $currborinfo =    C4::Members::GetMember( borrowernumber => $issue->borrowernumber );
974
973
974
        my $patron = Koha::Patrons->find( $issue->borrowernumber );
975
975
976
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
976
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
977
977
Lines 980-989 sub CanBookBeIssued { Link Here
980
            $issuingimpossible{branch_to_return} = $message;
980
            $issuingimpossible{branch_to_return} = $message;
981
        } else {
981
        } else {
982
            $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
982
            $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
983
            $needsconfirmation{issued_firstname} = $currborinfo->{'firstname'};
983
            $needsconfirmation{issued_firstname} = $patron->firstname;
984
            $needsconfirmation{issued_surname} = $currborinfo->{'surname'};
984
            $needsconfirmation{issued_surname} = $patron->surname;
985
            $needsconfirmation{issued_cardnumber} = $currborinfo->{'cardnumber'};
985
            $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
986
            $needsconfirmation{issued_borrowernumber} = $currborinfo->{'borrowernumber'};
986
            $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
987
        }
987
        }
988
    }
988
    }
989
989
Lines 993-1020 sub CanBookBeIssued { Link Here
993
        if ($restype) {
993
        if ($restype) {
994
            my $resbor = $res->{'borrowernumber'};
994
            my $resbor = $res->{'borrowernumber'};
995
            if ( $resbor ne $borrower->{'borrowernumber'} ) {
995
            if ( $resbor ne $borrower->{'borrowernumber'} ) {
996
                my ( $resborrower ) = C4::Members::GetMember( borrowernumber => $resbor );
996
                my $patron = Koha::Patrons->find( $resbor );
997
                if ( $restype eq "Waiting" )
997
                if ( $restype eq "Waiting" )
998
                {
998
                {
999
                    # The item is on reserve and waiting, but has been
999
                    # The item is on reserve and waiting, but has been
1000
                    # reserved by some other patron.
1000
                    # reserved by some other patron.
1001
                    $needsconfirmation{RESERVE_WAITING} = 1;
1001
                    $needsconfirmation{RESERVE_WAITING} = 1;
1002
                    $needsconfirmation{'resfirstname'} = $resborrower->{'firstname'};
1002
                    $needsconfirmation{'resfirstname'} = $patron->firstname;
1003
                    $needsconfirmation{'ressurname'} = $resborrower->{'surname'};
1003
                    $needsconfirmation{'ressurname'} = $patron->surname;
1004
                    $needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
1004
                    $needsconfirmation{'rescardnumber'} = $patron->cardnumber;
1005
                    $needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
1005
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1006
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1006
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1007
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1007
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1008
                }
1008
                }
1009
                elsif ( $restype eq "Reserved" ) {
1009
                elsif ( $restype eq "Reserved" ) {
1010
                    # The item is on reserve for someone else.
1010
                    # The item is on reserve for someone else.
1011
                    $needsconfirmation{RESERVED} = 1;
1011
                    $needsconfirmation{RESERVED} = 1;
1012
                    $needsconfirmation{'resfirstname'} = $resborrower->{'firstname'};
1012
                    $needsconfirmation{'resfirstname'} = $patron->firstname;
1013
                    $needsconfirmation{'ressurname'} = $resborrower->{'surname'};
1013
                    $needsconfirmation{'ressurname'} = $patron->surname;
1014
                    $needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
1014
                    $needsconfirmation{'rescardnumber'} = $patron->cardnumber;
1015
                    $needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
1015
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1016
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1016
                    $needsconfirmation{'resbranchcode'} = $patron->branchcode;
1017
                    $needsconfirmation{'resreservedate'} = $res->{'reservedate'};
1017
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1018
                }
1018
                }
1019
            }
1019
            }
1020
        }
1020
        }
Lines 1238-1244 Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this Link Here
1238
1238
1239
=over 4
1239
=over 4
1240
1240
1241
=item C<$borrower> is a hash with borrower informations (from GetMember).
1241
=item C<$borrower> is a hash with borrower informations (from Koha::Patron->unblessed).
1242
1242
1243
=item C<$barcode> is the barcode of the item being issued.
1243
=item C<$barcode> is the barcode of the item being issued.
1244
1244
Lines 1816-1822 sub AddReturn { Link Here
1816
    }
1816
    }
1817
    $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
1817
    $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
1818
    my $messages;
1818
    my $messages;
1819
    my $borrower;
1819
    my $patron;
1820
    my $doreturn       = 1;
1820
    my $doreturn       = 1;
1821
    my $validTransfert = 0;
1821
    my $validTransfert = 0;
1822
    my $stat_type = 'return';
1822
    my $stat_type = 'return';
Lines 1835-1841 sub AddReturn { Link Here
1835
1835
1836
    my $issue  = Koha::Checkouts->find( { itemnumber => $itemnumber } );
1836
    my $issue  = Koha::Checkouts->find( { itemnumber => $itemnumber } );
1837
    if ( $issue ) {
1837
    if ( $issue ) {
1838
        $borrower = C4::Members::GetMember( borrowernumber => $issue->borrowernumber )
1838
        $patron = Koha::Patrons->find( $issue->borrowernumber )
1839
            or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existent borrowernumber '" . $issue->borrowernumber . "'\n"
1839
            or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existent borrowernumber '" . $issue->borrowernumber . "'\n"
1840
                . Dumper($issue->unblessed) . "\n";
1840
                . Dumper($issue->unblessed) . "\n";
1841
    } else {
1841
    } else {
Lines 1868-1874 sub AddReturn { Link Here
1868
    my $returnbranch = $item->{$hbr} || $branch ;
1868
    my $returnbranch = $item->{$hbr} || $branch ;
1869
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1869
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1870
1870
1871
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1871
    my $borrowernumber = $patron ? $patron->borrowernumber : undef;    # we don't know if we had a borrower or not
1872
    my $patron_unblessed = $patron ? $patron->unblessed : {};
1872
1873
1873
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1874
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1874
    if ($yaml) {
1875
    if ($yaml) {
Lines 1907-1913 sub AddReturn { Link Here
1907
            Rightbranch => $message
1908
            Rightbranch => $message
1908
        };
1909
        };
1909
        $doreturn = 0;
1910
        $doreturn = 0;
1910
        return ( $doreturn, $messages, $issue, $borrower );
1911
        return ( $doreturn, $messages, $issue, $patron_unblessed);
1911
    }
1912
    }
1912
1913
1913
    if ( $item->{'withdrawn'} ) { # book has been cancelled
1914
    if ( $item->{'withdrawn'} ) { # book has been cancelled
Lines 1921-1948 sub AddReturn { Link Here
1921
    if ($doreturn) {
1922
    if ($doreturn) {
1922
        my $is_overdue;
1923
        my $is_overdue;
1923
        die "The item is not issed and cannot be returned" unless $issue; # Just in case...
1924
        die "The item is not issed and cannot be returned" unless $issue; # Just in case...
1924
        $borrower or warn "AddReturn without current borrower";
1925
        $patron or warn "AddReturn without current borrower";
1925
		my $circControlBranch;
1926
		my $circControlBranch;
1926
        if ($dropbox) {
1927
        if ($dropbox) {
1927
            # define circControlBranch only if dropbox mode is set
1928
            # define circControlBranch only if dropbox mode is set
1928
            # don't allow dropbox mode to create an invalid entry in issues (issuedate > today)
1929
            # don't allow dropbox mode to create an invalid entry in issues (issuedate > today)
1929
            # FIXME: check issuedate > returndate, factoring in holidays
1930
            # FIXME: check issuedate > returndate, factoring in holidays
1930
1931
1931
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1932
            $circControlBranch = _GetCircControlBranch($item,$patron_unblessed);
1932
            $is_overdue = $issue->is_overdue( $dropboxdate );
1933
            $is_overdue = $issue->is_overdue( $dropboxdate );
1933
        } else {
1934
        } else {
1934
            $is_overdue = $issue->is_overdue;
1935
            $is_overdue = $issue->is_overdue;
1935
        }
1936
        }
1936
1937
1937
        if ($borrowernumber) {
1938
        if ($patron) {
1938
            eval {
1939
            eval {
1939
                my $issue_id = MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
1940
                my $issue_id = MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
1940
                    $circControlBranch, $return_date, $borrower->{'privacy'} );
1941
                    $circControlBranch, $return_date, $patron->privacy );
1941
                $issue->issue_id($issue_id);
1942
                $issue->issue_id($issue_id);
1942
            };
1943
            };
1943
            unless ( $@ ) {
1944
            unless ( $@ ) {
1944
                if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) {
1945
                if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) {
1945
                    _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $borrower, return_date => $return_date } );
1946
                    _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed, return_date => $return_date } );
1946
                }
1947
                }
1947
            } else {
1948
            } else {
1948
                $messages->{'Wrongbranch'} = {
1949
                $messages->{'Wrongbranch'} = {
Lines 1950-1956 sub AddReturn { Link Here
1950
                    Rightbranch => $message
1951
                    Rightbranch => $message
1951
                };
1952
                };
1952
                carp $@;
1953
                carp $@;
1953
                return ( 0, { WasReturned => 0 }, $issue, $borrower );
1954
                return ( 0, { WasReturned => 0 }, $issue, $patron_unblessed );
1954
            }
1955
            }
1955
1956
1956
            # FIXME is the "= 1" right?  This could be the borrower hash.
1957
            # FIXME is the "= 1" right?  This could be the borrower hash.
Lines 2022-2043 sub AddReturn { Link Here
2022
        if ( $issue and $issue->is_overdue ) {
2023
        if ( $issue and $issue->is_overdue ) {
2023
        # fix fine days
2024
        # fix fine days
2024
            $today = $dropboxdate if $dropbox;
2025
            $today = $dropboxdate if $dropbox;
2025
            my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, dt_from_string($issue->date_due), $today );
2026
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item, dt_from_string($issue->date_due), $today );
2026
            if ($reminder){
2027
            if ($reminder){
2027
                $messages->{'PrevDebarred'} = $debardate;
2028
                $messages->{'PrevDebarred'} = $debardate;
2028
            } else {
2029
            } else {
2029
                $messages->{'Debarred'} = $debardate if $debardate;
2030
                $messages->{'Debarred'} = $debardate if $debardate;
2030
            }
2031
            }
2031
        # there's no overdue on the item but borrower had been previously debarred
2032
        # there's no overdue on the item but borrower had been previously debarred
2032
        } elsif ( $issue->date_due and $borrower->{'debarred'} ) {
2033
        } elsif ( $issue->date_due and $patron->debarred ) {
2033
             if ( $borrower->{debarred} eq "9999-12-31") {
2034
             if ( $patron->debarred eq "9999-12-31") {
2034
                $messages->{'ForeverDebarred'} = $borrower->{'debarred'};
2035
                $messages->{'ForeverDebarred'} = $patron->debarred;
2035
             } else {
2036
             } else {
2036
                  my $borrower_debar_dt = dt_from_string( $borrower->{debarred} );
2037
                  my $borrower_debar_dt = dt_from_string( $patron->debarred );
2037
                  $borrower_debar_dt->truncate(to => 'day');
2038
                  $borrower_debar_dt->truncate(to => 'day');
2038
                  my $today_dt = $today->clone()->truncate(to => 'day');
2039
                  my $today_dt = $today->clone()->truncate(to => 'day');
2039
                  if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) {
2040
                  if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) {
2040
                      $messages->{'PrevDebarred'} = $borrower->{'debarred'};
2041
                      $messages->{'PrevDebarred'} = $patron->debarred;
2041
                  }
2042
                  }
2042
             }
2043
             }
2043
        }
2044
        }
Lines 2063-2091 sub AddReturn { Link Here
2063
        ccode          => $item->{ ccode }
2064
        ccode          => $item->{ ccode }
2064
    });
2065
    });
2065
2066
2066
    # Send a check-in slip. # NOTE: borrower may be undef.  probably shouldn't try to send messages then.
2067
    # Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then.
2067
    my $circulation_alert = 'C4::ItemCirculationAlertPreference';
2068
    if ( $patron ) {
2068
    my %conditions = (
2069
        my $circulation_alert = 'C4::ItemCirculationAlertPreference';
2069
        branchcode   => $branch,
2070
        my %conditions = (
2070
        categorycode => $borrower->{categorycode},
2071
            branchcode   => $branch,
2071
        item_type    => $item->{itype},
2072
            categorycode => $patron->categorycode,
2072
        notification => 'CHECKIN',
2073
            item_type    => $item->{itype},
2073
    );
2074
            notification => 'CHECKIN',
2074
    if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
2075
        );
2075
        SendCirculationAlert({
2076
        if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
2076
            type     => 'CHECKIN',
2077
            SendCirculationAlert({
2077
            item     => $item,
2078
                type     => 'CHECKIN',
2078
            borrower => $borrower,
2079
                item     => $item,
2079
            branch   => $branch,
2080
                borrower => $patron->unblessed,
2080
        });
2081
                branch   => $branch,
2081
    }
2082
            });
2082
    
2083
        }
2083
    logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
2084
2084
        if C4::Context->preference("ReturnLog");
2085
        logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
2085
    
2086
            if C4::Context->preference("ReturnLog");
2087
        }
2088
2086
    # Remove any OVERDUES related debarment if the borrower has no overdues
2089
    # Remove any OVERDUES related debarment if the borrower has no overdues
2087
    if ( $borrowernumber
2090
    if ( $borrowernumber
2088
      && $borrower->{'debarred'}
2091
      && $patron->debarred
2089
      && C4::Context->preference('AutoRemoveOverduesRestrictions')
2092
      && C4::Context->preference('AutoRemoveOverduesRestrictions')
2090
      && !Koha::Patrons->find( $borrowernumber )->has_overdues
2093
      && !Koha::Patrons->find( $borrowernumber )->has_overdues
2091
      && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
2094
      && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
Lines 2108-2114 sub AddReturn { Link Here
2108
        }
2111
        }
2109
    }
2112
    }
2110
2113
2111
    return ( $doreturn, $messages, $issue, $borrower );
2114
    return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ));
2112
}
2115
}
2113
2116
2114
=head2 MarkIssueReturned
2117
=head2 MarkIssueReturned
Lines 2145-2151 sub MarkIssueReturned { Link Here
2145
        # Note that a warning should appear on the about page (System information tab).
2148
        # Note that a warning should appear on the about page (System information tab).
2146
        $anonymouspatron = C4::Context->preference('AnonymousPatron');
2149
        $anonymouspatron = C4::Context->preference('AnonymousPatron');
2147
        die "Fatal error: the patron ($borrowernumber) has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or not set correctly."
2150
        die "Fatal error: the patron ($borrowernumber) has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or not set correctly."
2148
            unless C4::Members::GetMember( borrowernumber => $anonymouspatron );
2151
            unless Koha::Patrons->find( $anonymouspatron );
2149
    }
2152
    }
2150
    my $database = Koha::Database->new();
2153
    my $database = Koha::Database->new();
2151
    my $schema   = $database->schema;
2154
    my $schema   = $database->schema;
Lines 2628-2634 sub CanBookBeRenewed { Link Here
2628
    return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout;
2631
    return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout;
2629
2632
2630
    $borrowernumber ||= $issue->borrowernumber;
2633
    $borrowernumber ||= $issue->borrowernumber;
2631
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2634
    my $patron = Koha::Patrons->find( $borrowernumber )
2632
      or return;
2635
      or return;
2633
2636
2634
    my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber);
2637
    my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber);
Lines 2682-2688 sub CanBookBeRenewed { Link Here
2682
                my $item = GetItem($i);
2685
                my $item = GetItem($i);
2683
                next if IsItemOnHoldAndFound($i);
2686
                next if IsItemOnHoldAndFound($i);
2684
                for my $b (@borrowernumbers) {
2687
                for my $b (@borrowernumbers) {
2685
                    my $borr = $borrowers{$b}//= C4::Members::GetMember(borrowernumber => $b);
2688
                    my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed;
2686
                    next unless IsAvailableForItemLevelRequest($item, $borr);
2689
                    next unless IsAvailableForItemLevelRequest($item, $borr);
2687
                    next unless CanItemBeReserved($b,$i);
2690
                    next unless CanItemBeReserved($b,$i);
2688
2691
Lines 2700-2708 sub CanBookBeRenewed { Link Here
2700
2703
2701
    return ( 1, undef ) if $override_limit;
2704
    return ( 1, undef ) if $override_limit;
2702
2705
2703
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2706
    my $branchcode = _GetCircControlBranch( $item, $patron->unblessed );
2704
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
2707
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
2705
        {   categorycode => $borrower->{categorycode},
2708
        {   categorycode => $patron->categorycode,
2706
            itemtype     => $item->{itype},
2709
            itemtype     => $item->{itype},
2707
            branchcode   => $branchcode
2710
            branchcode   => $branchcode
2708
        }
2711
        }
Lines 2713-2719 sub CanBookBeRenewed { Link Here
2713
2716
2714
    my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2717
    my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2715
    my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2718
    my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2716
    my $patron      = Koha::Patrons->find($borrowernumber);
2719
    $patron         = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful?
2717
    my $restricted  = $patron->is_debarred;
2720
    my $restricted  = $patron->is_debarred;
2718
    my $hasoverdues = $patron->has_overdues;
2721
    my $hasoverdues = $patron->has_overdues;
2719
2722
Lines 2747-2753 sub CanBookBeRenewed { Link Here
2747
2750
2748
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2751
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2749
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2752
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2750
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2753
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($patron->borrowernumber);
2751
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2754
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2752
                return ( 0, "auto_too_much_oweing" );
2755
                return ( 0, "auto_too_much_oweing" );
2753
            }
2756
            }
Lines 2839-2848 sub AddRenewal { Link Here
2839
        return;
2842
        return;
2840
    }
2843
    }
2841
2844
2842
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return;
2845
    my $patron = Koha::Patrons->find( $borrowernumber ) or return; # FIXME Should do more than just return
2846
    my $patron_unblessed = $patron->unblessed;
2843
2847
2844
    if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) {
2848
    if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) {
2845
        _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $borrower } );
2849
        _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } );
2846
    }
2850
    }
2847
    _FixOverduesOnReturn( $borrowernumber, $itemnumber );
2851
    _FixOverduesOnReturn( $borrowernumber, $itemnumber );
2848
2852
Lines 2856-2862 sub AddRenewal { Link Here
2856
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2860
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2857
                                        dt_from_string( $issue->date_due, 'sql' ) :
2861
                                        dt_from_string( $issue->date_due, 'sql' ) :
2858
                                        DateTime->now( time_zone => C4::Context->tz());
2862
                                        DateTime->now( time_zone => C4::Context->tz());
2859
        $datedue =  CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $borrower), $borrower, 'is a renewal');
2863
        $datedue =  CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal');
2860
    }
2864
    }
2861
2865
2862
    # Update the issues record to have the new due date, and a new count
2866
    # Update the issues record to have the new due date, and a new count
Lines 2893-2903 sub AddRenewal { Link Here
2893
2897
2894
    # Send a renewal slip according to checkout alert preferencei
2898
    # Send a renewal slip according to checkout alert preferencei
2895
    if ( C4::Context->preference('RenewalSendNotice') eq '1' ) {
2899
    if ( C4::Context->preference('RenewalSendNotice') eq '1' ) {
2896
        $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
2897
        my $circulation_alert = 'C4::ItemCirculationAlertPreference';
2900
        my $circulation_alert = 'C4::ItemCirculationAlertPreference';
2898
        my %conditions        = (
2901
        my %conditions        = (
2899
            branchcode   => $branch,
2902
            branchcode   => $branch,
2900
            categorycode => $borrower->{categorycode},
2903
            categorycode => $patron->categorycode,
2901
            item_type    => $item->{itype},
2904
            item_type    => $item->{itype},
2902
            notification => 'CHECKOUT',
2905
            notification => 'CHECKOUT',
2903
        );
2906
        );
Lines 2906-2912 sub AddRenewal { Link Here
2906
                {
2909
                {
2907
                    type     => 'RENEWAL',
2910
                    type     => 'RENEWAL',
2908
                    item     => $item,
2911
                    item     => $item,
2909
                    borrower => $borrower,
2912
                    borrower => $patron->unblessed,
2910
                    branch   => $branch,
2913
                    branch   => $branch,
2911
                }
2914
                }
2912
            );
2915
            );
Lines 2914-2923 sub AddRenewal { Link Here
2914
    }
2917
    }
2915
2918
2916
    # Remove any OVERDUES related debarment if the borrower has no overdues
2919
    # Remove any OVERDUES related debarment if the borrower has no overdues
2917
    $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
2920
    if ( $patron
2918
    if ( $borrowernumber
2921
      && $patron->is_debarred
2919
      && $borrower->{'debarred'}
2922
      && ! $patron->has_overdues
2920
      && !Koha::Patrons->find( $borrowernumber )->has_overdues
2921
      && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
2923
      && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
2922
    ) {
2924
    ) {
2923
        DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
2925
        DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
Lines 2949-2956 sub GetRenewCount { Link Here
2949
    my $renewsallowed = 0;
2951
    my $renewsallowed = 0;
2950
    my $renewsleft    = 0;
2952
    my $renewsleft    = 0;
2951
2953
2952
    my $borrower = C4::Members::GetMember( borrowernumber => $bornum);
2954
    my $patron = Koha::Patrons->find( $bornum );
2953
    my $item     = GetItem($itemno); 
2955
    my $item     = GetItem($itemno);
2956
2957
    return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed
2954
2958
2955
    # Look in the issues table for this item, lent to this borrower,
2959
    # Look in the issues table for this item, lent to this borrower,
2956
    # and not yet returned.
2960
    # and not yet returned.
Lines 2965-2980 sub GetRenewCount { Link Here
2965
    my $data = $sth->fetchrow_hashref;
2969
    my $data = $sth->fetchrow_hashref;
2966
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
2970
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
2967
    # $item and $borrower should be calculated
2971
    # $item and $borrower should be calculated
2968
    my $branchcode = _GetCircControlBranch($item, $borrower);
2972
    my $branchcode = _GetCircControlBranch($item, $patron->unblessed);
2969
2973
2970
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
2974
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
2971
        {   categorycode => $borrower->{categorycode},
2975
        {   categorycode => $patron->categorycode,
2972
            itemtype     => $item->{itype},
2976
            itemtype     => $item->{itype},
2973
            branchcode   => $branchcode
2977
            branchcode   => $branchcode
2974
        }
2978
        }
2975
    );
2979
    );
2976
2980
2977
    $renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : undef; # FIXME Just replace undef with 0 to get what we expected. But what about the side-effects? TODO LATER
2981
    $renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : 0;
2978
    $renewsleft    = $renewsallowed - $renewcount;
2982
    $renewsleft    = $renewsallowed - $renewcount;
2979
    if($renewsleft < 0){ $renewsleft = 0; }
2983
    if($renewsleft < 0){ $renewsleft = 0; }
2980
    return ( $renewcount, $renewsallowed, $renewsleft );
2984
    return ( $renewcount, $renewsallowed, $renewsleft );
Lines 3008-3019 sub GetSoonestRenewDate { Link Here
3008
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3012
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3009
3013
3010
    $borrowernumber ||= $itemissue->borrowernumber;
3014
    $borrowernumber ||= $itemissue->borrowernumber;
3011
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3015
    my $patron = Koha::Patrons->find( $borrowernumber )
3012
      or return;
3016
      or return;
3013
3017
3014
    my $branchcode = _GetCircControlBranch( $item, $borrower );
3018
    my $branchcode = _GetCircControlBranch( $item, $patron->unblessed );
3015
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
3019
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
3016
        {   categorycode => $borrower->{categorycode},
3020
        {   categorycode => $patron->categorycode,
3017
            itemtype     => $item->{itype},
3021
            itemtype     => $item->{itype},
3018
            branchcode   => $branchcode
3022
            branchcode   => $branchcode
3019
        }
3023
        }
Lines 3067-3078 sub GetLatestAutoRenewDate { Link Here
3067
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3071
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3068
3072
3069
    $borrowernumber ||= $itemissue->borrowernumber;
3073
    $borrowernumber ||= $itemissue->borrowernumber;
3070
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3074
    my $patron = Koha::Patrons->find( $borrowernumber )
3071
      or return;
3075
      or return;
3072
3076
3073
    my $branchcode = _GetCircControlBranch( $item, $borrower );
3077
    my $branchcode = _GetCircControlBranch( $item, $patron->unblessed );
3074
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
3078
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
3075
        {   categorycode => $borrower->{categorycode},
3079
        {   categorycode => $patron->categorycode,
3076
            itemtype     => $item->{itype},
3080
            itemtype     => $item->{itype},
3077
            branchcode   => $branchcode
3081
            branchcode   => $branchcode
3078
        }
3082
        }
Lines 3616-3627 sub ReturnLostItem{ Link Here
3616
    my ( $borrowernumber, $itemnum ) = @_;
3620
    my ( $borrowernumber, $itemnum ) = @_;
3617
3621
3618
    MarkIssueReturned( $borrowernumber, $itemnum );
3622
    MarkIssueReturned( $borrowernumber, $itemnum );
3619
    my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber );
3623
    my $patron = Koha::Patrons->find( $borrowernumber );
3620
    my $item = C4::Items::GetItem( $itemnum );
3624
    my $item = C4::Items::GetItem( $itemnum );
3621
    my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{};
3625
    my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{};
3622
    my @datearr = localtime(time);
3626
    my @datearr = localtime(time);
3623
    my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
3627
    my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
3624
    my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
3628
    my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber;
3625
    ModItem({ paidfor =>  $old_note."Paid for by $bor $date" }, undef, $itemnum);
3629
    ModItem({ paidfor =>  $old_note."Paid for by $bor $date" }, undef, $itemnum);
3626
}
3630
}
3627
3631
Lines 3640-3646 sub LostItem{ Link Here
3640
3644
3641
    # If a borrower lost the item, add a replacement cost to the their record
3645
    # If a borrower lost the item, add a replacement cost to the their record
3642
    if ( my $borrowernumber = $issues->{borrowernumber} ){
3646
    if ( my $borrowernumber = $issues->{borrowernumber} ){
3643
        my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
3647
        my $patron = Koha::Patrons->find( $borrowernumber );
3644
3648
3645
        if (C4::Context->preference('WhenLostForgiveFine')){
3649
        if (C4::Context->preference('WhenLostForgiveFine')){
3646
            my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, 1, 0); # 1, 0 = exemptfine, no-dropbox
3650
            my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, 1, 0); # 1, 0 = exemptfine, no-dropbox
Lines 3652-3658 sub LostItem{ Link Here
3652
            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
3656
            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
3653
        }
3657
        }
3654
3658
3655
        MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$borrower->{'privacy'}) if $mark_returned;
3659
        MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$patron->privacy) if $mark_returned;
3656
    }
3660
    }
3657
}
3661
}
3658
3662
Lines 3736-3751 sub ProcessOfflineReturn { Link Here
3736
sub ProcessOfflineIssue {
3740
sub ProcessOfflineIssue {
3737
    my $operation = shift;
3741
    my $operation = shift;
3738
3742
3739
    my $borrower = C4::Members::GetMember( cardnumber => $operation->{cardnumber} );
3743
    my $patron = Koha::Patrons->find( { cardnumber => $operation->{cardnumber} } );
3740
3744
3741
    if ( $borrower->{borrowernumber} ) {
3745
    if ( $patron ) {
3742
        my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} );
3746
        my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} );
3743
        unless ($itemnumber) {
3747
        unless ($itemnumber) {
3744
            return "Barcode not found.";
3748
            return "Barcode not found.";
3745
        }
3749
        }
3746
        my $issue = GetOpenIssue( $itemnumber );
3750
        my $issue = GetOpenIssue( $itemnumber );
3747
3751
3748
        if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned
3752
        if ( $issue and ( $issue->{borrowernumber} ne $patron->borrowernumber ) ) { # Item already issued to another patron mark it returned
3749
            MarkIssueReturned(
3753
            MarkIssueReturned(
3750
                $issue->{borrowernumber},
3754
                $issue->{borrowernumber},
3751
                $itemnumber,
3755
                $itemnumber,
Lines 3754-3760 sub ProcessOfflineIssue { Link Here
3754
            );
3758
            );
3755
        }
3759
        }
3756
        AddIssue(
3760
        AddIssue(
3757
            $borrower,
3761
            $patron->unblessed,
3758
            $operation->{'barcode'},
3762
            $operation->{'barcode'},
3759
            undef,
3763
            undef,
3760
            1,
3764
            1,
(-)a/C4/HoldsQueue.pm (-5 / +6 lines)
Lines 29-34 use C4::Circulation; Link Here
29
use C4::Members;
29
use C4::Members;
30
use C4::Biblio;
30
use C4::Biblio;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Patrons;
32
33
33
use List::Util qw(shuffle);
34
use List::Util qw(shuffle);
34
use List::MoreUtils qw(any);
35
use List::MoreUtils qw(any);
Lines 677-687 sub CreatePicklistFromItemMap { Link Here
677
        my $barcode = $item->{barcode};
678
        my $barcode = $item->{barcode};
678
        my $itemcallnumber = $item->{itemcallnumber};
679
        my $itemcallnumber = $item->{itemcallnumber};
679
680
680
        my $borrower = GetMember('borrowernumber'=>$borrowernumber);
681
        my $patron = Koha::Patrons->find( $borrowernumber );
681
        my $cardnumber = $borrower->{'cardnumber'};
682
        my $cardnumber = $patron->cardnumber;
682
        my $surname = $borrower->{'surname'};
683
        my $surname = $patron->surname;
683
        my $firstname = $borrower->{'firstname'};
684
        my $firstname = $patron->firstname;
684
        my $phone = $borrower->{'phone'};
685
        my $phone = $patron->phone;
685
686
686
        my $bib = GetBiblioData($biblionumber);
687
        my $bib = GetBiblioData($biblionumber);
687
        my $title = $bib->{title};
688
        my $title = $bib->{title};
(-)a/C4/ILSDI/Services.pm (-31 / +23 lines)
Lines 306-323 Parameters: Link Here
306
sub LookupPatron {
306
sub LookupPatron {
307
    my ($cgi) = @_;
307
    my ($cgi) = @_;
308
308
309
    # Get the borrower...
309
    my $patrons = Koha::Patrons->search( { $cgi->param('id_type') => $cgi->param('id') } );
310
    my $borrower = GetMember($cgi->param('id_type') => $cgi->param('id'));
310
    unless ( $patrons->count ) {
311
    if ( not $borrower->{'borrowernumber'} ) {
312
        return { message => 'PatronNotFound' };
311
        return { message => 'PatronNotFound' };
313
    }
312
    }
314
313
315
    # Build the hashref
314
    return { id => $patrons->next->borrowernumber };
316
    my $patron->{'id'} = $borrower->{'borrowernumber'};
317
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
318
319
    # ...and return his ID
320
    return $patron;
321
}
315
}
322
316
323
=head2 AuthenticatePatron
317
=head2 AuthenticatePatron
Lines 341-349 sub AuthenticatePatron { Link Here
341
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password );
335
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password );
342
    if ( $status ) {
336
    if ( $status ) {
343
        # Get the borrower
337
        # Get the borrower
344
        my $borrower = GetMember( cardnumber => $cardnumber );
338
        my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
345
        my $patron->{'id'} = $borrower->{'borrowernumber'};
339
        return { id => $patron->borrowernumber };
346
        return $patron;
347
    }
340
    }
348
    else {
341
    else {
349
        return { code => 'PatronNotFound' };
342
        return { code => 'PatronNotFound' };
Lines 376-386 sub GetPatronInfo { Link Here
376
369
377
    # Get Member details
370
    # Get Member details
378
    my $borrowernumber = $cgi->param('patron_id');
371
    my $borrowernumber = $cgi->param('patron_id');
379
    my $borrower = GetMember( borrowernumber => $borrowernumber );
380
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
381
    my $patron = Koha::Patrons->find( $borrowernumber );
372
    my $patron = Koha::Patrons->find( $borrowernumber );
373
    return { code => 'PatronNotFound' } unless $patron;
382
374
383
    # Cleaning the borrower hashref
375
    # Cleaning the borrower hashref
376
    my $borrower = $patron->unblessed;
384
    my $flags = C4::Members::patronflags( $borrower );
377
    my $flags = C4::Members::patronflags( $borrower );
385
    $borrower->{'charges'} = $flags->{'CHARGES'}->{'amount'};
378
    $borrower->{'charges'} = $flags->{'CHARGES'}->{'amount'};
386
    my $library = Koha::Libraries->find( $borrower->{branchcode} );
379
    my $library = Koha::Libraries->find( $borrower->{branchcode} );
Lines 473-486 sub GetPatronStatus { Link Here
473
466
474
    # Get Member details
467
    # Get Member details
475
    my $borrowernumber = $cgi->param('patron_id');
468
    my $borrowernumber = $cgi->param('patron_id');
476
    my $borrower = GetMember( borrowernumber => $borrowernumber );
469
    my $patron = Koha::Patrons->find( $borrowernumber );
477
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
470
    return { code => 'PatronNotFound' } unless $patron;
478
471
479
    # Return the results
472
    # Return the results
480
    return {
473
    return {
481
        type   => $$borrower{categorycode},
474
        type   => $patron->categorycode,
482
        status => 0, # TODO
475
        status => 0, # TODO
483
        expiry => $$borrower{dateexpiry},
476
        expiry => $patron->dateexpiry,
484
    };
477
    };
485
}
478
}
486
479
Lines 503-513 sub GetServices { Link Here
503
496
504
    # Get the member, or return an error code if not found
497
    # Get the member, or return an error code if not found
505
    my $borrowernumber = $cgi->param('patron_id');
498
    my $borrowernumber = $cgi->param('patron_id');
506
    my $borrower = GetMember( borrowernumber => $borrowernumber );
507
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
508
509
    my $patron = Koha::Patrons->find( $borrowernumber );
499
    my $patron = Koha::Patrons->find( $borrowernumber );
500
    return { code => 'PatronNotFound' } unless $patron;
510
501
502
    my $borrower = $patron->unblessed;
511
    # Get the item, or return an error code if not found
503
    # Get the item, or return an error code if not found
512
    my $itemnumber = $cgi->param('item_id');
504
    my $itemnumber = $cgi->param('item_id');
513
    my $item = GetItem( $itemnumber );
505
    my $item = GetItem( $itemnumber );
Lines 577-584 sub RenewLoan { Link Here
577
569
578
    # Get borrower infos or return an error code
570
    # Get borrower infos or return an error code
579
    my $borrowernumber = $cgi->param('patron_id');
571
    my $borrowernumber = $cgi->param('patron_id');
580
    my $borrower = GetMember( borrowernumber => $borrowernumber );
572
    my $patron = Koha::Patrons->find( $borrowernumber );
581
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
573
    return { code => 'PatronNotFound' } unless $patron;
582
574
583
    # Get the item, or return an error code
575
    # Get the item, or return an error code
584
    my $itemnumber = $cgi->param('item_id');
576
    my $itemnumber = $cgi->param('item_id');
Lines 627-634 sub HoldTitle { Link Here
627
619
628
    # Get the borrower or return an error code
620
    # Get the borrower or return an error code
629
    my $borrowernumber = $cgi->param('patron_id');
621
    my $borrowernumber = $cgi->param('patron_id');
630
    my $borrower = GetMember( borrowernumber => $borrowernumber );
622
    my $patron = Koha::Patrons->find( $borrowernumber );
631
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
623
    return { code => 'PatronNotFound' } unless $patron;
632
624
633
    # Get the biblio record, or return an error code
625
    # Get the biblio record, or return an error code
634
    my $biblionumber = $cgi->param('bib_id');
626
    my $biblionumber = $cgi->param('bib_id');
Lines 647-653 sub HoldTitle { Link Here
647
        $branch = $cgi->param('pickup_location');
639
        $branch = $cgi->param('pickup_location');
648
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
640
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
649
    } else { # if the request provide no branch, use the borrower's branch
641
    } else { # if the request provide no branch, use the borrower's branch
650
        $branch = $$borrower{branchcode};
642
        $branch = $patron->branchcode;
651
    }
643
    }
652
644
653
    # Add the reserve
645
    # Add the reserve
Lines 695-702 sub HoldItem { Link Here
695
687
696
    # Get the borrower or return an error code
688
    # Get the borrower or return an error code
697
    my $borrowernumber = $cgi->param('patron_id');
689
    my $borrowernumber = $cgi->param('patron_id');
698
    my $borrower = GetMember( borrowernumber => $borrowernumber );
690
    my $patron = Koha::Patrons->find( $borrowernumber );
699
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
691
    return { code => 'PatronNotFound' } unless $patron;
700
692
701
    # Get the biblio or return an error code
693
    # Get the biblio or return an error code
702
    my $biblionumber = $cgi->param('bib_id');
694
    my $biblionumber = $cgi->param('bib_id');
Lines 724-730 sub HoldItem { Link Here
724
        $branch = $cgi->param('pickup_location');
716
        $branch = $cgi->param('pickup_location');
725
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
717
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
726
    } else { # if the request provide no branch, use the borrower's branch
718
    } else { # if the request provide no branch, use the borrower's branch
727
        $branch = $$borrower{branchcode};
719
        $branch = $patron->branchcode;
728
    }
720
    }
729
721
730
    # Add the reserve
722
    # Add the reserve
Lines 762-769 sub CancelHold { Link Here
762
754
763
    # Get the borrower or return an error code
755
    # Get the borrower or return an error code
764
    my $borrowernumber = $cgi->param('patron_id');
756
    my $borrowernumber = $cgi->param('patron_id');
765
    my $borrower = GetMember( borrowernumber => $borrowernumber );
757
    my $patron = Koha::Patrons->find( $borrowernumber );
766
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
758
    return { code => 'PatronNotFound' } unless $patron;
767
759
768
    # Get the reserve or return an error code
760
    # Get the reserve or return an error code
769
    my $reserve_id = $cgi->param('item_id');
761
    my $reserve_id = $cgi->param('item_id');
(-)a/C4/Letters.pm (-14 / +16 lines)
Lines 37-42 use Koha::SMS::Providers; Link Here
37
37
38
use Koha::Email;
38
use Koha::Email;
39
use Koha::DateUtils qw( format_sqldatetime dt_from_string );
39
use Koha::DateUtils qw( format_sqldatetime dt_from_string );
40
use Koha::Patrons;
40
41
41
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
42
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
42
43
Lines 416-423 sub SendAlerts { Link Here
416
        # find the list of borrowers to alert
417
        # find the list of borrowers to alert
417
        my $alerts = getalert( '', 'issue', $subscriptionid );
418
        my $alerts = getalert( '', 'issue', $subscriptionid );
418
        foreach (@$alerts) {
419
        foreach (@$alerts) {
419
            my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'});
420
            my $patron = Koha::Patrons->find( $_->{borrowernumber} );
420
            my $email = $borinfo->{email} or next;
421
            next unless $patron; # Just in case
422
            my $email = $patron->email or next;
421
423
422
#                    warn "sending issues...";
424
#                    warn "sending issues...";
423
            my $userenv = C4::Context->userenv;
425
            my $userenv = C4::Context->userenv;
Lines 430-436 sub SendAlerts { Link Here
430
                    'branches'    => $_->{branchcode},
432
                    'branches'    => $_->{branchcode},
431
                    'biblio'      => $biblionumber,
433
                    'biblio'      => $biblionumber,
432
                    'biblioitems' => $biblionumber,
434
                    'biblioitems' => $biblionumber,
433
                    'borrowers'   => $borinfo,
435
                    'borrowers'   => $patron->unblessed,
434
                    'subscription' => $subscriptionid,
436
                    'subscription' => $subscriptionid,
435
                    'serial' => $externalid,
437
                    'serial' => $externalid,
436
                },
438
                },
Lines 1048-1062 sub SendQueuedMessages { Link Here
1048
        }
1050
        }
1049
        elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) {
1051
        elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) {
1050
            if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) {
1052
            if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) {
1051
                my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
1053
                my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1052
                my $sms_provider = Koha::SMS::Providers->find( $member->{'sms_provider_id'} );
1054
                my $sms_provider = Koha::SMS::Providers->find( $patron->sms_provider_id );
1053
                unless ( $sms_provider ) {
1055
                unless ( $sms_provider ) {
1054
                    warn sprintf( "Patron %s has no sms provider id set!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
1056
                    warn sprintf( "Patron %s has no sms provider id set!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
1055
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1057
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1056
                    next MESSAGE;
1058
                    next MESSAGE;
1057
                }
1059
                }
1058
                $message->{to_address} ||= $member->{'smsalertnumber'};
1060
                $message->{to_address} ||= $patron->smsalertnumber;
1059
                unless ( $message->{to_address} && $member->{'smsalertnumber'} ) {
1061
                unless ( $message->{to_address} && $patron->smsalertnumber ) {
1060
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1062
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1061
                    warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
1063
                    warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
1062
                    next MESSAGE;
1064
                    next MESSAGE;
Lines 1302-1311 sub _send_message_by_email { Link Here
1302
    my $message = shift or return;
1304
    my $message = shift or return;
1303
    my ($username, $password, $method) = @_;
1305
    my ($username, $password, $method) = @_;
1304
1306
1305
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
1307
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1306
    my $to_address = $message->{'to_address'};
1308
    my $to_address = $message->{'to_address'};
1307
    unless ($to_address) {
1309
    unless ($to_address) {
1308
        unless ($member) {
1310
        unless ($patron) {
1309
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1311
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1310
            _set_message_status( { message_id => $message->{'message_id'},
1312
            _set_message_status( { message_id => $message->{'message_id'},
1311
                                   status     => 'failed' } );
1313
                                   status     => 'failed' } );
Lines 1330-1337 sub _send_message_by_email { Link Here
1330
    my $branch_email = undef;
1332
    my $branch_email = undef;
1331
    my $branch_replyto = undef;
1333
    my $branch_replyto = undef;
1332
    my $branch_returnpath = undef;
1334
    my $branch_returnpath = undef;
1333
    if ($member) {
1335
    if ($patron) {
1334
        my $library = Koha::Libraries->find( $member->{branchcode} );
1336
        my $library = $patron->library;
1335
        $branch_email      = $library->branchemail;
1337
        $branch_email      = $library->branchemail;
1336
        $branch_replyto    = $library->branchreplyto;
1338
        $branch_replyto    = $library->branchreplyto;
1337
        $branch_returnpath = $library->branchreturnpath;
1339
        $branch_returnpath = $library->branchreturnpath;
Lines 1407-1415 sub _is_duplicate { Link Here
1407
1409
1408
sub _send_message_by_sms {
1410
sub _send_message_by_sms {
1409
    my $message = shift or return;
1411
    my $message = shift or return;
1410
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
1412
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1411
1413
1412
    unless ( $member->{smsalertnumber} ) {
1414
    unless ( $patron and $patron->smsalertnumber ) {
1413
        _set_message_status( { message_id => $message->{'message_id'},
1415
        _set_message_status( { message_id => $message->{'message_id'},
1414
                               status     => 'failed' } );
1416
                               status     => 'failed' } );
1415
        return;
1417
        return;
Lines 1421-1427 sub _send_message_by_sms { Link Here
1421
        return;
1423
        return;
1422
    }
1424
    }
1423
1425
1424
    my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'},
1426
    my $success = C4::SMS->send_sms( { destination => $patron->smsalertnumber,
1425
                                       message     => $message->{'content'},
1427
                                       message     => $message->{'content'},
1426
                                     } );
1428
                                     } );
1427
    _set_message_status( { message_id => $message->{'message_id'},
1429
    _set_message_status( { message_id => $message->{'message_id'},
(-)a/C4/Members.pm (-63 lines)
Lines 60-66 BEGIN { Link Here
60
    @ISA = qw(Exporter);
60
    @ISA = qw(Exporter);
61
    #Get data
61
    #Get data
62
    push @EXPORT, qw(
62
    push @EXPORT, qw(
63
        &GetMember
64
63
65
        &GetPendingIssues
64
        &GetPendingIssues
66
        &GetAllIssues
65
        &GetAllIssues
Lines 280-347 sub patronflags { Link Here
280
}
279
}
281
280
282
281
283
=head2 GetMember
284
285
  $borrower = &GetMember(%information);
286
287
Retrieve the first patron record meeting on criteria listed in the
288
C<%information> hash, which should contain one or more
289
pairs of borrowers column names and values, e.g.,
290
291
   $borrower = GetMember(borrowernumber => id);
292
293
C<&GetBorrower> returns a reference-to-hash whose keys are the fields of
294
the C<borrowers> table in the Koha database.
295
296
FIXME: GetMember() is used throughout the code as a lookup
297
on a unique key such as the borrowernumber, but this meaning is not
298
enforced in the routine itself.
299
300
=cut
301
302
#'
303
sub GetMember {
304
    my ( %information ) = @_;
305
    if (exists $information{borrowernumber} && !defined $information{borrowernumber}) {
306
        #passing mysql's kohaadmin?? Makes no sense as a query
307
        return;
308
    }
309
    my $dbh = C4::Context->dbh;
310
    my $select =
311
    q{SELECT borrowers.*, categories.category_type, categories.description
312
    FROM borrowers 
313
    LEFT JOIN categories on borrowers.categorycode=categories.categorycode WHERE };
314
    my $more_p = 0;
315
    my @values = ();
316
    for (keys %information ) {
317
        if ($more_p) {
318
            $select .= ' AND ';
319
        }
320
        else {
321
            $more_p++;
322
        }
323
324
        if (defined $information{$_}) {
325
            $select .= "$_ = ?";
326
            push @values, $information{$_};
327
        }
328
        else {
329
            $select .= "$_ IS NULL";
330
        }
331
    }
332
    $debug && warn $select, " ",values %information;
333
    my $sth = $dbh->prepare("$select");
334
    $sth->execute(@values);
335
    my $data = $sth->fetchall_arrayref({});
336
    #FIXME interface to this routine now allows generation of a result set
337
    #so whole array should be returned but bowhere in the current code expects this
338
    if (@{$data} ) {
339
        return $data->[0];
340
    }
341
342
    return;
343
}
344
345
=head2 ModMember
282
=head2 ModMember
346
283
347
  my $success = ModMember(borrowernumber => $borrowernumber,
284
  my $success = ModMember(borrowernumber => $borrowernumber,
(-)a/C4/Reserves.pm (-17 / +18 lines)
Lines 226-241 sub AddReserve { Link Here
226
226
227
    # Send e-mail to librarian if syspref is active
227
    # Send e-mail to librarian if syspref is active
228
    if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){
228
    if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){
229
        my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
229
        my $patron = Koha::Patrons->find( $borrowernumber );
230
        my $library = Koha::Libraries->find($borrower->{branchcode})->unblessed;
230
        my $library = $patron->library;
231
        if ( my $letter =  C4::Letters::GetPreparedLetter (
231
        if ( my $letter =  C4::Letters::GetPreparedLetter (
232
            module => 'reserves',
232
            module => 'reserves',
233
            letter_code => 'HOLDPLACED',
233
            letter_code => 'HOLDPLACED',
234
            branchcode => $branch,
234
            branchcode => $branch,
235
            lang => $borrower->{lang},
235
            lang => $patron->lang,
236
            tables => {
236
            tables => {
237
                'branches'    => $library,
237
                'branches'    => $library->unblessed,
238
                'borrowers'   => $borrower,
238
                'borrowers'   => $patron->unblessed,
239
                'biblio'      => $biblionumber,
239
                'biblio'      => $biblionumber,
240
                'biblioitems' => $biblionumber,
240
                'biblioitems' => $biblionumber,
241
                'items'       => $checkitem,
241
                'items'       => $checkitem,
Lines 243-249 sub AddReserve { Link Here
243
            },
243
            },
244
        ) ) {
244
        ) ) {
245
245
246
            my $admin_email_address = $library->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
246
            my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress');
247
247
248
            C4::Letters::EnqueueLetter(
248
            C4::Letters::EnqueueLetter(
249
                {   letter                 => $letter,
249
                {   letter                 => $letter,
Lines 331-337 sub CanItemBeReserved { Link Here
331
    # item->{itype} will come for biblioitems if necessery
331
    # item->{itype} will come for biblioitems if necessery
332
    my $item       = GetItem($itemnumber);
332
    my $item       = GetItem($itemnumber);
333
    my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} );
333
    my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} );
334
    my $borrower   = C4::Members::GetMember( 'borrowernumber' => $borrowernumber );
334
    my $patron = Koha::Patrons->find( $borrowernumber );
335
    my $borrower = $patron->unblessed;
335
336
336
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
337
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
337
    return 'damaged'
338
    return 'damaged'
Lines 807-818 sub CheckReserves { Link Here
807
            if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
808
            if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
808
                return ( "Waiting", $res, \@reserves ); # Found it
809
                return ( "Waiting", $res, \@reserves ); # Found it
809
            } else {
810
            } else {
810
                my $borrowerinfo;
811
                my $patron;
811
                my $iteminfo;
812
                my $iteminfo;
812
                my $local_hold_match;
813
                my $local_hold_match;
813
814
814
                if ($LocalHoldsPriority) {
815
                if ($LocalHoldsPriority) {
815
                    $borrowerinfo = C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} );
816
                    $patron = Koha::Patrons->find( $res->{borrowernumber} );
816
                    $iteminfo = C4::Items::GetItem($itemnumber);
817
                    $iteminfo = C4::Items::GetItem($itemnumber);
817
818
818
                    my $local_holds_priority_item_branchcode =
819
                    my $local_holds_priority_item_branchcode =
Lines 821-827 sub CheckReserves { Link Here
821
                      ( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' )
822
                      ( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' )
822
                      ? $res->{branchcode}
823
                      ? $res->{branchcode}
823
                      : ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' )
824
                      : ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' )
824
                      ? $borrowerinfo->{branchcode}
825
                      ? $patron->branchcode
825
                      : undef;
826
                      : undef;
826
                    $local_hold_match =
827
                    $local_hold_match =
827
                      $local_holds_priority_item_branchcode eq
828
                      $local_holds_priority_item_branchcode eq
Lines 832-842 sub CheckReserves { Link Here
832
                if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) {
833
                if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) {
833
                    $iteminfo ||= C4::Items::GetItem($itemnumber);
834
                    $iteminfo ||= C4::Items::GetItem($itemnumber);
834
                    next if $res->{itemtype} && $res->{itemtype} ne _get_itype( $iteminfo );
835
                    next if $res->{itemtype} && $res->{itemtype} ne _get_itype( $iteminfo );
835
                    $borrowerinfo ||= C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} );
836
                    $patron ||= Koha::Patrons->find( $res->{borrowernumber} );
836
                    my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo );
837
                    my $branch = GetReservesControlBranch( $iteminfo, $patron->unblessed );
837
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
838
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
838
                    next if ($branchitemrule->{'holdallowed'} == 0);
839
                    next if ($branchitemrule->{'holdallowed'} == 0);
839
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'}));
840
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
840
                    next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $iteminfo->{ $branchitemrule->{hold_fulfillment_policy} }) );
841
                    next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $iteminfo->{ $branchitemrule->{hold_fulfillment_policy} }) );
841
                    $priority = $res->{'priority'};
842
                    $priority = $res->{'priority'};
842
                    $highest  = $res;
843
                    $highest  = $res;
Lines 1808-1814 sub _koha_notify_reserve { Link Here
1808
    my $hold = Koha::Holds->find($reserve_id);
1809
    my $hold = Koha::Holds->find($reserve_id);
1809
    my $borrowernumber = $hold->borrowernumber;
1810
    my $borrowernumber = $hold->borrowernumber;
1810
1811
1811
    my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
1812
    my $patron = Koha::Patrons->find( $borrowernumber );
1812
1813
1813
    # Try to get the borrower's email address
1814
    # Try to get the borrower's email address
1814
    my $to_address = C4::Members::GetNoticeEmailAddress($borrowernumber);
1815
    my $to_address = C4::Members::GetNoticeEmailAddress($borrowernumber);
Lines 1825-1834 sub _koha_notify_reserve { Link Here
1825
    my %letter_params = (
1826
    my %letter_params = (
1826
        module => 'reserves',
1827
        module => 'reserves',
1827
        branchcode => $hold->branchcode,
1828
        branchcode => $hold->branchcode,
1828
        lang => $borrower->{lang},
1829
        lang => $patron->lang,
1829
        tables => {
1830
        tables => {
1830
            'branches'       => $library,
1831
            'branches'       => $library,
1831
            'borrowers'      => $borrower,
1832
            'borrowers'      => $patron->unblessed,
1832
            'biblio'         => $hold->biblionumber,
1833
            'biblio'         => $hold->biblionumber,
1833
            'biblioitems'    => $hold->biblionumber,
1834
            'biblioitems'    => $hold->biblionumber,
1834
            'reserves'       => $hold->unblessed,
1835
            'reserves'       => $hold->unblessed,
Lines 1859-1865 sub _koha_notify_reserve { Link Here
1859
    while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) {
1860
    while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) {
1860
        next if (
1861
        next if (
1861
               ( $mtt eq 'email' and not $to_address ) # No email address
1862
               ( $mtt eq 'email' and not $to_address ) # No email address
1862
            or ( $mtt eq 'sms'   and not $borrower->{smsalertnumber} ) # No SMS number
1863
            or ( $mtt eq 'sms'   and not $patron->smsalertnumber ) # No SMS number
1863
            or ( $mtt eq 'phone' and C4::Context->preference('TalkingTechItivaPhoneNotification') ) # Notice is handled by TalkingTech_itiva_outbound.pl
1864
            or ( $mtt eq 'phone' and C4::Context->preference('TalkingTechItivaPhoneNotification') ) # Notice is handled by TalkingTech_itiva_outbound.pl
1864
        );
1865
        );
1865
1866
(-)a/C4/SIP/ILS/Item.pm (-15 / +13 lines)
Lines 93-101 sub new { Link Here
93
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
93
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
94
    if ($issue) {
94
    if ($issue) {
95
        $item->{due_date} = dt_from_string( $issue->date_due, 'sql' )->truncate( to => 'minute' );
95
        $item->{due_date} = dt_from_string( $issue->date_due, 'sql' )->truncate( to => 'minute' );
96
        my $patron = Koha::Patrons->find( $issue->borrowernumber );
97
        $item->{patron} = $patron->cardnumber;
96
    }
98
    }
97
    my $borrower = $issue ? GetMember( borrowernumber => $issue->borrowernumber ) : {};
98
	$item->{patron} = $borrower->{'cardnumber'};
99
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
99
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
100
    my $holds = $biblio->current_holds->unblessed;
100
    my $holds = $biblio->current_holds->unblessed;
101
    $item->{hold_queue} = $holds;
101
    $item->{hold_queue} = $holds;
Lines 176-204 sub hold_patron_name { Link Here
176
        return $output;
176
        return $output;
177
    }
177
    }
178
178
179
    my $holder = GetMember(borrowernumber=>$borrowernumber);
179
    my $holder = Koha::Patrons->find( $borrowernumber );
180
    unless ($holder) {
180
    unless ($holder) {
181
        syslog("LOG_ERR", "While checking hold, GetMember failed for borrowernumber '$borrowernumber'");
181
        syslog("LOG_ERR", "While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'");
182
        return;
182
        return;
183
    }
183
    }
184
    my $email = $holder->{email} || '';
184
    my $email = $holder->email || '';
185
    my $phone = $holder->{phone} || '';
185
    my $phone = $holder->phone || '';
186
    my $extra = ($email and $phone) ? " ($email, $phone)" :  # both populated, employ comma
186
    my $extra = ($email and $phone) ? " ($email, $phone)" :  # both populated, employ comma
187
                ($email or  $phone) ? " ($email$phone)"   :  # only 1 populated, we don't care which: no comma
187
                ($email or  $phone) ? " ($email$phone)"   :  # only 1 populated, we don't care which: no comma
188
                "" ;                                         # neither populated, empty string
188
                "" ;                                         # neither populated, empty string
189
    my $name = $holder->{firstname} ? $holder->{firstname} . ' ' : '';
189
    my $name = $holder->firstname ? $holder->firstname . ' ' : '';
190
    $name .= $holder->{surname} . $extra;
190
    $name .= $holder->surname . $extra;
191
    return $name;
191
    return $name;
192
}
192
}
193
193
194
sub hold_patron_bcode {
194
sub hold_patron_bcode {
195
    my $self = shift;
195
    my $self = shift;
196
    my $borrowernumber = (@_ ? shift: $self->hold_patron_id()) or return;
196
    my $borrowernumber = (@_ ? shift: $self->hold_patron_id()) or return;
197
    my $holder = GetMember(borrowernumber => $borrowernumber);
197
    my $holder = Koha::Patrons->find( $borrowernumber );
198
    if ($holder) {
198
    if ($holder and $holder->cardnumber ) {
199
        if ($holder->{cardnumber}) {
199
        return $holder->cardnumber;
200
            return $holder->{cardnumber};
201
        }
202
    }
200
    }
203
    return;
201
    return;
204
}
202
}
Lines 360-367 sub available { Link Here
360
sub _barcode_to_borrowernumber {
358
sub _barcode_to_borrowernumber {
361
    my $known = shift;
359
    my $known = shift;
362
    return unless defined $known;
360
    return unless defined $known;
363
    my $member = GetMember(cardnumber=>$known) or return;
361
    my $patron = Koha::Patrons->find( { cardnumber => $known } ) or return;
364
    return $member->{borrowernumber};
362
    return $patron->borrowernumber
365
}
363
}
366
sub barcode_is_borrowernumber {    # because hold_queue only has borrowernumber...
364
sub barcode_is_borrowernumber {    # because hold_queue only has borrowernumber...
367
    my $self = shift;
365
    my $self = shift;
(-)a/C4/SIP/ILS/Patron.pm (-5 / +5 lines)
Lines 32-45 sub new { Link Here
32
    my ($class, $patron_id) = @_;
32
    my ($class, $patron_id) = @_;
33
    my $type = ref($class) || $class;
33
    my $type = ref($class) || $class;
34
    my $self;
34
    my $self;
35
    $kp = GetMember(cardnumber=>$patron_id) || GetMember(userid=>$patron_id);
35
    $kp = Koha::Patrons->find( { cardnumber => $patron_id } )
36
    $debug and warn "new Patron (GetMember): " . Dumper($kp);
36
      or Koha::Patrons->find( { userid => $patron_id } );
37
    unless (defined $kp) {
37
    $debug and warn "new Patron: " . Dumper($kp->unblessed) if $kp;
38
    unless ($kp) {
38
        syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
39
        syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
39
        return;
40
        return;
40
    }
41
    }
41
    $kp = GetMember( borrowernumber => $kp->{borrowernumber});
42
    $kp = $kp->unblessed;
42
    $debug and warn "new Patron (GetMember): " . Dumper($kp);
43
    my $pw        = $kp->{password};
43
    my $pw        = $kp->{password};
44
    my $flags     = C4::Members::patronflags( $kp );
44
    my $flags     = C4::Members::patronflags( $kp );
45
    my $debarred  = defined($flags->{DBARRED});
45
    my $debarred  = defined($flags->{DBARRED});
(-)a/C4/SIP/ILS/Transaction/Hold.pm (-10 / +10 lines)
Lines 9-16 use strict; Link Here
9
use C4::SIP::ILS::Transaction;
9
use C4::SIP::ILS::Transaction;
10
10
11
use C4::Reserves;	# AddReserve
11
use C4::Reserves;	# AddReserve
12
use C4::Members;	# GetMember
13
use C4::Biblio;		# GetBiblioFromItemNumber GetBiblioItemByBiblioNumber
12
use C4::Biblio;		# GetBiblioFromItemNumber GetBiblioItemByBiblioNumber
13
use Koha::Patrons;
14
use parent qw(C4::SIP::ILS::Transaction);
14
use parent qw(C4::SIP::ILS::Transaction);
15
15
16
16
Lines 43-50 sub do_hold { Link Here
43
        $self->ok(0);
43
        $self->ok(0);
44
        return $self;
44
        return $self;
45
    }
45
    }
46
    my $borrower = GetMember( 'cardnumber' => $self->{patron}->id );
46
    my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
47
    unless ($borrower) {
47
    unless ($patron) {
48
        $self->screen_msg( 'No borrower matches cardnumber "' . $self->{patron}->id . '".' );
48
        $self->screen_msg( 'No borrower matches cardnumber "' . $self->{patron}->id . '".' );
49
        $self->ok(0);
49
        $self->ok(0);
50
        return $self;
50
        return $self;
Lines 62-68 sub do_hold { Link Here
62
        return $self;
62
        return $self;
63
    }
63
    }
64
    my $bibno = $bib->{biblionumber};
64
    my $bibno = $bib->{biblionumber};
65
    AddReserve( $branch, $borrower->{borrowernumber}, $bibno, GetBiblioItemByBiblioNumber($bibno) );
65
    AddReserve( $branch, $patron->borrowernumber, $bibno, GetBiblioItemByBiblioNumber($bibno) );
66
66
67
    # unfortunately no meaningful return value
67
    # unfortunately no meaningful return value
68
    $self->ok(1);
68
    $self->ok(1);
Lines 76-83 sub drop_hold { Link Here
76
		$self->ok(0);
76
		$self->ok(0);
77
		return $self;
77
		return $self;
78
	}
78
	}
79
	my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
79
    my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
80
	unless ($borrower) {
80
    unless ($patron) {
81
		$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
81
		$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
82
		$self->ok(0);
82
		$self->ok(0);
83
		return $self;
83
		return $self;
Lines 87-93 sub drop_hold { Link Here
87
      CancelReserve({
87
      CancelReserve({
88
            biblionumber   => $bib->{biblionumber},
88
            biblionumber   => $bib->{biblionumber},
89
        itemnumber     => $self->{item}->id,
89
        itemnumber     => $self->{item}->id,
90
           borrowernumber => $borrower->{borrowernumber}
90
           borrowernumber => $patron->borrowernumber
91
      });
91
      });
92
92
93
	$self->ok(1);
93
	$self->ok(1);
Lines 101-108 sub change_hold { Link Here
101
		$self->ok(0);
101
		$self->ok(0);
102
		return $self;
102
		return $self;
103
	}
103
	}
104
	my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
104
    my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
105
	unless ($borrower) {
105
    unless ($patron) {
106
		$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
106
		$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
107
		$self->ok(0);
107
		$self->ok(0);
108
		return $self;
108
		return $self;
Lines 120-126 sub change_hold { Link Here
120
		return $self;
120
		return $self;
121
	}
121
	}
122
	my $bibno = $bib->{biblionumber};
122
	my $bibno = $bib->{biblionumber};
123
	ModReserve({ biblionumber => $bibno, borrowernumber => $borrower->{borrowernumber}, branchcode => $branch });
123
    ModReserve({ biblionumber => $bibno, borrowernumber => $patron->borrowernumber, branchcode => $branch });
124
124
125
	$self->ok(1);
125
	$self->ok(1);
126
	return $self;
126
	return $self;
(-)a/C4/SIP/ILS/Transaction/Renew.pm (-3 / +3 lines)
Lines 8-14 use warnings; Link Here
8
use strict;
8
use strict;
9
9
10
use C4::Circulation;
10
use C4::Circulation;
11
use C4::Members;
11
use Koha::Patrons;
12
use Koha::DateUtils;
12
use Koha::DateUtils;
13
13
14
use parent qw(C4::SIP::ILS::Transaction);
14
use parent qw(C4::SIP::ILS::Transaction);
Lines 60-67 sub do_renew_for { Link Here
60
60
61
sub do_renew {
61
sub do_renew {
62
    my $self = shift;
62
    my $self = shift;
63
    my $borrower = GetMember( cardnumber => $self->{patron}->id );
63
    my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
64
    return $self->do_renew_for($borrower);
64
    return $self->do_renew_for($patron->unblessed);
65
}
65
}
66
66
67
1;
67
1;
(-)a/C4/SIP/ILS/Transaction/RenewAll.pm (-2 / +2 lines)
Lines 10-16 use Sys::Syslog qw(syslog); Link Here
10
10
11
use C4::SIP::ILS::Item;
11
use C4::SIP::ILS::Item;
12
12
13
use C4::Members qw( GetMember );
13
use Koha::Patrons;
14
14
15
use parent qw(C4::SIP::ILS::Transaction::Renew);
15
use parent qw(C4::SIP::ILS::Transaction::Renew);
16
16
Lines 34-40 sub new { Link Here
34
sub do_renew_all {
34
sub do_renew_all {
35
    my $self     = shift;
35
    my $self     = shift;
36
    my $patron   = $self->{patron};                           # SIP's  patron
36
    my $patron   = $self->{patron};                           # SIP's  patron
37
    my $borrower = GetMember( cardnumber => $patron->id );    # Koha's patron
37
    my $borrower = Koha::Patrons->find( { cardnumber => $patron->id } )->unblessed;    # Koha's patron
38
    my $all_ok   = 1;
38
    my $all_ok   = 1;
39
    $self->{renewed}   = [];
39
    $self->{renewed}   = [];
40
    $self->{unrenewed} = [];
40
    $self->{unrenewed} = [];
(-)a/acqui/acqui-home.pl (-5 / +7 lines)
Lines 38-43 use C4::Members; Link Here
38
use C4::Debug;
38
use C4::Debug;
39
use C4::Suggestions;
39
use C4::Suggestions;
40
use Koha::Acquisition::Currencies;
40
use Koha::Acquisition::Currencies;
41
use Koha::Patrons;
41
42
42
my $query = CGI->new;
43
my $query = CGI->new;
43
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
44
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
Lines 70-80 my @budget_loop; Link Here
70
foreach my $budget ( @{$budget_arr} ) {
71
foreach my $budget ( @{$budget_arr} ) {
71
    next unless (CanUserUseBudget($loggedinuser, $budget, $userflags));
72
    next unless (CanUserUseBudget($loggedinuser, $budget, $userflags));
72
73
73
    my $member = GetMember( borrowernumber => $budget->{budget_owner_id} );
74
    my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
74
    if ($member) {
75
    if ( $patron ) {
75
        $budget->{budget_owner_firstname} = $member->{'firstname'};
76
        # FIXME should pass the entire object into budget_owner
76
        $budget->{budget_owner_surname} = $member->{'surname'};
77
        $budget->{budget_owner_firstname} = $patron->firstname;
77
        $budget->{budget_owner_borrowernumber} = $member->{'borrowernumber'};
78
        $budget->{budget_owner_surname} = $patron->surname;
79
        $budget->{budget_owner_borrowernumber} = $patron->borrowernumber;
78
    }
80
    }
79
81
80
    if ( !defined $budget->{budget_amount} ) {
82
    if ( !defined $budget->{budget_amount} ) {
(-)a/acqui/addorderiso2709.pl (-5 / +5 lines)
Lines 47-52 use Koha::Libraries; Link Here
47
use Koha::Acquisition::Currencies;
47
use Koha::Acquisition::Currencies;
48
use Koha::Acquisition::Order;
48
use Koha::Acquisition::Order;
49
use Koha::Acquisition::Booksellers;
49
use Koha::Acquisition::Booksellers;
50
use Koha::Patrons;
50
51
51
my $input = new CGI;
52
my $input = new CGI;
52
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({
53
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({
Lines 310-323 if ($op eq ""){ Link Here
310
            }
311
            }
311
        } else {
312
        } else {
312
            # 3rd add order
313
            # 3rd add order
313
            my $patron = C4::Members::GetMember( borrowernumber => $loggedinuser );
314
            my $patron = Koha::Patrons->find( $loggedinuser );
314
            # get quantity in the MARC record (1 if none)
315
            # get quantity in the MARC record (1 if none)
315
            my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
316
            my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
316
            my %orderinfo = (
317
            my %orderinfo = (
317
                biblionumber       => $biblionumber,
318
                biblionumber       => $biblionumber,
318
                basketno           => $cgiparams->{'basketno'},
319
                basketno           => $cgiparams->{'basketno'},
319
                quantity           => $c_quantity,
320
                quantity           => $c_quantity,
320
                branchcode         => $patron->{branchcode},
321
                branchcode         => $patron->branchcode,
321
                budget_id          => $c_budget_id,
322
                budget_id          => $c_budget_id,
322
                uncertainprice     => 1,
323
                uncertainprice     => 1,
323
                sort1              => $c_sort1,
324
                sort1              => $c_sort1,
Lines 417-431 if ($op eq ""){ Link Here
417
my $budgets = GetBudgets();
418
my $budgets = GetBudgets();
418
my $budget_id = @$budgets[0]->{'budget_id'};
419
my $budget_id = @$budgets[0]->{'budget_id'};
419
# build bookfund list
420
# build bookfund list
420
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
421
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
421
my ( $flags, $homebranch ) = ( $borrower->{'flags'}, $borrower->{'branchcode'} );
422
my $budget = GetBudget($budget_id);
422
my $budget = GetBudget($budget_id);
423
423
424
# build budget list
424
# build budget list
425
my $budget_loop = [];
425
my $budget_loop = [];
426
my $budgets_hierarchy = GetBudgetHierarchy;
426
my $budgets_hierarchy = GetBudgetHierarchy;
427
foreach my $r ( @{$budgets_hierarchy} ) {
427
foreach my $r ( @{$budgets_hierarchy} ) {
428
    next unless (CanUserUseBudget($borrower, $r, $userflags));
428
    next unless (CanUserUseBudget($patron, $r, $userflags));
429
    if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
429
    if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
430
        next;
430
        next;
431
    }
431
    }
(-)a/acqui/basket.pl (-6 / +6 lines)
Lines 30-36 use C4::Budgets; Link Here
30
use C4::Contract;
30
use C4::Contract;
31
use C4::Debug;
31
use C4::Debug;
32
use C4::Biblio;
32
use C4::Biblio;
33
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
34
use C4::Items;
33
use C4::Items;
35
use C4::Suggestions;
34
use C4::Suggestions;
36
use Koha::Biblios;
35
use Koha::Biblios;
Lines 41-46 use Date::Calc qw/Add_Delta_Days/; Link Here
41
use Koha::Database;
40
use Koha::Database;
42
use Koha::EDI qw( create_edi_order get_edifact_ean );
41
use Koha::EDI qw( create_edi_order get_edifact_ean );
43
use Koha::CsvProfiles;
42
use Koha::CsvProfiles;
43
use Koha::Patrons;
44
44
45
=head1 NAME
45
=head1 NAME
46
46
Lines 291-298 if ( $op eq 'list' ) { Link Here
291
291
292
#if the basket is closed,and the user has the permission to edit basketgroups, display a list of basketgroups
292
#if the basket is closed,and the user has the permission to edit basketgroups, display a list of basketgroups
293
    my ($basketgroup, $basketgroups);
293
    my ($basketgroup, $basketgroups);
294
    my $staffuser = GetMember(borrowernumber => $loggedinuser);
294
    my $patron = Koha::Patrons->find($loggedinuser);
295
    if ($basket->{closedate} && haspermission($staffuser->{userid}, { acquisition => 'group_manage'} )) {
295
    if ($basket->{closedate} && haspermission($patron->userid, { acquisition => 'group_manage'} )) {
296
        $basketgroups = GetBasketgroups($basket->{booksellerid});
296
        $basketgroups = GetBasketgroups($basket->{booksellerid});
297
        for my $bg ( @{$basketgroups} ) {
297
        for my $bg ( @{$basketgroups} ) {
298
            if ($basket->{basketgroupid} && $basket->{basketgroupid} == $bg->{id}){
298
            if ($basket->{basketgroupid} && $basket->{basketgroupid} == $bg->{id}){
Lines 321-328 if ( $op eq 'list' ) { Link Here
321
    my @basketusers_ids = GetBasketUsers($basketno);
321
    my @basketusers_ids = GetBasketUsers($basketno);
322
    my @basketusers;
322
    my @basketusers;
323
    foreach my $basketuser_id (@basketusers_ids) {
323
    foreach my $basketuser_id (@basketusers_ids) {
324
        my $basketuser = GetMember(borrowernumber => $basketuser_id);
324
        # FIXME Could be improved with a search -in
325
        push @basketusers, $basketuser if $basketuser;
325
        my $basket_patron = Koha::Patrons->find( $basketuser_id );
326
        push @basketusers, $basket_patron if $basket_patron;
326
    }
327
    }
327
328
328
    my $active_currency = Koha::Acquisition::Currencies->get_active;
329
    my $active_currency = Koha::Acquisition::Currencies->get_active;
Lines 375-381 if ( $op eq 'list' ) { Link Here
375
    if ($basket->{basketgroupid}){
376
    if ($basket->{basketgroupid}){
376
        $basketgroup = GetBasketgroup($basket->{basketgroupid});
377
        $basketgroup = GetBasketgroup($basket->{basketgroupid});
377
    }
378
    }
378
    my $borrower= GetMember('borrowernumber' => $loggedinuser);
379
    my $budgets = GetBudgetHierarchy;
379
    my $budgets = GetBudgetHierarchy;
380
    my $has_budgets = 0;
380
    my $has_budgets = 0;
381
    foreach my $r (@{$budgets}) {
381
    foreach my $r (@{$budgets}) {
(-)a/acqui/basketgroup.pl (-4 / +4 lines)
Lines 52-62 use C4::Output; Link Here
52
use CGI qw ( -utf8 );
52
use CGI qw ( -utf8 );
53
53
54
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
54
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
55
use C4::Members qw/GetMember/;
56
use Koha::EDI qw/create_edi_order get_edifact_ean/;
55
use Koha::EDI qw/create_edi_order get_edifact_ean/;
57
56
58
use Koha::Acquisition::Booksellers;
57
use Koha::Acquisition::Booksellers;
59
use Koha::ItemTypes;
58
use Koha::ItemTypes;
59
use Koha::Patrons;
60
60
61
our $input=new CGI;
61
our $input=new CGI;
62
62
Lines 273-281 if ( $op eq "add" ) { Link Here
273
        $template->param( closedbg => 0);
273
        $template->param( closedbg => 0);
274
    }
274
    }
275
    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
275
    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
276
    my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) );
276
    my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
277
    $billingplace  = $billingplace  || $borrower->{'branchcode'};
277
    $billingplace  = $billingplace  || $patron->branchcode;
278
    $deliveryplace = $deliveryplace || $borrower->{'branchcode'};
278
    $deliveryplace = $deliveryplace || $patron->branchcode;
279
279
280
    $template->param( billingplace => $billingplace );
280
    $template->param( billingplace => $billingplace );
281
    $template->param( deliveryplace => $deliveryplace );
281
    $template->param( deliveryplace => $deliveryplace );
(-)a/acqui/booksellers.pl (-6 / +8 lines)
Lines 60-69 use C4::Output; Link Here
60
use CGI qw ( -utf8 );
60
use CGI qw ( -utf8 );
61
61
62
use C4::Acquisition qw/ GetBasketsInfosByBookseller CanUserManageBasket /;
62
use C4::Acquisition qw/ GetBasketsInfosByBookseller CanUserManageBasket /;
63
use C4::Members qw/GetMember/;
64
use C4::Context;
63
use C4::Context;
65
64
66
use Koha::Acquisition::Booksellers;
65
use Koha::Acquisition::Booksellers;
66
use Koha::Patrons;
67
67
68
my $query = CGI->new;
68
my $query = CGI->new;
69
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
69
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
Lines 99-106 if ( $supplier_count == 1 ) { Link Here
99
}
99
}
100
100
101
my $uid;
101
my $uid;
102
# FIXME This script should only be accessed by a valid logged in patron
102
if ($loggedinuser) {
103
if ($loggedinuser) {
103
    $uid = GetMember( borrowernumber => $loggedinuser )->{userid};
104
    # FIXME Should not be needed, logged in patron should be cached
105
    $uid = Koha::Patrons->find( $loggedinuser )->userid;
104
}
106
}
105
107
106
my $userenv = C4::Context::userenv;
108
my $userenv = C4::Context::userenv;
Lines 130-142 for my $vendor (@suppliers) { Link Here
130
132
131
    for my $basket ( @{$baskets} ) {
133
    for my $basket ( @{$baskets} ) {
132
        if (CanUserManageBasket($loggedinuser, $basket, $userflags)) {
134
        if (CanUserManageBasket($loggedinuser, $basket, $userflags)) {
133
            my $member = GetMember( borrowernumber => $basket->{authorisedby} );
135
            my $patron = Koha::Patrons->find( $basket->{authorisedby} );
134
            foreach (qw(total_items total_biblios expected_items)) {
136
            foreach (qw(total_items total_biblios expected_items)) {
135
                $basket->{$_} ||= 0;
137
                $basket->{$_} ||= 0;
136
            }
138
            }
137
            if($member) {
139
            if ( $patron ) {
138
                $basket->{authorisedby_firstname} = $member->{firstname};
140
                $basket->{authorisedby_firstname} = $patron->firstname;
139
                $basket->{authorisedby_surname} = $member->{surname};
141
                $basket->{authorisedby_surname} = $patron->surname;
140
            }
142
            }
141
            if ($basket->{basketgroupid}) {
143
            if ($basket->{basketgroupid}) {
142
                my $basketgroup = C4::Acquisition::GetBasketgroup($basket->{basketgroupid});
144
                my $basketgroup = C4::Acquisition::GetBasketgroup($basket->{basketgroupid});
(-)a/acqui/neworderbiblio.pl (-3 / +3 lines)
Lines 64-76 use C4::Biblio; Link Here
64
use C4::Auth;
64
use C4::Auth;
65
use C4::Output;
65
use C4::Output;
66
use C4::Koha;
66
use C4::Koha;
67
use C4::Members qw/ GetMember /;
68
use C4::Budgets qw/ GetBudgetHierarchy /;
67
use C4::Budgets qw/ GetBudgetHierarchy /;
69
68
70
use Koha::Acquisition::Booksellers;
69
use Koha::Acquisition::Booksellers;
71
use Koha::SearchEngine;
70
use Koha::SearchEngine;
72
use Koha::SearchEngine::Search;
71
use Koha::SearchEngine::Search;
73
use Koha::SearchEngine::QueryBuilder;
72
use Koha::SearchEngine::QueryBuilder;
73
use Koha::Patrons;
74
74
75
my $input = new CGI;
75
my $input = new CGI;
76
76
Lines 133-140 foreach my $result ( @{$marcresults} ) { Link Here
133
133
134
}
134
}
135
135
136
my $borrower= GetMember('borrowernumber' => $loggedinuser);
136
my $patron = Koha::Patrons->find( $loggedinuser );
137
my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
137
my $budgets = GetBudgetHierarchy(q{},$patron->branchcode,$patron->borrowernumber);
138
my $has_budgets = 0;
138
my $has_budgets = 0;
139
foreach my $r (@{$budgets}) {
139
foreach my $r (@{$budgets}) {
140
    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
140
    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
(-)a/acqui/neworderempty.pl (-5 / +6 lines)
Lines 90-95 use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/; Link Here
90
use Koha::Acquisition::Booksellers;
90
use Koha::Acquisition::Booksellers;
91
use Koha::Acquisition::Currencies;
91
use Koha::Acquisition::Currencies;
92
use Koha::ItemTypes;
92
use Koha::ItemTypes;
93
use Koha::Patrons;
93
94
94
our $input           = new CGI;
95
our $input           = new CGI;
95
my $booksellerid    = $input->param('booksellerid');	# FIXME: else ERROR!
96
my $booksellerid    = $input->param('booksellerid');	# FIXME: else ERROR!
Lines 198-205 else { #modify order Link Here
198
199
199
    @order_user_ids = GetOrderUsers($ordernumber);
200
    @order_user_ids = GetOrderUsers($ordernumber);
200
    foreach my $order_user_id (@order_user_ids) {
201
    foreach my $order_user_id (@order_user_ids) {
201
        my $order_user = GetMember(borrowernumber => $order_user_id);
202
        # FIXME Could be improved with search -in
202
        push @order_users, $order_user if $order_user;
203
        my $order_patron = Koha::Patrons->find( $order_user_id );
204
        push @order_users, $order_patron if $order_patron;
203
    }
205
    }
204
}
206
}
205
207
Lines 210-224 my @currencies = Koha::Acquisition::Currencies->search; Link Here
210
my $active_currency = Koha::Acquisition::Currencies->get_active;
212
my $active_currency = Koha::Acquisition::Currencies->get_active;
211
213
212
# build bookfund list
214
# build bookfund list
213
my $borrower= GetMember('borrowernumber' => $loggedinuser);
215
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
214
my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
215
216
216
my $budget =  GetBudget($budget_id);
217
my $budget =  GetBudget($budget_id);
217
# build budget list
218
# build budget list
218
my $budget_loop = [];
219
my $budget_loop = [];
219
my $budgets = GetBudgetHierarchy;
220
my $budgets = GetBudgetHierarchy;
220
foreach my $r (@{$budgets}) {
221
foreach my $r (@{$budgets}) {
221
    next unless (CanUserUseBudget($borrower, $r, $userflags));
222
    next unless (CanUserUseBudget($patron, $r, $userflags));
222
    if (!defined $r->{budget_amount} || $r->{budget_amount} <0) {
223
    if (!defined $r->{budget_amount} || $r->{budget_amount} <0) {
223
        next;
224
        next;
224
    }
225
    }
(-)a/acqui/orderreceive.pl (-5 / +6 lines)
Lines 76-81 use C4::Koha; Link Here
76
use Koha::Acquisition::Booksellers;
76
use Koha::Acquisition::Booksellers;
77
use Koha::DateUtils qw( dt_from_string );
77
use Koha::DateUtils qw( dt_from_string );
78
use Koha::ItemTypes;
78
use Koha::ItemTypes;
79
use Koha::Patrons;
79
80
80
my $input      = new CGI;
81
my $input      = new CGI;
81
82
Lines 180-186 if( defined $order->{tax_rate_on_receiving} ) { Link Here
180
my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber});
181
my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber});
181
182
182
my $authorisedby = $order->{authorisedby};
183
my $authorisedby = $order->{authorisedby};
183
my $member = GetMember( borrowernumber => $authorisedby );
184
my $authorised_patron = Koha::Patrons->find( $authorisedby );
184
185
185
my $budget = GetBudget( $order->{budget_id} );
186
my $budget = GetBudget( $order->{budget_id} );
186
187
Lines 213-220 $template->param( Link Here
213
    ecost                 => $ecost,
214
    ecost                 => $ecost,
214
    unitprice             => $unitprice,
215
    unitprice             => $unitprice,
215
    tax_rate              => $tax_rate,
216
    tax_rate              => $tax_rate,
216
    memberfirstname       => $member->{firstname} || "",
217
    memberfirstname       => $authorised_patron->firstname || "",
217
    membersurname         => $member->{surname} || "",
218
    membersurname         => $authorised_patron->surname || "",
218
    invoiceid             => $invoice->{invoiceid},
219
    invoiceid             => $invoice->{invoiceid},
219
    invoice               => $invoice->{invoicenumber},
220
    invoice               => $invoice->{invoicenumber},
220
    datereceived          => $datereceived,
221
    datereceived          => $datereceived,
Lines 226-232 $template->param( Link Here
226
    gst_values            => \@gst_values,
227
    gst_values            => \@gst_values,
227
);
228
);
228
229
229
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
230
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
230
my @budget_loop;
231
my @budget_loop;
231
my $periods = GetBudgetPeriods( );
232
my $periods = GetBudgetPeriods( );
232
foreach my $period (@$periods) {
233
foreach my $period (@$periods) {
Lines 237-243 foreach my $period (@$periods) { Link Here
237
    my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} );
238
    my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} );
238
    my @funds;
239
    my @funds;
239
    foreach my $r ( @{$budget_hierarchy} ) {
240
    foreach my $r ( @{$budget_hierarchy} ) {
240
        next unless ( CanUserUseBudget( $borrower, $r, $userflags ) );
241
        next unless ( CanUserUseBudget( $patron, $r, $userflags ) );
241
        if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
242
        if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
242
            next;
243
            next;
243
        }
244
        }
(-)a/acqui/transferorder.pl (-3 / +2 lines)
Lines 26-32 use C4::Auth; Link Here
26
use C4::Output;
26
use C4::Output;
27
use C4::Context;
27
use C4::Context;
28
use C4::Acquisition;
28
use C4::Acquisition;
29
use C4::Members;
30
use Koha::Acquisition::Booksellers;
29
use Koha::Acquisition::Booksellers;
31
30
32
my $input = new CGI;
31
my $input = new CGI;
Lines 89-96 if( $basketno && $ordernumber) { Link Here
89
    for( my $i = 0 ; $i < $basketscount ; $i++ ){
88
    for( my $i = 0 ; $i < $basketscount ; $i++ ){
90
        my %line;
89
        my %line;
91
        %line = %{ $baskets->[$i] };
90
        %line = %{ $baskets->[$i] };
92
        my $createdby = GetMember(borrowernumber => $line{authorisedby});
91
        my $createdby = Koha::Patrons->find( $line{authorisedby} );
93
        $line{createdby} = "$createdby->{surname}, $createdby->{firstname}";
92
        $line{createdby} = $createdby ? $createdby->surname . ', ' . $createdby->firstname : '';
94
        push @basketsloop, \%line unless $line{closedate};
93
        push @basketsloop, \%line unless $line{closedate};
95
    }
94
    }
96
    $template->param(
95
    $template->param(
(-)a/admin/aqbudgets.pl (-9 / +6 lines)
Lines 29-40 use C4::Auth qw/get_user_subpermissions/; Link Here
29
use C4::Auth;
29
use C4::Auth;
30
use C4::Acquisition;
30
use C4::Acquisition;
31
use C4::Budgets;
31
use C4::Budgets;
32
use C4::Members;
33
use C4::Context;
32
use C4::Context;
34
use C4::Output;
33
use C4::Output;
35
use C4::Koha;
34
use C4::Koha;
36
use C4::Debug;
35
use C4::Debug;
37
use Koha::Acquisition::Currencies;
36
use Koha::Acquisition::Currencies;
37
use Koha::Patrons;
38
38
39
my $input = new CGI;
39
my $input = new CGI;
40
my $dbh     = C4::Context->dbh;
40
my $dbh     = C4::Context->dbh;
Lines 89-96 if ( $budget_period_id ) { Link Here
89
89
90
# USED FOR PERMISSION COMPARISON LATER
90
# USED FOR PERMISSION COMPARISON LATER
91
my $borrower_id         = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'};
91
my $borrower_id         = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'};
92
my $user                = C4::Members::GetMember( borrowernumber => $borrower_id );
93
my $user_branchcode     = $user->{'branchcode'};
94
92
95
$template->param(
93
$template->param(
96
    show_mine   => $show_mine,
94
    show_mine   => $show_mine,
Lines 117-124 if ($op eq 'add_form') { Link Here
117
            exit;
115
            exit;
118
        }
116
        }
119
        $dropbox_disabled = BudgetHasChildren($budget_id);
117
        $dropbox_disabled = BudgetHasChildren($budget_id);
120
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
118
        my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
121
        $budget->{budget_owner_name} = ( $borrower ? $borrower->{'firstname'} . ' ' . $borrower->{'surname'} : '' );
119
        $budget->{budget_owner_name} = ( $patron ? $patron->firstname . ' ' . $patron->surname : '' );
122
    }
120
    }
123
121
124
    # build budget hierarchy
122
    # build budget hierarchy
Lines 155-165 if ($op eq 'add_form') { Link Here
155
        my @budgetusers = GetBudgetUsers($budget->{budget_id});
153
        my @budgetusers = GetBudgetUsers($budget->{budget_id});
156
        my @budgetusers_loop;
154
        my @budgetusers_loop;
157
        foreach my $borrowernumber (@budgetusers) {
155
        foreach my $borrowernumber (@budgetusers) {
158
            my $member = C4::Members::GetMember(
156
            my $patron = Koha::Patrons->find( $borrowernumber );
159
                borrowernumber => $borrowernumber);
160
            push @budgetusers_loop, {
157
            push @budgetusers_loop, {
161
                firstname => $member->{firstname},
158
                firstname => $patron->firstname, # FIXME Should pass the patron object
162
                surname => $member->{surname},
159
                surname => $patron->surname,
163
                borrowernumber => $borrowernumber
160
                borrowernumber => $borrowernumber
164
            };
161
            };
165
        }
162
        }
(-)a/catalogue/ISBDdetail.pl (-5 / +5 lines)
Lines 43-54 use CGI qw ( -utf8 ); Link Here
43
use C4::Koha;
43
use C4::Koha;
44
use C4::Biblio;
44
use C4::Biblio;
45
use C4::Items;
45
use C4::Items;
46
use C4::Members; # to use GetMember
47
use C4::Serials;    # CountSubscriptionFromBiblionumber
46
use C4::Serials;    # CountSubscriptionFromBiblionumber
48
use C4::Search;		# enabled_staff_search_views
47
use C4::Search;		# enabled_staff_search_views
49
use C4::Acquisition qw(GetOrdersByBiblionumber);
48
use C4::Acquisition qw(GetOrdersByBiblionumber);
50
49
51
use Koha::Biblios;
50
use Koha::Biblios;
51
use Koha::Patrons;
52
use Koha::RecordProcessor;
52
use Koha::RecordProcessor;
53
53
54
54
Lines 107-118 my $res = GetISBDView({ Link Here
107
});
107
});
108
108
109
if($query->cookie("holdfor")){ 
109
if($query->cookie("holdfor")){ 
110
    my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
110
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
111
    $template->param(
111
    $template->param(
112
        holdfor => $query->cookie("holdfor"),
112
        holdfor => $query->cookie("holdfor"),
113
        holdfor_surname => $holdfor_patron->{'surname'},
113
        holdfor_surname => $holdfor_patron->surname,
114
        holdfor_firstname => $holdfor_patron->{'firstname'},
114
        holdfor_firstname => $holdfor_patron->firstname,
115
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
115
        holdfor_cardnumber => $holdfor_patron->cardnumber,
116
    );
116
    );
117
}
117
}
118
118
(-)a/catalogue/MARCdetail.pl (-5 / +5 lines)
Lines 56-67 use MARC::Record; Link Here
56
use C4::Biblio;
56
use C4::Biblio;
57
use C4::Items;
57
use C4::Items;
58
use C4::Acquisition;
58
use C4::Acquisition;
59
use C4::Members; # to use GetMember
60
use C4::Serials;    #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber
59
use C4::Serials;    #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber
61
use C4::Search;		# enabled_staff_search_views
60
use C4::Search;		# enabled_staff_search_views
62
61
63
use Koha::Biblios;
62
use Koha::Biblios;
64
use Koha::BiblioFrameworks;
63
use Koha::BiblioFrameworks;
64
use Koha::Patrons;
65
65
66
use List::MoreUtils qw( uniq );
66
use List::MoreUtils qw( uniq );
67
67
Lines 105-116 my $tagslib = &GetMarcStructure(1,$frameworkcode); Link Here
105
my $biblio = GetBiblioData($biblionumber);
105
my $biblio = GetBiblioData($biblionumber);
106
106
107
if($query->cookie("holdfor")){ 
107
if($query->cookie("holdfor")){ 
108
    my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
108
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
109
    $template->param(
109
    $template->param(
110
        holdfor => $query->cookie("holdfor"),
110
        holdfor => $query->cookie("holdfor"),
111
        holdfor_surname => $holdfor_patron->{'surname'},
111
        holdfor_surname => $holdfor_patron->surname,
112
        holdfor_firstname => $holdfor_patron->{'firstname'},
112
        holdfor_firstname => $holdfor_patron->firstname,
113
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
113
        holdfor_cardnumber => $holdfor_patron->cardnumber,
114
    );
114
    );
115
}
115
}
116
116
(-)a/catalogue/detail.pl (-9 / +9 lines)
Lines 29-35 use C4::Biblio; Link Here
29
use C4::Items;
29
use C4::Items;
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Reserves;
31
use C4::Reserves;
32
use C4::Members; # to use GetMember
33
use C4::Serials;
32
use C4::Serials;
34
use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
33
use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
35
use C4::External::Amazon;
34
use C4::External::Amazon;
Lines 75-86 if ( not defined $record ) { Link Here
75
}
74
}
76
75
77
if($query->cookie("holdfor")){ 
76
if($query->cookie("holdfor")){ 
78
    my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
77
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
79
    $template->param(
78
    $template->param(
79
        # FIXME Should pass the patron object
80
        holdfor => $query->cookie("holdfor"),
80
        holdfor => $query->cookie("holdfor"),
81
        holdfor_surname => $holdfor_patron->{'surname'},
81
        holdfor_surname => $holdfor_patron->surname,
82
        holdfor_firstname => $holdfor_patron->{'firstname'},
82
        holdfor_firstname => $holdfor_patron->firstname,
83
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
83
        holdfor_cardnumber => $holdfor_patron->cardnumber,
84
    );
84
    );
85
}
85
}
86
86
Lines 262-275 foreach my $item (@items) { Link Here
262
    my $item_object = Koha::Items->find( $item->{itemnumber} );
262
    my $item_object = Koha::Items->find( $item->{itemnumber} );
263
    my $holds = $item_object->current_holds;
263
    my $holds = $item_object->current_holds;
264
    if ( my $first_hold = $holds->next ) {
264
    if ( my $first_hold = $holds->next ) {
265
        my $ItemBorrowerReserveInfo = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber); # FIXME could be improved
265
        my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
266
        $item->{backgroundcolor} = 'reserved';
266
        $item->{backgroundcolor} = 'reserved';
267
        $item->{reservedate}     = $first_hold->reservedate;
267
        $item->{reservedate}     = $first_hold->reservedate;
268
        $item->{ReservedForBorrowernumber}     = $first_hold->borrowernumber;
268
        $item->{ReservedForBorrowernumber}     = $first_hold->borrowernumber;
269
        $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
269
        $item->{ReservedForSurname}     = $patron->surname;
270
        $item->{ReservedForFirstname}   = $ItemBorrowerReserveInfo->{'firstname'};
270
        $item->{ReservedForFirstname}   = $patron->firstname;
271
        $item->{ExpectedAtLibrary}      = $first_hold->branchcode;
271
        $item->{ExpectedAtLibrary}      = $first_hold->branchcode;
272
        $item->{Reservedcardnumber}             = $ItemBorrowerReserveInfo->{'cardnumber'};
272
        $item->{Reservedcardnumber}     = $patron->cardnumber;
273
        # Check waiting status
273
        # Check waiting status
274
        $item->{waitingdate} = $first_hold->waitingdate;
274
        $item->{waitingdate} = $first_hold->waitingdate;
275
    }
275
    }
(-)a/catalogue/imageviewer.pl (-5 / +5 lines)
Lines 30-35 use C4::Search; Link Here
30
use C4::Acquisition qw(GetOrdersByBiblionumber);
30
use C4::Acquisition qw(GetOrdersByBiblionumber);
31
31
32
use Koha::Biblios;
32
use Koha::Biblios;
33
use Koha::Patrons;
33
34
34
my $query = new CGI;
35
my $query = new CGI;
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 60-72 foreach my $item (@items) { Link Here
60
}
61
}
61
62
62
if ( $query->cookie("holdfor") ) {
63
if ( $query->cookie("holdfor") ) {
63
    my $holdfor_patron =
64
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
64
      GetMember( 'borrowernumber' => $query->cookie("holdfor") );
65
    $template->param(
65
    $template->param(
66
        holdfor            => $query->cookie("holdfor"),
66
        holdfor            => $query->cookie("holdfor"),
67
        holdfor_surname    => $holdfor_patron->{'surname'},
67
        holdfor_surname    => $holdfor_patron->surname,
68
        holdfor_firstname  => $holdfor_patron->{'firstname'},
68
        holdfor_firstname  => $holdfor_patron->firstname,
69
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
69
        holdfor_cardnumber => $holdfor_patron->cardnumber,
70
    );
70
    );
71
}
71
}
72
72
(-)a/catalogue/labeledMARCdetail.pl (-5 / +5 lines)
Lines 27-38 use C4::Context; Link Here
27
use C4::Output;
27
use C4::Output;
28
use C4::Biblio;
28
use C4::Biblio;
29
use C4::Items;
29
use C4::Items;
30
use C4::Members; # to use GetMember
31
use C4::Search;		# enabled_staff_search_views
30
use C4::Search;		# enabled_staff_search_views
32
use C4::Acquisition qw(GetOrdersByBiblionumber);
31
use C4::Acquisition qw(GetOrdersByBiblionumber);
33
32
34
use Koha::Biblios;
33
use Koha::Biblios;
35
use Koha::BiblioFrameworks;
34
use Koha::BiblioFrameworks;
35
use Koha::Patrons;
36
36
37
my $query        = new CGI;
37
my $query        = new CGI;
38
my $dbh          = C4::Context->dbh;
38
my $dbh          = C4::Context->dbh;
Lines 71-82 my $tagslib = GetMarcStructure(1,$frameworkcode); Link Here
71
my $biblio = GetBiblioData($biblionumber);
71
my $biblio = GetBiblioData($biblionumber);
72
72
73
if($query->cookie("holdfor")){ 
73
if($query->cookie("holdfor")){ 
74
    my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
74
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
75
    $template->param(
75
    $template->param(
76
        holdfor => $query->cookie("holdfor"),
76
        holdfor => $query->cookie("holdfor"),
77
        holdfor_surname => $holdfor_patron->{'surname'},
77
        holdfor_surname => $holdfor_patron->surname,
78
        holdfor_firstname => $holdfor_patron->{'firstname'},
78
        holdfor_firstname => $holdfor_patron->firstname,
79
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
79
        holdfor_cardnumber => $holdfor_patron->cardnumber,
80
    );
80
    );
81
}
81
}
82
82
(-)a/catalogue/moredetail.pl (-8 / +7 lines)
Lines 30-36 use C4::Acquisition; Link Here
30
use C4::Output;
30
use C4::Output;
31
use C4::Auth;
31
use C4::Auth;
32
use C4::Serials;
32
use C4::Serials;
33
use C4::Members; # to use GetMember
34
use C4::Search;		# enabled_staff_search_views
33
use C4::Search;		# enabled_staff_search_views
35
34
36
use Koha::Acquisition::Booksellers;
35
use Koha::Acquisition::Booksellers;
Lines 53-64 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
53
);
52
);
54
53
55
if($query->cookie("holdfor")){ 
54
if($query->cookie("holdfor")){ 
56
    my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
55
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
57
    $template->param(
56
    $template->param(
58
        holdfor => $query->cookie("holdfor"),
57
        holdfor => $query->cookie("holdfor"),
59
        holdfor_surname => $holdfor_patron->{'surname'},
58
        holdfor_surname => $holdfor_patron->surname,
60
        holdfor_firstname => $holdfor_patron->{'firstname'},
59
        holdfor_firstname => $holdfor_patron->firstname,
61
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
60
        holdfor_cardnumber => $holdfor_patron->cardnumber,
62
    );
61
    );
63
}
62
}
64
63
Lines 190-198 foreach my $item (@items){ Link Here
190
189
191
    unless ($hidepatronname) {
190
    unless ($hidepatronname) {
192
        if ( $item->{'borrowernumber'} ) {
191
        if ( $item->{'borrowernumber'} ) {
193
            my $curr_borrower = GetMember('borrowernumber' => $item->{'borrowernumber'} );
192
            my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} );
194
            $item->{borrowerfirstname} = $curr_borrower->{'firstname'};
193
            $item->{borrowerfirstname} = $curr_borrower->firstname;
195
            $item->{borrowersurname} = $curr_borrower->{'surname'};
194
            $item->{borrowersurname} = $curr_borrower->surname;
196
        }
195
        }
197
    }
196
    }
198
197
(-)a/catalogue/search.pl (-6 / +6 lines)
Lines 146-161 use C4::Auth qw(:DEFAULT get_session); Link Here
146
use C4::Search;
146
use C4::Search;
147
use C4::Languages qw(getLanguages);
147
use C4::Languages qw(getLanguages);
148
use C4::Koha;
148
use C4::Koha;
149
use C4::Members qw(GetMember);
150
use URI::Escape;
149
use URI::Escape;
151
use POSIX qw(ceil floor);
150
use POSIX qw(ceil floor);
152
use C4::Search::History;
151
use C4::Search::History;
153
152
154
use Koha::ItemTypes;
153
use Koha::ItemTypes;
155
use Koha::LibraryCategories;
154
use Koha::LibraryCategories;
156
use Koha::Virtualshelves;
155
use Koha::Patrons;
157
use Koha::SearchEngine::Search;
156
use Koha::SearchEngine::Search;
158
use Koha::SearchEngine::QueryBuilder;
157
use Koha::SearchEngine::QueryBuilder;
158
use Koha::Virtualshelves;
159
159
160
use URI::Escape;
160
use URI::Escape;
161
161
Lines 196-207 if (C4::Context->preference("IntranetNumbersPreferPhrase")) { Link Here
196
}
196
}
197
197
198
if($cgi->cookie("holdfor")){ 
198
if($cgi->cookie("holdfor")){ 
199
    my $holdfor_patron = GetMember('borrowernumber' => $cgi->cookie("holdfor"));
199
    my $holdfor_patron = Koha::Patrons->find( $cgi->cookie("holdfor") );
200
    $template->param(
200
    $template->param(
201
        holdfor => $cgi->cookie("holdfor"),
201
        holdfor => $cgi->cookie("holdfor"),
202
        holdfor_surname => $holdfor_patron->{'surname'},
202
        holdfor_surname => $holdfor_patron->surname,
203
        holdfor_firstname => $holdfor_patron->{'firstname'},
203
        holdfor_firstname => $holdfor_patron->firstname,
204
        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
204
        holdfor_cardnumber => $holdfor_patron->cardnumber,
205
    );
205
    );
206
}
206
}
207
207
(-)a/cataloguing/additem.pl (-1 / +2 lines)
Lines 33-38 use C4::ClassSource; Link Here
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
use Koha::ItemTypes;
34
use Koha::ItemTypes;
35
use Koha::Libraries;
35
use Koha::Libraries;
36
use Koha::Patrons;
36
use List::MoreUtils qw/any/;
37
use List::MoreUtils qw/any/;
37
use C4::Search;
38
use C4::Search;
38
use Storable qw(thaw freeze);
39
use Storable qw(thaw freeze);
Lines 401-407 my ($template, $loggedinuser, $cookie) Link Here
401
402
402
403
403
# Does the user have a restricted item editing permission?
404
# Does the user have a restricted item editing permission?
404
my $uid = $loggedinuser ? GetMember( borrowernumber => $loggedinuser )->{userid} : undef;
405
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
405
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
406
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
406
# In case user is a superlibrarian, editing is not restricted
407
# In case user is a superlibrarian, editing is not restricted
407
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
408
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
(-)a/circ/branchtransfers.pl (-5 / +8 lines)
Lines 33-38 use C4::Koha; Link Here
33
use C4::Members;
33
use C4::Members;
34
use Koha::BiblioFrameworks;
34
use Koha::BiblioFrameworks;
35
use Koha::AuthorisedValues;
35
use Koha::AuthorisedValues;
36
use Koha::Patrons;
36
37
37
###############################################
38
###############################################
38
#  Getting state
39
#  Getting state
Lines 207-217 foreach my $code ( keys %$messages ) { Link Here
207
        elsif ( $code eq 'WasReturned' ) {
208
        elsif ( $code eq 'WasReturned' ) {
208
            $err{errwasreturned} = 1;
209
            $err{errwasreturned} = 1;
209
            $err{borrowernumber} = $messages->{'WasReturned'};
210
            $err{borrowernumber} = $messages->{'WasReturned'};
210
            my $borrower = GetMember('borrowernumber'=>$messages->{'WasReturned'});
211
            my $patron = Koha::Patrons->find( $messages->{'WasReturned'} );
211
            $err{title}      = $borrower->{'title'};
212
            if ( $patron ) { # Just in case...
212
            $err{firstname}  = $borrower->{'firstname'};
213
                $err{title}      = $patron->title;
213
            $err{surname}    = $borrower->{'surname'};
214
                $err{firstname}  = $patron->firstname;
214
            $err{cardnumber} = $borrower->{'cardnumber'};
215
                $err{surname}    = $patron->surname;
216
                $err{cardnumber} = $patron->cardnumber;
217
            }
215
        }
218
        }
216
        $err{errdesteqholding} = ( $code eq 'DestinationEqualsHolding' );
219
        $err{errdesteqholding} = ( $code eq 'DestinationEqualsHolding' );
217
        push( @errmsgloop, \%err );
220
        push( @errmsgloop, \%err );
(-)a/circ/circulation.pl (-36 / +34 lines)
Lines 22-27 Link Here
22
# You should have received a copy of the GNU General Public License
22
# You should have received a copy of the GNU General Public License
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
24
24
25
# FIXME There are too many calls to Koha::Patrons->find in this script
26
25
use strict;
27
use strict;
26
use warnings;
28
use warnings;
27
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
Lines 44-56 use CGI::Session; Link Here
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
46
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use Koha::AuthorisedValues;
47
use Koha::AuthorisedValues;
46
use Koha::CsvProfiles;
48
use Koha::CsvProfiles;
47
use Koha::Patron;
49
use Koha::Patrons;
48
use Koha::Patron::Debarments qw(GetDebarments);
50
use Koha::Patron::Debarments qw(GetDebarments);
49
use Koha::DateUtils;
51
use Koha::DateUtils;
50
use Koha::Database;
52
use Koha::Database;
51
use Koha::BiblioFrameworks;
53
use Koha::BiblioFrameworks;
52
use Koha::Patron::Messages;
54
use Koha::Patron::Messages;
53
use Koha::Patron::Images;
54
use Koha::SearchEngine;
55
use Koha::SearchEngine;
55
use Koha::SearchEngine::Search;
56
use Koha::SearchEngine::Search;
56
use Koha::Patron::Modifications;
57
use Koha::Patron::Modifications;
Lines 104-116 $barcodes = [ uniq @$barcodes ]; Link Here
104
105
105
my $template_name = q|circ/circulation.tt|;
106
my $template_name = q|circ/circulation.tt|;
106
my $borrowernumber = $query->param('borrowernumber');
107
my $borrowernumber = $query->param('borrowernumber');
107
my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
108
my $patron = $borrowernumber ? Koha::Patrons->find( $borrowernumber ) : undef;
108
my $batch = $query->param('batch');
109
my $batch = $query->param('batch');
109
my $batch_allowed = 0;
110
my $batch_allowed = 0;
110
if ( $batch && C4::Context->preference('BatchCheckouts') ) {
111
if ( $batch && C4::Context->preference('BatchCheckouts') ) {
111
    $template_name = q|circ/circulation_batch_checkouts.tt|;
112
    $template_name = q|circ/circulation_batch_checkouts.tt|;
112
    my @batch_category_codes = split '\|', C4::Context->preference('BatchCheckoutsValidCategories');
113
    my @batch_category_codes = split '\|', C4::Context->preference('BatchCheckoutsValidCategories');
113
    if ( grep {/^$borrower->{categorycode}$/} @batch_category_codes ) {
114
    my $categorycode = $patron->categorycode;
115
    if ( $categorycode && grep {/^$categorycode$/} @batch_category_codes ) {
114
        $batch_allowed = 1;
116
        $batch_allowed = 1;
115
    } else {
117
    } else {
116
        $barcodes = [];
118
        $barcodes = [];
Lines 231-239 if ( $print eq 'yes' && $borrowernumber ne '' ) { Link Here
231
#
233
#
232
my $message;
234
my $message;
233
if ($findborrower) {
235
if ($findborrower) {
234
    my $borrower = C4::Members::GetMember( cardnumber => $findborrower );
236
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
235
    if ( $borrower ) {
237
    if ( $patron ) {
236
        $borrowernumber = $borrower->{borrowernumber};
238
        $borrowernumber = $patron->borrowernumber;
237
    } else {
239
    } else {
238
        my $dt_params = { iDisplayLength => -1 };
240
        my $dt_params = { iDisplayLength => -1 };
239
        my $results = C4::Utils::DataTables::Members::search(
241
        my $results = C4::Utils::DataTables::Members::search(
Lines 258-267 if ($findborrower) { Link Here
258
}
260
}
259
261
260
# get the borrower information.....
262
# get the borrower information.....
261
my $patron;
262
if ($borrowernumber) {
263
if ($borrowernumber) {
263
    $patron = Koha::Patrons->find( $borrowernumber );
264
    $patron = Koha::Patrons->find( $borrowernumber );
264
    $borrower = GetMember( borrowernumber => $borrowernumber );
265
    my $overdues = $patron->get_overdues;
265
    my $overdues = $patron->get_overdues;
266
    my $issues = $patron->checkouts;
266
    my $issues = $patron->checkouts;
267
    my $balance = $patron->account->balance;
267
    my $balance = $patron->account->balance;
Lines 279-285 if ($borrowernumber) { Link Here
279
    # check for NotifyBorrowerDeparture
279
    # check for NotifyBorrowerDeparture
280
    elsif ( $patron->is_going_to_expire ) {
280
    elsif ( $patron->is_going_to_expire ) {
281
        # borrower card soon to expire warn librarian
281
        # borrower card soon to expire warn librarian
282
        $template->param( "warndeparture" => $borrower->{dateexpiry} ,
282
        $template->param( "warndeparture" => $patron->dateexpiry ,
283
                        );
283
                        );
284
        if (C4::Context->preference('ReturnBeforeExpiry')){
284
        if (C4::Context->preference('ReturnBeforeExpiry')){
285
            $template->param("returnbeforeexpiry" => 1);
285
            $template->param("returnbeforeexpiry" => 1);
Lines 293-304 if ($borrowernumber) { Link Here
293
293
294
    if ( $patron and $patron->is_debarred ) {
294
    if ( $patron and $patron->is_debarred ) {
295
        $template->param(
295
        $template->param(
296
            'userdebarred'    => $borrower->{debarred},
296
            'userdebarred'    => $patron->debarred,
297
            'debarredcomment' => $borrower->{debarredcomment},
297
            'debarredcomment' => $patron->debarredcomment,
298
        );
298
        );
299
299
300
        if ( $borrower->{debarred} ne "9999-12-31" ) {
300
        if ( $patron->debarred ne "9999-12-31" ) {
301
            $template->param( 'userdebarreddate' => $borrower->{debarred} );
301
            $template->param( 'userdebarreddate' => $patron->debarred );
302
        }
302
        }
303
    }
303
    }
304
304
Lines 314-320 if (@$barcodes) { Link Here
314
    my $template_params = { barcode => $barcode };
314
    my $template_params = { barcode => $barcode };
315
    # always check for blockers on issuing
315
    # always check for blockers on issuing
316
    my ( $error, $question, $alerts, $messages ) = CanBookBeIssued(
316
    my ( $error, $question, $alerts, $messages ) = CanBookBeIssued(
317
        $borrower,
317
        $patron->unblessed,
318
        $barcode, $datedue,
318
        $barcode, $datedue,
319
        $inprocess,
319
        $inprocess,
320
        undef,
320
        undef,
Lines 399-405 if (@$barcodes) { Link Here
399
        }
399
        }
400
        unless($confirm_required) {
400
        unless($confirm_required) {
401
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
401
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
402
            my $issue = AddIssue( $borrower, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } );
402
            my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } );
403
            $template_params->{issue} = $issue;
403
            $template_params->{issue} = $issue;
404
            $session->clear('auto_renew');
404
            $session->clear('auto_renew');
405
            $inprocess = 1;
405
            $inprocess = 1;
Lines 439-449 if (@$barcodes) { Link Here
439
  }
439
  }
440
}
440
}
441
441
442
# reload the borrower info for the sake of reseting the flags.....
443
if ($borrowernumber) {
444
    $borrower = GetMember( borrowernumber => $borrowernumber );
445
}
446
447
##################################################################################
442
##################################################################################
448
# BUILD HTML
443
# BUILD HTML
449
# show all reserves of this borrower, and the position of the reservation ....
444
# show all reserves of this borrower, and the position of the reservation ....
Lines 455-465 if ($borrowernumber) { Link Here
455
        WaitingHolds => $waiting_holds,
450
        WaitingHolds => $waiting_holds,
456
    );
451
    );
457
452
458
    $template->param( adultborrower => 1 ) if ( $borrower->{category_type} eq 'A' || $borrower->{category_type} eq 'I' );
453
    my $category_type = $patron->category->category_type;
454
    $template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
459
}
455
}
460
456
461
#title
457
#title
462
my $flags = $borrower ? C4::Members::patronflags( $borrower ) : {};
458
my $flags = $patron ? C4::Members::patronflags( $patron->unblessed ) : {};
463
foreach my $flag ( sort keys %$flags ) {
459
foreach my $flag ( sort keys %$flags ) {
464
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
460
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
465
    if ( $flags->{$flag}->{'noissues'} ) {
461
    if ( $flags->{$flag}->{'noissues'} ) {
Lines 547-553 $amountold =~ s/^.*\$//; # remove upto the $, if any Link Here
547
543
548
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
544
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
549
545
550
if ( $borrowernumber && $borrower->{'category_type'} eq 'C') {
546
if ( $patron && $patron->category->category_type eq 'C') {
551
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
547
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
552
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
548
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
553
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
549
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
Lines 595-604 my $relatives_issues_count = Link Here
595
  Koha::Database->new()->schema()->resultset('Issue')
591
  Koha::Database->new()->schema()->resultset('Issue')
596
  ->count( { borrowernumber => \@relatives } );
592
  ->count( { borrowernumber => \@relatives } );
597
593
598
my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $borrower->{streettype} });
594
if ( $patron ) {
599
my $roadtype = $av->count ? $av->next->lib : '';
595
    my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $patron->streettype });
600
596
    my $roadtype = $av->count ? $av->next->lib : '';
601
$template->param(%$borrower);
597
    $template->param(
598
        %{ $patron->unblessed },
599
        borrower => $patron->unblessed,
600
        roadtype          => $roadtype,
601
        patron            => $patron,
602
        categoryname      => $patron->category->description,
603
        expiry            => $patron->dateexpiry,
604
        is_child          => ( $patron->category->category_type eq 'C' ),
605
        picture           => ( $patron->image ? 1 : 0 ),
606
    );
607
}
602
608
603
# Restore date if changed by holds and/or save stickyduedate to session
609
# Restore date if changed by holds and/or save stickyduedate to session
604
if ($restoreduedatespec || $stickyduedate) {
610
if ($restoreduedatespec || $stickyduedate) {
Lines 612-626 if ($restoreduedatespec || $stickyduedate) { Link Here
612
}
618
}
613
619
614
$template->param(
620
$template->param(
615
    patron            => $patron,
616
    messages           => $messages,
621
    messages           => $messages,
617
    borrower          => $borrower,
618
    borrowernumber    => $borrowernumber,
622
    borrowernumber    => $borrowernumber,
619
    categoryname      => $borrower->{'description'},
620
    branch            => $branch,
623
    branch            => $branch,
621
    was_renewed       => scalar $query->param('was_renewed') ? 1 : 0,
624
    was_renewed       => scalar $query->param('was_renewed') ? 1 : 0,
622
    expiry            => $borrower->{'dateexpiry'},
623
    roadtype          => $roadtype,
624
    amountold         => $amountold,
625
    amountold         => $amountold,
625
    barcodes          => $barcodes,
626
    barcodes          => $barcodes,
626
    stickyduedate     => $stickyduedate,
627
    stickyduedate     => $stickyduedate,
Lines 629-635 $template->param( Link Here
629
    message           => $message,
630
    message           => $message,
630
    totaldue          => sprintf('%.2f', $total),
631
    totaldue          => sprintf('%.2f', $total),
631
    inprocess         => $inprocess,
632
    inprocess         => $inprocess,
632
    is_child          => ($borrowernumber && $borrower->{'category_type'} eq 'C'),
633
    $view             => 1,
633
    $view             => 1,
634
    batch_allowed     => $batch_allowed,
634
    batch_allowed     => $batch_allowed,
635
    batch             => $batch,
635
    batch             => $batch,
Lines 643-650 $template->param( Link Here
643
    relatives_borrowernumbers => \@relatives,
643
    relatives_borrowernumbers => \@relatives,
644
);
644
);
645
645
646
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
647
$template->param( picture => 1 ) if $patron_image;
648
646
649
if ( C4::Context->preference("ExportCircHistory") ) {
647
if ( C4::Context->preference("ExportCircHistory") ) {
650
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
648
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
(-)a/circ/returns.pl (-53 / +59 lines)
Lines 30-35 script to execute returns of books Link Here
30
use strict;
30
use strict;
31
use warnings;
31
use warnings;
32
32
33
# FIXME There are weird things going on with $patron and $borrowernumber in this script
34
33
use Carp 'verbose';
35
use Carp 'verbose';
34
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
36
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
35
37
Lines 166-173 if ( $query->param('reserve_id') ) { Link Here
166
#   check if we have other reserves for this document, if we have a return send the message of transfer
168
#   check if we have other reserves for this document, if we have a return send the message of transfer
167
    my ( $messages, $nextreservinfo ) = GetOtherReserves($item);
169
    my ( $messages, $nextreservinfo ) = GetOtherReserves($item);
168
170
169
    my $borr = GetMember( borrowernumber => $nextreservinfo );
171
    my $patron = Koha::Patrons->find( $nextreservinfo );
170
    my $name   = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
172
    my $name   = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
171
    if ( $messages->{'transfert'} ) {
173
    if ( $messages->{'transfert'} ) {
172
        $template->param(
174
        $template->param(
173
            itemtitle      => $iteminfo->{'title'},
175
            itemtitle      => $iteminfo->{'title'},
Lines 176-185 if ( $query->param('reserve_id') ) { Link Here
176
            iteminfo       => $iteminfo->{'author'},
178
            iteminfo       => $iteminfo->{'author'},
177
            name           => $name,
179
            name           => $name,
178
            borrowernumber => $borrowernumber,
180
            borrowernumber => $borrowernumber,
179
            borcnum        => $borr->{'cardnumber'},
181
            borcnum        => $patron->cardnumber,
180
            borfirstname   => $borr->{'firstname'},
182
            borfirstname   => $patron->firstname,
181
            borsurname     => $borr->{'surname'},
183
            borsurname     => $patron->surname,
182
            borcategory    => $borr->{'description'},
184
            borcategory    => $patron->category->description,
183
            diffbranch     => 1,
185
            diffbranch     => 1,
184
        );
186
        );
185
    }
187
    }
Lines 403-429 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
403
    );
405
    );
404
406
405
    my $reserve    = $messages->{'ResFound'};
407
    my $reserve    = $messages->{'ResFound'};
406
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
408
    if ( $reserve ) {
407
    my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
409
        my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
410
        my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
411
        $template->param(
412
            # FIXME The full patron object should be passed to the template
413
                wname           => $name,
414
                wborfirstname   => $patron->firstname,
415
                wborsurname     => $patron->surname,
416
                wborcategory    => $patron->category->description,
417
                wbortitle       => $patron->title,
418
                wborphone       => $patron->phone,
419
                wboremail       => $patron->email,
420
                streetnumber    => $patron->streetnumber,
421
                address         => $patron->address,
422
                address2        => $patron->address2,
423
                city            => $patron->city,
424
                zipcode         => $patron->zipcode,
425
                state           => $patron->state,
426
                country         => $patron->country,
427
                wborrowernumber => $reserve->{'borrowernumber'},
428
                wborcnum        => $patron->cardnumber,
429
        );
430
    }
408
    $template->param(
431
    $template->param(
409
            wname           => $name,
432
        wtransfertFrom  => $userenv_branch,
410
            wborfirstname   => $borr->{'firstname'},
411
            wborsurname     => $borr->{'surname'},
412
            wborcategory    => $borr->{'description'},
413
            wbortitle       => $borr->{'title'},
414
            wborphone       => $borr->{'phone'},
415
            wboremail       => $borr->{'email'},
416
            streetnumber    => $borr->{streetnumber},
417
            streettype      => $borr->{streettype},
418
            address         => $borr->{'address'},
419
            address2        => $borr->{'address2'},
420
            city            => $borr->{'city'},
421
            zipcode         => $borr->{'zipcode'},
422
            state           => $borr->{'state'},
423
            country         => $borr->{'country'},
424
            wborrowernumber => $reserve->{'borrowernumber'},
425
            wborcnum        => $borr->{'cardnumber'},
426
            wtransfertFrom  => $userenv_branch,
427
    );
433
    );
428
}
434
}
429
435
Lines 432-438 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
432
#
438
#
433
if ( $messages->{'ResFound'}) {
439
if ( $messages->{'ResFound'}) {
434
    my $reserve    = $messages->{'ResFound'};
440
    my $reserve    = $messages->{'ResFound'};
435
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
441
    my $patron = Koha::Patrons->find( $reserve->{borrowernumber} );
436
    my $holdmsgpreferences =  C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name   => 'Hold_Filled' } );
442
    my $holdmsgpreferences =  C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name   => 'Hold_Filled' } );
437
    if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
443
    if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
438
        if ( $reserve->{'ResFound'} eq "Waiting" ) {
444
        if ( $reserve->{'ResFound'} eq "Waiting" ) {
Lines 450-474 if ( $messages->{'ResFound'}) { Link Here
450
456
451
        # same params for Waiting or Reserved
457
        # same params for Waiting or Reserved
452
        $template->param(
458
        $template->param(
459
            # FIXME The full patron object should be passed to the template
453
            found          => 1,
460
            found          => 1,
454
            name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
461
            name           => $patron->surname . ", " . $patron->title . " " . $patron->firstname,
455
            borfirstname   => $borr->{'firstname'},
462
            borfirstname   => $patron->firstname,
456
            borsurname     => $borr->{'surname'},
463
            borsurname     => $patron->surname,
457
            borcategory    => $borr->{'description'},
464
            borcategory    => $patron->category->description,
458
            bortitle       => $borr->{'title'},
465
            bortitle       => $patron->title,
459
            borphone       => $borr->{'phone'},
466
            borphone       => $patron->phone,
460
            boremail       => $borr->{'email'},
467
            boremail       => $patron->email,
461
            streetnumber   => $borr->{streetnumber},
468
            boraddress     => $patron->address,
462
            streettype     => $borr->{streettype},
469
            boraddress2    => $patron->address2,
463
            address        => $borr->{'address'},
470
            streetnumber   => $patron->streetnumber,
464
            address2       => $borr->{'address2'},
471
            city           => $patron->city,
465
            city           => $borr->{'city'},
472
            zipcode        => $patron->zipcode,
466
            zipcode        => $borr->{'zipcode'},
473
            state          => $patron->state,
467
            state          => $borr->{'state'},
474
            country        => $patron->country,
468
            country        => $borr->{'country'},
475
            borcnum        => $patron->cardnumber,
469
            borcnum        => $borr->{'cardnumber'},
476
            debarred       => $patron->debarred,
470
            debarred       => $borr->{'debarred'},
477
            gonenoaddress  => $patron->gonenoaddress,
471
            gonenoaddress  => $borr->{'gonenoaddress'},
472
            barcode        => $barcode,
478
            barcode        => $barcode,
473
            destbranch     => $reserve->{'branchcode'},
479
            destbranch     => $reserve->{'branchcode'},
474
            borrowernumber => $reserve->{'borrowernumber'},
480
            borrowernumber => $reserve->{'borrowernumber'},
Lines 576-594 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
576
            $ri{hour}   = $duedate->hour();
582
            $ri{hour}   = $duedate->hour();
577
            $ri{minute}   = $duedate->minute();
583
            $ri{minute}   = $duedate->minute();
578
            $ri{duedate} = output_pref($duedate);
584
            $ri{duedate} = output_pref($duedate);
579
            my $b      = C4::Members::GetMember( borrowernumber => $riborrowernumber{$_} );
585
            my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
580
            unless ( $dropboxmode ) {
586
            unless ( $dropboxmode ) {
581
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
587
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
582
            } else {
588
            } else {
583
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
589
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
584
            }
590
            }
585
            $ri{borrowernumber} = $b->{'borrowernumber'};
591
            $ri{borrowernumber} = $patron->borrowernumber;
586
            $ri{borcnum}        = $b->{'cardnumber'};
592
            $ri{borcnum}        = $patron->cardnumber;
587
            $ri{borfirstname}   = $b->{'firstname'};
593
            $ri{borfirstname}   = $patron->firstname;
588
            $ri{borsurname}     = $b->{'surname'};
594
            $ri{borsurname}     = $patron->surname;
589
            $ri{bortitle}       = $b->{'title'};
595
            $ri{bortitle}       = $patron->title;
590
            $ri{bornote}        = $b->{'borrowernotes'};
596
            $ri{bornote}        = $patron->borrowernotes;
591
            $ri{borcategorycode}= $b->{'categorycode'};
597
            $ri{borcategorycode}= $patron->categorycode;
592
            $ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
598
            $ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
593
        }
599
        }
594
        else {
600
        else {
(-)a/circ/transferstoreceive.pl (-6 / +8 lines)
Lines 40-45 use Koha::ItemTypes; Link Here
40
use Koha::Libraries;
40
use Koha::Libraries;
41
use Koha::DateUtils;
41
use Koha::DateUtils;
42
use Koha::BiblioFrameworks;
42
use Koha::BiblioFrameworks;
43
use Koha::Patrons;
43
44
44
my $input = new CGI;
45
my $input = new CGI;
45
my $itemnumber = $input->param('itemnumber');
46
my $itemnumber = $input->param('itemnumber');
Lines 105-116 while ( my $library = $libraries->next ) { Link Here
105
            my $item = Koha::Items->find( $num->{itemnumber} );
106
            my $item = Koha::Items->find( $num->{itemnumber} );
106
            my $holds = $item->current_holds;
107
            my $holds = $item->current_holds;
107
            if ( my $first_hold = $holds->next ) {
108
            if ( my $first_hold = $holds->next ) {
108
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
109
                my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
109
                $getransf{'borrowernum'}       = $getborrower->{'borrowernumber'};
110
                # FIXME The full patron object should be passed to the template
110
                $getransf{'borrowername'}      = $getborrower->{'surname'};
111
                $getransf{'borrowernum'}       = $patron->borrowernumber;
111
                $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
112
                $getransf{'borrowername'}      = $patron->surname;
112
                $getransf{'borrowermail'}      = $getborrower->{'email'} if $getborrower->{'email'};
113
                $getransf{'borrowerfirstname'} = $patron->firstname;
113
                $getransf{'borrowerphone'}     = $getborrower->{'phone'};
114
                $getransf{'borrowermail'}      = $patron->email if $patron->email;
115
                $getransf{'borrowerphone'}     = $patron->phone;
114
            }
116
            }
115
            push( @transferloop, \%getransf );
117
            push( @transferloop, \%getransf );
116
        }
118
        }
(-)a/circ/waitingreserves.pl (-7 / +8 lines)
Lines 38-43 use C4::Koha; Link Here
38
use Koha::DateUtils;
38
use Koha::DateUtils;
39
use Koha::BiblioFrameworks;
39
use Koha::BiblioFrameworks;
40
use Koha::ItemTypes;
40
use Koha::ItemTypes;
41
use Koha::Patrons;
41
42
42
my $input = new CGI;
43
my $input = new CGI;
43
44
Lines 104-110 foreach my $num (@getreserves) { Link Here
104
105
105
    # fix up item type for display
106
    # fix up item type for display
106
    $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
107
    $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
107
    my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
108
    my $patron = Koha::Patrons->find( $num->{borrowernumber} );
108
    my $itemtype = Koha::ItemTypes->find( $gettitle->{'itemtype'} );  # using the fixed up itype/itemtype
109
    my $itemtype = Koha::ItemTypes->find( $gettitle->{'itemtype'} );  # using the fixed up itype/itemtype
109
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
110
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
110
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
111
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
Lines 123-131 foreach my $num (@getreserves) { Link Here
123
    if ( $homebranch ne $holdingbranch ) {
124
    if ( $homebranch ne $holdingbranch ) {
124
        $getreserv{'dotransfer'} = 1;
125
        $getreserv{'dotransfer'} = 1;
125
    }
126
    }
126
    $getreserv{'borrowername'}      = $getborrower->{'surname'};
127
    $getreserv{'borrowername'}      = $patron->surname;
127
    $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
128
    $getreserv{'borrowerfirstname'} = $patron->firstname;
128
    $getreserv{'borrowerphone'}     = $getborrower->{'phone'};
129
    $getreserv{'borrowerphone'}     = $patron->phone;
129
130
130
    my $borEmail = GetFirstValidEmailAddress( $borrowernum );
131
    my $borEmail = GetFirstValidEmailAddress( $borrowernum );
131
132
Lines 189-195 sub cancel { Link Here
189
    # if we have a result
190
    # if we have a result
190
    if ($nextreservinfo) {
191
    if ($nextreservinfo) {
191
        my %res;
192
        my %res;
192
        my $borrowerinfo = C4::Members::GetMember( borrowernumber => $nextreservinfo );
193
        my $patron = Koha::Patrons->find( $nextreservinfo );
193
        my $iteminfo = GetBiblioFromItemNumber($item);
194
        my $iteminfo = GetBiblioFromItemNumber($item);
194
        if ( $messages->{'transfert'} ) {
195
        if ( $messages->{'transfert'} ) {
195
            $res{messagetransfert} = $messages->{'transfert'};
196
            $res{messagetransfert} = $messages->{'transfert'};
Lines 198-205 sub cancel { Link Here
198
199
199
        $res{message}             = 1;
200
        $res{message}             = 1;
200
        $res{nextreservnumber}    = $nextreservinfo;
201
        $res{nextreservnumber}    = $nextreservinfo;
201
        $res{nextreservsurname}   = $borrowerinfo->{'surname'};
202
        $res{nextreservsurname}   = $patron->surname;
202
        $res{nextreservfirstname} = $borrowerinfo->{'firstname'};
203
        $res{nextreservfirstname} = $patron->firstname;
203
        $res{nextreservitem}      = $item;
204
        $res{nextreservitem}      = $item;
204
        $res{nextreservtitle}     = $iteminfo->{'title'};
205
        $res{nextreservtitle}     = $iteminfo->{'title'};
205
        $res{waiting}             = $messages->{'waiting'} ? 1 : 0;
206
        $res{waiting}             = $messages->{'waiting'} ? 1 : 0;
(-)a/members/boraccount.pl (-10 / +8 lines)
Lines 31-38 use CGI qw ( -utf8 ); Link Here
31
use C4::Members;
31
use C4::Members;
32
use C4::Accounts;
32
use C4::Accounts;
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use Koha::Patron::Images;
34
use Koha::Patrons;
35
36
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
37
36
38
my $input=new CGI;
37
my $input=new CGI;
Lines 53-66 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
53
my $borrowernumber=$input->param('borrowernumber');
52
my $borrowernumber=$input->param('borrowernumber');
54
my $action = $input->param('action') || '';
53
my $action = $input->param('action') || '';
55
54
56
#get borrower details
55
#get patron details
57
my $data=GetMember('borrowernumber' => $borrowernumber);
56
my $patron = Koha::Patrons->find( $borrowernumber );
58
57
59
if ( $action eq 'reverse' ) {
58
if ( $action eq 'reverse' ) {
60
  ReversePayment( $input->param('accountlines_id') );
59
  ReversePayment( $input->param('accountlines_id') );
61
}
60
}
62
61
63
if ( $data->{'category_type'} eq 'C') {
62
if ( $patron->category->category_type eq 'C') {
64
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
63
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
65
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
64
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
66
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
65
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
Lines 92-101 foreach my $accountline ( @{$accts}) { Link Here
92
    }
91
    }
93
}
92
}
94
93
95
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
94
$template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
96
95
97
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
96
$template->param( picture => 1 ) if $patron->image;
98
$template->param( picture => 1 ) if $patron_image;
99
97
100
if (C4::Context->preference('ExtendedPatronAttributes')) {
98
if (C4::Context->preference('ExtendedPatronAttributes')) {
101
    my $attributes = GetBorrowerAttributes($borrowernumber);
99
    my $attributes = GetBorrowerAttributes($borrowernumber);
Lines 105-118 if (C4::Context->preference('ExtendedPatronAttributes')) { Link Here
105
    );
103
    );
106
}
104
}
107
105
108
$template->param(%$data);
106
$template->param(%{ $patron->unblessed });
109
107
110
$template->param(
108
$template->param(
111
    finesview           => 1,
109
    finesview           => 1,
112
    borrowernumber      => $borrowernumber,
110
    borrowernumber      => $borrowernumber,
113
    total               => sprintf("%.2f",$total),
111
    total               => sprintf("%.2f",$total),
114
    totalcredit         => $totalcredit,
112
    totalcredit         => $totalcredit,
115
    is_child            => ($data->{'category_type'} eq 'C'),
113
    is_child            => ($patron->category->category_type eq 'C'),
116
    reverse_col         => $reverse_col,
114
    reverse_col         => $reverse_col,
117
    accounts            => $accts,
115
    accounts            => $accts,
118
    RoutingSerials => C4::Context->preference('RoutingSerials'),
116
    RoutingSerials => C4::Context->preference('RoutingSerials'),
(-)a/members/deletemem.pl (-27 / +27 lines)
Lines 31-37 use C4::Auth; Link Here
31
use C4::Members;
31
use C4::Members;
32
use Module::Load;
32
use Module::Load;
33
use Koha::Patrons;
33
use Koha::Patrons;
34
use Koha::Patron::Images;
35
use Koha::Token;
34
use Koha::Token;
36
35
37
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
36
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
Lines 75-87 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
75
my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
74
my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
76
my $countissues = scalar(@$issues);
75
my $countissues = scalar(@$issues);
77
76
78
my $bor = C4::Members::GetMember( borrowernumber => $member );
77
my $patron = Koha::Patrons->find( $member );
79
my $flags = C4::Members::patronflags( $bor );
78
my $flags = C4::Members::patronflags( $patron->unblessed );
80
my $userenv = C4::Context->userenv;
79
my $userenv = C4::Context->userenv;
81
80
82
 
81
 
83
82
84
if ($bor->{category_type} eq "S") {
83
if ($patron->category->category_type eq "S") {
85
    unless(C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) {
84
    unless(C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) {
86
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF");
85
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF");
87
        exit 0; # Exit without error
86
        exit 0; # Exit without error
Lines 95-102 if ($bor->{category_type} eq "S") { Link Here
95
94
96
if (C4::Context->preference("IndependentBranches")) {
95
if (C4::Context->preference("IndependentBranches")) {
97
    my $userenv = C4::Context->userenv;
96
    my $userenv = C4::Context->userenv;
98
    if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
97
    if ( !C4::Context->IsSuperLibrarian() && $patron->branchcode){
99
        unless ($userenv->{branch} eq $bor->{'branchcode'}){
98
        unless ($userenv->{branch} eq $patron->branchcode){
100
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
99
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
101
            exit 0; # Exit without error
100
            exit 0; # Exit without error
102
        }
101
        }
Lines 107-133 my $op = $input->param('op') || 'delete_confirm'; Link Here
107
my $dbh = C4::Context->dbh;
106
my $dbh = C4::Context->dbh;
108
my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
107
my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
109
if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'}  or $is_guarantor or $deletelocal == 0) {
108
if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'}  or $is_guarantor or $deletelocal == 0) {
110
    my $patron_image = Koha::Patron::Images->find($bor->{borrowernumber});
109
    $template->param( picture => 1 ) if $patron->image;
111
    $template->param( picture => 1 ) if $patron_image;
110
112
111
    $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/;
113
    $template->param( adultborrower => 1 ) if ( $bor->{category_type} eq 'A' || $bor->{category_type} eq 'I' );
112
114
113
    $template->param(
115
    $template->param(borrowernumber => $member,
114
        # FIXME The patron object should be passed to the template
116
        surname => $bor->{'surname'},
115
        borrowernumber => $patron->borrowernumber,
117
        title => $bor->{'title'},
116
        surname => $patron->surname,
118
        cardnumber => $bor->{'cardnumber'},
117
        title => $patron->title,
119
        firstname => $bor->{'firstname'},
118
        cardnumber => $patron->cardnumber,
120
        categorycode => $bor->{'categorycode'},
119
        firstname => $patron->firstname,
121
        category_type => $bor->{'category_type'},
120
        categorycode => $patron->categorycode,
122
        categoryname  => $bor->{'description'},
121
        category_type => $patron->category->category_type,
123
        address => $bor->{'address'},
122
        categoryname  => $patron->category->description,
124
        address2 => $bor->{'address2'},
123
        address => $patron->address,
125
        city => $bor->{'city'},
124
        address2 => $patron->address2,
126
        zipcode => $bor->{'zipcode'},
125
        city => $patron->city,
127
        country => $bor->{'country'},
126
        zipcode => $patron->zipcode,
128
        phone => $bor->{'phone'},
127
        country => $patron->country,
129
        email => $bor->{'email'},
128
        phone => $patron->phone,
130
        branchcode => $bor->{'branchcode'},
129
        email => $patron->email,
130
        branchcode => $patron->branchcode,
131
        RoutingSerials => C4::Context->preference('RoutingSerials'),
131
        RoutingSerials => C4::Context->preference('RoutingSerials'),
132
    );
132
    );
133
    if ($countissues >0) {
133
    if ($countissues >0) {
(-)a/members/discharge.pl (-27 / +22 lines)
Lines 37-43 use C4::Members; Link Here
37
use C4::Reserves;
37
use C4::Reserves;
38
use C4::Letters;
38
use C4::Letters;
39
use Koha::Patron::Discharge;
39
use Koha::Patron::Discharge;
40
use Koha::Patron::Images;
41
use Koha::Patrons;
40
use Koha::Patrons;
42
41
43
use Koha::DateUtils;
42
use Koha::DateUtils;
Lines 59-77 unless ( C4::Context->preference('useDischarge') ) { Link Here
59
   exit;
58
   exit;
60
}
59
}
61
60
62
my $data;
63
if ( $input->param('borrowernumber') ) {
61
if ( $input->param('borrowernumber') ) {
64
    $borrowernumber = $input->param('borrowernumber');
62
    $borrowernumber = $input->param('borrowernumber');
65
63
66
    # Getting member data
64
    # Getting member data
67
    $data = GetMember( borrowernumber => $borrowernumber );
65
    my $patron = Koha::Patrons->find( $borrowernumber );
68
66
69
    my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
67
    my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
70
        borrowernumber => $borrowernumber
68
        borrowernumber => $borrowernumber
71
    });
69
    });
72
70
73
    # Getting reserves
74
    my $patron = Koha::Patrons->find( $borrowernumber );
75
    my $holds = $patron->holds;
71
    my $holds = $patron->holds;
76
    my $has_reserves = $holds->count;
72
    my $has_reserves = $holds->count;
77
73
Lines 87-93 if ( $input->param('borrowernumber') ) { Link Here
87
        }
83
        }
88
        eval {
84
        eval {
89
            my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
85
            my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
90
                { borrowernumber => $borrowernumber, branchcode => $data->{'branchcode'} } );
86
                { borrowernumber => $borrowernumber, branchcode => $patron->branchcode } );
91
87
92
            binmode(STDOUT);
88
            binmode(STDOUT);
93
            print $input->header(
89
            print $input->header(
Lines 112-142 if ( $input->param('borrowernumber') ) { Link Here
112
        borrowernumber => $borrowernumber,
108
        borrowernumber => $borrowernumber,
113
    });
109
    });
114
110
115
    my $patron_image = Koha::Patron::Images->find($borrowernumber);
111
    $template->param( picture => 1 ) if $patron->image;
116
    $template->param( picture => 1 ) if $patron_image;
117
112
118
    $template->param(
113
    $template->param(
114
        # FIXME The patron object should be passed to the template
119
        borrowernumber    => $borrowernumber,
115
        borrowernumber    => $borrowernumber,
120
        biblionumber      => $data->{'biblionumber'},
116
        title             => $patron->title,
121
        title             => $data->{'title'},
117
        initials          => $patron->initials,
122
        initials          => $data->{'initials'},
118
        surname           => $patron->surname,
123
        surname           => $data->{'surname'},
124
        borrowernumber    => $borrowernumber,
119
        borrowernumber    => $borrowernumber,
125
        firstname         => $data->{'firstname'},
120
        firstname         => $patron->firstname,
126
        cardnumber        => $data->{'cardnumber'},
121
        cardnumber        => $patron->cardnumber,
127
        categorycode      => $data->{'categorycode'},
122
        categorycode      => $patron->categorycode,
128
        category_type     => $data->{'category_type'},
123
        category_type     => $patron->category->category_type,
129
        categoryname      => $data->{'description'},
124
        categoryname      => $patron->category->description,
130
        address           => $data->{'address'},
125
        address           => $patron->address,
131
        streetnumber      => $data->{streetnumber},
126
        streetnumber      => $patron->streetnumber,
132
        streettype        => $data->{streettype},
127
        streettype        => $patron->streettype,
133
        address2          => $data->{'address2'},
128
        address2          => $patron->address2,
134
        city              => $data->{'city'},
129
        city              => $patron->city,
135
        zipcode           => $data->{'zipcode'},
130
        zipcode           => $patron->zipcode,
136
        country           => $data->{'country'},
131
        country           => $patron->country,
137
        phone             => $data->{'phone'},
132
        phone             => $patron->phone,
138
        email             => $data->{'email'},
133
        email             => $patron->email,
139
        branchcode        => $data->{'branchcode'},
134
        branchcode        => $patron->branchcode,
140
        has_reserves      => $has_reserves,
135
        has_reserves      => $has_reserves,
141
        can_be_discharged => $can_be_discharged,
136
        can_be_discharged => $can_be_discharged,
142
        validated_discharges => $validated_discharges,
137
        validated_discharges => $validated_discharges,
(-)a/members/files.pl (-6 / +5 lines)
Lines 29-36 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
29
use C4::Debug;
29
use C4::Debug;
30
30
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Patrons;
32
use Koha::Patron::Files;
33
use Koha::Patron::Files;
33
use Koha::Patron::Images;
34
34
35
my $cgi = CGI->new;
35
my $cgi = CGI->new;
36
36
Lines 63-70 if ( $op eq 'download' ) { Link Here
63
    print $file->{'file_content'};
63
    print $file->{'file_content'};
64
}
64
}
65
else {
65
else {
66
    my $data = GetMember( borrowernumber => $borrowernumber );
66
    my $patron = Koha::Patrons->find( $borrowernumber );
67
    $template->param(%$data);
67
    $template->param(%{ $patron->unblessed});
68
68
69
    my %errors;
69
    my %errors;
70
70
Lines 102-108 else { Link Here
102
    }
102
    }
103
103
104
    $template->param(
104
    $template->param(
105
        categoryname    => $data->{'description'},
105
        categoryname    => $patron->category->description,
106
        RoutingSerials => C4::Context->preference('RoutingSerials'),
106
        RoutingSerials => C4::Context->preference('RoutingSerials'),
107
    );
107
    );
108
108
Lines 114-121 else { Link Here
114
        );
114
        );
115
    }
115
    }
116
116
117
    my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
117
    $template->param( picture => 1 ) if $patron->image;
118
    $template->param( picture => 1 ) if $patron_image;
119
118
120
    $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' || $data->{category_type} eq 'I' );
119
    $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' || $data->{category_type} eq 'I' );
121
    $template->param(
120
    $template->param(
(-)a/members/housebound.pl (-1 / +1 lines)
Lines 66-72 push @messages, { type => 'error', code => 'error_on_patron_load' } Link Here
66
# Get supporting cast
66
# Get supporting cast
67
my ( $branch, $category, $houseboundprofile, $visit, $patron_image );
67
my ( $branch, $category, $houseboundprofile, $visit, $patron_image );
68
if ( $patron ) {
68
if ( $patron ) {
69
    $patron_image = Koha::Patron::Images->find($patron->borrowernumber);
69
    $patron_image = $patron->image;
70
    $branch = Koha::Libraries->new->find($patron->branchcode);
70
    $branch = Koha::Libraries->new->find($patron->branchcode);
71
    $category = Koha::Patron::Categories->new->find($patron->categorycode);
71
    $category = Koha::Patron::Categories->new->find($patron->categorycode);
72
    $houseboundprofile = $patron->housebound_profile;
72
    $houseboundprofile = $patron->housebound_profile;
(-)a/members/mancredit.pl (-10 / +8 lines)
Lines 33-39 use C4::Members; Link Here
33
use C4::Accounts;
33
use C4::Accounts;
34
use C4::Items;
34
use C4::Items;
35
use C4::Members::Attributes qw(GetBorrowerAttributes);
35
use C4::Members::Attributes qw(GetBorrowerAttributes);
36
use Koha::Patron::Images;
36
use Koha::Patrons;
37
37
38
use Koha::Patron::Categories;
38
use Koha::Patron::Categories;
39
39
Lines 42-49 my $flagsrequired = { borrowers => 1, updatecharges => 1 }; Link Here
42
42
43
my $borrowernumber=$input->param('borrowernumber');
43
my $borrowernumber=$input->param('borrowernumber');
44
44
45
#get borrower details
45
my $patron = Koha::Patrons->find( $borrowernumber );
46
my $data=GetMember('borrowernumber' => $borrowernumber);
47
my $add=$input->param('add');
46
my $add=$input->param('add');
48
47
49
if ($add){
48
if ($add){
Lines 74-88 if ($add){ Link Here
74
        }
73
        }
75
    );
74
    );
76
					  
75
					  
77
    if ( $data->{'category_type'} eq 'C') {
76
    if ( $patron->category->category_type eq 'C') {
78
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
77
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
79
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
78
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
80
        $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
79
        $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
81
    }
80
    }
82
81
83
    $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' || $data->{category_type} eq 'I' );
82
    $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
84
    my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
83
    $template->param( picture => 1 ) if $patron->image;
85
    $template->param( picture => 1 ) if $patron_image;
86
84
87
    if (C4::Context->preference('ExtendedPatronAttributes')) {
85
    if (C4::Context->preference('ExtendedPatronAttributes')) {
88
        my $attributes = GetBorrowerAttributes($borrowernumber);
86
        my $attributes = GetBorrowerAttributes($borrowernumber);
Lines 92-104 if ($add){ Link Here
92
        );
90
        );
93
    }
91
    }
94
92
95
    $template->param(%$data);
93
    $template->param(%{ $patron->unblessed});
96
94
97
    $template->param(
95
    $template->param(
98
        finesview      => 1,
96
        finesview      => 1,
99
        borrowernumber => $borrowernumber,
97
        borrowernumber => $borrowernumber,
100
        categoryname   => $data->{'description'},
98
        categoryname   => $patron->category->description,
101
        is_child       => ($data->{'category_type'} eq 'C'),
99
        is_child       => ($patron->category->category_type eq 'C'), # FIXME is_child should be a Koha::Patron method
102
        RoutingSerials => C4::Context->preference('RoutingSerials'),
100
        RoutingSerials => C4::Context->preference('RoutingSerials'),
103
        );
101
        );
104
    output_html_with_http_headers $input, $cookie, $template->output;
102
    output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/maninvoice.pl (-11 / +9 lines)
Lines 32-38 use C4::Members; Link Here
32
use C4::Accounts;
32
use C4::Accounts;
33
use C4::Items;
33
use C4::Items;
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
35
use Koha::Patron::Images;
35
36
use Koha::Patrons;
36
37
37
use Koha::Patron::Categories;
38
use Koha::Patron::Categories;
38
39
Lines 41-49 my $flagsrequired = { borrowers => 1 }; Link Here
41
42
42
my $borrowernumber=$input->param('borrowernumber');
43
my $borrowernumber=$input->param('borrowernumber');
43
44
44
45
my $patron = Koha::Patrons->find( $borrowernumber );
45
# get borrower details
46
my $data=GetMember('borrowernumber'=>$borrowernumber);
47
my $add=$input->param('add');
46
my $add=$input->param('add');
48
if ($add){
47
if ($add){
49
    if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
48
    if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
Lines 100-114 if ($add){ Link Here
100
  }
99
  }
101
  $template->param( invoice_types_loop => \@invoice_types );
100
  $template->param( invoice_types_loop => \@invoice_types );
102
101
103
    if ( $data->{'category_type'} eq 'C') {
102
    if ( $patron->category->category_type eq 'C') {
104
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
103
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
105
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
104
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
106
        $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
105
        $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
107
    }
106
    }
108
107
109
    $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
108
    $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
110
    my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
109
    $template->param( picture => 1 ) if $patron->image;
111
    $template->param( picture => 1 ) if $patron_image;
112
110
113
    if (C4::Context->preference('ExtendedPatronAttributes')) {
111
    if (C4::Context->preference('ExtendedPatronAttributes')) {
114
        my $attributes = GetBorrowerAttributes($borrowernumber);
112
        my $attributes = GetBorrowerAttributes($borrowernumber);
Lines 118-129 if ($add){ Link Here
118
        );
116
        );
119
    }
117
    }
120
118
121
    $template->param(%$data);
119
    $template->param(%{ $patron->unblessed });
122
    $template->param(
120
    $template->param(
123
        finesview      => 1,
121
        finesview      => 1,
124
        borrowernumber => $borrowernumber,
122
        borrowernumber => $borrowernumber,
125
        categoryname   => $data->{'description'},
123
        categoryname   => $patron->category->description,
126
        is_child       => ($data->{'category_type'} eq 'C'),
124
        is_child       => ($patron->category->category_type eq 'C'),
127
        RoutingSerials => C4::Context->preference('RoutingSerials'),
125
        RoutingSerials => C4::Context->preference('RoutingSerials'),
128
    );
126
    );
129
    output_html_with_http_headers $input, $cookie, $template->output;
127
    output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/member-flags.pl (-8 / +10 lines)
Lines 16-21 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
16
#use C4::Acquisitions;
16
#use C4::Acquisitions;
17
17
18
use Koha::Patron::Categories;
18
use Koha::Patron::Categories;
19
use Koha::Patrons;
19
20
20
use C4::Output;
21
use C4::Output;
21
use Koha::Patron::Images;
22
use Koha::Patron::Images;
Lines 25-32 my $input = new CGI; Link Here
25
26
26
my $flagsrequired = { permissions => 1 };
27
my $flagsrequired = { permissions => 1 };
27
my $member=$input->param('member');
28
my $member=$input->param('member');
28
my $bor = GetMember( borrowernumber => $member );
29
my $patron = Koha::Patrons->find( $member );
29
if( $bor->{'category_type'} eq 'S' )  {
30
my $category_type = $patron->category->category_type;
31
my $bor = $patron->unblessed;
32
if( $category_type eq 'S' )  {
30
	$flagsrequired->{'staffaccess'} = 1;
33
	$flagsrequired->{'staffaccess'} = 1;
31
}
34
}
32
my ($template, $loggedinuser, $cookie) = get_template_and_user({
35
my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 170-184 if ($input->param('newflags')) { Link Here
170
	    push @loop, \%row;
173
	    push @loop, \%row;
171
    }
174
    }
172
175
173
    if ( $bor->{'category_type'} eq 'C') {
176
    if ( $category_type eq 'C') {
174
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
177
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
175
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
178
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
176
        $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
179
        $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
177
    }
180
    }
178
	
181
	
179
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' || $bor->{'category_type'} eq 'I' );
182
$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
180
    my $patron_image = Koha::Patron::Images->find($bor->{borrowernumber});
183
    $template->param( picture => 1 ) if $patron->image;
181
    $template->param( picture => 1 ) if $patron_image;
182
184
183
if (C4::Context->preference('ExtendedPatronAttributes')) {
185
if (C4::Context->preference('ExtendedPatronAttributes')) {
184
    my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
186
    my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
Lines 195-201 $template->param( Link Here
195
		firstname => $bor->{'firstname'},
197
		firstname => $bor->{'firstname'},
196
        othernames => $bor->{'othernames'},
198
        othernames => $bor->{'othernames'},
197
		categorycode => $bor->{'categorycode'},
199
		categorycode => $bor->{'categorycode'},
198
		category_type => $bor->{'category_type'},
200
		category_type => $category_type,
199
		categoryname => $bor->{'description'},
201
		categoryname => $bor->{'description'},
200
        address => $bor->{address},
202
        address => $bor->{address},
201
		address2 => $bor->{'address2'},
203
		address2 => $bor->{'address2'},
Lines 211-217 $template->param( Link Here
211
        emailpro => $bor->{'emailpro'},
213
        emailpro => $bor->{'emailpro'},
212
		branchcode => $bor->{'branchcode'},
214
		branchcode => $bor->{'branchcode'},
213
		loop => \@loop,
215
		loop => \@loop,
214
		is_child        => ($bor->{'category_type'} eq 'C'),
216
		is_child        => ($category_type eq 'C'),
215
        RoutingSerials => C4::Context->preference('RoutingSerials'),
217
        RoutingSerials => C4::Context->preference('RoutingSerials'),
216
        csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID'), } ),
218
        csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID'), } ),
217
		);
219
		);
(-)a/members/member-password.pl (-9 / +10 lines)
Lines 15-23 use C4::Members; Link Here
15
use C4::Circulation;
15
use C4::Circulation;
16
use CGI qw ( -utf8 );
16
use CGI qw ( -utf8 );
17
use C4::Members::Attributes qw(GetBorrowerAttributes);
17
use C4::Members::Attributes qw(GetBorrowerAttributes);
18
use Koha::Patron::Images;
19
use Koha::Token;
18
use Koha::Token;
20
19
20
use Koha::Patrons;
21
use Koha::Patron::Categories;
21
use Koha::Patron::Categories;
22
22
23
my $input = new CGI;
23
my $input = new CGI;
Lines 48-56 my $newpassword2 = $input->param('newpassword2'); Link Here
48
48
49
my @errors;
49
my @errors;
50
50
51
my ($bor) = GetMember( 'borrowernumber' => $member );
51
my $patron = Koha::Patrons->find( $member );
52
my $category_type = $patron->category->category_type;
53
my $bor = $patron->unblessed;
52
54
53
if ( ( $member ne $loggedinuser ) && ( $bor->{'category_type'} eq 'S' ) ) {
55
if ( ( $member ne $loggedinuser ) && ( $category_type eq 'S' ) ) {
54
    push( @errors, 'NOPERMISSION' )
56
    push( @errors, 'NOPERMISSION' )
55
      unless ( $staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
57
      unless ( $staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
56
58
Lines 99-114 else { Link Here
99
    $template->param( defaultnewpassword => $defaultnewpassword );
101
    $template->param( defaultnewpassword => $defaultnewpassword );
100
}
102
}
101
103
102
if ( $bor->{'category_type'} eq 'C') {
104
if ( $category_type eq 'C') {
103
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
105
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
104
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
106
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
105
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
107
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
106
}
108
}
107
109
108
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' || $bor->{'category_type'} eq 'I' );
110
$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
109
111
110
my $patron_image = Koha::Patron::Images->find($bor->{borrowernumber});
112
$template->param( picture => 1 ) if $patron->image;
111
$template->param( picture => 1 ) if $patron_image;
112
113
113
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
114
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
114
    my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} );
115
    my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} );
Lines 125-131 $template->param( Link Here
125
    borrowernumber             => $bor->{'borrowernumber'},
126
    borrowernumber             => $bor->{'borrowernumber'},
126
    cardnumber                 => $bor->{'cardnumber'},
127
    cardnumber                 => $bor->{'cardnumber'},
127
    categorycode               => $bor->{'categorycode'},
128
    categorycode               => $bor->{'categorycode'},
128
    category_type              => $bor->{'category_type'},
129
    category_type              => $category_type,
129
    categoryname               => $bor->{'description'},
130
    categoryname               => $bor->{'description'},
130
    address                    => $bor->{address},
131
    address                    => $bor->{address},
131
    address2                   => $bor->{'address2'},
132
    address2                   => $bor->{'address2'},
Lines 143-149 $template->param( Link Here
143
    branchcode                 => $bor->{'branchcode'},
144
    branchcode                 => $bor->{'branchcode'},
144
    userid                     => $bor->{'userid'},
145
    userid                     => $bor->{'userid'},
145
    destination                => $destination,
146
    destination                => $destination,
146
    is_child                   => ( $bor->{'category_type'} eq 'C' ),
147
    is_child                   => ( $category_type eq 'C' ),
147
    minPasswordLength          => $minpw,
148
    minPasswordLength          => $minpw,
148
    RoutingSerials             => C4::Context->preference('RoutingSerials'),
149
    RoutingSerials             => C4::Context->preference('RoutingSerials'),
149
    csrf_token                 => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID'), }),
150
    csrf_token                 => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID'), }),
(-)a/members/member.pl (-7 / +4 lines)
Lines 27-35 use Modern::Perl; Link Here
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Output;
28
use C4::Output;
29
use CGI qw( -utf8 );
29
use CGI qw( -utf8 );
30
use C4::Members qw( GetMember );
31
use Koha::DateUtils;
30
use Koha::DateUtils;
32
use Koha::List::Patron;
31
use Koha::List::Patron;
32
use Koha::Patrons;
33
33
34
my $input = new CGI;
34
my $input = new CGI;
35
35
Lines 52-63 if ( $quicksearch and $searchmember ) { Link Here
52
        my $userenv = C4::Context->userenv;
52
        my $userenv = C4::Context->userenv;
53
        $branchcode = $userenv->{'branch'};
53
        $branchcode = $userenv->{'branch'};
54
    }
54
    }
55
    my $member = GetMember(
55
    my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
56
        cardnumber => $searchmember,
56
    if( ( $branchcode and $patron->branchcode eq $branchcode ) or ( not $branchcode and $patron ) ){
57
        ( $branchcode ? ( branchcode => $branchcode ) : () ),
57
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber);
58
    );
59
    if( $member ){
60
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $member->{borrowernumber});
61
        exit;
58
        exit;
62
    }
59
    }
63
}
60
}
(-)a/members/memberentry.pl (-4 / +10 lines)
Lines 42-47 use Koha::Patron::Debarments; Link Here
42
use Koha::Cities;
42
use Koha::Cities;
43
use Koha::DateUtils;
43
use Koha::DateUtils;
44
use Koha::Libraries;
44
use Koha::Libraries;
45
use Koha::Patrons;
45
use Koha::Patron::Categories;
46
use Koha::Patron::Categories;
46
use Koha::Patron::HouseboundRole;
47
use Koha::Patron::HouseboundRole;
47
use Koha::Patron::HouseboundRoles;
48
use Koha::Patron::HouseboundRoles;
Lines 152-158 $template->param( "add" => 1 ) if ( $op eq 'add' ); Link Here
152
$template->param( "quickadd" => 1 ) if ( $quickadd );
153
$template->param( "quickadd" => 1 ) if ( $quickadd );
153
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
154
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
154
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
155
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
155
( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
156
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
157
    my $patron = Koha::Patrons->find( $borrowernumber );
158
    $borrower_data = $patron->unblessed;
159
    $borrower_data->{category_type} = $patron->category->category_type;
160
}
156
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
161
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
157
my $category_type = $input->param('category_type') || '';
162
my $category_type = $input->param('category_type') || '';
158
unless ($category_type or !($categorycode)){
163
unless ($category_type or !($categorycode)){
Lines 242-248 if ( ( $op eq 'insert' ) and !$nodouble ) { Link Here
242
247
243
  #recover all data from guarantor address phone ,fax... 
248
  #recover all data from guarantor address phone ,fax... 
244
if ( $guarantorid ) {
249
if ( $guarantorid ) {
245
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
250
    if (my $guarantor = Koha::Patrons->find( $guarantorid )) {
251
        my $guarantordata = $guarantor->unblessed;
246
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
252
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
247
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
253
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
248
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
254
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
Lines 307-314 if ($op eq 'save' || $op eq 'insert'){ Link Here
307
313
308
    my $dateofbirth;
314
    my $dateofbirth;
309
    if ($op eq 'save' && $step == 3) {
315
    if ($op eq 'save' && $step == 3) {
310
        my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
316
        my $patron = Koha::Patrons->find( $borrowernumber );
311
        $dateofbirth = $borrower->{dateofbirth};
317
        $dateofbirth = $patron->dateofbirth;
312
    }
318
    }
313
    else {
319
    else {
314
        $dateofbirth = $newdata{dateofbirth};
320
        $dateofbirth = $newdata{dateofbirth};
(-)a/members/moremember.pl (-12 / +9 lines)
Lines 120-125 my $error = $input->param('error'); Link Here
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 $patron        = Koha::Patrons->find($borrowernumber);
123
unless ( $patron ) {
124
    $template->param (unknowuser => 1);
125
    output_html_with_http_headers $input, $cookie, $template->output;
126
    exit;
127
}
128
123
my $issues        = $patron->checkouts;
129
my $issues        = $patron->checkouts;
124
my $balance       = $patron->account->balance;
130
my $balance       = $patron->account->balance;
125
$template->param(
131
$template->param(
Lines 127-142 $template->param( Link Here
127
    fines      => $balance,
133
    fines      => $balance,
128
);
134
);
129
135
130
136
my $category_type = $patron->category->category_type;
131
my $data = GetMember( 'borrowernumber' => $borrowernumber );
137
my $data = $patron->unblessed;
132
133
if ( not defined $data ) {
134
    $template->param (unknowuser => 1);
135
	output_html_with_http_headers $input, $cookie, $template->output;
136
    exit;
137
}
138
139
my $category_type = $data->{'category_type'};
140
138
141
$debug and printf STDERR "dates (enrolled,expiry,birthdate) raw: (%s, %s, %s)\n", map {$data->{$_}} qw(dateenrolled dateexpiry dateofbirth);
139
$debug and printf STDERR "dates (enrolled,expiry,birthdate) raw: (%s, %s, %s)\n", map {$data->{$_}} qw(dateenrolled dateexpiry dateofbirth);
142
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
140
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
Lines 279-286 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
279
# check to see if patron's image exists in the database
277
# check to see if patron's image exists in the database
280
# basically this gives us a template var to condition the display of
278
# basically this gives us a template var to condition the display of
281
# patronimage related interface on
279
# patronimage related interface on
282
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
280
$template->param( picture => 1 ) if $patron->image;
283
$template->param( picture => 1 ) if $patron_image;
284
# Generate CSRF token for upload and delete image buttons
281
# Generate CSRF token for upload and delete image buttons
285
$template->param(
282
$template->param(
286
    csrf_token => Koha::Token->new->generate_csrf({ session_id => $input->cookie('CGISESSID'),}),
283
    csrf_token => Koha::Token->new->generate_csrf({ session_id => $input->cookie('CGISESSID'),}),
(-)a/members/notices.pl (-6 / +5 lines)
Lines 27-40 use CGI qw ( -utf8 ); Link Here
27
use C4::Members;
27
use C4::Members;
28
use C4::Letters;
28
use C4::Letters;
29
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use C4::Members::Attributes qw(GetBorrowerAttributes);
30
use Koha::Patron::Images;
30
use Koha::Patrons;
31
31
32
my $input=new CGI;
32
my $input=new CGI;
33
33
34
34
35
my $borrowernumber = $input->param('borrowernumber');
35
my $borrowernumber = $input->param('borrowernumber');
36
#get borrower details
36
my $patron = Koha::Patrons->find( $borrowernumber );
37
my $borrower = GetMember(borrowernumber => $borrowernumber);
37
my $borrower = $patron->unblessed;
38
38
39
my ($template, $loggedinuser, $cookie)
39
my ($template, $loggedinuser, $cookie)
40
= get_template_and_user({template_name => "members/notices.tt",
40
= get_template_and_user({template_name => "members/notices.tt",
Lines 46-53 my ($template, $loggedinuser, $cookie) Link Here
46
				});
46
				});
47
47
48
$template->param( $borrower );
48
$template->param( $borrower );
49
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
49
$template->param( picture => 1 ) if $patron->image;
50
$template->param( picture => 1 ) if $patron_image;
51
50
52
# Allow resending of messages in Notices tab
51
# Allow resending of messages in Notices tab
53
my $op = $input->param('op') || q{};
52
my $op = $input->param('op') || q{};
Lines 78-84 $template->param( Link Here
78
    QUEUED_MESSAGES    => $queued_messages,
77
    QUEUED_MESSAGES    => $queued_messages,
79
    borrowernumber     => $borrowernumber,
78
    borrowernumber     => $borrowernumber,
80
    sentnotices        => 1,
79
    sentnotices        => 1,
81
    categoryname       => $borrower->{'description'},
80
    categoryname       => $patron->category->description,
82
    RoutingSerials => C4::Context->preference('RoutingSerials'),
81
    RoutingSerials => C4::Context->preference('RoutingSerials'),
83
);
82
);
84
output_html_with_http_headers $input, $cookie, $template->output;
83
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/pay.pl (-1 / +6 lines)
Lines 40-45 use C4::Stats; Link Here
40
use C4::Koha;
40
use C4::Koha;
41
use C4::Overdues;
41
use C4::Overdues;
42
use C4::Members::Attributes qw(GetBorrowerAttributes);
42
use C4::Members::Attributes qw(GetBorrowerAttributes);
43
use Koha::Patrons;
43
use Koha::Patron::Images;
44
use Koha::Patron::Images;
44
45
45
use Koha::Patron::Categories;
46
use Koha::Patron::Categories;
Lines 66-72 if ( !$borrowernumber ) { Link Here
66
}
67
}
67
68
68
# get borrower details
69
# get borrower details
69
our $borrower = GetMember( borrowernumber => $borrowernumber );
70
my $patron = Koha::Patrons->find( $borrowernumber );
71
my $category = $patron->category;
72
our $borrower = $patron->unblessed;
73
$borrower->{description} = $category->description;
74
$borrower->{category_type} = $category->category_type;
70
our $user = $input->remote_user;
75
our $user = $input->remote_user;
71
$user ||= q{};
76
$user ||= q{};
72
77
(-)a/members/paycollect.pl (-1 / +6 lines)
Lines 29-34 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
29
use C4::Accounts;
29
use C4::Accounts;
30
use C4::Koha;
30
use C4::Koha;
31
use Koha::Patron::Images;
31
use Koha::Patron::Images;
32
use Koha::Patrons;
32
use Koha::Account;
33
use Koha::Account;
33
34
34
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
Lines 48-54 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
48
49
49
# get borrower details
50
# get borrower details
50
my $borrowernumber = $input->param('borrowernumber');
51
my $borrowernumber = $input->param('borrowernumber');
51
my $borrower       = GetMember( borrowernumber => $borrowernumber );
52
my $patron         = Koha::Patrons->find( $borrowernumber );
53
my $borrower       = $patron->unblessed;
54
my $category       = $patron->category;
55
$borrower->{description} = $category->description;
56
$borrower->{category_type} = $category->category_type;
52
my $user           = $input->remote_user;
57
my $user           = $input->remote_user;
53
58
54
my $branch         = C4::Context->userenv->{'branch'};
59
my $branch         = C4::Context->userenv->{'branch'};
(-)a/members/printfeercpt.pl (-5 / +7 lines)
Lines 31-37 use CGI qw ( -utf8 ); Link Here
31
use C4::Members;
31
use C4::Members;
32
use C4::Accounts;
32
use C4::Accounts;
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
use Koha::Patron::Images;
34
use Koha::Patrons;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
36
37
my $input=new CGI;
37
my $input=new CGI;
Lines 50-57 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
#get borrower details
53
my $patron = Koha::Patrons->find( $borrowernumber );
54
my $data=GetMember('borrowernumber' => $borrowernumber);
54
my $category = $patron->category;
55
my $data = $patron->unblessed;
56
$data->{description} = $category->description;
57
$data->{category_type} = $category->category_type;
55
58
56
if ( $action eq 'print' ) {
59
if ( $action eq 'print' ) {
57
#  ReversePayment( $borrowernumber, $input->param('accountno') );
60
#  ReversePayment( $borrowernumber, $input->param('accountno') );
Lines 114-121 for (my $i=0;$i<$numaccts;$i++){ Link Here
114
117
115
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
118
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
116
119
117
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
120
$template->param( picture => 1 ) if $patron->image;
118
$template->param( picture => 1 ) if $patron_image;
119
121
120
$template->param(
122
$template->param(
121
    finesview           => 1,
123
    finesview           => 1,
(-)a/members/printinvoice.pl (-5 / +7 lines)
Lines 29-36 use Koha::DateUtils; Link Here
29
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
30
use C4::Members;
30
use C4::Members;
31
use C4::Accounts;
31
use C4::Accounts;
32
use Koha::Patron::Images;
33
32
33
use Koha::Patrons;
34
use Koha::Patron::Categories;
34
use Koha::Patron::Categories;
35
35
36
my $input = new CGI;
36
my $input = new CGI;
Lines 49-56 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
#get borrower details
52
my $patron = Koha::Patrons->find( $borrowernumber );
53
my $data = GetMember( 'borrowernumber' => $borrowernumber );
53
my $category = $patron->category;
54
my $data = $patron->unblessed;
55
$data->{description} = $category->description;
56
$data->{category_type} = $category->category_type;
54
57
55
if ( $data->{'category_type'} eq 'C' ) {
58
if ( $data->{'category_type'} eq 'C' ) {
56
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
59
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
Lines 114-121 for ( my $i = 0 ; $i < $numaccts ; $i++ ) { Link Here
114
117
115
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
118
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
116
119
117
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
120
$template->param( picture => 1 ) if $patron->image;
118
$template->param( picture => 1 ) if $patron_image;
119
121
120
$template->param(
122
$template->param(
121
    finesview      => 1,
123
    finesview      => 1,
(-)a/members/purchase-suggestions.pl (-7 / +10 lines)
Lines 26-32 use C4::Output; Link Here
26
use C4::Members;
26
use C4::Members;
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Suggestions;
28
use C4::Suggestions;
29
use Koha::Patron::Images;
29
use Koha::Patrons;
30
30
31
my $input = new CGI;
31
my $input = new CGI;
32
32
Lines 43-55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
43
my $borrowernumber = $input->param('borrowernumber');
43
my $borrowernumber = $input->param('borrowernumber');
44
44
45
# Set informations for the patron
45
# Set informations for the patron
46
my $borrower = GetMember( borrowernumber => $borrowernumber );
46
my $patron = Koha::Patrons->find( $borrowernumber );
47
foreach my $key ( keys %$borrower ) {
47
my $category = $patron->category;
48
    $template->param( $key => $borrower->{$key} );
48
my $data = $patron->unblessed;
49
$data->{description} = $category->description;
50
$data->{category_type} = $category->category_type;
51
foreach my $key ( keys %$data ) {
52
    $template->param( $key => $data->{$key} );
49
}
53
}
50
$template->param(
54
$template->param(
51
    suggestionsview  => 1,
55
    suggestionsview  => 1,
52
    categoryname => $borrower->{'description'},
56
    categoryname => $data->{'description'},
53
    RoutingSerials => C4::Context->preference('RoutingSerials'),
57
    RoutingSerials => C4::Context->preference('RoutingSerials'),
54
);
58
);
55
59
Lines 61-68 if (C4::Context->preference('ExtendedPatronAttributes')) { Link Here
61
    );
65
    );
62
}
66
}
63
67
64
my $patron_image = Koha::Patron::Images->find($borrowernumber);
68
$template->param( picture => 1 ) if $patron->image;
65
$template->param( picture => 1 ) if $patron_image;
66
69
67
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
70
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
68
71
(-)a/members/readingrec.pl (-7 / +8 lines)
Lines 31-38 use C4::Members; Link Here
31
use List::MoreUtils qw/any uniq/;
31
use List::MoreUtils qw/any uniq/;
32
use Koha::DateUtils;
32
use Koha::DateUtils;
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use Koha::Patron::Images;
35
34
35
use Koha::Patrons;
36
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
37
37
38
my $input = CGI->new;
38
my $input = CGI->new;
Lines 51-64 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => Link Here
51
				});
51
				});
52
52
53
my $op = $input->param('op') || '';
53
my $op = $input->param('op') || '';
54
my $patron;
54
if ($input->param('cardnumber')) {
55
if ($input->param('cardnumber')) {
55
    $cardnumber = $input->param('cardnumber');
56
    $cardnumber = $input->param('cardnumber');
56
    $data = GetMember(cardnumber => $cardnumber);
57
    $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
58
    $data = $patron->unblessed;
57
    $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
59
    $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
58
}
60
}
59
if ($input->param('borrowernumber')) {
61
if ($input->param('borrowernumber')) {
60
    $borrowernumber = $input->param('borrowernumber');
62
    $borrowernumber = $input->param('borrowernumber');
61
    $data = GetMember(borrowernumber => $borrowernumber);
63
    $patron = Koha::Patrons->find( $borrowernumber );
64
    $data = $patron->unblessed;
62
}
65
}
63
66
64
my $order = 'date_due desc';
67
my $order = 'date_due desc';
Lines 79-86 if ( $op eq 'export_barcodes' ) { Link Here
79
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
82
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
80
        my @barcodes =
83
        my @barcodes =
81
          map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
84
          map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
82
        my $borrowercardnumber =
85
        my $borrowercardnumber = $data->{cardnumber};
83
          GetMember( borrowernumber => $borrowernumber )->{'cardnumber'};
84
        my $delimiter = "\n";
86
        my $delimiter = "\n";
85
        binmode( STDOUT, ":encoding(UTF-8)" );
87
        binmode( STDOUT, ":encoding(UTF-8)" );
86
        print $input->header(
88
        print $input->header(
Lines 106-113 if (! $limit){ Link Here
106
	$limit = 'full';
108
	$limit = 'full';
107
}
109
}
108
110
109
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
111
$template->param( picture => 1 ) if $patron->image;
110
$template->param( picture => 1 ) if $patron_image;
111
112
112
if (C4::Context->preference('ExtendedPatronAttributes')) {
113
if (C4::Context->preference('ExtendedPatronAttributes')) {
113
    my $attributes = GetBorrowerAttributes($borrowernumber);
114
    my $attributes = GetBorrowerAttributes($borrowernumber);
(-)a/members/routing-lists.pl (-17 / +12 lines)
Lines 26-32 use C4::Members; Link Here
26
use C4::Members::Attributes qw(GetBorrowerAttributes);
26
use C4::Members::Attributes qw(GetBorrowerAttributes);
27
use C4::Context;
27
use C4::Context;
28
use C4::Serials;
28
use C4::Serials;
29
use Koha::Patron::Images;
29
use Koha::Patrons;
30
use CGI::Session;
30
use CGI::Session;
31
31
32
my $query = new CGI;
32
my $query = new CGI;
Lines 49-66 my $borrowernumber = $query->param('borrowernumber'); Link Here
49
my $branch = C4::Context->userenv->{'branch'};
49
my $branch = C4::Context->userenv->{'branch'};
50
50
51
# get the borrower information.....
51
# get the borrower information.....
52
my $borrower;
52
my ( $patron, $patron_info );
53
if ($borrowernumber) {
53
if ($borrowernumber) {
54
    $borrower = GetMember( borrowernumber => $borrowernumber );
54
    $patron = Koha::Patrons->find( $borrowernumber );
55
}
55
    my $category = $patron->category;
56
56
    my $patron_info = $patron->unblessed;
57
    $patron_info->{description} = $category->description;
58
    $patron_info->{category_type} = $category->category_type;
57
59
58
##################################################################################
59
# BUILD HTML
60
# I'm trying to show the title of subscriptions where the borrowernumber is attached via a routing list
61
62
if ($borrowernumber) {
63
# new op dev
64
  my $count;
60
  my $count;
65
  my @borrowerSubscriptions;
61
  my @borrowerSubscriptions;
66
  ($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
62
  ($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
Lines 80-98 if ($borrowernumber) { Link Here
80
        routinglistview => 1
76
        routinglistview => 1
81
    );
77
    );
82
78
83
    $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' || $borrower->{'category_type'} eq 'I' );
79
    $template->param( adultborrower => 1 ) if ( $patron_info->{category_type} =~ /^(A|I)$/ );
84
}
80
}
85
81
86
##################################################################################
82
##################################################################################
87
83
88
$template->param(%$borrower);
84
$template->param(%$patron_info);
89
85
90
$template->param(
86
$template->param(
91
    findborrower      => $findborrower,
87
    findborrower      => $findborrower,
92
    borrower          => $borrower,
88
    borrower          => $patron_info,
93
    borrowernumber    => $borrowernumber,
89
    borrowernumber    => $borrowernumber,
94
    branch            => $branch,
90
    branch            => $branch,
95
    categoryname      => $borrower->{description},
91
    categoryname      => $patron_info->{description},
96
    RoutingSerials    => C4::Context->preference('RoutingSerials'),
92
    RoutingSerials    => C4::Context->preference('RoutingSerials'),
97
);
93
);
98
94
Lines 104-110 if (C4::Context->preference('ExtendedPatronAttributes')) { Link Here
104
    );
100
    );
105
}
101
}
106
102
107
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
103
$template->param( picture => 1 ) if $patron and $patron->image;
108
$template->param( picture => 1 ) if $patron_image;
109
104
110
output_html_with_http_headers $query, $cookie, $template->output;
105
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/members/statistics.pl (-5 / +9 lines)
Lines 31-37 use C4::Members; Link Here
31
use C4::Members::Statistics;
31
use C4::Members::Statistics;
32
use C4::Members::Attributes qw(GetBorrowerAttributes);
32
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Output;
33
use C4::Output;
34
use Koha::Patron::Images;
34
use Koha::Patrons;
35
35
36
my $input = new CGI;
36
my $input = new CGI;
37
37
Lines 48-60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
48
my $borrowernumber = $input->param('borrowernumber');
48
my $borrowernumber = $input->param('borrowernumber');
49
49
50
# Set informations for the patron
50
# Set informations for the patron
51
my $borrower = GetMember( borrowernumber => $borrowernumber );
51
my $patron = Koha::Patrons->find( $borrowernumber );
52
if ( not defined $borrower ) {
52
unless ( $patron ) {
53
    $template->param (unknowuser => 1);
53
    $template->param (unknowuser => 1);
54
    output_html_with_http_headers $input, $cookie, $template->output;
54
    output_html_with_http_headers $input, $cookie, $template->output;
55
    exit;
55
    exit;
56
}
56
}
57
57
58
my $category = $patron->category;
59
my $borrower= $patron->unblessed;
60
$borrower->{description} = $category->description;
61
$borrower->{category_type} = $category->category_type;
62
58
foreach my $key ( keys %$borrower ) {
63
foreach my $key ( keys %$borrower ) {
59
    $template->param( $key => $borrower->{$key} );
64
    $template->param( $key => $borrower->{$key} );
60
}
65
}
Lines 92-99 if (C4::Context->preference('ExtendedPatronAttributes')) { Link Here
92
    );
97
    );
93
}
98
}
94
99
95
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
100
$template->param( picture => 1 ) if $patron->image;
96
$template->param( picture => 1 ) if $patron_image;
97
101
98
$template->param(%$borrower);
102
$template->param(%$borrower);
99
103
(-)a/members/summary-print.pl (-1 / +6 lines)
Lines 27-32 use C4::Reserves; Link Here
27
use C4::Items;
27
use C4::Items;
28
use Koha::Holds;
28
use Koha::Holds;
29
use Koha::ItemTypes;
29
use Koha::ItemTypes;
30
use Koha::Patrons;
30
31
31
my $input          = CGI->new;
32
my $input          = CGI->new;
32
my $borrowernumber = $input->param('borrowernumber');
33
my $borrowernumber = $input->param('borrowernumber');
Lines 42-48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
42
    }
43
    }
43
);
44
);
44
45
45
my $data = GetMember( 'borrowernumber' => $borrowernumber );
46
my $patron = Koha::Patrons->find( $borrowernumber );
47
my $category = $patron->category;
48
my $data = $patron->unblessed;
49
$data->{description} = $category->description;
50
$data->{category_type} = $category->category_type;
46
51
47
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
52
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
48
foreach my $accountline (@$accts) {
53
foreach my $accountline (@$accts) {
(-)a/members/update-child.pl (-1 / +3 lines)
Lines 33-38 use C4::Context; Link Here
33
use C4::Auth;
33
use C4::Auth;
34
use C4::Output;
34
use C4::Output;
35
use C4::Members;
35
use C4::Members;
36
use Koha::Patrons;
36
use Koha::Patron::Categories;
37
use Koha::Patron::Categories;
37
38
38
# use Smart::Comments;
39
# use Smart::Comments;
Lines 71-77 if ( $op eq 'multi' ) { Link Here
71
}
72
}
72
73
73
elsif ( $op eq 'update' ) {
74
elsif ( $op eq 'update' ) {
74
    my $member = GetMember('borrowernumber'=>$borrowernumber);
75
    my $patron = Koha::Patrons->find( $borrowernumber );
76
    my $member = $patron->unblessed;
75
    $member->{'guarantorid'}  = 0;
77
    $member->{'guarantorid'}  = 0;
76
    $member->{'categorycode'} = $catcode;
78
    $member->{'categorycode'} = $catcode;
77
    my $borcat = Koha::Patron::Categories->find($catcode);
79
    my $borcat = Koha::Patron::Categories->find($catcode);
(-)a/misc/cronjobs/advance_notices.pl (-3 / +2 lines)
Lines 509-517 sub get_branch_info { Link Here
509
    my ( $borrowernumber ) = @_;
509
    my ( $borrowernumber ) = @_;
510
510
511
    ## Get branch info for borrowers home library.
511
    ## Get branch info for borrowers home library.
512
    my $borrower_details = C4::Members::GetMember( borrowernumber => $borrowernumber );
512
    my $patron = Koha::Patrons->find( $borrowernumber );
513
    my $borrower_branchcode = $borrower_details->{'branchcode'};
513
    my $branch = $patron->library->unblessed;
514
    my $branch = Koha::Libraries->find( $borrower_branchcode )->unblessed;
515
    my %branch_info;
514
    my %branch_info;
516
    foreach my $key( keys %$branch ) {
515
    foreach my $key( keys %$branch ) {
517
        $branch_info{"branches.$key"} = $branch->{$key};
516
        $branch_info{"branches.$key"} = $branch->{$key};
(-)a/misc/cronjobs/notice_unprocessed_suggestions.pl (-10 / +10 lines)
Lines 6-14 use Pod::Usage; Link Here
6
use Getopt::Long;
6
use Getopt::Long;
7
7
8
use C4::Budgets qw( GetBudget );
8
use C4::Budgets qw( GetBudget );
9
use C4::Members qw( GetMember );
10
use C4::Suggestions qw( GetUnprocessedSuggestions );
9
use C4::Suggestions qw( GetUnprocessedSuggestions );
11
use Koha::Libraries;
10
use Koha::Libraries;
11
use Koha::Patrons;
12
12
13
my ( $help, $verbose, $confirm, @days );
13
my ( $help, $verbose, $confirm, @days );
14
GetOptions(
14
GetOptions(
Lines 45-82 for my $number_of_days (@days) { Link Here
45
        say "Suggestion $suggestion->{suggestionid} should be processed" if $verbose;
45
        say "Suggestion $suggestion->{suggestionid} should be processed" if $verbose;
46
46
47
        my $budget = C4::Budgets::GetBudget( $suggestion->{budgetid} );
47
        my $budget = C4::Budgets::GetBudget( $suggestion->{budgetid} );
48
        my $patron = C4::Members::GetMember( borrowernumber => $budget->{budget_owner_id} );
48
        my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
49
        my $email_address =
49
        my $email_address =
50
          C4::Members::GetNoticeEmailAddress( $budget->{budget_owner_id} );
50
          C4::Members::GetNoticeEmailAddress( $budget->{budget_owner_id} );
51
        my $library = Koha::Libraries->find( $patron->{branchcode} );
51
        my $library = $patron->library;
52
        my $admin_email_address = $library->branchemail
52
        my $admin_email_address = $library->branchemail
53
          || C4::Context->preference('KohaAdminEmailAddress');
53
          || C4::Context->preference('KohaAdminEmailAddress');
54
54
55
        if ($email_address) {
55
        if ($email_address) {
56
            say "Patron $patron->{borrowernumber} is going to be notified" if $verbose;
56
            say "Patron " . $patron->borrowernumber . " is going to be notified" if $verbose;
57
            my $letter = C4::Letters::GetPreparedLetter(
57
            my $letter = C4::Letters::GetPreparedLetter(
58
                module      => 'suggestions',
58
                module      => 'suggestions',
59
                letter_code => 'TO_PROCESS',
59
                letter_code => 'TO_PROCESS',
60
                branchcode  => $patron->{branchcode},
60
                branchcode  => $patron->branchcode,
61
                lang        => $patron->{lang},
61
                lang        => $patron->lang,
62
                tables      => {
62
                tables      => {
63
                    suggestions => $suggestion->{suggestionid},
63
                    suggestions => $suggestion->{suggestionid},
64
                    branches    => $patron->{branchcode},
64
                    branches    => $patron->branchcode,
65
                    borrowers   => $patron->{borrowernumber},
65
                    borrowers   => $patron->borrowernumber,
66
                },
66
                },
67
            );
67
            );
68
            if ( $confirm ) {
68
            if ( $confirm ) {
69
                C4::Letters::EnqueueLetter(
69
                C4::Letters::EnqueueLetter(
70
                    {
70
                    {
71
                        letter                 => $letter,
71
                        letter                 => $letter,
72
                        borrowernumber         => $patron->{borrowernumber},
72
                        borrowernumber         => $patron->borrowernumber,
73
                        message_transport_type => 'email',
73
                        message_transport_type => 'email',
74
                        from_address           => $admin_email_address,
74
                        from_address           => $admin_email_address,
75
                    }
75
                    }
76
                );
76
                );
77
            }
77
            }
78
        } else {
78
        } else {
79
            say "Patron $patron->{borrowernumber} does not have an email address" if $verbose;
79
            say "Patron " . $patron->borrowernumber . " does not have an email address" if $verbose;
80
        }
80
        }
81
    }
81
    }
82
82
(-)a/misc/export_borrowers.pl (-4 / +13 lines)
Lines 24-30 use Text::CSV; Link Here
24
use Getopt::Long qw(:config no_ignore_case);
24
use Getopt::Long qw(:config no_ignore_case);
25
25
26
use C4::Context;
26
use C4::Context;
27
use C4::Members;
27
use Koha::Patrons;
28
28
29
binmode STDOUT, ":encoding(UTF-8)";
29
binmode STDOUT, ":encoding(UTF-8)";
30
30
Lines 41-47 $0 [--field=FIELD [--field=FIELD [...]]] [--separator=CHAR] [--show-header] [--w Link Here
41
$0 -h
41
$0 -h
42
42
43
    -f, --field=FIELD       Field to export. It is repeatable and has to match
43
    -f, --field=FIELD       Field to export. It is repeatable and has to match
44
                            keys returned by the GetMember function.
44
                            column names of the borrower table (also as 'description' and 'category_type'
45
                            If no field is specified, then all fields will be
45
                            If no field is specified, then all fields will be
46
                            exported.
46
                            exported.
47
    -s, --separator=CHAR    This character will be used to separate fields.
47
    -s, --separator=CHAR    This character will be used to separate fields.
Lines 99-106 my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } ); Link Here
99
# If the user did not specify any field to export, we assume they want them all
99
# If the user did not specify any field to export, we assume they want them all
100
# We retrieve the first borrower informations to get field names
100
# We retrieve the first borrower informations to get field names
101
my ($borrowernumber) = $sth->fetchrow_array or die "No borrower to export";
101
my ($borrowernumber) = $sth->fetchrow_array or die "No borrower to export";
102
my $member = GetMember($borrowernumber); # FIXME Now is_expired is no longer available
102
my $patron = Koha::Patrons->find( $borrowernumber ); # FIXME Now is_expired is no longer available
103
                                         # We will have to use Koha::Patron and allow method calls
103
                                         # We will have to use Koha::Patron and allow method calls
104
my $category = $patron->category;
105
my $member = $patron->unblessed;
106
$member->{description} = $category->description;
107
$member->{category_type} = $category->category_type;
108
104
@fields = keys %$member unless (@fields);
109
@fields = keys %$member unless (@fields);
105
110
106
if ($show_header) {
111
if ($show_header) {
Lines 121-127 die "Invalid character at borrower $borrowernumber: [" Link Here
121
print $csv->string . "\n";
126
print $csv->string . "\n";
122
127
123
while ( my $borrowernumber = $sth->fetchrow_array ) {
128
while ( my $borrowernumber = $sth->fetchrow_array ) {
124
    $member = GetMember( borrowernumber => $borrowernumber );
129
    my $patron = Koha::Patrons->find( $borrowernumber );
130
    my $category = $patron->category;
131
    my $member = $patron->unblessed;
132
    $member->{description} = $category->description;
133
    $member->{category_type} = $category->category_type;
125
    $csv->combine(
134
    $csv->combine(
126
        map {
135
        map {
127
            ( defined $member->{$_} and !ref $member->{$_} )
136
            ( defined $member->{$_} and !ref $member->{$_} )
(-)a/misc/load_testing/benchmark_staff.pl (-2 / +2 lines)
Lines 18-25 use Data::Dumper; Link Here
18
use HTTP::Cookies;
18
use HTTP::Cookies;
19
use C4::Context;
19
use C4::Context;
20
use C4::Debug;
20
use C4::Debug;
21
use C4::Members qw ( GetMember );
22
use URI::Escape;
21
use URI::Escape;
22
use Koha::Patrons;
23
23
24
my ($help, $steps, $baseurl, $max_tries, $user, $password,$short_print);
24
my ($help, $steps, $baseurl, $max_tries, $user, $password,$short_print);
25
GetOptions(
25
GetOptions(
Lines 91-97 if( $resp->is_success and $resp->content =~ m|<status>ok</status>| ) { Link Here
91
}
91
}
92
92
93
die "You cannot use the database administrator account to launch this script"
93
die "You cannot use the database administrator account to launch this script"
94
    unless defined C4::Members::GetMember(userid => $user);
94
    unless defined Koha::Patrons->find( { userid => $user } );
95
95
96
# remove some unnecessary garbage from the cookie
96
# remove some unnecessary garbage from the cookie
97
$cookie =~ s/ path_spec; discard; version=0//;
97
$cookie =~ s/ path_spec; discard; version=0//;
(-)a/offline_circ/list.pl (-4 / +5 lines)
Lines 29-34 use C4::Context; Link Here
29
use C4::Circulation;
29
use C4::Circulation;
30
use C4::Members;
30
use C4::Members;
31
use C4::Biblio;
31
use C4::Biblio;
32
use Koha::Patrons;
32
33
33
my $query = CGI->new;
34
my $query = CGI->new;
34
35
Lines 46-55 for (@$operations) { Link Here
46
    my $biblio             = GetBiblioFromItemNumber(undef, $_->{'barcode'});
47
    my $biblio             = GetBiblioFromItemNumber(undef, $_->{'barcode'});
47
    $_->{'bibliotitle'}    = $biblio->{'title'};
48
    $_->{'bibliotitle'}    = $biblio->{'title'};
48
    $_->{'biblionumber'}   = $biblio->{'biblionumber'};
49
    $_->{'biblionumber'}   = $biblio->{'biblionumber'};
49
    my $borrower           = C4::Members::GetMember( cardnumber => $_->{'cardnumber'} );
50
    my $patron             = $_->{cardnumber} ? Koha::Patrons->find( { cardnumber => $_->{cardnumber} } ) : undef;
50
    if ($borrower) {
51
    if ($patron) {
51
        $_->{'borrowernumber'} = $borrower->{'borrowernumber'};
52
        $_->{'borrowernumber'} = $patron->borrowernumber;
52
        $_->{'borrower'}       = ($borrower->{'firstname'}?$borrower->{'firstname'}:'').' '.$borrower->{'surname'};
53
        $_->{'borrower'}       = ($patron->firstname ? $patron->firstname:'').' '.$patron->surname;
53
    }
54
    }
54
    $_->{'actionissue'}    = $_->{'action'} eq 'issue';
55
    $_->{'actionissue'}    = $_->{'action'} eq 'issue';
55
    $_->{'actionreturn'}   = $_->{'action'} eq 'return';
56
    $_->{'actionreturn'}   = $_->{'action'} eq 'return';
(-)a/offline_circ/process_koc.pl (-7 / +8 lines)
Lines 249-255 sub kocIssueItem { Link Here
249
249
250
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
250
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
251
    my $branchcode = C4::Context->userenv->{branch};
251
    my $branchcode = C4::Context->userenv->{branch};
252
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
252
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{ 'cardnumber' } } );
253
    my $borrower = $patron->unblessed;
253
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
254
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
254
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
255
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
255
256
Lines 330-342 sub kocReturnItem { Link Here
330
    #warn( Data::Dumper->Dump( [ $circ, $item ], [ qw( circ item ) ] ) );
331
    #warn( Data::Dumper->Dump( [ $circ, $item ], [ qw( circ item ) ] ) );
331
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
332
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
332
    if ( $borrowernumber ) {
333
    if ( $borrowernumber ) {
333
        my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
334
        my $patron = Koha::Patrons->find( $borrowernumber );
334
        C4::Circulation::MarkIssueReturned(
335
        C4::Circulation::MarkIssueReturned(
335
            $borrowernumber,
336
            $borrowernumber,
336
            $item->{'itemnumber'},
337
            $item->{'itemnumber'},
337
            undef,
338
            undef,
338
            $circ->{'date'},
339
            $circ->{'date'},
339
            $borrower->{'privacy'}
340
            $patron->privacy
340
        );
341
        );
341
342
342
        ModItem({ onloan => undef }, $item->{'biblionumber'}, $item->{'itemnumber'});
343
        ModItem({ onloan => undef }, $item->{'biblionumber'}, $item->{'itemnumber'});
Lines 347-356 sub kocReturnItem { Link Here
347
            title => $item->{ 'title' },
348
            title => $item->{ 'title' },
348
            biblionumber => $item->{'biblionumber'},
349
            biblionumber => $item->{'biblionumber'},
349
            barcode => $item->{ 'barcode' },
350
            barcode => $item->{ 'barcode' },
350
            borrowernumber => $borrower->{'borrowernumber'},
351
            borrowernumber => $patron->borrowernumber,
351
            firstname => $borrower->{'firstname'},
352
            firstname => $patron->firstname,
352
            surname => $borrower->{'surname'},
353
            surname => $patron->surname,
353
            cardnumber => $borrower->{'cardnumber'},
354
            cardnumber => $patron->cardnumber,
354
            datetime => $circ->{ 'datetime' }
355
            datetime => $circ->{ 'datetime' }
355
        };
356
        };
356
    } else {
357
    } else {
(-)a/opac/opac-ISBDdetail.pl (-3 / +3 lines)
Lines 52-59 use C4::Reserves; Link Here
52
use C4::Acquisition;
52
use C4::Acquisition;
53
use C4::Serials;    # uses getsubscriptionfrom biblionumber
53
use C4::Serials;    # uses getsubscriptionfrom biblionumber
54
use C4::Koha;
54
use C4::Koha;
55
use C4::Members;    # GetMember
56
use Koha::ItemTypes;
55
use Koha::ItemTypes;
56
use Koha::Patrons;
57
use Koha::RecordProcessor;
57
use Koha::RecordProcessor;
58
58
59
59
Lines 164-170 my $res = GetISBDView({ Link Here
164
});
164
});
165
165
166
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
166
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
167
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
167
my $patron = Koha::Patrons->find( $loggedinuser );
168
for my $itm (@items) {
168
for my $itm (@items) {
169
    $norequests = 0
169
    $norequests = 0
170
      if $norequests
170
      if $norequests
Lines 174-180 for my $itm (@items) { Link Here
174
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
174
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
175
        && $itm->{'itemnumber'};
175
        && $itm->{'itemnumber'};
176
176
177
    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
177
    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $patron->unblessed)
178
      unless $allow_onshelf_holds;
178
      unless $allow_onshelf_holds;
179
}
179
}
180
180
(-)a/opac/opac-MARCdetail.pl (-2 / +3 lines)
Lines 57-62 use C4::Members; Link Here
57
use C4::Acquisition;
57
use C4::Acquisition;
58
use C4::Koha;
58
use C4::Koha;
59
use List::MoreUtils qw( any uniq );
59
use List::MoreUtils qw( any uniq );
60
use Koha::Patrons;
60
use Koha::RecordProcessor;
61
use Koha::RecordProcessor;
61
62
62
my $query = new CGI;
63
my $query = new CGI;
Lines 126-134 if(my $cart_list = $query->cookie("bib_list")){ Link Here
126
}
127
}
127
128
128
my $allow_onshelf_holds;
129
my $allow_onshelf_holds;
129
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
130
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
130
for my $itm (@all_items) {
131
for my $itm (@all_items) {
131
    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower);
132
    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $patron);
132
    last if $allow_onshelf_holds;
133
    last if $allow_onshelf_holds;
133
}
134
}
134
135
(-)a/opac/opac-account-pay-paypal-return.pl (-2 / +3 lines)
Lines 29-37 use URI; Link Here
29
use C4::Auth;
29
use C4::Auth;
30
use C4::Output;
30
use C4::Output;
31
use C4::Accounts;
31
use C4::Accounts;
32
use C4::Members;
33
use Koha::Acquisition::Currencies;
32
use Koha::Acquisition::Currencies;
34
use Koha::Database;
33
use Koha::Database;
34
use Koha::Patrons;
35
35
36
my $cgi = new CGI;
36
my $cgi = new CGI;
37
37
Lines 117-124 else { Link Here
117
    $error = "PAYPAL_UNABLE_TO_CONNECT";
117
    $error = "PAYPAL_UNABLE_TO_CONNECT";
118
}
118
}
119
119
120
my $patron = Koha::Patrons->find( $borrowernumber );
120
$template->param(
121
$template->param(
121
    borrower    => GetMember( borrowernumber => $borrowernumber ),
122
    borrower    => $patron->unblessed,
122
    accountview => 1
123
    accountview => 1
123
);
124
);
124
125
(-)a/opac/opac-account.pl (-3 / +7 lines)
Lines 19-30 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
21
22
use strict;
22
use Modern::Perl;
23
use CGI qw ( -utf8 );
23
use CGI qw ( -utf8 );
24
use C4::Members;
24
use C4::Members;
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Output;
26
use C4::Output;
27
use warnings;
27
use Koha::Patrons;
28
28
29
my $query = new CGI;
29
my $query = new CGI;
30
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
30
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 37-43 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
37
    }
37
    }
38
);
38
);
39
39
40
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
40
my $patron = Koha::Patrons->find( $borrowernumber );
41
my $category = $patron->category;
42
my $borrower= $patron->unblessed;
43
$borrower->{description} = $category->description;
44
$borrower->{category_type} = $category->category_type;
41
$template->param( BORROWER_INFO => $borrower );
45
$template->param( BORROWER_INFO => $borrower );
42
46
43
#get account details
47
#get account details
(-)a/opac/opac-detail.pl (-11 / +12 lines)
Lines 53-58 use Koha::AuthorisedValues; Link Here
53
use Koha::Biblios;
53
use Koha::Biblios;
54
use Koha::ItemTypes;
54
use Koha::ItemTypes;
55
use Koha::Virtualshelves;
55
use Koha::Virtualshelves;
56
use Koha::Patrons;
56
use Koha::Ratings;
57
use Koha::Ratings;
57
use Koha::Reviews;
58
use Koha::Reviews;
58
59
Lines 655-661 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
655
    );
656
    );
656
} else {
657
} else {
657
  my $allow_onshelf_holds;
658
  my $allow_onshelf_holds;
658
  my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
659
  my $patron = Koha::Patrons->find( $borrowernumber );
659
  for my $itm (@items) {
660
  for my $itm (@items) {
660
    $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
661
    $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
661
    $itm->{priority} = $priority{ $itm->{itemnumber} };
662
    $itm->{priority} = $priority{ $itm->{itemnumber} };
Lines 667-673 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
667
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
668
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
668
        && $itm->{'itemnumber'};
669
        && $itm->{'itemnumber'};
669
670
670
    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $borrower )
671
    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $patron->unblessed )
671
      unless $allow_onshelf_holds;
672
      unless $allow_onshelf_holds;
672
673
673
    # get collection code description, too
674
    # get collection code description, too
Lines 839-857 if ( C4::Context->preference('reviewson') ) { Link Here
839
        }
840
        }
840
    }
841
    }
841
    for my $review (@$reviews) {
842
    for my $review (@$reviews) {
842
        my $borrowerData = GetMember( 'borrowernumber' => $review->{borrowernumber} );
843
        my $patron = Koha::Patrons->find( $review->{borrowernumber} );
843
844
844
        # setting some borrower info into this hash
845
        # setting some borrower info into this hash
845
        $review->{title}     = $borrowerData->{'title'};
846
        $review->{title}     = $patron->title;
846
        $review->{surname}   = $borrowerData->{'surname'};
847
        $review->{surname}   = $patron->surname;
847
        $review->{firstname} = $borrowerData->{'firstname'};
848
        $review->{firstname} = $patron->firstname;
848
        if ( $libravatar_enabled and $borrowerData->{'email'} ) {
849
        if ( $libravatar_enabled and $patron->email ) {
849
            $review->{avatarurl} = libravatar_url( email => $borrowerData->{'email'}, https => $ENV{HTTPS} );
850
            $review->{avatarurl} = libravatar_url( email => $patron->email, https => $ENV{HTTPS} );
850
        }
851
        }
851
        $review->{userid}     = $borrowerData->{'userid'};
852
        $review->{userid}     = $patron->userid;
852
        $review->{cardnumber} = $borrowerData->{'cardnumber'};
853
        $review->{cardnumber} = $patron->cardnumber;
853
854
854
        if ( $borrowerData->{'borrowernumber'} eq $borrowernumber ) {
855
        if ( $patron->borrowernumber eq $borrowernumber ) {
855
            $review->{your_comment} = 1;
856
            $review->{your_comment} = 1;
856
            $loggedincommenter = 1;
857
            $loggedincommenter = 1;
857
        }
858
        }
(-)a/opac/opac-discharge.pl (-3 / +3 lines)
Lines 26-32 use C4::Context; Link Here
26
use C4::Output;
26
use C4::Output;
27
use C4::Log;
27
use C4::Log;
28
use C4::Debug;
28
use C4::Debug;
29
use C4::Members;
29
use Koha::Patrons;
30
use Koha::Patron::Discharge;
30
use Koha::Patron::Discharge;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
32
Lines 63-72 elsif ( $op eq 'get' ) { Link Here
63
    eval {
63
    eval {
64
64
65
        # Getting member data
65
        # Getting member data
66
        my $data = GetMember( borrowernumber => $loggedinuser );
66
        my $patron = Koha::Patrons->find( $loggedinuser );
67
        my $pdf_path = Koha::Patron::Discharge::generate_as_pdf({
67
        my $pdf_path = Koha::Patron::Discharge::generate_as_pdf({
68
            borrowernumber => $loggedinuser,
68
            borrowernumber => $loggedinuser,
69
            branchcode => $data->{'branchcode'},
69
            branchcode => $patron->branchcode,
70
        });
70
        });
71
71
72
        binmode(STDOUT);
72
        binmode(STDOUT);
(-)a/opac/opac-memberentry.pl (-11 / +12 lines)
Lines 208-215 if ( $action eq 'create' ) { Link Here
208
            C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if $borrowernumber && C4::Context->preference('EnhancedMessagingPreferences');
208
            C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if $borrowernumber && C4::Context->preference('EnhancedMessagingPreferences');
209
209
210
            $template->param( password_cleartext => $password );
210
            $template->param( password_cleartext => $password );
211
            $template->param(
211
            my $patron = Koha::Patrons->find( $borrowernumber );
212
                borrower => GetMember( borrowernumber => $borrowernumber ) );
212
            $template->param( borrower => $patron->unblessed );
213
            $template->param(
213
            $template->param(
214
                PatronSelfRegistrationAdditionalInstructions =>
214
                PatronSelfRegistrationAdditionalInstructions =>
215
                  C4::Context->preference(
215
                  C4::Context->preference(
Lines 220-226 if ( $action eq 'create' ) { Link Here
220
}
220
}
221
elsif ( $action eq 'update' ) {
221
elsif ( $action eq 'update' ) {
222
222
223
    my $borrower = GetMember( borrowernumber => $borrowernumber );
223
    my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
224
    die "Wrong CSRF token"
224
    die "Wrong CSRF token"
225
        unless Koha::Token->new->check_csrf({
225
        unless Koha::Token->new->check_csrf({
226
            session_id => scalar $cgi->cookie('CGISESSID'),
226
            session_id => scalar $cgi->cookie('CGISESSID'),
Lines 277-291 elsif ( $action eq 'update' ) { Link Here
277
277
278
            my $m = Koha::Patron::Modification->new( \%borrower_changes )->store();
278
            my $m = Koha::Patron::Modification->new( \%borrower_changes )->store();
279
279
280
            $template->param(
280
            my $patron = Koha::Patrons->find( $borrowernumber );
281
                borrower => GetMember( borrowernumber => $borrowernumber ),
281
            $template->param( borrower => $patron->unblessed );
282
            );
283
        }
282
        }
284
        else {
283
        else {
284
            my $patron = Koha::Patrons->find( $borrowernumber );
285
            $template->param(
285
            $template->param(
286
                action => 'edit',
286
                action => 'edit',
287
                nochanges => 1,
287
                nochanges => 1,
288
                borrower => GetMember( borrowernumber => $borrowernumber ),
288
                borrower => $patron->unblessed,
289
                patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber, $attributes ),
289
                patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber, $attributes ),
290
                csrf_token => Koha::Token->new->generate_csrf({
290
                csrf_token => Koha::Token->new->generate_csrf({
291
                    session_id => scalar $cgi->cookie('CGISESSID'),
291
                    session_id => scalar $cgi->cookie('CGISESSID'),
Lines 295-301 elsif ( $action eq 'update' ) { Link Here
295
    }
295
    }
296
}
296
}
297
elsif ( $action eq 'edit' ) {    #Display logged in borrower's data
297
elsif ( $action eq 'edit' ) {    #Display logged in borrower's data
298
    my $borrower = GetMember( borrowernumber => $borrowernumber );
298
    my $patron = Koha::Patrons->find( $borrowernumber );
299
    my $borrower = $patron->unblessed;
299
300
300
    $template->param(
301
    $template->param(
301
        borrower  => $borrower,
302
        borrower  => $borrower,
Lines 307-314 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
307
    );
308
    );
308
309
309
    if (C4::Context->preference('OPACpatronimages')) {
310
    if (C4::Context->preference('OPACpatronimages')) {
310
        my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
311
        $template->param( display_patron_image => 1 ) if $patron->image;
311
        $template->param( display_patron_image => 1 ) if $patron_image;
312
    }
312
    }
313
313
314
    $template->param( patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber ) );
314
    $template->param( patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber ) );
Lines 450-456 sub ParseCgiForBorrower { Link Here
450
sub DelUnchangedFields {
450
sub DelUnchangedFields {
451
    my ( $borrowernumber, %new_data ) = @_;
451
    my ( $borrowernumber, %new_data ) = @_;
452
452
453
    my $current_data = GetMember( borrowernumber => $borrowernumber );
453
    my $patron = Koha::Patrons->find( $borrowernumber );
454
    my $current_data = $patron->unblessed;
454
455
455
    foreach my $key ( keys %new_data ) {
456
    foreach my $key ( keys %new_data ) {
456
        if ( $current_data->{$key} eq $new_data{$key} ) {
457
        if ( $current_data->{$key} eq $new_data{$key} ) {
(-)a/opac/opac-messaging.pl (-2 / +3 lines)
Lines 50-56 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
50
    }
50
    }
51
);
51
);
52
52
53
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
53
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
54
my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
54
my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
55
55
56
if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) {
56
if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) {
Lines 63-69 if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) { Link Here
63
            smsalertnumber  => $sms,
63
            smsalertnumber  => $sms,
64
            sms_provider_id => $sms_provider_id,
64
            sms_provider_id => $sms_provider_id,
65
        );
65
        );
66
        $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
66
        # FIXME will not be needed when ModMember will be replaced
67
        $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
67
    }
68
    }
68
69
69
    C4::Form::MessagingPreferences::handle_form_action($query, { borrowernumber => $borrowernumber }, $template);
70
    C4::Form::MessagingPreferences::handle_form_action($query, { borrowernumber => $borrowernumber }, $template);
(-)a/opac/opac-passwd.pl (-3 / +4 lines)
Lines 30-35 use C4::Circulation; Link Here
30
use C4::Members;
30
use C4::Members;
31
use C4::Output;
31
use C4::Output;
32
use Koha::AuthUtils qw(hash_password);
32
use Koha::AuthUtils qw(hash_password);
33
use Koha::Patrons;
33
34
34
my $query = new CGI;
35
my $query = new CGI;
35
my $dbh   = C4::Context->dbh;
36
my $dbh   = C4::Context->dbh;
Lines 44-50 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
44
    }
45
    }
45
);
46
);
46
47
47
my $borr = C4::Members::GetMember( borrowernumber => $borrowernumber );
48
my $patron = Koha::Patrons->find( $borrowernumber );
48
my $minpasslen = C4::Context->preference("minPasswordLength");
49
my $minpasslen = C4::Context->preference("minPasswordLength");
49
if ( C4::Context->preference("OpacPasswordChange") ) {
50
if ( C4::Context->preference("OpacPasswordChange") ) {
50
    my $sth =  $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?");
51
    my $sth =  $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?");
Lines 103-110 if ( C4::Context->preference("OpacPasswordChange") ) { Link Here
103
        }
104
        }
104
    }
105
    }
105
}
106
}
106
$template->param(firstname => $borr->{'firstname'},
107
$template->param(firstname => $patron->firstname,
107
							surname => $borr->{'surname'},
108
							surname => $patron->surname,
108
							minpasslen => $minpasslen,
109
							minpasslen => $minpasslen,
109
							passwdview => 1,
110
							passwdview => 1,
110
);
111
);
(-)a/opac/opac-readingrecord.pl (-2 / +2 lines)
Lines 31-36 use MARC::Record; Link Here
31
31
32
use C4::Output;
32
use C4::Output;
33
use C4::Charset qw(StripNonXmlChars);
33
use C4::Charset qw(StripNonXmlChars);
34
use Koha::Patrons;
34
35
35
use Koha::ItemTypes;
36
use Koha::ItemTypes;
36
37
Lines 52-59 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
52
    }
53
    }
53
);
54
);
54
55
55
# get borrower information ....
56
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
56
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
57
57
58
$template->param(%{$borr});
58
$template->param(%{$borr});
59
59
(-)a/opac/opac-registration-verify.pl (-2 / +3 lines)
Lines 23-28 use C4::Auth; Link Here
23
use C4::Output;
23
use C4::Output;
24
use C4::Members;
24
use C4::Members;
25
use C4::Form::MessagingPreferences;
25
use C4::Form::MessagingPreferences;
26
use Koha::Patrons;
26
use Koha::Patron::Modifications;
27
use Koha::Patron::Modifications;
27
28
28
my $cgi = new CGI;
29
my $cgi = new CGI;
Lines 60-67 if ( $m ) { Link Here
60
        C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
61
        C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
61
62
62
        $template->param( password_cleartext => $password );
63
        $template->param( password_cleartext => $password );
63
        $template->param(
64
        my $patron = Koha::Patrons->find( $borrowernumber );
64
            borrower => GetMember( borrowernumber => $borrowernumber ) );
65
        $template->param( borrower => $patron->unblessed );
65
        $template->param(
66
        $template->param(
66
            PatronSelfRegistrationAdditionalInstructions =>
67
            PatronSelfRegistrationAdditionalInstructions =>
67
              C4::Context->preference(
68
              C4::Context->preference(
(-)a/opac/opac-renew.pl (-2 / +1 lines)
Lines 70-77 else { Link Here
70
                $branchcode = $item->{'homebranch'};
70
                $branchcode = $item->{'homebranch'};
71
            }
71
            }
72
            elsif ( $renewalbranch eq 'patronhomebranch' ) {
72
            elsif ( $renewalbranch eq 'patronhomebranch' ) {
73
                my $borrower = GetMember( borrowernumber => $borrowernumber );
73
                $branchcode = Koha::Patrons->find( $borrowernumber )->branchcode;
74
                $branchcode = $borrower->{'branchcode'};
75
            }
74
            }
76
            elsif ( $renewalbranch eq 'checkoutbranch' ) {
75
            elsif ( $renewalbranch eq 'checkoutbranch' ) {
77
                my $issue = GetOpenIssue($itemnumber);
76
                my $issue = GetOpenIssue($itemnumber);
(-)a/opac/opac-reserve.pl (-15 / +15 lines)
Lines 73-87 sub get_out { Link Here
73
	exit;
73
	exit;
74
}
74
}
75
75
76
# get borrower information ....
77
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
78
my $patron = Koha::Patrons->find( $borrowernumber );
76
my $patron = Koha::Patrons->find( $borrowernumber );
79
77
80
my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
78
my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
81
unless ( $can_place_hold_if_available_at_pickup ) {
79
unless ( $can_place_hold_if_available_at_pickup ) {
82
    my @patron_categories = split '\|', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
80
    my @patron_categories = split '\|', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
83
    if ( @patron_categories ) {
81
    if ( @patron_categories ) {
84
        $can_place_hold_if_available_at_pickup = grep /$borr->{categorycode}/, @patron_categories;
82
        my $categorycode = $patron->categorycode;
83
        $can_place_hold_if_available_at_pickup = grep /^$categorycode$/, @patron_categories;
85
    }
84
    }
86
}
85
}
87
86
Lines 135-141 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) { Link Here
135
134
136
135
137
# pass the pickup branch along....
136
# pass the pickup branch along....
138
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
137
my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '' ;
139
$template->param( branch => $branch );
138
$template->param( branch => $branch );
140
139
141
# Is the person allowed to choose their branch
140
# Is the person allowed to choose their branch
Lines 240-246 if ( $query->param('place_reserve') ) { Link Here
240
        my $singleBranchMode = Koha::Libraries->search->count == 1;
239
        my $singleBranchMode = Koha::Libraries->search->count == 1;
241
        if ( $singleBranchMode || !$OPACChooseBranch )
240
        if ( $singleBranchMode || !$OPACChooseBranch )
242
        {    # single branch mode or disabled user choosing
241
        {    # single branch mode or disabled user choosing
243
            $branch = $borr->{'branchcode'};
242
            $branch = $patron->branchcode;
244
        }
243
        }
245
244
246
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
245
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
Lines 335-341 if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) { Link Here
335
    $template->param( too_much_oweing => $amount );
334
    $template->param( too_much_oweing => $amount );
336
}
335
}
337
336
338
if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) {
337
if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
339
    $noreserves = 1;
338
    $noreserves = 1;
340
    $template->param(
339
    $template->param(
341
        message => 1,
340
        message => 1,
Lines 343-349 if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) { Link Here
343
    );
342
    );
344
}
343
}
345
344
346
if ( $borr->{lost} && ($borr->{lost} == 1) ) {
345
if ( $patron->lost && ($patron->lost == 1) ) {
347
    $noreserves = 1;
346
    $noreserves = 1;
348
    $template->param(
347
    $template->param(
349
        message => 1,
348
        message => 1,
Lines 356-363 if ( $patron->is_debarred ) { Link Here
356
    $template->param(
355
    $template->param(
357
        message          => 1,
356
        message          => 1,
358
        debarred         => 1,
357
        debarred         => 1,
359
        debarred_comment => $borr->{debarredcomment},
358
        debarred_comment => $patron->debarredcomment,
360
        debarred_date    => $borr->{debarred},
359
        debarred_date    => $patron->debarred,
361
    );
360
    );
362
}
361
}
363
362
Lines 477-488 foreach my $biblioNum (@biblionumbers) { Link Here
477
        my $holds = $item->current_holds;
476
        my $holds = $item->current_holds;
478
477
479
        if ( my $first_hold = $holds->next ) {
478
        if ( my $first_hold = $holds->next ) {
480
            my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
479
            my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
481
            $itemLoopIter->{backgroundcolor} = 'reserved';
480
            $itemLoopIter->{backgroundcolor} = 'reserved';
482
            $itemLoopIter->{reservedate}     = output_pref({ dt => dt_from_string($first_hold->reservedate), dateonly => 1 }); # FIXME Should be formatted in the template
481
            $itemLoopIter->{reservedate}     = output_pref({ dt => dt_from_string($first_hold->reservedate), dateonly => 1 }); # FIXME Should be formatted in the template
483
            $itemLoopIter->{ReservedForBorrowernumber} = $first_hold->borrowernumber;
482
            $itemLoopIter->{ReservedForBorrowernumber} = $first_hold->borrowernumber;
484
            $itemLoopIter->{ReservedForSurname}        = $ItemBorrowerReserveInfo->{'surname'};
483
            $itemLoopIter->{ReservedForSurname}        = $patron->surname;
485
            $itemLoopIter->{ReservedForFirstname}      = $ItemBorrowerReserveInfo->{'firstname'};
484
            $itemLoopIter->{ReservedForFirstname}      = $patron->firstname;
486
            $itemLoopIter->{ExpectedAtLibrary}         = $first_hold->branchcode;
485
            $itemLoopIter->{ExpectedAtLibrary}         = $first_hold->branchcode;
487
            $itemLoopIter->{waitingdate} = $first_hold->waitingdate;
486
            $itemLoopIter->{waitingdate} = $first_hold->waitingdate;
488
        }
487
        }
Lines 528-542 foreach my $biblioNum (@biblionumbers) { Link Here
528
        # If there is no loan, return and transfer, we show a checkbox.
527
        # If there is no loan, return and transfer, we show a checkbox.
529
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
528
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
530
529
531
        my $branch = GetReservesControlBranch( $itemInfo, $borr );
530
        my $patron_unblessed = $patron->unblessed;
531
        my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
532
532
533
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
533
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
534
        $policy_holdallowed &&=
534
        $policy_holdallowed &&=
535
            IsAvailableForItemLevelRequest($itemInfo,$borr) &&
535
            IsAvailableForItemLevelRequest($itemInfo,$patron_unblessed) &&
536
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
536
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
537
537
538
        if ($policy_holdallowed) {
538
        if ($policy_holdallowed) {
539
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $borr ) ) {
539
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $patron_unblessed ) ) {
540
                $itemLoopIter->{available} = 1;
540
                $itemLoopIter->{available} = 1;
541
                $numCopiesOPACAvailable++;
541
                $numCopiesOPACAvailable++;
542
                $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';
542
                $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';
(-)a/opac/opac-sendbasket.pl (-4 / +5 lines)
Lines 33-38 use C4::Output; Link Here
33
use C4::Members;
33
use C4::Members;
34
use C4::Templates ();
34
use C4::Templates ();
35
use Koha::Email;
35
use Koha::Email;
36
use Koha::Patrons;
36
use Koha::Token;
37
use Koha::Token;
37
38
38
my $query = new CGI;
39
my $query = new CGI;
Lines 57-67 if ( $email_add ) { Link Here
57
        token  => scalar $query->param('csrf_token'),
58
        token  => scalar $query->param('csrf_token'),
58
    });
59
    });
59
    my $email = Koha::Email->new();
60
    my $email = Koha::Email->new();
60
    my $user = GetMember(borrowernumber => $borrowernumber);
61
    my $patron = Koha::Patrons->find( $borrowernumber );
61
    my $user_email = GetFirstValidEmailAddress($borrowernumber)
62
    my $user_email = GetFirstValidEmailAddress($borrowernumber)
62
    || C4::Context->preference('KohaAdminEmailAddress');
63
    || C4::Context->preference('KohaAdminEmailAddress');
63
64
64
    my $email_replyto = "$user->{firstname} $user->{surname} <$user_email>";
65
    my $email_replyto = $patron->firstname . " " . $patron->surname . " <$user_email>";
65
    my $comment    = $query->param('comment');
66
    my $comment    = $query->param('comment');
66
67
67
   # if you want to use the KohaAdmin address as from, that is the default no need to set it
68
   # if you want to use the KohaAdmin address as from, that is the default no need to set it
Lines 114-121 if ( $email_add ) { Link Here
114
    $template2->param(
115
    $template2->param(
115
        BIBLIO_RESULTS => $resultsarray,
116
        BIBLIO_RESULTS => $resultsarray,
116
        comment        => $comment,
117
        comment        => $comment,
117
        firstname      => $user->{firstname},
118
        firstname      => $patron->firstname,
118
        surname        => $user->{surname},
119
        surname        => $patron->surname,
119
    );
120
    );
120
121
121
    # Getting template result
122
    # Getting template result
(-)a/opac/opac-sendshelf.pl (-3 / +4 lines)
Lines 33-38 use C4::Items; Link Here
33
use C4::Output;
33
use C4::Output;
34
use C4::Members;
34
use C4::Members;
35
use Koha::Email;
35
use Koha::Email;
36
use Koha::Patrons;
36
use Koha::Virtualshelves;
37
use Koha::Virtualshelves;
37
38
38
my $query = new CGI;
39
my $query = new CGI;
Lines 109-122 if ( $email ) { Link Here
109
        push( @results, $dat );
110
        push( @results, $dat );
110
    }
111
    }
111
112
112
    my $user = GetMember(borrowernumber => $borrowernumber);
113
    my $patron = Koha::Patrons->find( $borrowernumber );
113
114
114
    $template2->param(
115
    $template2->param(
115
        BIBLIO_RESULTS => \@results,
116
        BIBLIO_RESULTS => \@results,
116
        comment        => $comment,
117
        comment        => $comment,
117
        shelfname      => $shelf->shelfname,
118
        shelfname      => $shelf->shelfname,
118
        firstname      => $user->{firstname},
119
        firstname      => $patron->firstname,
119
        surname        => $user->{surname},
120
        surname        => $patron->surname,
120
    );
121
    );
121
122
122
    # Getting template result
123
    # Getting template result
(-)a/opac/opac-shelves.pl (-3 / +4 lines)
Lines 31-36 use C4::XSLT; Link Here
31
31
32
use Koha::Biblioitems;
32
use Koha::Biblioitems;
33
use Koha::ItemTypes;
33
use Koha::ItemTypes;
34
use Koha::Patrons;
34
use Koha::Virtualshelves;
35
use Koha::Virtualshelves;
35
use Koha::RecordProcessor;
36
use Koha::RecordProcessor;
36
37
Lines 67-73 if ( $op eq 'add_form' ) { Link Here
67
68
68
    if ( $shelf ) {
69
    if ( $shelf ) {
69
        $category = $shelf->category;
70
        $category = $shelf->category;
70
        my $patron = GetMember( 'borrowernumber' => $shelf->owner );
71
        my $patron = Koha::Patrons->find( $shelf->owner );
71
        $template->param( owner => $patron, );
72
        $template->param( owner => $patron, );
72
        unless ( $shelf->can_be_managed( $loggedinuser ) ) {
73
        unless ( $shelf->can_be_managed( $loggedinuser ) ) {
73
            push @messages, { type => 'error', code => 'unauthorized_on_update' };
74
            push @messages, { type => 'error', code => 'unauthorized_on_update' };
Lines 257-263 if ( $op eq 'view' ) { Link Here
257
                @cart_list = split(/\//, $cart_list);
258
                @cart_list = split(/\//, $cart_list);
258
            }
259
            }
259
260
260
            my $borrower = GetMember( borrowernumber => $loggedinuser );
261
            my $patron = Koha::Patrons->find( $loggedinuser );
261
262
262
            # Lists display falls back to search results configuration
263
            # Lists display falls back to search results configuration
263
            my $xslfile = C4::Context->preference('OPACXSLTListsDisplay');
264
            my $xslfile = C4::Context->preference('OPACXSLTListsDisplay');
Lines 314-320 if ( $op eq 'view' ) { Link Here
314
                    });
315
                    });
315
                }
316
                }
316
317
317
                $this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
318
                $this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($this_item, $patron);
318
319
319
320
320
                if ( grep {$_ eq $biblionumber} @cart_list) {
321
                if ( grep {$_ eq $biblionumber} @cart_list) {
(-)a/opac/opac-showreviews.pl (-2 / +2 lines)
Lines 27-34 use C4::Koha; Link Here
27
use C4::Output;
27
use C4::Output;
28
use C4::Circulation;
28
use C4::Circulation;
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Members qw/GetMember/;
31
use Koha::DateUtils;
30
use Koha::DateUtils;
31
use Koha::Patrons;
32
use Koha::Reviews;
32
use Koha::Reviews;
33
use POSIX qw(ceil floor strftime);
33
use POSIX qw(ceil floor strftime);
34
34
Lines 92-98 for my $result (@$reviews){ Link Here
92
	my $bib = &GetBiblioData($biblionumber);
92
	my $bib = &GetBiblioData($biblionumber);
93
    my $record = GetMarcBiblio($biblionumber);
93
    my $record = GetMarcBiblio($biblionumber);
94
    my $frameworkcode = GetFrameworkCode($biblionumber);
94
    my $frameworkcode = GetFrameworkCode($biblionumber);
95
    my ( $borr ) = GetMember( borrowernumber => $result->{borrowernumber} );
95
    my $borr = Koha::Patrons->find( $result->{borrowernumber} )->unblessed;
96
	$result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour);
96
	$result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour);
97
	$result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour);
97
	$result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour);
98
	$result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour);
98
	$result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour);
(-)a/opac/opac-suggestions.pl (-2 / +6 lines)
Lines 30-35 use C4::Scrubber; Link Here
30
30
31
use Koha::AuthorisedValues;
31
use Koha::AuthorisedValues;
32
use Koha::Libraries;
32
use Koha::Libraries;
33
use Koha::Patrons;
33
34
34
use Koha::DateUtils qw( dt_from_string );
35
use Koha::DateUtils qw( dt_from_string );
35
36
Lines 195-208 my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG"); Link Here
195
196
196
# Is the person allowed to choose their branch
197
# Is the person allowed to choose their branch
197
if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
198
if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
198
    my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
199
199
200
# pass the pickup branch along....
200
# pass the pickup branch along....
201
    my $userbranch = '';
201
    my $userbranch = '';
202
    if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
202
    if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
203
        $userbranch = C4::Context->userenv->{'branch'};
203
        $userbranch = C4::Context->userenv->{'branch'};
204
    }
204
    }
205
    my $branchcode = $input->param('branchcode') || $borr->{'branchcode'} || $userbranch || '' ;
205
    my $branchcode = $input->param('branchcode');
206
    unless ( $branchcode ) {
207
        my $patron = Koha::Patrons->find( $borrowernumber );
208
        $branchcode = $patron->branchcode || $userbranch || '' ;
209
    }
206
210
207
    $template->param( branchcode => $branchcode );
211
    $template->param( branchcode => $branchcode );
208
}
212
}
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 88-94 if (!$borrowernumber) { Link Here
88
}
88
}
89
89
90
# get borrower information ....
90
# get borrower information ....
91
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
91
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
92
92
93
my (  $today_year,   $today_month,   $today_day) = Today();
93
my (  $today_year,   $today_month,   $today_day) = Today();
94
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
94
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
(-)a/opac/sco/sco-main.pl (-4 / +4 lines)
Lines 45-50 use C4::Biblio; Link Here
45
use C4::Items;
45
use C4::Items;
46
use Koha::DateUtils qw( dt_from_string );
46
use Koha::DateUtils qw( dt_from_string );
47
use Koha::Acquisition::Currencies;
47
use Koha::Acquisition::Currencies;
48
use Koha::Patrons;
48
use Koha::Patron::Images;
49
use Koha::Patron::Images;
49
use Koha::Patron::Messages;
50
use Koha::Patron::Messages;
50
use Koha::Token;
51
use Koha::Token;
Lines 106-120 my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed) = ( Link Here
106
);
107
);
107
108
108
my $issuenoconfirm = 1; #don't need to confirm on issue.
109
my $issuenoconfirm = 1; #don't need to confirm on issue.
109
#warn "issuerid: " . $issuerid;
110
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
110
my $issuer   = GetMember( borrowernumber => $issuerid );
111
my $item     = GetItem(undef,$barcode);
111
my $item     = GetItem(undef,$barcode);
112
if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) {
112
if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) {
113
    my $dbh = C4::Context->dbh;
113
    my $dbh = C4::Context->dbh;
114
    my $resval;
114
    my $resval;
115
    ($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw);
115
    ($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw);
116
}
116
}
117
my $borrower = GetMember( cardnumber => $patronid );
117
my $borrower = Koha::Patrons->find( { cardnumber => $patronid } )->unblessed;
118
118
119
my $currencySymbol = "";
119
my $currencySymbol = "";
120
if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) {
120
if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) {
Lines 132-138 if ($op eq "logout") { Link Here
132
elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
132
elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
133
    my ($doreturn) = AddReturn( $barcode, $branch );
133
    my ($doreturn) = AddReturn( $barcode, $branch );
134
    #warn "returnbook: " . $doreturn;
134
    #warn "returnbook: " . $doreturn;
135
    $borrower = GetMember( cardnumber => $patronid );
135
    $borrower = Koha::Patrons->find( { cardnumber => $patronid } )->unblessed;
136
}
136
}
137
elsif ( $op eq "checkout" ) {
137
elsif ( $op eq "checkout" ) {
138
    my $impossible  = {};
138
    my $impossible  = {};
(-)a/patroncards/create-pdf.pl (-2 / +2 lines)
Lines 29-38 use autouse 'Data::Dumper' => qw(Dumper); Link Here
29
29
30
use C4::Debug;
30
use C4::Debug;
31
use C4::Context;
31
use C4::Context;
32
use autouse 'C4::Members' => qw(GetMember);
33
use C4::Creators;
32
use C4::Creators;
34
use C4::Patroncards;
33
use C4::Patroncards;
35
use Koha::List::Patron;
34
use Koha::List::Patron;
35
use Koha::Patrons;
36
use Koha::Patron::Images;
36
use Koha::Patron::Images;
37
37
38
my $cgi = new CGI;
38
my $cgi = new CGI;
Lines 135-141 foreach my $item (@{$items}) { Link Here
135
135
136
        $cardscount ++;
136
        $cardscount ++;
137
        my $borrower_number = $item->{'borrower_number'};
137
        my $borrower_number = $item->{'borrower_number'};
138
        my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
138
        my $card_number = Koha::Patrons->find( $borrower_number)->cardnumber;
139
139
140
#       Set barcode data
140
#       Set barcode data
141
        $print_layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $print_layout_xml->{'barcode'};
141
        $print_layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $print_layout_xml->{'barcode'};
(-)a/patroncards/edit-batch.pl (-2 / +3 lines)
Lines 29-35 use C4::Auth qw(get_template_and_user); Link Here
29
use C4::Output qw(output_html_with_http_headers);
29
use C4::Output qw(output_html_with_http_headers);
30
use C4::Creators;
30
use C4::Creators;
31
use C4::Patroncards;
31
use C4::Patroncards;
32
use C4::Members qw(GetMember);
32
use Koha::Patrons;
33
33
my $cgi = new CGI;
34
my $cgi = new CGI;
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
    {
36
    {
Lines 84-90 if ($bor_num_list) { Link Here
84
        my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a <cr> separated list
85
        my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a <cr> separated list
85
        foreach my $number (@bor_nums_unchecked) {
86
        foreach my $number (@bor_nums_unchecked) {
86
            $number =~ s/\r$//; # strip any naughty return chars
87
            $number =~ s/\r$//; # strip any naughty return chars
87
            if ( GetMember(borrowernumber => $number)) {  # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm
88
            if ( Koha::Patrons->find( $number )) {  # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm
88
                my $borrower_number = $number;
89
                my $borrower_number = $number;
89
                push @borrower_numbers, $borrower_number;
90
                push @borrower_numbers, $borrower_number;
90
            }
91
            }
(-)a/reserve/placerequest.pl (-2 / +4 lines)
Lines 32-37 use C4::Reserves; Link Here
32
use C4::Circulation;
32
use C4::Circulation;
33
use C4::Members;
33
use C4::Members;
34
use C4::Auth qw/checkauth/;
34
use C4::Auth qw/checkauth/;
35
use Koha::Patrons;
35
36
36
my $input = CGI->new();
37
my $input = CGI->new();
37
38
Lines 51-57 my $checkitem = $input->param('checkitem'); Link Here
51
my $expirationdate = $input->param('expiration_date');
52
my $expirationdate = $input->param('expiration_date');
52
my $itemtype       = $input->param('itemtype') || undef;
53
my $itemtype       = $input->param('itemtype') || undef;
53
54
54
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
55
my $borrower = Koha::Patrons->find( $borrowernumber );
56
$borrower = $borrower->unblessed if $borrower;
55
57
56
my $multi_hold = $input->param('multi_hold');
58
my $multi_hold = $input->param('multi_hold');
57
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
59
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
Lines 128-134 if ( $type eq 'str8' && $borrower ) { Link Here
128
        print $input->redirect("request.pl?biblionumber=$biblionumber");
130
        print $input->redirect("request.pl?biblionumber=$biblionumber");
129
    }
131
    }
130
}
132
}
131
elsif ( $borrower eq '' ) {
133
elsif ( $borrowernumber eq '' ) {
132
    print $input->header();
134
    print $input->header();
133
    print "Invalid borrower number please try again";
135
    print "Invalid borrower number please try again";
134
136
(-)a/reserve/request.pl (-38 / +38 lines)
Lines 100-108 if ( $action eq 'move' ) { Link Here
100
}
100
}
101
101
102
if ($findborrower) {
102
if ($findborrower) {
103
    my $borrower = C4::Members::GetMember( cardnumber => $findborrower );
103
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
104
    if ( $borrower ) {
104
    if ( $patron ) {
105
        $borrowernumber_hold = $borrower->{borrowernumber};
105
        $borrowernumber_hold = $patron->borrowernumber;
106
    } else {
106
    } else {
107
        my $dt_params = { iDisplayLength => -1 };
107
        my $dt_params = { iDisplayLength => -1 };
108
        my $results = C4::Utils::DataTables::Members::search(
108
        my $results = C4::Utils::DataTables::Members::search(
Lines 134-147 if ($multihold) { Link Here
134
# If we have the borrowernumber because we've performed an action, then we
134
# If we have the borrowernumber because we've performed an action, then we
135
# don't want to try to place another reserve.
135
# don't want to try to place another reserve.
136
if ($borrowernumber_hold && !$action) {
136
if ($borrowernumber_hold && !$action) {
137
    my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold );
137
    my $patron = Koha::Patrons->find( $borrowernumber_hold );
138
    my $diffbranch;
138
    my $diffbranch;
139
139
140
    # we check the reserves of the user, and if they can reserve a document
140
    # we check the reserves of the user, and if they can reserve a document
141
    # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
141
    # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
142
142
143
    my $reserves_count =
143
    my $reserves_count =
144
      GetReserveCount( $borrowerinfo->{'borrowernumber'} );
144
      GetReserveCount( $patron->borrowernumber );
145
145
146
    my $new_reserves_count = scalar( @biblionumbers );
146
    my $new_reserves_count = scalar( @biblionumbers );
147
147
Lines 164-170 if ($borrowernumber_hold && !$action) { Link Here
164
    }
164
    }
165
165
166
    # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
166
    # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
167
    my $expiry_date = $borrowerinfo->{dateexpiry};
167
    my $expiry_date = $patron->dateexpiry;
168
    my $expiry = 0; # flag set if patron account has expired
168
    my $expiry = 0; # flag set if patron account has expired
169
    if ($expiry_date and $expiry_date ne '0000-00-00' and
169
    if ($expiry_date and $expiry_date ne '0000-00-00' and
170
        Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
170
        Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
Lines 172-209 if ($borrowernumber_hold && !$action) { Link Here
172
    }
172
    }
173
173
174
    # check if the borrower make the reserv in a different branch
174
    # check if the borrower make the reserv in a different branch
175
    if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) {
175
    if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
176
        $diffbranch = 1;
176
        $diffbranch = 1;
177
    }
177
    }
178
178
179
    my $is_debarred = Koha::Patrons->find( $borrowerinfo->{borrowernumber} )->is_debarred;
179
    my $is_debarred = $patron->is_debarred;
180
    $template->param(
180
    $template->param(
181
                borrowernumber      => $borrowerinfo->{'borrowernumber'},
181
                borrowernumber      => $patron->borrowernumber,
182
                borrowersurname     => $borrowerinfo->{'surname'},
182
                borrowersurname     => $patron->surname,
183
                borrowerfirstname   => $borrowerinfo->{'firstname'},
183
                borrowerfirstname   => $patron->firstname,
184
                borrowerstreetaddress   => $borrowerinfo->{'address'},
184
                borrowerstreetaddress   => $patron->address,
185
                borrowercity        => $borrowerinfo->{'city'},
185
                borrowercity        => $patron->city,
186
                borrowerphone       => $borrowerinfo->{'phone'},
186
                borrowerphone       => $patron->phone,
187
                borrowermobile      => $borrowerinfo->{'mobile'},
187
                borrowermobile      => $patron->mobile,
188
                borrowerfax         => $borrowerinfo->{'fax'},
188
                borrowerfax         => $patron->fax,
189
                borrowerphonepro    => $borrowerinfo->{'phonepro'},
189
                borrowerphonepro    => $patron->phonepro,
190
                borroweremail       => $borrowerinfo->{'email'},
190
                borroweremail       => $patron->email,
191
                borroweremailpro    => $borrowerinfo->{'emailpro'},
191
                borroweremailpro    => $patron->emailpro,
192
                borrowercategory    => $borrowerinfo->{'category'},
192
                cardnumber          => $patron->cardnumber,
193
                cardnumber          => $borrowerinfo->{'cardnumber'},
194
                expiry              => $expiry,
193
                expiry              => $expiry,
195
                diffbranch          => $diffbranch,
194
                diffbranch          => $diffbranch,
196
                messages            => $messages,
195
                messages            => $messages,
197
                warnings            => $warnings,
196
                warnings            => $warnings,
198
                restricted          => $is_debarred,
197
                restricted          => $is_debarred,
199
                amount_outstanding  => GetMemberAccountRecords($borrowerinfo->{borrowernumber}),
198
                amount_outstanding  => GetMemberAccountRecords($patron->borrowernumber),
200
    );
199
    );
201
}
200
}
202
201
203
$template->param( messageborrower => $messageborrower );
202
$template->param( messageborrower => $messageborrower );
204
203
205
# FIXME launch another time GetMember perhaps until
204
# FIXME launch another time GetMember perhaps until (Joubu: Why?)
206
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold );
205
my $patron = Koha::Patrons->find( $borrowernumber_hold );
207
206
208
my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
207
my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
209
208
Lines 216-222 foreach my $biblionumber (@biblionumbers) { Link Here
216
215
217
    my $dat = GetBiblioData($biblionumber);
216
    my $dat = GetBiblioData($biblionumber);
218
217
219
    my $canReserve = CanBookBeReserved( $borrowerinfo->{borrowernumber}, $biblionumber );
218
    my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
220
    $canReserve //= '';
219
    $canReserve //= '';
221
    if ( $canReserve eq 'OK' ) {
220
    if ( $canReserve eq 'OK' ) {
222
221
Lines 238-244 foreach my $biblionumber (@biblionumbers) { Link Here
238
    }
237
    }
239
238
240
    my $force_hold_level;
239
    my $force_hold_level;
241
    if ( $borrowerinfo->{borrowernumber} ) {
240
    if ( $patron->borrowernumber ) {
242
        # For multiple holds per record, if a patron has previously placed a hold,
241
        # For multiple holds per record, if a patron has previously placed a hold,
243
        # the patron can only place more holds of the same type. That is, if the
242
        # the patron can only place more holds of the same type. That is, if the
244
        # patron placed a record level hold, all the holds the patron places must
243
        # patron placed a record level hold, all the holds the patron places must
Lines 246-252 foreach my $biblionumber (@biblionumbers) { Link Here
246
        # the patron places must be item level
245
        # the patron places must be item level
247
        my $holds = Koha::Holds->search(
246
        my $holds = Koha::Holds->search(
248
            {
247
            {
249
                borrowernumber => $borrowerinfo->{borrowernumber},
248
                borrowernumber => $patron->borrowernumber,
250
                biblionumber   => $biblionumber,
249
                biblionumber   => $biblionumber,
251
                found          => undef,
250
                found          => undef,
252
            }
251
            }
Lines 257-263 foreach my $biblionumber (@biblionumbers) { Link Here
257
256
258
        # For a librarian to be able to place multiple record holds for a patron for a record,
257
        # For a librarian to be able to place multiple record holds for a patron for a record,
259
        # we must find out what the maximum number of holds they can place for the patron is
258
        # we must find out what the maximum number of holds they can place for the patron is
260
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowerinfo->{borrowernumber}, $biblionumber );
259
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
261
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
260
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
262
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
261
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
263
        $template->param( max_holds_for_record => $max_holds_for_record );
262
        $template->param( max_holds_for_record => $max_holds_for_record );
Lines 268-274 foreach my $biblionumber (@biblionumbers) { Link Here
268
    # patron already has an item from that record checked out
267
    # patron already has an item from that record checked out
269
    my $alreadypossession;
268
    my $alreadypossession;
270
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
269
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
271
        && CheckIfIssuedToPatron( $borrowerinfo->{borrowernumber}, $biblionumber ) )
270
        && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) )
272
    {
271
    {
273
        $template->param( alreadypossession => $alreadypossession, );
272
        $template->param( alreadypossession => $alreadypossession, );
274
    }
273
    }
Lines 393-405 foreach my $biblionumber (@biblionumbers) { Link Here
393
            # checking reserve
392
            # checking reserve
394
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
393
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
395
            if ( my $first_hold = $holds->next ) {
394
            if ( my $first_hold = $holds->next ) {
396
                my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
395
                my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
397
396
398
                $item->{backgroundcolor} = 'reserved';
397
                $item->{backgroundcolor} = 'reserved';
399
                $item->{reservedate}     = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
398
                $item->{reservedate}     = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
400
                $item->{ReservedForBorrowernumber}     = $first_hold->borrowernumber;
399
                $item->{ReservedForBorrowernumber}     = $first_hold->borrowernumber;
401
                $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
400
                $item->{ReservedForSurname}     = $patron->surname;
402
                $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
401
                $item->{ReservedForFirstname}     = $patron->firstname;
403
                $item->{ExpectedAtLibrary}     = $first_hold->branchcode;
402
                $item->{ExpectedAtLibrary}     = $first_hold->branchcode;
404
                $item->{waitingdate} = $first_hold->waitingdate;
403
                $item->{waitingdate} = $first_hold->waitingdate;
405
            }
404
            }
Lines 452-472 foreach my $biblionumber (@biblionumbers) { Link Here
452
                }
451
                }
453
            }
452
            }
454
453
455
            my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
454
            my $patron_unblessed = $patron->unblessed;
455
            my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
456
456
457
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
457
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
458
458
459
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
459
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
460
460
461
            my $can_item_be_reserved = CanItemBeReserved( $borrowerinfo->{borrowernumber}, $itemnumber );
461
            my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
462
            $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
462
            $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
463
463
464
            $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $borrowerinfo );
464
            $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed);
465
465
466
            if (
466
            if (
467
                   !$item->{cantreserve}
467
                   !$item->{cantreserve}
468
                && !$exceeded_maxreserves
468
                && !$exceeded_maxreserves
469
                && IsAvailableForItemLevelRequest($item, $borrowerinfo)
469
                && IsAvailableForItemLevelRequest($item, $patron_unblessed)
470
                && $can_item_be_reserved eq 'OK'
470
                && $can_item_be_reserved eq 'OK'
471
              )
471
              )
472
            {
472
            {
Lines 611-618 foreach my $biblionumber (@biblionumbers) { Link Here
611
                     holdsview => 1,
611
                     holdsview => 1,
612
                     C4::Search::enabled_staff_search_views,
612
                     C4::Search::enabled_staff_search_views,
613
                    );
613
                    );
614
    if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
614
    if ( $patron ) { # FIXME This test seems very useless
615
        $template->param( borrower_branchcode => $borrowerinfo->{'branchcode'},);
615
        $template->param( borrower_branchcode => $patron->branchcode );
616
    }
616
    }
617
617
618
    $biblioloopiter{biblionumber} = $biblionumber;
618
    $biblioloopiter{biblionumber} = $biblionumber;
(-)a/reviews/reviewswaiting.pl (-4 / +4 lines)
Lines 21-28 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use C4::Members;
25
use C4::Biblio;
24
use C4::Biblio;
25
use Koha::Patrons;
26
use Koha::Reviews;
26
use Koha::Reviews;
27
27
28
my $query = new CGI;
28
my $query = new CGI;
Lines 68-79 my $reviews = Koha::Reviews->search( Link Here
68
68
69
foreach ( @$reviews ) {
69
foreach ( @$reviews ) {
70
    my $borrowernumber = $_->{borrowernumber};
70
    my $borrowernumber = $_->{borrowernumber};
71
    my $borrowerData   = GetMember('borrowernumber' => $borrowernumber);
71
    my $patron = Koha::Patrons->find( $borrowernumber);
72
    my $biblioData     = GetBiblioData($_->{biblionumber});
72
    my $biblioData     = GetBiblioData($_->{biblionumber});
73
    # setting some borrower info into this hash
73
    # setting some borrower info into this hash
74
    $_->{bibliotitle} = $biblioData->{'title'};
74
    $_->{bibliotitle} = $biblioData->{'title'};
75
    $_->{surname}     = $borrowerData->{'surname'};
75
    $_->{surname}     = $patron->surname;
76
    $_->{firstname}   = $borrowerData->{'firstname'};
76
    $_->{firstname}   = $patron->firstname;
77
}
77
}
78
78
79
my $url = "/cgi-bin/koha/reviews/reviewswaiting.pl?status=$status";
79
my $url = "/cgi-bin/koha/reviews/reviewswaiting.pl?status=$status";
(-)a/serials/routing-preview.pl (-1 / +2 lines)
Lines 36-41 use URI::Escape; Link Here
36
36
37
use Koha::Biblios;
37
use Koha::Biblios;
38
use Koha::Libraries;
38
use Koha::Libraries;
39
use Koha::Patrons;
39
40
40
my $query = new CGI;
41
my $query = new CGI;
41
my $subscriptionid = $query->param('subscriptionid');
42
my $subscriptionid = $query->param('subscriptionid');
Lines 121-127 if($ok){ Link Here
121
122
122
my $memberloop = [];
123
my $memberloop = [];
123
for my $routing (@routinglist) {
124
for my $routing (@routinglist) {
124
    my $member = GetMember( borrowernumber => $routing->{borrowernumber} );
125
    my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed;
125
    $member->{name}           = "$member->{firstname} $member->{surname}";
126
    $member->{name}           = "$member->{firstname} $member->{surname}";
126
    push @{$memberloop}, $member;
127
    push @{$memberloop}, $member;
127
}
128
}
(-)a/serials/routing.pl (-1 / +2 lines)
Lines 37-42 use C4::Context; Link Here
37
37
38
use C4::Members;
38
use C4::Members;
39
use C4::Serials;
39
use C4::Serials;
40
use Koha::Patrons;
40
41
41
use URI::Escape;
42
use URI::Escape;
42
43
Lines 95-101 my ($template, $loggedinuser, $cookie) Link Here
95
96
96
my $member_loop = [];
97
my $member_loop = [];
97
for my $routing ( @routinglist ) {
98
for my $routing ( @routinglist ) {
98
    my $member=GetMember('borrowernumber' => $routing->{borrowernumber});
99
    my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed;
99
    $member->{location} = $member->{branchcode};
100
    $member->{location} = $member->{branchcode};
100
    if ($member->{firstname} ) {
101
    if ($member->{firstname} ) {
101
        $member->{name} = $member->{firstname} . q| |;
102
        $member->{name} = $member->{firstname} . q| |;
(-)a/suggestion/suggestion.pl (-10 / +12 lines)
Lines 34-39 use Koha::DateUtils qw( dt_from_string ); Link Here
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::Acquisition::Currencies;
35
use Koha::Acquisition::Currencies;
36
use Koha::Libraries;
36
use Koha::Libraries;
37
use Koha::Patrons;
37
38
38
use URI::Escape;
39
use URI::Escape;
39
40
Lines 69-77 sub GetCriteriumDesc{ Link Here
69
        return $av->count ? $av->next->lib : 'Unkown';
70
        return $av->count ? $av->next->lib : 'Unkown';
70
    }
71
    }
71
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
72
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
72
        my $borr=C4::Members::GetMember(borrowernumber=>$criteriumvalue);
73
        my $patron = Koha::Patrons->find( $criteriumvalue );
73
        return "" unless $borr;
74
        return "" unless $patron;
74
        return $$borr{surname} . ", " . $$borr{firstname};
75
        return $patron->surname . ", " . $patron->firstname;
75
    }
76
    }
76
    if ( $displayby =~ /budgetid/) {
77
    if ( $displayby =~ /budgetid/) {
77
        my $budget = GetBudget($criteriumvalue);
78
        my $budget = GetBudget($criteriumvalue);
Lines 281-294 if ($op=~/else/) { Link Here
281
foreach my $element ( qw(managedby suggestedby acceptedby) ) {
282
foreach my $element ( qw(managedby suggestedby acceptedby) ) {
282
#    $debug || warn $$suggestion_ref{$element};
283
#    $debug || warn $$suggestion_ref{$element};
283
    if ($$suggestion_ref{$element}){
284
    if ($$suggestion_ref{$element}){
284
        my $member=GetMember(borrowernumber=>$$suggestion_ref{$element});
285
        my $patron = Koha::Patrons->find( $$suggestion_ref{$element} );
286
        my $category = $patron->category;
285
        $template->param(
287
        $template->param(
286
            $element."_borrowernumber"=>$$member{borrowernumber},
288
            $element."_borrowernumber"=>$patron->borrowernumber,
287
            $element."_firstname"=>$$member{firstname},
289
            $element."_firstname"=>$patron->firstname,
288
            $element."_surname"=>$$member{surname},
290
            $element."_surname"=>$patron->surname,
289
            $element."_branchcode"=>$$member{branchcode},
291
            $element."_branchcode"=>$patron->branchcode,
290
            $element."_description"=>$$member{description},
292
            $element."_description"=>$category->description,
291
            $element."_category_type"=>$$member{category_type}
293
            $element."_category_type"=>$category->category_type,
292
        );
294
        );
293
    }
295
    }
294
}
296
}
(-)a/svc/members/search (-2 / +3 lines)
Lines 25-30 use C4::Output qw( output_with_http_headers ); Link Here
25
use C4::Utils::DataTables qw( dt_get_params );
25
use C4::Utils::DataTables qw( dt_get_params );
26
use C4::Utils::DataTables::Members qw( search );
26
use C4::Utils::DataTables::Members qw( search );
27
use Koha::DateUtils qw( output_pref dt_from_string );
27
use Koha::DateUtils qw( output_pref dt_from_string );
28
use Koha::Patrons;
28
29
29
my $input = new CGI;
30
my $input = new CGI;
30
31
Lines 63-73 if ( $searchmember Link Here
63
    and $searchfieldstype
64
    and $searchfieldstype
64
    and $searchfieldstype eq 'standard' )
65
    and $searchfieldstype eq 'standard' )
65
{
66
{
66
    my $member = C4::Members::GetMember( cardnumber => $searchmember );
67
    my $member = Koha::Patrons->find( { cardnumber => $searchmember } );
67
    $results = {
68
    $results = {
68
        iTotalRecords        => 1,
69
        iTotalRecords        => 1,
69
        iTotalDisplayRecords => 1,
70
        iTotalDisplayRecords => 1,
70
        patrons              => [ $member ],
71
        patrons              => [ $member->unblessed ],
71
    } if $member;
72
    } if $member;
72
}
73
}
73
74
(-)a/t/db_dependent/Acquisition/OrderUsers.t (-2 lines)
Lines 77-84 my $borrowernumber = C4::Members::AddMember( Link Here
77
    userid => 'TESTUSERID'
77
    userid => 'TESTUSERID'
78
);
78
);
79
79
80
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
81
82
C4::Acquisition::ModOrderUsers( $ordernumber, $borrowernumber );
80
C4::Acquisition::ModOrderUsers( $ordernumber, $borrowernumber );
83
81
84
my $is_added = grep { /^$borrowernumber$/ } C4::Acquisition::GetOrderUsers( $ordernumber );
82
my $is_added = grep { /^$borrowernumber$/ } C4::Acquisition::GetOrderUsers( $ordernumber );
(-)a/t/db_dependent/Circulation.t (-10 / +13 lines)
Lines 35-40 use Koha::DateUtils; Link Here
35
use Koha::Database;
35
use Koha::Database;
36
use Koha::IssuingRules;
36
use Koha::IssuingRules;
37
use Koha::Checkouts;
37
use Koha::Checkouts;
38
use Koha::Patrons;
38
use Koha::Subscriptions;
39
use Koha::Subscriptions;
39
40
40
my $schema = Koha::Database->schema;
41
my $schema = Koha::Database->schema;
Lines 294-301 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
294
    my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data);
295
    my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data);
295
    my $restricted_borrowernumber = AddMember(%restricted_borrower_data);
296
    my $restricted_borrowernumber = AddMember(%restricted_borrower_data);
296