CRM-16596 - Fix adding PDF activity to case
authorColeman Watts <coleman@civicrm.org>
Sun, 31 May 2015 00:40:15 +0000 (20:40 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 31 May 2015 00:40:15 +0000 (20:40 -0400)
CRM/Contact/Form/Task/PDFLetterCommon.php
templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl

index 9b0227607195f0bf1be9a6aede93d98e87053324..62eccb8c88abbe3c424360bda79eb5601438d625 100644 (file)
@@ -395,6 +395,10 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
     }
     if ($form->_cid) {
       $activity = CRM_Activity_BAO_Activity::create($activityParams);
+      if (!empty($form->_caseId)) {
+        $caseActivityParams = array('activity_id' => $activity->id, 'case_id' => $form->_caseId);
+        CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
+      }
     }
     else {
       // create  Print PDF activity for each selected contact. CRM-6886
index 89f6c21eed50ac806d2dbd5aea7be3f6f8bf325a..44a9545e01008125c78a677cbddd28153e7dc9d9 100644 (file)
@@ -128,6 +128,11 @@ CRM.$(function($) {
   $('#format_id', $form).on('change', function() {
     selectFormat($(this).val());
   });
+  // After the pdf downloads, the user has to manually close the dialog (which would be nice to fix)
+  // But at least we can trigger the underlying list of activities to refresh
+  $form.closest('.ui-dialog-content.crm-ajax-container').on('dialogbeforeclose', function() {
+    $(this).trigger('crmFormSuccess');
+  });
 });
 
 var currentWidth;