本文整理汇总了PHP中CRM_Contribute_PseudoConstant::paymentInstrument方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_PseudoConstant::paymentInstrument方法的具体用法?PHP CRM_Contribute_PseudoConstant::paymentInstrument怎么用?PHP CRM_Contribute_PseudoConstant::paymentInstrument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Contribute_PseudoConstant::paymentInstrument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
function buildQuickForm()
{
$this->addElement('hidden', 'batch_status', true);
$this->addElement('hidden', 'id', $_GET['id']);
$this->add('text', 'batch_title', ts('Batch Title'), array('size' => 35, 'maxlength' => 64, 'style' => 'text-align:right'), true);
$this->add('textarea', 'description', ts('Description'), null, false);
$emptySelect1[''] = '- select -';
$bankAccounts = $bankAccounts = CRM_Finance_BAO_BankAccount::getBankAccountsList($emptySelect1);
$this->add('select', 'banking_account', ts('Bank Account'), $bankAccounts, true);
$this->addDate('banking_date', ts('Banking Date'), true, array('formatType' => 'activityDate'));
$this->addElement('checkbox', 'exclude_from_posting', ts('Exclude from posting'), null, null);
$this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), true);
$this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), true);
$this->addFormRule(array($this, 'formRule'));
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->assign('formObject', $this);
}
示例2: buildQuickForm
public function buildQuickForm()
{
$attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch');
$attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
$this->add('text', 'title', ts('Batch Name'), $attributes['title']);
$batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
$this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- any -'), array_search('Open', $batchStatus) => ts('Open'), array_search('Closed', $batchStatus) => ts('Closed'), array_search('Exported', $batchStatus) => ts('Exported')), false);
$this->add('select', 'payment_instrument_id', ts('Payment Instrument'), array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), false);
$this->add('text', 'total', ts('Total Amount'), $attributes['total']);
$this->add('text', 'item_count', ts('Number of Items'), $attributes['item_count']);
$this->add('text', 'sort_name', ts('Created By'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$this->assign('elements', array('status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total'));
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
$batchAction = array('reopen' => ts('Re-open'), 'close' => ts('Close'), 'export' => ts('Export'), 'delete' => ts('Delete'));
$this->add('select', 'batch_update', ts('Task'), array('' => ts('- actions -')) + $batchAction);
$this->add('submit', 'submit', ts('Go'), array('class' => 'form-submit', 'id' => 'Go'));
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
parent::buildQuickForm();
}
示例3: buildQuickForm
public function buildQuickForm()
{
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.redirect.min.js', 0, 'html-header');
$attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch');
$attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
$this->add('text', 'title', ts('Batch Name'), $attributes['title']);
$this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- any -'), 1 => ts('Open'), 2 => ts('Closed'), 5 => ts('Exported')), false);
$this->add('select', 'payment_instrument_id', ts('Payment Instrument'), array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), false);
$this->add('text', 'total', ts('Total Amount'), $attributes['total']);
$this->add('text', 'item_count', ts('Number of Items'), $attributes['item_count']);
$this->add('text', 'sort_name', ts('Created By'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$this->assign('elements', array('status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total'));
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
$batchAction = array('reopen' => ts('Re-open'), 'close' => ts('Close'), 'export' => ts('Export'), 'delete' => ts('Delete'));
$this->add('select', 'batch_update', ts('Task'), array('' => ts('- actions -')) + $batchAction);
$this->add('submit', 'submit', ts('Go'), array('class' => 'form-submit', 'id' => 'Go'));
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
parent::buildQuickForm();
}
示例4: alterDisplay
/**
* Alter display of rows.
*
* Iterate through the rows retrieved via SQL and make changes for display purposes,
* such as rendering contacts as links.
*
* @param array $rows
* Rows generated by SQL, with an array for each row.
*/
public function alterDisplay(&$rows)
{
$entryFound = FALSE;
$eventType = CRM_Core_OptionGroup::values('event_type');
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
$eventId = $row['civicrm_participant_event_id'];
if ($eventId) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($eventId, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $eventId, $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = TRUE;
}
// handle event type id
$this->_initBasicRow($rows, $entryFound, $row, 'civicrm_event_event_type_id', $rowNum, $eventType);
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
$statusId = $row['civicrm_participant_status_id'];
if ($statusId) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($statusId, FALSE, 'label');
}
$entryFound = TRUE;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
$roleId = $row['civicrm_participant_role_id'];
if ($roleId) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $roleId);
$roleId = array();
foreach ($roles as $role) {
$roleId[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
$rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $roleId);
}
$entryFound = TRUE;
}
// Handel value seperator in Fee Level
if (array_key_exists('civicrm_participant_participant_fee_level', $row)) {
$feeLevel = $row['civicrm_participant_participant_fee_level'];
if ($feeLevel) {
CRM_Event_BAO_Participant::fixEventLevel($feeLevel);
$rows[$rowNum]['civicrm_participant_participant_fee_level'] = $feeLevel;
}
$entryFound = TRUE;
}
// Convert display name to link
$displayName = CRM_Utils_Array::value('civicrm_contact_sort_name_linked', $row);
$cid = CRM_Utils_Array::value('civicrm_contact_id', $row);
$id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row);
if ($displayName && $cid && $id) {
$url = CRM_Report_Utils_Report::getNextUrl('contact/detail', "reset=1&force=1&id_op=eq&id_value={$cid}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
$viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant", "reset=1&id={$id}&cid={$cid}&action=view&context=participant");
$contactTitle = ts('View Contact Details');
$participantTitle = ts('View Participant Record');
$rows[$rowNum]['civicrm_contact_sort_name_linked'] = "<a title='{$contactTitle}' href={$url}>{$displayName}</a>";
if ($this->_outputMode !== 'csv') {
$rows[$rowNum]['civicrm_contact_sort_name_linked'] .= "<span style='float: right;'><a title='{$participantTitle}' href={$viewUrl}>" . ts('View') . "</a></span>";
}
$entryFound = TRUE;
}
// Handle country id
if (array_key_exists('civicrm_address_country_id', $row)) {
$countryId = $row['civicrm_address_country_id'];
if ($countryId) {
$rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($countryId, TRUE);
}
$entryFound = TRUE;
}
// Handle state/province id
if (array_key_exists('civicrm_address_state_province_id', $row)) {
$provinceId = $row['civicrm_address_state_province_id'];
if ($provinceId) {
$rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($provinceId, TRUE);
}
$entryFound = TRUE;
}
// Handle employer id
if (array_key_exists('civicrm_contact_employer_id', $row)) {
$employerId = $row['civicrm_contact_employer_id'];
if ($employerId) {
$rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($employerId);
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $employerId, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_employer_id_link'] = $url;
$rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.');
//.........这里部分代码省略.........
示例5: resolveDefaults
/**
* Get the values for pseudoconstants for name->value and reverse.
*
* @param array $defaults (reference) the default values, some of which need to be resolved.
* @param boolean $reverse true if we want to resolve the values in the reverse direction (value -> name)
*
* @return void
* @access public
* @static
*/
static function resolveDefaults(&$defaults, $reverse = false)
{
require_once 'CRM/Contribute/PseudoConstant.php';
self::lookupValue($defaults, 'contribution_type', CRM_Contribute_PseudoConstant::contributionType(), $reverse);
self::lookupValue($defaults, 'payment_instrument', CRM_Contribute_PseudoConstant::paymentInstrument(), $reverse);
self::lookupValue($defaults, 'contribution_status', CRM_Contribute_PseudoConstant::contributionStatus(), $reverse);
self::lookupValue($defaults, 'pcp', CRM_Contribute_PseudoConstant::pcPage(), $reverse);
}
示例6: getContributionTokenDetails
/**
* Gives required details of contribuion in an indexed array format so we
* can iterate in a nice loop and do token evaluation
*
* @param array $contributionIDs
* @param array $returnProperties
* Of required properties.
* @param array $extraParams
* Extra params.
* @param array $tokens
* The list of tokens we've extracted from the content.
* @param string $className
*
* @return array
*/
public static function getContributionTokenDetails($contributionIDs, $returnProperties = NULL, $extraParams = NULL, $tokens = array(), $className = NULL)
{
// @todo this function basically replicates calling
// civicrm_api3('contribution', 'get', array('id' => array('IN' => array())
if (empty($contributionIDs)) {
// putting a fatal here so we can track if/when this happens
CRM_Core_Error::fatal();
}
$details = array();
// no apiQuery helper yet, so do a loop and find contribution by id
foreach ($contributionIDs as $contributionID) {
$dao = new CRM_Contribute_DAO_Contribution();
$dao->id = $contributionID;
if ($dao->find(TRUE)) {
$details[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $details[$dao->id]);
// do the necessary transformation
if (!empty($details[$dao->id]['payment_instrument_id'])) {
$piId = $details[$dao->id]['payment_instrument_id'];
$pis = CRM_Contribute_PseudoConstant::paymentInstrument();
$details[$dao->id]['payment_instrument'] = $pis[$piId];
}
if (!empty($details[$dao->id]['campaign_id'])) {
$campaignId = $details[$dao->id]['campaign_id'];
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$details[$dao->id]['campaign'] = $campaigns[$campaignId];
}
if (!empty($details[$dao->id]['financial_type_id'])) {
$financialtypeId = $details[$dao->id]['financial_type_id'];
$ftis = CRM_Contribute_PseudoConstant::financialType();
$details[$dao->id]['financial_type'] = $ftis[$financialtypeId];
}
// @todo call a hook to get token contribution details
}
}
return $details;
}
示例7: postProcess
//.........这里部分代码省略.........
//use of the message template below requires variables in different format
$event = $events = array();
$returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
//get all event details.
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties);
$event = $events[$params['event_id']];
unset($event['start_date']);
unset($event['end_date']);
$role = CRM_Event_PseudoConstant::participantRole();
$participantRoles = CRM_Utils_Array::value('role_id', $params);
if (is_array($participantRoles)) {
$selectedRoles = array();
foreach ($participantRoles as $roleId) {
$selectedRoles[] = $role[$roleId];
}
$event['participant_role'] = implode(', ', $selectedRoles);
} else {
$event['participant_role'] = CRM_Utils_Array::value($participantRoles, $role);
}
$event['is_monetary'] = $this->_isPaidEvent;
if ($params['receipt_text']) {
$event['confirm_email_text'] = $params['receipt_text'];
}
$this->assign('isAmountzero', 1);
$this->assign('event', $event);
$this->assign('isShowLocation', $event['is_show_location']);
if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
$locationParams = array('entity_id' => $params['event_id'], 'entity_table' => 'civicrm_event');
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
$this->assign('location', $location);
}
$status = CRM_Event_PseudoConstant::participantStatus();
if ($this->_isPaidEvent) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
if (!$this->_mode) {
if (isset($params['payment_instrument_id'])) {
$this->assign('paidBy', CRM_Utils_Array::value($params['payment_instrument_id'], $paymentInstrument));
}
}
$this->assign('totalAmount', $contributionParams['total_amount']);
if (isset($contributionParams['partial_payment_total'])) {
// balance amount
$balanceAmount = $contributionParams['partial_payment_total'] - $contributionParams['partial_amount_pay'];
$this->assign('balanceAmount', $balanceAmount);
}
$this->assign('isPrimary', 1);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}
if ($this->_mode) {
if (!empty($params['billing_first_name'])) {
$name = $params['billing_first_name'];
}
if (!empty($params['billing_middle_name'])) {
$name .= " {$params['billing_middle_name']}";
}
if (!empty($params['billing_last_name'])) {
$name .= " {$params['billing_last_name']}";
}
$this->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
示例8: buildQuickForm
//.........这里部分代码省略.........
}
}
}
foreach ($paneNames as $name => $type) {
$allPanes[$name] = $this->generatePane($type, $defaults);
}
$qfKey = $this->controller->_key;
$this->assign('qfKey', $qfKey);
$this->assign('allPanes', $allPanes);
$this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
if ($this->_formType) {
$this->assign('formType', $this->_formType);
return;
}
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Contribution');
$this->assign('customDataSubType', $this->_contributionType);
$this->assign('entityID', $this->_id);
if ($this->_context == 'standalone') {
$this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution');
// Check permissions for financial type first
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action);
if (empty($financialTypes)) {
CRM_Core_Error::statusBounce(ts('You do not have all the permissions needed for this page.'));
}
$financialType = $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialTypes, TRUE, array('onChange' => "CRM.buildCustomData( 'Contribution', this.value );"));
$paymentInstrument = FALSE;
if (!$this->_mode) {
$paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
}
$trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']);
//add receipt for offline contribution
$this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'));
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
$status = CRM_Contribute_PseudoConstant::contributionStatus();
// suppressing contribution statuses that are NOT relevant to pledges (CRM-5169)
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if ($this->_ppID) {
foreach (array('Cancelled', 'Failed', 'In Progress') as $suppress) {
unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
}
} elseif (!$this->_ppID && $this->_id || !$this->_id) {
$suppressFlag = FALSE;
if ($this->_id) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) {
$suppressFlag = TRUE;
}
}
if (!$suppressFlag) {
foreach (array('Overdue', 'In Progress') as $suppress) {
unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
}
} else {
unset($status[CRM_Utils_Array::key('Overdue', $statusName)]);
}
}
if ($this->_id) {
$contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_id, 'contribution_status_id');
示例9: validate
function validate()
{
if (CRM_Utils_System::isNull($this->_value)) {
return true;
}
switch ($this->_name) {
case 'contact_id':
// note: we validate extistence of the contact in API, upon
// insert (it would be too costlty to do a db call here)
return CRM_Utils_Rule::integer($this->_value);
break;
case 'receive_date':
case 'cancel_date':
case 'receipt_date':
case 'thankyou_date':
return CRM_Utils_Rule::date($this->_value);
break;
case 'non_deductible_amount':
case 'total_amount':
case 'fee_amount':
case 'net_amount':
return CRM_Utils_Rule::money($this->_value);
break;
case 'trxn_id':
static $seenTrxnIds = array();
if (in_array($this->_value, $seenTrxnIds)) {
return false;
} elseif ($this->_value) {
$seenTrxnIds[] = $this->_value;
return true;
} else {
$this->_value = null;
return true;
}
break;
case 'currency':
return CRM_Utils_Rule::currencyCode($this->_value);
break;
case 'contribution_type':
static $contributionTypes = null;
if (!$contributionTypes) {
$contributionTypes =& CRM_Contribute_PseudoConstant::contributionType();
}
if (in_array($this->_value, $contributionTypes)) {
return true;
} else {
return false;
}
break;
case 'payment_instrument':
static $paymentInstruments = null;
if (!$paymentInstruments) {
$paymentInstruments =& CRM_Contribute_PseudoConstant::paymentInstrument();
}
if (in_array($this->_value, $paymentInstruments)) {
return true;
} else {
return false;
}
break;
default:
break;
}
// check whether that's a valid custom field id
// and if so, check the contents' validity
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) {
static $customFields = null;
if (!$customFields) {
$customFields =& CRM_Core_BAO_CustomField::getFields('Contribution');
}
if (!array_key_exists($customFieldID, $customFields)) {
return false;
}
return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value);
}
return true;
}
示例10: submit
//.........这里部分代码省略.........
// These variable sets prior to renewMembership may not be required for this form. They were in
// a function this form shared with other forms.
$membershipSource = NULL;
if (!empty($this->_params['membership_source'])) {
$membershipSource = $this->_params['membership_source'];
}
$isPending = $this->_params['contribution_status_id'] == 2 ? TRUE : FALSE;
list($renewMembership) = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_params['membership_type_id'][1], $isTestMembership, $renewalDate, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId, $isPending, $contributionRecurID, $membershipSource, $this->_params['is_pay_later'], CRM_Utils_Array::value('campaign_id', $this->_params));
$this->endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
$this->membershipTypeName = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
if (!empty($this->_params['record_contribution']) || $this->_mode) {
// set the source
$this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})";
//create line items
$lineItem = array();
$this->_params = $this->setPriceSetParameters($this->_params);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$this->_priceSetId]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $this->_params)) {
foreach ($lineItem[$this->_priceSetId] as &$li) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
if (!empty($lineItem)) {
$this->_params['lineItems'] = $lineItem;
$this->_params['processPriceSet'] = TRUE;
}
//assign contribution contact id to the field expected by recordMembershipContribution
if ($this->_contributorContactID != $this->_contactID) {
$this->_params['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])) {
$this->_params['soft_credit'] = array('soft_credit_type_id' => $this->_params['soft_credit_type_id'], 'contact_id' => $this->_contactID);
}
}
$this->_params['contact_id'] = $this->_contactID;
//recordMembershipContribution receives params as a reference & adds one variable. This is
// not a great pattern & ideally it would not receive as a reference. We assign our params as a
// temporary variable to avoid e-notice & to make it clear to future refactorer that
// this function is NOT reliant on that var being set
$temporaryParams = array_merge($this->_params, array('membership_id' => $renewMembership->id));
CRM_Member_BAO_Membership::recordMembershipContribution($temporaryParams);
}
if (!empty($this->_params['send_receipt'])) {
$receiptFrom = $this->_params['from_email_address'];
if (!empty($this->_params['payment_instrument_id'])) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$this->_params['paidBy'] = $paymentInstrument[$this->_params['payment_instrument_id']];
}
//get the group Tree
$this->_groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $this->_id, FALSE, $this->_memType);
// retrieve custom data
$customFields = $customValues = $fo = array();
foreach ($this->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
}
$members = array(array('member_id', '=', $this->_membershipId, 0, 0));
// check whether its a test drive
if ($this->_mode == 'test') {
$members[] = array('member_test', '=', 1, 0, 0);
}
CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, FALSE, $members);
$this->assign_by_ref('formValues', $this->_params);
if (!empty($this->_params['contribution_id'])) {
$this->assign('contributionID', $this->_params['contribution_id']);
}
$this->assign('membership_name', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id));
$this->assign('customValues', $customValues);
$this->assign('mem_start_date', CRM_Utils_Date::customFormat($renewMembership->start_date));
$this->assign('mem_end_date', CRM_Utils_Date::customFormat($renewMembership->end_date));
if ($this->_mode) {
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
}
}
$this->assign('address', CRM_Utils_Address::format($addressFields));
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
$this->assign('receipt_text_renewal', $this->_params['receipt_text']);
if ($this->_mode == 'test') {
$this->assign('action', '1024');
}
}
list($this->isMailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $this->_receiptContactId, 'from' => $receiptFrom, 'toName' => $this->_contributorDisplayName, 'toEmail' => $this->_contributorEmail, 'isTest' => $this->_mode == 'test'));
}
}
示例11: updateFinancialTrxnData
/**
* Update financial_account_id for bad data in financial_trxn table.
* CRM-12844
*/
public function updateFinancialTrxnData(CRM_Queue_TaskContext $ctx)
{
$upgrade = new CRM_Upgrade_Form();
$sql = "SELECT cc.id contribution_id, cc.contribution_recur_id, cft.payment_processor_id,\ncft.id financial_trxn_id, cfi.entity_table, cft.from_financial_account_id, cft.to_financial_account_id\n\nFROM `civicrm_contribution` cc\nLEFT JOIN civicrm_entity_financial_trxn ceft ON ceft.entity_id = cc.id\nLEFT JOIN civicrm_financial_trxn cft ON cft.id = ceft.financial_trxn_id\nLEFT JOIN civicrm_entity_financial_trxn ceft1 ON ceft1.financial_trxn_id = ceft.financial_trxn_id\nLEFT JOIN civicrm_financial_item cfi ON cfi.id = ceft1.entity_id\nWHERE ceft.entity_table = 'civicrm_contribution' AND cc.contribution_recur_id IS NOT NULL\nAND ceft1.entity_table = 'civicrm_financial_item' AND cft.id IS NOT NULL AND cft.payment_instrument_id = %1\n\nORDER BY cft.id ";
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument('name');
$param = array(1 => array(array_search('Credit Card', $paymentInstrument), 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $param);
$financialTrxn = array();
$subsequentPayments = array();
while ($dao->fetch()) {
if (!array_key_exists($dao->contribution_recur_id, $financialTrxn)) {
$financialTrxn[$dao->contribution_recur_id] = array('from_financial_account_id' => $dao->to_financial_account_id, 'payment_processor_id' => $dao->payment_processor_id, $dao->contribution_id => 1);
if (!is_null($dao->from_financial_account_id)) {
$sql = 'UPDATE civicrm_financial_trxn SET from_financial_account_id = NULL WHERE id = %1';
$params = array(1 => array($dao->financial_trxn_id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $params);
}
} elseif (!array_key_exists($dao->contribution_id, $financialTrxn[$dao->contribution_recur_id])) {
if ($dao->entity_table == 'civicrm_line_item' && $dao->to_financial_account_id == $financialTrxn[$dao->contribution_recur_id]['from_financial_account_id'] || $dao->entity_table == 'civicrm_financial_trxn' && $dao->from_financial_account_id == $financialTrxn[$dao->contribution_recur_id]['from_financial_account_id']) {
continue;
}
$subsequentPayments[$dao->contribution_recur_id][$dao->entity_table][] = $dao->financial_trxn_id;
}
}
foreach ($subsequentPayments as $key => $value) {
foreach ($value as $table => $val) {
if ($table == 'civicrm_financial_trxn') {
$field = 'from_financial_account_id';
} else {
$field = 'to_financial_account_id';
}
$sql = "UPDATE civicrm_financial_trxn SET {$field} = " . $financialTrxn[$dao->contribution_recur_id]['from_financial_account_id'] . ',
payment_processor_id = ' . $financialTrxn[$dao->contribution_recur_id]['payment_processor_id'] . ' WHERE
id IN (' . implode(',', $val) . ')';
CRM_Core_DAO::executeQuery($sql);
}
}
return TRUE;
}
示例12: buildSearchForm
/**
* add all the elements shared between contribute search and advnaced search
*
* @access public
* @return void
* @static
*/
static function buildSearchForm(&$form)
{
require_once 'CRM/Utils/Money.php';
//added contribution source
$form->addElement('text', 'contribution_source', ts('Contribution Source'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'source'));
$form->addDate('contribution_date_low', ts('Contribution Dates - From'), false, array('formatType' => 'searchDate'));
$form->addDate('contribution_date_high', ts('To'), false, array('formatType' => 'searchDate'));
$form->add('text', 'contribution_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'contribution_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
require_once 'CRM/Contribute/PseudoConstant.php';
$form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->add('select', 'contribution_page_id', ts('Contribution Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage());
$form->add('select', 'contribution_payment_instrument_id', ts('Payment Instrument'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument());
$form->add('select', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::pcPage());
$status = array();
require_once "CRM/Core/OptionGroup.php";
$statusValues = CRM_Core_OptionGroup::values("contribution_status");
// Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
unset($statusValues['5']);
unset($statusValues['6']);
foreach ($statusValues as $key => $val) {
$status[] = $form->createElement('advcheckbox', $key, null, $val);
}
$form->addGroup($status, 'contribution_status_id', ts('Contribution Status'));
// add null checkboxes for thank you and receipt
$form->addElement('checkbox', 'contribution_thankyou_date_isnull', ts('Thank-you date not set?'));
$form->addElement('checkbox', 'contribution_receipt_date_isnull', ts('Receipt not sent?'));
//add fields for honor search
$form->addElement('text', 'contribution_in_honor_of', ts("In Honor Of"));
$form->addElement('checkbox', 'contribution_test', ts('Find Test Contributions?'));
$form->addElement('checkbox', 'contribution_pay_later', ts('Find Pay Later Contributions?'));
//add field for transaction ID search
$form->addElement('text', 'contribution_transaction_id', ts("Transaction ID"));
$form->addElement('checkbox', 'contribution_recurring', ts('Find Recurring Contributions?'));
$form->addElement('text', 'contribution_check_number', ts('Check Number'));
//add field for pcp display in roll search
$form->addYesNo('contribution_pcp_display_in_roll', ts('Display In Roll ?'));
// add all the custom searchable fields
require_once 'CRM/Core/BAO/CustomGroup.php';
$contribution = array('Contribution');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $contribution);
if ($groupDetails) {
require_once 'CRM/Core/BAO/CustomField.php';
$form->assign('contributeGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
}
}
}
$form->assign('validCiviContribute', true);
}
示例13: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
function buildQuickForm()
{
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_CORE_ACTION_DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
$this->buldPremiumForm($this);
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution');
$element =& $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('-select-')) + CRM_Contribute_PseudoConstant::contributionType(), true);
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('-select-')) + CRM_Contribute_PseudoConstant::paymentInstrument());
if ($this->_online) {
$element->freeze();
}
// add various dates
$element =& $this->add('date', 'receive_date', ts('Received'), CRM_Core_SelectValues::date('manual', 3, 1), false);
$this->addRule('receive_date', ts('Select a valid date.'), 'qfDate');
if ($this->_online) {
$this->assign("hideCalender", true);
$element->freeze();
}
$this->addElement('date', 'receipt_date', ts('Receipt Sent'), CRM_Core_SelectValues::date('manual', 3, 1));
$this->addRule('receipt_date', ts('Select a valid date.'), 'qfDate');
$this->addElement('date', 'thankyou_date', ts('Thank-you Sent'), CRM_Core_SelectValues::date('manual', 3, 1));
$this->addRule('thankyou_date', ts('Select a valid date.'), 'qfDate');
$this->addElement('date', 'cancel_date', ts('Cancelled'), CRM_Core_SelectValues::date('manual', 3, 1));
$this->addRule('cancel_date', ts('Select a valid date.'), 'qfDate');
$this->add('textarea', 'cancel_reason', ts('Cancellation Reason'), $attributes['cancel_reason']);
// add various amounts
$element =& $this->add('text', 'non_deductible_amount', ts('Non-deductible Amount'), $attributes['non_deductible_amount']);
$this->addRule('non_deductible_amount', ts('Please enter a valid amount.'), 'money');
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('text', 'total_amount', ts('Total Amount'), $attributes['total_amount'], true);
$this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('text', 'fee_amount', ts('Fee Amount'), $attributes['fee_amount']);
$this->addRule('fee_amount', ts('Please enter a valid amount.'), 'money');
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('text', 'net_amount', ts('Net Amount'), $attributes['net_amount']);
$this->addRule('net_amount', ts('Please enter a valid amount.'), 'money');
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['trxn_id']);
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('text', 'invoice_id', ts('Invoice ID'), $attributes['invoice_id']);
if ($this->_online) {
$element->freeze();
}
$element =& $this->add('text', 'source', ts('Source'), $attributes['source']);
if ($this->_online) {
$element->freeze();
}
$this->add('textarea', 'note', ts('Notes'), array("rows" => 4, "cols" => 60));
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
if ($this->_action & CRM_CORE_ACTION_VIEW) {
$this->freeze();
}
}
示例14: contribution
function contribution()
{
$config =& CRM_Core_Config::singleton();
if (!in_array('CiviContribute', $config->enableComponents)) {
return;
}
// process to / from date
$this->dateQueryBuilder('civicrm_contribution', 'contribution_date', 'receive_date', 'Contribution Date');
$qill = array();
if (isset($this->_params['contribution_date_from'])) {
$revDate = array_reverse($this->_params['contribution_date_from']);
$date = CRM_Utils_Date::format($revDate);
$format = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($revDate, '-'));
if ($date) {
$this->_where[] = "civicrm_contribution.receive_date >= '{$date}'";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$qill[] = ts('greater than "%1"', array(1 => $format));
}
}
if (isset($this->_params['contribution_date_to'])) {
$revDate = array_reverse($this->_params['contribution_date_to']);
$date = CRM_Utils_Date::format($revDate);
$format = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($revDate, '-'));
if ($date) {
$this->_where[] = " ( civicrm_contribution.receive_date <= '{$date}' ) ";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$qill[] = ts('less than "%1"', array(1 => $format));
}
}
if (!empty($qill)) {
$this->_qill[] = ts('Contribution Date - %1', array(1 => implode(' ' . ts('and') . ' ', $qill)));
}
// process min/max amount
$qill = array();
if (isset($this->_params['contribution_min_amount'])) {
$amount = $this->_params['contribution_min_amount'];
if ($amount > 0) {
$this->_where[] = "civicrm_contribution.total_amount >= {$amount}";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$qill[] = ts('greater than "%1"', array(1 => $amount));
}
}
if (isset($this->_params['contribution_max_amount'])) {
$amount = $this->_params['contribution_max_amount'];
if ($amount > 0) {
$this->_where[] = "civicrm_contribution.total_amount <= {$amount}";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$qill[] = ts('less than "%1"', array(1 => $amount));
}
}
if (!empty($qill)) {
$this->_qill[] = ts('Contribution Amount - %1', array(1 => implode(' ' . ts('and') . ' ', $qill)));
}
if (CRM_Utils_Array::value('contribution_thankyou_date_isnull', $this->_params)) {
$this->_where[] = "civicrm_contribution.thankyou_date is null";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$this->_qill[] = ts('Contribution Thank-you date is null');
}
if (CRM_Utils_Array::value('contribution_receipt_date_isnull', $this->_params)) {
$this->_where[] = "civicrm_contribution.receipt_date is null";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$this->_qill[] = ts('Contribution Receipt date is null');
}
if (CRM_Utils_Array::value('contribution_type_id', $this->_params)) {
require_once 'CRM/Contribute/PseudoConstant.php';
$cType = $this->_params['contribution_type_id'];
$types = CRM_Contribute_PseudoConstant::contributionType();
$this->_where[] = "civicrm_contribution.contribution_type_id = {$cType}";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$this->_qill[] = ts('Contribution Type - %1', array(1 => $types[$cType]));
}
if (CRM_Utils_Array::value('payment_instrument_id', $this->_params)) {
require_once 'CRM/Contribute/PseudoConstant.php';
$pi = $this->_params['payment_instrument_id'];
$pis = CRM_Contribute_PseudoConstant::paymentInstrument();
$this->_where[] = "civicrm_contribution.payment_instrument_id = {$pi}";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$this->_qill[] = ts('Paid By - %1', array(1 => $pis[$pi]));
}
if (isset($this->_params['contribution_status'])) {
switch ($this->_params['contribution_status']) {
case 'Valid':
$this->_where[] = "civicrm_contribution.cancel_date is null";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$this->_qill[] = ts('Contribution Status - Valid');
break;
case 'Cancelled':
$this->_where[] = "civicrm_contribution.cancel_date is not null";
$this->_tables['civicrm_contribution'] = $this->_whereTables['civicrm_contribution'] = 1;
$this->_qill[] = ts('Contribution Status - Cancelled');
break;
}
}
}
示例15: buildQuickFormCommon
/**
* add all the elements shared between this and advnaced search
*
* @access public
* @return void
* @static
*/
function buildQuickFormCommon(&$form)
{
// Date selects for date
$form->add('date', 'contribution_date_from', ts('Contribution Dates - From'), CRM_Core_SelectValues::date('relative'));
$form->addRule('contribution_date_from', ts('Select a valid date.'), 'qfDate');
$form->add('date', 'contribution_date_to', ts('To'), CRM_Core_SelectValues::date('relative'));
$form->addRule('contribution_date_to', ts('Select a valid date.'), 'qfDate');
$form->add('text', 'contribution_min_amount', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_min_amount', ts('Please enter a valid money value (e.g. 9.99).'), 'money');
$form->add('text', 'contribution_max_amount', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_max_amount', ts('Please enter a valid money value (e.g. 99.99).'), 'money');
$form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->add('select', 'payment_instrument_id', ts('Payment Instrument'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument());
$status = array();
$status[] = $form->createElement('radio', null, null, ts('Valid'), 'Valid');
$status[] = $form->createElement('radio', null, null, ts('Cancelled'), 'Cancelled');
$status[] = $form->createElement('radio', null, null, ts('All'), 'All');
$form->addGroup($status, 'contribution_status', ts('Contribution Status'));
$form->setDefaults(array('contribution_status' => 'All'));
// add null checkboxes for thank you and receipt
$form->addElement('checkbox', 'contribution_thankyou_date_isnull', ts('Thank-you date not set?'));
$form->addElement('checkbox', 'contribution_receipt_date_isnull', ts('Receipt date not set?'));
// add all the custom searchable fields
require_once 'CRM/Core/BAO/CustomGroup.php';
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, array('Contribution'));
if ($groupDetails) {
require_once 'CRM/Core/BAO/CustomField.php';
$form->assign('contributeGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
}
}
}
}