1 <& /elements/header.html, 'Manage customer email settings' &>
2 <STYLE TYPE="text/css">
3 .hidden { display: none }
5 <& /elements/xmlhttp.html,
6 url => $p.'misc/xmlhttp-cust_main-email_search.html',
7 subs => ['email_search']
9 <SCRIPT TYPE="text/javascript">
11 function receive_search(result) {
12 var recs = JSON.parse(result);
13 var tbody = document.getElementById('tbody_results');
14 var j = tbody.rows.length;
15 for(var i = 0; i < j; i++) {
16 tbody.deleteRow(tbody.rows[i]);
18 if (recs.length > 0) {
19 for(var i = 0; i < recs.length; i++) {
21 var row = tbody.insertRow(i);
22 row.style.backgroundColor = (i % 2 ? '#eeeeee' : '#ffffff');
24 var cell = row.insertCell(0); // custnum
25 cell.appendChild( document.createTextNode(rec[0]) );
26 cell = row.insertCell(1); // customer name
27 cell.appendChild( document.createTextNode(rec[1]) );
28 cell = row.insertCell(2); // email
29 cell.appendChild( document.createTextNode(rec[2]) );
31 cell = row.insertCell(3); // invoice_email
32 var input = document.createElement('INPUT');
33 input.type = 'hidden';
34 input.name = 'custnum';
36 cell.appendChild(input);
38 input = document.createElement('INPUT');
39 input.type = 'checkbox';
40 input.name = 'custnum' + rec[0] + '_invoice_email';
42 input.checked = (rec[3] != 'Y');
43 cell.appendChild(input);
44 cell.style.textAlign = 'center';
46 cell = row.insertCell(4); // message_email
47 input = document.createElement('INPUT');
48 input.type = 'checkbox';
49 input.name = 'custnum' + rec[0] + '_message_email';
51 input.checked = (rec[4] != 'Y');
52 cell.appendChild(input);
53 cell.style.textAlign = 'center';
55 document.getElementById('div_found').style.display = '';
57 document.getElementById('div_notfound').style.display = '';
61 function start_search() {
62 document.getElementById('div_found').style.display = 'none';
63 document.getElementById('div_notfound').style.display = 'none';
64 var email = document.getElementById('input_email').value;
65 email_search(email, receive_search);
67 % if ( $cgi->param('search') ) {
68 window.onload = start_search;
71 <FORM ACTION="<%$p%>misc/process/manage_cust_email.html" METHOD="POST">
73 % if ( $cgi->param('done') ) {
74 <P STYLE="font-weight: bold; color: #00ff00">Changes saved.</P>
75 % } elsif ( $cgi->param('error') ) {
76 <P STYLE="font-weight: bold; color: #ff0000"><% $cgi->param('error') |h %></P>
79 <INPUT TYPE="text" ID="input_email" NAME="search"\
80 VALUE="<% $cgi->param('search') |h %>">
81 <INPUT TYPE="button" onclick="start_search()" VALUE="find">
83 <DIV ID="div_notfound" STYLE="display: none; padding: 1em">
84 No matching email addresses found.
86 <DIV ID="div_found" STYLE="display: none">
87 <TABLE CLASS="grid" STYLE="border-spacing: 0px">
89 <TR STYLE="background-color: #dddddd">
93 <TH>Send invoices</TH>
94 <TH>Send other notices</TH>
97 <TBODY ID="tbody_results"></TBODY>
99 <INPUT TYPE="submit" VALUE="Save changes">
101 <& /elements/footer.html &>
104 unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');