use C4::Form::MessagingPreferences;
use Koha::Borrower::Debarments;
use Koha::DateUtils;
+use Module::Load;
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
+}
use vars qw($debug);
$extended_patron_attributes = parse_extended_patron_attributes($input);
foreach my $attr (@$extended_patron_attributes) {
unless (C4::Members::Attributes::CheckUniqueness($attr->{code}, $attr->{value}, $borrowernumber)) {
+ my $attr_info = C4::Members::AttributeTypes->fetch($attr->{code});
push @errors, "ERROR_extended_unique_id_failed";
- $template->param(ERROR_extended_unique_id_failed_value => "$attr->{code}/$attr->{value}");
+ $template->param(
+ ERROR_extended_unique_id_failed_code => $attr->{code},
+ ERROR_extended_unique_id_failed_value => $attr->{value},
+ ERROR_extended_unique_id_failed_description => $attr_info->description()
+ );
}
}
}
if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) {
C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'});
}
+ # Try to do the live sync with the Norwegian national patron database, if it is enabled
+ if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ NLSync({ 'borrowernumber' => $borrowernumber });
+ }
} elsif ($op eq 'save'){
if ($NoUpdateLogin) {
delete $newdata{'password'};
delete $newdata{'userid'};
}
- &ModMember(%newdata) unless scalar(keys %newdata) <= 1; # bug 4508 - avoid crash if we're not
+ &ModMember(%newdata) unless scalar(keys %newdata) <= 1; # bug 4508 - avoid crash if we're not
# updating any columns in the borrowers table,
# which can happen if we're only editing the
# patron attributes or messaging preferences sections
if ( $step == 4 ) {
$template->param( categorycode => $borrower_data->{'categorycode'} );
}
+ # Add sync data to the user data
+ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
+ if ( $sync ) {
+ $template->param(
+ sync => $sync->sync,
+ );
+ }
+ }
}
if ( $op eq "duplicate" ) {
$template->param( updtype => 'I' );
$userbranch = C4::Context->userenv->{'branch'};
}
-if (defined ($data{'branchcode'}) and ( $op eq 'modify' || ( $op eq 'add' && $category_type eq 'C' ) )) {
+if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category_type eq 'C' ) )) {
$userbranch = $data{'branchcode'};
}