summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-cust_main-duplicates.html
blob: 7ee00af66b063dea4c14cc6cd26c6b0e6dc34ff1 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% if ( @cust_main ) {
<CENTER><BR><B>Duplicate customer</B><BR>
Choose an existing customer
<TABLE WIDTH="300px">
<FORM name="DuplicateForm">
% foreach (@cust_main) {
%   my $custnum = $_->custnum;
<TR>
  <TD ALIGN="right" VALIGN="top"><B><% $custnum %>: </B></TD>
  <TD ALIGN="left">
    <% $_->name |h %>&mdash;<B><FONT COLOR="#<%$_->statuscolor%>"><%$_->ucfirst_cust_status%></FONT></B><BR>
<% $_->address1 |h %><BR>
<% $_->city |h %>,&nbsp;<% $_->state %>&nbsp;&nbsp;<% $_->zip %>
  </TD>
  <TD ALIGN="center">
    <INPUT TYPE="radio" NAME="dup_custnum" VALUE="<%$custnum%>">
  </TD>
</TR>
% } #foreach cust_main
</FORM>
</TABLE>
<TABLE WIDTH="100%">
<TR>
  <TD ALIGN="center">
    <BUTTON TYPE="button" onclick="submit_continue();">
      <IMG SRC="<%$p%>images/error.png"> Create a new customer
    </BUTTON>
  </TD>
  <TD ALIGN="center">
    <BUTTON TYPE="button" onclick="<% $set_to_customer %>">
      <IMG SRC="<%$p%>images/tick.png"> Use the selected customer
    </BUTTON>
  </TD>
</TR>
<TR>
  <TD COLSPAN=2 ALIGN="center">
    <BUTTON TYPE="button" onclick="submit_abort();">
      <IMG SRC="<%$p%>images/cross.png"> Cancel submission
    </BUTTON>
  </TD>
</TR>
% }
%# else return nothing
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('List customers');

my $conf = new FS::Conf;

my $sub = $cgi->param('sub');
my $hashref = decode_json($cgi->param('arg'));
my @cust_main = qsearch('cust_main', $hashref);

my $set_to_customer = <<EOF;
  var custnum_array = document.getElementsByName('dup_custnum');
  var custnum;
  for(i=0; i<custnum_array.length; i++) {
    if(custnum_array[i].checked) {
      custnum = custnum_array[i].value;
    }
  }
  //alert('Setting to customer '+custnum);
  document.CustomerForm.elements['duplicate_of_custnum'].value = custnum;
  submit_continue();
EOF

</%init>