summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/API.pm200
-rw-r--r--FS/FS/AccessRight.pm4
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm9
-rw-r--r--FS/FS/Conf.pm8
-rw-r--r--FS/FS/access_right.pm1
-rw-r--r--FS/FS/cust_contact.pm2
-rw-r--r--FS/FS/cust_main_Mixin.pm11
-rw-r--r--FS/FS/cust_pkg/Import.pm17
-rw-r--r--FS/FS/part_event/Action/notice_to_emailtovoice.pm84
-rw-r--r--FS/FS/part_event/Condition/pkg_contract_date.pm34
10 files changed, 359 insertions, 11 deletions
diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index fd3793d4f..f9cc37ea6 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -719,7 +719,205 @@ sub bill_now {
}
-#next.. Advertising sources?
+#next.. Delete Advertising sources?
+
+=item list_advertising_sources OPTION => VALUE, ...
+
+Lists all advertising sources.
+
+=over
+
+=item secret
+
+API Secret
+
+=back
+
+Example:
+
+ my $result = FS::API->list_advertising_sources(
+ 'secret' => 'sharingiscaring',
+ );
+
+ if ( $result->{'error'} ) {
+ die $result->{'error'};
+ } else {
+ # list advertising sources returns an array of hashes for sources.
+ print Dumper($result->{'sources'});
+ }
+
+=cut
+
+#list_advertising_sources
+sub list_advertising_sources {
+ my( $class, %opt ) = @_;
+ return _shared_secret_error() unless _check_shared_secret($opt{secret});
+
+ my @sources = qsearch('part_referral', {}, '', "")
+ or return { 'error' => 'No referrals' };
+
+ my $return = {
+ 'sources' => [ map $_->hashref, @sources ],
+ };
+
+ $return;
+}
+
+=item add_advertising_source OPTION => VALUE, ...
+
+Add a new advertising source.
+
+=over
+
+=item secret
+
+API Secret
+
+=item referral
+
+Referral name
+
+=item disabled
+
+Referral disabled, Y for disabled or nothing for enabled
+
+=item agentnum
+
+Agent ID number
+
+=item title
+
+External referral ID
+
+=back
+
+Example:
+
+ my $result = FS::API->add_advertising_source(
+ 'secret' => 'sharingiscaring',
+ 'referral' => 'test referral',
+
+ #optional
+ 'disabled' => 'Y',
+ 'agentnum' => '2', #agent id number
+ 'title' => 'test title',
+ );
+
+ if ( $result->{'error'} ) {
+ die $result->{'error'};
+ } else {
+ # add_advertising_source returns new source upon success.
+ print Dumper($result);
+ }
+
+=cut
+
+#add_advertising_source
+sub add_advertising_source {
+ my( $class, %opt ) = @_;
+ return _shared_secret_error() unless _check_shared_secret($opt{secret});
+
+ use FS::part_referral;
+
+ my $new_source = $opt{source};
+
+ my $source = new FS::part_referral $new_source;
+
+ my $error = $source->insert;
+
+ my $return = {$source->hash};
+ $return = { 'error' => $error, } if $error;
+
+ $return;
+}
+
+=item edit_advertising_source OPTION => VALUE, ...
+
+Edit a advertising source.
+
+=over
+
+=item secret
+
+API Secret
+
+=item refnum
+
+Referral number to edit
+
+=item source
+
+hash of edited source fields.
+
+=over
+
+=item referral
+
+Referral name
+
+=item disabled
+
+Referral disabled, Y for disabled or nothing for enabled
+
+=item agentnum
+
+Agent ID number
+
+=item title
+
+External referral ID
+
+=back
+
+=back
+
+Example:
+
+ my $result = FS::API->edit_advertising_source(
+ 'secret' => 'sharingiscaring',
+ 'refnum' => '4', # referral number to edit
+ 'source' => {
+ #optional
+ 'referral' => 'test referral',
+ 'disabled' => 'Y',
+ 'agentnum' => '2', #agent id number
+ 'title' => 'test title',
+ }
+ );
+
+ if ( $result->{'error'} ) {
+ die $result->{'error'};
+ } else {
+ # edit_advertising_source returns updated source upon success.
+ print Dumper($result);
+ }
+
+=cut
+
+#edit_advertising_source
+sub edit_advertising_source {
+ my( $class, %opt ) = @_;
+ return _shared_secret_error() unless _check_shared_secret($opt{secret});
+
+ use FS::part_referral;
+
+ my $refnum = $opt{refnum};
+ my $source = $opt{source};
+
+ my $old = FS::Record::qsearchs('part_referral', {'refnum' => $refnum,});
+ my $new = new FS::part_referral { $old->hash };
+
+ foreach my $key (keys %$source) {
+ $new->$key($source->{$key});
+ }
+
+ my $error = $new->replace;
+
+ my $return = {$new->hash};
+ $return = { 'error' => $error, } if $error;
+
+ $return;
+}
##
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 9cccb01f4..ccabf27fd 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -362,6 +362,10 @@ tie my %rights, 'Tie::IxHash',
{ rightname=>'Employee preference telephony integration' },
#]
+ #'RT preference rights' => [
+ { rightname=>'RT activity notification' },
+ #]
+
],
###
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 2b4d52d8f..5c86b7820 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1748,8 +1748,13 @@ sub delete_payby {
})
or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} };
- return { 'error' => $cust_payby->delete };
-
+ my $conf = new FS::Conf;
+ if (($cust_payby->payby eq "DCHK" || $cust_payby->payby eq "CHEK") && $conf->exists('selfservice-ACH_info_readonly')) {
+ return { 'error' => "Sorry you do not have permission to delete bank information." };
+ }
+ else {
+ return { 'error' => $cust_payby->delete };
+ }
}
sub cancel {
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index e2ebd09af..715733667 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -898,6 +898,14 @@ my $validate_email = sub { $_[0] =~
},
{
+ 'key' => 'email-to-voice_domain',
+ 'section' => 'email_to_voice_services',
+ 'description' => 'The Domain to send email to voice to',
+ 'type' => 'text',
+ 'per_agent' => 1,
+ },
+
+ {
'key' => 'next-bill-ignore-time',
'section' => 'billing',
'description' => 'Ignore the time portion of next bill dates when billing, matching anything from 00:00:00 to 23:59:59 on the billing day.',
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 3926fafcc..4a360333e 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -252,6 +252,7 @@ sub _upgrade_data { # class method
'Generate quotation' => 'Disable quotation',
'Add on-the-fly void credit reason' => 'Add on-the-fly void reason',
'_ALL' => 'Employee preference telephony integration',
+ '_ALL' => 'RT activity notification',
'Edit customer package dates' => [ 'Change package start date', #4.x
'Change package contract end date',
],
diff --git a/FS/FS/cust_contact.pm b/FS/FS/cust_contact.pm
index 6820ac4b4..118a9e000 100644
--- a/FS/FS/cust_contact.pm
+++ b/FS/FS/cust_contact.pm
@@ -106,7 +106,7 @@ and replace methods.
sub check {
my $self = shift;
- if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'P') {
+ if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'E' || $self->selfservice_access eq 'P') {
$self->selfservice_access('Y');
$self->_resend('Y');
}
diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm
index f8f117371..8b6569a74 100644
--- a/FS/FS/cust_main_Mixin.pm
+++ b/FS/FS/cust_main_Mixin.pm
@@ -408,14 +408,21 @@ use Digest::SHA qw(sha1); # for duplicate checking
sub email_search_result {
my($class, $param) = @_;
+ my $conf = FS::Conf->new;
+ my $send_to_domain = $conf->config('email-to-voice_domain');
+
my $msgnum = $param->{msgnum};
my $from = delete $param->{from};
my $subject = delete $param->{subject};
my $html_body = delete $param->{html_body};
my $text_body = delete $param->{text_body};
my $to_contact_classnum = delete $param->{to_contact_classnum};
+ my $emailtovoice_name = delete $param->{emailtovoice_contact};
+
my $error = '';
+ my $to = $emailtovoice_name . '@' . $send_to_domain unless !$emailtovoice_name;
+
my $job = delete $param->{'job'}
or die "email_search_result must run from the job queue.\n";
@@ -476,10 +483,14 @@ sub email_search_result {
next; # unlinked object; nothing else we can do
}
+my %to = {};
+if ($to) { $to{'to'} = $to; }
+
my $cust_msg = $msg_template->prepare(
'cust_main' => $cust_main,
'object' => $obj,
'to_contact_classnum' => $to_contact_classnum,
+ %to,
);
# For non-cust_main searches, we avoid duplicates based on message
diff --git a/FS/FS/cust_pkg/Import.pm b/FS/FS/cust_pkg/Import.pm
index 63a9909e5..96c6272b7 100644
--- a/FS/FS/cust_pkg/Import.pm
+++ b/FS/FS/cust_pkg/Import.pm
@@ -283,17 +283,20 @@ sub batch_import {
};
}
- my $formatfields = _formatfields();
+ my @formats = split /-/, $format;
+ foreach my $f (@formats){
- die "unknown format $format" unless $formatfields->{$format};
+ my $formatfields = _formatfields();
+ die "unknown format $format" unless $formatfields->{$f};
- foreach my $field ( @{ $formatfields->{$format} } ) {
+ foreach my $field ( @{ $formatfields->{$f} } ) {
- push @fields, sub {
- my( $self, $value, $conf, $param ) = @_;
- $param->{"$format.$field"} = $value;
- };
+ push @fields, sub {
+ my( $self, $value, $conf, $param ) = @_;
+ $param->{"$f.$field"} = $value;
+ };
+ }
}
$opt->{'fields'} = \@fields;
diff --git a/FS/FS/part_event/Action/notice_to_emailtovoice.pm b/FS/FS/part_event/Action/notice_to_emailtovoice.pm
new file mode 100644
index 000000000..a3a5e9824
--- /dev/null
+++ b/FS/FS/part_event/Action/notice_to_emailtovoice.pm
@@ -0,0 +1,84 @@
+package FS::part_event::Action::notice_to_emailtovoice;
+
+use strict;
+use base qw( FS::part_event::Action );
+use FS::Record qw( qsearchs );
+use FS::msg_template;
+use FS::Conf;
+
+sub description { 'Email a email to voice notice'; }
+
+sub eventtable_hashref {
+ {
+ 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ 'cust_pay' => 1,
+ 'cust_pay_batch' => 1,
+ 'cust_statement' => 1,
+ 'svc_acct' => 1,
+ };
+}
+
+sub option_fields {
+
+ #my $conf = new FS::Conf;
+ #my $to_domain = $conf->config('email-to-voice_domain');
+
+(
+ 'to_name' => { 'label' => 'Address To',
+ 'type' => 'select',
+ 'options' => [ 'mobile', 'fax', 'daytime' ],
+ 'option_labels' => { 'mobile' => 'Mobile Phone #',
+ 'fax' => 'Fax #',
+ 'daytime' => 'Day Time #',
+ },
+ 'post_field_label' => "@", # . $to_domain ,
+ },
+
+ 'msgnum' => { 'label' => 'Template',
+ 'type' => 'select-table',
+ 'table' => 'msg_template',
+ 'name_col' => 'msgname',
+ 'hashref' => { disabled => '' },
+ 'disable_empty' => 1,
+ },
+ );
+
+}
+
+sub default_weight { 56; } #?
+
+sub do_action {
+ my( $self, $object ) = @_;
+
+ my $conf = new FS::Conf;
+ my $to_domain = $conf->config('email-to-voice_domain')
+ or die "Can't send notice with out send-to-domain, being set in global config \n";
+
+ my $cust_main = $self->cust_main($object);
+
+ my $msgnum = $self->option('msgnum');
+ my $name = $self->option('to_name');
+
+ my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
+ or die "Template $msgnum not found";
+
+ my $to_name = $cust_main->$name
+ or die "Can't send notice with out " . $cust_main->$name . " number set";
+
+ ## remove - from phone number
+ $to_name =~ s/-//g;
+
+ #my $to = $to_name . '@' . $self->option('to_domain');
+ my $to = $to_name . '@' . $to_domain;
+
+ $msg_template->send(
+ 'to' => $to,
+ 'cust_main' => $cust_main,
+ 'object' => $object,
+ );
+
+}
+
+1;
diff --git a/FS/FS/part_event/Condition/pkg_contract_date.pm b/FS/FS/part_event/Condition/pkg_contract_date.pm
new file mode 100644
index 000000000..9cb75f60d
--- /dev/null
+++ b/FS/FS/part_event/Condition/pkg_contract_date.pm
@@ -0,0 +1,34 @@
+package FS::part_event::Condition::pkg_contract_date;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description {
+ 'Package contract date nearing';
+}
+
+sub eventtable_hashref {
+ {
+ 'cust_pkg' => 1,
+ };
+}
+
+sub option_fields {
+ my $class = shift;
+ (
+ 'within' => { 'label' => 'Package contract date with in',
+ 'type' => 'freq',
+ },
+ );
+}
+
+sub condition {
+ my( $self, $cust_pkg, %opt ) = @_;
+
+ my $contract_end_date = $cust_pkg->contract_end ? $cust_pkg->contract_end : 0;
+ my $contract_within_time = $self->option_age_from('within', $contract_end_date );
+
+ $opt{'time'} >= $contract_within_time and $contract_within_time > 0;
+}
+
+1; \ No newline at end of file