+<SCRIPT TYPE="text/javascript">
+function toggle(obj) {
+ document.getElementById('table_no_template').style.display = (obj.value == 0) ? '' : 'none';
+}
+
+</SCRIPT>
+% if ( $msg_template and $msg_template->disabled ) {
+% # if we've already established a draft template, don't let msgnum be changed
+ <& /elements/hidden.html,
+ field => 'msgnum',
+ curr_value => ( scalar($cgi->param('msgnum')) || ''),
+ &>
+% } else {
+Template:
+ <& /elements/select-msg_template.html,
+ onchange => 'toggle(this)',
+ curr_value => ( scalar($cgi->param('msgnum')) || ''),
+ &>
+ <BR>
+% }
+% # select destination contact classes
+<TABLE CELLSPACING=0 id="send_to_contacts_table">
+<TR>
+ <TD>Send to contacts:</TD>
+ <TD>
+ <div id="contactclassesdiv">
+ <& /elements/checkboxes.html,
+ 'style' => 'display: inline; vertical-align: top',
+ 'disable_links' => 1,
+ 'names_list' => \@optin_checkboxes,
+ 'element_name_prefix' => 'contact_class_',
+ 'checked_callback' => sub {
+ # Called for each checkbox
+ # Return true to default as checked, false as unchecked
+ my($cgi, $name) = @_;
+ exists $dest_ischecked{$name};
+ },
+ &>
+ </div>
+% if ($send_to_domain) {
+ <div>
+ <INPUT TYPE="checkbox" NAME="emailtovoice" ID="emailtovoice" VALUE="ON" onclick="toggleDiv(this)">Email to voice
+ </div>
+ <div id="emailtovoicediv" style="display:none";>
+
+ <& /elements/select-cust_phone.html,
+ 'cust_num' => $cgi->param('custnum'),
+ 'field_name' => 'emailtovoice_contact',
+ 'format' => 'xxxxxxxxxx',
+ 'phone_types' => [ 'daytime', 'night', 'fax', 'mobile' ],
+ &>@<% $send_to_domain |h %>
+ </div>
+% }
+ </TD>
+% if (@active_classes) {
+</tr>
+<tr>
+<TD>Contact Type:</TD>
+<TD>
+ <div id="contactclassesdiv">
+ <& /elements/checkboxes.html,
+ 'style' => 'display: inline; vertical-align: top',
+ 'disable_links' => 1,
+ 'names_list' => \@classnum_checkboxes,
+ 'element_name_prefix' => 'contact_class_',
+ 'checked_callback' => sub {
+ # Called for each checkbox
+ # Return true to default as checked, false as unchecked
+ my($cgi, $name) = @_;
+ exists $classnum_ischecked{$name};
+ },
+ &>
+ </div>
+</TD>
+% }
+</TR>
+</TABLE>
+<BR>
+% # if sending a one-off message, show a form to edit it
+ <TABLE BGCOLOR="#cccccc" CELLSPACING=0 WIDTH="100%" id="table_no_template">
+ <& /elements/tr-td-label.html, 'label' => 'From:' &>
+ <TD><& /elements/input-text.html,
+ 'field' => 'from_name',
+ 'value' => $conf->config('invoice_from_name', $agent_virt_agentnum) ||
+ $conf->config('company_name', $agent_virt_agentnum), #?
+ 'size' => 20,
+ 'curr_value' => scalar($cgi->param('from_name')),
+ &> <\
+ <& /elements/input-text.html,
+ 'field' => 'from_addr',
+ 'type' => 'email', # HTML5, woot
+ 'value' => $conf->config('invoice_from', $agent_virt_agentnum),
+ 'size' => 20,
+ 'curr_value' => scalar($cgi->param('from_addr')),
+ &>></TD>
+
+ <& /elements/tr-input-text.html,