Lines 627-645
sub ModMember {
Link Here
|
627 |
$new_borrower->{dateexpiry} ||= undef if exists $new_borrower->{dateexpiry}; |
627 |
$new_borrower->{dateexpiry} ||= undef if exists $new_borrower->{dateexpiry}; |
628 |
$new_borrower->{debarred} ||= undef if exists $new_borrower->{debarred}; |
628 |
$new_borrower->{debarred} ||= undef if exists $new_borrower->{debarred}; |
629 |
$new_borrower->{sms_provider_id} ||= undef if exists $new_borrower->{sms_provider_id}; |
629 |
$new_borrower->{sms_provider_id} ||= undef if exists $new_borrower->{sms_provider_id}; |
|
|
630 |
$new_borrower->{guarantorid} ||= undef if exists $new_borrower->{guarantorid}; |
630 |
|
631 |
|
631 |
my $rs = $schema->resultset('Borrower')->search({ |
632 |
my $patron = Koha::Patrons->find( $new_borrower->{borrowernumber} ); |
632 |
borrowernumber => $new_borrower->{borrowernumber}, |
|
|
633 |
}); |
634 |
|
633 |
|
635 |
delete $new_borrower->{userid} if exists $new_borrower->{userid} and not $new_borrower->{userid}; |
634 |
delete $new_borrower->{userid} if exists $new_borrower->{userid} and not $new_borrower->{userid}; |
636 |
|
635 |
|
637 |
my $execute_success = $rs->update($new_borrower); |
636 |
my $execute_success = $patron->store if $patron->set($new_borrower); |
638 |
if ($execute_success ne '0E0') { # only proceed if the update was a success |
637 |
|
|
|
638 |
if ($execute_success) { # only proceed if the update was a success |
639 |
# If the patron changes to a category with enrollment fee, we add a fee |
639 |
# If the patron changes to a category with enrollment fee, we add a fee |
640 |
if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { |
640 |
if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { |
641 |
if ( C4::Context->preference('FeeOnChangePatronCategory') ) { |
641 |
if ( C4::Context->preference('FeeOnChangePatronCategory') ) { |
642 |
AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); |
642 |
$patron->add_enrolment_fee_if_needed; |
643 |
} |
643 |
} |
644 |
} |
644 |
} |
645 |
|
645 |
|
Lines 726-733
sub AddMember {
Link Here
|
726 |
my $new_member = { map { join(' ',@columns) =~ /$_/ ? ( $_ => $data{$_} ) : () } keys(%data) } ; |
726 |
my $new_member = { map { join(' ',@columns) =~ /$_/ ? ( $_ => $data{$_} ) : () } keys(%data) } ; |
727 |
delete $new_member->{borrowernumber}; |
727 |
delete $new_member->{borrowernumber}; |
728 |
|
728 |
|
729 |
my $rs = $schema->resultset('Borrower'); |
729 |
my $patron = Koha::Patron->new($new_member)->store; |
730 |
$data{borrowernumber} = $rs->create($new_member)->id; |
730 |
$data{borrowernumber} = $patron->id; |
731 |
|
731 |
|
732 |
# If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a |
732 |
# If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a |
733 |
# cronjob will use for syncing with NL |
733 |
# cronjob will use for syncing with NL |
Lines 741-750
sub AddMember {
Link Here
|
741 |
}); |
741 |
}); |
742 |
} |
742 |
} |
743 |
|
743 |
|
744 |
# mysql_insertid is probably bad. not necessarily accurate and mysql-specific at best. |
|
|
745 |
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); |
744 |
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); |
746 |
|
745 |
|
747 |
AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); |
746 |
$patron->add_enrolment_fee_if_needed; |
748 |
|
747 |
|
749 |
return $data{borrowernumber}; |
748 |
return $data{borrowernumber}; |
750 |
} |
749 |
} |
Lines 2119-2153
sub AddMember_Opac {
Link Here
|
2119 |
return ( $borrowernumber, $borrower{'password'} ); |
2118 |
return ( $borrowernumber, $borrower{'password'} ); |
2120 |
} |
2119 |
} |
2121 |
|
2120 |
|
2122 |
=head2 AddEnrolmentFeeIfNeeded |
|
|
2123 |
|
2124 |
AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} ); |
2125 |
|
2126 |
Add enrolment fee for a patron if needed. |
2127 |
|
2128 |
=cut |
2129 |
|
2130 |
sub AddEnrolmentFeeIfNeeded { |
2131 |
my ( $categorycode, $borrowernumber ) = @_; |
2132 |
# check for enrollment fee & add it if needed |
2133 |
my $dbh = C4::Context->dbh; |
2134 |
my $sth = $dbh->prepare(q{ |
2135 |
SELECT enrolmentfee |
2136 |
FROM categories |
2137 |
WHERE categorycode=? |
2138 |
}); |
2139 |
$sth->execute( $categorycode ); |
2140 |
if ( $sth->err ) { |
2141 |
warn sprintf('Database returned the following error: %s', $sth->errstr); |
2142 |
return; |
2143 |
} |
2144 |
my ($enrolmentfee) = $sth->fetchrow; |
2145 |
if ($enrolmentfee && $enrolmentfee > 0) { |
2146 |
# insert fee in patron debts |
2147 |
C4::Accounts::manualinvoice( $borrowernumber, '', '', 'A', $enrolmentfee ); |
2148 |
} |
2149 |
} |
2150 |
|
2151 |
=head2 HasOverdues |
2121 |
=head2 HasOverdues |
2152 |
|
2122 |
|
2153 |
=cut |
2123 |
=cut |