summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/misc/cust_main-merge.html12
-rw-r--r--httemplate/misc/merge_cust.html42
-rwxr-xr-xhttemplate/view/cust_main.cgi11
-rw-r--r--httemplate/view/cust_main/packages/contact.html28
-rwxr-xr-xhttemplate/view/cust_main/packages/section.html12
-rw-r--r--httemplate/view/cust_main/packages/status.html7
6 files changed, 90 insertions, 22 deletions
diff --git a/httemplate/misc/cust_main-merge.html b/httemplate/misc/cust_main-merge.html
index 4decbef7a..3b4425fc8 100755
--- a/httemplate/misc/cust_main-merge.html
+++ b/httemplate/misc/cust_main-merge.html
@@ -31,7 +31,17 @@ if ( $cgi->param('new_custnum') =~ /^(\d+)$/ ) {
} );
die "No customer # $custnum" unless $cust_main;
- $error = $cust_main->merge($new_custnum);
+ if ( $cgi->param('merge') eq 'Y' ) {
+
+ #old-style merge: everything + delete old customer
+ $error = $cust_main->merge($new_custnum);
+
+ } else {
+
+ #new-style attach: move packages 3.0 style, that's it
+ $error = $cust_main->attach_pkgs($new_custnum);
+
+ }
} else {
$error = 'Select a customer to merge into';
diff --git a/httemplate/misc/merge_cust.html b/httemplate/misc/merge_cust.html
index ad075be2f..9c869fa21 100644
--- a/httemplate/misc/merge_cust.html
+++ b/httemplate/misc/merge_cust.html
@@ -1,6 +1,6 @@
-<% include('/elements/header-popup.html', 'Merge customer' ) %>
+<& /elements/header-popup.html, 'Merge customer' &>
-<% include('/elements/error.html') %>
+<& /elements/error.html &>
<FORM NAME="cust_merge_popup" ID="cust_merge_popup" ACTION="<% popurl(1) %>cust_main-merge.html" METHOD=POST onSubmit="submit_merge(); return false;">
@@ -35,13 +35,43 @@ function do_submit_merge() {
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<TABLE BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
- <% include('/elements/tr-search-cust_main.html',
+
+ <& /elements/tr-search-cust_main.html,
'label' => 'Merge into: ',
'field' => 'new_custnum',
'find_button' => 1,
'curr_value' => scalar($cgi->param('new_custnum')),
- )
- %>
+ &>
+
+% if ( $conf->exists('deletecustomers') ) {
+
+% if ( scalar($cust_main->ncancelled_pkgs) ) {
+ <TR>
+ <TD COLSPAN=2>
+ <& /elements/radio.html,
+ 'field' => 'merge',
+ 'value' => '',
+ 'curr_value' => scalar($cgi->param('merge')),
+ &>
+ Merge packages only.
+ </TD>
+ </TR>
+% } else {
+% $cgi->param('merge', 'Y');
+% }
+
+ <TR>
+ <TD COLSPAN=2>
+ <& /elements/radio.html,
+ 'field' => 'merge',
+ 'value' => 'Y',
+ 'curr_value' => scalar($cgi->param('merge')),
+ &>
+ Merge invoices, payments/credits, notes, tickets and delete this customer.
+ </TD>
+ </TR>
+% }
+
</TABLE>
<P ALIGN="CENTER">
@@ -54,6 +84,8 @@ function do_submit_merge() {
<%init>
+my $conf = new FS::Conf;
+
$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
my $custnum = $1;
diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi
index ec3191971..be0100fb3 100755
--- a/httemplate/view/cust_main.cgi
+++ b/httemplate/view/cust_main.cgi
@@ -91,14 +91,19 @@ function areyousure(href, message) {
&> |
% }
-% if ( $curuser->access_right('Merge customer') ) {
+% if ( $curuser->access_right('Merge customer')
+% and ( scalar($cust_main->ncancelled_pkgs)
+% || $conf->exists('deletecustomers')
+% )
+% )
+% {
<& /elements/popup_link-cust_main.html,
{ 'action' => $p. 'misc/merge_cust.html',
'label' => emt('Merge this customer'),
'actionlabel' => emt('Merge customer'),
'cust_main' => $cust_main,
- 'width' => 480,
- 'height' => 192,
+ 'width' => 569,
+ 'height' => 210,
}
&> |
% }
diff --git a/httemplate/view/cust_main/packages/contact.html b/httemplate/view/cust_main/packages/contact.html
index 4e0551b31..fe8b71534 100644
--- a/httemplate/view/cust_main/packages/contact.html
+++ b/httemplate/view/cust_main/packages/contact.html
@@ -1,15 +1,19 @@
% if ( $contact ) {
<% $contact->line |h %>
-% if ( $show_link ) {
+% if ( $show_change_link ) {
<FONT SIZE=-1>
(&nbsp;<%pkg_change_contact_link($cust_pkg)%>&nbsp;)
- (&nbsp;<%pkg_detach_link($cust_pkg)%>&nbsp;)
</FONT>
-% }
-% } elsif ( $show_link ) {
+% }
+% if ( $show_detach_link ) {
<FONT SIZE=-1>
- (&nbsp;<%pkg_add_contact_link($cust_pkg)%>&nbsp;)
+ (&nbsp;<%pkg_detach_link($cust_pkg)%>&nbsp;)
</FONT>
+% }
+% } elsif ( $show_contact_link ) {
+ <FONT SIZE=-1>
+ (&nbsp;<%pkg_add_contact_link($cust_pkg)%>&nbsp;)
+ </FONT>
% }
<%init>
@@ -18,10 +22,18 @@ my %opt = @_;
my $cust_pkg = $opt{'cust_pkg'};
-my $show_link =
+my $show_change_link =
! $cust_pkg->get('cancel')
&& $FS::CurrentUser::CurrentUser->access_right('Change customer package');
+my $show_detach_link =
+ ! $cust_pkg->get('cancel')
+ && $FS::CurrentUser::CurrentUser->access_right('Detach customer package');
+
+my $show_contact_link =
+ ! $cust_pkg->get('cancel')
+ ; #&& $FS::CurrentUser::CurrentUser->access_right('Add package contact'); #or something like that
+
my $contact = $cust_pkg->contact_obj;
sub pkg_change_contact_link {
@@ -43,7 +55,7 @@ sub pkg_add_contact_link {
include( '/elements/popup_link-cust_pkg.html',
'action' => $p. "misc/change_pkg_contact.html",
'label' => emt('Add contact'),
- 'actionlabel' => emt('Change'),
+ 'actionlabel' => emt('Add contact'),
'cust_pkg' => $cust_pkg,
'width' => 616,
'height' => 192,
@@ -59,7 +71,7 @@ sub pkg_detach_link {
'actionlabel' => emt('Detach'),
'cust_pkg' => $cust_pkg,
'width' => 616,
- 'height' => 676,
+ 'height' => 684,
);
}
diff --git a/httemplate/view/cust_main/packages/section.html b/httemplate/view/cust_main/packages/section.html
index 5f54c0a36..391a13b5f 100755
--- a/httemplate/view/cust_main/packages/section.html
+++ b/httemplate/view/cust_main/packages/section.html
@@ -28,7 +28,7 @@
<& package.html, %iopt &>
<& status.html, %iopt &>
<TD CLASS="inv" BGCOLOR="<% $iopt{bgcolor} %>" WIDTH="20%" VALIGN="top">
- <& contact.html, %iopt &>
+ <& contact.html, %iopt &><BR>
<& location.html, %iopt &>
</TD>
<& services.html, %iopt &>
@@ -59,6 +59,15 @@ my $packages = $opt{'packages'};
( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
} @$packages;
+my %change_custnum = map { $_->change_custnum => 1 }
+ grep { $_->change_custnum }
+ grep { $_->getfield('cancel') }
+ @$packages;
+
+my $pkg_attached = ( scalar(keys %change_custnum) == 1
+ && ! grep { ! $_->getfield('cancel') } @$packages
+ );
+
my $countrydefault = scalar($conf->config('countrydefault')) || 'US';
my %conf_opt = (
@@ -67,6 +76,7 @@ my %conf_opt = (
|| $curuser->option('cust_pkg-display_times')),
#for status.html
'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
+ 'pkg_attached' => $pkg_attached,
#for status.html pkg-balances
'pkg-balances' => $conf->exists('pkg-balances'),
'money_char' => ( $conf->config('money_char') || '$' ),
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index 24a4dfcd0..c0213e90b 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -365,9 +365,6 @@ sub pkg_status_row_changed {
sub pkg_status_row_detached {
my( $cust_pkg, %opt ) = @_;
-warn $cust_pkg->pkgnum;
-warn $cust_pkg->change_custnum;
-
return '' unless $cust_pkg->change_custnum;
my $html = '';
@@ -379,8 +376,10 @@ warn $cust_pkg->change_custnum;
encode_entities( $cust_main->name ).
'</A>';
+ my $what = $opt{'pkg_attached'} ? 'Attached' : 'Detached';
+
$html .= pkg_status_row_colspan( $cust_pkg,
- emt("Detached to customer #[_1]: ",
+ emt("$what to customer #[_1]: ",
$cust_pkg->change_custnum
).
$cust_link,