diff options
author | mark <mark> | 2010-10-12 01:15:17 +0000 |
---|---|---|
committer | mark <mark> | 2010-10-12 01:15:17 +0000 |
commit | 29472410e3b882a6a6b74fe48d28db411fe8fcff (patch) | |
tree | 727d1670a720d424ec2b5c5e3480657c992bcb44 | |
parent | fa5a1ac184e1fa9448453655b7e1f8e1297ef3b6 (diff) |
package contract end date field, RT#9918
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 8 | ||||
-rw-r--r-- | FS/FS/part_pkg/flat.pm | 11 | ||||
-rwxr-xr-x | httemplate/edit/REAL_cust_pkg.cgi | 6 | ||||
-rw-r--r-- | httemplate/edit/process/quick-cust_pkg.cgi | 4 | ||||
-rw-r--r-- | httemplate/elements/input-date-field.html | 6 | ||||
-rw-r--r-- | httemplate/misc/order_pkg.html | 39 | ||||
-rwxr-xr-x | httemplate/search/cust_pkg.cgi | 5 | ||||
-rwxr-xr-x | httemplate/search/report_cust_pkg.html | 3 | ||||
-rw-r--r-- | 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 <b>suspend</b> 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 <b>suspend</b> 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 <b>cancel</b> 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) { <LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2"> <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT> +% } <INPUT TYPE="text" NAME="<% $name %>" ID="<% $name %>_text" VALUE="<% $value %>"> <IMG SRC="<%$fsurl%>images/calendar.png" ID="<% $name %>_button" STYLE="cursor: pointer" TITLE="Select date"> @@ -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 <TR> <TH ALIGN="right">Start date </TD> <TD COLSPAN=6> - <INPUT TYPE = "text" - NAME = "start_date" - SIZE = 32 - ID = "start_date_text" - VALUE = "<% $start_date %>" - > - <IMG SRC = "../images/calendar.png" - ID = "start_date_button" - STYLE = "cursor: pointer" - TITLE = "Select date" - > + <% include('/elements/input-date-field.html',{ + 'name' => 'start_date', + 'format' => $date_format, + 'value' => $start_date, + 'noinit' => 1, + }) %> <FONT SIZE=-1>(leave blank to start immediately)</FONT> </TD> </TR> -<SCRIPT TYPE="text/javascript"> - Calendar.setup({ - inputField: "start_date_text", - ifFormat: "<% $date_format %>", - button: "start_date_button", - align: "BR" - }); -</SCRIPT> - % if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) { % my $what = lc(FS::payby->shortname($cust_main->payby)); <TR> @@ -99,6 +84,18 @@ ) %> +<TR> + <TH ALIGN="right">Contract end date </TD> + <TD COLSPAN=6> + <% include('/elements/input-date-field.html',{ + 'name' => 'contract_end', + 'format' => $date_format, + 'value' => '', + 'noinit' => 1, + }) %> + </TD> +</TR> + </TABLE> <% 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 )) { <TR> <TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD> @@ -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 ) %> <TR> <TD COLSPAN=<%$colspan%>> @@ -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 ) { |