本文整理汇总了PHP中CRM_Core_BAO_MessageTemplate类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_MessageTemplate类的具体用法?PHP CRM_Core_BAO_MessageTemplate怎么用?PHP CRM_Core_BAO_MessageTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_MessageTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:40,代码来源:Mailing.php
示例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);
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Case.php
示例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');
}
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:81,代码来源:SMSCommon.php
示例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'));
}
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:33,代码来源:MessageTemplates.php
示例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;
}
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:Membership.php
示例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;
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:ScheduleReminders.php
示例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);
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Pledge.php
示例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 == '[email protected]') {
$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));
}
}
开发者ID:rollox,项目名称:civicrm-core,代码行数:29,代码来源:UFGroup.php
示例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);
}
}
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Invoice.php
示例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 (!$domainEmailAddre
|
请发表评论