|
Lines 76-81
my $cardnumber = $input->param('cardnumber');
Link Here
|
| 76 |
my $check_member = $input->param('check_member'); |
76 |
my $check_member = $input->param('check_member'); |
| 77 |
my $nodouble = $input->param('nodouble'); |
77 |
my $nodouble = $input->param('nodouble'); |
| 78 |
my $duplicate = $input->param('duplicate'); |
78 |
my $duplicate = $input->param('duplicate'); |
|
|
79 |
my $mailacctdetails= $input->param('mailacctdetails') // 0; |
| 80 |
|
| 79 |
$nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate'); # FIXME hack to represent fact that if we're |
81 |
$nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate'); # FIXME hack to represent fact that if we're |
| 80 |
# modifying an existing patron, it ipso facto |
82 |
# modifying an existing patron, it ipso facto |
| 81 |
# isn't a duplicate. Marking FIXME because this |
83 |
# isn't a duplicate. Marking FIXME because this |
|
Lines 376-414
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
Link Here
|
| 376 |
$borrowernumber = &AddMember(%newdata); |
378 |
$borrowernumber = &AddMember(%newdata); |
| 377 |
$newdata{'borrowernumber'} = $borrowernumber; |
379 |
$newdata{'borrowernumber'} = $borrowernumber; |
| 378 |
|
380 |
|
| 379 |
# If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. |
381 |
SendAutoEmail( \%newdata, $template ); # optionally send acct details |
| 380 |
if ( C4::Context->preference("AutoEmailOpacUser") == 1 && $newdata{'userid'} && $newdata{'password'}) { |
|
|
| 381 |
#look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead |
| 382 |
my $emailaddr; |
| 383 |
if (C4::Context->preference("AutoEmailPrimaryAddress") ne 'OFF' && |
| 384 |
$newdata{C4::Context->preference("AutoEmailPrimaryAddress")} =~ /\w\@\w/ ) { |
| 385 |
$emailaddr = $newdata{C4::Context->preference("AutoEmailPrimaryAddress")} |
| 386 |
} |
| 387 |
elsif ($newdata{email} =~ /\w\@\w/) { |
| 388 |
$emailaddr = $newdata{email} |
| 389 |
} |
| 390 |
elsif ($newdata{emailpro} =~ /\w\@\w/) { |
| 391 |
$emailaddr = $newdata{emailpro} |
| 392 |
} |
| 393 |
elsif ($newdata{B_email} =~ /\w\@\w/) { |
| 394 |
$emailaddr = $newdata{B_email} |
| 395 |
} |
| 396 |
# if we manage to find a valid email address, send notice |
| 397 |
if ($emailaddr) { |
| 398 |
$newdata{emailaddr} = $emailaddr; |
| 399 |
my $err; |
| 400 |
eval { |
| 401 |
$err = SendAlerts ( 'members', \%newdata, "ACCTDETAILS" ); |
| 402 |
}; |
| 403 |
if ( $@ ) { |
| 404 |
$template->param(error_alert => $@); |
| 405 |
} elsif ( ref($err) eq "HASH" && defined $err->{error} and $err->{error} eq "no_email" ) { |
| 406 |
$template->{VARS}->{'error_alert'} = "no_email"; |
| 407 |
} else { |
| 408 |
$template->{VARS}->{'info_alert'} = 1; |
| 409 |
} |
| 410 |
} |
| 411 |
} |
| 412 |
|
382 |
|
| 413 |
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { |
383 |
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { |
| 414 |
C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes); |
384 |
C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes); |
|
Lines 425-430
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
Link Here
|
| 425 |
# updating any columns in the borrowers table, |
395 |
# updating any columns in the borrowers table, |
| 426 |
# which can happen if we're only editing the |
396 |
# which can happen if we're only editing the |
| 427 |
# patron attributes or messaging preferences sections |
397 |
# patron attributes or messaging preferences sections |
|
|
398 |
|
| 399 |
SendAutoEmail( \%newdata, $template ) if $mailacctdetails; # optionally send acct details, if the checkbox was checked |
| 428 |
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { |
400 |
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { |
| 429 |
C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes); |
401 |
C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes); |
| 430 |
} |
402 |
} |
|
Lines 812-817
sub patron_attributes_form {
Link Here
|
| 812 |
|
784 |
|
| 813 |
} |
785 |
} |
| 814 |
|
786 |
|
|
|
787 |
sub SendAutoEmail { #optionally send account detail notice |
| 788 |
my ( $dataref, $template ) = @_; |
| 789 |
my %newdata = %$dataref; |
| 790 |
|
| 791 |
# check AutoEmailOpacUser syspref first |
| 792 |
return if !C4::Context->preference("AutoEmailOpacUser"); |
| 793 |
# no mail too if no userid or password |
| 794 |
return if !$newdata{'userid'} || !$newdata{'password'}; |
| 795 |
|
| 796 |
#look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead |
| 797 |
my $emailaddr; |
| 798 |
if (C4::Context->preference("AutoEmailPrimaryAddress") ne 'OFF' && |
| 799 |
$newdata{C4::Context->preference("AutoEmailPrimaryAddress")} =~ /\w\@\w/ ) { |
| 800 |
$emailaddr = $newdata{C4::Context->preference("AutoEmailPrimaryAddress")} |
| 801 |
} |
| 802 |
elsif ($newdata{email} =~ /\w\@\w/) { |
| 803 |
$emailaddr = $newdata{email}; |
| 804 |
} |
| 805 |
elsif ($newdata{emailpro} =~ /\w\@\w/) { |
| 806 |
$emailaddr = $newdata{emailpro}; |
| 807 |
} |
| 808 |
elsif ($newdata{B_email} =~ /\w\@\w/) { |
| 809 |
$emailaddr = $newdata{B_email}; |
| 810 |
} |
| 811 |
# if we manage to find a valid email address, send notice |
| 812 |
if ($emailaddr) { |
| 813 |
$newdata{emailaddr} = $emailaddr; |
| 814 |
my $err; |
| 815 |
eval { |
| 816 |
$err = SendAlerts ( 'members', \%newdata, "ACCTDETAILS" ); |
| 817 |
}; |
| 818 |
if ( $@ ) { |
| 819 |
$template->param(error_alert => $@); |
| 820 |
} elsif ( ref($err) eq "HASH" && defined $err->{error} and $err->{error} eq "no_email" ) { |
| 821 |
$template->{VARS}->{'error_alert'} = "no_email"; |
| 822 |
} else { |
| 823 |
$template->{VARS}->{'info_alert'} = 1; |
| 824 |
} |
| 825 |
} |
| 826 |
} |
| 827 |
|
| 815 |
# Local Variables: |
828 |
# Local Variables: |
| 816 |
# tab-width: 8 |
829 |
# tab-width: 8 |
| 817 |
# End: |
830 |
# End: |
| 818 |
- |
|
|