summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-02-03 07:18:45 -0800
committerIvan Kohler <ivan@freeside.biz>2015-02-03 07:18:45 -0800
commitaeb90ade381fc3d5477db0334048c2af623fccfe (patch)
treed1540f5ccef513d10193c124fa6aeaae743ba107 /FS
parent167dbdad01e2c1b62fd9be43cc05212e8c874a02 (diff)
parentd9edf24e9d3e1fd87a23359a7679ef6d6637c00d (diff)
contacts can be shared among customers / "duplicate contact emails", RT#27943
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Daemon/Preforking.pm1
-rw-r--r--FS/FS/Record.pm1
-rw-r--r--FS/FS/contact.pm2
-rw-r--r--FS/FS/part_event/Condition/cust_bill_has_service.pm4
-rw-r--r--FS/FS/part_event/Condition/has_cust_tag.pm1
-rw-r--r--FS/FS/part_export/amazon_ec2.pm35
-rw-r--r--FS/FS/part_export/cardfortress.pm2
-rw-r--r--FS/FS/part_svc.pm2
-rw-r--r--FS/FS/phone_avail.pm4
-rw-r--r--FS/FS/svc_phone.pm1
-rw-r--r--FS/bin/freeside-cdrd8
11 files changed, 38 insertions, 23 deletions
diff --git a/FS/FS/Daemon/Preforking.pm b/FS/FS/Daemon/Preforking.pm
index 98b4fa6..f3a39a6 100644
--- a/FS/FS/Daemon/Preforking.pm
+++ b/FS/FS/Daemon/Preforking.pm
@@ -96,6 +96,7 @@ sub daemon_run {
#parent doesn't need to hold a DB connection open
dbh->disconnect;
undef $FS::UID::dbh;
+ undef $RT::Handle;
server_spawn(MAX_PROCESSES);
POE::Kernel->run();
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index f8282c0..92fb896 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -876,6 +876,7 @@ sub qsearchs { # $result_record = &FS::Record:qsearchs('table',\%hash);
my $table = $_[0];
my(@result) = qsearch(@_);
cluck "warning: Multiple records in scalar search ($table)"
+ #.join(' / ', map "$_=>".$_[1]->{$_}, keys %{ $_[1] } )
if scalar(@result) > 1;
#should warn more vehemently if the search was on a primary key?
scalar(@result) ? ($result[0]) : ();
diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 07458c7..589fc7c 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -464,6 +464,8 @@ sub replace {
next;
}
+ $contact_phone ||= new FS::contact_phone \%cp;
+
my %cpd = _parse_phonestring( $self->get($pf) );
$contact_phone->set( $_ => $cpd{$_} ) foreach keys %cpd;
diff --git a/FS/FS/part_event/Condition/cust_bill_has_service.pm b/FS/FS/part_event/Condition/cust_bill_has_service.pm
index 6e981ee..898b08d 100644
--- a/FS/FS/part_event/Condition/cust_bill_has_service.pm
+++ b/FS/FS/part_event/Condition/cust_bill_has_service.pm
@@ -44,13 +44,13 @@ sub condition_sql {
my $servicenums =
$class->condition_sql_option_option_integer('has_service');
- my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart)
+ my $sql = " 0 < ( SELECT COUNT(cs.svcpart)
FROM cust_bill_pkg cbp, cust_svc cs
WHERE cbp.invnum = cust_bill.invnum
AND cs.pkgnum = cbp.pkgnum
AND cs.svcpart IN $servicenums
)
- |;
+ ";
return $sql;
}
diff --git a/FS/FS/part_event/Condition/has_cust_tag.pm b/FS/FS/part_event/Condition/has_cust_tag.pm
index cde9338..79bf2d3 100644
--- a/FS/FS/part_event/Condition/has_cust_tag.pm
+++ b/FS/FS/part_event/Condition/has_cust_tag.pm
@@ -16,7 +16,6 @@ sub eventtable_hashref {
};
}
-#something like this
sub option_fields {
(
'tagnum' => { 'label' => 'Customer tag',
diff --git a/FS/FS/part_export/amazon_ec2.pm b/FS/FS/part_export/amazon_ec2.pm
index 06e2c23..c1082a8 100644
--- a/FS/FS/part_export/amazon_ec2.pm
+++ b/FS/FS/part_export/amazon_ec2.pm
@@ -8,10 +8,12 @@ use FS::Record qw( qsearchs );
use FS::svc_external;
tie my %options, 'Tie::IxHash',
- 'access_key' => { label => 'AWS access key', },
- 'secret_key' => { label => 'AWS secret key', },
- 'ami' => { label => 'AMI', 'default' => 'ami-ff46a796', },
- 'keyname' => { label => 'Keypair name', },
+ 'access_key' => { label => 'AWS access key', },
+ 'secret_key' => { label => 'AWS secret key', },
+ 'ami' => { label => 'AMI', 'default' => 'ami-ff46a796', },
+ 'keyname' => { label => 'Keypair name', },
+ 'region' => { label => 'Region', },
+ 'InstanceType' => { label => 'Instance Type', },
#option to turn off (or on) ip address allocation
;
@@ -38,6 +40,7 @@ sub _export_insert {
$svc_external->svcnum,
$self->option('ami'),
$self->option('keyname'),
+ $self->option('InstanceType'),
);
ref($err_or_queue) ? '' : $err_or_queue;
}
@@ -96,31 +99,35 @@ sub amazon_ec2_queue {
};
$queue->insert( $self->option('access_key'),
$self->option('secret_key'),
+ $self->option('region'),
@_
)
or $queue;
}
sub amazon_ec2_new {
- my( $access_key, $secret_key, @rest ) = @_;
+ my( $access_key, $secret_key, $region, @rest ) = @_;
eval 'use Net::Amazon::EC2;';
die $@ if $@;
my $ec2 = new Net::Amazon::EC2 'AWSAccessKeyId' => $access_key,
- 'SecretAccessKey' => $secret_key;
-
+ 'SecretAccessKey' => $secret_key,
+ 'region' => $region || 'us-east-1',
+ ;
( $ec2, @rest );
}
sub amazon_ec2_insert { #subroutine, not method
- my( $ec2, $svcnum, $ami, $keyname ) = amazon_ec2_new(@_);
-
- my $reservation_info = $ec2->run_instances( 'ImageId' => $ami,
- 'KeyName' => $keyname,
- 'MinCount' => 1,
- 'MaxCount' => 1,
- );
+ my( $ec2, $svcnum, $ami, $keyname, $InstanceType ) = amazon_ec2_new(@_);
+
+ my $reservation_info = $ec2->run_instances(
+ 'ImageId' => $ami,
+ 'KeyName' => $keyname,
+ 'InstanceType' => $InstanceType || 'm1.small',
+ 'MinCount' => 1,
+ 'MaxCount' => 1,
+ );
my $instance_id = $reservation_info->instances_set->[0]->instance_id;
diff --git a/FS/FS/part_export/cardfortress.pm b/FS/FS/part_export/cardfortress.pm
index 7ff7280..154f979 100644
--- a/FS/FS/part_export/cardfortress.pm
+++ b/FS/FS/part_export/cardfortress.pm
@@ -28,6 +28,7 @@ sub _export_insert {
my $ssh = Net::OpenSSH->new( $self->machine,
default_stdin_fh => $def_in );
+ #capture2 and return STDERR, its probably useful if there's a problem
my $private_key = $ssh->capture(
{ 'stdin_data' => $svc_acct->_password. "\n" },
'/usr/local/bin/merchant_create', map $svc_acct->$_, qw( username finger )
@@ -67,6 +68,7 @@ sub _export_delete {
my $ssh = Net::OpenSSH->new( $self->machine,
default_stdin_fh => $def_in );
+ #capture2 and return STDERR, its probably useful if there's a problem
my $unused_output = $ssh->capture(
'/usr/local/bin/merchant_disable', map $svc_acct->$_, qw( username )
);
diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm
index 2748686..f56878a 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -697,6 +697,8 @@ some components specified by "select-.*.html", and a bunch more...
=item select_label - Used with select_table, this is the field name of labels
+=item select_allow_empty - Used with select_table, adds an empty option
+
=back
=cut
diff --git a/FS/FS/phone_avail.pm b/FS/FS/phone_avail.pm
index 52bbdeb..ae8526c 100644
--- a/FS/FS/phone_avail.pm
+++ b/FS/FS/phone_avail.pm
@@ -283,8 +283,8 @@ sub _upgrade_data {
my $sth = dbh->prepare(
'UPDATE phone_avail SET svcnum = NULL
WHERE svcnum IS NOT NULL
- AND 0 = ( SELECT COUNT(*) FROM svc_phone
- WHERE phone_avail.svcnum = svc_phone.svcnum )'
+ AND NOT EXISTS ( SELECT 1 FROM svc_phone
+ WHERE phone_avail.svcnum = svc_phone.svcnum )'
) or die dbh->errstr;
$sth->execute or die $sth->errstr;
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index 06ce948..71a61ad 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -196,6 +196,7 @@ sub table_info {
select_table => 'svc_domain',
select_key => 'svcnum',
select_label => 'domain',
+ select_allow_empty => 1,
disable_inventory => 1,
},
'circuit_svcnum' => { label => 'Circuit',
diff --git a/FS/bin/freeside-cdrd b/FS/bin/freeside-cdrd
index 45d5878..a3c67f9 100644
--- a/FS/bin/freeside-cdrd
+++ b/FS/bin/freeside-cdrd
@@ -120,10 +120,10 @@ while (1) {
sub _shouldrun {
my $extra_sql =
- ' AND 0 < ( SELECT COUNT(*) FROM cust_pkg
- WHERE cust_pkg.pkgpart = part_pkg.pkgpart
- AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
- )
+ ' AND EXISTS ( SELECT 1 FROM cust_pkg
+ WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+ AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
+ )
';
my @part_pkg =