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