summaryrefslogtreecommitdiff
path: root/FS/FS/contact.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-11-02 13:47:50 -0700
committerIvan Kohler <ivan@freeside.biz>2013-11-02 13:47:50 -0700
commitcaad814a67620dad4aa97f0c5be8adb324956cc1 (patch)
treeed7335ad41d75e02fffb8b0f19a8ab5559fcbacf /FS/FS/contact.pm
parent3dc2e7f2c7d562b968ae8032e2865eebb401f895 (diff)
contact search, RT#25687 (also possibly #25583 and #22991)
Diffstat (limited to 'FS/FS/contact.pm')
-rw-r--r--FS/FS/contact.pm65
1 files changed, 64 insertions, 1 deletions
diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 8fcd724a0..da6f2eb99 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -1,7 +1,7 @@
package FS::contact;
+use base qw( FS::Record );
use strict;
-use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs dbh );
use FS::prospect_main;
use FS::cust_main;
@@ -153,6 +153,16 @@ sub insert {
}
+ #unless ( $import || $skip_fuzzyfiles ) {
+ #warn " queueing fuzzyfiles update\n"
+ # if $DEBUG > 1;
+ $error = $self->queue_fuzzyfiles_update;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "updating fuzzy search cache: $error";
+ }
+ #}
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
@@ -277,6 +287,16 @@ sub replace {
}
+ #unless ( $import || $skip_fuzzyfiles ) {
+ #warn " queueing fuzzyfiles update\n"
+ # if $DEBUG > 1;
+ $error = $self->queue_fuzzyfiles_update;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "updating fuzzy search cache: $error";
+ }
+ #}
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
@@ -306,6 +326,44 @@ sub _parse_phonestring {
);
}
+=item queue_fuzzyfiles_update
+
+Used by insert & replace to update the fuzzy search cache
+
+=cut
+
+use FS::cust_main::Search;
+sub queue_fuzzyfiles_update {
+ my $self = shift;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ foreach my $field ( 'first', 'last' ) {
+ my $queue = new FS::queue {
+ 'job' => 'FS::cust_main::Search::append_fuzzyfiles_fuzzyfield'
+ };
+ my @args = "contact.$field", $self->get($field);
+ my $error = $queue->insert( @args );
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "queueing job (transaction rolled back): $error";
+ }
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+
+}
+
=item check
Checks all fields to make sure this is a valid example. If there is
@@ -381,6 +439,11 @@ sub contact_email {
qsearch('contact_email', { 'contactnum' => $self->contactnum } );
}
+sub cust_main {
+ my $self = shift;
+ qsearchs('cust_main', { 'custnum' => $self->custnum } );
+}
+
=back
=head1 BUGS