本文整理汇总了PHP中CRM_Core_PseudoConstant::getKey方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::getKey方法的具体用法?PHP CRM_Core_PseudoConstant::getKey怎么用?PHP CRM_Core_PseudoConstant::getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::getKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: where
function where()
{
$approved = CRM_Core_PseudoConstant::getKey('CRM_Grant_DAO_Grant', 'status_id', 'Approved', array('labelColumn' => 'name'));
$whereClause = "\nWHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL\n AND {$this->_aliases['civicrm_grant']}.amount_total > 0";
$this->_where = $whereClause . " AND {$this->_aliases['civicrm_grant']}.status_id = {$approved} ";
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$clause = NULL;
if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
$relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
$from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
$to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
if ($relative || $from || $to) {
$clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
}
} else {
$op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
if ($fieldName == 'grant_report_received' && CRM_Utils_Array::value("{$fieldName}_value", $this->_params) === 0) {
$op = 'nll';
$this->_params["{$fieldName}_value"] = NULL;
}
if ($op) {
$clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params));
}
}
if (!empty($clause)) {
$clauses[] = $clause;
$this->_where .= " AND " . implode(' AND ', $clauses);
$this->_whereClause = $whereClause . " AND " . implode(' AND ', $clauses);
}
}
}
}
}
示例2: setUp
/**
* Setup function.
*/
public function setUp()
{
parent::setUp();
$this->_apiversion = 3;
$this->_individualId = $this->individualCreate();
$this->_params = array('contact_id' => $this->_individualId, 'receive_date' => '20120511', 'total_amount' => 100.0, 'financial_type_id' => $this->_financialTypeId, 'non_deductible_amount' => 10.0, 'fee_amount' => 5.0, 'net_amount' => 95.0, 'source' => 'SSF', 'contribution_status_id' => 1);
$this->_processorParams = array('domain_id' => 1, 'name' => 'Dummy', 'payment_processor_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_PaymentProcessor', 'payment_processor_type_id', 'Dummy'), 'financial_account_id' => 12, 'is_active' => 1, 'user_name' => '', 'url_site' => 'http://dummy.com', 'url_recur' => 'http://dummy.com', 'billing_mode' => 1);
$this->paymentProcessorID = $this->processorCreate();
$this->_pageParams = array('title' => 'Test Contribution Page', 'financial_type_id' => 1, 'currency' => 'USD', 'financial_account_id' => 1, 'payment_processor' => $this->paymentProcessorID, 'is_active' => 1, 'is_allow_other_amount' => 1, 'min_amount' => 10, 'max_amount' => 1000);
}
示例3: preProcess
/**
* Set variables up before form is built.
*/
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, FALSE, NULL, NULL, NULL, $params['id']);
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_Core_PseudoConstant::getKey('CRM_Pledge_BAO_Pledge', 'status_id', $values['status_id']);
}
$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);
}
示例4: setUp
public function setUp()
{
parent::setUp();
$this->_individualId = $this->individualCreate();
$this->_orgId = $this->organizationCreate(NULL);
$this->params = array('title' => "Test Contribution Page" . substr(sha1(rand()), 0, 7), 'financial_type_id' => 1, 'payment_processor' => 1, 'currency' => 'NZD', 'goal_amount' => 350, 'is_pay_later' => 1, 'pay_later_text' => 'I will pay later', 'pay_later_receipt' => "I will pay later", 'is_monetary' => TRUE, 'is_billing_required' => TRUE);
$this->_priceSetParams = array('name' => 'tax_contribution' . substr(sha1(rand()), 0, 7), 'title' => 'contributiontax' . substr(sha1(rand()), 0, 7), 'is_active' => 1, 'help_pre' => "Where does your goat sleep", 'help_post' => "thank you for your time", 'extends' => 2, 'financial_type_id' => 3, 'is_quick_config' => 0, 'is_reserved' => 0);
// Financial Account with 20% tax rate
$financialAccountSetparams = array('name' => 'vat full taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 20.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0);
$financialAccount = $this->callAPISuccess('financial_account', 'create', $financialAccountSetparams);
$this->financialAccountId = $financialAccount['id'];
// Financial type having 'Sales Tax Account is' with liability financail account
$financialType = array('name' => 'grassvariety1' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1);
$priceField = $this->callAPISuccess('financial_type', 'create', $financialType);
$this->financialtypeID = $priceField['id'];
$financialRelationParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->financialtypeID, 'account_relationship' => 10, 'financial_account_id' => $this->financialAccountId);
$financialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationParams);
// Financial type with 5% tax rate
$financialAccHalftax = array('name' => 'vat half taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 5.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0);
$halfFinancialAccount = CRM_Financial_BAO_FinancialAccount::add($financialAccHalftax);
$this->halfFinancialAccId = $halfFinancialAccount->id;
$halfFinancialtypeHalftax = array('name' => 'grassvariety2' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1);
$halfFinancialType = CRM_Financial_BAO_FinancialType::add($halfFinancialtypeHalftax);
$this->halfFinancialTypeId = $halfFinancialType->id;
$financialRelationHalftax = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->halfFinancialTypeId, 'account_relationship' => 10, 'financial_account_id' => $this->halfFinancialAccId);
$halfFinancialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationHalftax);
// Enable component contribute setting
$contributeSetting = array('invoicing' => 1, 'invoice_prefix' => 'INV_', 'credit_notes_prefix' => 'CN_', 'due_date' => 10, 'due_date_period' => 'days', 'notes' => '', 'is_email_pdf' => 1, 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive');
$setInvoiceSettings = Civi::settings()->set('contribution_invoice_settings', $contributeSetting);
// Payment Processor
$paymentProceParams = array('domain_id' => 1, 'name' => 'dummy' . substr(sha1(rand()), 0, 7), 'payment_processor_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_PaymentProcessor', 'payment_processor_type_id', 'Dummy'), 'financial_account_id' => 12, 'is_active' => 1, 'is_default' => 1, 'user_name' => 'dummy', 'url_site' => 'http://dummy.com', 'url_recur' => 'http://dummyrecur.com', 'class_name' => 'Payment_Dummy', 'billing_mode' => 1, 'is_recur' => 1, 'payment_type' => 1);
$result = $this->callAPISuccess('payment_processor', 'create', $paymentProceParams);
$this->_ids['paymentProcessID'] = $result['id'];
require_once 'api/v3/examples/PaymentProcessor/Create.php';
$this->assertAPISuccess($result);
}
示例5: postProcess
public function postProcess()
{
$formValues = $this->exportValues();
// reset all selected contact ids from session
// when we came from search context, CRM-3526
$session = CRM_Core_Session::singleton();
if ($session->get('selectedSearchContactIds')) {
$session->resetScope('selectedSearchContactIds');
}
$formValues['main_details'] = $this->_mainDetails;
$formValues['other_details'] = $this->_otherDetails;
CRM_Dedupe_Merger::moveAllBelongings($this->_cid, $this->_oid, $formValues);
$name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_cid, 'display_name');
$message = '<ul><li>' . ts('%1 has been updated.', array(1 => $name)) . '</li><li>' . ts('Contact ID %1 has been deleted.', array(1 => $this->_oid)) . '</li></ul>';
CRM_Core_Session::setStatus($message, ts('Contacts Merged'), 'success');
//create activity for merge
//To do: this should be refactored into BAO layer at some point.
$messageActivity = ts('Contact ID %1 has been merged and deleted.', array(1 => $this->_oid));
$activityParams = array('subject' => $messageActivity, 'source_contact_id' => $session->get('userID'), 'target_contact_id' => $this->_cid, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Contact Merged'), 'status_id' => 'Completed', 'priority_id' => 'Normal', 'activity_date_time' => date('YmdHis'));
civicrm_api3('activity', 'create', $activityParams);
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_cid}");
if (!empty($formValues['_qf_Merge_submit'])) {
$listParamsURL = "reset=1&action=update&rgid={$this->_rgid}";
if ($this->_gid) {
$listParamsURL .= "&gid={$this->_gid}";
}
$lisitingURL = CRM_Utils_System::url('civicrm/contact/dedupefind', $listParamsURL);
CRM_Utils_System::redirect($lisitingURL);
}
if (!empty($formValues['_qf_Merge_done'])) {
CRM_Utils_System::redirect($url);
}
if ($this->next && $this->_mergeId) {
$cacheKey = "merge {$this->_contactType}";
$cacheKey .= $this->_rgid ? "_{$this->_rgid}" : '_0';
$cacheKey .= $this->_gid ? "_{$this->_gid}" : '_0';
$join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND\n pn.entity_id2 = de.contact_id2 )";
$where = "de.id IS NULL";
$pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, NULL, NULL, $this->_mergeId, $join, $where);
if (!empty($pos) && $pos['next']['id1'] && $pos['next']['id2']) {
$urlParam = "reset=1&cid={$pos['next']['id1']}&oid={$pos['next']['id2']}&mergeId={$pos['next']['mergeId']}&action=update";
if ($this->_rgid) {
$urlParam .= "&rgid={$this->_rgid}";
}
if ($this->_gid) {
$urlParam .= "&gid={$this->_gid}";
}
$url = CRM_Utils_System::url('civicrm/contact/merge', $urlParam);
}
}
CRM_Utils_System::redirect($url);
}
示例6: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
// process url params
if ($this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive')) {
$this->assign('contactID', $this->_contactID);
}
if ($this->_caseID = CRM_Utils_Request::retrieve('case_id', 'Positive')) {
$this->assign('case_id', $this->_caseID);
// get Vacancy ID
$vacancyID = CRM_HRRecruitment_BAO_HRVacancy::getVacancyIDByCase($this->_caseID);
//Get application and evaluaiton profile IDs
foreach (array('application_profile', 'evaluation_profile') as $profileName) {
$dao = new CRM_Core_DAO_UFJoin();
$dao->module = 'Vacancy';
$dao->entity_id = $vacancyID;
$dao->module_data = $profileName;
$dao->find(TRUE);
$profile[$profileName] = $dao->uf_group_id;
}
//Check for existing Evaluation activity type and assign variables to tpl
$this->assign('actions', 'add');
$params = array('activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Evaluation'));
$caseActivity = CRM_Case_BAO_Case::getCaseActivity($this->_caseID, $params, $this->_contactID);
foreach ($caseActivity as $caseActivity) {
$evalID = $caseActivity['id'];
$this->assign('id', $evalID);
$this->assign('actions', 'update');
}
$this->_profileID = $profile['application_profile'];
$this->_evalProfileID = $profile['evaluation_profile'];
}
}
示例7: exportComponents
//.........这里部分代码省略.........
}
//also merge Head of Household
$relationKeyMOH = CRM_Utils_Array::key('Household Member of', $contactRelationshipTypes);
$relationKeyHOH = CRM_Utils_Array::key('Head of Household for', $contactRelationshipTypes);
foreach ($returnProperties as $key => $value) {
if (!array_key_exists($key, $contactRelationshipTypes)) {
$returnProperties[$relationKeyMOH][$key] = $value;
$returnProperties[$relationKeyHOH][$key] = $value;
}
}
unset($returnProperties[$relationKeyMOH]['location_type']);
unset($returnProperties[$relationKeyMOH]['im_provider']);
unset($returnProperties[$relationKeyHOH]['location_type']);
unset($returnProperties[$relationKeyHOH]['im_provider']);
}
$allRelContactArray = $relationQuery = array();
foreach ($contactRelationshipTypes as $rel => $dnt) {
if ($relationReturnProperties = CRM_Utils_Array::value($rel, $returnProperties)) {
$allRelContactArray[$rel] = array();
// build Query for each relationship
$relationQuery[$rel] = new CRM_Contact_BAO_Query(NULL, $relationReturnProperties, NULL, FALSE, FALSE, $queryMode);
list($relationSelect, $relationFrom, $relationWhere, $relationHaving) = $relationQuery[$rel]->query();
list($id, $direction) = explode('_', $rel, 2);
// identify the relationship direction
$contactA = 'contact_id_a';
$contactB = 'contact_id_b';
if ($direction == 'b_a') {
$contactA = 'contact_id_b';
$contactB = 'contact_id_a';
}
if ($exportMode == CRM_Export_Form_Select::CONTACT_EXPORT) {
$relIDs = $ids;
} elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
$sourceID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source');
$query = "SELECT contact_id FROM civicrm_activity_contact\n WHERE activity_id IN ( " . implode(',', $ids) . ") AND\n record_type_id = {$sourceID}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$relIDs[] = $dao->contact_id;
}
} else {
$component = self::exportComponent($exportMode);
if ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
$relIDs = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($ids);
} else {
$relIDs = CRM_Core_DAO::getContactIDsFromComponent($ids, $component);
}
}
$relationshipJoin = $relationshipClause = '';
if (!$selectAll && $componentTable) {
$relationshipJoin = " INNER JOIN {$componentTable} ctTable ON ctTable.contact_id = {$contactA}";
} elseif (!empty($relIDs)) {
$relID = implode(',', $relIDs);
$relationshipClause = " AND crel.{$contactA} IN ( {$relID} )";
}
$relationFrom = " {$relationFrom}\n INNER JOIN civicrm_relationship crel ON crel.{$contactB} = contact_a.id AND crel.relationship_type_id = {$id}\n {$relationshipJoin} ";
//check for active relationship status only
$today = date('Ymd');
$relationActive = " AND (crel.is_active = 1 AND ( crel.end_date is NULL OR crel.end_date >= {$today} ) )";
$relationWhere = " WHERE contact_a.is_deleted = 0 {$relationshipClause} {$relationActive}";
$relationGroupBy = " GROUP BY crel.{$contactA}";
$relationSelect = "{$relationSelect}, {$contactA} as refContact ";
$relationQueryString = "{$relationSelect} {$relationFrom} {$relationWhere} {$relationHaving} {$relationGroupBy}";
$allRelContactDAO = CRM_Core_DAO::executeQuery($relationQueryString);
while ($allRelContactDAO->fetch()) {
//FIX Me: Migrate this to table rather than array
// build the array of all related contacts
示例8: getRefundTransactionIDs
/**
* Get the transaction id for the (latest) refund associated with a contribution.
*
* @param int $contributionID
* @return string
*/
public static function getRefundTransactionIDs($contributionID)
{
$refundStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
return self::getFinancialTrxnId($contributionID, 'DESC', FALSE, " AND cft.status_id = {$refundStatusID}");
}
示例9: getResult
/**
* Get the result of the payment.
*
* Usually this will be pending but the calling layer has a chance to set the result.
*
* This would apply in particular when the form accepts status id.
*
* Note that currently this payment class is only being used to manage the 'billing block' aspect
* of pay later. However, a longer term idea is that by treating 'pay-later' as 'just another processor'
* will allow code simplification.
*
* @return int
*/
protected function getResult()
{
if (!$this->result) {
$this->setResult(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending'));
}
return $this->result;
}
示例10: testSubmitRecurCompleteInstant
/**
* Test the submit function of the membership form.
*/
public function testSubmitRecurCompleteInstant()
{
$form = $this->getForm();
$processor = Civi\Payment\System::singleton()->getById($this->_paymentProcessorID);
$processor->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'kettles boil water', 'fee_amount' => 0.29));
$this->callAPISuccess('MembershipType', 'create', array('id' => $this->membershipTypeAnnualFixedID, 'duration_unit' => 'month', 'duration_interval' => 1, 'auto_renew' => TRUE));
$this->createLoggedInUser();
$form->preProcess();
$form->_contactID = $this->_individualId;
$params = $this->getBaseSubmitParams();
$form->_mode = 'test';
$form->testSubmit($params);
$membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
$contributionRecur = $this->callAPISuccessGetSingle('ContributionRecur', array('contact_id' => $this->_individualId));
$this->assertEquals($contributionRecur['id'], $membership['contribution_recur_id']);
$this->assertEquals(0, $contributionRecur['is_email_receipt']);
$this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contributionRecur['modified_date'])));
$this->assertNotEmpty($contributionRecur['invoice_id']);
print_r($contributionRecur);
// @todo fix this part!
/*
$this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id',
'In Progress'), $contributionRecur['contribution_status_id']);
$this->assertNotEmpty($contributionRecur['next_sched_contribution_date']);
*/
$this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Credit Card'), $contributionRecur['payment_instrument_id']);
$contribution = $this->callAPISuccess('Contribution', 'getsingle', array('contact_id' => $this->_individualId, 'is_test' => TRUE));
$this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Credit Card'), $contribution['payment_instrument_id']);
$this->assertEquals('kettles boil water', $contribution['trxn_id']);
$this->assertEquals(0.29, $contribution['fee_amount']);
$this->assertEquals(78, $contribution['total_amount']);
$this->assertEquals(77.70999999999999, $contribution['net_amount']);
$this->callAPISuccessGetCount('LineItem', array('entity_id' => $membership['id'], 'entity_table' => 'civicrm_membership', 'contribution_id' => $contribution['id']), 1);
}
示例11: selectClause
/**
* Adjust query for the activity_contact table.
*
* As this is just a join table the ID we REALLY care about is the activity id.
*
* @param string $tableName
* @param string $tableKey
* @param string $fieldName
* @param string $field
*
* @return string
*/
public function selectClause(&$tableName, $tableKey, &$fieldName, &$field)
{
if ($this->currentLogTable == 'log_civicrm_activity_contact' && $fieldName == 'id') {
$alias = "{$tableName}_{$fieldName}";
$select[] = "{$tableName}.activity_id as {$alias}";
$this->_selectAliases[] = $alias;
return "activity_id";
}
if ($fieldName == 'log_grouping') {
if ($this->currentLogTable != 'log_civicrm_activity_contact') {
return 1;
}
$mergeActivityID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Contact Merged');
return " IF (entity_log_civireport.log_action = 'Insert' AND extra_table.activity_type_id = {$mergeActivityID} , GROUP_CONCAT(entity_log_civireport.contact_id), 1) ";
}
}
示例12: getActivityTypeId
/**
* Fetch activity type id of custom Activity
* @return integer
*/
public static function getActivityTypeId()
{
return CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', static::CUSTOM_ACTIVITY_TYPE);
}
示例13: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param bool $isTest
* @param bool $isRecur
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, $contactID, $contributionTypeId, $component = 'contribution', $isTest, $isRecur)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
$contributionParams = array('id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, $form->_bltID, $isRecur);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
if (!empty($form->_paymentProcessor)) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
$form->_params = array_merge($form->_params, $result);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
if (!empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$result['contribution'] = $contribution;
if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending') && $payment->isSendReceiptForPending()) {
//.........这里部分代码省略.........
示例14: buildQuickForm
/**
* Function to build the form
*
* @return void
* @access public
*/
function buildQuickForm()
{
$attributes = CRM_Core_DAO::getAttribute('CRM_HRRecruitment_DAO_HRVacancy');
$this->add('text', 'position', ts('Job Position'), $attributes['position'], TRUE);
$this->addSelect('location', array('label' => ts('Location'), 'entity' => 'HRJobDetails', 'field' => 'location'));
$this->add('text', 'salary', ts('Salary'), $attributes['salary']);
$this->addWysiwyg('description', ts('Description'), array('rows' => 2, 'cols' => 40));
$this->addWysiwyg('benefits', ts('Benefits'), array('rows' => 2, 'cols' => 40));
$this->addWysiwyg('requirements', ts('Requirements'), array('rows' => 2, 'cols' => 40));
$this->addDateTime('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDateTime'));
$include =& $this->addElement('advmultiselect', 'stages', '', CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND grouping = 'Vacancy'"), array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
$include->setButtonAttributes('add', array('value' => ts('Enable >>')));
$include->setButtonAttributes('remove', array('value' => ts('<< Disable')));
$templates = $vacancyPermissions = array();
if (!$this->_isTemplate) {
$this->addSelect('status_id', array(), TRUE);
$result = civicrm_api3('HRVacancy', 'get', array('is_template' => 1, 'return' => 'position'));
foreach ($result['values'] as $id => $vacancy) {
$templates[$id] = $vacancy['position'];
}
//hide 'From Template' on edit screen
if (empty($this->_id)) {
$this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $templates, FALSE, array('class' => 'crm-select2 huge'));
}
}
$caseTypes = CRM_Case_PseudoConstant::caseType('name');
$application = array_search('Application', $caseTypes);
$evalID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Evaluation');
$evalEntity[] = array('entity_name' => 'activity_1', 'entity_type' => 'ActivityModel', 'entity_sub_type' => "{$evalID}");
$appEntities = array();
$appEntities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
$appEntities[] = array('entity_name' => 'case_1', 'entity_type' => 'CaseModel', 'entity_sub_type' => "{$application}");
$this->addProfileSelector('application_profile', '', array('Individual', 'Contact', 'Case'), array('CaseType' => array($application)), $appEntities);
$this->addProfileSelector('evaluation_profile', '', array('Activity'), array('ActivityType' => array($evalID)), $evalEntity);
$permissionClass = new CRM_Core_Permission_Base();
$permissions = $permissionClass->getAllModulePermissions();
foreach (array('view Applicants', 'manage Applicants', 'evaluate Applicants', 'administer Vacancy') as $permission) {
$explodedPerms = explode(':', $permissions[$permission]);
$vacancyPermissions[$permission] = array_pop($explodedPerms);
}
$rowCount = 5;
for ($rowNumber = 1; $rowNumber <= $rowCount; $rowNumber++) {
$this->add('select', "permission[{$rowNumber}]", '', array('' => ts('- select -')) + $vacancyPermissions, FALSE, array('class' => 'crm-select2 huge'));
$this->addEntityRef("permission_contact_id[{$rowNumber}]", NULL, array('api' => array('params' => array('contact_type' => 'Individual'))));
}
$this->assign('rowCount', $rowCount);
$this->assign('showPermissionRow', 1);
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$session = CRM_Core_Session::singleton();
if ($this->_isTemplate) {
$this->_cancelURL = CRM_Utils_System::url('civicrm/vacancy/find', 'reset=1&template=1');
} else {
$this->_cancelURL = CRM_Utils_System::url('civicrm/vacancy/find', 'reset=1');
}
$this->addFormRule(array('CRM_HRRecruitment_Form_HRVacancy', 'formRule'));
$session->replaceUserContext($this->_cancelURL);
}
示例15: getTotalPayments
/**
* @param int $contributionId
*
* @return array
*/
public static function getTotalPayments($contributionId)
{
$statusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
$sql = "SELECT SUM(ft.total_amount) FROM civicrm_financial_trxn ft\n INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution')\n WHERE eft.entity_id = %1 AND ft.is_payment = 1 AND ft.status_id = %2";
$params = array(1 => array($contributionId, 'Integer'), 2 => array($statusId, 'Integer'));
return CRM_Core_DAO::singleValueQuery($sql, $params);
}