Lines 535-553
sub ModMember {
Link Here
|
535 |
$new_borrower->{dateexpiry} ||= undef if exists $new_borrower->{dateexpiry}; |
535 |
$new_borrower->{dateexpiry} ||= undef if exists $new_borrower->{dateexpiry}; |
536 |
$new_borrower->{debarred} ||= undef if exists $new_borrower->{debarred}; |
536 |
$new_borrower->{debarred} ||= undef if exists $new_borrower->{debarred}; |
537 |
$new_borrower->{sms_provider_id} ||= undef if exists $new_borrower->{sms_provider_id}; |
537 |
$new_borrower->{sms_provider_id} ||= undef if exists $new_borrower->{sms_provider_id}; |
|
|
538 |
$new_borrower->{guarantorid} ||= undef if exists $new_borrower->{guarantorid}; |
538 |
|
539 |
|
539 |
my $rs = $schema->resultset('Borrower')->search({ |
540 |
my $patron = Koha::Patrons->find( $new_borrower->{borrowernumber} ); |
540 |
borrowernumber => $new_borrower->{borrowernumber}, |
|
|
541 |
}); |
542 |
|
541 |
|
543 |
delete $new_borrower->{userid} if exists $new_borrower->{userid} and not $new_borrower->{userid}; |
542 |
delete $new_borrower->{userid} if exists $new_borrower->{userid} and not $new_borrower->{userid}; |
544 |
|
543 |
|
545 |
my $execute_success = $rs->update($new_borrower); |
544 |
my $execute_success = $patron->store if $patron->set($new_borrower); |
546 |
if ($execute_success ne '0E0') { # only proceed if the update was a success |
545 |
|
|
|
546 |
if ($execute_success) { # only proceed if the update was a success |
547 |
# If the patron changes to a category with enrollment fee, we add a fee |
547 |
# If the patron changes to a category with enrollment fee, we add a fee |
548 |
if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { |
548 |
if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { |
549 |
if ( C4::Context->preference('FeeOnChangePatronCategory') ) { |
549 |
if ( C4::Context->preference('FeeOnChangePatronCategory') ) { |
550 |
AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); |
550 |
$patron->add_enrolment_fee_if_needed; |
551 |
} |
551 |
} |
552 |
} |
552 |
} |
553 |
|
553 |
|
Lines 651-660
sub AddMember {
Link Here
|
651 |
}); |
651 |
}); |
652 |
} |
652 |
} |
653 |
|
653 |
|
654 |
# mysql_insertid is probably bad. not necessarily accurate and mysql-specific at best. |
|
|
655 |
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); |
654 |
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); |
656 |
|
655 |
|
657 |
AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); |
656 |
$patron->add_enrolment_fee_if_needed; |
658 |
|
657 |
|
659 |
return $data{borrowernumber}; |
658 |
return $data{borrowernumber}; |
660 |
} |
659 |
} |
Lines 1680-1714
sub AddMember_Opac {
Link Here
|
1680 |
return ( $borrowernumber, $borrower{'password'} ); |
1679 |
return ( $borrowernumber, $borrower{'password'} ); |
1681 |
} |
1680 |
} |
1682 |
|
1681 |
|
1683 |
=head2 AddEnrolmentFeeIfNeeded |
|
|
1684 |
|
1685 |
AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} ); |
1686 |
|
1687 |
Add enrolment fee for a patron if needed. |
1688 |
|
1689 |
=cut |
1690 |
|
1691 |
sub AddEnrolmentFeeIfNeeded { |
1692 |
my ( $categorycode, $borrowernumber ) = @_; |
1693 |
# check for enrollment fee & add it if needed |
1694 |
my $dbh = C4::Context->dbh; |
1695 |
my $sth = $dbh->prepare(q{ |
1696 |
SELECT enrolmentfee |
1697 |
FROM categories |
1698 |
WHERE categorycode=? |
1699 |
}); |
1700 |
$sth->execute( $categorycode ); |
1701 |
if ( $sth->err ) { |
1702 |
warn sprintf('Database returned the following error: %s', $sth->errstr); |
1703 |
return; |
1704 |
} |
1705 |
my ($enrolmentfee) = $sth->fetchrow; |
1706 |
if ($enrolmentfee && $enrolmentfee > 0) { |
1707 |
# insert fee in patron debts |
1708 |
C4::Accounts::manualinvoice( $borrowernumber, '', '', 'A', $enrolmentfee ); |
1709 |
} |
1710 |
} |
1711 |
|
1712 |
=head2 DeleteExpiredOpacRegistrations |
1682 |
=head2 DeleteExpiredOpacRegistrations |
1713 |
|
1683 |
|
1714 |
Delete accounts that haven't been upgraded from the 'temporary' category |
1684 |
Delete accounts that haven't been upgraded from the 'temporary' category |