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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<& /elements/header-popup.html, 'Merge customer' &>
<& /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;">
<SCRIPT TYPE="text/javascript">
var submit_interval_id;
function submit_merge() {
document.getElementById('confirm_merge_cust_button').disabled = 'true';
smart_new_custnum_search(document.getElementById('new_custnum_search'));
submit_interval_id = setInterval( do_submit_merge, 100);
}
function do_submit_merge() {
if ( new_custnum_search_active )
return;
document.getElementById('confirm_merge_cust_button').disabled = '';
clearInterval(submit_interval_id);
if ( document.cust_merge_popup.new_custnum.value != '' ) {
document.cust_merge_popup.submit();
}
}
</SCRIPT>
</SCRIPT>
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<TABLE BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
<& /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">
%#have merge button start out disabled and enable after you select a target cust
<INPUT TYPE="submit" NAME="confirm_merge_cust_button" ID="confirm_merge_cust_button" VALUE="Merge customer"> <INPUT TYPE="BUTTON" VALUE="Don't merge" onClick="parent.cClick();">
</FORM>
</BODY>
</HTML>
<%init>
my $conf = new FS::Conf;
$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
my $custnum = $1;
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied" unless $curuser->access_right('Merge customer');
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;
</%init>
|