Bug 17829: Move GetMember to Koha::Patron

GetMember returned a patron given a borrowernumber, cardnumber or
userid.
All of these 3 attributes are defined as a unique key at the DB level
and so we can use Koha::Patrons->find to replace this subroutine.
Additionaly GetMember set category_type and description.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2016-12-29 14:24:03 +01:00
parent 06c53f21db
commit 2b90ea2cb0
124 changed files with 951 additions and 944 deletions

View File

@ -35,6 +35,7 @@ use Koha::Items;
use Koha::Number::Price;
use Koha::Libraries;
use Koha::CsvProfiles;
use Koha::Patrons;
use C4::Koha;
@ -805,7 +806,7 @@ AcqViewBaskets, user permissions and basket properties (creator, users list,
branch).
First parameter can be either a borrowernumber or a hashref as returned by
C4::Members::GetMember.
Koha::Patron->unblessed
Second parameter can be either a basketno or a hashref as returned by
C4::Acquisition::GetBasket.
@ -822,7 +823,7 @@ sub CanUserManageBasket {
my ($borrower, $basket, $userflags) = @_;
if (!ref $borrower) {
$borrower = C4::Members::GetMember(borrowernumber => $borrower);
$borrower = Koha::Patrons->find( $borrower );
}
if (!ref $basket) {
$basket = GetBasket($basket);
@ -830,7 +831,7 @@ sub CanUserManageBasket {
return 0 unless ($basket and $borrower);
my $borrowernumber = $borrower->{borrowernumber};
my $borrowernumber = $borrower->borrowernumber;
my $basketno = $basket->{basketno};
my $AcqViewBaskets = C4::Context->preference('AcqViewBaskets');
@ -842,7 +843,7 @@ sub CanUserManageBasket {
my ($flags) = $sth->fetchrow_array;
$sth->finish;
$userflags = C4::Auth::getuserflags($flags, $borrower->{userid}, $dbh);
$userflags = C4::Auth::getuserflags($flags, $borrower->userid, $dbh);
}
unless ($userflags->{superlibrarian}
@ -865,7 +866,7 @@ sub CanUserManageBasket {
}
if ($AcqViewBaskets eq 'branch' && defined $basket->{branch}
&& $basket->{branch} ne $borrower->{branchcode}) {
&& $basket->{branch} ne $borrower->branchcode) {
return 0;
}
}
@ -3082,17 +3083,17 @@ sub NotifyOrderUsers {
my $order = GetOrder( $ordernumber );
for my $borrowernumber (@borrowernumbers) {
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $library = Koha::Libraries->find( $borrower->{branchcode} )->unblessed;
my $patron = Koha::Patrons->find( $borrowernumber );
my $library = $patron->library->unblessed;
my $biblio = Koha::Biblios->find( $order->{biblionumber} )->unblessed;
my $letter = C4::Letters::GetPreparedLetter(
module => 'acquisition',
letter_code => 'ACQ_NOTIF_ON_RECEIV',
branchcode => $library->{branchcode},
lang => $borrower->{lang},
lang => $patron->lang,
tables => {
'branches' => $library,
'borrowers' => $borrower,
'borrowers' => $patron->unblessed,
'biblio' => $biblio,
'aqorders' => $order,
},

View File

@ -211,7 +211,6 @@ sub get_template_and_user {
my $borrowernumber;
if ($user) {
require C4::Members;
# It's possible for $user to be the borrowernumber if they don't have a
# userid defined (and are logging in through some other method, such
@ -219,8 +218,9 @@ sub get_template_and_user {
my $borrower;
$borrowernumber = getborrowernumber($user) if defined($user);
if ( !defined($borrowernumber) && defined($user) ) {
$borrower = C4::Members::GetMember( borrowernumber => $user );
$borrower = Koha::Patrons->find( $user );
if ($borrower) {
$borrower = $borrower->unblessed;
$borrowernumber = $user;
# A bit of a hack, but I don't know there's a nicer way
@ -228,7 +228,8 @@ sub get_template_and_user {
$user = $borrower->{firstname} . ' ' . $borrower->{surname};
}
} else {
$borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
$borrower = Koha::Patrons->find( $borrowernumber );
$borrower->unblessed if $borrower; # FIXME Otherwise, what to do?
}
# user info

View File

@ -21,6 +21,7 @@ use strict;
#use warnings; FIXME - Bug 2505
use C4::Context;
use Koha::Database;
use Koha::Patrons;
use C4::Debug;
use vars qw(@ISA @EXPORT);
@ -915,7 +916,7 @@ sub CanUserUseBudget {
my ($borrower, $budget, $userflags) = @_;
if (not ref $borrower) {
$borrower = C4::Members::GetMember(borrowernumber => $borrower);
$borrower = Koha::Patrons->find( $borrower )->unblessed;
}
if (not ref $budget) {
$budget = GetBudget($budget);
@ -998,7 +999,7 @@ sub CanUserModifyBudget {
my ($borrower, $budget, $userflags) = @_;
if (not ref $borrower) {
$borrower = C4::Members::GetMember(borrowernumber => $borrower);
$borrower = Koha::Patrons->find( $borrower )->unblessed;
}
if (not ref $budget) {
$budget = GetBudget($budget);

View File

@ -573,7 +573,7 @@ C<$issuingimpossible> and C<$needsconfirmation> are some hashref.
=over 4
=item C<$borrower> hash with borrower informations (from GetMember)
=item C<$borrower> hash with borrower informations (from Koha::Patron->unblessed)
=item C<$barcode> is the bar code of the book being issued.
@ -971,8 +971,8 @@ sub CanBookBeIssued {
elsif ( $issue ) {
# issued to someone else
my $currborinfo = C4::Members::GetMember( borrowernumber => $issue->borrowernumber );
my $patron = Koha::Patrons->find( $issue->borrowernumber );
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
@ -981,10 +981,10 @@ sub CanBookBeIssued {
$issuingimpossible{branch_to_return} = $message;
} else {
$needsconfirmation{ISSUED_TO_ANOTHER} = 1;
$needsconfirmation{issued_firstname} = $currborinfo->{'firstname'};
$needsconfirmation{issued_surname} = $currborinfo->{'surname'};
$needsconfirmation{issued_cardnumber} = $currborinfo->{'cardnumber'};
$needsconfirmation{issued_borrowernumber} = $currborinfo->{'borrowernumber'};
$needsconfirmation{issued_firstname} = $patron->firstname;
$needsconfirmation{issued_surname} = $patron->surname;
$needsconfirmation{issued_cardnumber} = $patron->cardnumber;
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
}
}
@ -994,28 +994,28 @@ sub CanBookBeIssued {
if ($restype) {
my $resbor = $res->{'borrowernumber'};
if ( $resbor ne $borrower->{'borrowernumber'} ) {
my ( $resborrower ) = C4::Members::GetMember( borrowernumber => $resbor );
my $patron = Koha::Patrons->find( $resbor );
if ( $restype eq "Waiting" )
{
# The item is on reserve and waiting, but has been
# reserved by some other patron.
$needsconfirmation{RESERVE_WAITING} = 1;
$needsconfirmation{'resfirstname'} = $resborrower->{'firstname'};
$needsconfirmation{'ressurname'} = $resborrower->{'surname'};
$needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
$needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
$needsconfirmation{'resfirstname'} = $patron->firstname;
$needsconfirmation{'ressurname'} = $patron->surname;
$needsconfirmation{'rescardnumber'} = $patron->cardnumber;
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
}
elsif ( $restype eq "Reserved" ) {
# The item is on reserve for someone else.
$needsconfirmation{RESERVED} = 1;
$needsconfirmation{'resfirstname'} = $resborrower->{'firstname'};
$needsconfirmation{'ressurname'} = $resborrower->{'surname'};
$needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
$needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
$needsconfirmation{'resreservedate'} = $res->{'reservedate'};
$needsconfirmation{'resfirstname'} = $patron->firstname;
$needsconfirmation{'ressurname'} = $patron->surname;
$needsconfirmation{'rescardnumber'} = $patron->cardnumber;
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
$needsconfirmation{'resbranchcode'} = $patron->branchcode;
$needsconfirmation{'resreservedate'} = $res->{reservedate};
}
}
}
@ -1235,7 +1235,7 @@ Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this
=over 4
=item C<$borrower> is a hash with borrower informations (from GetMember).
=item C<$borrower> is a hash with borrower informations (from Koha::Patron->unblessed).
=item C<$barcode> is the barcode of the item being issued.
@ -1808,7 +1808,7 @@ sub AddReturn {
}
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default
my $messages;
my $borrower;
my $patron;
my $doreturn = 1;
my $validTransfert = 0;
my $stat_type = 'return';
@ -1827,7 +1827,7 @@ sub AddReturn {
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
if ( $issue ) {
$borrower = C4::Members::GetMember( borrowernumber => $issue->borrowernumber )
$patron = Koha::Patrons->find( $issue->borrowernumber )
or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existent borrowernumber '" . $issue->borrowernumber . "'\n"
. Dumper($issue->unblessed) . "\n";
} else {
@ -1859,7 +1859,8 @@ sub AddReturn {
my $returnbranch = $item->{$hbr} || $branch ;
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
my $borrowernumber = $borrower->{'borrowernumber'} || undef; # we don't know if we had a borrower or not
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not
my $patron_unblessed = $patron ? $patron->unblessed : {};
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
if ($yaml) {
@ -1898,7 +1899,7 @@ sub AddReturn {
Rightbranch => $message
};
$doreturn = 0;
return ( $doreturn, $messages, $issue, $borrower );
return ( $doreturn, $messages, $issue, $patron_unblessed);
}
if ( $item->{'withdrawn'} ) { # book has been cancelled
@ -1912,28 +1913,28 @@ sub AddReturn {
if ($doreturn) {
my $is_overdue;
die "The item is not issed and cannot be returned" unless $issue; # Just in case...
$borrower or warn "AddReturn without current borrower";
$patron or warn "AddReturn without current borrower";
my $circControlBranch;
if ($dropbox) {
# define circControlBranch only if dropbox mode is set
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today)
# FIXME: check issuedate > returndate, factoring in holidays
$circControlBranch = _GetCircControlBranch($item,$borrower);
$circControlBranch = _GetCircControlBranch($item,$patron_unblessed);
$is_overdue = $issue->is_overdue( $dropboxdate );
} else {
$is_overdue = $issue->is_overdue;
}
if ($borrowernumber) {
if ($patron) {
eval {
my $issue_id = MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
$circControlBranch, $return_date, $borrower->{'privacy'} );
$circControlBranch, $return_date, $patron->privacy );
$issue->issue_id($issue_id);
};
unless ( $@ ) {
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) {
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $borrower, return_date => $return_date } );
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed, return_date => $return_date } );
}
} else {
$messages->{'Wrongbranch'} = {
@ -1941,7 +1942,7 @@ sub AddReturn {
Rightbranch => $message
};
carp $@;
return ( 0, { WasReturned => 0 }, $issue, $borrower );
return ( 0, { WasReturned => 0 }, $issue, $patron_unblessed );
}
# FIXME is the "= 1" right? This could be the borrower hash.
@ -2013,22 +2014,22 @@ sub AddReturn {
if ( $issue and $issue->is_overdue ) {
# fix fine days
$today = $dropboxdate if $dropbox;
my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, dt_from_string($issue->date_due), $today );
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item, dt_from_string($issue->date_due), $today );
if ($reminder){
$messages->{'PrevDebarred'} = $debardate;
} else {
$messages->{'Debarred'} = $debardate if $debardate;
}
# there's no overdue on the item but borrower had been previously debarred
} elsif ( $issue->date_due and $borrower->{'debarred'} ) {
if ( $borrower->{debarred} eq "9999-12-31") {
$messages->{'ForeverDebarred'} = $borrower->{'debarred'};
} elsif ( $issue->date_due and $patron->debarred ) {
if ( $patron->debarred eq "9999-12-31") {
$messages->{'ForeverDebarred'} = $patron->debarred;
} else {
my $borrower_debar_dt = dt_from_string( $borrower->{debarred} );
my $borrower_debar_dt = dt_from_string( $patron->debarred );
$borrower_debar_dt->truncate(to => 'day');
my $today_dt = $today->clone()->truncate(to => 'day');
if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) {
$messages->{'PrevDebarred'} = $borrower->{'debarred'};
$messages->{'PrevDebarred'} = $patron->debarred;
}
}
}
@ -2054,29 +2055,31 @@ sub AddReturn {
ccode => $item->{ ccode }
});
# Send a check-in slip. # NOTE: borrower may be undef. probably shouldn't try to send messages then.
my $circulation_alert = 'C4::ItemCirculationAlertPreference';
my %conditions = (
branchcode => $branch,
categorycode => $borrower->{categorycode},
item_type => $item->{itype},
notification => 'CHECKIN',
);
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
SendCirculationAlert({
type => 'CHECKIN',
item => $item,
borrower => $borrower,
branch => $branch,
});
}
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
if C4::Context->preference("ReturnLog");
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then.
if ( $patron ) {
my $circulation_alert = 'C4::ItemCirculationAlertPreference';
my %conditions = (
branchcode => $branch,
categorycode => $patron->categorycode,
item_type => $item->{itype},
notification => 'CHECKIN',
);
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
SendCirculationAlert({
type => 'CHECKIN',
item => $item,
borrower => $patron->unblessed,
branch => $branch,
});
}
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
if C4::Context->preference("ReturnLog");
}
# Remove any OVERDUES related debarment if the borrower has no overdues
if ( $borrowernumber
&& $borrower->{'debarred'}
&& $patron->debarred
&& C4::Context->preference('AutoRemoveOverduesRestrictions')
&& !Koha::Patrons->find( $borrowernumber )->has_overdues
&& @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
@ -2099,7 +2102,7 @@ sub AddReturn {
}
}
return ( $doreturn, $messages, $issue, $borrower );
return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ));
}
=head2 MarkIssueReturned
@ -2136,7 +2139,7 @@ sub MarkIssueReturned {
# Note that a warning should appear on the about page (System information tab).
$anonymouspatron = C4::Context->preference('AnonymousPatron');
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."
unless C4::Members::GetMember( borrowernumber => $anonymouspatron );
unless Koha::Patrons->find( $anonymouspatron );
}
my $database = Koha::Database->new();
my $schema = $database->schema;
@ -2619,7 +2622,7 @@ sub CanBookBeRenewed {
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout;
$borrowernumber ||= $issue->borrowernumber;
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
my $patron = Koha::Patrons->find( $borrowernumber )
or return;
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber);
@ -2673,7 +2676,7 @@ sub CanBookBeRenewed {
my $item = GetItem($i);
next if IsItemOnHoldAndFound($i);
for my $b (@borrowernumbers) {
my $borr = $borrowers{$b}//= C4::Members::GetMember(borrowernumber => $b);
my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed;
next unless IsAvailableForItemLevelRequest($item, $borr);
next unless CanItemBeReserved($b,$i);
@ -2691,9 +2694,9 @@ sub CanBookBeRenewed {
return ( 1, undef ) if $override_limit;
my $branchcode = _GetCircControlBranch( $item, $borrower );
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed );
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
{ categorycode => $borrower->{categorycode},
{ categorycode => $patron->categorycode,
itemtype => $item->{itype},
branchcode => $branchcode
}
@ -2704,7 +2707,7 @@ sub CanBookBeRenewed {
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
my $patron = Koha::Patrons->find($borrowernumber);
$patron = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful?
my $restricted = $patron->is_debarred;
my $hasoverdues = $patron->has_overdues;
@ -2738,7 +2741,7 @@ sub CanBookBeRenewed {
if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($patron->borrowernumber);
if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
return ( 0, "auto_too_much_oweing" );
}
@ -2831,10 +2834,11 @@ sub AddRenewal {
return;
}
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return;
my $patron = Koha::Patrons->find( $borrowernumber ) or return; # FIXME Should do more than just return
my $patron_unblessed = $patron->unblessed;
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) {
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $borrower } );
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } );
}
_FixOverduesOnReturn( $borrowernumber, $itemnumber );
@ -2847,7 +2851,7 @@ sub AddRenewal {
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
dt_from_string( $issue->date_due, 'sql' ) :
DateTime->now( time_zone => C4::Context->tz());
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $borrower), $borrower, 'is a renewal');
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal');
}
# Update the issues record to have the new due date, and a new count
@ -2883,11 +2887,10 @@ sub AddRenewal {
# Send a renewal slip according to checkout alert preferencei
if ( C4::Context->preference('RenewalSendNotice') eq '1' ) {
$borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $circulation_alert = 'C4::ItemCirculationAlertPreference';
my %conditions = (
branchcode => $branch,
categorycode => $borrower->{categorycode},
categorycode => $patron->categorycode,
item_type => $item->{itype},
notification => 'CHECKOUT',
);
@ -2896,7 +2899,7 @@ sub AddRenewal {
{
type => 'RENEWAL',
item => $item,
borrower => $borrower,
borrower => $patron->unblessed,
branch => $branch,
}
);
@ -2904,10 +2907,9 @@ sub AddRenewal {
}
# Remove any OVERDUES related debarment if the borrower has no overdues
$borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
if ( $borrowernumber
&& $borrower->{'debarred'}
&& !Koha::Patrons->find( $borrowernumber )->has_overdues
if ( $patron
&& $patron->is_debarred
&& ! $patron->has_overdues
&& @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) }
) {
DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
@ -2939,8 +2941,10 @@ sub GetRenewCount {
my $renewsallowed = 0;
my $renewsleft = 0;
my $borrower = C4::Members::GetMember( borrowernumber => $bornum);
my $item = GetItem($itemno);
my $patron = Koha::Patrons->find( $bornum );
my $item = GetItem($itemno);
return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed
# Look in the issues table for this item, lent to this borrower,
# and not yet returned.
@ -2955,16 +2959,16 @@ sub GetRenewCount {
my $data = $sth->fetchrow_hashref;
$renewcount = $data->{'renewals'} if $data->{'renewals'};
# $item and $borrower should be calculated
my $branchcode = _GetCircControlBranch($item, $borrower);
my $branchcode = _GetCircControlBranch($item, $patron->unblessed);
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
{ categorycode => $borrower->{categorycode},
{ categorycode => $patron->categorycode,
itemtype => $item->{itype},
branchcode => $branchcode
}
);
$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
$renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : 0;
$renewsleft = $renewsallowed - $renewcount;
if($renewsleft < 0){ $renewsleft = 0; }
return ( $renewcount, $renewsallowed, $renewsleft );
@ -2998,12 +3002,12 @@ sub GetSoonestRenewDate {
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
$borrowernumber ||= $itemissue->borrowernumber;
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
my $patron = Koha::Patrons->find( $borrowernumber )
or return;
my $branchcode = _GetCircControlBranch( $item, $borrower );
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed );
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
{ categorycode => $borrower->{categorycode},
{ categorycode => $patron->categorycode,
itemtype => $item->{itype},
branchcode => $branchcode
}
@ -3057,12 +3061,12 @@ sub GetLatestAutoRenewDate {
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
$borrowernumber ||= $itemissue->borrowernumber;
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
my $patron = Koha::Patrons->find( $borrowernumber )
or return;
my $branchcode = _GetCircControlBranch( $item, $borrower );
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed );
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
{ categorycode => $borrower->{categorycode},
{ categorycode => $patron->categorycode,
itemtype => $item->{itype},
branchcode => $branchcode
}
@ -3606,12 +3610,12 @@ sub ReturnLostItem{
my ( $borrowernumber, $itemnum ) = @_;
MarkIssueReturned( $borrowernumber, $itemnum );
my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $item = C4::Items::GetItem( $itemnum );
my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{};
my @datearr = localtime(time);
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber;
ModItem({ paidfor => $old_note."Paid for by $bor $date" }, undef, $itemnum);
}
@ -3630,7 +3634,7 @@ sub LostItem{
# If a borrower lost the item, add a replacement cost to the their record
if ( my $borrowernumber = $issues->{borrowernumber} ){
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
if (C4::Context->preference('WhenLostForgiveFine')){
my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, 1, 0); # 1, 0 = exemptfine, no-dropbox
@ -3642,7 +3646,7 @@ sub LostItem{
#warn " $issues->{'borrowernumber'} / $itemnumber ";
}
MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$borrower->{'privacy'}) if $mark_returned;
MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$patron->privacy) if $mark_returned;
}
}
@ -3727,9 +3731,9 @@ sub ProcessOfflineReturn {
sub ProcessOfflineIssue {
my $operation = shift;
my $borrower = C4::Members::GetMember( cardnumber => $operation->{cardnumber} );
my $patron = Koha::Patrons->find( { cardnumber => $operation->{cardnumber} } );
if ( $borrower->{borrowernumber} ) {
if ( $patron ) {
my $item = Koha::Items->find({ barcode => $operation->{barcode} });
unless ($item) {
return "Barcode not found.";
@ -3737,7 +3741,7 @@ sub ProcessOfflineIssue {
my $itemnumber = $item->itemnumber;
my $issue = GetOpenIssue( $itemnumber );
if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned
if ( $issue and ( $issue->{borrowernumber} ne $patron->borrowernumber ) ) { # Item already issued to another patron mark it returned
MarkIssueReturned(
$issue->{borrowernumber},
$itemnumber,
@ -3746,7 +3750,7 @@ sub ProcessOfflineIssue {
);
}
AddIssue(
$borrower,
$patron->unblessed,
$operation->{'barcode'},
undef,
1,

View File

@ -29,6 +29,7 @@ use C4::Circulation;
use C4::Members;
use C4::Biblio;
use Koha::DateUtils;
use Koha::Patrons;
use List::Util qw(shuffle);
use List::MoreUtils qw(any);
@ -677,11 +678,11 @@ sub CreatePicklistFromItemMap {
my $barcode = $item->{barcode};
my $itemcallnumber = $item->{itemcallnumber};
my $borrower = GetMember('borrowernumber'=>$borrowernumber);
my $cardnumber = $borrower->{'cardnumber'};
my $surname = $borrower->{'surname'};
my $firstname = $borrower->{'firstname'};
my $phone = $borrower->{'phone'};
my $patron = Koha::Patrons->find( $borrowernumber );
my $cardnumber = $patron->cardnumber;
my $surname = $patron->surname;
my $firstname = $patron->firstname;
my $phone = $patron->phone;
my $bib = GetBiblioData($biblionumber);
my $title = $bib->{title};

View File

@ -306,18 +306,12 @@ Parameters:
sub LookupPatron {
my ($cgi) = @_;
# Get the borrower...
my $borrower = GetMember($cgi->param('id_type') => $cgi->param('id'));
if ( not $borrower->{'borrowernumber'} ) {
my $patrons = Koha::Patrons->search( { $cgi->param('id_type') => $cgi->param('id') } );
unless ( $patrons->count ) {
return { message => 'PatronNotFound' };
}
# Build the hashref
my $patron->{'id'} = $borrower->{'borrowernumber'};
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
# ...and return his ID
return $patron;
return { id => $patrons->next->borrowernumber };
}
=head2 AuthenticatePatron
@ -341,9 +335,8 @@ sub AuthenticatePatron {
my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password );
if ( $status ) {
# Get the borrower
my $borrower = GetMember( cardnumber => $cardnumber );
my $patron->{'id'} = $borrower->{'borrowernumber'};
return $patron;
my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
return { id => $patron->borrowernumber };
}
else {
return { code => 'PatronNotFound' };
@ -376,11 +369,11 @@ sub GetPatronInfo {
# Get Member details
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
# Cleaning the borrower hashref
my $borrower = $patron->unblessed;
my $flags = C4::Members::patronflags( $borrower );
$borrower->{'charges'} = $flags->{'CHARGES'}->{'amount'};
my $library = Koha::Libraries->find( $borrower->{branchcode} );
@ -483,14 +476,14 @@ sub GetPatronStatus {
# Get Member details
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
# Return the results
return {
type => $$borrower{categorycode},
type => $patron->categorycode,
status => 0, # TODO
expiry => $$borrower{dateexpiry},
expiry => $patron->dateexpiry,
};
}
@ -513,11 +506,10 @@ sub GetServices {
# Get the member, or return an error code if not found
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
my $borrower = $patron->unblessed;
# Get the item, or return an error code if not found
my $itemnumber = $cgi->param('item_id');
my $item = GetItem( $itemnumber );
@ -587,8 +579,8 @@ sub RenewLoan {
# Get borrower infos or return an error code
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
# Get the item, or return an error code
my $itemnumber = $cgi->param('item_id');
@ -637,8 +629,8 @@ sub HoldTitle {
# Get the borrower or return an error code
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
# Get the biblio record, or return an error code
my $biblionumber = $cgi->param('bib_id');
@ -657,7 +649,7 @@ sub HoldTitle {
$branch = $cgi->param('pickup_location');
return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
} else { # if the request provide no branch, use the borrower's branch
$branch = $$borrower{branchcode};
$branch = $patron->branchcode;
}
# Add the reserve
@ -705,8 +697,8 @@ sub HoldItem {
# Get the borrower or return an error code
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
# Get the biblio or return an error code
my $biblionumber = $cgi->param('bib_id');
@ -734,7 +726,7 @@ sub HoldItem {
$branch = $cgi->param('pickup_location');
return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
} else { # if the request provide no branch, use the borrower's branch
$branch = $$borrower{branchcode};
$branch = $patron->branchcode;
}
# Add the reserve
@ -772,8 +764,8 @@ sub CancelHold {
# Get the borrower or return an error code
my $borrowernumber = $cgi->param('patron_id');
my $borrower = GetMember( borrowernumber => $borrowernumber );
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
my $patron = Koha::Patrons->find( $borrowernumber );
return { code => 'PatronNotFound' } unless $patron;
# Get the reserve or return an error code
my $reserve_id = $cgi->param('item_id');

View File

@ -37,6 +37,7 @@ use Koha::SMS::Providers;
use Koha::Email;
use Koha::DateUtils qw( format_sqldatetime dt_from_string );
use Koha::Patrons;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -416,8 +417,9 @@ sub SendAlerts {
# find the list of borrowers to alert
my $alerts = getalert( '', 'issue', $subscriptionid );
foreach (@$alerts) {
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'});
my $email = $borinfo->{email} or next;
my $patron = Koha::Patrons->find( $_->{borrowernumber} );
next unless $patron; # Just in case
my $email = $patron->email or next;
# warn "sending issues...";
my $userenv = C4::Context->userenv;
@ -430,7 +432,7 @@ sub SendAlerts {
'branches' => $_->{branchcode},
'biblio' => $biblionumber,
'biblioitems' => $biblionumber,
'borrowers' => $borinfo,
'borrowers' => $patron->unblessed,
'subscription' => $subscriptionid,
'serial' => $externalid,
},
@ -1048,15 +1050,15 @@ sub SendQueuedMessages {
}
elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) {
if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) {
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
my $sms_provider = Koha::SMS::Providers->find( $member->{'sms_provider_id'} );
my $patron = Koha::Patrons->find( $message->{borrowernumber} );
my $sms_provider = Koha::SMS::Providers->find( $patron->sms_provider_id );
unless ( $sms_provider ) {
warn sprintf( "Patron %s has no sms provider id set!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
_set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
next MESSAGE;
}
$message->{to_address} ||= $member->{'smsalertnumber'};
unless ( $message->{to_address} && $member->{'smsalertnumber'} ) {
$message->{to_address} ||= $patron->smsalertnumber;
unless ( $message->{to_address} && $patron->smsalertnumber ) {
_set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
next MESSAGE;
@ -1302,10 +1304,10 @@ sub _send_message_by_email {
my $message = shift or return;
my ($username, $password, $method) = @_;
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
my $patron = Koha::Patrons->find( $message->{borrowernumber} );
my $to_address = $message->{'to_address'};
unless ($to_address) {
unless ($member) {
unless ($patron) {
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
_set_message_status( { message_id => $message->{'message_id'},
status => 'failed' } );
@ -1330,8 +1332,8 @@ sub _send_message_by_email {
my $branch_email = undef;
my $branch_replyto = undef;
my $branch_returnpath = undef;
if ($member) {
my $library = Koha::Libraries->find( $member->{branchcode} );
if ($patron) {
my $library = $patron->library;
$branch_email = $library->branchemail;
$branch_replyto = $library->branchreplyto;
$branch_returnpath = $library->branchreturnpath;
@ -1407,9 +1409,9 @@ sub _is_duplicate {
sub _send_message_by_sms {
my $message = shift or return;
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
my $patron = Koha::Patrons->find( $message->{borrowernumber} );
unless ( $member->{smsalertnumber} ) {
unless ( $patron and $patron->smsalertnumber ) {
_set_message_status( { message_id => $message->{'message_id'},
status => 'failed' } );
return;
@ -1421,7 +1423,7 @@ sub _send_message_by_sms {
return;
}
my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'},
my $success = C4::SMS->send_sms( { destination => $patron->smsalertnumber,
message => $message->{'content'},
} );
_set_message_status( { message_id => $message->{'message_id'},

View File

@ -60,7 +60,6 @@ BEGIN {
@ISA = qw(Exporter);
#Get data
push @EXPORT, qw(
&GetMember
&GetPendingIssues
&GetAllIssues
@ -280,68 +279,6 @@ sub patronflags {
}
=head2 GetMember
$borrower = &GetMember(%information);
Retrieve the first patron record meeting on criteria listed in the
C<%information> hash, which should contain one or more
pairs of borrowers column names and values, e.g.,
$borrower = GetMember(borrowernumber => id);
C<&GetBorrower> returns a reference-to-hash whose keys are the fields of
the C<borrowers> table in the Koha database.
FIXME: GetMember() is used throughout the code as a lookup
on a unique key such as the borrowernumber, but this meaning is not
enforced in the routine itself.
=cut
#'
sub GetMember {
my ( %information ) = @_;
if (exists $information{borrowernumber} && !defined $information{borrowernumber}) {
#passing mysql's kohaadmin?? Makes no sense as a query
return;
}
my $dbh = C4::Context->dbh;
my $select =
q{SELECT borrowers.*, categories.category_type, categories.description
FROM borrowers
LEFT JOIN categories on borrowers.categorycode=categories.categorycode WHERE };
my $more_p = 0;
my @values = ();
for (keys %information ) {
if ($more_p) {
$select .= ' AND ';
}
else {
$more_p++;
}
if (defined $information{$_}) {
$select .= "$_ = ?";
push @values, $information{$_};
}
else {
$select .= "$_ IS NULL";
}
}
$debug && warn $select, " ",values %information;
my $sth = $dbh->prepare("$select");
$sth->execute(@values);
my $data = $sth->fetchall_arrayref({});
#FIXME interface to this routine now allows generation of a result set
#so whole array should be returned but bowhere in the current code expects this
if (@{$data} ) {
return $data->[0];
}
return;
}
=head2 ModMember
my $success = ModMember(borrowernumber => $borrowernumber,

View File

@ -226,16 +226,16 @@ sub AddReserve {
# Send e-mail to librarian if syspref is active
if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
my $library = Koha::Libraries->find($borrower->{branchcode})->unblessed;
my $patron = Koha::Patrons->find( $borrowernumber );
my $library = $patron->library;
if ( my $letter = C4::Letters::GetPreparedLetter (
module => 'reserves',
letter_code => 'HOLDPLACED',
branchcode => $branch,
lang => $borrower->{lang},
lang => $patron->lang,
tables => {
'branches' => $library,
'borrowers' => $borrower,
'branches' => $library->unblessed,
'borrowers' => $patron->unblessed,
'biblio' => $biblionumber,
'biblioitems' => $biblionumber,
'items' => $checkitem,
@ -243,7 +243,7 @@ sub AddReserve {
},
) ) {
my $admin_email_address = $library->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress');
C4::Letters::EnqueueLetter(
{ letter => $letter,
@ -331,7 +331,8 @@ sub CanItemBeReserved {
# item->{itype} will come for biblioitems if necessery
my $item = GetItem($itemnumber);
my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} );
my $borrower = C4::Members::GetMember( 'borrowernumber' => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $borrower = $patron->unblessed;
# If an item is damaged and we don't allow holds on damaged items, we can stop right here
return 'damaged'
@ -807,12 +808,12 @@ sub CheckReserves {
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
return ( "Waiting", $res, \@reserves ); # Found it
} else {
my $borrowerinfo;
my $patron;
my $iteminfo;
my $local_hold_match;
if ($LocalHoldsPriority) {
$borrowerinfo = C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} );
$patron = Koha::Patrons->find( $res->{borrowernumber} );
$iteminfo = C4::Items::GetItem($itemnumber);
my $local_holds_priority_item_branchcode =
@ -821,7 +822,7 @@ sub CheckReserves {
( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' )
? $res->{branchcode}
: ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' )
? $borrowerinfo->{branchcode}
? $patron->branchcode
: undef;
$local_hold_match =
$local_holds_priority_item_branchcode eq
@ -832,11 +833,11 @@ sub CheckReserves {
if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) {
$iteminfo ||= C4::Items::GetItem($itemnumber);
next if $res->{itemtype} && $res->{itemtype} ne _get_itype( $iteminfo );
$borrowerinfo ||= C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} );
my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo );
$patron ||= Koha::Patrons->find( $res->{borrowernumber} );
my $branch = GetReservesControlBranch( $iteminfo, $patron->unblessed );
my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
next if ($branchitemrule->{'holdallowed'} == 0);
next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'}));
next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $iteminfo->{ $branchitemrule->{hold_fulfillment_policy} }) );
$priority = $res->{'priority'};
$highest = $res;
@ -1808,7 +1809,7 @@ sub _koha_notify_reserve {
my $hold = Koha::Holds->find($reserve_id);
my $borrowernumber = $hold->borrowernumber;
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
# Try to get the borrower's email address
my $to_address = C4::Members::GetNoticeEmailAddress($borrowernumber);
@ -1825,10 +1826,10 @@ sub _koha_notify_reserve {
my %letter_params = (
module => 'reserves',
branchcode => $hold->branchcode,
lang => $borrower->{lang},
lang => $patron->lang,
tables => {
'branches' => $library,
'borrowers' => $borrower,
'borrowers' => $patron->unblessed,
'biblio' => $hold->biblionumber,
'biblioitems' => $hold->biblionumber,
'reserves' => $hold->unblessed,
@ -1859,7 +1860,7 @@ sub _koha_notify_reserve {
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) {
next if (
( $mtt eq 'email' and not $to_address ) # No email address
or ( $mtt eq 'sms' and not $borrower->{smsalertnumber} ) # No SMS number
or ( $mtt eq 'sms' and not $patron->smsalertnumber ) # No SMS number
or ( $mtt eq 'phone' and C4::Context->preference('TalkingTechItivaPhoneNotification') ) # Notice is handled by TalkingTech_itiva_outbound.pl
);

View File

@ -93,9 +93,9 @@ sub new {
my $issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
if ($issue) {
$self->{due_date} = dt_from_string( $issue->date_due, 'sql' )->truncate( to => 'minute' );
my $patron = Koha::Patrons->find( $issue->borrowernumber );
$self->{patron} = $patron->cardnumber;
}
my $borrower = $issue ? GetMember( borrowernumber => $issue->borrowernumber ) : {};
$self->{patron} = $borrower->{'cardnumber'};
my $biblio = Koha::Biblios->find( $self->{biblionumber} );
my $holds = $biblio->current_holds->unblessed;
$self->{hold_queue} = $holds;
@ -175,29 +175,27 @@ sub hold_patron_name {
return $output;
}
my $holder = GetMember(borrowernumber=>$borrowernumber);
my $holder = Koha::Patrons->find( $borrowernumber );
unless ($holder) {
syslog("LOG_ERR", "While checking hold, GetMember failed for borrowernumber '$borrowernumber'");
syslog("LOG_ERR", "While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'");
return;
}
my $email = $holder->{email} || '';
my $phone = $holder->{phone} || '';
my $email = $holder->email || '';
my $phone = $holder->phone || '';
my $extra = ($email and $phone) ? " ($email, $phone)" : # both populated, employ comma
($email or $phone) ? " ($email$phone)" : # only 1 populated, we don't care which: no comma
"" ; # neither populated, empty string
my $name = $holder->{firstname} ? $holder->{firstname} . ' ' : '';
$name .= $holder->{surname} . $extra;
my $name = $holder->firstname ? $holder->firstname . ' ' : '';
$name .= $holder->surname . $extra;
return $name;
}
sub hold_patron_bcode {
my $self = shift;
my $borrowernumber = (@_ ? shift: $self->hold_patron_id()) or return;
my $holder = GetMember(borrowernumber => $borrowernumber);
if ($holder) {
if ($holder->{cardnumber}) {
return $holder->{cardnumber};
}
my $holder = Koha::Patrons->find( $borrowernumber );
if ($holder and $holder->cardnumber ) {
return $holder->cardnumber;
}
return;
}
@ -359,8 +357,8 @@ sub available {
sub _barcode_to_borrowernumber {
my $known = shift;
return unless defined $known;
my $member = GetMember(cardnumber=>$known) or return;
return $member->{borrowernumber};
my $patron = Koha::Patrons->find( { cardnumber => $known } ) or return;
return $patron->borrowernumber
}
sub barcode_is_borrowernumber { # because hold_queue only has borrowernumber...
my $self = shift;

View File

@ -32,14 +32,14 @@ sub new {
my ($class, $patron_id) = @_;
my $type = ref($class) || $class;
my $self;
$kp = GetMember(cardnumber=>$patron_id) || GetMember(userid=>$patron_id);
$debug and warn "new Patron (GetMember): " . Dumper($kp);
unless (defined $kp) {
$kp = Koha::Patrons->find( { cardnumber => $patron_id } )
or Koha::Patrons->find( { userid => $patron_id } );
$debug and warn "new Patron: " . Dumper($kp->unblessed) if $kp;
unless ($kp) {
syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
return;
}
$kp = GetMember( borrowernumber => $kp->{borrowernumber});
$debug and warn "new Patron (GetMember): " . Dumper($kp);
$kp = $kp->unblessed;
my $pw = $kp->{password};
my $flags = C4::Members::patronflags( $kp );
my $debarred = defined($flags->{DBARRED});

View File

@ -8,7 +8,7 @@ use Modern::Perl;
use C4::SIP::ILS::Transaction;
use C4::Reserves; # AddReserve
use C4::Members; # GetMember
use Koha::Patrons;
use parent qw(C4::SIP::ILS::Transaction);
use Koha::Items;
@ -41,8 +41,8 @@ sub do_hold {
$self->ok(0);
return $self;
}
my $borrower = GetMember( 'cardnumber' => $self->{patron}->id );
unless ($borrower) {
my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
unless ($patron) {
$self->screen_msg( 'No borrower matches cardnumber "' . $self->{patron}->id . '".' );
$self->ok(0);
return $self;
@ -59,7 +59,7 @@ sub do_hold {
$self->ok(0);
return $self;
}
AddReserve( $branch, $borrower->{borrowernumber}, $item->biblionumber );
AddReserve( $branch, $patron->borrowernumber, $item->biblionumber );
# unfortunately no meaningful return value
$self->ok(1);
@ -73,8 +73,8 @@ sub drop_hold {
$self->ok(0);
return $self;
}
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
unless ($patron) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);
return $self;
@ -84,7 +84,7 @@ sub drop_hold {
CancelReserve({
biblionumber => $item->biblionumber,
itemnumber => $self->{item}->id,
borrowernumber => $borrower->{borrowernumber}
borrowernumber => $patron->borrowernumber
});
$self->ok(1);
@ -98,8 +98,8 @@ sub change_hold {
$self->ok(0);
return $self;
}
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
unless ($patron) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);
return $self;
@ -116,7 +116,7 @@ sub change_hold {
$self->ok(0);
return $self;
}
ModReserve({ biblionumber => $item->biblionumber, borrowernumber => $borrower->{borrowernumber}, branchcode => $branch });
ModReserve({ biblionumber => $item->biblionumber, borrowernumber => $patron->borrowernumber, branchcode => $branch });
$self->ok(1);
return $self;

View File

@ -8,7 +8,7 @@ use warnings;
use strict;
use C4::Circulation;
use C4::Members;
use Koha::Patrons;
use Koha::DateUtils;
use parent qw(C4::SIP::ILS::Transaction);
@ -60,8 +60,8 @@ sub do_renew_for {
sub do_renew {
my $self = shift;
my $borrower = GetMember( cardnumber => $self->{patron}->id );
return $self->do_renew_for($borrower);
my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
return $self->do_renew_for($patron->unblessed);
}
1;

View File

@ -10,7 +10,7 @@ use Sys::Syslog qw(syslog);
use C4::SIP::ILS::Item;
use C4::Members qw( GetMember );
use Koha::Patrons;
use parent qw(C4::SIP::ILS::Transaction::Renew);
@ -34,7 +34,7 @@ sub new {
sub do_renew_all {
my $self = shift;
my $patron = $self->{patron}; # SIP's patron
my $borrower = GetMember( cardnumber => $patron->id ); # Koha's patron
my $borrower = Koha::Patrons->find( { cardnumber => $patron->id } )->unblessed; # Koha's patron
my $all_ok = 1;
$self->{renewed} = [];
$self->{unrenewed} = [];

View File

@ -38,6 +38,7 @@ use C4::Members;
use C4::Debug;
use C4::Suggestions;
use Koha::Acquisition::Currencies;
use Koha::Patrons;
my $query = CGI->new;
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
@ -70,11 +71,12 @@ my @budget_loop;
foreach my $budget ( @{$budget_arr} ) {
next unless (CanUserUseBudget($loggedinuser, $budget, $userflags));
my $member = GetMember( borrowernumber => $budget->{budget_owner_id} );
if ($member) {
$budget->{budget_owner_firstname} = $member->{'firstname'};
$budget->{budget_owner_surname} = $member->{'surname'};
$budget->{budget_owner_borrowernumber} = $member->{'borrowernumber'};
my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
if ( $patron ) {
# FIXME should pass the entire object into budget_owner
$budget->{budget_owner_firstname} = $patron->firstname;
$budget->{budget_owner_surname} = $patron->surname;
$budget->{budget_owner_borrowernumber} = $patron->borrowernumber;
}
if ( !defined $budget->{budget_amount} ) {

View File

@ -47,6 +47,7 @@ use Koha::Libraries;
use Koha::Acquisition::Currencies;
use Koha::Acquisition::Order;
use Koha::Acquisition::Booksellers;
use Koha::Patrons;
my $input = new CGI;
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({
@ -310,14 +311,14 @@ if ($op eq ""){
}
} else {
# 3rd add order
my $patron = C4::Members::GetMember( borrowernumber => $loggedinuser );
my $patron = Koha::Patrons->find( $loggedinuser );
# get quantity in the MARC record (1 if none)
my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
my %orderinfo = (
biblionumber => $biblionumber,
basketno => $cgiparams->{'basketno'},
quantity => $c_quantity,
branchcode => $patron->{branchcode},
branchcode => $patron->branchcode,
budget_id => $c_budget_id,
uncertainprice => 1,
sort1 => $c_sort1,
@ -417,15 +418,14 @@ if ($op eq ""){
my $budgets = GetBudgets();
my $budget_id = @$budgets[0]->{'budget_id'};
# build bookfund list
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
my ( $flags, $homebranch ) = ( $borrower->{'flags'}, $borrower->{'branchcode'} );
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
my $budget = GetBudget($budget_id);
# build budget list
my $budget_loop = [];
my $budgets_hierarchy = GetBudgetHierarchy;
foreach my $r ( @{$budgets_hierarchy} ) {
next unless (CanUserUseBudget($borrower, $r, $userflags));
next unless (CanUserUseBudget($patron, $r, $userflags));
if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
next;
}

View File

@ -30,7 +30,6 @@ use C4::Budgets;
use C4::Contract;
use C4::Debug;
use C4::Biblio;
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket
use C4::Items;
use C4::Suggestions;
use Koha::Biblios;
@ -41,6 +40,7 @@ use Date::Calc qw/Add_Delta_Days/;
use Koha::Database;
use Koha::EDI qw( create_edi_order get_edifact_ean );
use Koha::CsvProfiles;
use Koha::Patrons;
=head1 NAME
@ -291,8 +291,8 @@ if ( $op eq 'list' ) {
#if the basket is closed,and the user has the permission to edit basketgroups, display a list of basketgroups
my ($basketgroup, $basketgroups);
my $staffuser = GetMember(borrowernumber => $loggedinuser);
if ($basket->{closedate} && haspermission($staffuser->{userid}, { acquisition => 'group_manage'} )) {
my $patron = Koha::Patrons->find($loggedinuser);
if ($basket->{closedate} && haspermission($patron->userid, { acquisition => 'group_manage'} )) {
$basketgroups = GetBasketgroups($basket->{booksellerid});
for my $bg ( @{$basketgroups} ) {
if ($basket->{basketgroupid} && $basket->{basketgroupid} == $bg->{id}){
@ -321,8 +321,9 @@ if ( $op eq 'list' ) {
my @basketusers_ids = GetBasketUsers($basketno);
my @basketusers;
foreach my $basketuser_id (@basketusers_ids) {
my $basketuser = GetMember(borrowernumber => $basketuser_id);
push @basketusers, $basketuser if $basketuser;
# FIXME Could be improved with a search -in
my $basket_patron = Koha::Patrons->find( $basketuser_id );
push @basketusers, $basket_patron if $basket_patron;
}
my $active_currency = Koha::Acquisition::Currencies->get_active;
@ -375,7 +376,6 @@ if ( $op eq 'list' ) {
if ($basket->{basketgroupid}){
$basketgroup = GetBasketgroup($basket->{basketgroupid});
}
my $borrower= GetMember('borrowernumber' => $loggedinuser);
my $budgets = GetBudgetHierarchy;
my $has_budgets = 0;
foreach my $r (@{$budgets}) {

View File

@ -52,11 +52,11 @@ use C4::Output;
use CGI qw ( -utf8 );
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
use C4::Members qw/GetMember/;
use Koha::EDI qw/create_edi_order get_edifact_ean/;
use Koha::Acquisition::Booksellers;
use Koha::ItemTypes;
use Koha::Patrons;
our $input=new CGI;
@ -273,9 +273,9 @@ if ( $op eq "add" ) {
$template->param( closedbg => 0);
}
# determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) );
$billingplace = $billingplace || $borrower->{'branchcode'};
$deliveryplace = $deliveryplace || $borrower->{'branchcode'};
my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
$billingplace = $billingplace || $patron->branchcode;
$deliveryplace = $deliveryplace || $patron->branchcode;
$template->param( billingplace => $billingplace );
$template->param( deliveryplace => $deliveryplace );

View File

@ -60,10 +60,10 @@ use C4::Output;
use CGI qw ( -utf8 );
use C4::Acquisition qw/ GetBasketsInfosByBookseller CanUserManageBasket /;
use C4::Members qw/GetMember/;
use C4::Context;
use Koha::Acquisition::Booksellers;
use Koha::Patrons;
my $query = CGI->new;
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
@ -99,8 +99,10 @@ if ( $supplier_count == 1 ) {
}
my $uid;
# FIXME This script should only be accessed by a valid logged in patron
if ($loggedinuser) {
$uid = GetMember( borrowernumber => $loggedinuser )->{userid};
# FIXME Should not be needed, logged in patron should be cached
$uid = Koha::Patrons->find( $loggedinuser )->userid;
}
my $userenv = C4::Context::userenv;
@ -130,13 +132,13 @@ for my $vendor (@suppliers) {
for my $basket ( @{$baskets} ) {
if (CanUserManageBasket($loggedinuser, $basket, $userflags)) {
my $member = GetMember( borrowernumber => $basket->{authorisedby} );
my $patron = Koha::Patrons->find( $basket->{authorisedby} );
foreach (qw(total_items total_biblios expected_items)) {
$basket->{$_} ||= 0;
}
if($member) {
$basket->{authorisedby_firstname} = $member->{firstname};
$basket->{authorisedby_surname} = $member->{surname};
if ( $patron ) {
$basket->{authorisedby_firstname} = $patron->firstname;
$basket->{authorisedby_surname} = $patron->surname;
}
if ($basket->{basketgroupid}) {
my $basketgroup = C4::Acquisition::GetBasketgroup($basket->{basketgroupid});

View File

@ -64,13 +64,13 @@ use C4::Biblio;
use C4::Auth;
use C4::Output;
use C4::Koha;
use C4::Members qw/ GetMember /;
use C4::Budgets qw/ GetBudgetHierarchy /;
use Koha::Acquisition::Booksellers;
use Koha::SearchEngine;
use Koha::SearchEngine::Search;
use Koha::SearchEngine::QueryBuilder;
use Koha::Patrons;
my $input = new CGI;
@ -133,8 +133,8 @@ foreach my $result ( @{$marcresults} ) {
}
my $borrower= GetMember('borrowernumber' => $loggedinuser);
my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber});
my $patron = Koha::Patrons->find( $loggedinuser );
my $budgets = GetBudgetHierarchy(q{},$patron->branchcode,$patron->borrowernumber);
my $has_budgets = 0;
foreach my $r (@{$budgets}) {
if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {

View File

@ -90,6 +90,7 @@ use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
use Koha::Acquisition::Booksellers;
use Koha::Acquisition::Currencies;
use Koha::ItemTypes;
use Koha::Patrons;
our $input = new CGI;
my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR!
@ -198,8 +199,9 @@ else { #modify order
@order_user_ids = GetOrderUsers($ordernumber);
foreach my $order_user_id (@order_user_ids) {
my $order_user = GetMember(borrowernumber => $order_user_id);
push @order_users, $order_user if $order_user;
# FIXME Could be improved with search -in
my $order_patron = Koha::Patrons->find( $order_user_id );
push @order_users, $order_patron if $order_patron;
}
}
@ -210,15 +212,14 @@ my @currencies = Koha::Acquisition::Currencies->search;
my $active_currency = Koha::Acquisition::Currencies->get_active;
# build bookfund list
my $borrower= GetMember('borrowernumber' => $loggedinuser);
my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
my $budget = GetBudget($budget_id);
# build budget list
my $budget_loop = [];
my $budgets = GetBudgetHierarchy;
foreach my $r (@{$budgets}) {
next unless (CanUserUseBudget($borrower, $r, $userflags));
next unless (CanUserUseBudget($patron, $r, $userflags));
if (!defined $r->{budget_amount} || $r->{budget_amount} <0) {
next;
}

View File

@ -76,6 +76,7 @@ use C4::Koha;
use Koha::Acquisition::Booksellers;
use Koha::DateUtils qw( dt_from_string );
use Koha::ItemTypes;
use Koha::Patrons;
my $input = new CGI;
@ -180,7 +181,7 @@ if( defined $order->{tax_rate_on_receiving} ) {
my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber});
my $authorisedby = $order->{authorisedby};
my $member = GetMember( borrowernumber => $authorisedby );
my $authorised_patron = Koha::Patrons->find( $authorisedby );
my $budget = GetBudget( $order->{budget_id} );
@ -213,8 +214,8 @@ $template->param(
ecost => $ecost,
unitprice => $unitprice,
tax_rate => $tax_rate,
memberfirstname => $member->{firstname} || "",
membersurname => $member->{surname} || "",
memberfirstname => $authorised_patron->firstname || "",
membersurname => $authorised_patron->surname || "",
invoiceid => $invoice->{invoiceid},
invoice => $invoice->{invoicenumber},
datereceived => $datereceived,
@ -226,7 +227,7 @@ $template->param(
gst_values => \@gst_values,
);
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
my @budget_loop;
my $periods = GetBudgetPeriods( );
foreach my $period (@$periods) {
@ -237,7 +238,7 @@ foreach my $period (@$periods) {
my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} );
my @funds;
foreach my $r ( @{$budget_hierarchy} ) {
next unless ( CanUserUseBudget( $borrower, $r, $userflags ) );
next unless ( CanUserUseBudget( $patron, $r, $userflags ) );
if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
next;
}

View File

@ -26,7 +26,6 @@ use C4::Auth;
use C4::Output;
use C4::Context;
use C4::Acquisition;
use C4::Members;
use Koha::Acquisition::Booksellers;
my $input = new CGI;
@ -89,8 +88,8 @@ if( $basketno && $ordernumber) {
for( my $i = 0 ; $i < $basketscount ; $i++ ){
my %line;
%line = %{ $baskets->[$i] };
my $createdby = GetMember(borrowernumber => $line{authorisedby});
$line{createdby} = "$createdby->{surname}, $createdby->{firstname}";
my $createdby = Koha::Patrons->find( $line{authorisedby} );
$line{createdby} = $createdby ? $createdby->surname . ', ' . $createdby->firstname : '';
push @basketsloop, \%line unless $line{closedate};
}
$template->param(

View File

@ -29,12 +29,12 @@ use C4::Auth qw/get_user_subpermissions/;
use C4::Auth;
use C4::Acquisition;
use C4::Budgets;
use C4::Members;
use C4::Context;
use C4::Output;
use C4::Koha;
use C4::Debug;
use Koha::Acquisition::Currencies;
use Koha::Patrons;
my $input = new CGI;
my $dbh = C4::Context->dbh;
@ -89,8 +89,6 @@ if ( $budget_period_id ) {
# USED FOR PERMISSION COMPARISON LATER
my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'};
my $user = C4::Members::GetMember( borrowernumber => $borrower_id );
my $user_branchcode = $user->{'branchcode'};
$template->param(
show_mine => $show_mine,
@ -117,8 +115,8 @@ if ($op eq 'add_form') {
exit;
}
$dropbox_disabled = BudgetHasChildren($budget_id);
my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
$budget->{budget_owner_name} = ( $borrower ? $borrower->{'firstname'} . ' ' . $borrower->{'surname'} : '' );
my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
$budget->{budget_owner_name} = ( $patron ? $patron->firstname . ' ' . $patron->surname : '' );
}
# build budget hierarchy
@ -155,11 +153,10 @@ if ($op eq 'add_form') {
my @budgetusers = GetBudgetUsers($budget->{budget_id});
my @budgetusers_loop;
foreach my $borrowernumber (@budgetusers) {
my $member = C4::Members::GetMember(
borrowernumber => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
push @budgetusers_loop, {
firstname => $member->{firstname},
surname => $member->{surname},
firstname => $patron->firstname, # FIXME Should pass the patron object
surname => $patron->surname,
borrowernumber => $borrowernumber
};
}

View File

@ -43,12 +43,12 @@ use CGI qw ( -utf8 );
use C4::Koha;
use C4::Biblio;
use C4::Items;
use C4::Members; # to use GetMember
use C4::Serials; # CountSubscriptionFromBiblionumber
use C4::Search; # enabled_staff_search_views
use C4::Acquisition qw(GetOrdersByBiblionumber);
use Koha::Biblios;
use Koha::Patrons;
use Koha::RecordProcessor;
@ -107,12 +107,12 @@ my $res = GetISBDView({
});
if($query->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
holdfor => $query->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}

View File

@ -56,12 +56,12 @@ use MARC::Record;
use C4::Biblio;
use C4::Items;
use C4::Acquisition;
use C4::Members; # to use GetMember
use C4::Serials; #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber
use C4::Search; # enabled_staff_search_views
use Koha::Biblios;
use Koha::BiblioFrameworks;
use Koha::Patrons;
use List::MoreUtils qw( uniq );
@ -105,12 +105,12 @@ my $tagslib = &GetMarcStructure(1,$frameworkcode);
my $biblio = GetBiblioData($biblionumber);
if($query->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
holdfor => $query->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}

View File

@ -29,7 +29,6 @@ use C4::Biblio;
use C4::Items;
use C4::Circulation;
use C4::Reserves;
use C4::Members; # to use GetMember
use C4::Serials;
use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
use C4::External::Amazon;
@ -75,12 +74,13 @@ if ( not defined $record ) {
}
if($query->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
# FIXME Should pass the patron object
holdfor => $query->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}
@ -262,14 +262,14 @@ foreach my $item (@items) {
my $item_object = Koha::Items->find( $item->{itemnumber} );
my $holds = $item_object->current_holds;
if ( my $first_hold = $holds->next ) {
my $ItemBorrowerReserveInfo = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber); # FIXME could be improved
my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
$item->{backgroundcolor} = 'reserved';
$item->{reservedate} = $first_hold->reservedate;
$item->{ReservedForBorrowernumber} = $first_hold->borrowernumber;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
$item->{ReservedForSurname} = $patron->surname;
$item->{ReservedForFirstname} = $patron->firstname;
$item->{ExpectedAtLibrary} = $first_hold->branchcode;
$item->{Reservedcardnumber} = $ItemBorrowerReserveInfo->{'cardnumber'};
$item->{Reservedcardnumber} = $patron->cardnumber;
# Check waiting status
$item->{waitingdate} = $first_hold->waitingdate;
}

View File

@ -30,6 +30,7 @@ use C4::Search;
use C4::Acquisition qw(GetOrdersByBiblionumber);
use Koha::Biblios;
use Koha::Patrons;
my $query = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
@ -58,13 +59,12 @@ foreach my $item (@items) {
}
if ( $query->cookie("holdfor") ) {
my $holdfor_patron =
GetMember( 'borrowernumber' => $query->cookie("holdfor") );
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
holdfor => $query->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}

View File

@ -27,12 +27,12 @@ use C4::Context;
use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Members; # to use GetMember
use C4::Search; # enabled_staff_search_views
use C4::Acquisition qw(GetOrdersByBiblionumber);
use Koha::Biblios;
use Koha::BiblioFrameworks;
use Koha::Patrons;
my $query = new CGI;
my $dbh = C4::Context->dbh;
@ -71,12 +71,12 @@ my $tagslib = GetMarcStructure(1,$frameworkcode);
my $biblio = GetBiblioData($biblionumber);
if($query->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
holdfor => $query->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}

View File

@ -30,7 +30,6 @@ use C4::Acquisition;
use C4::Output;
use C4::Auth;
use C4::Serials;
use C4::Members; # to use GetMember
use C4::Search; # enabled_staff_search_views
use Koha::Acquisition::Booksellers;
@ -53,12 +52,12 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
);
if($query->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
holdfor => $query->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}
@ -190,9 +189,9 @@ foreach my $item (@items){
unless ($hidepatronname) {
if ( $item->{'borrowernumber'} ) {
my $curr_borrower = GetMember('borrowernumber' => $item->{'borrowernumber'} );
$item->{borrowerfirstname} = $curr_borrower->{'firstname'};
$item->{borrowersurname} = $curr_borrower->{'surname'};
my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} );
$item->{borrowerfirstname} = $curr_borrower->firstname;
$item->{borrowersurname} = $curr_borrower->surname;
}
}

View File

@ -146,16 +146,16 @@ use C4::Auth qw(:DEFAULT get_session);
use C4::Search;
use C4::Languages qw(getLanguages);
use C4::Koha;
use C4::Members qw(GetMember);
use URI::Escape;
use POSIX qw(ceil floor);
use C4::Search::History;
use Koha::ItemTypes;
use Koha::LibraryCategories;
use Koha::Virtualshelves;
use Koha::Patrons;
use Koha::SearchEngine::Search;
use Koha::SearchEngine::QueryBuilder;
use Koha::Virtualshelves;
use URI::Escape;
@ -196,12 +196,12 @@ if (C4::Context->preference("IntranetNumbersPreferPhrase")) {
}
if($cgi->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $cgi->cookie("holdfor"));
my $holdfor_patron = Koha::Patrons->find( $cgi->cookie("holdfor") );
$template->param(
holdfor => $cgi->cookie("holdfor"),
holdfor_surname => $holdfor_patron->{'surname'},
holdfor_firstname => $holdfor_patron->{'firstname'},
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
holdfor_surname => $holdfor_patron->surname,
holdfor_firstname => $holdfor_patron->firstname,
holdfor_cardnumber => $holdfor_patron->cardnumber,
);
}

View File

@ -34,6 +34,7 @@ use Koha::DateUtils;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::Patrons;
use List::MoreUtils qw/any/;
use C4::Search;
use Storable qw(thaw freeze);
@ -402,7 +403,7 @@ my ($template, $loggedinuser, $cookie)
# Does the user have a restricted item editing permission?
my $uid = $loggedinuser ? GetMember( borrowernumber => $loggedinuser )->{userid} : undef;
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
my $restrictededition = $uid ? haspermission($uid, {'editcatalogue' => 'edit_items_restricted'}) : undef;
# In case user is a superlibrarian, editing is not restricted
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());

View File

@ -34,6 +34,7 @@ use C4::Members;
use Koha::BiblioFrameworks;
use Koha::AuthorisedValues;
use Koha::Items;
use Koha::Patrons;
###############################################
# Getting state
@ -205,11 +206,13 @@ foreach my $code ( keys %$messages ) {
elsif ( $code eq 'WasReturned' ) {
$err{errwasreturned} = 1;
$err{borrowernumber} = $messages->{'WasReturned'};
my $borrower = GetMember('borrowernumber'=>$messages->{'WasReturned'});
$err{title} = $borrower->{'title'};
$err{firstname} = $borrower->{'firstname'};
$err{surname} = $borrower->{'surname'};
$err{cardnumber} = $borrower->{'cardnumber'};
my $patron = Koha::Patrons->find( $messages->{'WasReturned'} );
if ( $patron ) { # Just in case...
$err{title} = $patron->title;
$err{firstname} = $patron->firstname;
$err{surname} = $patron->surname;
$err{cardnumber} = $patron->cardnumber;
}
}
$err{errdesteqholding} = ( $code eq 'DestinationEqualsHolding' );
push( @errmsgloop, \%err );

View File

@ -22,6 +22,8 @@
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
# FIXME There are too many calls to Koha::Patrons->find in this script
use strict;
use warnings;
use CGI qw ( -utf8 );
@ -44,14 +46,13 @@ use CGI::Session;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::AuthorisedValues;
use Koha::CsvProfiles;
use Koha::Patron;
use Koha::Patrons;
use Koha::Patron::Debarments qw(GetDebarments);
use Koha::DateUtils;
use Koha::Database;
use Koha::BiblioFrameworks;
use Koha::Items;
use Koha::Patron::Messages;
use Koha::Patron::Images;
use Koha::SearchEngine;
use Koha::SearchEngine::Search;
use Koha::Patron::Modifications;
@ -105,13 +106,14 @@ $barcodes = [ uniq @$barcodes ];
my $template_name = q|circ/circulation.tt|;
my $borrowernumber = $query->param('borrowernumber');
my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
my $patron = $borrowernumber ? Koha::Patrons->find( $borrowernumber ) : undef;
my $batch = $query->param('batch');
my $batch_allowed = 0;
if ( $batch && C4::Context->preference('BatchCheckouts') ) {
$template_name = q|circ/circulation_batch_checkouts.tt|;
my @batch_category_codes = split '\|', C4::Context->preference('BatchCheckoutsValidCategories');
if ( grep {/^$borrower->{categorycode}$/} @batch_category_codes ) {
my $categorycode = $patron->categorycode;
if ( $categorycode && grep {/^$categorycode$/} @batch_category_codes ) {
$batch_allowed = 1;
} else {
$barcodes = [];
@ -232,9 +234,9 @@ if ( $print eq 'yes' && $borrowernumber ne '' ) {
#
my $message;
if ($findborrower) {
my $borrower = C4::Members::GetMember( cardnumber => $findborrower );
if ( $borrower ) {
$borrowernumber = $borrower->{borrowernumber};
my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
if ( $patron ) {
$borrowernumber = $patron->borrowernumber;
} else {
my $dt_params = { iDisplayLength => -1 };
my $results = C4::Utils::DataTables::Members::search(
@ -259,10 +261,8 @@ if ($findborrower) {
}
# get the borrower information.....
my $patron;
if ($borrowernumber) {
$patron = Koha::Patrons->find( $borrowernumber );
$borrower = GetMember( borrowernumber => $borrowernumber );
my $overdues = $patron->get_overdues;
my $issues = $patron->checkouts;
my $balance = $patron->account->balance;
@ -280,7 +280,7 @@ if ($borrowernumber) {
# check for NotifyBorrowerDeparture
elsif ( $patron->is_going_to_expire ) {
# borrower card soon to expire warn librarian
$template->param( "warndeparture" => $borrower->{dateexpiry} ,
$template->param( "warndeparture" => $patron->dateexpiry ,
);
if (C4::Context->preference('ReturnBeforeExpiry')){
$template->param("returnbeforeexpiry" => 1);
@ -294,12 +294,12 @@ if ($borrowernumber) {
if ( $patron and $patron->is_debarred ) {
$template->param(
'userdebarred' => $borrower->{debarred},
'debarredcomment' => $borrower->{debarredcomment},
'userdebarred' => $patron->debarred,
'debarredcomment' => $patron->debarredcomment,
);
if ( $borrower->{debarred} ne "9999-12-31" ) {
$template->param( 'userdebarreddate' => $borrower->{debarred} );
if ( $patron->debarred ne "9999-12-31" ) {
$template->param( 'userdebarreddate' => $patron->debarred );
}
}
@ -315,7 +315,7 @@ if (@$barcodes) {
my $template_params = { barcode => $barcode };
# always check for blockers on issuing
my ( $error, $question, $alerts, $messages ) = CanBookBeIssued(
$borrower,
$patron->unblessed,
$barcode, $datedue,
$inprocess,
undef,
@ -402,7 +402,7 @@ if (@$barcodes) {
}
unless($confirm_required) {
my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
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, } );
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, } );
$template_params->{issue} = $issue;
$session->clear('auto_renew');
$inprocess = 1;
@ -439,11 +439,6 @@ if (@$barcodes) {
}
}
# reload the borrower info for the sake of reseting the flags.....
if ($borrowernumber) {
$borrower = GetMember( borrowernumber => $borrowernumber );
}
##################################################################################
# BUILD HTML
# show all reserves of this borrower, and the position of the reservation ....
@ -455,11 +450,12 @@ if ($borrowernumber) {
WaitingHolds => $waiting_holds,
);
$template->param( adultborrower => 1 ) if ( $borrower->{category_type} eq 'A' || $borrower->{category_type} eq 'I' );
my $category_type = $patron->category->category_type;
$template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
}
#title
my $flags = $borrower ? C4::Members::patronflags( $borrower ) : {};
my $flags = $patron ? C4::Members::patronflags( $patron->unblessed ) : {};
foreach my $flag ( sort keys %$flags ) {
$flags->{$flag}->{'message'} =~ s#\n#<br />#g;
if ( $flags->{$flag}->{'noissues'} ) {
@ -547,7 +543,7 @@ $amountold =~ s/^.*\$//; # remove upto the $, if any
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
if ( $borrowernumber && $borrower->{'category_type'} eq 'C') {
if ( $patron && $patron->category->category_type eq 'C') {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
$template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
@ -595,10 +591,20 @@ my $relatives_issues_count =
Koha::Database->new()->schema()->resultset('Issue')
->count( { borrowernumber => \@relatives } );
my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $borrower->{streettype} });
my $roadtype = $av->count ? $av->next->lib : '';
$template->param(%$borrower);
if ( $patron ) {
my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $patron->streettype });
my $roadtype = $av->count ? $av->next->lib : '';
$template->param(
%{ $patron->unblessed },
borrower => $patron->unblessed,
roadtype => $roadtype,
patron => $patron,
categoryname => $patron->category->description,
expiry => $patron->dateexpiry,
is_child => ( $patron->category->category_type eq 'C' ),
picture => ( $patron->image ? 1 : 0 ),
);
}
# Restore date if changed by holds and/or save stickyduedate to session
if ($restoreduedatespec || $stickyduedate) {
@ -612,15 +618,10 @@ if ($restoreduedatespec || $stickyduedate) {
}
$template->param(
patron => $patron,
messages => $messages,
borrower => $borrower,
borrowernumber => $borrowernumber,
categoryname => $borrower->{'description'},
branch => $branch,
was_renewed => scalar $query->param('was_renewed') ? 1 : 0,
expiry => $borrower->{'dateexpiry'},
roadtype => $roadtype,
amountold => $amountold,
barcodes => $barcodes,
stickyduedate => $stickyduedate,
@ -629,7 +630,6 @@ $template->param(
message => $message,
totaldue => sprintf('%.2f', $total),
inprocess => $inprocess,
is_child => ($borrowernumber && $borrower->{'category_type'} eq 'C'),
$view => 1,
batch_allowed => $batch_allowed,
batch => $batch,
@ -643,8 +643,6 @@ $template->param(
relatives_borrowernumbers => \@relatives,
);
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
if ( C4::Context->preference("ExportCircHistory") ) {
$template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);

View File

@ -30,6 +30,8 @@ script to execute returns of books
use strict;
use warnings;
# FIXME There are weird things going on with $patron and $borrowernumber in this script
use Carp 'verbose';
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
@ -167,8 +169,8 @@ if ( $query->param('reserve_id') ) {
# check if we have other reserves for this document, if we have a return send the message of transfer
my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
my $borr = GetMember( borrowernumber => $nextreservinfo );
my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
my $patron = Koha::Patrons->find( $nextreservinfo );
my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
if ( $messages->{'transfert'} ) {
$template->param(
itemtitle => $biblio->title,
@ -177,10 +179,10 @@ if ( $query->param('reserve_id') ) {
iteminfo => $biblio->author,
name => $name,
borrowernumber => $borrowernumber,
borcnum => $borr->{'cardnumber'},
borfirstname => $borr->{'firstname'},
borsurname => $borr->{'surname'},
borcategory => $borr->{'description'},
borcnum => $patron->cardnumber,
borfirstname => $patron->firstname,
borsurname => $patron->surname,
borcategory => $patron->category->description,
diffbranch => 1,
);
}
@ -399,27 +401,31 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
);
my $reserve = $messages->{'ResFound'};
my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
if ( $reserve ) {
my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
$template->param(
# FIXME The full patron object should be passed to the template
wname => $name,
wborfirstname => $patron->firstname,
wborsurname => $patron->surname,
wborcategory => $patron->category->description,
wbortitle => $patron->title,
wborphone => $patron->phone,
wboremail => $patron->email,
streetnumber => $patron->streetnumber,
address => $patron->address,
address2 => $patron->address2,
city => $patron->city,
zipcode => $patron->zipcode,
state => $patron->state,
country => $patron->country,
wborrowernumber => $reserve->{'borrowernumber'},
wborcnum => $patron->cardnumber,
);
}
$template->param(
wname => $name,
wborfirstname => $borr->{'firstname'},
wborsurname => $borr->{'surname'},
wborcategory => $borr->{'description'},
wbortitle => $borr->{'title'},
wborphone => $borr->{'phone'},
wboremail => $borr->{'email'},
streetnumber => $borr->{streetnumber},
streettype => $borr->{streettype},
address => $borr->{'address'},
address2 => $borr->{'address2'},
city => $borr->{'city'},
zipcode => $borr->{'zipcode'},
state => $borr->{'state'},
country => $borr->{'country'},
wborrowernumber => $reserve->{'borrowernumber'},
wborcnum => $borr->{'cardnumber'},
wtransfertFrom => $userenv_branch,
wtransfertFrom => $userenv_branch,
);
}
@ -428,7 +434,7 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
#
if ( $messages->{'ResFound'}) {
my $reserve = $messages->{'ResFound'};
my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
my $patron = Koha::Patrons->find( $reserve->{borrowernumber} );
my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } );
if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
if ( $reserve->{'ResFound'} eq "Waiting" ) {
@ -446,25 +452,25 @@ if ( $messages->{'ResFound'}) {
# same params for Waiting or Reserved
$template->param(
# FIXME The full patron object should be passed to the template
found => 1,
name => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
borfirstname => $borr->{'firstname'},
borsurname => $borr->{'surname'},
borcategory => $borr->{'description'},
bortitle => $borr->{'title'},
borphone => $borr->{'phone'},
boremail => $borr->{'email'},
streetnumber => $borr->{streetnumber},
streettype => $borr->{streettype},
address => $borr->{'address'},
address2 => $borr->{'address2'},
city => $borr->{'city'},
zipcode => $borr->{'zipcode'},
state => $borr->{'state'},
country => $borr->{'country'},
borcnum => $borr->{'cardnumber'},
debarred => $borr->{'debarred'},
gonenoaddress => $borr->{'gonenoaddress'},
name => $patron->surname . ", " . $patron->title . " " . $patron->firstname,
borfirstname => $patron->firstname,
borsurname => $patron->surname,
borcategory => $patron->category->description,
bortitle => $patron->title,
borphone => $patron->phone,
boremail => $patron->email,
boraddress => $patron->address,
boraddress2 => $patron->address2,
streetnumber => $patron->streetnumber,
city => $patron->city,
zipcode => $patron->zipcode,
state => $patron->state,
country => $patron->country,
borcnum => $patron->cardnumber,
debarred => $patron->debarred,
gonenoaddress => $patron->gonenoaddress,
barcode => $barcode,
destbranch => $reserve->{'branchcode'},
borrowernumber => $reserve->{'borrowernumber'},
@ -572,19 +578,19 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
$ri{hour} = $duedate->hour();
$ri{minute} = $duedate->minute();
$ri{duedate} = output_pref($duedate);
my $b = C4::Members::GetMember( borrowernumber => $riborrowernumber{$_} );
my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
unless ( $dropboxmode ) {
$ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
} else {
$ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
}
$ri{borrowernumber} = $b->{'borrowernumber'};
$ri{borcnum} = $b->{'cardnumber'};
$ri{borfirstname} = $b->{'firstname'};
$ri{borsurname} = $b->{'surname'};
$ri{bortitle} = $b->{'title'};
$ri{bornote} = $b->{'borrowernotes'};
$ri{borcategorycode}= $b->{'categorycode'};
$ri{borrowernumber} = $patron->borrowernumber;
$ri{borcnum} = $patron->cardnumber;
$ri{borfirstname} = $patron->firstname;
$ri{borsurname} = $patron->surname;
$ri{bortitle} = $patron->title;
$ri{bornote} = $patron->borrowernotes;
$ri{borcategorycode}= $patron->categorycode;
$ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
}
else {

View File

@ -40,6 +40,7 @@ use Koha::ItemTypes;
use Koha::Libraries;
use Koha::DateUtils;
use Koha::BiblioFrameworks;
use Koha::Patrons;
my $input = new CGI;
my $itemnumber = $input->param('itemnumber');
@ -114,12 +115,13 @@ while ( my $library = $libraries->next ) {
# we check if we have a reserv for this transfer
my $holds = $item->current_holds;
if ( my $first_hold = $holds->next ) {
my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
$getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
$getransf{'borrowername'} = $getborrower->{'surname'};
$getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
$getransf{'borrowermail'} = $getborrower->{'email'} if $getborrower->{'email'};
$getransf{'borrowerphone'} = $getborrower->{'phone'};
my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
# FIXME The full patron object should be passed to the template
$getransf{'borrowernum'} = $patron->borrowernumber;
$getransf{'borrowername'} = $patron->surname;
$getransf{'borrowerfirstname'} = $patron->firstname;
$getransf{'borrowermail'} = $patron->email if $patron->email;
$getransf{'borrowerphone'} = $patron->phone;
}
push( @transferloop, \%getransf );
}

View File

@ -39,6 +39,7 @@ use Koha::DateUtils;
use Koha::BiblioFrameworks;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Patrons;
my $input = new CGI;
@ -104,7 +105,7 @@ foreach my $num (@getreserves) {
borrowernum => $borrowernum,
);
my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
my $patron = Koha::Patrons->find( $num->{borrowernumber} );
my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
$getreserv{'waitingdate'} = $num->{'waitingdate'};
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
@ -123,9 +124,9 @@ foreach my $num (@getreserves) {
if ( $homebranch ne $holdingbranch ) {
$getreserv{'dotransfer'} = 1;
}
$getreserv{'borrowername'} = $getborrower->{'surname'};
$getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
$getreserv{'borrowerphone'} = $getborrower->{'phone'};
$getreserv{'borrowername'} = $patron->surname;
$getreserv{'borrowerfirstname'} = $patron->firstname;
$getreserv{'borrowerphone'} = $patron->phone;
my $borEmail = GetFirstValidEmailAddress( $borrowernum );
@ -189,7 +190,7 @@ sub cancel {
# if we have a result
if ($nextreservinfo) {
my %res;
my $borrowerinfo = C4::Members::GetMember( borrowernumber => $nextreservinfo );
my $patron = Koha::Patrons->find( $nextreservinfo );
my $title = Koha::Items->find( $item )->biblio->title;
if ( $messages->{'transfert'} ) {
$res{messagetransfert} = $messages->{'transfert'};
@ -198,8 +199,8 @@ sub cancel {
$res{message} = 1;
$res{nextreservnumber} = $nextreservinfo;
$res{nextreservsurname} = $borrowerinfo->{'surname'};
$res{nextreservfirstname} = $borrowerinfo->{'firstname'};
$res{nextreservsurname} = $patron->surname;
$res{nextreservfirstname} = $patron->firstname;
$res{nextreservitem} = $item;
$res{nextreservtitle} = $title;
$res{waiting} = $messages->{'waiting'} ? 1 : 0;

View File

@ -31,8 +31,7 @@ use CGI qw ( -utf8 );
use C4::Members;
use C4::Accounts;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Patron::Categories;
my $input=new CGI;
@ -53,14 +52,14 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
my $borrowernumber=$input->param('borrowernumber');
my $action = $input->param('action') || '';
#get borrower details
my $data=GetMember('borrowernumber' => $borrowernumber);
#get patron details
my $patron = Koha::Patrons->find( $borrowernumber );
if ( $action eq 'reverse' ) {
ReversePayment( $input->param('accountlines_id') );
}
if ( $data->{'category_type'} eq 'C') {
if ( $patron->category->category_type eq 'C') {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
$template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
@ -92,10 +91,9 @@ foreach my $accountline ( @{$accts}) {
}
}
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
$template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
@ -105,14 +103,14 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
);
}
$template->param(%$data);
$template->param(%{ $patron->unblessed });
$template->param(
finesview => 1,
borrowernumber => $borrowernumber,
total => sprintf("%.2f",$total),
totalcredit => $totalcredit,
is_child => ($data->{'category_type'} eq 'C'),
is_child => ($patron->category->category_type eq 'C'),
reverse_col => $reverse_col,
accounts => $accts,
RoutingSerials => C4::Context->preference('RoutingSerials'),

View File

@ -31,7 +31,6 @@ use C4::Auth;
use C4::Members;
use Module::Load;
use Koha::Patrons;
use Koha::Patron::Images;
use Koha::Token;
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
@ -75,13 +74,13 @@ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen
my $issues = GetPendingIssues($member); # FIXME: wasteful call when really, we only want the count
my $countissues = scalar(@$issues);
my $bor = C4::Members::GetMember( borrowernumber => $member );
my $flags = C4::Members::patronflags( $bor );
my $patron = Koha::Patrons->find( $member );
my $flags = C4::Members::patronflags( $patron->unblessed );
my $userenv = C4::Context->userenv;
if ($bor->{category_type} eq "S") {
if ($patron->category->category_type eq "S") {
unless(C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF");
exit 0; # Exit without error
@ -95,8 +94,8 @@ if ($bor->{category_type} eq "S") {
if (C4::Context->preference("IndependentBranches")) {
my $userenv = C4::Context->userenv;
if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
unless ($userenv->{branch} eq $bor->{'branchcode'}){
if ( !C4::Context->IsSuperLibrarian() && $patron->branchcode){
unless ($userenv->{branch} eq $patron->branchcode){
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
exit 0; # Exit without error
}
@ -107,27 +106,28 @@ my $op = $input->param('op') || 'delete_confirm';
my $dbh = C4::Context->dbh;
my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_guarantor or $deletelocal == 0) {
my $patron_image = Koha::Patron::Images->find($bor->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
$template->param( adultborrower => 1 ) if ( $bor->{category_type} eq 'A' || $bor->{category_type} eq 'I' );
$template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/;
$template->param(borrowernumber => $member,
surname => $bor->{'surname'},
title => $bor->{'title'},
cardnumber => $bor->{'cardnumber'},
firstname => $bor->{'firstname'},
categorycode => $bor->{'categorycode'},
category_type => $bor->{'category_type'},
categoryname => $bor->{'description'},
address => $bor->{'address'},
address2 => $bor->{'address2'},
city => $bor->{'city'},
zipcode => $bor->{'zipcode'},
country => $bor->{'country'},
phone => $bor->{'phone'},
email => $bor->{'email'},
branchcode => $bor->{'branchcode'},
$template->param(
# FIXME The patron object should be passed to the template
borrowernumber => $patron->borrowernumber,
surname => $patron->surname,
title => $patron->title,
cardnumber => $patron->cardnumber,
firstname => $patron->firstname,
categorycode => $patron->categorycode,
category_type => $patron->category->category_type,
categoryname => $patron->category->description,
address => $patron->address,
address2 => $patron->address2,
city => $patron->city,
zipcode => $patron->zipcode,
country => $patron->country,
phone => $patron->phone,
email => $patron->email,
branchcode => $patron->branchcode,
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
if ($countissues >0) {

View File

@ -37,7 +37,6 @@ use C4::Members;
use C4::Reserves;
use C4::Letters;
use Koha::Patron::Discharge;
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::DateUtils;
@ -59,19 +58,16 @@ unless ( C4::Context->preference('useDischarge') ) {
exit;
}
my $data;
if ( $input->param('borrowernumber') ) {
$borrowernumber = $input->param('borrowernumber');
# Getting member data
$data = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
borrowernumber => $borrowernumber
});
# Getting reserves
my $patron = Koha::Patrons->find( $borrowernumber );
my $holds = $patron->holds;
my $has_reserves = $holds->count;
@ -87,7 +83,7 @@ if ( $input->param('borrowernumber') ) {
}
eval {
my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
{ borrowernumber => $borrowernumber, branchcode => $data->{'branchcode'} } );
{ borrowernumber => $borrowernumber, branchcode => $patron->branchcode } );
binmode(STDOUT);
print $input->header(
@ -112,31 +108,30 @@ if ( $input->param('borrowernumber') ) {
borrowernumber => $borrowernumber,
});
my $patron_image = Koha::Patron::Images->find($borrowernumber);
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
$template->param(
# FIXME The patron object should be passed to the template
borrowernumber => $borrowernumber,
biblionumber => $data->{'biblionumber'},
title => $data->{'title'},
initials => $data->{'initials'},
surname => $data->{'surname'},
title => $patron->title,
initials => $patron->initials,
surname => $patron->surname,
borrowernumber => $borrowernumber,
firstname => $data->{'firstname'},
cardnumber => $data->{'cardnumber'},
categorycode => $data->{'categorycode'},
category_type => $data->{'category_type'},
categoryname => $data->{'description'},
address => $data->{'address'},
streetnumber => $data->{streetnumber},
streettype => $data->{streettype},
address2 => $data->{'address2'},
city => $data->{'city'},
zipcode => $data->{'zipcode'},
country => $data->{'country'},
phone => $data->{'phone'},
email => $data->{'email'},
branchcode => $data->{'branchcode'},
firstname => $patron->firstname,
cardnumber => $patron->cardnumber,
categorycode => $patron->categorycode,
category_type => $patron->category->category_type,
categoryname => $patron->category->description,
address => $patron->address,
streetnumber => $patron->streetnumber,
streettype => $patron->streettype,
address2 => $patron->address2,
city => $patron->city,
zipcode => $patron->zipcode,
country => $patron->country,
phone => $patron->phone,
email => $patron->email,
branchcode => $patron->branchcode,
has_reserves => $has_reserves,
can_be_discharged => $can_be_discharged,
validated_discharges => $validated_discharges,

View File

@ -29,8 +29,8 @@ use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Debug;
use Koha::DateUtils;
use Koha::Patrons;
use Koha::Patron::Files;
use Koha::Patron::Images;
my $cgi = CGI->new;
@ -63,8 +63,8 @@ if ( $op eq 'download' ) {
print $file->{'file_content'};
}
else {
my $data = GetMember( borrowernumber => $borrowernumber );
$template->param(%$data);
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param(%{ $patron->unblessed});
my %errors;
@ -102,7 +102,7 @@ else {
}
$template->param(
categoryname => $data->{'description'},
categoryname => $patron->category->description,
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
@ -114,8 +114,7 @@ else {
);
}
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
$template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' || $data->{category_type} eq 'I' );
$template->param(

View File

@ -66,7 +66,7 @@ push @messages, { type => 'error', code => 'error_on_patron_load' }
# Get supporting cast
my ( $branch, $category, $houseboundprofile, $visit, $patron_image );
if ( $patron ) {
$patron_image = Koha::Patron::Images->find($patron->borrowernumber);
$patron_image = $patron->image;
$branch = Koha::Libraries->new->find($patron->branchcode);
$category = Koha::Patron::Categories->new->find($patron->categorycode);
$houseboundprofile = $patron->housebound_profile;

View File

@ -33,7 +33,7 @@ use C4::Members;
use C4::Accounts;
use C4::Items;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Patron::Categories;
@ -42,8 +42,7 @@ my $flagsrequired = { borrowers => 1, updatecharges => 1 };
my $borrowernumber=$input->param('borrowernumber');
#get borrower details
my $data=GetMember('borrowernumber' => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
my $add=$input->param('add');
if ($add){
@ -74,15 +73,14 @@ if ($add){
}
);
if ( $data->{'category_type'} eq 'C') {
if ( $patron->category->category_type eq 'C') {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
$template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
}
$template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' || $data->{category_type} eq 'I' );
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
$template->param( picture => 1 ) if $patron->image;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
@ -92,13 +90,13 @@ if ($add){
);
}
$template->param(%$data);
$template->param(%{ $patron->unblessed});
$template->param(
finesview => 1,
borrowernumber => $borrowernumber,
categoryname => $data->{'description'},
is_child => ($data->{'category_type'} eq 'C'),
categoryname => $patron->category->description,
is_child => ($patron->category->category_type eq 'C'), # FIXME is_child should be a Koha::Patron method
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -32,7 +32,8 @@ use C4::Members;
use C4::Accounts;
use C4::Items;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Patron::Categories;
@ -41,9 +42,7 @@ my $flagsrequired = { borrowers => 1 };
my $borrowernumber=$input->param('borrowernumber');
# get borrower details
my $data=GetMember('borrowernumber'=>$borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
my $add=$input->param('add');
if ($add){
if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
@ -100,15 +99,14 @@ if ($add){
}
$template->param( invoice_types_loop => \@invoice_types );
if ( $data->{'category_type'} eq 'C') {
if ( $patron->category->category_type eq 'C') {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
$template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
}
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
$template->param( picture => 1 ) if $patron->image;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
@ -118,12 +116,12 @@ if ($add){
);
}
$template->param(%$data);
$template->param(%{ $patron->unblessed });
$template->param(
finesview => 1,
borrowernumber => $borrowernumber,
categoryname => $data->{'description'},
is_child => ($data->{'category_type'} eq 'C'),
categoryname => $patron->category->description,
is_child => ($patron->category->category_type eq 'C'),
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -16,6 +16,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes);
#use C4::Acquisitions;
use Koha::Patron::Categories;
use Koha::Patrons;
use C4::Output;
use Koha::Patron::Images;
@ -25,8 +26,10 @@ my $input = new CGI;
my $flagsrequired = { permissions => 1 };
my $member=$input->param('member');
my $bor = GetMember( borrowernumber => $member );
if( $bor->{'category_type'} eq 'S' ) {
my $patron = Koha::Patrons->find( $member );
my $category_type = $patron->category->category_type;
my $bor = $patron->unblessed;
if( $category_type eq 'S' ) {
$flagsrequired->{'staffaccess'} = 1;
}
my ($template, $loggedinuser, $cookie) = get_template_and_user({
@ -170,15 +173,14 @@ if ($input->param('newflags')) {
push @loop, \%row;
}
if ( $bor->{'category_type'} eq 'C') {
if ( $category_type eq 'C') {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
$template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
}
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' || $bor->{'category_type'} eq 'I' );
my $patron_image = Koha::Patron::Images->find($bor->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
$template->param( picture => 1 ) if $patron->image;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
@ -195,7 +197,7 @@ $template->param(
firstname => $bor->{'firstname'},
othernames => $bor->{'othernames'},
categorycode => $bor->{'categorycode'},
category_type => $bor->{'category_type'},
category_type => $category_type,
categoryname => $bor->{'description'},
address => $bor->{address},
address2 => $bor->{'address2'},
@ -211,7 +213,7 @@ $template->param(
emailpro => $bor->{'emailpro'},
branchcode => $bor->{'branchcode'},
loop => \@loop,
is_child => ($bor->{'category_type'} eq 'C'),
is_child => ($category_type eq 'C'),
RoutingSerials => C4::Context->preference('RoutingSerials'),
csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID'), } ),
);

View File

@ -15,9 +15,9 @@ use C4::Members;
use C4::Circulation;
use CGI qw ( -utf8 );
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Images;
use Koha::Token;
use Koha::Patrons;
use Koha::Patron::Categories;
my $input = new CGI;
@ -48,9 +48,11 @@ my $newpassword2 = $input->param('newpassword2');
my @errors;
my ($bor) = GetMember( 'borrowernumber' => $member );
my $patron = Koha::Patrons->find( $member );
my $category_type = $patron->category->category_type;
my $bor = $patron->unblessed;
if ( ( $member ne $loggedinuser ) && ( $bor->{'category_type'} eq 'S' ) ) {
if ( ( $member ne $loggedinuser ) && ( $category_type eq 'S' ) ) {
push( @errors, 'NOPERMISSION' )
unless ( $staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
@ -99,16 +101,15 @@ else {
$template->param( defaultnewpassword => $defaultnewpassword );
}
if ( $bor->{'category_type'} eq 'C') {
if ( $category_type eq 'C') {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
$template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
}
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' || $bor->{'category_type'} eq 'I' );
$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
my $patron_image = Koha::Patron::Images->find($bor->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} );
@ -125,7 +126,7 @@ $template->param(
borrowernumber => $bor->{'borrowernumber'},
cardnumber => $bor->{'cardnumber'},
categorycode => $bor->{'categorycode'},
category_type => $bor->{'category_type'},
category_type => $category_type,
categoryname => $bor->{'description'},
address => $bor->{address},
address2 => $bor->{'address2'},
@ -143,7 +144,7 @@ $template->param(
branchcode => $bor->{'branchcode'},
userid => $bor->{'userid'},
destination => $destination,
is_child => ( $bor->{'category_type'} eq 'C' ),
is_child => ( $category_type eq 'C' ),
minPasswordLength => $minpw,
RoutingSerials => C4::Context->preference('RoutingSerials'),
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID'), }),

View File

@ -27,9 +27,9 @@ use Modern::Perl;
use C4::Auth;
use C4::Output;
use CGI qw( -utf8 );
use C4::Members qw( GetMember );
use Koha::DateUtils;
use Koha::List::Patron;
use Koha::Patrons;
my $input = new CGI;
@ -52,12 +52,9 @@ if ( $quicksearch and $searchmember ) {
my $userenv = C4::Context->userenv;
$branchcode = $userenv->{'branch'};
}
my $member = GetMember(
cardnumber => $searchmember,
( $branchcode ? ( branchcode => $branchcode ) : () ),
);
if( $member ){
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $member->{borrowernumber});
my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
if( ( $branchcode and $patron->branchcode eq $branchcode ) or ( not $branchcode and $patron ) ){
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber);
exit;
}
}

View File

@ -42,6 +42,7 @@ use Koha::Patron::Debarments;
use Koha::Cities;
use Koha::DateUtils;
use Koha::Libraries;
use Koha::Patrons;
use Koha::Patron::Categories;
use Koha::Patron::HouseboundRole;
use Koha::Patron::HouseboundRoles;
@ -152,7 +153,11 @@ $template->param( "add" => 1 ) if ( $op eq 'add' );
$template->param( "quickadd" => 1 ) if ( $quickadd );
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
my $patron = Koha::Patrons->find( $borrowernumber );
$borrower_data = $patron->unblessed;
$borrower_data->{category_type} = $patron->category->category_type;
}
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
my $category_type = $input->param('category_type') || '';
unless ($category_type or !($categorycode)){
@ -242,7 +247,8 @@ if ( ( $op eq 'insert' ) and !$nodouble ) {
#recover all data from guarantor address phone ,fax...
if ( $guarantorid ) {
if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
if (my $guarantor = Koha::Patrons->find( $guarantorid )) {
my $guarantordata = $guarantor->unblessed;
$category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
$guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
$newdata{'contactfirstname'}= $guarantordata->{'firstname'};
@ -307,8 +313,8 @@ if ($op eq 'save' || $op eq 'insert'){
my $dateofbirth;
if ($op eq 'save' && $step == 3) {
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
$dateofbirth = $borrower->{dateofbirth};
my $patron = Koha::Patrons->find( $borrowernumber );
$dateofbirth = $patron->dateofbirth;
}
else {
$dateofbirth = $newdata{dateofbirth};

View File

@ -120,6 +120,12 @@ my $error = $input->param('error');
$template->param( error => $error ) if ( $error );
my $patron = Koha::Patrons->find($borrowernumber);
unless ( $patron ) {
$template->param (unknowuser => 1);
output_html_with_http_headers $input, $cookie, $template->output;
exit;
}
my $issues = $patron->checkouts;
my $balance = $patron->account->balance;
$template->param(
@ -127,16 +133,8 @@ $template->param(
fines => $balance,
);
my $data = GetMember( 'borrowernumber' => $borrowernumber );
if ( not defined $data ) {
$template->param (unknowuser => 1);
output_html_with_http_headers $input, $cookie, $template->output;
exit;
}
my $category_type = $data->{'category_type'};
my $category_type = $patron->category->category_type;
my $data = $patron->unblessed;
$debug and printf STDERR "dates (enrolled,expiry,birthdate) raw: (%s, %s, %s)\n", map {$data->{$_}} qw(dateenrolled dateexpiry dateofbirth);
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
@ -279,8 +277,7 @@ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen
# check to see if patron's image exists in the database
# basically this gives us a template var to condition the display of
# patronimage related interface on
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
# Generate CSRF token for upload and delete image buttons
$template->param(
csrf_token => Koha::Token->new->generate_csrf({ session_id => $input->cookie('CGISESSID'),}),

View File

@ -27,14 +27,14 @@ use CGI qw ( -utf8 );
use C4::Members;
use C4::Letters;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Images;
use Koha::Patrons;
my $input=new CGI;
my $borrowernumber = $input->param('borrowernumber');
#get borrower details
my $borrower = GetMember(borrowernumber => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
my $borrower = $patron->unblessed;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/notices.tt",
@ -46,8 +46,7 @@ my ($template, $loggedinuser, $cookie)
});
$template->param( $borrower );
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
# Allow resending of messages in Notices tab
my $op = $input->param('op') || q{};
@ -78,7 +77,7 @@ $template->param(
QUEUED_MESSAGES => $queued_messages,
borrowernumber => $borrowernumber,
sentnotices => 1,
categoryname => $borrower->{'description'},
categoryname => $patron->category->description,
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -40,6 +40,7 @@ use C4::Stats;
use C4::Koha;
use C4::Overdues;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patrons;
use Koha::Patron::Images;
use Koha::Patron::Categories;
@ -66,7 +67,11 @@ if ( !$borrowernumber ) {
}
# get borrower details
our $borrower = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
our $borrower = $patron->unblessed;
$borrower->{description} = $category->description;
$borrower->{category_type} = $category->category_type;
our $user = $input->remote_user;
$user ||= q{};

View File

@ -29,6 +29,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Accounts;
use C4::Koha;
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Account;
use Koha::Patron::Categories;
@ -48,7 +49,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
# get borrower details
my $borrowernumber = $input->param('borrowernumber');
my $borrower = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $borrower = $patron->unblessed;
my $category = $patron->category;
$borrower->{description} = $category->description;
$borrower->{category_type} = $category->category_type;
my $user = $input->remote_user;
my $branch = C4::Context->userenv->{'branch'};

View File

@ -31,7 +31,7 @@ use CGI qw ( -utf8 );
use C4::Members;
use C4::Accounts;
use Koha::DateUtils;
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Patron::Categories;
my $input=new CGI;
@ -50,8 +50,11 @@ my $borrowernumber=$input->param('borrowernumber');
my $action = $input->param('action') || '';
my $accountlines_id = $input->param('accountlines_id');
#get borrower details
my $data=GetMember('borrowernumber' => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
$data->{category_type} = $category->category_type;
if ( $action eq 'print' ) {
# ReversePayment( $borrowernumber, $input->param('accountno') );
@ -114,8 +117,7 @@ for (my $i=0;$i<$numaccts;$i++){
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
$template->param(
finesview => 1,

View File

@ -29,8 +29,8 @@ use Koha::DateUtils;
use CGI qw ( -utf8 );
use C4::Members;
use C4::Accounts;
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Patron::Categories;
my $input = new CGI;
@ -49,8 +49,11 @@ my $borrowernumber = $input->param('borrowernumber');
my $action = $input->param('action') || '';
my $accountlines_id = $input->param('accountlines_id');
#get borrower details
my $data = GetMember( 'borrowernumber' => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
$data->{category_type} = $category->category_type;
if ( $data->{'category_type'} eq 'C' ) {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
@ -114,8 +117,7 @@ for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
$template->param(
finesview => 1,

View File

@ -26,7 +26,7 @@ use C4::Output;
use C4::Members;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Suggestions;
use Koha::Patron::Images;
use Koha::Patrons;
my $input = new CGI;
@ -43,13 +43,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $borrowernumber = $input->param('borrowernumber');
# Set informations for the patron
my $borrower = GetMember( borrowernumber => $borrowernumber );
foreach my $key ( keys %$borrower ) {
$template->param( $key => $borrower->{$key} );
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
$data->{category_type} = $category->category_type;
foreach my $key ( keys %$data ) {
$template->param( $key => $data->{$key} );
}
$template->param(
suggestionsview => 1,
categoryname => $borrower->{'description'},
categoryname => $data->{'description'},
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
@ -61,8 +65,7 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
);
}
my $patron_image = Koha::Patron::Images->find($borrowernumber);
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );

View File

@ -31,8 +31,8 @@ use C4::Members;
use List::MoreUtils qw/any uniq/;
use Koha::DateUtils;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Patron::Categories;
my $input = CGI->new;
@ -51,14 +51,17 @@ my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name =>
});
my $op = $input->param('op') || '';
my $patron;
if ($input->param('cardnumber')) {
$cardnumber = $input->param('cardnumber');
$data = GetMember(cardnumber => $cardnumber);
$patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
$data = $patron->unblessed;
$borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
}
if ($input->param('borrowernumber')) {
$borrowernumber = $input->param('borrowernumber');
$data = GetMember(borrowernumber => $borrowernumber);
$patron = Koha::Patrons->find( $borrowernumber );
$data = $patron->unblessed;
}
my $order = 'date_due desc';
@ -79,8 +82,7 @@ if ( $op eq 'export_barcodes' ) {
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
my @barcodes =
map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
my $borrowercardnumber =
GetMember( borrowernumber => $borrowernumber )->{'cardnumber'};
my $borrowercardnumber = $data->{cardnumber};
my $delimiter = "\n";
binmode( STDOUT, ":encoding(UTF-8)" );
print $input->header(
@ -106,8 +108,7 @@ if (! $limit){
$limit = 'full';
}
my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);

View File

@ -26,7 +26,7 @@ use C4::Members;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Context;
use C4::Serials;
use Koha::Patron::Images;
use Koha::Patrons;
use CGI::Session;
my $query = new CGI;
@ -49,18 +49,14 @@ my $borrowernumber = $query->param('borrowernumber');
my $branch = C4::Context->userenv->{'branch'};
# get the borrower information.....
my $borrower;
my ( $patron, $patron_info );
if ($borrowernumber) {
$borrower = GetMember( borrowernumber => $borrowernumber );
}
$patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $patron_info = $patron->unblessed;
$patron_info->{description} = $category->description;
$patron_info->{category_type} = $category->category_type;
##################################################################################
# BUILD HTML
# I'm trying to show the title of subscriptions where the borrowernumber is attached via a routing list
if ($borrowernumber) {
# new op dev
my $count;
my @borrowerSubscriptions;
($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
@ -80,19 +76,19 @@ if ($borrowernumber) {
routinglistview => 1
);
$template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' || $borrower->{'category_type'} eq 'I' );
$template->param( adultborrower => 1 ) if ( $patron_info->{category_type} =~ /^(A|I)$/ );
}
##################################################################################
$template->param(%$borrower);
$template->param(%$patron_info);
$template->param(
findborrower => $findborrower,
borrower => $borrower,
borrower => $patron_info,
borrowernumber => $borrowernumber,
branch => $branch,
categoryname => $borrower->{description},
categoryname => $patron_info->{description},
RoutingSerials => C4::Context->preference('RoutingSerials'),
);
@ -104,7 +100,6 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
);
}
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron and $patron->image;
output_html_with_http_headers $query, $cookie, $template->output;

View File

@ -31,7 +31,7 @@ use C4::Members;
use C4::Members::Statistics;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Output;
use Koha::Patron::Images;
use Koha::Patrons;
my $input = new CGI;
@ -48,13 +48,18 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $borrowernumber = $input->param('borrowernumber');
# Set informations for the patron
my $borrower = GetMember( borrowernumber => $borrowernumber );
if ( not defined $borrower ) {
my $patron = Koha::Patrons->find( $borrowernumber );
unless ( $patron ) {
$template->param (unknowuser => 1);
output_html_with_http_headers $input, $cookie, $template->output;
exit;
}
my $category = $patron->category;
my $borrower= $patron->unblessed;
$borrower->{description} = $category->description;
$borrower->{category_type} = $category->category_type;
foreach my $key ( keys %$borrower ) {
$template->param( $key => $borrower->{$key} );
}
@ -92,8 +97,7 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
);
}
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
$template->param( picture => 1 ) if $patron->image;
$template->param(%$borrower);

View File

@ -27,6 +27,7 @@ use C4::Reserves;
use C4::Items;
use Koha::Holds;
use Koha::ItemTypes;
use Koha::Patrons;
my $input = CGI->new;
my $borrowernumber = $input->param('borrowernumber');
@ -42,7 +43,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
my $data = GetMember( 'borrowernumber' => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
$data->{category_type} = $category->category_type;
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
foreach my $accountline (@$accts) {

View File

@ -33,6 +33,7 @@ use C4::Context;
use C4::Auth;
use C4::Output;
use C4::Members;
use Koha::Patrons;
use Koha::Patron::Categories;
# use Smart::Comments;
@ -71,7 +72,8 @@ if ( $op eq 'multi' ) {
}
elsif ( $op eq 'update' ) {
my $member = GetMember('borrowernumber'=>$borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
my $member = $patron->unblessed;
$member->{'guarantorid'} = 0;
$member->{'categorycode'} = $catcode;
my $borcat = Koha::Patron::Categories->find($catcode);

View File

@ -511,9 +511,8 @@ sub get_branch_info {
my ( $borrowernumber ) = @_;
## Get branch info for borrowers home library.
my $borrower_details = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $borrower_branchcode = $borrower_details->{'branchcode'};
my $branch = Koha::Libraries->find( $borrower_branchcode )->unblessed;
my $patron = Koha::Patrons->find( $borrowernumber );
my $branch = $patron->library->unblessed;
my %branch_info;
foreach my $key( keys %$branch ) {
$branch_info{"branches.$key"} = $branch->{$key};

View File

@ -6,9 +6,9 @@ use Pod::Usage;
use Getopt::Long;
use C4::Budgets qw( GetBudget );
use C4::Members qw( GetMember );
use C4::Suggestions qw( GetUnprocessedSuggestions );
use Koha::Libraries;
use Koha::Patrons;
my ( $help, $verbose, $confirm, @days );
GetOptions(
@ -45,38 +45,38 @@ for my $number_of_days (@days) {
say "Suggestion $suggestion->{suggestionid} should be processed" if $verbose;
my $budget = C4::Budgets::GetBudget( $suggestion->{budgetid} );
my $patron = C4::Members::GetMember( borrowernumber => $budget->{budget_owner_id} );
my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
my $email_address =
C4::Members::GetNoticeEmailAddress( $budget->{budget_owner_id} );
my $library = Koha::Libraries->find( $patron->{branchcode} );
my $library = $patron->library;
my $admin_email_address = $library->branchemail
|| C4::Context->preference('KohaAdminEmailAddress');
if ($email_address) {
say "Patron $patron->{borrowernumber} is going to be notified" if $verbose;
say "Patron " . $patron->borrowernumber . " is going to be notified" if $verbose;
my $letter = C4::Letters::GetPreparedLetter(
module => 'suggestions',
letter_code => 'TO_PROCESS',
branchcode => $patron->{branchcode},
lang => $patron->{lang},
branchcode => $patron->branchcode,
lang => $patron->lang,
tables => {
suggestions => $suggestion->{suggestionid},
branches => $patron->{branchcode},
borrowers => $patron->{borrowernumber},
branches => $patron->branchcode,
borrowers => $patron->borrowernumber,
},
);
if ( $confirm ) {
C4::Letters::EnqueueLetter(
{
letter => $letter,
borrowernumber => $patron->{borrowernumber},
borrowernumber => $patron->borrowernumber,
message_transport_type => 'email',
from_address => $admin_email_address,
}
);
}
} else {
say "Patron $patron->{borrowernumber} does not have an email address" if $verbose;
say "Patron " . $patron->borrowernumber . " does not have an email address" if $verbose;
}
}

View File

@ -24,7 +24,7 @@ use Text::CSV;
use Getopt::Long qw(:config no_ignore_case);
use C4::Context;
use C4::Members;
use Koha::Patrons;
binmode STDOUT, ":encoding(UTF-8)";
@ -41,7 +41,7 @@ $0 [--field=FIELD [--field=FIELD [...]]] [--separator=CHAR] [--show-header] [--w
$0 -h
-f, --field=FIELD Field to export. It is repeatable and has to match
keys returned by the GetMember function.
column names of the borrower table (also as 'description' and 'category_type'
If no field is specified, then all fields will be
exported.
-s, --separator=CHAR This character will be used to separate fields.
@ -99,8 +99,13 @@ my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } );
# If the user did not specify any field to export, we assume they want them all
# We retrieve the first borrower informations to get field names
my ($borrowernumber) = $sth->fetchrow_array or die "No borrower to export";
my $member = GetMember($borrowernumber); # FIXME Now is_expired is no longer available
my $patron = Koha::Patrons->find( $borrowernumber ); # FIXME Now is_expired is no longer available
# We will have to use Koha::Patron and allow method calls
my $category = $patron->category;
my $member = $patron->unblessed;
$member->{description} = $category->description;
$member->{category_type} = $category->category_type;
@fields = keys %$member unless (@fields);
if ($show_header) {
@ -121,7 +126,11 @@ die "Invalid character at borrower $borrowernumber: ["
print $csv->string . "\n";
while ( my $borrowernumber = $sth->fetchrow_array ) {
$member = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $member = $patron->unblessed;
$member->{description} = $category->description;
$member->{category_type} = $category->category_type;
$csv->combine(
map {
( defined $member->{$_} and !ref $member->{$_} )

View File

@ -18,8 +18,8 @@ use Data::Dumper;
use HTTP::Cookies;
use C4::Context;
use C4::Debug;
use C4::Members qw ( GetMember );
use URI::Escape;
use Koha::Patrons;
my ($help, $steps, $baseurl, $max_tries, $user, $password,$short_print);
GetOptions(
@ -91,7 +91,7 @@ if( $resp->is_success and $resp->content =~ m|<status>ok</status>| ) {
}
die "You cannot use the database administrator account to launch this script"
unless defined C4::Members::GetMember(userid => $user);
unless defined Koha::Patrons->find( { userid => $user } );
# remove some unnecessary garbage from the cookie
$cookie =~ s/ path_spec; discard; version=0//;

View File

@ -29,6 +29,7 @@ use C4::Context;
use C4::Circulation;
use C4::Members;
use C4::Biblio;
use Koha::Patrons;
use Koha::Items;
@ -49,10 +50,10 @@ for (@$operations) {
my $biblio = $item->biblio;
$_->{'bibliotitle'} = $biblio->title;
$_->{'biblionumber'} = $biblio->biblionumber;
my $borrower = C4::Members::GetMember( cardnumber => $_->{'cardnumber'} );
if ($borrower) {
$_->{'borrowernumber'} = $borrower->{'borrowernumber'};
$_->{'borrower'} = ($borrower->{'firstname'}?$borrower->{'firstname'}:'').' '.$borrower->{'surname'};
my $patron = $_->{cardnumber} ? Koha::Patrons->find( { cardnumber => $_->{cardnumber} } ) : undef;
if ($patron) {
$_->{'borrowernumber'} = $patron->borrowernumber;
$_->{'borrower'} = ($patron->firstname ? $patron->firstname:'').' '.$patron->surname;
}
$_->{'actionissue'} = $_->{'action'} eq 'issue';
$_->{'actionreturn'} = $_->{'action'} eq 'return';

View File

@ -249,7 +249,8 @@ sub kocIssueItem {
$circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
my $branchcode = C4::Context->userenv->{branch};
my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
my $borrower = $patron->unblessed;
my $item = Koha::Items->find({ barcode => $circ->{barcode} });
my $issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
my $biblio = $item->biblio;
@ -331,29 +332,30 @@ sub kocReturnItem {
my $biblio = $item->biblio;
my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
if ( $borrowernumber ) {
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
C4::Circulation::MarkIssueReturned(
$borrowernumber,
$item->itemnumber,
undef,
$circ->{'date'},
$borrower->{'privacy'}
$patron->privacy
);
ModItem({ onloan => undef }, $biblio->biblionumber, $item->itemnumber);
ModDateLastSeen( $item->itemnumber );
push @output, {
return => 1,
title => $biblio->title,
biblionumber => $biblio->biblionumber,
barcode => $item->barcode,
borrowernumber => $borrower->{'borrowernumber'},
firstname => $borrower->{'firstname'},
surname => $borrower->{'surname'},
cardnumber => $borrower->{'cardnumber'},
datetime => $circ->{ 'datetime' }
};
push @output,
{
return => 1,
title => $biblio->title,
biblionumber => $biblio->biblionumber,
barcode => $item->barcode,
borrowernumber => $patron->borrowernumber,
firstname => $patron->firstname,
surname => $patron->surname,
cardnumber => $patron->cardnumber,
datetime => $circ->{'datetime'}
};
} else {
push @output, {
ERROR_no_borrower_from_item => 1,

View File

@ -52,8 +52,8 @@ use C4::Reserves;
use C4::Acquisition;
use C4::Serials; # uses getsubscriptionfrom biblionumber
use C4::Koha;
use C4::Members; # GetMember
use Koha::ItemTypes;
use Koha::Patrons;
use Koha::RecordProcessor;
@ -164,7 +164,7 @@ my $res = GetISBDView({
});
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
my $patron = Koha::Patrons->find( $loggedinuser );
for my $itm (@items) {
$norequests = 0
if $norequests
@ -174,7 +174,7 @@ for my $itm (@items) {
&& !$itemtypes->{$itm->{'itype'}}->{notforloan}
&& $itm->{'itemnumber'};
$allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
$allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $patron->unblessed)
unless $allow_onshelf_holds;
}

View File

@ -57,6 +57,7 @@ use C4::Members;
use C4::Acquisition;
use C4::Koha;
use List::MoreUtils qw( any uniq );
use Koha::Patrons;
use Koha::RecordProcessor;
my $query = new CGI;
@ -126,9 +127,9 @@ if(my $cart_list = $query->cookie("bib_list")){
}
my $allow_onshelf_holds;
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
for my $itm (@all_items) {
$allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower);
$allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $patron);
last if $allow_onshelf_holds;
}

View File

@ -29,9 +29,9 @@ use URI;
use C4::Auth;
use C4::Output;
use C4::Accounts;
use C4::Members;
use Koha::Acquisition::Currencies;
use Koha::Database;
use Koha::Patrons;
my $cgi = new CGI;
@ -117,8 +117,9 @@ else {
$error = "PAYPAL_UNABLE_TO_CONNECT";
}
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param(
borrower => GetMember( borrowernumber => $borrowernumber ),
borrower => $patron->unblessed,
accountview => 1
);

View File

@ -19,12 +19,12 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Members;
use C4::Auth;
use C4::Output;
use warnings;
use Koha::Patrons;
my $query = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
@ -37,7 +37,11 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $category = $patron->category;
my $borrower= $patron->unblessed;
$borrower->{description} = $category->description;
$borrower->{category_type} = $category->category_type;
$template->param( BORROWER_INFO => $borrower );
#get account details

View File

@ -53,6 +53,7 @@ use Koha::AuthorisedValues;
use Koha::Biblios;
use Koha::ItemTypes;
use Koha::Virtualshelves;
use Koha::Patrons;
use Koha::Ratings;
use Koha::Reviews;
@ -655,7 +656,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
);
} else {
my $allow_onshelf_holds;
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
for my $itm (@items) {
$itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
$itm->{priority} = $priority{ $itm->{itemnumber} };
@ -667,7 +668,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
&& !$itemtypes->{$itm->{'itype'}}->{notforloan}
&& $itm->{'itemnumber'};
$allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $borrower )
$allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $patron->unblessed )
unless $allow_onshelf_holds;
# get collection code description, too
@ -839,19 +840,19 @@ if ( C4::Context->preference('reviewson') ) {
}
}
for my $review (@$reviews) {
my $borrowerData = GetMember( 'borrowernumber' => $review->{borrowernumber} );
my $patron = Koha::Patrons->find( $review->{borrowernumber} );
# setting some borrower info into this hash
$review->{title} = $borrowerData->{'title'};
$review->{surname} = $borrowerData->{'surname'};
$review->{firstname} = $borrowerData->{'firstname'};
if ( $libravatar_enabled and $borrowerData->{'email'} ) {
$review->{avatarurl} = libravatar_url( email => $borrowerData->{'email'}, https => $ENV{HTTPS} );
$review->{title} = $patron->title;
$review->{surname} = $patron->surname;
$review->{firstname} = $patron->firstname;
if ( $libravatar_enabled and $patron->email ) {
$review->{avatarurl} = libravatar_url( email => $patron->email, https => $ENV{HTTPS} );
}
$review->{userid} = $borrowerData->{'userid'};
$review->{cardnumber} = $borrowerData->{'cardnumber'};
$review->{userid} = $patron->userid;
$review->{cardnumber} = $patron->cardnumber;
if ( $borrowerData->{'borrowernumber'} eq $borrowernumber ) {
if ( $patron->borrowernumber eq $borrowernumber ) {
$review->{your_comment} = 1;
$loggedincommenter = 1;
}

View File

@ -26,7 +26,7 @@ use C4::Context;
use C4::Output;
use C4::Log;
use C4::Debug;
use C4::Members;
use Koha::Patrons;
use Koha::Patron::Discharge;
use Koha::DateUtils;
@ -63,10 +63,10 @@ elsif ( $op eq 'get' ) {
eval {
# Getting member data
my $data = GetMember( borrowernumber => $loggedinuser );
my $patron = Koha::Patrons->find( $loggedinuser );
my $pdf_path = Koha::Patron::Discharge::generate_as_pdf({
borrowernumber => $loggedinuser,
branchcode => $data->{'branchcode'},
branchcode => $patron->branchcode,
});
binmode(STDOUT);

View File

@ -208,8 +208,8 @@ if ( $action eq 'create' ) {
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if $borrowernumber && C4::Context->preference('EnhancedMessagingPreferences');
$template->param( password_cleartext => $password );
$template->param(
borrower => GetMember( borrowernumber => $borrowernumber ) );
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param( borrower => $patron->unblessed );
$template->param(
PatronSelfRegistrationAdditionalInstructions =>
C4::Context->preference(
@ -220,7 +220,7 @@ if ( $action eq 'create' ) {
}
elsif ( $action eq 'update' ) {
my $borrower = GetMember( borrowernumber => $borrowernumber );
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
die "Wrong CSRF token"
unless Koha::Token->new->check_csrf({
session_id => scalar $cgi->cookie('CGISESSID'),
@ -277,15 +277,15 @@ elsif ( $action eq 'update' ) {
my $m = Koha::Patron::Modification->new( \%borrower_changes )->store();
$template->param(
borrower => GetMember( borrowernumber => $borrowernumber ),
);
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param( borrower => $patron->unblessed );
}
else {
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param(
action => 'edit',
nochanges => 1,
borrower => GetMember( borrowernumber => $borrowernumber ),
borrower => $patron->unblessed,
patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber, $attributes ),
csrf_token => Koha::Token->new->generate_csrf({
session_id => scalar $cgi->cookie('CGISESSID'),
@ -295,7 +295,8 @@ elsif ( $action eq 'update' ) {
}
}
elsif ( $action eq 'edit' ) { #Display logged in borrower's data
my $borrower = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $borrower = $patron->unblessed;
$template->param(
borrower => $borrower,
@ -307,8 +308,7 @@ elsif ( $action eq 'edit' ) { #Display logged in borrower's data
);
if (C4::Context->preference('OPACpatronimages')) {
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
$template->param( display_patron_image => 1 ) if $patron_image;
$template->param( display_patron_image => 1 ) if $patron->image;
}
$template->param( patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber ) );
@ -450,7 +450,8 @@ sub ParseCgiForBorrower {
sub DelUnchangedFields {
my ( $borrowernumber, %new_data ) = @_;
my $current_data = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $current_data = $patron->unblessed;
foreach my $key ( keys %new_data ) {
if ( $current_data->{$key} eq $new_data{$key} ) {

View File

@ -50,7 +50,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) {
@ -63,7 +63,8 @@ if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) {
smsalertnumber => $sms,
sms_provider_id => $sms_provider_id,
);
$borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
# FIXME will not be needed when ModMember will be replaced
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
}
C4::Form::MessagingPreferences::handle_form_action($query, { borrowernumber => $borrowernumber }, $template);

View File

@ -30,6 +30,7 @@ use C4::Circulation;
use C4::Members;
use C4::Output;
use Koha::AuthUtils qw(hash_password);
use Koha::Patrons;
my $query = new CGI;
my $dbh = C4::Context->dbh;
@ -44,7 +45,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
my $borr = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $minpasslen = C4::Context->preference("minPasswordLength");
if ( C4::Context->preference("OpacPasswordChange") ) {
my $sth = $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?");
@ -103,8 +104,8 @@ if ( C4::Context->preference("OpacPasswordChange") ) {
}
}
}
$template->param(firstname => $borr->{'firstname'},
surname => $borr->{'surname'},
$template->param(firstname => $patron->firstname,
surname => $patron->surname,
minpasslen => $minpasslen,
passwdview => 1,
);

View File

@ -31,6 +31,7 @@ use MARC::Record;
use C4::Output;
use C4::Charset qw(StripNonXmlChars);
use Koha::Patrons;
use Koha::ItemTypes;
@ -52,8 +53,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
# get borrower information ....
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
$template->param(%{$borr});

View File

@ -23,6 +23,7 @@ use C4::Auth;
use C4::Output;
use C4::Members;
use C4::Form::MessagingPreferences;
use Koha::Patrons;
use Koha::Patron::Modifications;
my $cgi = new CGI;
@ -60,8 +61,8 @@ if ( $m ) {
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
$template->param( password_cleartext => $password );
$template->param(
borrower => GetMember( borrowernumber => $borrowernumber ) );
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param( borrower => $patron->unblessed );
$template->param(
PatronSelfRegistrationAdditionalInstructions =>
C4::Context->preference(

View File

@ -70,8 +70,7 @@ else {
$branchcode = $item->{'homebranch'};
}
elsif ( $renewalbranch eq 'patronhomebranch' ) {
my $borrower = GetMember( borrowernumber => $borrowernumber );
$branchcode = $borrower->{'branchcode'};
$branchcode = Koha::Patrons->find( $borrowernumber )->branchcode;
}
elsif ( $renewalbranch eq 'checkoutbranch' ) {
my $issue = GetOpenIssue($itemnumber);

View File

@ -73,15 +73,14 @@ sub get_out {
exit;
}
# get borrower information ....
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
unless ( $can_place_hold_if_available_at_pickup ) {
my @patron_categories = split '\|', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
if ( @patron_categories ) {
$can_place_hold_if_available_at_pickup = grep /$borr->{categorycode}/, @patron_categories;
my $categorycode = $patron->categorycode;
$can_place_hold_if_available_at_pickup = grep /^$categorycode$/, @patron_categories;
}
}
@ -135,7 +134,7 @@ if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
# pass the pickup branch along....
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '' ;
$template->param( branch => $branch );
# Is the person allowed to choose their branch
@ -240,7 +239,7 @@ if ( $query->param('place_reserve') ) {
my $singleBranchMode = Koha::Libraries->search->count == 1;
if ( $singleBranchMode || !$OPACChooseBranch )
{ # single branch mode or disabled user choosing
$branch = $borr->{'branchcode'};
$branch = $patron->branchcode;
}
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
@ -336,7 +335,7 @@ if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
$template->param( too_much_oweing => $amount );
}
if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) {
if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
$noreserves = 1;
$template->param(
message => 1,
@ -344,7 +343,7 @@ if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) {
);
}
if ( $borr->{lost} && ($borr->{lost} == 1) ) {
if ( $patron->lost && ($patron->lost == 1) ) {
$noreserves = 1;
$template->param(
message => 1,
@ -357,8 +356,8 @@ if ( $patron->is_debarred ) {
$template->param(
message => 1,
debarred => 1,
debarred_comment => $borr->{debarredcomment},
debarred_date => $borr->{debarred},
debarred_comment => $patron->debarredcomment,
debarred_date => $patron->debarred,
);
}
@ -478,12 +477,12 @@ foreach my $biblioNum (@biblionumbers) {
my $holds = $item->current_holds;
if ( my $first_hold = $holds->next ) {
my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
$itemLoopIter->{backgroundcolor} = 'reserved';
$itemLoopIter->{reservedate} = output_pref({ dt => dt_from_string($first_hold->reservedate), dateonly => 1 }); # FIXME Should be formatted in the template
$itemLoopIter->{ReservedForBorrowernumber} = $first_hold->borrowernumber;
$itemLoopIter->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$itemLoopIter->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
$itemLoopIter->{ReservedForSurname} = $patron->surname;
$itemLoopIter->{ReservedForFirstname} = $patron->firstname;
$itemLoopIter->{ExpectedAtLibrary} = $first_hold->branchcode;
$itemLoopIter->{waitingdate} = $first_hold->waitingdate;
}
@ -529,15 +528,16 @@ foreach my $biblioNum (@biblionumbers) {
# If there is no loan, return and transfer, we show a checkbox.
$itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
my $branch = GetReservesControlBranch( $itemInfo, $borr );
my $patron_unblessed = $patron->unblessed;
my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
my $policy_holdallowed = !$itemLoopIter->{already_reserved};
$policy_holdallowed &&=
IsAvailableForItemLevelRequest($itemInfo,$borr) &&
IsAvailableForItemLevelRequest($itemInfo,$patron_unblessed) &&
CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
if ($policy_holdallowed) {
if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $borr ) ) {
if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $patron_unblessed ) ) {
$itemLoopIter->{available} = 1;
$numCopiesOPACAvailable++;
$biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';

View File

@ -33,6 +33,7 @@ use C4::Output;
use C4::Members;
use C4::Templates ();
use Koha::Email;
use Koha::Patrons;
use Koha::Token;
my $query = new CGI;
@ -57,11 +58,11 @@ if ( $email_add ) {
token => scalar $query->param('csrf_token'),
});
my $email = Koha::Email->new();
my $user = GetMember(borrowernumber => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
my $user_email = GetFirstValidEmailAddress($borrowernumber)
|| C4::Context->preference('KohaAdminEmailAddress');
my $email_replyto = "$user->{firstname} $user->{surname} <$user_email>";
my $email_replyto = $patron->firstname . " " . $patron->surname . " <$user_email>";
my $comment = $query->param('comment');
# if you want to use the KohaAdmin address as from, that is the default no need to set it
@ -114,8 +115,8 @@ if ( $email_add ) {
$template2->param(
BIBLIO_RESULTS => $resultsarray,
comment => $comment,
firstname => $user->{firstname},
surname => $user->{surname},
firstname => $patron->firstname,
surname => $patron->surname,
);
# Getting template result

View File

@ -33,6 +33,7 @@ use C4::Items;
use C4::Output;
use C4::Members;
use Koha::Email;
use Koha::Patrons;
use Koha::Virtualshelves;
my $query = new CGI;
@ -109,14 +110,14 @@ if ( $email ) {
push( @results, $dat );
}
my $user = GetMember(borrowernumber => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber );
$template2->param(
BIBLIO_RESULTS => \@results,
comment => $comment,
shelfname => $shelf->shelfname,
firstname => $user->{firstname},
surname => $user->{surname},
firstname => $patron->firstname,
surname => $patron->surname,
);
# Getting template result

View File

@ -32,6 +32,7 @@ use C4::XSLT;
use Koha::Biblioitems;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Patrons;
use Koha::Virtualshelves;
use Koha::RecordProcessor;
@ -68,7 +69,7 @@ if ( $op eq 'add_form' ) {
if ( $shelf ) {
$category = $shelf->category;
my $patron = GetMember( 'borrowernumber' => $shelf->owner );
my $patron = Koha::Patrons->find( $shelf->owner );
$template->param( owner => $patron, );
unless ( $shelf->can_be_managed( $loggedinuser ) ) {
push @messages, { type => 'error', code => 'unauthorized_on_update' };
@ -257,7 +258,7 @@ if ( $op eq 'view' ) {
@cart_list = split(/\//, $cart_list);
}
my $borrower = GetMember( borrowernumber => $loggedinuser );
my $patron = Koha::Patrons->find( $loggedinuser );
# Lists display falls back to search results configuration
my $xslfile = C4::Context->preference('OPACXSLTListsDisplay');
@ -314,7 +315,7 @@ if ( $op eq 'view' ) {
});
}
$this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
$this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($this_item, $patron);
if ( grep {$_ eq $biblionumber} @cart_list) {

View File

@ -27,8 +27,8 @@ use C4::Koha;
use C4::Output;
use C4::Circulation;
use C4::Biblio;
use C4::Members qw/GetMember/;
use Koha::DateUtils;
use Koha::Patrons;
use Koha::Reviews;
use POSIX qw(ceil floor strftime);
@ -92,7 +92,7 @@ for my $result (@$reviews){
my $bib = &GetBiblioData($biblionumber);
my $record = GetMarcBiblio($biblionumber);
my $frameworkcode = GetFrameworkCode($biblionumber);
my ( $borr ) = GetMember( borrowernumber => $result->{borrowernumber} );
my $borr = Koha::Patrons->find( $result->{borrowernumber} )->unblessed;
$result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour);
$result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour);
$result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour);

View File

@ -30,6 +30,7 @@ use C4::Scrubber;
use Koha::AuthorisedValues;
use Koha::Libraries;
use Koha::Patrons;
use Koha::DateUtils qw( dt_from_string );
@ -195,14 +196,17 @@ my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
# Is the person allowed to choose their branch
if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
# pass the pickup branch along....
my $userbranch = '';
if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
$userbranch = C4::Context->userenv->{'branch'};
}
my $branchcode = $input->param('branchcode') || $borr->{'branchcode'} || $userbranch || '' ;
my $branchcode = $input->param('branchcode');
unless ( $branchcode ) {
my $patron = Koha::Patrons->find( $borrowernumber );
$branchcode = $patron->branchcode || $userbranch || '' ;
}
$template->param( branchcode => $branchcode );
}

View File

@ -88,7 +88,7 @@ if (!$borrowernumber) {
}
# get borrower information ....
my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
my ( $today_year, $today_month, $today_day) = Today();
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};

View File

@ -45,6 +45,7 @@ use C4::Biblio;
use C4::Items;
use Koha::DateUtils qw( dt_from_string );
use Koha::Acquisition::Currencies;
use Koha::Patrons;
use Koha::Patron::Images;
use Koha::Patron::Messages;
use Koha::Token;
@ -106,15 +107,14 @@ my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed) = (
);
my $issuenoconfirm = 1; #don't need to confirm on issue.
#warn "issuerid: " . $issuerid;
my $issuer = GetMember( borrowernumber => $issuerid );
my $issuer = Koha::Patrons->find( $issuerid )->unblessed;
my $item = GetItem(undef,$barcode);
if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) {
my $dbh = C4::Context->dbh;
my $resval;
($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw);
}
my $borrower = GetMember( cardnumber => $patronid );
my $borrower = Koha::Patrons->find( { cardnumber => $patronid } )->unblessed;
my $currencySymbol = "";
if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) {
@ -132,7 +132,7 @@ if ($op eq "logout") {
elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
my ($doreturn) = AddReturn( $barcode, $branch );
#warn "returnbook: " . $doreturn;
$borrower = GetMember( cardnumber => $patronid );
$borrower = Koha::Patrons->find( { cardnumber => $patronid } )->unblessed;
}
elsif ( $op eq "checkout" ) {
my $impossible = {};

View File

@ -29,10 +29,10 @@ use autouse 'Data::Dumper' => qw(Dumper);
use C4::Debug;
use C4::Context;
use autouse 'C4::Members' => qw(GetMember);
use C4::Creators;
use C4::Patroncards;
use Koha::List::Patron;
use Koha::Patrons;
use Koha::Patron::Images;
my $cgi = new CGI;
@ -135,7 +135,7 @@ foreach my $item (@{$items}) {
$cardscount ++;
my $borrower_number = $item->{'borrower_number'};
my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
my $card_number = Koha::Patrons->find( $borrower_number)->cardnumber;
# Set barcode data
$print_layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $print_layout_xml->{'barcode'};

View File

@ -29,7 +29,8 @@ use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
use C4::Creators;
use C4::Patroncards;
use C4::Members qw(GetMember);
use Koha::Patrons;
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@ -84,7 +85,7 @@ if ($bor_num_list) {
my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a <cr> separated list
foreach my $number (@bor_nums_unchecked) {
$number =~ s/\r$//; # strip any naughty return chars
if ( GetMember(borrowernumber => $number)) { # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm
if ( Koha::Patrons->find( $number )) { # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm
my $borrower_number = $number;
push @borrower_numbers, $borrower_number;
}

View File

@ -32,6 +32,7 @@ use C4::Reserves;
use C4::Circulation;
use C4::Members;
use C4::Auth qw/checkauth/;
use Koha::Patrons;
my $input = CGI->new();
@ -51,7 +52,8 @@ my $checkitem = $input->param('checkitem');
my $expirationdate = $input->param('expiration_date');
my $itemtype = $input->param('itemtype') || undef;
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
my $borrower = Koha::Patrons->find( $borrowernumber );
$borrower = $borrower->unblessed if $borrower;
my $multi_hold = $input->param('multi_hold');
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
@ -128,7 +130,7 @@ if ( $type eq 'str8' && $borrower ) {
print $input->redirect("request.pl?biblionumber=$biblionumber");
}
}
elsif ( $borrower eq '' ) {
elsif ( $borrowernumber eq '' ) {
print $input->header();
print "Invalid borrower number please try again";

View File

@ -100,9 +100,9 @@ if ( $action eq 'move' ) {
}
if ($findborrower) {
my $borrower = C4::Members::GetMember( cardnumber => $findborrower );
if ( $borrower ) {
$borrowernumber_hold = $borrower->{borrowernumber};
my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
if ( $patron ) {
$borrowernumber_hold = $patron->borrowernumber;
} else {
my $dt_params = { iDisplayLength => -1 };
my $results = C4::Utils::DataTables::Members::search(
@ -134,14 +134,14 @@ if ($multihold) {
# If we have the borrowernumber because we've performed an action, then we
# don't want to try to place another reserve.
if ($borrowernumber_hold && !$action) {
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold );
my $patron = Koha::Patrons->find( $borrowernumber_hold );
my $diffbranch;
# we check the reserves of the user, and if they can reserve a document
# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
my $reserves_count =
GetReserveCount( $borrowerinfo->{'borrowernumber'} );
GetReserveCount( $patron->borrowernumber );
my $new_reserves_count = scalar( @biblionumbers );
@ -164,7 +164,7 @@ if ($borrowernumber_hold && !$action) {
}
# we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
my $expiry_date = $borrowerinfo->{dateexpiry};
my $expiry_date = $patron->dateexpiry;
my $expiry = 0; # flag set if patron account has expired
if ($expiry_date and $expiry_date ne '0000-00-00' and
Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
@ -172,38 +172,37 @@ if ($borrowernumber_hold && !$action) {
}
# check if the borrower make the reserv in a different branch
if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) {
if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
$diffbranch = 1;
}
my $is_debarred = Koha::Patrons->find( $borrowerinfo->{borrowernumber} )->is_debarred;
my $is_debarred = $patron->is_debarred;
$template->param(
borrowernumber => $borrowerinfo->{'borrowernumber'},
borrowersurname => $borrowerinfo->{'surname'},
borrowerfirstname => $borrowerinfo->{'firstname'},
borrowerstreetaddress => $borrowerinfo->{'address'},
borrowercity => $borrowerinfo->{'city'},
borrowerphone => $borrowerinfo->{'phone'},
borrowermobile => $borrowerinfo->{'mobile'},
borrowerfax => $borrowerinfo->{'fax'},
borrowerphonepro => $borrowerinfo->{'phonepro'},
borroweremail => $borrowerinfo->{'email'},
borroweremailpro => $borrowerinfo->{'emailpro'},
borrowercategory => $borrowerinfo->{'category'},
cardnumber => $borrowerinfo->{'cardnumber'},
borrowernumber => $patron->borrowernumber,
borrowersurname => $patron->surname,
borrowerfirstname => $patron->firstname,
borrowerstreetaddress => $patron->address,
borrowercity => $patron->city,
borrowerphone => $patron->phone,
borrowermobile => $patron->mobile,
borrowerfax => $patron->fax,
borrowerphonepro => $patron->phonepro,
borroweremail => $patron->email,
borroweremailpro => $patron->emailpro,
cardnumber => $patron->cardnumber,
expiry => $expiry,
diffbranch => $diffbranch,
messages => $messages,
warnings => $warnings,
restricted => $is_debarred,
amount_outstanding => GetMemberAccountRecords($borrowerinfo->{borrowernumber}),
amount_outstanding => GetMemberAccountRecords($patron->borrowernumber),
);
}
$template->param( messageborrower => $messageborrower );
# FIXME launch another time GetMember perhaps until
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold );
# FIXME launch another time GetMember perhaps until (Joubu: Why?)
my $patron = Koha::Patrons->find( $borrowernumber_hold );
my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
@ -216,7 +215,7 @@ foreach my $biblionumber (@biblionumbers) {
my $dat = GetBiblioData($biblionumber);
my $canReserve = CanBookBeReserved( $borrowerinfo->{borrowernumber}, $biblionumber );
my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
$canReserve //= '';
if ( $canReserve eq 'OK' ) {
@ -238,7 +237,7 @@ foreach my $biblionumber (@biblionumbers) {
}
my $force_hold_level;
if ( $borrowerinfo->{borrowernumber} ) {
if ( $patron->borrowernumber ) {
# For multiple holds per record, if a patron has previously placed a hold,
# the patron can only place more holds of the same type. That is, if the
# patron placed a record level hold, all the holds the patron places must
@ -246,7 +245,7 @@ foreach my $biblionumber (@biblionumbers) {
# the patron places must be item level
my $holds = Koha::Holds->search(
{
borrowernumber => $borrowerinfo->{borrowernumber},
borrowernumber => $patron->borrowernumber,
biblionumber => $biblionumber,
found => undef,
}
@ -257,7 +256,7 @@ foreach my $biblionumber (@biblionumbers) {
# For a librarian to be able to place multiple record holds for a patron for a record,
# we must find out what the maximum number of holds they can place for the patron is
my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowerinfo->{borrowernumber}, $biblionumber );
my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
$biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
$template->param( max_holds_for_record => $max_holds_for_record );
@ -268,7 +267,7 @@ foreach my $biblionumber (@biblionumbers) {
# patron already has an item from that record checked out
my $alreadypossession;
if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
&& CheckIfIssuedToPatron( $borrowerinfo->{borrowernumber}, $biblionumber ) )
&& CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) )
{
$template->param( alreadypossession => $alreadypossession, );
}
@ -393,13 +392,13 @@ foreach my $biblionumber (@biblionumbers) {
# checking reserve
my $holds = Koha::Items->find( $itemnumber )->current_holds;
if ( my $first_hold = $holds->next ) {
my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
$item->{backgroundcolor} = 'reserved';
$item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
$item->{ReservedForBorrowernumber} = $first_hold->borrowernumber;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
$item->{ReservedForSurname} = $patron->surname;
$item->{ReservedForFirstname} = $patron->firstname;
$item->{ExpectedAtLibrary} = $first_hold->branchcode;
$item->{waitingdate} = $first_hold->waitingdate;
}
@ -452,21 +451,22 @@ foreach my $biblionumber (@biblionumbers) {
}
}
my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
my $patron_unblessed = $patron->unblessed;
my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
my $can_item_be_reserved = CanItemBeReserved( $borrowerinfo->{borrowernumber}, $itemnumber );
my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
$item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
$item->{item_level_holds} = OPACItemHoldsAllowed( $item, $borrowerinfo );
$item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed);
if (
!$item->{cantreserve}
&& !$exceeded_maxreserves
&& IsAvailableForItemLevelRequest($item, $borrowerinfo)
&& IsAvailableForItemLevelRequest($item, $patron_unblessed)
&& $can_item_be_reserved eq 'OK'
)
{
@ -611,8 +611,8 @@ foreach my $biblionumber (@biblionumbers) {
holdsview => 1,
C4::Search::enabled_staff_search_views,
);
if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
$template->param( borrower_branchcode => $borrowerinfo->{'branchcode'},);
if ( $patron ) { # FIXME This test seems very useless
$template->param( borrower_branchcode => $patron->branchcode );
}
$biblioloopiter{biblionumber} = $biblionumber;

View File

@ -21,8 +21,8 @@ use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
use C4::Context;
use C4::Members;
use C4::Biblio;
use Koha::Patrons;
use Koha::Reviews;
my $query = new CGI;
@ -68,12 +68,12 @@ my $reviews = Koha::Reviews->search(
foreach ( @$reviews ) {
my $borrowernumber = $_->{borrowernumber};
my $borrowerData = GetMember('borrowernumber' => $borrowernumber);
my $patron = Koha::Patrons->find( $borrowernumber);
my $biblioData = GetBiblioData($_->{biblionumber});
# setting some borrower info into this hash
$_->{bibliotitle} = $biblioData->{'title'};
$_->{surname} = $borrowerData->{'surname'};
$_->{firstname} = $borrowerData->{'firstname'};
$_->{surname} = $patron->surname;
$_->{firstname} = $patron->firstname;
}
my $url = "/cgi-bin/koha/reviews/reviewswaiting.pl?status=$status";

View File

@ -36,6 +36,7 @@ use URI::Escape;
use Koha::Biblios;
use Koha::Libraries;
use Koha::Patrons;
my $query = new CGI;
my $subscriptionid = $query->param('subscriptionid');
@ -121,7 +122,7 @@ if($ok){
my $memberloop = [];
for my $routing (@routinglist) {
my $member = GetMember( borrowernumber => $routing->{borrowernumber} );
my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed;
$member->{name} = "$member->{firstname} $member->{surname}";
push @{$memberloop}, $member;
}

View File

@ -37,6 +37,7 @@ use C4::Context;
use C4::Members;
use C4::Serials;
use Koha::Patrons;
use URI::Escape;
@ -95,7 +96,7 @@ my ($template, $loggedinuser, $cookie)
my $member_loop = [];
for my $routing ( @routinglist ) {
my $member=GetMember('borrowernumber' => $routing->{borrowernumber});
my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed;
$member->{location} = $member->{branchcode};
if ($member->{firstname} ) {
$member->{name} = $member->{firstname} . q| |;

View File

@ -34,6 +34,7 @@ use Koha::DateUtils qw( dt_from_string );
use Koha::AuthorisedValues;
use Koha::Acquisition::Currencies;
use Koha::Libraries;
use Koha::Patrons;
use URI::Escape;
@ -69,9 +70,9 @@ sub GetCriteriumDesc{
return $av->count ? $av->next->lib : 'Unkown';
}
if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
my $borr=C4::Members::GetMember(borrowernumber=>$criteriumvalue);
return "" unless $borr;
return $$borr{surname} . ", " . $$borr{firstname};
my $patron = Koha::Patrons->find( $criteriumvalue );
return "" unless $patron;
return $patron->surname . ", " . $patron->firstname;
}
if ( $displayby =~ /budgetid/) {
my $budget = GetBudget($criteriumvalue);
@ -281,14 +282,15 @@ if ($op=~/else/) {
foreach my $element ( qw(managedby suggestedby acceptedby) ) {
# $debug || warn $$suggestion_ref{$element};
if ($$suggestion_ref{$element}){
my $member=GetMember(borrowernumber=>$$suggestion_ref{$element});
my $patron = Koha::Patrons->find( $$suggestion_ref{$element} );
my $category = $patron->category;
$template->param(
$element."_borrowernumber"=>$$member{borrowernumber},
$element."_firstname"=>$$member{firstname},
$element."_surname"=>$$member{surname},
$element."_branchcode"=>$$member{branchcode},
$element."_description"=>$$member{description},
$element."_category_type"=>$$member{category_type}
$element."_borrowernumber"=>$patron->borrowernumber,
$element."_firstname"=>$patron->firstname,
$element."_surname"=>$patron->surname,
$element."_branchcode"=>$patron->branchcode,
$element."_description"=>$category->description,
$element."_category_type"=>$category->category_type,
);
}
}

View File

@ -25,6 +25,7 @@ use C4::Output qw( output_with_http_headers );
use C4::Utils::DataTables qw( dt_get_params );
use C4::Utils::DataTables::Members qw( search );
use Koha::DateUtils qw( output_pref dt_from_string );
use Koha::Patrons;
my $input = new CGI;
@ -63,11 +64,11 @@ if ( $searchmember
and $searchfieldstype
and $searchfieldstype eq 'standard' )
{
my $member = C4::Members::GetMember( cardnumber => $searchmember );
my $member = Koha::Patrons->find( { cardnumber => $searchmember } );
$results = {
iTotalRecords => 1,
iTotalDisplayRecords => 1,
patrons => [ $member ],
patrons => [ $member->unblessed ],
} if $member;
}

View File

@ -77,8 +77,6 @@ my $borrowernumber = C4::Members::AddMember(
userid => 'TESTUSERID'
);
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
C4::Acquisition::ModOrderUsers( $ordernumber, $borrowernumber );
my $is_added = grep { /^$borrowernumber$/ } C4::Acquisition::GetOrderUsers( $ordernumber );

View File

@ -35,6 +35,7 @@ use Koha::DateUtils;
use Koha::Database;
use Koha::IssuingRules;
use Koha::Checkouts;
use Koha::Patrons;
use Koha::Subscriptions;
my $schema = Koha::Database->schema;
@ -294,8 +295,8 @@ C4::Context->dbh->do("DELETE FROM accountlines");
my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data);
my $restricted_borrowernumber = AddMember(%restricted_borrower_data);
my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber );
my $restricted_borrower = GetMember( borrowernumber => $restricted_borrowernumber );
my $renewing_borrower = Koha::Patrons->find( $renewing_borrowernumber )->unblessed;
my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed;
my $bibitems = '';
my $priority = '1';
@ -377,7 +378,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');
my $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, borrowernumber => $reserving_borrowernumber});
my $reserving_borrower = GetMember( borrowernumber => $reserving_borrowernumber );
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed;
AddIssue($reserving_borrower, $barcode3);
my $reserve = $dbh->selectrow_hashref(
'SELECT * FROM old_reserves WHERE reserve_id = ?',
@ -841,7 +842,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
);
my $a_borrower_borrowernumber = AddMember(%a_borrower_data);
my $a_borrower = GetMember( borrowernumber => $a_borrower_borrowernumber );
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber )->unblessed;
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 );
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 );
@ -922,7 +923,8 @@ C4::Context->dbh->do("DELETE FROM accountlines");
my $borrowernumber = AddMember(%a_borrower_data);
my $issue = AddIssue( GetMember( borrowernumber => $borrowernumber ), $barcode );
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
my $issue = AddIssue( $borrower, $barcode );
UpdateFine(
{
issue_id => $issue->id(),
@ -992,8 +994,8 @@ C4::Context->dbh->do("DELETE FROM accountlines");
branchcode => $library2->{branchcode},
);
my $borrower1 = GetMember( borrowernumber => $borrowernumber1 );
my $borrower2 = GetMember( borrowernumber => $borrowernumber2 );
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed;
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed;
my $issue = AddIssue( $borrower1, $barcode1 );
@ -1063,7 +1065,8 @@ C4::Context->dbh->do("DELETE FROM accountlines");
branchcode => $branch,
);
my $borrower = GetMember( borrowernumber => $borrowernumber );
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
my $issue = AddIssue( $borrower, $barcode, undef, undef, undef, undef, { onsite_checkout => 1 } );
my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $itemnumber );
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' );
@ -1089,7 +1092,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode} } } );
my $issue = AddIssue( GetMember( borrowernumber => $patron->{borrowernumber} ), $barcode );
my $issue = AddIssue( $patron, $barcode );
UpdateFine(
{
issue_id => $issue->id(),
@ -1393,7 +1396,7 @@ subtest 'MultipleReserves' => sub {
branchcode => $branch,
);
my $renewing_borrowernumber = AddMember(%renewing_borrower_data);
my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber );
my $renewing_borrower = Koha::Patrons->find( $renewing_borrowernumber )->unblessed;
my $issue = AddIssue( $renewing_borrower, $barcode1);
my $datedue = dt_from_string( $issue->date_due() );
is (defined $issue->date_due(), 1, "item 1 checked out");

View File

@ -143,7 +143,6 @@ my $borrower_id1 = C4::Members::AddMember(
categorycode => $samplecat->{categorycode},
branchcode => $samplebranch1->{branchcode},
);
my $borrower_1 = C4::Members::GetMember(borrowernumber => $borrower_id1);
is_deeply(
GetBranchBorrowerCircRule(),

View File

@ -25,6 +25,7 @@ use C4::Biblio;
use C4::Items;
use C4::Members;
use Koha::Library;
use Koha::Patrons;
use MARC::Record;
BEGIN {
@ -74,8 +75,8 @@ AddItem({ barcode => $barcode2, %item_info }, $biblionumber2);
my $borrowernumber1 = AddMember(categorycode => $categorycode, branchcode => $branchcode);
my $borrowernumber2 = AddMember(categorycode => $categorycode, branchcode => $branchcode);
my $borrower1 = GetMember(borrowernumber => $borrowernumber1);
my $borrower2 = GetMember(borrowernumber => $borrowernumber2);
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed;
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed;
my $module = new Test::MockModule('C4::Context');
$module->mock('userenv', sub { { branch => $branchcode } });

View File

@ -26,8 +26,8 @@ use C4::Circulation;
use C4::Items;
use C4::Members;
use Koha::Library;
use Koha::Libraries;
use Koha::Patrons;
use Koha::Patron::Categories;
use MARC::Record;
@ -63,7 +63,7 @@ my $borrowernumber = $builder->build(
}
)->{borrowernumber};
my $borrower = GetMember(borrowernumber => $borrowernumber);
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
# Need to mock userenv for AddIssue
my $module = new Test::MockModule('C4::Context');

Some files were not shown because too many files have changed in this diff Show More