Lines 590-608
sub ModMember {
Link Here
|
590 |
$new_borrower->{dateexpiry} ||= undef if exists $new_borrower->{dateexpiry}; |
590 |
$new_borrower->{dateexpiry} ||= undef if exists $new_borrower->{dateexpiry}; |
591 |
$new_borrower->{debarred} ||= undef if exists $new_borrower->{debarred}; |
591 |
$new_borrower->{debarred} ||= undef if exists $new_borrower->{debarred}; |
592 |
$new_borrower->{sms_provider_id} ||= undef if exists $new_borrower->{sms_provider_id}; |
592 |
$new_borrower->{sms_provider_id} ||= undef if exists $new_borrower->{sms_provider_id}; |
|
|
593 |
$new_borrower->{guarantorid} ||= undef if exists $new_borrower->{guarantorid}; |
593 |
|
594 |
|
594 |
my $rs = $schema->resultset('Borrower')->search({ |
595 |
my $patron = Koha::Patrons->find( $new_borrower->{borrowernumber} ); |
595 |
borrowernumber => $new_borrower->{borrowernumber}, |
|
|
596 |
}); |
597 |
|
596 |
|
598 |
delete $new_borrower->{userid} if exists $new_borrower->{userid} and not $new_borrower->{userid}; |
597 |
delete $new_borrower->{userid} if exists $new_borrower->{userid} and not $new_borrower->{userid}; |
599 |
|
598 |
|
600 |
my $execute_success = $rs->update($new_borrower); |
599 |
my $execute_success = $patron->store if $patron->set($new_borrower); |
601 |
if ($execute_success ne '0E0') { # only proceed if the update was a success |
600 |
|
|
|
601 |
if ($execute_success) { # only proceed if the update was a success |
602 |
# If the patron changes to a category with enrollment fee, we add a fee |
602 |
# If the patron changes to a category with enrollment fee, we add a fee |
603 |
if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { |
603 |
if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { |
604 |
if ( C4::Context->preference('FeeOnChangePatronCategory') ) { |
604 |
if ( C4::Context->preference('FeeOnChangePatronCategory') ) { |
605 |
AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); |
605 |
$patron->add_enrolment_fee_if_needed; |
606 |
} |
606 |
} |
607 |
} |
607 |
} |
608 |
|
608 |
|
Lines 690-697
sub AddMember {
Link Here
|
690 |
$new_member->{checkprevcheckout} ||= 'inherit'; |
690 |
$new_member->{checkprevcheckout} ||= 'inherit'; |
691 |
delete $new_member->{borrowernumber}; |
691 |
delete $new_member->{borrowernumber}; |
692 |
|
692 |
|
693 |
my $rs = $schema->resultset('Borrower'); |
693 |
my $patron = Koha::Patron->new($new_member)->store; |
694 |
$data{borrowernumber} = $rs->create($new_member)->id; |
694 |
$data{borrowernumber} = $patron->id; |
695 |
|
695 |
|
696 |
# If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a |
696 |
# If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a |
697 |
# cronjob will use for syncing with NL |
697 |
# cronjob will use for syncing with NL |
Lines 705-714
sub AddMember {
Link Here
|
705 |
}); |
705 |
}); |
706 |
} |
706 |
} |
707 |
|
707 |
|
708 |
# mysql_insertid is probably bad. not necessarily accurate and mysql-specific at best. |
|
|
709 |
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); |
708 |
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); |
710 |
|
709 |
|
711 |
AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); |
710 |
$patron->add_enrolment_fee_if_needed; |
712 |
|
711 |
|
713 |
return $data{borrowernumber}; |
712 |
return $data{borrowernumber}; |
714 |
} |
713 |
} |
Lines 1968-2002
sub AddMember_Opac {
Link Here
|
1968 |
return ( $borrowernumber, $borrower{'password'} ); |
1967 |
return ( $borrowernumber, $borrower{'password'} ); |
1969 |
} |
1968 |
} |
1970 |
|
1969 |
|
1971 |
=head2 AddEnrolmentFeeIfNeeded |
|
|
1972 |
|
1973 |
AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} ); |
1974 |
|
1975 |
Add enrolment fee for a patron if needed. |
1976 |
|
1977 |
=cut |
1978 |
|
1979 |
sub AddEnrolmentFeeIfNeeded { |
1980 |
my ( $categorycode, $borrowernumber ) = @_; |
1981 |
# check for enrollment fee & add it if needed |
1982 |
my $dbh = C4::Context->dbh; |
1983 |
my $sth = $dbh->prepare(q{ |
1984 |
SELECT enrolmentfee |
1985 |
FROM categories |
1986 |
WHERE categorycode=? |
1987 |
}); |
1988 |
$sth->execute( $categorycode ); |
1989 |
if ( $sth->err ) { |
1990 |
warn sprintf('Database returned the following error: %s', $sth->errstr); |
1991 |
return; |
1992 |
} |
1993 |
my ($enrolmentfee) = $sth->fetchrow; |
1994 |
if ($enrolmentfee && $enrolmentfee > 0) { |
1995 |
# insert fee in patron debts |
1996 |
C4::Accounts::manualinvoice( $borrowernumber, '', '', 'A', $enrolmentfee ); |
1997 |
} |
1998 |
} |
1999 |
|
2000 |
=head2 HasOverdues |
1970 |
=head2 HasOverdues |
2001 |
|
1971 |
|
2002 |
=cut |
1972 |
=cut |