$form->addDefaultButtons(ts('Send Email'), 'upload');
}
+ $fields = array(
+ 'followup_assignee_contact_id' => array(
+ 'type' => 'entityRef',
+ 'label' => ts('Assigned to'),
+ 'attributes' => array(
+ 'multiple' => TRUE,
+ 'create' => TRUE,
+ 'api' => array('params' => array('is_deceased' => 0)),
+ ),
+ ),
+ 'followup_activity_type_id' => array(
+ 'type' => 'select',
+ 'label' => ts('Followup Activity'),
+ 'attributes' => array('' => '- ' . ts('select activity') . ' -') + CRM_Core_PseudoConstant::ActivityType(FALSE),
+ 'extra' => array('class' => 'crm-select2'),
+ ),
+ 'followup_activity_subject' => array(
+ 'type' => 'text',
+ 'label' => ts('Subject'),
+ 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity',
+ 'subject'
+ ),
+ ),
+ );
+
+ //add followup date
+ $form->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
+
+ foreach ($fields as $field => $values) {
+ if (!empty($fields[$field])) {
+ $attribute = CRM_Utils_Array::value('attributes', $values);
+ $required = !empty($values['required']);
+
+ if ($values['type'] == 'select' && empty($attribute)) {
+ $form->addSelect($field, array('entity' => 'activity'), $required);
+ }
+ elseif ($values['type'] == 'entityRef') {
+ $form->addEntityRef($field, $values['label'], $attribute, $required);
+ }
+ else {
+ $form->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
+ }
+ }
+ }
+
$form->addFormRule(array('CRM_Contact_Form_Task_EmailCommon', 'formRule'), $form);
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js');
}
// check and ensure that
$formValues = $form->controller->exportValues($form->getName());
-
$fromEmail = $formValues['fromEmailAddress'];
$from = CRM_Utils_Array::value($fromEmail, $form->_emails);
$subject = $formValues['subject'];
// format contact details array to handle multiple emails from same contact
$formattedContactDetails = array();
$tempEmails = array();
-
foreach ($form->_contactIds as $key => $contactId) {
// if we dont have details on this contactID, we should ignore
// potentially this is due to the contact not wanting to receive email
$additionalDetails
);
+ $followupStatus = '';
if ($sent) {
+ $followupActivity = NULL;
+ if (!empty( $formValues['followup_activity_type_id'] )) {
+ $params['followup_activity_type_id'] = $formValues['followup_activity_type_id'];
+ $params['followup_activity_subject'] = $formValues['followup_activity_subject'];
+ $params['followup_date'] = $formValues['followup_date'];
+ $params['followup_date_time'] = $formValues['followup_date_time'];
+ $params['target_contact_id'] = $form->_contactIds;
+ $params['followup_assignee_contact_id'] = explode( ',', $formValues['followup_assignee_contact_id']);
+ $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activityId, $params);
+ $followupStatus = ts('A followup activity has been scheduled.');
+
+ if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
+ if ($followupActivity) {
+ $mailToFollowupContacts = array();
+ $assignee = array($followupActivity->id);
+ $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($assignee, TRUE, FALSE);
+ foreach ($assigneeContacts as $values) {
+ $mailToFollowupContacts[$values['email']] = $values;
+ }
+
+ if (!CRM_Utils_array::crmIsEmptyArray($mailToFollowupContacts)) {
+ $ics = new CRM_Activity_BAO_ICalendar($followupActivity);
+ $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $followupActivity->id);
+ $ics->addAttachment($attachments, $mailToFollowupContacts);
+ CRM_Case_BAO_Case::sendActivityCopy(NULL, $followupActivity->id, $mailToFollowupContacts, $attachments, NULL);
+ $ics->cleanup();
+ $followupStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
+ }
+ }
+ }
+ }
+
$count_success = count($form->_toContactDetails);
- CRM_Core_Session::setStatus(ts('One message was sent successfully.', array(
- 'plural' => '%count messages were sent successfully.',
+ CRM_Core_Session::setStatus(ts('One message was sent successfully. ', array(
+ 'plural' => '%count messages were sent successfully. ',
'count' => $count_success,
- )), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $count_success)), 'success');
+ )). $followupStatus, ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $count_success)), 'success');
}
// Display the name and number of contacts for those email is not sent.
{if $action neq 4} {* Don't include "Schedule Follow-up" section in View mode. *}
<tr class="crm-activity-form-block-schedule_followup">
<td colspan="2">
- <div class="crm-accordion-wrapper collapsed">
- <div class="crm-accordion-header">
- {ts}Schedule Follow-up{/ts}
- </div><!-- /.crm-accordion-header -->
- <div class="crm-accordion-body">
- <table class="form-layout-compressed">
- <tr><td class="label">{ts}Schedule Follow-up Activity{/ts}</td>
- <td>{$form.followup_activity_type_id.html} {ts}on{/ts}
- {include file="CRM/common/jcalendar.tpl" elementName=followup_date}
- </td>
- </tr>
- <tr>
- <td class="label">{$form.followup_activity_subject.label}</td>
- <td>{$form.followup_activity_subject.html|crmAddClass:huge}</td>
- </tr>
- <tr>
- <td class="label">
- {$form.followup_assignee_contact_id.label}
- {edit}
- {/edit}
- </td>
- <td>
- {$form.followup_assignee_contact_id.html}
- </td>
- </tr>
- </table>
- </div><!-- /.crm-accordion-body -->
- </div><!-- /.crm-accordion-wrapper -->
+ {include file="CRM/Activity/Form/FollowUp.tpl" type=""}
{literal}
<script type="text/javascript">
CRM.$(function($) {
--- /dev/null
+<div id="follow-up" class="crm-accordion-wrapper collapsed">
+ <div class="crm-accordion-header">
+ {ts}Schedule Follow-up{/ts}
+ </div><!-- /.crm-accordion-header -->
+ <div class="crm-accordion-body">
+ <table class="form-layout-compressed">
+ <tr class="crm-{$type}activity-form-block-followup_activity_type_id">
+ <td class="label">{ts}Schedule Follow-up Activity{/ts}</td>
+ <td>{$form.followup_activity_type_id.html} {ts}on{/ts}
+ {include file="CRM/common/jcalendar.tpl" elementName=followup_date}
+ </td>
+ </tr>
+ <tr class="crm-{$type}activity-form-block-followup_activity_subject">
+ <td class="label">{$form.followup_activity_subject.label}</td>
+ <td>{$form.followup_activity_subject.html|crmAddClass:huge}</td>
+ </tr>
+ <tr class="crm-{$type}activity-form-block-followup_assignee_contact_id">
+ <td class="label">
+ {$form.followup_assignee_contact_id.label}
+ {edit}
+ {/edit}
+ </td>
+ <td>
+ {$form.followup_assignee_contact_id.html}
+ </td>
+ </tr>
+ </table>
+ </div><!-- /.crm-accordion-body -->
+</div><!-- /.crm-accordion-wrapper -->
+
\ No newline at end of file
{/if}
<tr class="crm-case-activity-form-block-schedule_followup">
<td colspan="2">
-
- <div id="follow-up" class="crm-accordion-wrapper collapsed">
- <div class="crm-accordion-header">
- {ts}Schedule Follow-up{/ts}
- </div><!-- /.crm-accordion-header -->
- <div class="crm-accordion-body">
-
- <table class="form-layout-compressed">
- <tr class="crm-case-activity-form-block-followup_activity_type_id">
- <td class="label">{ts}Schedule Follow-up Activity{/ts}</td>
- <td>{$form.followup_activity_type_id.html} {ts}on{/ts}
- {include file="CRM/common/jcalendar.tpl" elementName=followup_date}
- </td>
- </tr>
- <tr class="crm-case-activity-form-block-followup_activity_subject">
- <td class="label">{$form.followup_activity_subject.label}</td>
- <td>{$form.followup_activity_subject.html|crmAddClass:huge}</td>
- </tr>
- <tr>
- <td class="label">
- {$form.followup_assignee_contact_id.label}
- {edit}
- {/edit}
- </td>
- <td>
- {$form.followup_assignee_contact_id.html}
- </td>
- </tr>
- </table>
- </div><!-- /.crm-accordion-body -->
- </div><!-- /.crm-accordion-wrapper -->
+ {include file="CRM/Activity/Form/FollowUp.tpl" type="case-"}
</td>
</tr>
{* Suppress activity status and priority for changes to status, case type and start date. PostProc will force status to completed. *}