From: levinse Date: Fri, 3 Jun 2011 18:10:45 +0000 (+0000) Subject: per-customer configurable payment date for auto CHEK/CARD, RT10813 X-Git-Tag: freeside_2_3_0~180 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=23ceb08c948d848556555840ffde296caebd6df6 per-customer configurable payment date for auto CHEK/CARD, RT10813 --- diff --git a/FS/FS/part_event/Condition/billday.pm b/FS/FS/part_event/Condition/billday.pm index e067f87f7..7cd74a1f9 100644 --- a/FS/FS/part_event/Condition/billday.pm +++ b/FS/FS/part_event/Condition/billday.pm @@ -9,22 +9,37 @@ sub description { "Customer's monthly billing day is before or on current day or customer has no billing day"; } +sub option_fields { + ( + 'delay' => { label => 'Delay additional days', + type => 'text', + value => '1', + }, + ); +} + + sub condition { my( $self, $object ) = @_; my $cust_main = $self->cust_main($object); my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + + my $delay = $self->option('delay'); + $delay = 0 unless length($delay); - (!$cust_main->billday) || ($mday >= $cust_main->billday); + (!$cust_main->billday) || ($mday >= $cust_main->billday + $delay); } sub condition_sql { - my( $self, $table ) = @_; + my( $class, $table, %opt ) = @_; my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); - - "cust_main.billday is null or $mday >= cust_main.billday"; + + my $delay = $class->condition_sql_option_integer('delay', $opt{'driver_name'}); + + "cust_main.billday is null or $mday >= (cust_main.billday + $delay)"; } 1; diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 57c0e523b..d6995af05 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -106,10 +106,10 @@ 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'; + if(payauto_field.checked) f.style.display = ''; else f.style.display = 'none'; } - + <& /elements/init_overlib.html &> @@ -144,8 +144,9 @@ % } % $ret; % } -% my $billday_card_display = $payby eq 'CARD' ? 'inline' : 'none'; -% my $billday_chek_display = $payby eq 'CHEK' ? 'inline' : 'none'; +% +% my $card_billday_style = $payby eq 'CARD' ? '' : 'style="display: none"'; +% my $chek_billday_style = $payby eq 'CHEK' ? '' : 'style="display: none"'; % % my %payby = ( % @@ -197,16 +198,18 @@ % qq!${r}!.emt('Exact name on card').qq! !. % qq!!. % -% qq! !.emt('Charge future payments to this [_1] automatically','credit card').qq!!. +% qq!!. +% qq! !. +% emt('Charge future payments to this [_1] automatically','credit card'). % % ( $conf->exists('cust_main-select-billday') ? -% qq! +% qq!
% Charge on this day of each month ! +% . billday_options($cust_main->billday) . qq!
! % : '' % ). % -% '', +% '', % % 'CHEK' => % @@ -242,16 +245,18 @@ % ). % % -% qq! !.emt('Charge future payments to this [_1] automatically','electronic check').qq!!. +% qq!!. +% qq! !. +% emt('Charge future payments to this [_1] automatically','electronic check'). % % ( $conf->exists('cust_main-select-billday') ? -% qq! +% qq!
% Charge on this day of each month ! +% . billday_options($cust_main->billday) . qq!
! % : '' % ). % -% '', +% '', % % 'LECB' => %