blob: 3b4425fc8bfaad76434d3e36cd959cc5a471df47 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 | % if ( $error ) {
% $cgi->param('error', $error);
<% $cgi->redirect(popurl(1). "merge_cust.html?". $cgi->query_string ) %>
% } else {
<% include('/elements/header-popup.html', "Customer merged") %>
  <SCRIPT TYPE="text/javascript">
    window.top.location.href = '<% $p %>view/cust_main.cgi?<% $new_custnum %>';
%# parent.nd(1) ?
  </SCRIPT>
  </BODY>
</HTML>
% }
<%init>
die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Merge customer');
my $error = '';
$cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
my $custnum = $1;
my $new_custnum;
if ( $cgi->param('new_custnum') =~ /^(\d+)$/ ) {
  $new_custnum = $1;
  my $cust_main = qsearchs( {
    'table'     => 'cust_main',
    'hashref'   => { 'custnum' => $custnum },
    'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
  } );
  die "No customer # $custnum" unless $cust_main;
  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';
}
</%init>
 |