summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_pkg.cgi13
-rwxr-xr-xhttemplate/edit/REAL_cust_pkg.cgi87
-rw-r--r--httemplate/edit/cust_main/bottomfixup.js4
-rwxr-xr-xhttemplate/edit/cust_pkg.cgi36
-rwxr-xr-xhttemplate/edit/part_pkg.cgi14
-rwxr-xr-xhttemplate/edit/process/REAL_cust_pkg.cgi57
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi9
-rw-r--r--httemplate/elements/order_pkg.js1
-rw-r--r--httemplate/elements/standardize_locations.js39
-rwxr-xr-xhttemplate/misc/change_pkg.cgi3
-rw-r--r--httemplate/misc/confirm-address_standardize.html12
-rwxr-xr-xhttemplate/misc/confirm-cust_pkg-edit_dates.html283
-rw-r--r--httemplate/misc/order_pkg.html3
-rw-r--r--httemplate/misc/xmlhttp-address_standardize.html10
-rw-r--r--httemplate/search/elements/search-html.html12
-rw-r--r--httemplate/search/elements/search.html5
-rwxr-xr-xhttemplate/view/cust_main/packages.html25
-rw-r--r--httemplate/view/cust_main/packages/package.html80
-rwxr-xr-xhttemplate/view/cust_main/packages/section.html51
-rw-r--r--httemplate/view/cust_main/packages/status.html144
20 files changed, 648 insertions, 240 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 57a429747..5b19a309b 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -20,6 +20,7 @@
'fields' => \@fields,
'links' => \@links,
'align' => $align,
+ 'link_field' => 'pkgpart',
)
%>
<%init>
@@ -274,6 +275,18 @@ push @fields, sub {
: ()
),
],
+ ( map { my $dst_pkg = $_->dst_pkg;
+ [
+ { data => 'Supplemental: &nbsp;'.
+ '<A HREF="#'. $dst_pkg->pkgpart . '">' .
+ $dst_pkg->pkg . '</A>',
+ align=> 'center',
+ colspan => 2,
+ }
+ ]
+ }
+ $part_pkg->supp_part_pkg_link
+ ),
( map {
my $dst_pkg = $_->dst_pkg;
[
diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi
index 166a3b7ea..4bcf55c44 100755
--- a/httemplate/edit/REAL_cust_pkg.cgi
+++ b/httemplate/edit/REAL_cust_pkg.cgi
@@ -9,6 +9,29 @@
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript">
+var submit_fields = [];
+function confirm_changes() {
+ var i;
+ var querystring = 'pkgnum=<%$pkgnum%>';
+ var f = document.forms.formname;
+ for(i = 0; i < submit_fields.length; i++) {
+ querystring += ';'
+ + submit_fields[i]
+ + '='
+ + encodeURIComponent(f.elements[submit_fields[i] + '_text'].value);
+ }
+ overlib(
+ OLiframeContent(
+ '<%$p%>/misc/confirm-cust_pkg-edit_dates.html?' + querystring,
+ 576, 576, 'confirm_popup'
+ ),
+ CAPTION, 'Package date changes', STICKY, AUTOSTATUSCAP, CLOSETEXT, '',
+ MIDX, 0, MIDY, 0, DRAGGABLE, BGCOLOR, '#333399', CGCOLOR, '#333399',
+ TEXTSIZE, 3
+ );
+}
+</SCRIPT>
<FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
@@ -31,6 +54,15 @@
<TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
</TR>
+% if ( $cust_pkg->main_pkgnum ) {
+% my $main_pkg = $cust_pkg->main_pkg;
+ <TR>
+ <TD ALIGN="right">Supplemental to</TD>
+ <TD BGCOLOR="#ffffff">Package #<% $cust_pkg->main_pkgnum%>:&nbsp;\
+ <% $main_pkg->part_pkg->pkg %></TD>
+ </TR>
+
+% }
<TR>
<TD ALIGN="right">Custom</TD>
<TD BGCOLOR="#ffffff"><% $part_pkg->custom %></TD>
@@ -50,14 +82,14 @@
% if ( $cust_pkg->setup && ! $cust_pkg->start_date ) {
<& .row_display, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start' &>
% } else {
- <& .row_edit, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start' &>
+ <& .row_edit, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start', if_primary=>1 &>
% }
- <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup' &>
+ <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup', if_primary=>1 &>
<& .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 &>
%#if ( $cust_pkg->contract_end or $part_pkg->option('contract_end_months',1) ) {
- <& .row_edit, cust_pkg=>$cust_pkg, column=>'contract_end',label=>'Contract end' &>
+ <& .row_edit, cust_pkg=>$cust_pkg, column=>'contract_end',label=>'Contract end', if_primary=>1 &>
%#}
<& .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' &>
@@ -73,10 +105,17 @@
$column
$label
$note => ''
+ $if_primary => 0
</%args>
% my $value = $cust_pkg->get($column);
% $value = $value ? time2str($format, $value) : "";
-
+%
+% # if_primary for the dates that can't be edited on supplemental packages
+% if ($if_primary and $cust_pkg->main_pkgnum) {
+ <INPUT TYPE="hidden" ID="<%$column%>_text" VALUE="<% $cust_pkg->get($column) %>">
+ <SCRIPT>submit_fields.push('<%$column%>');</SCRIPT>
+ <& .row_display, %ARGS &>
+% } else {
<TR>
<TD ALIGN="right"><% $label %> date</TD>
<TD>
@@ -104,8 +143,11 @@
button: "<% $column %>_button",
align: "BR"
});
- </SCRIPT>
+ submit_fields.push('<%$column%>');
+
+ </SCRIPT>
+% }
</%def>
<%def .row_display>
@@ -114,6 +156,7 @@
$column
$label
$note => ''
+ $is_primary => 0 #ignored
</%args>
% if ( $cust_pkg->get($column) ) {
<TR>
@@ -130,7 +173,7 @@
</TABLE>
<BR>
-<INPUT TYPE="submit" VALUE="<% mt('Apply changes') |h %>">
+<INPUT TYPE="button" VALUE="<% mt('Apply changes') |h %>" onclick="confirm_changes()">
</FORM>
<% include('/elements/footer.html') %>
@@ -160,38 +203,6 @@ if ( $cgi->param('error') ) {
my @errors = ();
my %errors = map { $_=>1 } split(',', $cgi->param('error'));
$cgi->param('error', '');
-
- if ( $errors{'_bill_areyousure'} ) {
- if ( $cgi->param('bill') =~ /^([\s\d\/\:\-\(\w\)]*)$/ ) {
- my $bill = $1;
- push @errors,
- "You are attempting to set the next bill date to $bill, which is
- in the past. This will charge the customer for the interval
- from $bill until now. Are you sure you want to do this? ".
- '<INPUT TYPE="checkbox" NAME="bill_areyousure" VALUE="1">';
- }
- }
-
- if ( $errors{'_setup_areyousure'} ) {
- push @errors,
- "You are attempting to remove the setup date. This will re-charge the
- customer for the setup fee. Are you sure you want to do this? ".
- '<INPUT TYPE="checkbox" NAME="setup_areyousure" VALUE="1">';
- }
-
- if ( $errors{'_setupadd_areyousure'} ) {
- push @errors,
- "You are attempting to add a setup date. This will prevent charging the
- customer for the setup fee. Are you sure you want to do this? ".
- '<INPUT TYPE="checkbox" NAME="setupadd_areyousure" VALUE="1">';
- }
-
- if ( $errors{'_start'} ) {
- push @errors,
- "You are attempting to add a start date to a package that has already
- started billing.";
- }
-
$error = join('<BR><BR>', @errors );
}
diff --git a/httemplate/edit/cust_main/bottomfixup.js b/httemplate/edit/cust_main/bottomfixup.js
index 1cfa52d8f..0de6d9dab 100644
--- a/httemplate/edit/cust_main/bottomfixup.js
+++ b/httemplate/edit/cust_main/bottomfixup.js
@@ -70,8 +70,8 @@ function copy_payby_fields() {
<& /elements/standardize_locations.js,
'callback' => 'submit_continue();',
- 'main_prefix' => 'bill_',
- 'no_company' => 1,
+ 'billship' => 1,
+ 'with_census' => 1, # no with_firm, apparently
&>
function copyelement(from, to) {
diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi
index dd1ed335f..88e925460 100755
--- a/httemplate/edit/cust_pkg.cgi
+++ b/httemplate/edit/cust_pkg.cgi
@@ -7,7 +7,6 @@
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
%#current packages
-%my @cust_pkg = qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } );
%if (@cust_pkg) {
Current packages - select to remove (services are moved to a new package below)
@@ -18,13 +17,7 @@
</TR>
<BR><BR>
%
-%
-% foreach ( sort { $all_pkg{ $a->getfield('pkgpart') }
-% cmp $all_pkg{ $b->getfield('pkgpart') }
-% }
-% @cust_pkg
-% )
-% {
+% foreach ( @main_pkgs ) {
% my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
% my $checked = $remove_pkg{$pkgnum} ? ' CHECKED' : '';
%
@@ -36,6 +29,13 @@
<TD ALIGN="right"><% $pkgnum %>:</TD>
<TD><% $all_pkg{$pkgpart} %> - <% $all_comment{$pkgpart} %></TD>
</TR>
+% foreach my $supp_pkg ( @{ $supp_pkgs_of{$pkgnum} } ) {
+ <TR>
+ <TD></TD>
+ <TD></TD>
+ <TD>+ <% $all_pkg{$supp_pkg->pkgpart} %> - <% $all_comment{$supp_pkg->pkgpart} %></TD>
+ </TR>
+% }
% }
@@ -147,4 +147,24 @@ if ( $cgi->param('error') ) {
my $p1 = popurl(1);
+my @cust_pkg = qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } );
+my @main_pkgs;
+my %supp_pkgs_of; # main pkgnum => arrayref of cust_pkgs
+
+
+foreach my $cust_pkg
+ ( sort { $all_pkg{ $a->pkgpart } cmp $all_pkg{ $b->getfield('pkgpart') } }
+ @cust_pkg
+ )
+ # XXX does not properly handle recursive supplemental links
+{
+ if ( my $main_pkgnum = $cust_pkg->main_pkgnum ) {
+ $supp_pkgs_of{$main_pkgnum} ||= [];
+ push @{ $supp_pkgs_of{$main_pkgnum} }, $cust_pkg;
+ } else {
+ push @main_pkgs, $cust_pkg;
+ $supp_pkgs_of{$cust_pkg->pkgnum} ||= [];
+ }
+}
+
</%init>
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index c3f4f88b6..7baf84d11 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -53,6 +53,7 @@
'discountnum' => 'Offer discounts for longer terms',
'bill_dst_pkgpart' => 'Include line item(s) from package',
'svc_dst_pkgpart' => 'Include services of package',
+ 'supp_dst_pkgpart' => 'Include complete package',
'report_option' => 'Report classes',
'fcc_ds0s' => 'Voice-grade equivalents',
'fcc_voip_class' => 'Category',
@@ -239,6 +240,19 @@
},
{ 'type' => 'tablebreak-tr-title',
+ 'value' => 'Supplemental packages',
+ 'colspan' => '4',
+ },
+ { 'field' => 'supp_dst_pkgpart',
+ 'type' => 'select-part_pkg',
+ 'm2_label' => 'Include complete package',
+ 'm2m_method' => 'supp_part_pkg_link',
+ 'm2m_dstcol' => 'dst_pkgpart',
+ 'm2_error_callback' =>
+ &{$m2_error_callback_maker}('supp'),
+ },
+
+ { 'type' => 'tablebreak-tr-title',
'value' => 'Pricing add-ons',
'colspan' => 4,
},
diff --git a/httemplate/edit/process/REAL_cust_pkg.cgi b/httemplate/edit/process/REAL_cust_pkg.cgi
index 3e0ef59c1..fd2893487 100755
--- a/httemplate/edit/process/REAL_cust_pkg.cgi
+++ b/httemplate/edit/process/REAL_cust_pkg.cgi
@@ -19,36 +19,41 @@ die "access denied"
my $pkgnum = $cgi->param('pkgnum') or die;
my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
my %hash = $old->hash;
-$hash{$_}= $cgi->param($_) ? parse_datetime($cgi->param($_)) : ''
- foreach qw( start_date setup bill last_bill contract_end );
+foreach ( qw( start_date setup bill last_bill contract_end ) ) {
+ if ( $cgi->param($_) =~ /^(\d+)$/ ) {
+ $hash{$_} = $1;
+ } else {
+ $hash{$_} = '';
+ }
# adjourn, expire, resume not editable this way
-
-my @errors = ();
-
-push @errors, '_bill_areyousure'
- if $hash{'bill'} != $old->bill # if the next bill date was changed
- && $hash{'bill'} < time # to a date in the past
- && ! $cgi->param('bill_areyousure'); # and it wasn't confirmed
-
-push @errors, '_setup_areyousure'
- if ! $hash{'setup'} && $old->setup # if the setup date was removed
- && ! $cgi->param('setup_areyousure'); # and it wasn't confirmed
-
-push @errors, '_setupadd_areyousure'
- if $hash{'setup'} && ! $old->setup # if the setup date was added
- && ! $cgi->param('setupadd_areyousure'); # and it wasn't confirmed
-
-push @errors, '_start'
- if $hash{'start_date'} && !$old->start_date # if a start date was added
- && $hash{'setup'}; # but there's a setup date
+}
my $new;
my $error;
-if ( @errors ) {
- $error = join(',', @errors);
-} else {
- $new = new FS::cust_pkg \%hash;
- $error = $new->replace($old);
+$new = new FS::cust_pkg \%hash;
+$error = $new->replace($old);
+
+if (!$error) {
+ my @supp_pkgs = $old->supplemental_pkgs;
+ foreach $new (@supp_pkgs) {
+ foreach ( qw( start_date setup contract_end ) ) {
+ # propagate these to supplementals
+ $new->set($_, $hash{$_});
+ }
+ if ( $hash{'bill'} ne $old->get('bill') ) {
+ if ( $hash{'bill'} and $old->get('bill') ) {
+ # adjust by the same interval
+ my $diff = $hash{'bill'} - $old->get('bill');
+ $new->set('bill', $new->get('bill') + $diff);
+ } else {
+ # absolute date
+ $new->set('bill', $hash{'bill'});
+ }
+ }
+ $error = $new->replace;
+ $error .= ' (supplemental package '.$new->pkgnum.')' if $error;
+ last if $error;
+ }
}
</%init>
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index c388676df..2ac57f90b 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -185,6 +185,15 @@ my @process_m2m = (
grep /^svc_dst_pkgpart/, $cgi->param
],
},
+ { 'link_table' => 'part_pkg_link',
+ 'target_table' => 'part_pkg',
+ 'base_field' => 'src_pkgpart',
+ 'target_field' => 'dst_pkgpart',
+ 'hashref' => { 'link_type' => 'supp', 'hidden' => '' },
+ 'params' => [ map $cgi->param($_),
+ grep /^supp_dst_pkgpart/, $cgi->param
+ ],
+ },
map {
my $hidden = $_;
{ 'link_table' => 'part_pkg_link',
diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js
index 8c1efd93a..1069a0ee4 100644
--- a/httemplate/elements/order_pkg.js
+++ b/httemplate/elements/order_pkg.js
@@ -44,4 +44,5 @@ function standardize_new_location() {
function submit_abort() {
document.OrderPkgForm.submitButton.disabled = false;
+ nd(1);
}
diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js
index 15c5761a0..88c87c154 100644
--- a/httemplate/elements/standardize_locations.js
+++ b/httemplate/elements/standardize_locations.js
@@ -7,8 +7,8 @@ function status_message(text, caption) {
function form_address_info() {
var cf = document.<% $formname %>;
- var returnobj = { onlyship: <% $onlyship ? 1 : 0 %> };
-% if ( !$onlyship ) {
+ var returnobj = { billship: <% $billship %> };
+% if ( $billship ) {
returnobj['same'] = cf.elements['same'].checked;
% }
% if ( $withfirm ) {
@@ -59,16 +59,12 @@ function standardize_locations() {
cf.elements['<% $pre %>coord_auto'].value = 'Y';
changed = true;
}
-
-% } #foreach $pre
-
// standardize if the old address wasn't clean
- if ( cf.elements['old_ship_addr_clean'].value == '' ||
- cf.elements['old_bill_addr_clean'].value == '' ) {
-
+ if ( cf.elements['<% $pre %>addr_clean'].value == '' ) {
changed = true;
-
}
+% } #foreach $pre
+
// or if it was clean but has been changed
for (var key in address_info) {
var old_el = cf.elements['old_'+key];
@@ -81,7 +77,7 @@ function standardize_locations() {
% # If address hasn't been changed, auto-confirm the existing value of
% # censustract so that we don't ask the user to confirm it again.
- if ( !changed ) {
+ if ( !changed && <% $withcensus %> ) {
if ( address_info['same'] ) {
cf.elements['bill_censustract'].value =
address_info['bill_censustract'];
@@ -279,21 +275,18 @@ function setselect(el, value) {
my %opt = @_;
my $conf = new FS::Conf;
-my $withfirm = 1;
-my $withcensus = 1;
+my $withfirm = $opt{'with_firm'} ? 1 : 0;
+my $withcensus = $opt{'with_census'} ? 1 : 0;
+
+my @prefixes = '';
+my $billship = $opt{'billship'} ? 1 : 0; # whether to have bill_ and ship_ prefixes
+my $taxpre = '';
+if ($billship) {
+ @prefixes = qw(bill_ ship_);
+ $taxpre = $conf->exists('tax-ship_address') ? 'ship_' : 'bill_';
+}
my $formname = $opt{form} || 'CustomerForm';
-my $onlyship = $opt{onlyship} || '';
-#my $main_prefix = $opt{main_prefix} || '';
-#my $ship_prefix = $opt{ship_prefix} || ($onlyship ? '' : 'ship_');
-# The prefixes are now 'ship_' and 'bill_'.
-my $taxpre = 'bill_';
-$taxpre = 'ship_' if ( $conf->exists('tax-ship_address') || $onlyship );
my $post_geocode = $opt{callback} || 'post_geocode();';
-$withfirm = 0 if $opt{no_company};
-$withcensus = 0 if $opt{no_census};
-
-my @prefixes = ('ship_');
-unshift @prefixes, 'bill_' unless $onlyship;
</%init>
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
index 7b08f7b10..03e336cba 100755
--- a/httemplate/misc/change_pkg.cgi
+++ b/httemplate/misc/change_pkg.cgi
@@ -32,9 +32,6 @@
<& /elements/standardize_locations.html,
'form' => "OrderPkgForm",
- 'onlyship' => 1,
- 'no_company' => 1,
- 'no_census' => 1,
'callback' => 'document.OrderPkgForm.submit();',
&>
diff --git a/httemplate/misc/confirm-address_standardize.html b/httemplate/misc/confirm-address_standardize.html
index 57201ea5a..420e8ea1d 100644
--- a/httemplate/misc/confirm-address_standardize.html
+++ b/httemplate/misc/confirm-address_standardize.html
@@ -11,16 +11,14 @@ Confirm address standardization
</B><BR><BR>
<TABLE WIDTH="100%">
-% my @prefixes;
-% if ( $old{onlyship} ) {
-% @prefixes = ('ship_');
-% } elsif ( $old{same} ) {
+% my @prefixes = ('');
+% if ( $old{same} ) {
% @prefixes = ('bill_');
-% } else {
+% } elsif ( $old{billship} ) {
% @prefixes = ('bill_', 'ship_');
% }
% for my $pre (@prefixes) {
-% my $name = $pre eq 'ship_' ? 'service' : 'billing';
+% my $name = $pre eq 'bill_' ? 'billing' : 'service';
% if ( $new{$pre.'addr_clean'} ) {
<TR>
<TH>Entered <%$name%> address</TH>
@@ -128,6 +126,6 @@ my $q = decode_json($cgi->param('q'));
my %old = %{ $q->{old} };
my %new = %{ $q->{new} };
-my $addresses = $old{onlyship} ? 'address' : 'addresses';
+my $addresses = $old{billship} ? 'addresses' : 'address';
</%init>
diff --git a/httemplate/misc/confirm-cust_pkg-edit_dates.html b/httemplate/misc/confirm-cust_pkg-edit_dates.html
new file mode 100755
index 000000000..27b9a82f4
--- /dev/null
+++ b/httemplate/misc/confirm-cust_pkg-edit_dates.html
@@ -0,0 +1,283 @@
+<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied"
+ unless $curuser->access_right('Edit customer package dates');
+
+my %arg = $cgi->Vars;
+
+my $pkgnum = $arg{'pkgnum'};
+$pkgnum =~ /^\d+$/ or die "bad pkgnum '$pkgnum'";
+my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
+my %hash = $cust_pkg->hash;
+foreach (qw( start_date setup bill last_bill contract_end )) {
+ # adjourn, expire, resume not editable this way
+ if( $arg{$_} =~ /^\d+$/ ) {
+ $hash{$_} = $arg{$_};
+ } elsif ( $arg{$_} ) {
+ $hash{$_} = parse_datetime($arg{$_});
+ } else {
+ $hash{$_} = '';
+ }
+}
+
+my (@changes, @confirm, @errors);
+
+my $part_pkg = $cust_pkg->part_pkg;
+my @supp_pkgs = $cust_pkg->supplemental_pkgs;
+my $main_pkg = $cust_pkg->main_pkg;
+
+my $conf = FS::Conf->new;
+my $date_format = $conf->config('date_format') || '%b %o, %Y';
+# Start date
+if ( $hash{'start_date'} != $cust_pkg->get('start_date') and !$hash{'setup'} ) {
+ my $start = '';
+ $start = time2str($date_format, $hash{'start_date'}) if $hash{'start_date'};
+ my $text = 'Set this package';
+ if ( @supp_pkgs ) {
+ $text .= ' and all its supplemental packages';
+ }
+ $text .= ' to start billing';
+ if ( $start ) {
+ $text .= ' on [_1].';
+ push @changes, mt($text, $start);
+ } else {
+ $text .= ' immediately.';
+ push @changes, mt($text);
+ }
+ push @confirm, '';
+}
+
+# Setup date changes
+if ( $hash{'setup'} != $cust_pkg->get('setup') ) {
+ my $setup = time2str($date_format, $hash{'setup'});
+ my $has_setup_fee = grep { $_->part_pkg->option('setup_fee',1) > 0 }
+ $cust_pkg, @supp_pkgs;
+ if ( !$hash{'setup'} ) {
+ my $text = 'Remove the setup date';
+ $text .= ' from this and all its supplemental packages' if @supp_pkgs;
+ $text .= '.';
+ push @changes, mt($text);
+ if ( $has_setup_fee ) {
+ push @confirm, mt('This will re-charge the customer for the setup fee.');
+ } else {
+ push @confirm, '';
+ }
+ } elsif ( $cust_pkg->get('setup') ) {
+ my $text = 'Add a setup date of [_1]';
+ $text .= ' to this and all its supplemental packages' if @supp_pkgs;
+ $text .= '.';
+ push @changes, mt($text, $setup);
+ if ( $has_setup_fee ) {
+ push @confirm, mt('This will prevent charging the setup fee.');
+ } else {
+ push @confirm, '';
+ }
+ } else {
+ my $text = 'Set the setup date to [_1]';
+ $text .= ' on this and all its supplemental packages' if @supp_pkgs;
+ $text .= '.';
+ push @changes, mt($text, $setup);
+ push @confirm, '';
+ }
+}
+
+# Check for start date + setup date
+if ( $hash{'start_date'} and $hash{'setup'} ) {
+ if ( $cust_pkg->get('setup') ) {
+ push @errors, mt('Since the package has already started billing, it '.
+ 'cannot have a start date.');
+ } else {
+ push @errors, mt('You cannot set both a start date and a setup date on '.
+ 'the same package.');
+ }
+}
+
+# Last bill date change
+if ( $hash{'last_bill'} != $cust_pkg->get('last_bill') ) {
+ my $last_bill = time2str($date_format, $hash{'last_bill'});
+ my $name = 'last bill date';
+ $name = 'last renewal date' if $part_pkg->is_prepaid;
+ if ( $hash{'last_bill'} ) {
+ push @changes, mt('Set the [_1] to [_2].', $name, $last_bill);
+ } else {
+ push @changes, mt('Remove the [_1].', $name);
+ }
+ push @confirm, '';
+ # I don't think we want to adjust this on supplemental packages.
+}
+
+# Bill date change
+if ( $hash{'bill'} != $cust_pkg->get('bill') ) {
+ my $bill = time2str($date_format, $hash{'bill'});
+ $bill = 'the current day' if !$hash{'bill'}; # or 'the end of today'?...
+ my $name = 'next bill date';
+ $name = 'end of the prepaid period' if $part_pkg->is_prepaid;
+ push @changes, mt('Set the [_1] to [_2].', $name, $bill);
+
+ if ( $hash{'bill'} < time and $hash{'bill'} ) {
+ push @confirm,
+ mt('The customer will be charged for the interval from [_1] until now.',
+ $bill);
+ } else {
+ push @confirm, '';
+ }
+
+ if ( @supp_pkgs ) {
+ push @changes, '';
+ if ( $cust_pkg->get('bill') and $hash{'bill'} ) {
+ # the package already has a bill date, so adjust the dates
+ # of supplementals by the same interval
+ my $diff = $hash{'bill'} - $cust_pkg->get('bill');
+ my $sign = $diff < 0 ? -1 : 1;
+ $diff = $diff * $sign / 86400;
+ if ( $diff < 1 ) {
+ $diff = mt('[quant,_1,hour]', int($diff * 24));
+ } else {
+ $diff = mt('[quant,_1,day]', int($diff));
+ }
+ push @confirm,
+ mt('[_1] supplemental package will also be billed [_2] [_3].',
+ (@supp_pkgs > 1 ? 'Each' : 'The'),
+ $diff,
+ ($sign > 0 ? 'later' : 'earlier')
+ );
+ } else {
+ # the package hasn't been billed yet, or you've set bill = null
+ push @confirm,
+ mt('[_1] supplemental package will also be billed on [_2].',
+ (@supp_pkgs > 1 ? 'Each' : 'The'),
+ $bill
+ );
+ }
+ } #if @supp_pkgs
+
+ if ( $main_pkg ) {
+ push @changes, '';
+ push @confirm,
+ mt('This package is a supplemental package. The bill date of its '.
+ 'main package will not be adjusted.');
+ }
+}
+
+# Contract end change
+if ( $hash{'contract_end'} != $cust_pkg->get('contract_end') ) {
+ if ( $hash{'contract_end'} ) {
+ my $contract_end = time2str($date_format, $hash{'contract_end'});
+ push @changes,
+ mt('Set this package\'s contract end date to [_1]', $contract_end);
+ } else {
+ push @changes, mt('Remove this package\'s contract end date.');
+ }
+ if ( @supp_pkgs ) {
+ my $text = 'This change will also apply to ' .
+ (@supp_pkgs > 1 ?
+ 'all supplemental packages.':
+ 'the supplemental package.');
+ push @confirm, mt($text);
+ } else {
+ push @confirm, '';
+ }
+}
+
+my $title = '';
+if ( @errors ) {
+ $title = 'Error changing package dates';
+} else {
+ $title = 'Confirm date changes';
+}
+</%init>
+<& /elements/header-popup.html, { title => $title, etc => 'BGCOLOR=""' } &>
+<STYLE TYPE="text/css">
+.error {
+ color: #ff0000;
+ font-weight: bold;
+ text-align: center;
+}
+.confirm { color: #ff0000 }
+.button-container {
+ position: fixed;
+ bottom: 5px;
+ text-align: center;
+ width: 100%
+}
+</STYLE>
+<DIV STYLE="text-align: center; padding:1em">
+<% emt('Package #') %><B><% $pkgnum %></B>: <B><% $cust_pkg->part_pkg->pkg %></B><BR>
+% if ( @changes ) {
+ <% emt('The following changes will be made:') %>
+% } else {
+ <% emt('No changes will be made.') %>
+% }
+</DIV>
+<TABLE WIDTH="100%">
+% if ( @errors ) {
+% foreach my $error ( @errors ) {
+<TR>
+ <TD><IMG SRC="<%$p%>images/cross.png"></TD>
+ <TD CLASS="error"><% $error %></TD>
+</TR>
+% }
+% } else {
+% while (@changes, @confirm) {
+% my $text = shift @changes;
+% if (length $text) {
+<TR>
+ <TD><IMG SRC="<%$p%>images/tick.png"></TD>
+ <TD><% $text %></TD>
+</TR>
+% }
+% $text = shift @confirm;
+% if (length $text) {
+<TR>
+ <TD>
+ <INPUT TYPE="checkbox" NAME="areyousure" VALUE=1 onclick="submit_ready()">
+ </TD>
+ <TD CLASS="confirm"><% $text %></TD>
+</TR>
+% }
+% }
+% }
+</TABLE>
+%# action buttons
+<DIV CLASS="button-container">
+ <BUTTON TYPE="button" STYLE="width:145px" ID="submit_cancel"\
+ onclick="submit_cancel()">
+ <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel
+ </BUTTON>
+% if (!@errors ) {
+ <BUTTON TYPE="button" STYLE="width:145px" ID="submit_continue"\
+ onclick="submit_continue()">
+ <IMG SRC="<%$p%>images/tick.png" ALT=""> Continue
+ </BUTTON>
+</DIV>
+% }
+<FORM NAME="DateEditForm" STYLE="display:none" TARGET="_parent" ACTION="<%$p%>edit/process/REAL_cust_pkg.cgi" METHOD="POST">
+% foreach (keys %hash) {
+<INPUT TYPE="hidden" NAME="<%$_%>" VALUE="<% $hash{$_} |h%>">
+% }
+</FORM>
+<SCRIPT>
+function submit_ready() {
+ var ready = true;
+ var checkboxes = document.getElementsByName('areyousure');
+ var i;
+ for (i=0; i < checkboxes.length; i++) {
+ if (! checkboxes[i].checked ) {
+ ready = false;
+ }
+ }
+ document.getElementById('submit_continue').disabled = !ready;
+ return ready;
+}
+function submit_cancel() {
+ parent.nd(1);
+}
+function submit_continue() {
+ if ( submit_ready() ) {
+ document.forms.DateEditForm.submit();
+ }
+}
+submit_ready();
+</SCRIPT>
+<& /elements/footer.html &>
diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html
index bfc7b6903..993ea366c 100644
--- a/httemplate/misc/order_pkg.html
+++ b/httemplate/misc/order_pkg.html
@@ -129,9 +129,6 @@
<& /elements/standardize_locations.html,
'form' => "OrderPkgForm",
- 'onlyship' => 1,
- 'no_company' => 1,
- 'no_census' => 1,
'callback' => 'document.OrderPkgForm.submit();',
&>
diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html
index 988057163..15f266ab0 100644
--- a/httemplate/misc/xmlhttp-address_standardize.html
+++ b/httemplate/misc/xmlhttp-address_standardize.html
@@ -16,12 +16,10 @@ my %old = %{ decode_json($cgi->param('arg')) }
my %new;
-my @prefixes;
-if ($old{onlyship}) {
- @prefixes = ('ship_');
-} elsif ( $old{same} ) {
+my @prefixes = ('');
+if ( $old{same} ) {
@prefixes = ('bill_');
-} else {
+} elsif ( $old{billship} ) {
@prefixes = ('bill_', 'ship_');
}
my $all_same = 1;
@@ -44,6 +42,8 @@ foreach my $pre ( @prefixes ) {
$all_same = 0 if ( $new{$pre.$_} ne $old{$pre.$_} );
last if !$all_same;
}
+
+ $all_same = 0 if $new{$pre.'error'};
}
my $return = { old => \%old, new => \%new, all_same => $all_same };
diff --git a/httemplate/search/elements/search-html.html b/httemplate/search/elements/search-html.html
index 7ccf356ea..e760bc546 100644
--- a/httemplate/search/elements/search-html.html
+++ b/httemplate/search/elements/search-html.html
@@ -253,7 +253,17 @@
% $bgcolor = $bgcolor1;
% }
- <TR>
+% my $trid = '';
+% if ( $opt{'link_field' } ) {
+% my $link_field = $opt{'link_field'};
+% if ( ref($link_field) eq 'CODE' ) {
+% $trid = &{$link_field}($row);
+% } else {
+% $trid = $row->$link_field();
+% }
+% }
+ <TR ID="<%$trid |h%>">
+
% if ( $opt{'fields'} ) {
%
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index 5a16a22fe..68c488837 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -167,6 +167,11 @@ Example:
# miscellany
'download_label' => 'Download this report',
# defaults to 'Download full results'
+ 'link_field' => 'pkgpart'
+ # will create internal links for each row,
+ # with the value of this field as the NAME attribute
+ # If this is a coderef, will evaluate it, passing the
+ # row as an argument, and use the result as the NAME.
&>
</%doc>
diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html
index 7d7930634..7b5b15692 100755
--- a/httemplate/view/cust_main/packages.html
+++ b/httemplate/view/cust_main/packages.html
@@ -1,3 +1,22 @@
+<STYLE TYPE="text/css">
+td.package {
+ vertical-align: top;
+ border-width: 0;
+ border-style: solid;
+ border-color: #bbbbff;
+}
+table.package {
+ border: none;
+ padding: 0;
+ border-spacing: 0;
+ width: 100%;
+}
+<!-- even/odd rows -->
+
+.row0 { background-color: #eeeeee; }
+.row1 { background-color: #ffffff; }
+
+</STYLE>
% my $s = 0;
% if ( $curuser->access_right('Qualify service') ) {
@@ -116,7 +135,7 @@ my( $packages, $num_old_packages ) = get_packages($cust_main, $conf);
my $show_location = $conf->exists('cust_pkg-always_show_location')
- || (grep $_->locationnum, @$packages); # ? '1' : '0';
+ || (grep $_->locationnum ne $cust_main->ship_locationnum, @$packages);
my $countrydefault = scalar($conf->config('countrydefault')) || 'US';
#subroutines
@@ -178,6 +197,10 @@ sub get_packages {
}
$num_old_packages -= scalar(@packages);
+
+ # don't include supplemental packages in this list; they'll be found from
+ # their main packages
+ @packages = grep !$_->main_pkgnum, @packages;
( \@packages, $num_old_packages );
}
diff --git a/httemplate/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html
index 5d93ad46f..3a362b6fa 100644
--- a/httemplate/view/cust_main/packages/package.html
+++ b/httemplate/view/cust_main/packages/package.html
@@ -1,5 +1,6 @@
-<TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="top">
- <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
+<TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top"
+ STYLE="border-left-width: <% $supplemental * 30 %>px">
+ <TABLE CLASS="inv package">
<TR>
<TD COLSPAN=2>
<A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
@@ -17,7 +18,7 @@
<B><% $cust_pkg->quantity %></B>
</TD>
</TR>
-% }
+% }
<TR>
<TD COLSPAN=2>
@@ -25,42 +26,51 @@
% unless ( $cust_pkg->get('cancel') ) {
%
-% my $br = 0;
-% if ( $curuser->access_right('Change customer package') ) {
-% $br=1;
- (&nbsp;<%pkg_change_link($cust_pkg)%>&nbsp;)
-% }
+% if ( $supplemental ) {
+% # then only show "Edit dates", "Add invoice details", and "Add
+% # comments".
+% if ( $curuser->access_right('Edit customer package dates') ) {
+ (&nbsp;<%pkg_dates_link($cust_pkg)%>&nbsp;)
+% }
+% } else {
+% # the usual case
+% my $br = 0;
+% if ( $curuser->access_right('Change customer package') ) {
+% $br=1;
+ (&nbsp;<%pkg_change_link($cust_pkg)%>&nbsp;)
+% }
%
-% if ( $curuser->access_right('Edit customer package dates') ) {
-% $br=1;
- (&nbsp;<%pkg_dates_link($cust_pkg)%>&nbsp;)
-% }
+% if ( $curuser->access_right('Edit customer package dates') ) {
+% $br=1;
+ (&nbsp;<%pkg_dates_link($cust_pkg)%>&nbsp;)
+% }
%
-% if ( $curuser->access_right('Discount customer package')
-% && $part_pkg->can_discount
-% && ! scalar($cust_pkg->cust_pkg_discount_active)
-% && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
-% )
-% {
-% $br=1;
- (&nbsp;<%pkg_discount_link($cust_pkg)%>&nbsp;)
-% }
+% if ( $curuser->access_right('Discount customer package')
+% && $part_pkg->can_discount
+% && ! scalar($cust_pkg->cust_pkg_discount_active)
+% && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
+% )
+% {
+% $br=1;
+ (&nbsp;<%pkg_discount_link($cust_pkg)%>&nbsp;)
+% }
%
-% if ( $curuser->access_right('Customize customer package') ) {
-% $br=1;
- (&nbsp;<%pkg_customize_link($cust_pkg,$part_pkg)%>&nbsp;)
-% }
+% if ( $curuser->access_right('Customize customer package') ) {
+% $br=1;
+ (&nbsp;<%pkg_customize_link($cust_pkg,$part_pkg)%>&nbsp;)
+% }
%
- <% $br ? '<BR>' : '' %>
-% }
+ <% $br ? '<BR>' : '' %>
+% }
-% if ( $cust_pkg->num_cust_event
-% && ( $curuser->access_right('Billing event reports')
-% || $curuser->access_right('View customer billing events')
-% )
-% ) {
- (&nbsp;<%pkg_event_link($cust_pkg)%>&nbsp;)
-% }
+% if ( $cust_pkg->num_cust_event
+% && ( $curuser->access_right('Billing event reports')
+% || $curuser->access_right('View customer billing events')
+% )
+% ) {
+ (&nbsp;<%pkg_event_link($cust_pkg)%>&nbsp;)
+% }
+% } #!$supplemental
</FONT>
</TD>
@@ -170,6 +180,7 @@
</TR>
% if ( $curuser->access_right('Change customer package') and
% !$cust_pkg->get('cancel') and
+% !$supplemental and
% !$opt{'show_location'}) {
<TR>
<TD><FONT SIZE="-1">
@@ -196,6 +207,7 @@ my $countrydefault = $opt{'countrydefault'} || 'US';
my $statedefault = $opt{'statedefault'}
|| ($countrydefault eq 'US' ? 'CA' : '');
+my $supplemental = $opt{'supplemental'} || 0;
#subroutines
#false laziness w/status.html
diff --git a/httemplate/view/cust_main/packages/section.html b/httemplate/view/cust_main/packages/section.html
index 85f0c795a..52246192f 100755
--- a/httemplate/view/cust_main/packages/section.html
+++ b/httemplate/view/cust_main/packages/section.html
@@ -1,8 +1,4 @@
% if ( @$packages ) {
-% my $bgcolor1 = '#eeeeee';
-% my $bgcolor2 = '#ffffff';
-% my $bgcolor = '';
-
<TR>
% #my $width = $show_location ? 'WIDTH="25%"' : 'WIDTH="33%"';
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Package') |h %></TH>
@@ -15,39 +11,38 @@
% #$FS::cust_pkg::DEBUG = 2;
% foreach my $cust_pkg (@$packages) {
+ <& .packagerow, $cust_pkg,
+ 'cust_main' => $opt{'cust_main'},
+ %conf_opt
+ &>
+% }
+% } else { # there are no packages
+<BR>
+% }
+<%def .packagerow>
%
-% if ( $bgcolor eq $bgcolor1 ) {
-% $bgcolor = $bgcolor2;
-% } else {
-% $bgcolor = $bgcolor1;
-% }
-%
-% my %iopt = (
-% 'bgcolor' => $bgcolor,
-% 'cust_pkg' => $cust_pkg,
-% 'part_pkg' => $cust_pkg->part_pkg,
-% 'cust_main' => $opt{'cust_main'},
-% %conf_opt,
-% );
-%
-
+% my ($cust_pkg, %iopt) = @_;
+% $iopt{'cust_pkg'} = $cust_pkg;
+% $iopt{'part_pkg'} = $cust_pkg->part_pkg;
<!--pkgnum: <% $cust_pkg->pkgnum %>-->
- <TR>
+ <TR CLASS="row<%$row % 2%>">
<& package.html, %iopt &>
<& status.html, %iopt &>
-% if ( $show_location ) {
+% if ( $iopt{'show_location'} ) {
<& location.html, %iopt &>
% }
<& services.html, %iopt &>
</TR>
-
-% } #foreach $cust_pkg
-%# </TABLE>
-% } #if @$packages
-% else {
-<BR>
+% $row++;
+% # include supplemental packages if any
+% $iopt{'supplemental'} = ($iopt{'supplemental'} || 0) + 1;
+% foreach my $supp_pkg ($cust_pkg->supplemental_pkgs) {
+ <& .packagerow, $supp_pkg, %iopt &>
% }
-
+</%def>
+<%shared>
+my $row = 0;
+</%shared>
<%init>
my %opt = @_;
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index e9017745b..6be0296a3 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -3,7 +3,9 @@
%#this should use cust_pkg->status and cust_pkg->statuscolor eventually
-% if ( $cust_pkg->order_date ) {
+% if ( $supplemental ) {
+ <% pkg_status_row_colspan($cust_pkg, emt('Supplemental'), '', 'color' => '7777FF', %opt) %>
+% } elsif ( $cust_pkg->order_date ) {
<% pkg_status_row($cust_pkg, emt('Ordered'), 'order_date', %opt ) %>
% }
@@ -12,30 +14,25 @@
<% pkg_status_row($cust_pkg, emt('Cancelled'), 'cancel', 'color'=>'FF0000', %opt ) %>
- <% pkg_status_row_colspan( $cust_pkg,
- ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
- 'align'=>'right', 'color'=>'ff0000', 'size'=>'-2', 'colspan'=>$colspan,
- %opt
- )
- %>
+ <% pkg_reason_row($cust_pkg, $cpr, color => 'ff0000', %opt) %>
% unless ( $cust_pkg->get('setup') ) {
- <% pkg_status_row_colspan( $cust_pkg, emt('Never billed'), '', 'colspan'=>$colspan, %opt, ) %>
+ <% pkg_status_row_colspan( $cust_pkg, emt('Never billed'), '', %opt, ) %>
% } else {
<% pkg_status_row( $cust_pkg, emt('Setup'), 'setup', %opt ) %>
- <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_changed( $cust_pkg, %opt ) %>
<% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
<% pkg_status_row_if( $cust_pkg, emt('Suspended'), 'susp', %opt, curuser=>$curuser ) %>
% }
%
-% if ( $part_pkg->freq ) { #?
+% if ( $part_pkg->freq and !$supplemental ) { #?
<TR>
- <TD COLSPAN=<%$colspan%>>
+ <TD COLSPAN=<%$opt{colspan}%>>
<FONT SIZE=-1>
% if ( $curuser->access_right('Un-cancel customer package') ) {
(&nbsp;<% pkg_uncancel_link($cust_pkg) %>&nbsp;)
@@ -52,26 +49,21 @@
<% pkg_status_row( $cust_pkg, emt('Suspended'), 'susp', 'color'=>'FF9900', %opt ) %>
- <% pkg_status_row_colspan( $cust_pkg,
- ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
- 'align'=>'right', 'color'=>'FF9900', 'size'=>'-2', 'colspan'=>$colspan,
- %opt,
- )
- %>
+ <% pkg_reason_row( $cust_pkg, $cpr, 'color' => 'FF9900', %opt ) %>
- <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_noauto( $cust_pkg, %opt ) %>
- <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt ) %>
% unless ( $cust_pkg->get('setup') ) {
- <% pkg_status_row_colspan( $cust_pkg, emt('Never billed'), '', 'colspan'=>$colspan, %opt ) %>
+ <% pkg_status_row_colspan( $cust_pkg, emt('Never billed'), '', %opt ) %>
% } else {
<% pkg_status_row($cust_pkg, emt('Setup'), 'setup', %opt ) %>
% }
<% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %>
- <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_changed( $cust_pkg, %opt ) %>
<% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
% if ( $cust_pkg->option('suspend_bill', 1)
% || ( $part_pkg->option('suspend_bill', 1)
@@ -85,31 +77,33 @@
<% pkg_status_row_if( $cust_pkg, emt('Expires'), 'expire', %opt, curuser=>$curuser ) %>
<% pkg_status_row_if( $cust_pkg, emt('Contract ends'), 'contract_end', %opt ) %>
- <TR>
- <TD COLSPAN=<%$colspan%>>
- <FONT SIZE=-1>
-% if ( $curuser->access_right('Unsuspend customer package') ) {
- (&nbsp;<% pkg_unsuspend_link($cust_pkg) %>&nbsp;)
- (&nbsp;<% pkg_resume_link($cust_pkg) %>&nbsp;)
-% }
-% if ( $curuser->access_right('Cancel customer package immediately') ) {
- (&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
-% }
- </FONT>
- </TD>
- </TR>
-
+% if ( !$supplemental ) {
+ <TR>
+ <TD COLSPAN=<%$opt{colspan}%>>
+ <FONT SIZE=-1>
+% if ( $curuser->access_right('Unsuspend customer package') ) {
+ (&nbsp;<% pkg_unsuspend_link($cust_pkg) %>&nbsp;)
+ (&nbsp;<% pkg_resume_link($cust_pkg) %>&nbsp;)
+% }
+% if ( $curuser->access_right('Cancel customer package immediately') ) {
+ (&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
+% }
+ </FONT>
+ </TD>
+ </TR>
+% }
+%
% } else { #status: active
%
% unless ( $cust_pkg->get('setup') ) { #not setup
%
% unless ( $part_pkg->freq ) {
- <% pkg_status_row_colspan( $cust_pkg, emt('Not yet billed (one-time charge)'), '', 'colspan'=>$colspan, %opt ) %>
+ <% pkg_status_row_colspan( $cust_pkg, emt('Not yet billed (one-time charge)'), '', %opt ) %>
- <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_noauto( $cust_pkg, %opt ) %>
- <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt ) %>
<% pkg_status_row_if(
$cust_pkg,
@@ -121,8 +115,9 @@
<% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %>
+% if (!$supplemental) {
<TR>
- <TD COLSPAN=<%$colspan%>>
+ <TD COLSPAN=<%$opt{colspan}%>>
<FONT SIZE=-1>
% if ( $curuser->access_right('Cancel customer package immediately') ) {
(&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
@@ -130,14 +125,15 @@
</FONT>
</TD>
</TR>
+% }
% } else {
- <% pkg_status_row_colspan($cust_pkg, emt("Not yet billed ($billed_or_prepaid [_1])", myfreq($part_pkg) ), '', 'colspan'=>$colspan, %opt ) %>
+ <% pkg_status_row_colspan($cust_pkg, emt("Not yet billed ($billed_or_prepaid [_1])", myfreq($part_pkg) ), '', %opt ) %>
- <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_noauto( $cust_pkg, %opt ) %>
- <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt ) %>
<% pkg_status_row_if($cust_pkg, emt('Start billing'), 'start_date', %opt) %>
<% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %>
@@ -148,13 +144,13 @@
%
% unless ( $part_pkg->freq ) {
- <% pkg_status_row_colspan($cust_pkg, emt('One-time charge'), '', 'colspan'=>$colspan, %opt ) %>
+ <% pkg_status_row_colspan($cust_pkg, emt('One-time charge'), '', %opt ) %>
<% pkg_status_row($cust_pkg, emt('Billed'), 'setup', %opt) %>
- <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_noauto( $cust_pkg, %opt ) %>
- <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt ) %>
<% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %>
@@ -170,7 +166,7 @@
<% pkg_status_row_colspan( $cust_pkg,
emt('Overlimit'),
$billed_or_prepaid. '&nbsp;'. myfreq($part_pkg),
- 'color'=>'FFD000', 'colspan'=>$colspan,
+ 'color'=>'FFD000',
%opt
)
%>
@@ -179,15 +175,15 @@
<% pkg_status_row_colspan( $cust_pkg,
emt('Active'),
$billed_or_prepaid. '&nbsp;'. myfreq($part_pkg),
- 'color'=>'00CC00', 'colspan'=>$colspan,
+ 'color'=>'00CC00',
%opt
)
%>
% }
- <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_noauto( $cust_pkg, %opt ) %>
- <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt ) %>
<% pkg_status_row($cust_pkg, emt('Setup'), 'setup', %opt) %>
@@ -202,7 +198,7 @@
% $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend;
% }
- <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+ <% pkg_status_row_changed( $cust_pkg, %opt ) %>
<% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
<% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', %opt, curuser=>$curuser ) %>
<% pkg_status_row_if($cust_pkg, emt('Will automatically suspend by'), 'autosuspend', %opt) %>
@@ -212,10 +208,10 @@
<% pkg_status_row_if( $cust_pkg, emt('Expires'), 'expire', %opt, curuser=>$curuser ) %>
<% pkg_status_row_if( $cust_pkg, emt('Contract ends'), 'contract_end', %opt ) %>
-% if ( $part_pkg->freq ) {
+% if ( $part_pkg->freq and !$supplemental ) {
<TR>
- <TD COLSPAN=<%$colspan%>>
+ <TD COLSPAN=<%$opt{colspan}%>>
<FONT SIZE=-1>
% if ( $curuser->access_right('Suspend customer package') ) {
(&nbsp;<% pkg_suspend_link($cust_pkg) %>&nbsp;)
@@ -251,8 +247,10 @@ my $bgcolor = $opt{'bgcolor'};
my $cust_pkg = $opt{'cust_pkg'};
my $part_pkg = $opt{'part_pkg'};
my $curuser = $FS::CurrentUser::CurrentUser;
-my $colspan = $opt{'cust_pkg-display_times'} ? 8 : 4;
my $width = $opt{'cust_pkg-display_times'} ? '38%' : '56%';
+my $supplemental = $opt{'supplemental'};
+
+$opt{colspan} = $opt{'cust_pkg-display_times'} ? 8 : 4;
#false laziness w/edit/REAL_cust_pkg.cgi
my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
@@ -285,9 +283,27 @@ sub pkg_link {
sub pkg_status_row {
my( $cust_pkg, $title, $field, %opt ) = @_;
+ if ( $field and $cust_pkg->main_pkgnum ) {
+ # for supplemental packages, we mostly only show these if they're
+ # different from the main package
+ my $main_pkg = $cust_pkg-> main_pkg;
+ if ( $main_pkg->get($field) ne $cust_pkg->get($field)
+ # with some exceptions
+ or $field eq 'bill'
+ or $field eq 'last_bill'
+ or $field eq 'setup'
+ or $field eq 'susp'
+ or $field eq 'cancel'
+ ) {
+ # handle it normally
+ } else {
+ return '';
+ }
+ }
+
my $color = $opt{'color'};
- my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
+ my $html = qq(<TR><TD WIDTH="$width" ALIGN="right">);
$html .= qq(<FONT COLOR="#$color"><B>) if length($color);
$html .= qq($title&nbsp;);
$html .= qq(</B></FONT>) if length($color);
@@ -338,7 +354,6 @@ sub pkg_status_row_changed {
'',
'size' => '-1',
'align' => 'right',
- 'colspan' => $opt{'colspan'},
);
}
@@ -356,9 +371,7 @@ sub pkg_status_row_noauto {
return '' unless $cust_main->payby =~ /^(CARD|CHEK)$/;
my $what = lc(FS::payby->shortname($cust_main->payby));
- pkg_status_row_colspan( $cust_pkg, emt("No automatic $what charge"), '',
- 'colspan' => $opt{'colspan'},
- );
+ pkg_status_row_colspan( $cust_pkg, emt("No automatic $what charge"), '');
}
sub pkg_status_row_discount {
@@ -382,15 +395,24 @@ sub pkg_status_row_discount {
$cust_pkg_discount->pkgdiscountnum.
'">'.emt('remove discount').'</A>)</FONT>';
- $html .= pkg_status_row_colspan( $cust_pkg, $label, '',
- 'colspan' => $opt{'colspan'},
- );
+ $html .= pkg_status_row_colspan( $cust_pkg, $label, '', %opt );
}
$html;
}
+sub pkg_reason_row {
+ my ($cust_pkg, $cpr, %opt) = @_;
+ return '' if $cust_pkg->main_pkgnum;
+
+ my $reasontext = '';
+ $reasontext = $cpr->reasontext . ' by ' . $cpr->otaker if $cpr;
+ pkg_status_row_colspan( $cust_pkg, $reasontext, '',
+ 'align'=>'right', 'size'=>'-2', %opt
+ );
+}
+
sub pkg_status_row_colspan {
my($cust_pkg, $title, $addl, %opt) = @_;