From a37ec997eb9969be1b3e6cbdac54c328a2146bc5 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Sat, 3 Oct 2015 16:09:15 -0400 Subject: [PATCH] CRM-16725 - Add Preview PDF button to PDF Letter task so users can review PDF without creating activity. ---------------------------------------- * CRM-16725: https://issues.civicrm.org/jira/browse/CRM-16725 --- CRM/Contact/Form/Task/PDFLetterCommon.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index 94f309254e..885b962ce2 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -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); -- 2.25.1