From 623ba9d28d0a916f7912c579a9fd69a0ff7f59ab Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 30 May 2015 20:40:15 -0400 Subject: [PATCH] CRM-16596 - Fix adding PDF activity to case --- CRM/Contact/Form/Task/PDFLetterCommon.php | 4 ++++ templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index 9b02276071..62eccb8c88 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -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 diff --git a/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl b/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl index 89f6c21eed..44a9545e01 100644 --- a/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl +++ b/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl @@ -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; -- 2.25.1