summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhttemplate/edit/REAL_cust_pkg.cgi244
-rwxr-xr-xhttemplate/edit/process/REAL_cust_pkg.cgi59
-rwxr-xr-xhttemplate/misc/confirm-cust_pkg-edit_dates.html289
-rw-r--r--httemplate/view/cust_main/packages/package.html12
4 files changed, 1 insertions, 603 deletions
diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi
deleted file mode 100755
index 99e911ae5..000000000
--- a/httemplate/edit/REAL_cust_pkg.cgi
+++ /dev/null
@@ -1,244 +0,0 @@
-<% include("/elements/header.html",'Customer package - Edit dates') %>
-
-%#, menubar(
-%# "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
-%#));
-
-<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
-<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
-<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 %>">
-
-% # raw error from below
-% if ( $error ) {
- <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
-% }
-% #or, regular error handler
-<% include('/elements/error.html') %>
-
-<% ntable("#cccccc",2) %>
-
- <TR>
- <TD ALIGN="right">Package number</TD>
- <TD BGCOLOR="#ffffff"><% $cust_pkg->pkgnum %></TD>
- </TR>
-
- <TR>
- <TD ALIGN="right">Package</TD>
- <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>
- </TR>
-
- <TR>
- <TD ALIGN="right">Comment</TD>
- <TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
- </TR>
-
- <TR>
- <TD ALIGN="right">Order taker</TD>
- <TD BGCOLOR="#ffffff"><% $cust_pkg->otaker %></TD>
- </TR>
-
- <& .row_display, cust_pkg=>$cust_pkg, column=>'order_date', label=>'Order' &>
-% 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', if_primary=>1 &>
-% }
-
- <& .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', 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' &>
- <& .row_display, cust_pkg=>$cust_pkg, column=>'resume', label=>'Resumption', note=> '(will <b>unsuspend</b> this package when the date is reached' &>
-
- <& .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
- $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>
- <INPUT TYPE = "text"
- NAME = "<% $column %>"
- SIZE = 32
- ID = "<% $column %>_text"
- VALUE = "<% $value %>"
- >
- <IMG SRC = "../images/calendar.png"
- ID = "<% $column %>_button"
- STYLE = "cursor: pointer"
- TITLE = "Select date"
- >
-% if ( $note ) {
- <BR><FONT SIZE=-1><% $note %></FONT>
-% }
- </TD>
- </TR>
-
- <SCRIPT TYPE="text/javascript">
- Calendar.setup({
- inputField: "<% $column %>_text",
- ifFormat: "<% $date_format %>",
- button: "<% $column %>_button",
- align: "BR"
- });
-
- submit_fields.push('<%$column%>');
-
- </SCRIPT>
-% }
-</%def>
-
-<%def .row_display>
-<%args>
- $cust_pkg
- $column
- $label
- $note => ''
- $is_primary => 0 #ignored
-</%args>
-% if ( $cust_pkg->get($column) ) {
- <TR>
- <TD ALIGN="right"><% $label %> date</TD>
- <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %>
-% if ( $note ) {
- <BR><FONT SIZE=-1><% $note %></FONT>
-% }
- </TD>
- </TR>
-% }
-</%def>
-
-</TABLE>
-
-<BR>
-<INPUT TYPE="button" VALUE="<% mt('Apply changes') |h %>" onclick="confirm_changes()">
-</FORM>
-
-<% include('/elements/footer.html') %>
-<%shared>
-
-my $conf = new FS::Conf;
-my $date_format = $conf->config('date_format') || '%m/%d/%Y';
-
-my $format = $date_format. ' %T'; # %z (%Z)';
-
-</%shared>
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
-
-
-my $error = '';
-my( $pkgnum, $cust_pkg );
-
-if ( $cgi->param('error') ) {
-
- $pkgnum = $cgi->param('pkgnum');
-
- if ( $cgi->param('error') =~ /^_/ ) {
-
- my @errors = ();
- my %errors = map { $_=>1 } split(',', $cgi->param('error'));
- $cgi->param('error', '');
- $error = join('<BR><BR>', @errors );
-
- }
-
- #get package record
- $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
- die "No package!" unless $cust_pkg;
-
- foreach my $col (qw( start_date setup last_bill bill )) {
- my $value = $cgi->param($col);
- $cust_pkg->set( $col, $value ? parse_datetime($value) : '' );
- }
-
-} else {
-
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/ or die "no pkgnum";
- $pkgnum = $1;
-
- #get package record
- $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
- die "No package!" unless $cust_pkg;
-
-}
-
-my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $cust_pkg->pkgpart } );
-
-my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
-unless ( $part_pkg->is_prepaid ) {
- #$billed_or_prepaid = 'billed';
- $last_bill_or_renewed = 'Last bill';
- $next_bill_or_prepaid_until = 'Next bill';
-} else {
- #$billed_or_prepaid = 'prepaid';
- $last_bill_or_renewed = 'Renewed';
- $next_bill_or_prepaid_until = 'Prepaid until';
-}
-
-</%init>
diff --git a/httemplate/edit/process/REAL_cust_pkg.cgi b/httemplate/edit/process/REAL_cust_pkg.cgi
deleted file mode 100755
index fd2893487..000000000
--- a/httemplate/edit/process/REAL_cust_pkg.cgi
+++ /dev/null
@@ -1,59 +0,0 @@
-%if ( $error ) {
-% $cgi->param('error', $error);
-<% $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ) %>
-%} else {
-% my $custnum = $new->custnum;
-% my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
-% ? ''
-% : ';show=packages';
-% my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
-<% $cgi->redirect(popurl(3). "view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag" ) %>
-%}
-<%init>
-
-my $curuser = $FS::CurrentUser::CurrentUser;
-
-die "access denied"
- unless $curuser->access_right('Edit customer package dates');
-
-my $pkgnum = $cgi->param('pkgnum') or die;
-my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
-my %hash = $old->hash;
-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 $new;
-my $error;
-$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/misc/confirm-cust_pkg-edit_dates.html b/httemplate/misc/confirm-cust_pkg-edit_dates.html
deleted file mode 100755
index 8e548527a..000000000
--- a/httemplate/misc/confirm-cust_pkg-edit_dates.html
+++ /dev/null
@@ -1,289 +0,0 @@
-<%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 ( $hash{'setup'} and !$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 = 'today' 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);
- } elsif ( !$hash{'bill'} and ($hash{'last_bill'} or $hash{'setup'}) ) {
- my $last_bill =
- time2str($date_format, $hash{'last_bill'} || $hash{'setup'});
- push @confirm,
- mt('The customer will be charged for the interval from [_1] until now.',
- $last_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/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html
index 520305a9a..2267294b3 100644
--- a/httemplate/view/cust_main/packages/package.html
+++ b/httemplate/view/cust_main/packages/package.html
@@ -29,11 +29,8 @@
% if ( $supplemental or $part_pkg->freq eq '0' ) {
% # Supplemental packages can't be changed independently.
% # One-time charges don't need to be changed.
-% # For both of those, we only show "Edit dates", "Add comments",
+% # For both of those, we only show "Add comments",
% # and "Add invoice details".
-% if ( $curuser->access_right('Edit customer package dates') ) {
- (&nbsp;<%pkg_dates_link($cust_pkg)%>&nbsp;)
-% }
% } else {
% # the usual case: links to change package definition,
% # discount, and customization
@@ -43,11 +40,6 @@
(&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('Discount customer package')
% && $part_pkg->can_discount
% && ! scalar($cust_pkg->cust_pkg_discount_active)
@@ -290,8 +282,6 @@ sub pkg_change_quantity_link {
);
}
-sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
-
sub pkg_discount_link {
my $cust_pkg = shift or return '';
include( '/elements/popup_link-cust_pkg.html',