本文整理汇总了PHP中CRM_Utils_Recent类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Recent类的具体用法?PHP CRM_Utils_Recent怎么用?PHP CRM_Utils_Recent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Recent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddCaseToContact
public function testAddCaseToContact()
{
$params = array('case_id' => 1, 'contact_id' => 17);
CRM_Case_BAO_CaseContact::create($params);
$recent = CRM_Utils_Recent::get();
$this->assertEquals('Test Contact - Housing Support', $recent[0]['title']);
}
示例2: view
/**
* View details of a relationship
*
* @return void
*
* @access public
*/
function view()
{
require_once 'CRM/Core/DAO.php';
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, null, null, null, $this->_id);
//To check whether selected contact is a contact_id_a in
//relationship type 'a_b' in relationship table, if yes then
//revert the permissionship text in template
$relationship =& new CRM_Contact_DAO_Relationship();
$relationship->id = $viewRelationship[$this->_id]['id'];
if ($relationship->find(true)) {
if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
$this->assign("is_contact_id_a", true);
}
}
$relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
$this->assign('viewRelationship', $viewRelationship);
$viewNote = CRM_Core_BAO_Note::getNote($this->_id);
$this->assign('viewNote', $viewNote);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
// add viewed contribution to recent items list
require_once 'CRM/Utils/Recent.php';
$url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($this->_contactId) . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
// add the recently viewed Relationship
CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, null);
}
示例3: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_contactID = $this->get('cid');
$this->_caseID = $this->get('id');
$this->assign('caseID', $this->_caseID);
$this->assign('contactID', $this->_contactID);
//retrieve details about case
$params = array('id' => $this->_caseID);
$returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date');
CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties);
$values['case_type_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('case_type_id', $values));
$statuses = CRM_Case_PseudoConstant::caseStatus();
$caseTypeName = CRM_Case_PseudoConstant::caseTypeName($this->_caseID);
$caseType = CRM_Core_OptionGroup::getLabel('case_type', $caseTypeName['id']);
$this->_caseDetails = array('case_type' => $caseType, 'case_status' => $statuses[$values['case_status_id']], 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']);
$this->_caseType = $caseTypeName['name'];
$this->assign('caseDetails', $this->_caseDetails);
$newActivityUrl = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype=", false, null, false);
$this->assign('newActivityUrl', $newActivityUrl);
$reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", false, null, false);
$this->assign('reportUrl', $reportUrl);
// add to recently viewed
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home");
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
$this->assign('displayName', $displayName);
$title = $displayName . ' - ' . $caseType;
// add the recently created case
CRM_Utils_Recent::add($title, $url, $this->_caseID, 'Case', $this->_contactID, null);
}
示例4: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$values = $ids = array();
$params = array('id' => $this->get('id'));
CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
$values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
$values['honor_type'] = $honor[$values['honor_type_id']];
}
//handle custom data.
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
if (!empty($values['contribution_page_id'])) {
$values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
}
$values['financial_type'] = CRM_Utils_Array::value($values['financial_type_id'], CRM_Contribute_PseudoConstant::financialType());
if ($values['status_id']) {
$values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
}
$url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
$displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
$this->assign('displayName', $displayName);
$title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['financial_type'] . ')';
// add Pledge to Recent Items
CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], NULL, $recentOther);
// Check if this is default domain contact CRM-10482
if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
$displayName .= ' (' . ts('default organization') . ')';
}
// omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
$this->assign($values);
}
示例5: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
$values = array();
$params['id'] = $this->_id;
CRM_Grant_BAO_Grant::retrieve($params, $values);
$grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($grantTokens as $token) {
$this->assign($token, CRM_Utils_Array::value($token, $values));
}
if (isset($this->_id)) {
$noteDAO = new CRM_Core_BAO_Note();
$noteDAO->entity_table = 'civicrm_grant';
$noteDAO->entity_id = $this->_id;
if ($noteDAO->find(TRUE)) {
$this->_noteId = $noteDAO->id;
}
}
if (isset($this->_noteId)) {
$this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
}
// add Grant to Recent Items
$url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], NULL, $recentOther);
$attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
$this->assign('attachment', $attachment);
$grantType = CRM_Core_DAO::getFieldValue("CRM_Grant_DAO_Grant", $this->_id, "grant_type_id");
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0, $grantType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
$this->assign('id', $this->_id);
$this->setPageTitle(ts('Grant'));
}
示例6: create
/**
* Create case contact record.
*
* @param array $params
* case_id, contact_id
*
* @return CRM_Case_BAO_CaseContact
*/
public static function create($params)
{
$caseContact = new self();
$caseContact->copyValues($params);
$caseContact->save();
// add to recently viewed
$caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id);
$url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType;
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home");
}
// add the recently created case
CRM_Utils_Recent::add($title, $url, $caseContact->case_id, 'Case', $caseContact->contact_id, NULL, $recentOther);
return $caseContact;
}
示例7: CRM_Core_Smarty
/**
* class constructor
*
* @return CRM_Core_Smarty
* @access private
*/
function CRM_Core_Smarty()
{
parent::Smarty();
$config =& CRM_Core_Config::singleton();
$this->template_dir = $config->templateDir;
$this->compile_dir = $config->templateCompileDir;
$this->use_sub_dirs = true;
$this->plugins_dir = array($config->smartyDir . 'plugins', $config->pluginsDir);
// add the session and the config here
$config =& CRM_Core_Config::singleton();
$session =& CRM_Core_Session::singleton();
$recent =& CRM_Utils_Recent::get();
$this->assign_by_ref('config', $config);
$this->assign_by_ref('session', $session);
$this->assign_by_ref('recentlyViewed', $recent);
$this->assign('displayRecent', true);
$this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
}
示例8: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$values = array();
$params['id'] = $this->_id;
require_once 'CRM/Grant/BAO/Grant.php';
CRM_Grant_BAO_Grant::retrieve($params, $values);
require_once 'CRM/Grant/PseudoConstant.php';
$grantType = CRM_Grant_PseudoConstant::grantType();
$grantStatus = CRM_Grant_PseudoConstant::grantStatus();
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($grantTokens as $token) {
$this->assign($token, CRM_Utils_Array::value($token, $values));
}
if (isset($this->_id)) {
require_once 'CRM/Core/BAO/Note.php';
$noteDAO =& new CRM_Core_BAO_Note();
$noteDAO->entity_table = 'civicrm_grant';
$noteDAO->entity_id = $this->_id;
if ($noteDAO->find(true)) {
$this->_noteId = $noteDAO->id;
}
}
if (isset($this->_noteId)) {
$this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
}
// add Grant to Recent Items
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Utils/Money.php';
$url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null);
require_once 'CRM/Core/BAO/File.php';
$attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
$this->assign('attachment', $attachment);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('id', $this->_id);
}
示例9: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Member/BAO/Membership.php';
require_once 'CRM/Member/BAO/MembershipType.php';
require_once 'CRM/Core/BAO/CustomGroup.php';
$values = array();
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
// Make sure context is assigned to template for condition where we come here view civicrm/membership/view
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
if ($id) {
$params = array('id' => $id);
CRM_Member_BAO_Membership::retrieve($params, $values);
// build associated contributions
require_once 'CRM/Member/Page/Tab.php';
CRM_Member_Page_Tab::associatedContribution($values['contact_id'], $id);
//Provide information about membership source when it is the result of a relationship (CRM-1901)
$values['owner_membership_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $id, 'owner_membership_id');
if (isset($values['owner_membership_id'])) {
$values['owner_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $values['owner_membership_id'], 'contact_id', 'id');
$values['owner_display_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['owner_contact_id'], 'display_name', 'id');
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
$direction = strrev($membershipType['relationship_direction']);
$values['relationship'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $membershipType['relationship_type_id'], "name_{$direction}", 'id');
}
$displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
$this->assign('displayName', $displayName);
// add viewed membership to recent items list
require_once 'CRM/Utils/Recent.php';
$url = CRM_Utils_System::url('civicrm/contact/view/membership', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}");
$title = $displayName . ' - ' . ts('Membership Type:') . ' ' . $values['membership_type'];
CRM_Utils_Recent::add($title, $url, $values['id'], 'Membership', $values['contact_id'], null);
CRM_Member_Page_Tab::setContext($values['contact_id']);
$memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $id, "membership_type_id");
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $id, 0, $memType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
}
if ($values['is_test']) {
$values['membership_type'] .= ' (test) ';
}
$this->assign($values);
}
示例10: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Pledge/BAO/Pledge.php';
$values = $ids = array();
$params = array('id' => $this->get('id'));
CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
$values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
$values['eachPaymentAmount'] = floor($values['amount'] / $values['installments']);
if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
$dao =& new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::honor();
$values['honor_type'] = $honor[$values['honor_type_id']];
}
//handle custom data.
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
if (CRM_Utils_Array::value('contribution_page_id', $values)) {
$values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
}
$values['contribution_type'] = CRM_Utils_Array::value($values['contribution_type_id'], CRM_Contribute_PseudoConstant::contributionType());
if ($values['status_id']) {
$values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
}
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
require_once 'CRM/Utils/Money.php';
$displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
$this->assign('displayName', $displayName);
$title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['contribution_type'] . ')';
// add Pledge to Recent Items
CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], null);
$this->assign($values);
}
示例11: preProcess
function preProcess()
{
$params = array();
$defaults = array();
$ids = array();
$session =& CRM_Core_Session::singleton();
$uid = $session->get('userID');
if (!$uid) {
require_once 'CRM/Utils/System.php';
CRM_Utils_System::setUFMessage(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
CRM_Core_Error::statusBounce(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
}
$this->assign('contactId', $uid);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'view');
$this->assign('action', $this->_action);
// a user can always view their own activity history
// if they have access CiviCRM permission
$this->_permission = CRM_Core_Permission::VIEW;
// make the permission edit if the user has edit permission on the contact
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if (CRM_Contact_BAO_Contact_Permission::allow($uid, CRM_Core_Permission::EDIT)) {
$this->_permission = CRM_Core_Permission::EDIT;
}
$displayName = $this->get('displayName');
list($displayName, $contactImage, $contactType) = CRM_Contact_BAO_Contact::getDisplayAndImage($uid, true);
$this->set('displayName', $displayName);
$this->set('contactImage', $contactImage);
CRM_Utils_System::setTitle($contactImage . ' ' . $displayName, $displayName);
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $uid), $uid, $contactType, $uid, $displayName);
// call hook to get html from other modules
require_once 'CRM/Utils/Hook.php';
$contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
// ignored but needed to prevent warnings
$html = CRM_Utils_Hook::dashboard($uid, $contentPlacement);
if (is_array($html)) {
$this->assign_by_ref('hookContent', $html);
$this->assign('hookContentPlacement', $contentPlacement);
}
}
示例12: preProcess
//.........这里部分代码省略.........
$values['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id');
if ($values['to_financial_account_id']) {
$values['to_financial_account'] = CRM_Contribute_PseudoConstant::financialAccount($values['to_financial_account_id']);
}
$values['payment_processor_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'payment_processor_id');
if ($values['payment_processor_id']) {
$values['payment_processor_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
}
}
if (!empty($values['contribution_recur_id'])) {
$sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
$params = array(1 => array($values['contribution_recur_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$values['recur_installments'] = $dao->installments;
$values['recur_frequency_unit'] = $dao->frequency_unit;
$values['recur_frequency_interval'] = $dao->frequency_interval;
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, CRM_Utils_Array::value('financial_type_id', $values));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = NULL;
if ($id) {
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->find(TRUE);
$this->assign('premium', $productDAO->name);
$this->assign('option', $dao->product_option);
$this->assign('fulfilled', $dao->fulfilled_date);
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote(CRM_Utils_Array::value('id', $values), 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (!empty($values['address_id'])) {
$addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['billing_address'] = $addressDetails[0]['display'];
}
//assign soft credit record if exists.
$SCRecords = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id'], TRUE);
if (!empty($SCRecords['soft_credit'])) {
$this->assign('softContributions', $SCRecords['soft_credit']);
unset($SCRecords['soft_credit']);
}
//assign pcp record if exists
foreach ($SCRecords as $name => $value) {
$this->assign($name, $value);
}
$lineItems = array();
if ($id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
if (!empty($lineItem)) {
$lineItems[] = $lineItem;
}
}
$this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
$values['totalAmount'] = $values['total_amount'];
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
// assign values to the template
$this->assign($values);
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$this->assign('invoicing', $invoicing);
if ($invoicing && isset($values['tax_amount'])) {
$this->assign('totalTaxAmount', $values['tax_amount']);
}
$displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
$this->assign('displayName', $displayName);
// Check if this is default domain contact CRM-10482
if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
$displayName .= ' (' . ts('default organization') . ')';
}
// omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
CRM_Utils_System::setTitle(ts('View Contribution from') . ' ' . $displayName);
// add viewed contribution to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$title = $displayName . ' - (' . CRM_Utils_Money::format($values['total_amount']) . ' ' . ' - ' . $values['financial_type'] . ')';
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
CRM_Utils_Recent::add($title, $url, $values['id'], 'Contribution', $values['contact_id'], NULL, $recentOther);
}
示例13: create
//.........这里部分代码省略.........
if (!empty($params['id'])) {
$logMsg = "Activity (id: {$result->id} ) updated with ";
} else {
$logMsg = "Activity created for ";
}
$msgs = array();
if (isset($params['source_contact_id'])) {
$msgs[] = "source={$params['source_contact_id']}";
}
if (!empty($params['target_contact_id'])) {
if (is_array($params['target_contact_id']) && !CRM_Utils_array::crmIsEmptyArray($params['target_contact_id'])) {
$msgs[] = "target=" . implode(',', $params['target_contact_id']);
// take only first target
// will be used for recently viewed display
$t = array_slice($params['target_contact_id'], 0, 1);
$recentContactId = $t[0];
} elseif (isset($params['target_contact_id']) && !is_array($params['target_contact_id'])) {
$msgs[] = "target={$params['target_contact_id']}";
// will be used for recently viewed display
$recentContactId = $params['target_contact_id'];
}
} else {
// at worst, take source for recently viewed display
$recentContactId = CRM_Utils_Array::value('source_contact_id', $params);
}
if (isset($params['assignee_contact_id'])) {
if (is_array($params['assignee_contact_id'])) {
$msgs[] = "assignee=" . implode(',', $params['assignee_contact_id']);
} else {
$msgs[] = "assignee={$params['assignee_contact_id']}";
}
}
$logMsg .= implode(', ', $msgs);
self::logActivityAction($result, $logMsg);
if (!empty($params['custom']) && is_array($params['custom'])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);
}
$transaction->commit();
if (empty($params['skipRecentView'])) {
$recentOther = array();
if (!empty($params['case_id'])) {
$caseContactID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $params['case_id'], 'contact_id', 'case_id');
$url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activity->id}&cid={$caseContactID}&caseID={$params['case_id']}&context=home");
} else {
$q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home";
if ($activity->activity_type_id != CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name')) {
$url = CRM_Utils_System::url('civicrm/activity', $q);
if ($activity->activity_type_id == CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/activity/pdf/add', "action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$params['source_contact_id']}&context=home");
} else {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/activity/add', "action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home");
}
if (CRM_Core_Permission::check("delete activities")) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity', "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home");
}
} else {
$url = CRM_Utils_System::url('civicrm/activity/view', $q);
if (CRM_Core_Permission::check('delete activities')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity', "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home");
}
}
}
if (!isset($activity->parent_id)) {
$recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
// add the recently created Activity
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
$activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activity->id, 'subject');
$title = "";
if (isset($activitySubject)) {
$title = $activitySubject . ' - ';
}
$title = $title . $recentContactDisplay;
if (!empty($activityTypes[$activity->activity_type_id])) {
$title .= ' (' . $activityTypes[$activity->activity_type_id] . ')';
}
CRM_Utils_Recent::add($title, $url, $activity->id, 'Activity', $recentContactId, $recentContactDisplay, $recentOther);
}
}
// reset the group contact cache since smart groups might be affected due to this
CRM_Contact_BAO_GroupContactCache::remove();
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
} else {
CRM_Utils_Hook::post('create', 'Activity', $activity->id, $activity);
}
// if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916)
$matches = array();
if (preg_match('/\\[case #([0-9a-h]{7})\\]/', CRM_Utils_Array::value('subject', $params), $matches)) {
$key = CRM_Core_DAO::escapeString(CIVICRM_SITE_KEY);
$hash = $matches[1];
$query = "SELECT id FROM civicrm_case WHERE SUBSTR(SHA1(CONCAT('{$key}', id)), 1, 7) = '{$hash}'";
$caseParams = array('activity_id' => $activity->id, 'case_id' => CRM_Core_DAO::singleValueQuery($query));
if ($caseParams['case_id']) {
CRM_Case_BAO_Case::processCaseActivity($caseParams);
} else {
self::logActivityAction($activity, "unknown case hash encountered: {$hash}");
}
}
return $result;
}
示例14: deletePledge
/**
* Function to delete the pledge
*
* @param int $id pledge id
*
* @access public
* @static
*
*/
static function deletePledge($id)
{
CRM_Utils_Hook::pre('delete', 'Pledge', $id, CRM_Core_DAO::$_nullArray);
$transaction = new CRM_Core_Transaction();
//check for no Completed Payment records with the pledge
$payment = new CRM_Pledge_DAO_PledgePayment();
$payment->pledge_id = $id;
$payment->find();
while ($payment->fetch()) {
//also delete associated contribution.
if ($payment->contribution_id) {
CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id);
}
$payment->delete();
}
$dao = new CRM_Pledge_DAO_Pledge();
$dao->id = $id;
$results = $dao->delete();
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Pledge', $dao->id, $dao);
// delete the recently created Pledge
$pledgeRecent = array('id' => $id, 'type' => 'Pledge');
CRM_Utils_Recent::del($pledgeRecent);
return $results;
}
示例15: deleteContribution
/**
* Delete the indirect records associated with this contribution first.
*
* @param int $id
*
* @return mixed|null
* $results no of deleted Contribution on success, false otherwise
*/
public static function deleteContribution($id)
{
CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
$transaction = new CRM_Core_Transaction();
$results = NULL;
//delete activity record
$params = array('source_record_id' => $id, 'activity_type_id' => 6);
CRM_Activity_BAO_Activity::deleteActivity($params);
//delete billing address if exists for this contribution.
self::deleteAddress($id);
//update pledge and pledge payment, CRM-3961
CRM_Pledge_BAO_PledgePayment::resetPledgePayment($id);
// remove entry from civicrm_price_set_entity, CRM-5095
if (CRM_Price_BAO_PriceSet::getFor('civicrm_contribution', $id)) {
CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution', $id);
}
// cleanup line items.
$participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id');
// delete any related entity_financial_trxn, financial_trxn and financial_item records.
CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id);
if ($participantId) {
CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant');
} else {
CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_contribution');
}
//delete note.
$note = CRM_Core_BAO_Note::getNote($id, 'civicrm_contribution');
$noteId = key($note);
if ($noteId) {
CRM_Core_BAO_Note::del($noteId, FALSE);
}
$dao = new CRM_Contribute_DAO_Contribution();
$dao->id = $id;
$results = $dao->delete();
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
// delete the recently created Contribution
$contributionRecent = array('id' => $id, 'type' => 'Contribution');
CRM_Utils_Recent::del($contributionRecent);
return $results;
}