CRM-16725 - Add Preview PDF button to PDF Letter task so users can review PDF without...
authorDave Greenberg <dave@civicrm.org>
Sat, 3 Oct 2015 20:09:15 +0000 (16:09 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 7 Oct 2015 18:56:14 +0000 (14:56 -0400)
----------------------------------------
* CRM-16725:
  https://issues.civicrm.org/jira/browse/CRM-16725

CRM/Contact/Form/Task/PDFLetterCommon.php

index 94f309254e89533b1d76a954c25b4debb55bee96..885b962ce2d50edf42783a5c41201e7c668cd145 100644 (file)
@@ -171,6 +171,13 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
 
     $buttons = array();
     if ($form->get('action') != CRM_Core_Action::VIEW) {
+      $buttons[] = array(
+        'type' => 'submit',
+        'name' => $form->_single ? ts('Preview PDF') : ts('Preview PDFs'),
+        'subName' => 'preview',
+        'icon' => 'zoomin',
+        'isDefault' => FALSE,
+      );
       $buttons[] = array(
         'type' => 'submit',
         'name' => $form->_single ? ts('Make PDF') : ts('Make PDFs'),
@@ -312,7 +319,7 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
    */
   public static function postProcess(&$form) {
     list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($form);
-
+    $buttonName = $form->controller->getButtonName();
     $skipOnHold = isset($form->skipOnHold) ? $form->skipOnHold : FALSE;
     $skipDeceased = isset($form->skipDeceased) ? $form->skipDeceased : TRUE;
 
@@ -345,7 +352,10 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
       $html[] = $tokenHtml;
     }
 
-    self::createActivities($form, $html_message, $form->_contactIds);
+    // CRM-16725 Skip creation of activities if user is previewing their PDF letter(s)
+    if ($buttonName == '_qf_PDF_submit') {
+      self::createActivities($form, $html_message, $form->_contactIds);
+    }
 
     CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);