summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_main.pm1
-rw-r--r--FS/FS/part_event/Condition/billday.pm30
-rw-r--r--httemplate/edit/cust_main/billing.html39
-rw-r--r--httemplate/view/cust_main/billing.html9
6 files changed, 85 insertions, 2 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 5bad05636..61cba34da 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -681,6 +681,13 @@ my %payment_gateway_options = (
'description' => 'Display a barcode on HTML and PDF invoices',
'type' => 'checkbox',
},
+
+ {
+ 'key' => 'cust_main-select-billday',
+ 'section' => 'billing',
+ 'description' => 'When used with a specific billing event, allows the selection of the day of month on which to charge credit card / bank account automatically, on a per-customer basis',
+ 'type' => 'checkbox',
+ },
{
'key' => 'encryption',
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 5dd9e13a5..0b6ea0d2b 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -871,6 +871,7 @@ sub tables_hashref {
'archived', 'char', 'NULL', 1, '', '',
'email_csv_cdr', 'char', 'NULL', 1, '', '',
'accountcode_cdr', 'char', 'NULL', 1, '', '',
+ 'billday', 'int', 'NULL', '', '', '',
],
'primary_key' => 'custnum',
'unique' => [ [ 'agentnum', 'agent_custid' ] ],
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 22c16fbaa..8345d9267 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1681,6 +1681,7 @@ sub check {
|| $self->ut_alphan('geocode')
|| $self->ut_floatn('cdr_termination_percentage')
|| $self->ut_floatn('credit_limit')
+ || $self->ut_numbern('billday')
;
#barf. need message catalogs. i18n. etc.
diff --git a/FS/FS/part_event/Condition/billday.pm b/FS/FS/part_event/Condition/billday.pm
new file mode 100644
index 000000000..b150a6cb8
--- /dev/null
+++ b/FS/FS/part_event/Condition/billday.pm
@@ -0,0 +1,30 @@
+package FS::part_event::Condition::billday;
+
+use strict;
+use Tie::IxHash;
+
+use base qw( FS::part_event::Condition );
+
+sub description {
+ "Customer's monthly billing day matches current day or customer has no billing day";
+}
+
+sub condition {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+
+ ($mday == $cust_main->billday) || (!$cust_main->billday);
+}
+
+sub condition_sql {
+ my( $self, $table ) = @_;
+
+ my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+
+ "cust_main.billday is null or cust_main.billday = $mday";
+}
+
+1;
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index e6600e689..2301a0b9c 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -96,6 +96,14 @@
return true;
}
+ function payauto_changed(payauto_field){
+ var f = (payauto_field.name == 'CARD_payauto') ? 'card_billday' : 'chek_billday';
+ f = document.getElementById(f);
+ if ( f == null) return;
+ if(payauto_field.checked) f.style.display = 'inline';
+ else f.style.display = 'none';
+ }
+
</SCRIPT>
<% include('/elements/init_overlib.html') %>
@@ -120,6 +128,19 @@
% : $payby eq 'CHEK' ? 'CHECKED'
% : $disable_payauto ? '' : 'CHECKED';
%
+% sub billday_options {
+% my $curr_value = shift;
+% my $ret = '<OPTION></OPTION>';
+% for my $billday ( 1 .. 28 ) {
+% my $sel = '';
+% $sel = "SELECTED='SELECTED'" if $curr_value == $billday;
+% $ret .= "<OPTION VALUE='$billday' $sel>$billday</OPTION>";
+% }
+% $ret;
+% }
+% my $billday_card_display = $payby eq 'CARD' ? 'inline' : 'none';
+% my $billday_chek_display = $payby eq 'CHEK' ? 'inline' : 'none';
+%
% my %payby = (
%
% 'CARD' =>
@@ -171,7 +192,14 @@
% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Exact name on card </TD>!.
% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="CARD_payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
%
-% qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="CARD_payauto" $CARD_payauto_checked> Charge future payments to this card automatically</TD></TR>!.
+% qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" onchange="payauto_changed(this);" NAME="CARD_payauto" $CARD_payauto_checked> Charge future payments to this card automatically</TD></TR>!.
+%
+% ( $conf->exists('cust_main-select-billday') ?
+% qq!<TR><TD COLSPAN=2 WIDTH="608" id="card_billday" style="display: $billday_card_display">
+% Charge on the <SELECT NAME="billday">!
+% . billday_options($cust_main->billday) . qq!</SELECT> day of each month</TD></TR>!
+% : ''
+% ).
%
% '</TABLE>',
%
@@ -209,7 +237,14 @@
% ).
%
%
-% qq!<TR><TD COLSPAN=4 WIDTH="608"><INPUT TYPE="checkbox" NAME="CHEK_payauto" $CHEK_payauto_checked> Charge future payments to this electronic check automatically</TD></TR>!.
+% qq!<TR><TD COLSPAN=4 WIDTH="608"><INPUT TYPE="checkbox" onchange="payauto_changed(this);" NAME="CHEK_payauto" $CHEK_payauto_checked> Charge future payments to this electronic check automatically</TD></TR>!.
+%
+% ( $conf->exists('cust_main-select-billday') ?
+% qq!<TR><TD COLSPAN=2 WIDTH="608" id="chek_billday" style="display: $billday_chek_display">
+% Charge on the <SELECT NAME="billday">!
+% . billday_options($cust_main->billday) . qq!</SELECT> day of each month</TD></TR>!
+% : ''
+% ).
%
% '<TR><TD>&nbsp;</TD></TR>'.
% '<TR><TD>&nbsp;</TD></TR>'.
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index 014ddaba2..efff3ed1c 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -23,6 +23,15 @@ Billing information
<TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
</TR>
+% if ( $conf->exists('cust_main-select-billday')
+% && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
+<TR>
+ <TD ALIGN="right">Billing day of month</TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
+ </TD>
+</TR>
+% }
+
<TR>
<TD ALIGN="right">Billing&nbsp;type</TD>
<TD BGCOLOR="#ffffff">