Odyssey
aSendEmail.prg
1 <?php
2 /**
3  * @author Samuel Bennett
4  * This script handles the Send Email option on the lefthand menu in admin. It contains all the frontend and backend logic for that page.
5  *
6  * @var $self -- The URL to this script.
7  */
8 
9 $parameters = array("a" => array("templateId" => "", "testAddress" => "", "body" => "", "fromEmail" => "", "fromName" => "", "subject" => "", "optin" => "",
10  "inputList" => "", "select" => "", "templateName" => "", "encoded" => ""));
11 $string = array("filter" => FILTER_SANITIZE_STRING);
12 $stringNoEncodeQuote = array("filter" => FILTER_SANITIZE_STRING, "options" => array("flags" => FILTER_FLAG_NO_ENCODE_QUOTES));
13 $unSanitized = array("filter" => FILTER_DEFAULT); // Verified by other means
14 $html = array("filter" => FILTER_SANITIZE_SPECIAL_CHARS);
15 HCU_ImportVars($parameters, "a", array("templateId" => $string, "testAddress" => $string, "body" => $html, "fromEmail" => $string, "fromName" => $stringNoEncodeQuote,
16  "subject" => $stringNoEncodeQuote, "optin" => $string, "select" => $string, "templateName" => $stringNoEncodeQuote,
17  "encoded" => $unSanitized));
18 extract($parameters["a"]); // dms_import doesn't work anymore because this isn't in global scope anymore.
19 
20 $templateId = isset($templateId) ? intval($templateId) : 0;
21 $testAddress = isset($testAddress) ? trim($testAddress) : "";
22 $body = isset($body) ? htmlspecialchars_decode(trim($body)) : "";
23 $fromEmail = isset($fromEmail) ? trim($fromEmail) : "";
24 $fromName = isset($fromName) ? trim($fromName) : "";
25 $subject = isset($subject) ? trim($subject) : "";
26 $optin = isset($optin) ? trim($optin) : "";
27 $select = isset($select) ? trim($select) : "";
28 $templateName = isset($templateName) ? trim($templateName) : "";
29 $encoded = isset($encoded) ? trim($encoded) : "";
30 
31 $self = "$menu_link?ft=$ft";
32 require_once(dirname(__FILE__) . "/aSendEmail.data");
33 
34 if ($operation != "") {
35  switch($operation) {
36  case "readSetup":
37  $returnArray = ReadSetup($dbh, $Cu);
38  break;
39  case "prepareEmail":
40  $returnArray = PrepareEmail($dbh, $Cu, $testAddress, $body, $fromEmail, $fromName, $subject, $optin, $select, $templateId);
41  break;
42  case "sendEmail":
43  $returnArray = SendEmail($dbh, $Cu, $logger, $encoded);
44  break;
45  case "saveTemplate":
46  $returnArray = SaveTemplate($dbh, $Cu, $Cn, $testAddress, $body, $fromEmail, $fromName, $subject, $optin, $select, $templateName, $templateId);
47  break;
48  case "removeTemplate":
49  $returnArray = RemoveTemplate($dbh, $Cu, $Cn, $templateId);
50  break;
51  case "updateEmailList":
52  $returnArray = updateEmailList($dbh, $Cu);
53  break;
54  default:
55  $returnArray = array("sql" => array(), "error" => array("Operation is not recognized: $operation."));
56  }
57 
58  header('Content-type: application/json');
59  print HCU_JsonEncode($returnArray);
60 } else {
61  PrintSendEmailPage($self);
62 }
63 
64 /**
65  * function PrintSendEmailPage($self)
66  * Prints out the send email page.
67  *
68  * @param string $self -- the address to this script
69  */
70 function PrintSendEmailPage($self) {
71  $cloudfrontDomainName = GetCloudFrontDomainName();
72  $tinymceVersion = GetTinyMCEVersion ();
73  ?>
74  <script type="text/javascript" src="https://<?php echo $cloudfrontDomainName; ?>/homecu/js/tinymce/<?php echo $tinymceVersion; ?>/tinymce.min.js"></script>
75  <script type="text/javascript" src="https://<?php echo $cloudfrontDomainName; ?>/homecu/js/tinymce/homecuchar.plugin.js"></script>
76 
77  <?php
78  /**
79  * The Javascript portion of the page.
80  */
81  ?>
82  <script type="text/javascript">
83  <?php
84  // Library javascript functions
85  getShowWaitFunctions();
86  ?>
87 
88  <?php
89  /**
90  * @var previousDataItem -- Preserve the values of the template for when the save is reverted.
91  */
92  ?>
93  var previousDataItem = null;
94 
95  <?php
96  /**
97  * function InitPage()
98  * Initializes the page. In this case, it is creating the kendo grid, and click events for the buttons.
99  */
100  ?>
101  function InitPage()
102  {
103  $.homecuValidator.setup({formValidate:'form', formStatusField: 'formValidateDiv'});
104  var tinyFocused = false;
105 
106  <?php
107  /**
108  * @var tinymce -- a global for setting up the email part.
109  */
110  ?>
111  tinymce.init({
112  selector: "#emailBody",
113  relative_urls: false,
114  remove_script_host : false,
115  plugins: [
116  "advlist autolink link image lists preview anchor pagebreak",
117  "searchreplace visualblocks visualchars code insertdatetime nonbreaking",
118  "table contextmenu directionality template textcolor homecuchar paste textcolor"
119  ],
120  toolbar1: "code newdocument | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | fontselect fontsizeselect | bullist numlist",
121  toolbar2: "outdent indent blockquote | undo redo | link unlink image | preview | forecolor backcolor | removeformat | homecuchar | nonbreaking",
122  toolbar3: "",
123  menubar : false,
124  toolbar_items_size: "small",
125  valid_children : "+body[style]",
126  auto_focus: "emailBody",
127  init_instance_callback: function (editor) {
128  $("#emailBody_ifr").attr("tabindex", -1); <?php // Prevent browser from stopping at a field that doesn't do anything. ?>
129 
130  editor.on("click", function(e) {
131  tinymce.execCommand('mceFocus',true,'emailBody');
132  tinyFocused = true;
133  });
134  }
135  });
136 
137  <?php
138  /**
139  * @var selectDDL -- This is a drop down list for who to send the emails to.
140  */
141  ?>
142  var selectDDL = $("#selectDDL").kendoDropDownList({
143  dataSource: {
144  data: [
145  {text: "All Members", value: "all"},
146  {text: "Members with eStatements", value: "withE"},
147  {text: "Members without eStatements", value: "withoutE"},
148  <?php // #3044: billPay option is no longer available
149  // If necessary, we will need to use perms on profile
150  if (false) { ?> {text: "Members with BillPay", value: "withBP"}, <?php } ?>
151  {text: "Members using Text Banking", value: "withText"}]
152  },
153  dataTextField: "text",
154  dataValueField: "value",
155  filter: "startswith",
156  change: function() {
157  var dataItem = templateDDL.dataItem();
158  if (dataItem != null) {
159  dataItem.select = this.value();
160  }
161  }
162  }).data("kendoDropDownList");
163 
164  <?php
165  /**
166  * Anonymous function
167  * Make sure that tinymce is focused when the underlying control is focused.
168  */
169  ?>
170  $("#emailBodyDiv").focus(function() {
171  if (!tinyFocused) {
172  tinymce.execCommand('mceFocus',true,'emailBody');
173  tinyFocused = true;
174  }
175  });
176 
177  <?php
178  /**
179  * Anonymous function
180  * Make sure that tinymce is blurred when the underlying control is blurred.
181  */
182  ?>
183  $("#emailBodyDiv").blur(function() {
184  if (tinyFocused) {
185  tinymce.execCommand('mceFocus',false,'emailBody');
186  tinyFocused = false;
187  }
188  });
189 
190  <?php
191  /**
192  * Anonymous function
193  * Make sure that change to optin changes the template dataItem.
194  */
195  ?>
196  $("#optinRequired").click(function() {
197  var dataItem = templateDDL.dataItem();
198 
199  if (dataItem != null) {
200  dataItem.optin = $(this).prop("checked") ? "Y" : "N";
201  }
202 
203  });
204 
205  <?php
206  /**
207  * Anonymous function
208  * Make sure that test email input becomes visible and is required when test email checkbox is true.
209  */
210  ?>
211  $("#sendTestEmail").click(function() {
212  if ($(this).prop("checked")) {
213  $("#emailAddressRow").show();
214  $("[name='testEmail']").prop("required", true);
215  } else {
216  $("#emailAddressRow").hide();
217  $("[name='testEmail']").prop("required", false).removeClass("k-invalid").val(null);
218  $(".k-invalid-msg[data-for='testEmail']").hide();
219  }
220  });
221 
222  <?php
223  /**
224  * Anonymous function
225  * Make sure that template dataItem changes when fromName DDL is changed.
226  */
227  ?>
228  $("[name='fromName']").blur(function() {
229  var dataItem = templateDDL.dataItem();
230 
231  if (dataItem != null) {
232  dataItem.fromname = $(this).val();
233  }
234  });
235 
236  <?php
237  /**
238  * Anonymous function
239  * Make sure that template dataItem changes when subject is blurred.
240  */
241  ?>
242  $("[name='subject']").blur(function() {
243  var dataItem = templateDDL.dataItem();
244 
245  if (dataItem != null) {
246  dataItem.subject = $(this).val();
247  }
248  });
249 
250  <?php
251  /**
252  * @var fromEmailDDL -- This is a list of all approved emails. This comes from the list in the SES role in the cuadmnotify table.
253  */
254  ?>
255  var fromEmailDDL = $("#fromEmailDDL").kendoDropDownList({
256  dataSource: [],
257  dataTextField: "email",
258  dataValueField: "email",
259  optionLabel: "Select email...",
260  select: function (e) {
261  var dataItem = templateDDL.dataItem();
262 
263  if (dataItem != null) {
264  dataItem.fromemail = e.dataItem.email;
265  }
266  }
267  }).data("kendoDropDownList");
268 
269  <?php
270  /**
271  * @var templateDDL -- This is a list of all templates. This is saved to and retrieved from cuadmemailtmpl.
272  */
273  ?>
274  var templateDDL = $("#templateDDL").kendoComboBox({
275  dataSource: {
276  data: [],
277  schema: {
278  model: {
279  id: "value",
280  fields: {
281  value: {type: "number"},
282  text: {type: "string"},
283  fromemail: {type: "string"},
284  fromname: {type: "string"},
285  subject: {type: "string"},
286  body: {type: "string"},
287  optin: {type: "number"},
288  select: {type: "string"}
289  }
290  }
291  }
292  },
293  dataTextField: "text",
294  dataValueField: "value",
295  filter: "startswith",
296  change: function() {
297  var dataItem = this.dataItem();
298  if (dataItem != null) { <?php // User typed it in and it doesn't relate to an existing template. ?>
299  $(this.wrapper).find(".k-dropdown-wrap.k-invalid").removeClass("k-invalid");
300  if (dataItem.value == 0) {
301  $(".removeBtn").hide();
302  } else {
303  $(".removeBtn").show();
304  }
305 
306  $("[name='fromName']").val(dataItem.fromname).removeClass("k-invalid");
307  $("#fromEmailDDL").data("kendoDropDownList").value(dataItem.fromemail);
308  $("[name='subject']").val(dataItem.subject).removeClass("k-invalid");
309 
310  $("#optinRequired").prop("checked", dataItem.optin == "Y");
311  $("#selectDDL").data("kendoDropDownList").value(dataItem.select);
312 
313  if (previousDataItem != null) {
314  previousDataItem.body = tinyMCE.activeEditor.getContent();
315  }
316 
317  tinyMCE.activeEditor.setContent(dataItem.body, {format: "raw"});
318  } else {
319  $(".removeBtn").hide();
320  if (this.value() != null && this.value().trim() != "") {
321  $(this.wrapper).find(".k-dropdown-wrap.k-invalid").removeClass("k-invalid");
322  }
323  }
324 
325  if (dataItem != null) {
326  previousDataItem = dataItem;
327  }
328  },
329  dataBound: function() {
330  previousDataItem = this.dataItem(); <?php // Will be the (None) ?>
331  },
332  placeholder: "Select an item from the list or type",
333  noDataTemplate: "On save, new template will be created."
334  }).data("kendoComboBox");
335 
336  <?php // Add validation to the input in the combobox. This gets created on initialization even if you create a kendoComboBox on an input. ?>
337  $(".templateRow .k-combobox .k-input[type='text']").attr({"data-required-msg": "Template is required", "maxlength": "50", "name": "templateInput"});
338 
339  everythingDataSource.read({operation: "readSetup"});
340 
341  $(".previewBtn").click(function() {
342  $(".k-dropdown-wrap.k-invalid").removeClass("k-invalid");
343  $.homecuValidator.validate();
344 
345  if ($("#formValidateDiv li:visible").length == 0) {
346  var parameters = {};
347  if ($("#sendTestEmail").prop("checked")) {
348  parameters.testAddress = $("[name='testEmail']").val();
349  }
350  parameters.body = tinyMCE.activeEditor.getContent();
351  parameters.fromEmail = $("#fromEmailDDL").data("kendoDropDownList").value();
352  parameters.fromName = $("[name='fromName']").val();
353  parameters.subject = $("[name='subject']").val();
354  parameters.optin = $("#optinRequired").prop("checked") ? "Y" : "N";
355  parameters.select = selectDDL.value();
356 
357  var combobox = $("#templateDDL").data("kendoComboBox");
358  var dataItem = combobox.dataItem();
359  parameters.templateId = dataItem == null ? 0 : dataItem.value;
360  parameters.operation = "prepareEmail";
361 
362  everythingDataSource.read(parameters);
363  } else {
364  $("#homecu-container").animate({ scrollTop: 0 }, { duration: 500 } );
365  }
366 
367  return false;
368  });
369 
370  <?php
371  /**
372  * Anonymous function
373  * Saves the template
374  */
375  ?>
376  $(".saveBtn").click(function() {
377  var input = $("[name='templateInput']");
378  $(input).prop("required", true);
379  $("[name='testEmail']").attr("data-validate", false); <?php // Also need to make sure that test email doesn't get validated. ?>
380  $.homecuValidator.validate();
381  $(input).prop("required", false);
382  $("[name='testEmail']").attr("data-validate", true);
383 
384  $(input).hasClass("k-invalid") ? $(input).closest(".k-dropdown-wrap").addClass("k-invalid") : $(input).closest(".k-dropdown-wrap").removeClass("k-invalid");
385 
386  if ($("#formValidateDiv li:visible").length == 0) {
387  var parameters = {};
388  parameters.body = tinyMCE.activeEditor.getContent();
389  parameters.fromEmail = $("#fromEmailDDL").data("kendoDropDownList").value();
390  parameters.fromName = $("[name='fromName']").val();
391  parameters.subject = $("[name='subject']").val();
392  parameters.optin = $("#optinRequired").prop("checked") ? "Y" : "N";
393  parameters.select = selectDDL.value();
394 
395  var templateDDL = $("#templateDDL").data("kendoComboBox");
396  var dataItem = templateDDL.dataItem();
397  if (dataItem == null) {
398  parameters.templateId = 0;
399  parameters.templateName = templateDDL.value();
400  } else {
401  parameters.templateId = dataItem.value;
402  parameters.templateName = dataItem.text;
403  }
404 
405  OpenConfirm(false, parameters);
406  } else {
407  $("#homecu-container").animate({ scrollTop: 0 }, { duration: 500 } );
408  }
409 
410  return false;
411  });
412 
413  <?php
414  /**
415  * Anonymous function
416  * Removes the template
417  */
418  ?>
419  $(".removeBtn").click(function() {
420  $(".k-dropdown-wrap.k-invalid").removeClass("k-invalid");
421  var input = $("[name='templateInput']");
422  $(input).prop("required", true);
423  $("[name='testEmail']").attr("data-validate", false); <?php // Also need to make sure that test email doesn't get validated. ?>
424  $.homecuValidator.validate();
425  $(input).prop("required", false);
426  $("[name='testEmail']").attr("data-validate", true);
427  if ($("#formValidateDiv li:visible").length == 0) {
428  var parameters = {};
429  var templateDDL = $("#templateDDL").data("kendoComboBox");
430  parameters.templateId = templateDDL.value();
431 
432  OpenConfirm(true, parameters);
433  } else {
434  $("#homecu-container").animate({ scrollTop: 0 }, { duration: 500 } );
435  }
436  });
437  }
438 
439  var everythingDataSource = null;
440 
441  <?php
442  /**
443  * function InitDataSource
444  * This initializes the dataSource that everyone uses. As per standards, it is preferable to use a DataSource versus $.post.
445  */
446  ?>
447  function InitDataSource() {
448 
449  <?php
450  /**
451  * @var everythingDataSource -- Uses this versus $.post directly.
452  */
453  ?>
454  everythingDataSource = new kendo.data.DataSource({
455  transport: {
456  read: {
457  url: "<?php echo $self; ?>",
458  dataType: "json",
459  type: "POST"
460  },
461  parameterMap: function(data, type) {
462  if (data.operation != "updateEmailList") {
463  showWaitWindow();
464  }
465  return data;
466  }
467  },
468  schema: {
469  parse: function(results) {
470  if (results.operation != "updateEmailList") {
471  hideWaitWindow();
472  }
473  if (results.error && results.error.length > 0) {
474  $.homecuValidator.displayMessage(results.error, $.homecuValidator.settings.statusError );
475  return [];
476  } else if (results.info && results.info.length > 0) {
477  $.homecuValidator.displayMessage(results.info, $.homecuValidator.settings.statusInfo );
478  }
479 
480  switch(results.operation) {
481  case "readSetup":
482  $("[name='fromName']").val("");
483  $("[name='subject']").val("");
484  $("#templateDDL").data("kendoComboBox").dataSource.data(results.data.templateDDL);
485  $("#fromEmailDDL").data("kendoDropDownList").dataSource.data(results.data.emailList);
486  if (results.data.hasUnverified) {
487  everythingDataSource.read({operation: "updateEmailList"});
488  }
489  break;
490  case "prepareEmail":
491  OpenPreviewWindow(results.data);
492  break;
493  case "saveTemplate":
494  var templateDDL = $("#templateDDL").data("kendoComboBox");
495  templateDDL.dataSource.data(results.data.templateDDL);
496  templateDDL.value(results.data.templateId);
497  $(".removeBtn").show();
498 
499  $("#homecu-container").animate({ scrollTop: 0 }, { duration: 500 } );
500  break;
501  case "removeTemplate":
502  var templateDDL = $("#templateDDL").data("kendoComboBox");
503  var selectDDL = $("#selectDDL").data("kendoDropDownList");
504  templateDDL.dataSource.data(results.data.templateDDL);
505  templateDDL.value("");
506 
507  $(".removeBtn").hide();
508  $("[name='templateName']").val("");
509  $("[name='fromName']").val("");
510  $("#fromEmailDDL").data("kendoDropDownList").select(0);
511  $("[name='subject']").val("");
512  tinyMCE.activeEditor.setContent("");
513  $("#optinRequired").prop("checked", true);
514  selectDDL.select(0);
515 
516  $("#homecu-container").animate({ scrollTop: 0 }, { duration: 500 } );
517  break;
518  case "sendEmail":
519  var dialog = $("#previewWindow").data("kendoDialog");
520  dialog.close();
521  break;
522  case "updateEmailList":
523  $("#fromEmailDDL").data("kendoDropDownList").dataSource.data(results.data.emailList);
524  break;
525  }
526 
527  return [];
528  }
529  }
530  });
531  }
532 
533  <?php
534  /**
535  * function OpenConfirm(isDelete, parameters)
536  * This opens up the confirmation message.
537  *
538  * @param boolean isDelete -- if true, it is confirming the delete. Otherwise it is confirming the save.
539  * @param {} parameters -- parameters acquired from above.
540  */
541  ?>
542  function OpenConfirm(isDelete, parameters) {
543  var confirmDialog = $("#confirmDialog").data("kendoDialog");
544 
545  if (confirmDialog == null) {
546 
547  <?php
548  /**
549  * @var confirmDialog -- This is a confirmation dialog that is used for saving and deleting templates.
550  */
551  ?>
552  confirmDialog = $("<div id='confirmDialog'></div>").appendTo("body").kendoDialog({
553  actions: [{text: "No", action: function() {
554  confirmDialog.close();
555  return false;
556  }}, {text: "Yes", primary: true, action: function() {
557  confirmDialog.close();
558 
559  var parameters = $("#confirmDialog").data("parameters");
560  var isDelete = $("#confirmDialog").data("isDelete");
561  if (isDelete) {
562 
563  parameters.operation = "removeTemplate";
564  everythingDataSource.read(parameters);
565  } else {
566 
567  parameters.operation = "saveTemplate";
568  everythingDataSource.read(parameters);
569  }
570 
571  return false;
572  }}],
573  visible: false,
574  open: function() {
575  if (window.activeWindows != null) {
576  window.activeWindows.push(this);
577  }
578  },
579  close: function() {
580  if (window.activeWindows != null) {
581  window.activeWindows.pop();
582  }
583  },
584  visible: false,
585  modal: true,
586  minWidth: 300
587  }).data("kendoDialog");
588  }
589 
590  $("#confirmDialog").data("parameters", parameters);
591  $("#confirmDialog").data("isDelete", isDelete);
592 
593  var content = "<p>You are about to " + (isDelete ? "delete" : "save") + " this email template.</p><p>Do you wish to continue?</p>";
594  var title = "Confirm " + (isDelete ? "Delete" : "Save");
595 
596  confirmDialog.title(title).content(content).open();
597  }
598 
599  <?php
600  /**
601  * function OpenPreviewWindow(previewData)
602  * Opens up the preview window for sending emails.
603  *
604  * @param array previewData -- data from the prepare data call.
605  */
606  ?>
607  function OpenPreviewWindow(previewData) {
608  var dialog = $("#previewWindow").data("kendoDialog");
609 
610  if (dialog == null) {
611 
612  <?php
613  /**
614  * @var dialog -- The kendo dialog for previewing the email before sending.
615  */
616  ?>
617  dialog = $("<div id='previewWindow'></div>").appendTo("body").kendoDialog({
618  title: "Preview",
619  actions: [
620  {text: "Send Email", primary: true, action: function() {
621 
622  var encoded = $("#previewWindow").data("encoded");
623  $("#previewWindow").data("encoded", null);
624  everythingDataSource.read({encoded: encoded, operation: "sendEmail"});
625  }},
626  {text: "Cancel"}
627  ],
628  visible: false,
629  open: function() {
630  if (window.activeWindows != null) {
631  window.activeWindows.push(this);
632  }
633  var maxHeight1 = 600;
634  var maxHeight2 = $(window).height() - 150;
635  var maxHeight = maxHeight2 >= maxHeight1 ? maxHeight1 : maxHeight2;
636  var maxWidth1 = 800;
637  var maxWidth2 = $(window).width() - 75;
638  var maxWidth = maxWidth2 >= maxWidth1 ? maxWidth1 : maxWidth2;
639  $("#previewWindow").css({maxHeight: maxHeight, maxWidth: maxWidth});
640  },
641  close: function() {
642  if (window.activeWindows != null) {
643  window.activeWindows.pop();
644  }
645  }
646  }).data("kendoDialog");
647  }
648 
649  var template = kendo.template($("#previewTemplate").html());
650  $("#previewWindow").data("encoded", previewData.encoded);
651  delete previewData.encoded;
652 
653  previewData.testEmail = $("[name='testEmail']").val();
654  previewData.optinRequired = $("#optinRequired").prop("checked");
655  previewData.selectedOption = $("#selectDDL").data("kendoDropDownList").text();
656  previewData.fromEmail = $("#fromEmailDDL").data("kendoDropDownList").value();
657  previewData.fromName = $("[name='fromName']").val();
658  previewData.subject = $("[name='subject']").val();
659  previewData.emailBody = tinyMCE.activeEditor.getContent();
660 
661  dialog.content(template(previewData)).open();
662  }
663 
664  var activeWindows = [];
665  $(document).ready(function() {
666  InitDataSource();
667  InitPage();
668  <?php printClickOverlayEvent(); ?>
669  });
670  </script>
671 
672  <?php
673  /**
674  * @var previewTemplate
675  * This is a template for the preview window.
676  */
677  ?>
678  <script type="text/x-kendo-template" id="previewTemplate">
679  <div class="container hcu-all-100 hcu-no-padding">
680  # if (testSent) { #
681  <div class="col-xs-12 hcu-no-padding">
682  <label class="col-xs-12 k-info-colored">Check email for <b>#: testEmail #</b> to view test message.</label>
683  </div>
684  <div class="col-xs-12">&nbsp;</div>
685  # } #
686  <div class="col-xs-12 hcu-no-padding">
687  <div id='previewValidateDiv' class='k-block k-error-colored col-xs-12' style='display:none;'></div>
688  </div>
689  <div class='col-xs-12 col-sm-4 hcu-no-padding'>
690  <label class='col-xs-4 col-sm-12'>To</label>
691  <div class='col-xs-8 col-sm-12'><div class="admIndent">#= optinRequired ? "Opted-in Members" : "All Members" #</div></div>
692  </div>
693  <div class="visible-xs-block col-xs-12">&nbsp;</div>
694  <div class="col-xs-12 col-sm-4 hcu-no-padding hcuSpacer">
695  <label class="col-xs-4 col-sm-12">Selecting</label>
696  <div class="col-xs-8 col-sm-12"><div class="admIndent">#: selectedOption #</div></div>
697  </div>
698  <div class="visible-xs-block col-xs-12">&nbsp;</div>
699  <div class="col-xs-12 col-sm-4 hcu-no-padding">
700  <label class="col-xs-4 col-sm-12">No. Emails</label>
701  <div class="col-xs-8 col-sm-12"><div class="admIndent">#: numEmails #</div></div>
702  </div>
703  <div class="col-xs-12">&nbsp;</div>
704  <div class="col-xs-12 col-sm-4 hcu-no-padding">
705  <label class="col-xs-4 col-sm-12">From</label>
706  <div class="col-xs-8 col-sm-12"><div class="admIndent">#: fromName # <div class="visible-xs-block"><br></div> (#: fromEmail #)</div></div>
707  </div>
708  <div class="visible-xs-block col-xs-12">&nbsp;</div>
709  <div class="visible-xs-block col-xs-12">&nbsp;</div>
710  <div class="col-xs-12 col-sm-4 hcu-no-padding">
711  <label class="col-xs-4 col-sm-12">Subject</label>
712  <div class="col-xs-8 col-sm-12"><div class="admIndent">#: subject #</div></div>
713  </div>
714  <div class="col-xs-12">&nbsp;</div>
715  <div class="col-xs-12 hcu-no-padding">
716  <label class="col-xs-12">Body of Email</label>
717  <div class="col-xs-12"><div id="previewEmailDiv">#= emailBody #</div></div>
718  </div>
719  </div>
720  </script>
721 
722  <?php
723  /**
724  * The HTML part of the page.
725  */
726  ?>
727  <form id="form" class="broadcastEmailsForm">
728  <div class="container hcu-all-100 hcu-template vsgPrimary">
729  <div class="row">
730  <div class="col-xs-12 notificationRow"></div>
731  </div>
732  <div class="col-xs-12">
733  <div class="row">
734  <div id="formValidateDiv" class="k-block k-error-colored formValidateDiv" style="display:none;"></div>
735  </div>
736  </div>
737  <div class="well sm-well col-xs-12">
738  <div class="toTheMax">
739  <div class="row hcuSpacer templateRow">
740  <div class="col-xs-12 col-sm-1 hcu-no-padding-nonmobile">
741  <label class="col-xs-12">Template</label>
742  </div>
743  <div class="col-xs-12 col-sm-11 col-lg-5">
744  <div class="col-xs-12 col-md-12">
745  <div id="templateDDL" class="hcu-all-100"></div>
746  </div>
747  </div>
748  </div>
749  </div>
750  <div class="row hcuSpacer">
751  <hr class="col-xs-12">
752  </div>
753  <div class="toTheMax">
754  <div class="row hcuSpacer">
755  <div class="col-xs-12 col-sm-1 hcu-no-padding-nonmobile">
756  <label class="col-xs-12">Email</label>
757  </div>
758  <div class="col-xs-12 col-sm-5">
759  <div class="col-xs-12">
760  <div id="fromEmailDDL" class="hcu-all-100"></div>
761  <p class="small vsgSecondary">Manage emails on the <a href="main.prg?ft=46">CU Email Notifications</a> screen.</p>
762  </div>
763  </div>
764 
765  <div class="visible-xs-block col-xs-12">
766  &nbsp;
767  </div>
768 
769  <div class="col-xs-12 col-sm-1 hcu-no-padding-nonmobile">
770  <label class="col-xs-12">Name</label>
771  </div>
772  <div class="col-xs-12 col-sm-5">
773  <div class="col-xs-12">
774  <input type="text" class="k-input k-textbox hcu-all-100" name="fromName" required data-required-msg="Name is required" maxlength="100">
775  </div>
776  </div>
777 
778  <div class="col-xs-12">
779  &nbsp;
780  </div>
781 
782  <div class="col-xs-12 col-sm-1 hcu-no-padding-nonmobile">
783  <label class="col-xs-12">Subject</label>
784  </div>
785  <div class="col-xs-12 col-sm-5">
786  <div class="col-xs-12">
787  <input type="text" class="k-input k-textbox hcu-all-100" name="subject" required data-required-msg="Subject is required" maxlength="255">
788  </div>
789  </div>
790 
791  <div class="visible-xs-block col-xs-12">
792  &nbsp;
793  </div>
794 
795  <div class="col-xs-12 col-sm-1 hcu-no-padding-nonmobile">
796  <label class="col-xs-12">Select</label>
797  </div>
798  <div class="col-xs-12 col-sm-5">
799  <div class="col-xs-12">
800  <div id="selectDDL" class="hcu-all-100"></div>
801  </div>
802  </div>
803 
804  <div class="col-xs-12">
805  &nbsp;
806  </div>
807 
808  <div class="col-xs-12 col-sm-6 hcu-no-padding-nonmobile">
809  <div class="col-xs-12">
810  <label>Only opt-in members &nbsp;&nbsp; </label><input type="checkbox" id="optinRequired" checked>
811  </div>
812  </div>
813 
814  <div class="visible-xs-block col-xs-12">
815  &nbsp;
816  </div>
817 
818  <div class="col-xs-12 col-sm-6 hcu-no-padding-nonmobile">
819  <div class="col-xs-12">
820  <label>Send Test Email &nbsp;&nbsp; </label><input type="checkbox" id="sendTestEmail">
821  </div>
822  </div>
823 
824  <div class="col-xs-12">
825  &nbsp;
826  </div>
827 
828  <div id="emailAddressRow" style="display:none;">
829  <div class="hidden-xs col-sm-1 hcu-no-padding-nonmobile">
830  <label class="col-xs-12">&nbsp;</label>
831  </div>
832  <div class="hidden-xs col-sm-5">
833  <div class="col-xs-12">
834  &nbsp;
835  </div>
836  </div>
837  <div class="col-xs-12 col-sm-1 hcu-no-padding-nonmobile">
838  <label class="col-xs-12">Email</label>
839  </div>
840  <div class="col-xs-12 col-sm-5">
841  <div class="col-xs-12">
842  <input type="email" class="k-input k-textbox hcu-all-100" name="testEmail" data-required-msg="Test Email is required"
843  data-email-msg="Test Email is not valid" placeholder="Test email recipient">
844  </div>
845  </div>
846  </div>
847 
848  <div class="visible-xs-block col-xs-12">
849  &nbsp;
850  </div>
851  </div>
852  </div>
853  </div>
854  <div class="well sm-well col-xs-12">
855  <div class="row hcuSpacer">
856  <div class="h4">Email Body</div>
857  </div>
858  <div class="row hcuSpacer" id="emailBodyDiv" tabindex="0">
859  <textarea id="emailBody" name="emailBody" class="hcu-all-100"></textarea>
860  </div>
861  </div>
862  <div class="col-xs-12">
863  <div class="hcu-edit-buttons k-state-default row">
864  <span class="hcu-icon-delete">
865  <a class="removeBtn" href="#" style="display:none;"><i class="fa fa-trash-o fa-lg"></i></a>
866  </span>
867  <a class="previewBtn" href="#">Preview & Send</a>
868  &nbsp;&nbsp;&nbsp;
869  <a class="saveBtn k-button k-primary" href="#"><i class="fa fa-check"></i>Save</a>
870  </div>
871  </div>
872  </div>
873  </form>
874 <?php }