From 29472410e3b882a6a6b74fe48d28db411fe8fcff Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 12 Oct 2010 01:15:17 +0000 Subject: [PATCH] package contract end date field, RT#9918 --- FS/FS/Schema.pm | 1 + FS/FS/cust_pkg.pm | 8 ++++-- FS/FS/part_pkg/flat.pm | 11 ++++++++ httemplate/edit/REAL_cust_pkg.cgi | 6 ++-- httemplate/edit/process/quick-cust_pkg.cgi | 4 +++ httemplate/elements/input-date-field.html | 6 ++-- httemplate/misc/order_pkg.html | 39 ++++++++++++-------------- httemplate/search/cust_pkg.cgi | 5 ++-- httemplate/search/report_cust_pkg.html | 3 +- httemplate/view/cust_main/packages/status.html | 2 ++ 10 files changed, 55 insertions(+), 30 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index a6018435e..6a987ceb1 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1303,6 +1303,7 @@ sub tables_hashref { 'adjourn', @date_type, '', '', 'cancel', @date_type, '', '', 'expire', @date_type, '', '', + 'contract_end', @date_type, '', '', 'change_date', @date_type, '', '', 'change_pkgnum', 'int', 'NULL', '', '', '', 'change_pkgpart', 'int', 'NULL', '', '', '', diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 3e37ec9e9..ebc94e7eb 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -153,6 +153,10 @@ date date +=item contract_end + +date + =item cancel date @@ -259,7 +263,7 @@ sub insert { $self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) ); } - foreach my $action ( qw(expire adjourn) ) { + foreach my $action ( qw(expire adjourn contract_end) ) { my $months = $self->part_pkg->option("${action}_months",1); if($months and !$self->$action) { my $start = $self->start_date || $self->setup || time; @@ -2806,7 +2810,7 @@ sub search { "NOT (".FS::cust_pkg->onetime_sql . ")"; } else { - foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) { + foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel )) { next unless exists($params->{$field}); diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index 975e80ab3..c52f96e12 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -20,6 +20,11 @@ tie my %temporalities, 'Tie::IxHash', 'preceding' => "Preceding (past)", ; +tie my %contract_years, 'Tie::IxHash', ( + '(none)' => '', + map { $_*12 => $_ } (1..5), +); + %usage_fields = ( 'seconds' => { 'name' => 'Time limit for this package', @@ -117,6 +122,11 @@ tie my %temporalities, 'Tie::IxHash', }, 'adjourn_months'=> { 'name' => 'Auto-add a suspension date this number of months out', }, + 'contract_end_months'=> { + 'name' => 'Auto-add a contract end date this number of years out', + 'type' => 'select', + 'select_options' => \%contract_years, + }, #used in cust_pkg.pm so could add to any price plan where it made sense 'start_1st' => { 'name' => 'Auto-add a start date to the 1st, ignoring the current month.', 'type' => 'checkbox', @@ -141,6 +151,7 @@ tie my %temporalities, 'Tie::IxHash', 'fieldorder' => [ qw( setup_fee recur_fee recur_temporality unused_credit expire_months adjourn_months + contract_end_months start_1st sync_bill_date unsuspend_adjust_bill ), diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi index 77e5da141..98a37bb94 100755 --- a/httemplate/edit/REAL_cust_pkg.cgi +++ b/httemplate/edit/REAL_cust_pkg.cgi @@ -55,12 +55,14 @@ <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup' &> <& .row_edit, cust_pkg=>$cust_pkg, column=>'last_bill', label=>$last_bill_or_renewed &> <& .row_edit, cust_pkg=>$cust_pkg, column=>'bill', label=>$next_bill_or_prepaid_until &> - <& .row_display, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will suspend this package when the date is reached)' &> - <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &> + <& .row_display, cust_pkg=>$cust_pkg, column=>'contract_end',label=>'Contract end' &> + <& .row_display, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will suspend this package when the date is reached)' &> + <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &> <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will cancel this package when the date is reached)' &> <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &> + <%def .row_edit> <%args> $cust_pkg diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 71f424ca3..599f7607c 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -66,6 +66,10 @@ my $cust_pkg = new FS::cust_pkg { 'discountnum_amount' => scalar($cgi->param('discountnum_amount')), 'discountnum_percent' => scalar($cgi->param('discountnum_percent')), 'discountnum_months' => scalar($cgi->param('discountnum_months')), + 'contract_end' => ( scalar($cgi->param('contract_end')) + ? parse_datetime($cgi->param('contract_end')) + : '' + ), #'discountnum_disabled' => scalar($cgi->param('discountnum_disabled')), }; diff --git a/httemplate/elements/input-date-field.html b/httemplate/elements/input-date-field.html index 0ea4be70a..2a9bc1d53 100644 --- a/httemplate/elements/input-date-field.html +++ b/httemplate/elements/input-date-field.html @@ -1,8 +1,9 @@ - +% if(!$noinit) { +% } @@ -18,13 +19,14 @@ <%init> -my($name, $value, $format, $usedatetime); +my($name, $value, $format, $usedatetime, $noinit); if ( ref($_[0]) ) { my $opt = shift; $name = $opt->{'name'}; $value = $opt->{'value'}; $format = $opt->{'format'}; $usedatetime = $opt->{'usedatetime'}; + $noinit = $opt->{'noinit'}; } else { ($name, $value, $format, $usedatetime) = @_; } diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index e9a56b1a5..b232debd7 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -38,34 +38,19 @@ ) %> -%# false laziness w/edit/quick-charge.html Start date - - + <% include('/elements/input-date-field.html',{ + 'name' => 'start_date', + 'format' => $date_format, + 'value' => $start_date, + 'noinit' => 1, + }) %> (leave blank to start immediately) - - % if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) { % my $what = lc(FS::payby->shortname($cust_main->payby)); @@ -99,6 +84,18 @@ ) %> + + Contract end date + + <% include('/elements/input-date-field.html',{ + 'name' => 'contract_end', + 'format' => $date_format, + 'value' => '', + 'noinit' => 1, + }) %> + + + <% include( '/elements/standardize_locations.html', diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index da4371f5e..207e4f611 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -19,6 +19,7 @@ 'Adjourn', 'Susp.', 'Expire', + 'Contract end', 'Cancel', 'Reason', FS::UI::Web::cust_header( @@ -59,7 +60,7 @@ #sub { time2str('%b %d %Y', shift->expire); }, #sub { time2str('%b %d %Y', shift->get('cancel')); }, ( map { time_or_blank($_) } - qw( setup last_bill bill adjourn susp expire cancel ) ), + qw( setup last_bill bill adjourn susp expire contract_end cancel ) ), sub { my $self = shift; my $return = ''; @@ -206,7 +207,7 @@ my %disable = ( '' => {}, ); -foreach my $field (qw( setup last_bill bill adjourn susp expire cancel active )) { +foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel active )) { my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field); diff --git a/httemplate/search/report_cust_pkg.html b/httemplate/search/report_cust_pkg.html index 58fcf619e..289fec458 100755 --- a/httemplate/search/report_cust_pkg.html +++ b/httemplate/search/report_cust_pkg.html @@ -89,7 +89,7 @@ % } -% foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) { +% foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel )) { <% $label{$field} %> @@ -181,6 +181,7 @@ my %label = ( 'adjourn' => 'Adjourns', 'susp' => 'Suspended', 'expire' => 'Expires', + 'contract_end' => 'Contract ends', 'cancel' => 'Cancelled', ); diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html index a6868434b..74e52efdd 100644 --- a/httemplate/view/cust_main/packages/status.html +++ b/httemplate/view/cust_main/packages/status.html @@ -56,6 +56,7 @@ <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %> % # pkg_status_row($cust_pkg, 'Next bill', 'bill', %opt) <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %> + <% pkg_status_row_if( $cust_pkg, 'Contract ends', 'contract_end', %opt ) %> > @@ -167,6 +168,7 @@ <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %> <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %> <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %> + <% pkg_status_row_if( $cust_pkg, 'Contract ends', 'contract_end', %opt ) %> % if ( $part_pkg->freq ) { -- 2.11.0