2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(1). "merge_cust.html?". $cgi->query_string ) %>
5 <% include('/elements/header-popup.html', "Customer merged") %>
6 <SCRIPT TYPE="text/javascript">
7 window.top.location.href = '<% $p %>view/cust_main.cgi?<% $new_custnum %>';
16 unless $FS::CurrentUser::CurrentUser->access_right('Merge customer');
20 $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
24 if ( $cgi->param('new_custnum') =~ /^(\d+)$/ ) {
27 my $cust_main = qsearchs( {
28 'table' => 'cust_main',
29 'hashref' => { 'custnum' => $custnum },
30 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
32 die "No customer # $custnum" unless $cust_main;
34 if ( $cgi->param('merge') eq 'Y' ) {
36 #old-style merge: everything + delete old customer
37 $error = $cust_main->merge($new_custnum);
41 #new-style attach: move packages 3.0 style, that's it
42 $error = $cust_main->attach_pkgs($new_custnum);
47 $error = 'Select a customer to merge into';