From: Ivan Kohler Date: Fri, 31 May 2013 19:59:30 +0000 (-0700) Subject: its time. no more edit dates in 4.x. X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=83a80303c6bc862de098ed693bd43e0d52807156 its time. no more edit dates in 4.x. --- 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", -%#)); - - - - - - - -
- - -% # raw error from below -% if ( $error ) { - Error: <% $error %> -% } -% #or, regular error handler -<% include('/elements/error.html') %> - -<% ntable("#cccccc",2) %> - - - Package number - <% $cust_pkg->pkgnum %> - - - - Package - <% $part_pkg->pkg %> - - -% if ( $cust_pkg->main_pkgnum ) { -% my $main_pkg = $cust_pkg->main_pkg; - - Supplemental to - Package #<% $cust_pkg->main_pkgnum%>: \ - <% $main_pkg->part_pkg->pkg %> - - -% } - - Custom - <% $part_pkg->custom %> - - - - Comment - <% $part_pkg->comment |h %> - - - - Order taker - <% $cust_pkg->otaker %> - - - <& .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 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=>'resume', label=>'Resumption', note=> '(will unsuspend this package when the date is reached' &> - - <& .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 - $column - $label - $note => '' - $if_primary => 0 - -% 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) { - - - <& .row_display, %ARGS &> -% } else { - - <% $label %> date - - - -% if ( $note ) { -
<% $note %> -% } - - - - -% } - - -<%def .row_display> -<%args> - $cust_pkg - $column - $label - $note => '' - $is_primary => 0 #ignored - -% if ( $cust_pkg->get($column) ) { - - <% $label %> date - <% time2str($format,$cust_pkg->get($column)) %> -% if ( $note ) { -
<% $note %> -% } - - -% } - - - - -
- -
- -<% 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)'; - - -<%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('

', @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'; -} - - 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; - } -} - - 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'; -} - -<& /elements/header-popup.html, { title => $title, etc => 'BGCOLOR=""' } &> - -
-<% emt('Package #') %><% $pkgnum %>: <% $cust_pkg->part_pkg->pkg %>
-% if ( @changes ) { - <% emt('The following changes will be made:') %> -% } else { - <% emt('No changes will be made.') %> -% } -
- -% if ( @errors ) { -% foreach my $error ( @errors ) { - - - - -% } -% } else { -% while (@changes, @confirm) { -% my $text = shift @changes; -% if (length $text) { - - - - -% } -% $text = shift @confirm; -% if (length $text) { - - - - -% } -% } -% } -
<% $error %>
<% $text %>
- - <% $text %>
-%# action buttons -
- -% if (!@errors ) { - -
-% } -
-% foreach (keys %hash) { - -% } -
- -<& /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') ) { - ( <%pkg_dates_link($cust_pkg)%> ) -% } % } else { % # the usual case: links to change package definition, % # discount, and customization @@ -43,11 +40,6 @@ ( <%pkg_change_link($cust_pkg)%> ) % } % -% if ( $curuser->access_right('Edit customer package dates') ) { -% $br=1; - ( <%pkg_dates_link($cust_pkg)%> ) -% } -% % 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',