本文整理汇总了PHP中CRM_Core_BAO_MessageTemplate类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_MessageTemplate类的具体用法?PHP CRM_Core_BAO_MessageTemplate怎么用?PHP CRM_Core_BAO_MessageTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_MessageTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: commonLetterCompose
/**
* Function to build the compose PDF letter form
*
* @param $form
*
* @return None
* @access public
*/
public static function commonLetterCompose(&$form)
{
//get the tokens.
$tokens = CRM_Core_SelectValues::contactTokens();
if (CRM_Utils_System::getClassName($form) == 'CRM_Mailing_Form_Upload') {
$tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens);
}
//@todo move this fn onto the form
if (CRM_Utils_System::getClassName($form) == 'CRM_Contribute_Form_Task_PDFLetter') {
$tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens);
}
if (method_exists($form, 'listTokens')) {
$tokens = array_merge($form->listTokens(), $tokens);
}
//sorted in ascending order tokens by ignoring word case
natcasesort($tokens);
$form->assign('tokens', json_encode($tokens));
$form->add('select', 'token1', ts('Insert Tokens'), $tokens, FALSE, array('size' => "5", 'multiple' => TRUE, 'onchange' => "return tokenReplHtml(this);"));
$form->_templates = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE);
if (!empty($form->_templates)) {
$form->assign('templates', TRUE);
$form->add('select', 'template', ts('Select Template'), array('' => ts('- select -')) + $form->_templates, FALSE, array('onChange' => "selectValue( this.value );"));
$form->add('checkbox', 'updateTemplate', ts('Update Template'), NULL);
}
$form->add('checkbox', 'saveTemplate', ts('Save As New Template'), NULL, FALSE, array('onclick' => "showSaveDetails(this);"));
$form->add('text', 'saveTemplateName', ts('Template Title'));
$form->addWysiwyg('html_message', ts('Your Letter'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)"));
$action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE);
if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF' && $action == CRM_Core_Action::VIEW) {
$form->freeze('html_message');
}
}
示例2: sendActivityCopy
/**
* Function that sends e-mail copy of activity
*
* @param $clientId
* @param int $activityId activity Id
* @param array $contacts array of related contact
*
* @param null $attachments
* @param $caseId
*
* @return void
* @access public
*/
static function sendActivityCopy($clientId, $activityId, $contacts, $attachments = NULL, $caseId)
{
if (!$activityId) {
return;
}
$tplParams = $activityInfo = array();
//if its a case activity
if ($caseId) {
$activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityId, 'activity_type_id');
$nonCaseActivityTypes = CRM_Core_PseudoConstant::activityType();
if (!empty($nonCaseActivityTypes[$activityTypeId])) {
$anyActivity = TRUE;
} else {
$anyActivity = FALSE;
}
$tplParams['isCaseActivity'] = 1;
$tplParams['client_id'] = $clientId;
} else {
$anyActivity = TRUE;
}
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isRedact = $xmlProcessorProcess->getRedactActivityEmail();
$xmlProcessorReport = new CRM_Case_XMLProcessor_Report();
$activityInfo = $xmlProcessorReport->getActivityInfo($clientId, $activityId, $anyActivity, $isRedact);
if ($caseId) {
$activityInfo['fields'][] = array('label' => 'Case ID', 'type' => 'String', 'value' => $caseId);
}
$tplParams['activity'] = $activityInfo;
foreach ($tplParams['activity']['fields'] as $k => $val) {
if (CRM_Utils_Array::value('label', $val) == ts('Subject')) {
$activitySubject = $val['value'];
break;
}
}
$session = CRM_Core_Session::singleton();
// CRM-8926 If user is not logged in, use the activity creator as userID
if (!($userID = $session->get('userID'))) {
$userID = CRM_Activity_BAO_Activity::getSourceContactID($activityId);
}
//also create activities simultaneously of this copy.
$activityParams = array();
$activityParams['source_record_id'] = $activityId;
$activityParams['source_contact_id'] = $userID;
$activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name');
$activityParams['activity_date_time'] = date('YmdHis');
$activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$activityParams['medium_id'] = CRM_Core_OptionGroup::getValue('encounter_medium', 'email', 'name');
$activityParams['case_id'] = $caseId;
$activityParams['is_auto'] = 0;
$activityParams['target_id'] = $clientId;
$tplParams['activitySubject'] = $activitySubject;
// if it’s a case activity, add hashed id to the template (CRM-5916)
if ($caseId) {
$tplParams['idHash'] = substr(sha1(CIVICRM_SITE_KEY . $caseId), 0, 7);
}
$result = array();
list($name, $address) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
$receiptFrom = "{$name} <{$address}>";
$recordedActivityParams = array();
foreach ($contacts as $mail => $info) {
$tplParams['contact'] = $info;
self::buildPermissionLinks($tplParams, $activityParams);
$displayName = CRM_Utils_Array::value('display_name', $info);
list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_case', 'valueName' => 'case_activity', 'contactId' => CRM_Utils_Array::value('contact_id', $info), 'tplParams' => $tplParams, 'from' => $receiptFrom, 'toName' => $displayName, 'toEmail' => $mail, 'attachments' => $attachments));
$activityParams['subject'] = $activitySubject . ' - copy sent to ' . $displayName;
$activityParams['details'] = $message;
if (!empty($result[$info['contact_id']])) {
/*
* Really only need to record one activity with all the targets combined.
* Originally the template was going to possibly have different content, e.g. depending on permissions,
* but it's always the same content at the moment.
*/
if (empty($recordedActivityParams)) {
$recordedActivityParams = $activityParams;
} else {
$recordedActivityParams['subject'] .= "; {$displayName}";
}
$recordedActivityParams['target_contact_id'][] = $info['contact_id'];
} else {
unset($result[CRM_Utils_Array::value('contact_id', $info)]);
}
}
if (!empty($recordedActivityParams)) {
$activity = CRM_Activity_BAO_Activity::create($recordedActivityParams);
//create case_activity record if its case activity.
if ($caseId) {
$caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
//.........这里部分代码省略.........
示例3: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function postProcess(&$form)
{
// check and ensure that
$thisValues = $form->controller->exportValues($form->getName());
$fromSmsProviderId = $thisValues['sms_provider_id'];
// process message template
if (!empty($thisValues['saveTemplate']) || !empty($thisValues['updateTemplate'])) {
$messageTemplate = array('msg_text' => $thisValues['sms_text_message'], 'is_active' => TRUE);
if (!empty($thisValues['saveTemplate'])) {
$messageTemplate['msg_title'] = $thisValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
if (!empty($thisValues['template']) && !empty($thisValues['updateTemplate'])) {
$messageTemplate['id'] = $thisValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
}
// format contact details array to handle multiple sms from same contact
$formattedContactDetails = array();
$tempPhones = array();
foreach ($form->_contactIds as $key => $contactId) {
$phone = $form->_toContactPhone[$key];
if ($phone) {
$phoneKey = "{$contactId}::{$phone}";
if (!in_array($phoneKey, $tempPhones)) {
$tempPhones[] = $phoneKey;
if (!empty($form->_contactDetails[$contactId])) {
$formattedContactDetails[] = $form->_contactDetails[$contactId];
}
}
}
}
// $smsParams carries all the arguments provided on form (or via hooks), to the provider->send() method
// this gives flexibity to the users / implementors to add their own args via hooks specific to their sms providers
$smsParams = $thisValues;
unset($smsParams['sms_text_message']);
$smsParams['provider_id'] = $fromSmsProviderId;
$contactIds = array_keys($form->_contactDetails);
$allContactIds = array_keys($form->_allContactDetails);
list($sent, $activityId, $countSuccess) = CRM_Activity_BAO_Activity::sendSMS($formattedContactDetails, $thisValues, $smsParams, $contactIds);
if ($countSuccess > 0) {
CRM_Core_Session::setStatus(ts('One message was sent successfully.', array('plural' => '%count messages were sent successfully.', 'count' => $countSuccess)), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $countSuccess)), 'success');
}
if (is_array($sent)) {
// At least one PEAR_Error object was generated.
// Display the error messages to the user.
$status = '<ul>';
foreach ($sent as $errMsg) {
$status .= '<li>' . $errMsg . '</li>';
}
$status .= '</ul>';
CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($sent), 'plural' => '%count Messages Not Sent')), 'info');
} else {
//Display the name and number of contacts for those sms is not sent.
$smsNotSent = array_diff_assoc($allContactIds, $contactIds);
if (!empty($smsNotSent)) {
$not_sent = array();
foreach ($smsNotSent as $index => $contactId) {
$displayName = $form->_allContactDetails[$contactId]['display_name'];
$phone = $form->_allContactDetails[$contactId]['phone'];
$contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactId}");
$not_sent[] = "<a href='{$contactViewUrl}' title='{$phone}'>{$displayName}</a>";
}
$status = '(' . ts('because no phone number on file or communication preferences specify DO NOT SMS or Contact is deceased');
if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Form_Task_SMS') {
$status .= ' ' . ts("or the contact is not part of the activity '%1'", array(1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT));
}
$status .= ')<ul><li>' . implode('</li><li>', $not_sent) . '</li></ul>';
CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($smsNotSent), 'plural' => '%count Messages Not Sent')), 'info');
}
}
}
示例4: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_BAO_MessageTemplate::del($this->_id);
} elseif ($this->_action & CRM_Core_Action::VIEW) {
// currently, the above action is used solely for previewing default workflow templates
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'));
} else {
$params = array();
// store the submitted values in an array
$params = $this->exportValues();
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
if ($this->_workflow_id) {
$params['workflow_id'] = $this->_workflow_id;
$params['is_active'] = TRUE;
}
$messageTemplate = CRM_Core_BAO_MessageTemplate::add($params);
CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', array(1 => $messageTemplate->msg_title)), ts('Saved'), 'success');
if ($this->_workflow_id) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'));
} else {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=user&reset=1'));
}
}
}
示例5: emailReceipt
//.........这里部分代码省略.........
if (property_exists($form, '_groupTree') && !empty($form->_groupTree)) {
foreach ($form->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
}
}
$members = array(array('member_id', '=', $membership->id, 0, 0));
// check whether its a test drive
if ($form->_mode == 'test') {
$members[] = array('member_test', '=', 1, 0, 0);
}
CRM_Core_BAO_UFGroup::getValues($formValues['contact_id'], $customFields, $customValues, FALSE, $members);
if ($form->_mode) {
if (!empty($form->_params['billing_first_name'])) {
$name = $form->_params['billing_first_name'];
}
if (!empty($form->_params['billing_middle_name'])) {
$name .= " {$form->_params['billing_middle_name']}";
}
if (!empty($form->_params['billing_last_name'])) {
$name .= " {$form->_params['billing_last_name']}";
}
$form->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$form->_bltID}", "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "state_province-{$form->_bltID}", "country-{$form->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($form->_params['billing_' . $part])) {
$addressFields[$n] = $form->_params['billing_' . $part];
}
}
$form->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($form->_params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$form->assign('credit_card_exp_date', $date);
$form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($form->_params['credit_card_number']));
$form->assign('credit_card_type', $form->_params['credit_card_type']);
$form->assign('contributeMode', 'direct');
$form->assign('isAmountzero', 0);
$form->assign('is_pay_later', 0);
$form->assign('isPrimary', 1);
}
$form->assign('module', 'Membership');
$form->assign('contactID', $formValues['contact_id']);
$form->assign('membershipID', CRM_Utils_Array::value('membership_id', $form->_params, CRM_Utils_Array::value('membership_id', $form->_defaultValues)));
if (!empty($formValues['contribution_id'])) {
$form->assign('contributionID', $formValues['contribution_id']);
} elseif (isset($form->_onlinePendingContributionId)) {
$form->assign('contributionID', $form->_onlinePendingContributionId);
}
if (!empty($formValues['contribution_status_id'])) {
$form->assign('contributionStatusID', $formValues['contribution_status_id']);
$form->assign('contributionStatus', CRM_Contribute_PseudoConstant::contributionStatus($formValues['contribution_status_id'], 'name'));
}
if (!empty($formValues['is_renew'])) {
$form->assign('receiptType', 'membership renewal');
} else {
$form->assign('receiptType', 'membership signup');
}
$form->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $formValues)));
$form->assign('formValues', $formValues);
if (empty($lineItem)) {
$form->assign('mem_start_date', CRM_Utils_Date::customFormat($membership->start_date, '%B %E%f, %Y'));
if (!CRM_Utils_System::isNull($membership->end_date)) {
$form->assign('mem_end_date', CRM_Utils_Date::customFormat($membership->end_date, '%B %E%f, %Y'));
}
$form->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
}
$form->assign('customValues', $customValues);
$isBatchProcess = is_a($form, 'CRM_Batch_Form_Entry');
if (empty($form->_contributorDisplayName) || empty($form->_contributorEmail) || $isBatchProcess) {
// in this case the form is being called statically from the batch editing screen
// having one class in the form layer call another statically is not greate
// & we should aim to move this function to the BAO layer in future.
// however, we can assume that the contact_id passed in by the batch
// function will be the recipient
list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($formValues['contact_id']);
if (empty($form->_receiptContactId) || $isBatchProcess) {
$form->_receiptContactId = $formValues['contact_id'];
}
}
$template = CRM_Core_Smarty::singleton();
$taxAmt = $template->get_template_vars('dataArray');
$eventTaxAmt = $template->get_template_vars('totalTaxAmount');
$prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
$isEmailPdf = TRUE;
} else {
$isEmailPdf = FALSE;
}
list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $form->_receiptContactId, 'from' => $receiptFrom, 'toName' => $form->_contributorDisplayName, 'toEmail' => $form->_contributorEmail, 'PDFFilename' => ts('receipt') . '.pdf', 'isEmailPdf' => $isEmailPdf, 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW)));
return TRUE;
}
示例6: parseActionSchedule
//.........这里部分代码省略.........
} elseif (CRM_Utils_Array::value('recipient', $values) == 'group') {
$params['group_id'] = $values['group_id'];
$params['recipient_manual'] = $params['recipient'] = $params['recipient_listing'] = 'null';
} elseif (isset($values['recipient_listing']) && isset($values['limit_to']) && !CRM_Utils_System::isNull($values['recipient_listing']) && !CRM_Utils_System::isNull($values['limit_to'])) {
$params['recipient'] = CRM_Utils_Array::value('recipient', $values);
$params['recipient_listing'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('recipient_listing', $values));
$params['group_id'] = $params['recipient_manual'] = 'null';
} else {
$params['recipient'] = CRM_Utils_Array::value('recipient', $values);
$params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null';
}
if (!empty($this->_mappingID) && !empty($this->_compId)) {
$params['mapping_id'] = $this->_mappingID;
$params['entity_value'] = $this->_compId;
$params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $values['entity']);
} else {
$params['mapping_id'] = $values['entity'][0];
if ($params['mapping_id'] == 1) {
$params['limit_to'] = 1;
}
$entity_value = CRM_Utils_Array::value(1, $values['entity'], array());
$entity_status = CRM_Utils_Array::value(2, $values['entity'], array());
$params['entity_value'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $entity_value);
$params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $entity_status);
}
$params['is_active'] = CRM_Utils_Array::value('is_active', $values, 0);
if (CRM_Utils_Array::value('is_repeat', $values) == 0) {
$params['repetition_frequency_unit'] = 'null';
$params['repetition_frequency_interval'] = 'null';
$params['end_frequency_unit'] = 'null';
$params['end_frequency_interval'] = 'null';
$params['end_action'] = 'null';
$params['end_date'] = 'null';
}
// multilingual options
$params['filter_contact_language'] = CRM_Utils_Array::value('filter_contact_language', $values, array());
$params['filter_contact_language'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['filter_contact_language']);
$params['communication_language'] = CRM_Utils_Array::value('communication_language', $values, NULL);
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
} elseif ($this->_action & CRM_Core_Action::ADD) {
// we do this only once, so name never changes
$params['name'] = CRM_Utils_String::munge($params['title'], '_', 64);
}
$modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS');
if ($params['mode'] == 'Email' || empty($params['sms_provider_id'])) {
unset($modePrefixes['SMS']);
} elseif ($params['mode'] == 'SMS') {
unset($modePrefixes['Mail']);
}
//TODO: handle postprocessing of SMS and/or Email info based on $modePrefixes
$composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
$msgTemplate = NULL;
//mail template is composed
foreach ($modePrefixes as $prefix) {
$composeParams = array();
foreach ($composeFields as $key) {
$key = $prefix . $key;
if (!empty($values[$key])) {
$composeParams[$key] = $values[$key];
}
}
if (!empty($composeParams[$prefix . 'updateTemplate'])) {
$templateParams = array('is_active' => TRUE);
if ($prefix == 'SMS') {
$templateParams += array('msg_text' => $params['sms_body_text'], 'is_sms' => TRUE);
} else {
$templateParams += array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject']);
}
$templateParams['id'] = $values[$prefix . 'template'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (!empty($composeParams[$prefix . 'saveTemplate'])) {
$templateParams = array('is_active' => TRUE);
if ($prefix == 'SMS') {
$templateParams += array('msg_text' => $params['sms_body_text'], 'is_sms' => TRUE);
} else {
$templateParams += array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject']);
}
$templateParams['msg_title'] = $composeParams[$prefix . 'saveTemplateName'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if ($prefix == 'SMS') {
if (isset($msgTemplate->id)) {
$params['sms_template_id'] = $msgTemplate->id;
} else {
$params['sms_template_id'] = CRM_Utils_Array::value('SMStemplate', $values);
}
} else {
if (isset($msgTemplate->id)) {
$params['msg_template_id'] = $msgTemplate->id;
} else {
$params['msg_template_id'] = CRM_Utils_Array::value('template', $values);
}
}
}
$actionSchedule = new CRM_Core_DAO_ActionSchedule();
$actionSchedule->copyValues($params);
return $actionSchedule;
}
示例7: updatePledgeStatus
public static function updatePledgeStatus($params)
{
$returnMessages = array();
$sendReminders = CRM_Utils_Array::value('send_reminders', $params, FALSE);
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//unset statues that we never use for pledges
foreach (array('Completed', 'Cancelled', 'Failed') as $statusKey) {
if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
unset($allStatus[$key]);
}
}
$statusIds = implode(',', array_keys($allStatus));
$updateCnt = 0;
$query = "\nSELECT pledge.contact_id as contact_id,\n pledge.id as pledge_id,\n pledge.amount as amount,\n payment.scheduled_date as scheduled_date,\n pledge.create_date as create_date,\n payment.id as payment_id,\n pledge.currency as currency,\n pledge.contribution_page_id as contribution_page_id,\n payment.reminder_count as reminder_count,\n pledge.max_reminders as max_reminders,\n payment.reminder_date as reminder_date,\n pledge.initial_reminder_day as initial_reminder_day,\n pledge.additional_reminder_day as additional_reminder_day,\n pledge.status_id as pledge_status,\n payment.status_id as payment_status,\n pledge.is_test as is_test,\n pledge.campaign_id as campaign_id,\n SUM(payment.scheduled_amount) as amount_due,\n ( SELECT sum(civicrm_pledge_payment.actual_amount)\n FROM civicrm_pledge_payment\n WHERE civicrm_pledge_payment.status_id = 1\n AND civicrm_pledge_payment.pledge_id = pledge.id\n ) as amount_paid\n FROM civicrm_pledge pledge, civicrm_pledge_payment payment\n WHERE pledge.id = payment.pledge_id\n AND payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )\n GROUP By payment.id\n ";
$dao = CRM_Core_DAO::executeQuery($query);
$now = date('Ymd');
$pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
while ($dao->fetch()) {
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
$pledgeDetails[$dao->payment_id] = array('scheduled_date' => $dao->scheduled_date, 'amount_due' => $dao->amount_due, 'amount' => $dao->amount, 'amount_paid' => $dao->amount_paid, 'create_date' => $dao->create_date, 'contact_id' => $dao->contact_id, 'pledge_id' => $dao->pledge_id, 'checksumValue' => $checksumValue, 'contribution_page_id' => $dao->contribution_page_id, 'reminder_count' => $dao->reminder_count, 'max_reminders' => $dao->max_reminders, 'reminder_date' => $dao->reminder_date, 'initial_reminder_day' => $dao->initial_reminder_day, 'additional_reminder_day' => $dao->additional_reminder_day, 'pledge_status' => $dao->pledge_status, 'payment_status' => $dao->payment_status, 'is_test' => $dao->is_test, 'currency' => $dao->currency, 'campaign_id' => $dao->campaign_id);
$contactIds[$dao->contact_id] = $dao->contact_id;
$pledgeStatus[$dao->pledge_id] = $dao->pledge_status;
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'), $now) && $dao->payment_status != array_search('Overdue', $allStatus)) {
$pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id;
}
}
// process the updating script...
foreach ($pledgePayments as $pledgeId => $paymentIds) {
// 1. update the pledge /pledge payment status. returns new status when an update happens
$returnMessages[] = "Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})";
$newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds, array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE);
if ($newStatus != $pledgeStatus[$pledgeId]) {
$returnMessages[] = "- status updated to: {$allStatus[$newStatus]}";
$updateCnt += 1;
}
}
if ($sendReminders) {
// retrieve domain tokens
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
$domainValues = array();
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
//get the domain email address, since we don't carry w/ object.
$domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
$domainValues['email'] = $domainValue[1];
// retrieve contact tokens
// this function does NOT return Deceased contacts since we don't want to send them email
list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, $tokens, 'CRM_UpdatePledgeRecord');
// assign domain values to template
$template = CRM_Core_Smarty::singleton();
$template->assign('domain', $domainValues);
//set receipt from
$receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
foreach ($pledgeDetails as $paymentId => $details) {
if (array_key_exists($details['contact_id'], $contactDetails)) {
$contactId = $details['contact_id'];
$pledgerName = $contactDetails[$contactId]['display_name'];
} else {
continue;
}
if (empty($details['reminder_date'])) {
$nextReminderDate = new DateTime($details['scheduled_date']);
$nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
} else {
$nextReminderDate = new DateTime($details['reminder_date']);
$nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
}
if ($details['reminder_count'] < $details['max_reminders'] && $nextReminderDate <= $now) {
$toEmail = $doNotEmail = $onHold = NULL;
if (!empty($contactDetails[$contactId]['email'])) {
$toEmail = $contactDetails[$contactId]['email'];
}
if (!empty($contactDetails[$contactId]['do_not_email'])) {
$doNotEmail = $contactDetails[$contactId]['do_not_email'];
}
if (!empty($contactDetails[$contactId]['on_hold'])) {
$onHold = $contactDetails[$contactId]['on_hold'];
}
// 2. send acknowledgement mail
if ($toEmail && !($doNotEmail || $onHold)) {
//assign value to template
$template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
$template->assign('contact', $contactDetails[$contactId]);
$template->assign('next_payment', $details['scheduled_date']);
$template->assign('amount_due', $details['amount_due']);
$template->assign('checksumValue', $details['checksumValue']);
$template->assign('contribution_page_id', $details['contribution_page_id']);
$template->assign('pledge_id', $details['pledge_id']);
$template->assign('scheduled_payment_date', $details['scheduled_date']);
$template->assign('amount', $details['amount']);
$template->assign('create_date', $details['create_date']);
$template->assign('currency', $details['currency']);
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_reminder', 'contactId' => $contactId, 'from' => $receiptFrom, 'toName' => $pledgerName, 'toEmail' => $toEmail));
// 3. update pledge payment details
if ($mailSent) {
CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId);
//.........这里部分代码省略.........
示例8: commonSendMail
/**
* Process that send notification e-mails
*
* @param int $contactID
* Contact id.
* @param array $values
* Associative array of name/value pair.
*/
public static function commonSendMail($contactID, &$values)
{
if (!$contactID || !$values) {
return;
}
$template = CRM_Core_Smarty::singleton();
$displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name');
self::profileDisplay($values['id'], $values['values'], $template);
$emailList = explode(',', $values['email']);
$contactLink = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactID}", TRUE, NULL, FALSE, FALSE, TRUE);
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
foreach ($emailList as $emailTo) {
// FIXME: take the below out of the foreach loop
CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_uf', 'valueName' => 'uf_notify', 'contactId' => $contactID, 'tplParams' => array('displayName' => $displayName, 'currentDate' => date('r'), 'contactLink' => $contactLink), 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $emailTo));
}
}
示例9: printPDF
//.........这里部分代码省略.........
} else {
$stateProvinceAbbreviationDomain = '';
}
if (isset($locationDefaults['address'][1]['country_id'])) {
$countryDomain = CRM_Core_PseudoConstant::country($locationDefaults['address'][1]['country_id']);
} else {
$countryDomain = '';
}
// parameters to be assign for template
$tplParams = array('title' => $title, 'component' => $input['component'], 'id' => $contribution->id, 'source' => $source, 'invoice_id' => $invoiceId, 'resourceBase' => $config->userFrameworkResourceURL, 'defaultCurrency' => $config->defaultCurrency, 'amount' => $contribution->total_amount, 'amountDue' => $amountDue, 'invoice_date' => $invoiceDate, 'dueDate' => $dueDate, 'notes' => CRM_Utils_Array::value('notes', $prefixValue), 'display_name' => $contribution->_relatedObjects['contact']->display_name, 'lineItem' => $lineItem, 'dataArray' => $dataArray, 'refundedStatusId' => $refundedStatusId, 'contribution_status_id' => $contribution->contribution_status_id, 'subTotal' => $subTotal, 'street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'stateProvinceAbbreviation' => $stateProvinceAbbreviation, 'postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'is_pay_later' => $contribution->is_pay_later, 'organization_name' => $contribution->_relatedObjects['contact']->organization_name, 'domain_organization' => $domain->name, 'domain_street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_state' => $stateProvinceAbbreviationDomain, 'domain_country' => $countryDomain, 'domain_email' => CRM_Utils_Array::value('email', CRM_Utils_Array::value('1', $locationDefaults['email'])), 'domain_phone' => CRM_Utils_Array::value('phone', CRM_Utils_Array::value('1', $locationDefaults['phone'])));
if (isset($creditNoteId)) {
$tplParams['creditnote_id'] = $creditNoteId;
}
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_invoice_receipt', 'contactId' => $contribution->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => 'Invoice.pdf');
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
//CRM-16319 - we dont store in userID in case the user is doing multiple
//transactions etc
if (empty($contactID)) {
$contactID = $session->get('transaction.userID');
}
$contactEmails = CRM_Core_BAO_Email::allEmails($contactID);
$emails = array();
$fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name');
foreach ($contactEmails as $emailId => $item) {
$email = $item['email'];
if ($email) {
$emails[$emailId] = '"' . $fromDisplayName . '" <' . $email . '> ';
}
}
$fromEmail = CRM_Utils_Array::crmArrayMerge($emails, CRM_Core_OptionGroup::values('from_email_address'));
// from email address
if (isset($params['from_email_address'])) {
$fromEmailAddress = CRM_Utils_Array::value($params['from_email_address'], $fromEmail);
}
// condition to check for download PDF Invoice or email Invoice
if ($invoiceElements['createPdf']) {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
if (isset($params['forPage'])) {
return $html;
} else {
$mail = array('subject' => $subject, 'body' => $message, 'html' => $html);
if ($mail['html']) {
$messageInvoice[] = $mail['html'];
} else {
$messageInvoice[] = nl2br($mail['body']);
}
}
} elseif ($contribution->_component == 'contribute') {
$email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
$sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment']));
$sendTemplateParams['from'] = $fromEmailAddress;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values);
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
$fileName = self::putFile($html);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
} elseif ($contribution->_component == 'event') {
$email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
$sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment']));
$sendTemplateParams['from'] = $fromEmailAddress;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_confirm', $values);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_confirm', $values);
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
$fileName = self::putFile($html);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
}
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'invoice_id', $invoiceId);
if ($contribution->contribution_status_id == $refundedStatusId) {
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'creditnote_id', $creditNoteId);
}
$invoiceTemplate->clearTemplateVars();
}
if ($invoiceElements['createPdf']) {
if (isset($params['forPage'])) {
return $html;
} else {
CRM_Utils_PDF_Utils::html2pdf($messageInvoice, 'Invoice.pdf', FALSE, array('margin_top' => 10, 'margin_left' => 65, 'metric' => 'px'));
// functions call for adding activity with attachment
$fileName = self::putFile($html);
self::addActivities($subject, $contactIds, $fileName, $params);
CRM_Utils_System::civiExit();
}
} else {
if ($invoiceElements['suppressedEmails']) {
$status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $invoiceElements['suppressedEmails']));
$msgTitle = ts('Email Error');
$msgType = 'error';
} else {
$status = ts('Your mail has been sent.');
$msgTitle = ts('Sent');
$msgType = 'success';
}
CRM_Core_Session::setStatus($status, $msgTitle, $msgType);
}
}
示例10: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active', 'is_notify');
foreach ($checkBoxes as $key) {
if (!isset($params[$key])) {
$params[$key] = 0;
}
}
$session = CRM_Core_Session::singleton();
$contactID = isset($this->_contactID) ? $this->_contactID : $session->get('userID');
if (!$contactID) {
$contactID = $this->get('contactID');
}
$params['title'] = $params['pcp_title'];
$params['intro_text'] = $params['pcp_intro_text'];
$params['contact_id'] = $contactID;
$params['page_id'] = $this->get('component_page_id') ? $this->get('component_page_id') : $this->_contriPageId;
$params['page_type'] = $this->_component;
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
$htmlFields = array('intro_text', 'page_text', 'title');
foreach ($htmlFields as $field) {
if (!empty($params[$field])) {
$params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
}
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $params['page_id'];
$pcpBlock->find(TRUE);
$params['pcp_block_id'] = $pcpBlock->id;
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
$approval_needed = $pcpBlock->is_approval_needed;
$approvalMessage = NULL;
if ($this->get('action') & CRM_Core_Action::ADD) {
$params['status_id'] = $approval_needed ? 1 : 2;
$approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin promoting your campaign. You will receive an email confirmation shortly which includes a link to return to this page.') : ts('and is ready to use.');
}
$params['id'] = $this->_pageId;
$pcp = CRM_PCP_BAO_PCP::add($params, FALSE);
//create page in wordpress
create_wp_campaign($pcp->title, $pcp->contact_id, $pcp->id);
CRM_Core_Error::debug_log_message("Calling create_wp_campaign.... Params title: {$pcp->title}, contact_id: {$pcp->contact_id}, pcp_id: {$pcp->id} ");
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
$pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
$statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id');
//send notification of PCP create/update.
$pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id);
$notifyParams = array();
$notifyStatus = "";
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
if ($emails = $pcpBlock->notify_email) {
$this->assign('pcpTitle', $pcp->title);
if ($this->_pageId) {
$this->assign('mode', 'Update');
} else {
$this->assign('mode', 'Add');
}
$pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
$this->assign('pcpStatus', $pcpStatus);
$this->assign('pcpId', $pcp->id);
$supporterUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$pcp->contact_id}", TRUE, NULL, FALSE, FALSE);
$this->assign('supporterUrl', $supporterUrl);
$supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
$this->assign('supporterName', $supporterName);
if ($this->_component == 'contribute') {
$pageUrl = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcpBlock->entity_id, 'title');
} elseif ($this->_component == 'event') {
$pageUrl = CRM_Utils_System::url('civicrm/event', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpBlock->entity_id, 'title');
}
$this->assign('contribPageUrl', $pageUrl);
$this->assign('contribPageTitle', $contribPageTitle);
$managePCPUrl = CRM_Utils_System::url('civicrm/admin/pcp', "reset=1", TRUE, NULL, FALSE, FALSE);
$this->assign('managePCPUrl', $managePCPUrl);
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
//if more than one email present for PCP notification ,
//first email take it as To and other as CC and First email
//address should be sent in users email receipt for
//support purpose.
$emailArray = explode(',', $emails);
$to = $emailArray[0];
unset($emailArray[0]);
$cc = implode(',', $emailArray);
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $to, 'cc' => $cc));
//.........这里部分代码省略.........
示例11: submit
//.........这里部分代码省略.........
// These variable sets prior to renewMembership may not be required for this form. They were in
// a function this form shared with other forms.
$membershipSource = NULL;
if (!empty($this->_params['membership_source'])) {
$membershipSource = $this->_params['membership_source'];
}
$isPending = $this->_params['contribution_status_id'] == 2 ? TRUE : FALSE;
list($renewMembership) = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_params['membership_type_id'][1], $isTestMembership, $renewalDate, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId, $isPending, $contributionRecurID, $membershipSource, $this->_params['is_pay_later'], CRM_Utils_Array::value('campaign_id', $this->_params));
$this->endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
$this->membershipTypeName = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
if (!empty($this->_params['record_contribution']) || $this->_mode) {
// set the source
$this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})";
//create line items
$lineItem = array();
$this->_params = $this->setPriceSetParameters($this->_params);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$this->_priceSetId]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $this->_params)) {
foreach ($lineItem[$this->_priceSetId] as &$li) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
if (!empty($lineItem)) {
$this->_params['lineItems'] = $lineItem;
$this->_params['processPriceSet'] = TRUE;
}
//assign contribution contact id to the field expected by recordMembershipContribution
if ($this->_contributorContactID != $this->_contactID) {
$this->_params['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])) {
$this->_params['soft_credit'] = array('soft_credit_type_id' => $this->_params['soft_credit_type_id'], 'contact_id' => $this->_contactID);
}
}
$this->_params['contact_id'] = $this->_contactID;
//recordMembershipContribution receives params as a reference & adds one variable. This is
// not a great pattern & ideally it would not receive as a reference. We assign our params as a
// temporary variable to avoid e-notice & to make it clear to future refactorer that
// this function is NOT reliant on that var being set
$temporaryParams = array_merge($this->_params, array('membership_id' => $renewMembership->id));
CRM_Member_BAO_Membership::recordMembershipContribution($temporaryParams);
}
if (!empty($this->_params['send_receipt'])) {
$receiptFrom = $this->_params['from_email_address'];
if (!empty($this->_params['payment_instrument_id'])) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$this->_params['paidBy'] = $paymentInstrument[$this->_params['payment_instrument_id']];
}
//get the group Tree
$this->_groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $this->_id, FALSE, $this->_memType);
// retrieve custom data
$customFields = $customValues = $fo = array();
foreach ($this->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
}
$members = array(array('member_id', '=', $this->_membershipId, 0, 0));
// check whether its a test drive
if ($this->_mode == 'test') {
$members[] = array('member_test', '=', 1, 0, 0);
}
CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, FALSE, $members);
$this->assign_by_ref('formValues', $this->_params);
if (!empty($this->_params['contribution_id'])) {
$this->assign('contributionID', $this->_params['contribution_id']);
}
$this->assign('membership_name', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id));
$this->assign('customValues', $customValues);
$this->assign('mem_start_date', CRM_Utils_Date::customFormat($renewMembership->start_date));
$this->assign('mem_end_date', CRM_Utils_Date::customFormat($renewMembership->end_date));
if ($this->_mode) {
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
}
}
$this->assign('address', CRM_Utils_Address::format($addressFields));
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
$this->assign('receipt_text_renewal', $this->_params['receipt_text']);
if ($this->_mode == 'test') {
$this->assign('action', '1024');
}
}
list($this->isMailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $this->_receiptContactId, 'from' => $receiptFrom, 'toName' => $this->_contributorDisplayName, 'toEmail' => $this->_contributorEmail, 'isTest' => $this->_mode == 'test'));
}
}
示例12: sendAbsenceMail
/**
* Function to send absence email
*
* @access public
* @static
*/
public static function sendAbsenceMail($mailprm, $sendTemplateParams)
{
foreach ($mailprm as $k => $v) {
$sendTemplateParams['tplParams']['displayName'] = $v['display_name'];
$sendTemplateParams['toName'] = $v['display_name'];
$sendTemplateParams['toEmail'] = $v['email'];
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
}
示例13: postProcess
/**
* Process the form after the input has been submitted and validated.
*
* @param CRM_Core_Form $form
*/
public static function postProcess(&$form)
{
if (count($form->_contactIds) > self::MAX_EMAILS_KILL_SWITCH) {
CRM_Core_Error::fatal(ts('Please do not use this task to send a lot of emails (greater than %1). We recommend using CiviMail instead.', array(1 => self::MAX_EMAILS_KILL_SWITCH)));
}
// check and ensure that
$formValues = $form->controller->exportValues($form->getName());
$fromEmail = $formValues['fromEmailAddress'];
$from = CRM_Utils_Array::value($fromEmail, $form->_emails);
$subject = $formValues['subject'];
// CRM-13378: Append CC and BCC information at the end of Activity Details and format cc and bcc fields
$elements = array('cc_id', 'bcc_id');
$additionalDetails = NULL;
$ccValues = $bccValues = array();
foreach ($elements as $element) {
if (!empty($formValues[$element])) {
$allEmails = explode(',', $formValues[$element]);
foreach ($allEmails as $value) {
list($contactId, $email) = explode('::', $value);
$contactURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$contactId}", TRUE);
switch ($element) {
case 'cc_id':
$ccValues['email'][] = '"' . $form->_contactDetails[$contactId]['sort_name'] . '" <' . $email . '>';
$ccValues['details'][] = "<a href='{$contactURL}'>" . $form->_contactDetails[$contactId]['display_name'] . "</a>";
break;
case 'bcc_id':
$bccValues['email'][] = '"' . $form->_contactDetails[$contactId]['sort_name'] . '" <' . $email . '>';
$bccValues['details'][] = "<a href='{$contactURL}'>" . $form->_contactDetails[$contactId]['display_name'] . "</a>";
break;
}
}
}
}
$cc = $bcc = '';
if (!empty($ccValues)) {
$cc = implode(',', $ccValues['email']);
$additionalDetails .= "\ncc : " . implode(", ", $ccValues['details']);
}
if (!empty($bccValues)) {
$bcc = implode(',', $bccValues['email']);
$additionalDetails .= "\nbcc : " . implode(", ", $bccValues['details']);
}
// CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
if (isset($form->_caseId) && is_numeric($form->_caseId)) {
$hash = substr(sha1(CIVICRM_SITE_KEY . $form->_caseId), 0, 7);
$subject = "[case #{$hash}] {$subject}";
}
// process message template
if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
$messageTemplate = array('msg_text' => $formValues['text_message'], 'msg_html' => $formValues['html_message'], 'msg_subject' => $formValues['subject'], 'is_active' => TRUE);
if (!empty($formValues['saveTemplate'])) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
if (!empty($formValues['template']) && !empty($formValues['updateTemplate'])) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
}
$attachments = array();
CRM_Core_BAO_File::formatAttachment($formValues, $attachments, NULL, NULL);
// 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
if (!isset($form->_contactDetails[$contactId])) {
continue;
}
$email = $form->_toContactEmails[$key];
// prevent duplicate emails if same email address is selected CRM-4067
// we should allow same emails for different contacts
$emailKey = "{$contactId}::{$email}";
if (!in_array($emailKey, $tempEmails)) {
$tempEmails[] = $emailKey;
$details = $form->_contactDetails[$contactId];
$details['email'] = $email;
unset($details['email_id']);
$formattedContactDetails[] = $details;
}
}
// send the mail
list($sent, $activityId) = CRM_Activity_BAO_Activity::sendEmail($formattedContactDetails, $subject, $formValues['text_message'], $formValues['html_message'], NULL, NULL, $from, $attachments, $cc, $bcc, array_keys($form->_toContactDetails), $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']);
//.........这里部分代码省略.........
示例14: emailReceipt
/**
* @param array $params
*
* @return mixed
*/
public function emailReceipt(&$params)
{
// email receipt sending
// send message template
if ($this->_component == 'event') {
$eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
$returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $eventId, $events, $returnProperties);
$event = $events[$eventId];
unset($event['start_date']);
unset($event['end_date']);
$this->assign('event', $event);
$this->assign('isShowLocation', $event['is_show_location']);
if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
$locationParams = array('entity_id' => $eventId, 'entity_table' => 'civicrm_event');
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
$this->assign('location', $location);
}
}
// assign payment info here
$paymentConfig['confirm_email_text'] = CRM_Utils_Array::value('confirm_email_text', $params);
$this->assign('paymentConfig', $paymentConfig);
$isRefund = $this->_paymentType == 'refund' ? TRUE : FALSE;
$this->assign('isRefund', $isRefund);
if ($isRefund) {
$this->assign('totalPaid', $this->_amtPaid);
$this->assign('totalAmount', $this->_amtTotal);
$this->assign('refundAmount', $params['total_amount']);
} else {
$balance = $this->_amtTotal - ($this->_amtPaid + $params['total_amount']);
$paymentsComplete = $balance == 0 ? 1 : 0;
$this->assign('amountOwed', $balance);
$this->assign('totalAmount', $this->_amtTotal);
$this->assign('paymentAmount', $params['total_amount']);
$this->assign('paymentsComplete', $paymentsComplete);
}
$this->assign('contactDisplayName', $this->_contributorDisplayName);
// assign trxn details
$this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $params));
$this->assign('receive_date', CRM_Utils_Array::value('trxn_date', $params));
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
if (array_key_exists('payment_instrument_id', $params)) {
$this->assign('paidBy', CRM_Utils_Array::value($params['payment_instrument_id'], $paymentInstrument));
}
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'payment_or_refund_notification', 'contactId' => $this->_contactId, 'PDFFilename' => ts('notification') . '.pdf');
// try to send emails only if email id is present
// and the do-not-email option is not checked for that contact
if ($this->_contributorEmail && !$this->_toDoNotEmail) {
if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) {
$receiptFrom = $params['from_email_address'];
}
$sendTemplateParams['from'] = $receiptFrom;
$sendTemplateParams['toName'] = $this->_contributorDisplayName;
$sendTemplateParams['toEmail'] = $this->_contributorEmail;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails);
}
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
return $mailSent;
}
示例15: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
// delete reminder
CRM_Core_BAO_ActionSchedule::del($this->_id);
CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success');
if ($this->_context == 'event' && $this->_eventId) {
$url = CRM_Utils_System::url('civicrm/event/manage/reminder', "reset=1&action=update&id={$this->_eventId}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
return;
}
$values = $this->controller->exportValues($this->getName());
$keys = array('title', 'subject', 'absolute_date', 'group_id', 'record_activity', 'limit_to', 'mode', 'sms_provider_id', 'from_name', 'from_email');
foreach ($keys as $key) {
$params[$key] = CRM_Utils_Array::value($key, $values);
}
$moreKeys = array('start_action_offset', 'start_action_unit', 'start_action_condition', 'start_action_date', 'repetition_frequency_unit', 'repetition_frequency_interval', 'end_frequency_unit', 'end_frequency_interval', 'end_action', 'end_date');
if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) {
$params['absolute_date'] = CRM_Utils_Date::processDate($absoluteDate);
foreach ($moreKeys as $mkey) {
$params[$mkey] = 'null';
}
} else {
$params['absolute_date'] = 'null';
foreach ($moreKeys as $mkey) {
$params[$mkey] = CRM_Utils_Array::value($mkey, $values);
}
}
$params['body_text'] = CRM_Utils_Array::value('text_message', $values);
$params['body_html'] = CRM_Utils_Array::value('html_message', $values);
if (CRM_Utils_Array::value('recipient', $values) == 'manual') {
$params['recipient_manual'] = CRM_Utils_Array::value('recipient_manual_id', $values);
$params['group_id'] = $params['recipient'] = $params['recipient_listing'] = 'null';
} elseif (CRM_Utils_Array::value('recipient', $values) == 'group') {
$params['group_id'] = $values['group_id'];
$params['recipient_manual'] = $params['recipient'] = $params['recipient_listing'] = 'null';
} elseif (!CRM_Utils_System::isNull($values['recipient_listing'])) {
$params['recipient'] = CRM_Utils_Array::value('recipient', $values);
$params['recipient_listing'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('recipient_listing', $values));
$params['group_id'] = $params['recipient_manual'] = 'null';
} else {
$params['recipient'] = CRM_Utils_Array::value('recipient', $values);
$params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null';
}
$params['mapping_id'] = $values['entity'][0];
$entity_value = $values['entity'][1];
$entity_status = $values['entity'][2];
foreach (array('entity_value', 'entity_status') as $key) {
$params[$key] = implode(CRM_Core_DAO::VALUE_SEPARATOR, ${$key});
}
$params['is_active'] = CRM_Utils_Array::value('is_active', $values, 0);
$params['is_repeat'] = CRM_Utils_Array::value('is_repeat', $values, 0);
if (CRM_Utils_Array::value('is_repeat', $values) == 0) {
$params['repetition_frequency_unit'] = 'null';
$params['repetition_frequency_interval'] = 'null';
$params['end_frequency_unit'] = 'null';
$params['end_frequency_interval'] = 'null';
$params['end_action'] = 'null';
$params['end_date'] = 'null';
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
} elseif ($this->_action & CRM_Core_Action::ADD) {
// we do this only once, so name never changes
$params['name'] = CRM_Utils_String::munge($params['title'], '_', 64);
}
$composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
$msgTemplate = NULL;
//mail template is composed
$composeParams = array();
foreach ($composeFields as $key) {
if (!empty($values[$key])) {
$composeParams[$key] = $values[$key];
}
}
if (!empty($composeParams['updateTemplate'])) {
$templateParams = array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject'], 'is_active' => TRUE);
$templateParams['id'] = $values['template'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (!empty($composeParams['saveTemplate'])) {
$templateParams = array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject'], 'is_active' => TRUE);
$templateParams['msg_title'] = $composeParams['saveTemplateName'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (isset($msgTemplate->id)) {
$params['msg_template_id'] = $msgTemplate->id;
} else {
$params['msg_template_id'] = CRM_Utils_Array::value('template', $values);
}
$bao = CRM_Core_BAO_ActionSchedule::add($params);
//.........这里部分代码省略.........