$self->custnum('');
my %link_hash = ();
- for (qw( classnum comment selfservice_access invoice_dest )) {
+ for (qw( classnum comment selfservice_access invoice_dest message_dest)) {
$link_hash{$_} = $self->get($_);
$self->$_('');
}
}
- $error ||= $self->insert_password_history;
-
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
}
}
+ if ( $self->get('password') ) {
+ my $error = $self->is_password_allowed($self->get('password'))
+ || $self->change_password($self->get('password'));
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
my $prospectnum = $self->prospectnum;
$self->prospectnum('');
my $custnum = $self->custnum;
- $self->custnum('');
+ $self->custnum(''); $old->custnum(''); # remove because now stored cust_contact
my %link_hash = ();
- for (qw( classnum comment selfservice_access invoice_dest )) {
+ for (qw( classnum comment selfservice_access invoice_dest message_dest )) {
$link_hash{$_} = $self->get($_);
+ $old->$_(''); ##remove values from old record, causes problem with history
$self->$_('');
}
if ( defined($self->hashref->{'emailaddress'}) ) {
- #ineffecient but whatever, how many email addresses can there be?
-
+ my %contact_emails = ();
foreach my $contact_email ( $self->contact_email ) {
- my $error = $contact_email->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
+ $contact_emails{$contact_email->emailaddress} = '1';
}
foreach my $email ( split(/\s*,\s*/, $self->get('emailaddress') ) ) {
- my $contact_email = new FS::contact_email {
- 'contactnum' => $self->contactnum,
- 'emailaddress' => $email,
- };
- $error = $contact_email->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
+ unless ($contact_emails{$email}) {
+ my $contact_email = new FS::contact_email {
+ 'contactnum' => $self->contactnum,
+ 'emailaddress' => $email,
+ };
+ $error = $contact_email->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
}
+ else { delete($contact_emails{$email}); }
}
+ foreach my $contact_email ( $self->contact_email ) {
+ if ($contact_emails{$contact_email->emailaddress}) {
+ my $error = $contact_email->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+ }
+
}
unless ( $skip_fuzzyfiles ) { #unless ( $import || $skip_fuzzyfiles ) {
$hash eq $check_hash;
- } else {
+ } else {
return 0 if $self->_password eq '';
my @contact_fields = qw(
classnum first last title comment emailaddress selfservice_access
- invoice_dest password
+ invoice_dest message_dest password
);
push @contact_fields, 'phonetypenum'. $_->phonetypenum
=cut
1;
-