diff options
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-x | httemplate/misc/change_pkg.cgi | 3 | ||||
-rw-r--r-- | httemplate/misc/confirm-address_standardize.html | 12 | ||||
-rwxr-xr-x | httemplate/misc/confirm-cust_pkg-edit_dates.html | 283 | ||||
-rw-r--r-- | httemplate/misc/order_pkg.html | 3 | ||||
-rw-r--r-- | httemplate/misc/xmlhttp-address_standardize.html | 10 |
5 files changed, 293 insertions, 18 deletions
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 }; |