package contract end date field, RT#9918
authormark <mark>
Tue, 12 Oct 2010 01:15:17 +0000 (01:15 +0000)
committermark <mark>
Tue, 12 Oct 2010 01:15:17 +0000 (01:15 +0000)
FS/FS/Schema.pm
FS/FS/cust_pkg.pm
FS/FS/part_pkg/flat.pm
httemplate/edit/REAL_cust_pkg.cgi
httemplate/edit/process/quick-cust_pkg.cgi
httemplate/elements/input-date-field.html
httemplate/misc/order_pkg.html
httemplate/search/cust_pkg.cgi
httemplate/search/report_cust_pkg.html
httemplate/view/cust_main/packages/status.html

index a601843..6a987ce 100644 (file)
@@ -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', '', '', '',
index 3e37ec9..ebc94e7 100644 (file)
@@ -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});
 
index 975e80a..c52f96e 100644 (file)
@@ -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
                       ),
index 77e5da1..98a37bb 100755 (executable)
   <& .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
index 71f424c..599f760 100644 (file)
@@ -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')),
 };
 
index 0ea4be7..2a9bc1d 100644 (file)
@@ -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">
 
 <%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) = @_;
 }
index e9a56b1..b232deb 100644 (file)
           )
 %>
 
-%# 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>
           )
 %>
 
+<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',
index da4371f..207e4f6 100755 (executable)
@@ -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);
 
index 58fcf61..289fec4 100755 (executable)
@@ -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',
 );
 
index a686843..74e52ef 100644 (file)
@@ -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%>>
       <% 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 ) {