agent wholesale bulk billing: option to use cost only, disabling fallback to price...
[freeside.git] / httemplate / misc / manage_cust_email.html
1 <& /elements/header.html, 'Manage customer email settings' &>
2 <STYLE TYPE="text/css">
3 .hidden { display: none }
4 </STYLE>
5 <& /elements/xmlhttp.html,
6     url => $p.'misc/xmlhttp-cust_main-email_search.html',
7     subs => ['email_search']
8 &>
9 <SCRIPT TYPE="text/javascript">
10
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]);
17   }
18   if (recs.length > 0) {
19     for(var i = 0; i < recs.length; i++) {
20       var rec = recs[i];
21       var row = tbody.insertRow(i);
22       row.style.backgroundColor = (i % 2 ? '#eeeeee' : '#ffffff');
23
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]) );
30
31       cell = row.insertCell(3);     // invoice_email
32       var input = document.createElement('INPUT');
33       input.type = 'hidden';
34       input.name = 'custnum';
35       input.value = rec[0];
36       cell.appendChild(input);
37
38       input = document.createElement('INPUT');
39       input.type = 'checkbox';
40       input.name = 'custnum' + rec[0] + '_invoice_email';
41       input.value = 'Y';
42       input.checked = (rec[3] != 'Y');
43       cell.appendChild(input);
44       cell.style.textAlign = 'center';
45       
46       cell = row.insertCell(4);     // message_email
47       input = document.createElement('INPUT');
48       input.type = 'checkbox';
49       input.name = 'custnum' + rec[0] + '_message_email';
50       input.value = 'Y';
51       input.checked = (rec[4] != 'Y');
52       cell.appendChild(input);
53       cell.style.textAlign = 'center';
54     }
55     document.getElementById('div_found').style.display = '';
56   } else {
57     document.getElementById('div_notfound').style.display = '';
58   }
59 }
60
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);
66 }
67 % if ( $cgi->param('search') ) {
68 window.onload = start_search;
69 % }
70 </SCRIPT>
71 <FORM ACTION="<%$p%>misc/process/manage_cust_email.html" METHOD="POST">
72 <DIV>
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>
77 % }
78   Email address: 
79   <INPUT TYPE="text" ID="input_email" NAME="search"\
80          VALUE="<% $cgi->param('search') |h %>">
81   <INPUT TYPE="button" onclick="start_search()" VALUE="find">
82 </DIV>
83 <DIV ID="div_notfound" STYLE="display: none; padding: 1em">
84 No matching email addresses found.
85 </DIV>
86 <DIV ID="div_found" STYLE="display: none">
87 <TABLE CLASS="grid" STYLE="border-spacing: 0px">
88   <THEAD>
89     <TR STYLE="background-color: #dddddd">
90       <TH>#</TH>
91       <TH>Customer</TH>
92       <TH>Email</TH>
93       <TH>Send invoices</TH>
94       <TH>Send other notices</TH>
95     </TR>
96   </THEAD>
97   <TBODY ID="tbody_results"></TBODY>
98 </TABLE>
99 <INPUT TYPE="submit" VALUE="Save changes">
100 </FORM>
101 <& /elements/footer.html &>
102 <%init>
103 die "access denied"
104   unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');
105
106 </%init>