本文整理汇总了PHP中CRM_Core_BAO_UFJoin::getUFGroupIds方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFJoin::getUFGroupIds方法的具体用法?PHP CRM_Core_BAO_UFJoin::getUFGroupIds怎么用?PHP CRM_Core_BAO_UFJoin::getUFGroupIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFJoin
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFJoin::getUFGroupIds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
*/
public static function preProcess(&$form)
{
$session = CRM_Core_Session::singleton();
$contactID = $form->_contactID;
$ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $form->_id);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$form->_profileId = $profileId[0];
if (!$form->_profileId || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
}
$requiredProfileFields = array('organization_name', 'email');
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
if (!$validProfile) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
}
$form->assign('profileId', $form->_profileId);
$form->assign('mode', $form->_mode);
if ($contactID) {
$form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
if (!empty($form->_membershipContactID) && $contactID != $form->_membershipContactID) {
// renewal case - membership being renewed may or may not be for organization
if (!empty($form->_employers) && array_key_exists($form->_membershipContactID, $form->_employers)) {
// if _membershipContactID belongs to employers list, we can say:
$form->_relatedOrganizationFound = TRUE;
}
} elseif (!empty($form->_employers)) {
// not a renewal case and _employers list is not empty
$form->_relatedOrganizationFound = TRUE;
}
if ($form->_relatedOrganizationFound) {
// Related org url - pass checksum if needed
$args = array('cid' => '');
if (!empty($_GET['cs'])) {
$args = array('uid' => $form->_contactID, 'cs' => $_GET['cs'], 'cid' => '');
}
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
if (!empty($form->_submitValues['onbehalf'])) {
if (!empty($form->_submitValues['onbehalfof_id'])) {
$form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
}
$form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
}
}
if ($form->_values['is_for_organization'] != 2) {
$form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound);
} else {
$form->assign('onBehalfRequired', $form->_onBehalfRequired);
}
if (count($form->_employers) == 1) {
foreach ($form->_employers as $id => $value) {
$form->_organizationName = $value['name'];
$orgId = $id;
}
$form->assign('orgId', $orgId);
$form->assign('organizationName', $form->_organizationName);
}
}
}
示例2: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = array();
$ufJoinParams = array('entity_table' => 'civicrm_survey', 'module' => 'CiviCampaign', 'entity_id' => $this->_surveyId);
list($defaults['contact_profile_id'], $second) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$defaults['activity_profile_id'] = $second ? array_shift($second) : '';
return $defaults;
}
示例3: setDefaultValues
/**
* Set default values for the form.
*
* Note that in edit/view mode the default values are retrieved from the database.
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
$ufJoinParams = array('module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
list($defaults['custom_pre_id'], $second) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$defaults['custom_post_id'] = $second ? array_shift($second) : '';
return $defaults;
}
示例4: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return void
*/
function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if ($this->_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
CRM_Utils_System::setTitle(ts('Include Profiles (%1)', array(1 => $title)));
}
$ufJoinParams = array('module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
list($defaults['custom_pre_id'], $defaults['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
return $defaults;
}
示例5: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return void
*/
function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if ($this->_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
CRM_Utils_System::setTitle(ts('Title and Settings (%1)', array(1 => $title)));
$ufJoinParams = array('module' => 'OnBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
$defaults['onbehalf_profile_id'] = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
} else {
CRM_Utils_System::setTitle(ts('Title and Settings'));
}
return $defaults;
}
示例6: preProcess
/**
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function preProcess(&$form)
{
$contriDAO = new CRM_Contribute_DAO_Contribution();
$contriDAO->id = $form->_id;
$contriDAO->find(TRUE);
if ($contriDAO->contribution_page_id) {
$ufJoinParams = array('module' => 'soft_credit', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $contriDAO->contribution_page_id);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
//check if any honree profile is enabled if yes then assign its profile type to $_honoreeProfileType
// which will be used to constraint soft-credit contact type in formRule, CRM-13981
if ($profileId[0]) {
$form->_honoreeProfileType = CRM_Core_BAO_UFGroup::getContactType($profileId[0]);
}
}
}
示例7: preProcess
/**
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
*/
public static function preProcess(&$form)
{
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$ufJoinParams = array('module' => 'soft_credit', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $form->_id);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$form->_honoreeProfileId = $profileId[0];
if (!$form->_honoreeProfileId || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_honoreeProfileId, 'is_active')) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the selected honoree profile is either disabled or not found.'));
}
$profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_honoreeProfileId);
$requiredProfileFields = array('Individual' => array('first_name', 'last_name'), 'Organization' => array('organization_name', 'email'), 'Household' => array('household_name', 'email'));
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_honoreeProfileId, $requiredProfileFields[$profileContactType]);
if (!$validProfile) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the required fields of the selected honoree profile are disabled or doesn\'t exist.'));
}
}
示例8: setValues
static function setValues($id, &$values)
{
$params = array('id' => $id);
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values);
// get the amounts and the label
require_once 'CRM/Core/OptionGroup.php';
$values['amount'] = array();
CRM_Core_OptionGroup::getAssoc("civicrm_contribution_page.amount.{$id}", $values['amount'], true);
// get the profile ids
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $id);
list($values['custom_pre_id'], $values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// add an accounting code also
if ($values['contribution_type_id']) {
$values['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $values['contribution_type_id'], 'accounting_code');
}
}
示例9: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
static function preProcess(&$form)
{
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $form->_id);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$form->_profileId = $profileId[0];
if (!$form->_profileId || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
}
$requiredProfileFields = array('organization_name', 'email');
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
if (!$validProfile) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
}
$form->assign('profileId', $form->_profileId);
$form->assign('mode', $form->_mode);
if ($contactID) {
$form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
if (!empty($form->_employers)) {
$form->_relatedOrganizationFound = TRUE;
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', 'cid=', FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
$dataURL = CRM_Utils_System::url('civicrm/ajax/employer', 'cid=' . $contactID, FALSE, NULL, FALSE);
$form->assign('employerDataURL', $dataURL);
}
if ($form->_values['is_for_organization'] != 2) {
$form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound);
} else {
$form->assign('onBehalfRequired', $form->_onBehalfRequired);
}
if (count($form->_employers) == 1) {
foreach ($form->_employers as $id => $value) {
$form->_organizationName = $value['name'];
$orgId = $id;
}
$form->assign('orgId', $orgId);
$form->assign('organizationName', $form->_organizationName);
}
}
}
示例10: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
$eventId = $this->_id;
$defaults = parent::setDefaultValues();
$this->setShowHide($defaults);
if (isset($eventId)) {
$params = array('id' => $eventId);
CRM_Event_BAO_Event::retrieve($params, $defaults);
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $eventId);
list($defaults['custom_pre_id'], $defaults['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
if ($defaults['is_multiple_registrations']) {
// CRM-4377: set additional participants’ profiles – set to ‘none’ if explicitly unset (non-active)
$ufJoin = new CRM_Core_DAO_UFJoin();
$ufJoin->module = 'CiviEvent_Additional';
$ufJoin->entity_table = 'civicrm_event';
$ufJoin->entity_id = $eventId;
$ufJoin->orderBy('weight');
$ufJoin->find();
$custom = array(1 => 'additional_custom_pre_id', 2 => 'additional_custom_post_id');
while ($ufJoin->fetch()) {
$defaults[$custom[$ufJoin->weight]] = $ufJoin->is_active ? $ufJoin->uf_group_id : 'none';
}
}
} else {
$defaults['is_email_confirm'] = 0;
}
// provide defaults for required fields if empty (and as a 'hint' for approval message field)
$defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now'));
$defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information'));
$defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
$defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
if (CRM_Utils_Array::value('registration_start_date', $defaults)) {
list($defaults['registration_start_date'], $defaults['registration_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'], 'activityDateTime');
}
if (CRM_Utils_Array::value('registration_end_date', $defaults)) {
list($defaults['registration_end_date'], $defaults['registration_end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'], 'activityDateTime');
}
return $defaults;
}
示例11: preProcess
//.........这里部分代码省略.........
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
$this->_allowWaitlist = $this->_isEventFull = FALSE;
if ($eventFull && !$this->_allowConfirmation) {
$this->_isEventFull = TRUE;
//lets redirecting to info only when to waiting list.
$this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']);
if (!$this->_allowWaitlist) {
CRM_Utils_System::redirect($infoUrl);
}
}
$this->set('isEventFull', $this->_isEventFull);
$this->set('allowWaitlist', $this->_allowWaitlist);
//check for require requires approval.
$this->_requireApproval = FALSE;
if (!empty($this->_values['event']['requires_approval']) && !$this->_allowConfirmation) {
$this->_requireApproval = TRUE;
}
$this->set('requireApproval', $this->_requireApproval);
if (isset($this->_values['event']['default_role_id'])) {
$participant_role = CRM_Core_OptionGroup::values('participant_role');
$this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
}
$isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'is_pay_later');
//check for various combinations for paylater, payment
//process with paid event.
if ($isMonetary && (!$isPayLater || !empty($this->_values['event']['payment_processor']))) {
$this->_paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values['event']));
$this->assignPaymentProcessor($isPayLater);
}
//init event fee.
self::initEventFee($this, $this->_eventId);
// get the profile ids
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// set profiles for additional participants
if ($this->_values['event']['is_multiple_registrations']) {
// CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
$ufJoinParams['module'] = 'CiviEvent_Additional';
list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
// set same profile for additional contacts.
if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
$this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
}
if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
$this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
}
// now check for no profile condition, in that case is_active = 0
if (isset($preActive) && !$preActive) {
unset($this->_values['additional_custom_pre_id']);
}
if (isset($postActive) && !$postActive) {
unset($this->_values['additional_custom_post_id']);
}
}
$this->assignBillingType();
if ($this->_values['event']['is_monetary']) {
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
}
$params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
$this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
$this->set('availableRegistrations', $this->_availableRegistrations);
}
示例12: completeTransaction
//.........这里部分代码省略.........
$logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
}
$membershipLog['start_date'] = $logStartDate;
$membershipLog['membership_id'] = $membership->id;
$membershipLog['modified_id'] = $membership->contact_id;
$membershipLog['modified_date'] = date('Ymd');
$membershipLog['membership_type_id'] = $membership->membership_type_id;
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
//update related Memberships.
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
//update the membership type key of membership relatedObjects array
//if it has changed after membership update
if ($membershipTypeIdKey != $membership->membership_type_id) {
$memberships[$membership->membership_type_id] = $membership;
$contribution->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
unset($contribution->_relatedObjects['membership'][$membershipTypeIdKey]);
unset($memberships[$membershipTypeIdKey]);
}
}
}
}
} else {
// event
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$values['custom_pre_id'] = $custom_pre_id;
$values['custom_post_id'] = $custom_post_ids;
$contribution->source = ts('Online Event Registration') . ': ' . $values['event']['title'];
if ($values['event']['is_email_confirm']) {
$contribution->receipt_date = self::$_now;
$values['is_email_receipt'] = 1;
}
$participant->status_id = 1;
$participant->save();
}
if (CRM_Utils_Array::value('net_amount', $input, 0) == 0 && CRM_Utils_Array::value('fee_amount', $input, 0) != 0) {
$input['net_amount'] = $input['amount'] - $input['fee_amount'];
}
$addLineItems = FALSE;
if (empty($contribution->id)) {
$addLineItems = TRUE;
}
$contribution->contribution_status_id = 1;
$contribution->is_test = $input['is_test'];
$contribution->fee_amount = CRM_Utils_Array::value('fee_amount', $input, 0);
$contribution->net_amount = CRM_Utils_Array::value('net_amount', $input, 0);
$contribution->trxn_id = $input['trxn_id'];
$contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
$contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date);
$contribution->cancel_date = 'null';
if (CRM_Utils_Array::value('check_number', $input)) {
$contribution->check_number = $input['check_number'];
}
if (CRM_Utils_Array::value('payment_instrument_id', $input)) {
$contribution->payment_instrument_id = $input['payment_instrument_id'];
}
$contribution->save();
示例13: completeTransaction
//.........这里部分代码省略.........
$membershipLog['start_date'] = $logStartDate;
$membershipLog['membership_id'] = $membership->id;
$membershipLog['modified_id'] = $membership->contact_id;
$membershipLog['modified_date'] = date('Ymd');
$membershipLog['membership_type_id'] = $membership->membership_type_id;
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
//update related Memberships.
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
//update the membership type key of membership relatedObjects array
//if it has changed after membership update
if ($membershipTypeIdKey != $membership->membership_type_id) {
$membershipsUpdate[$membership->membership_type_id] = $membership;
$contribution->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
unset($contribution->_relatedObjects['membership'][$membershipTypeIdKey]);
unset($memberships[$membershipTypeIdKey]);
}
}
}
//update the memberships object with updated membershipTypeId data
//if membershipTypeId has changed after membership update
if (!empty($membershipsUpdate)) {
$memberships = $memberships + $membershipsUpdate;
}
}
} else {
// event
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$values['custom_pre_id'] = $custom_pre_id;
$values['custom_post_id'] = $custom_post_ids;
//for tasks 'Change Participant Status' and 'Batch Update Participants Via Profile' case
//and cases involving status updation through ipn
$values['totalAmount'] = $input['amount'];
$contribution->source = ts('Online Event Registration') . ': ' . $values['event']['title'];
if ($values['event']['is_email_confirm']) {
$contribution->receipt_date = self::$_now;
$values['is_email_receipt'] = 1;
}
if (!CRM_Utils_Array::value('skipComponentSync', $input)) {
$participant->status_id = 1;
}
$participant->save();
}
if (CRM_Utils_Array::value('net_amount', $input, 0) == 0 && CRM_Utils_Array::value('fee_amount', $input, 0) != 0) {
$input['net_amount'] = $input['amount'] - $input['fee_amount'];
}
// This complete transaction function is being overloaded to create new contributions too.
// here we record if it is a new contribution.
// @todo separate the 2 more appropriately.
$isNewContribution = FALSE;
if (empty($contribution->id)) {
$isNewContribution = TRUE;
if (!empty($input['amount']) && $input['amount'] != $contribution->total_amount) {
$contribution->total_amount = $input['amount'];
// The BAO does this stuff but we are actually kinda bypassing it here (bad code! go sit in the corner)
// so we have to handle net_amount in this (naughty) code.
if (isset($input['fee_amount']) && is_numeric($input['fee_amount'])) {
$contribution->fee_amount = $input['fee_amount'];
}
$contribution->net_amount = $contribution->total_amount - $contribution->fee_amount;
示例14: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
$this->assignToTemplate();
$params = $this->_params;
$honor_block_is_active = $this->get('honor_block_is_active');
// make sure we have values for it
if ($honor_block_is_active && !empty($params['soft_credit_type_id'])) {
$honorName = null;
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
$this->assign('honor_block_is_active', $honor_block_is_active);
$this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]);
CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($this, $params['honor'], $params['honoree_profile_id']);
$fieldTypes = array('Contact');
$fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
$this->buildCustom($params['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
}
$this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
$amount_block_is_active = $this->get('amount_block_is_active');
$this->assign('amount_block_is_active', $amount_block_is_active);
if (!empty($params['selectProduct']) && $params['selectProduct'] != 'no_thanks') {
$option = CRM_Utils_Array::value('options_' . $params['selectProduct'], $params);
$productID = $params['selectProduct'];
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, FALSE, $productID, $option);
$this->set('productID', $productID);
$this->set('option', $option);
}
$config = CRM_Core_Config::singleton();
if (in_array('CiviMember', $config->enableComponents)) {
if (isset($params['selectMembership']) && $params['selectMembership'] != 'no_thanks') {
CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, $this->_membershipContactID, FALSE, $params['selectMembership'], FALSE);
} else {
$this->assign('membershipBlock', FALSE);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
if (!empty($params['hidden_onbehalf_profile'])) {
$ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
$OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$profileId = $OnBehalfProfile[0];
$fieldTypes = array('Contact', 'Organization');
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
$fieldTypes = array_merge($fieldTypes, $contactSubType);
if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) {
$fieldTypes = array_merge($fieldTypes, array('Membership'));
} else {
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
$this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
}
$this->_separateMembershipPayment = $this->get('separateMembershipPayment');
$this->assign('is_separate_payment', $this->_separateMembershipPayment);
if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$this->assign('lineItem', $this->_lineItem);
} else {
$this->assign('is_quick_config', 1);
$this->_params['is_quick_config'] = 1;
}
$this->assign('priceSetID', $this->_priceSetId);
$paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(false, null, 'name');
if ($this->_paymentProcessor && $this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('Google_Checkout', $paymentProcessorType) && !$this->_params['is_pay_later'] && !($this->_amount == 0)) {
$this->_checkoutButtonName = $this->getButtonName('next', 'checkout');
$this->add('image', $this->_checkoutButtonName, $this->_paymentProcessor['url_button'], array('class' => 'form-submit'));
$this->addButtons(array(array('type' => 'back', 'name' => ts('<< Go Back'))));
} else {
if ($this->_contributeMode == 'notify' || !$this->_values['is_monetary'] || $this->_amount <= 0.0 || $this->_params['is_pay_later'] || $this->_separateMembershipPayment && $this->_amount <= 0.0) {
$contribButton = ts('Continue >>');
$this->assign('button', ts('Continue'));
} else {
$contribButton = ts('Make Contribution');
$this->assign('button', ts('Make Contribution'));
}
$this->addButtons(array(array('type' => 'next', 'name' => $contribButton, 'spacing' => ' ', 'isDefault' => TRUE, 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');")), array('type' => 'back', 'name' => ts('Go Back'))));
}
$defaults = array();
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
if ($name != 'onbehalf' || $name != 'honor') {
$fields[$name] = 1;
}
}
$fields["billing_state_province-{$this->_bltID}"] = $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1;
$contact = $this->_params;
foreach ($fields as $name => $dontCare) {
if (isset($contact[$name])) {
$defaults[$name] = $contact[$name];
if (substr($name, 0, 7) == 'custom_') {
$timeField = "{$name}_time";
if (isset($contact[$timeField])) {
$defaults[$timeField] = $contact[$timeField];
}
if (isset($contact["{$name}_id"])) {
$defaults["{$name}_id"] = $contact["{$name}_id"];
}
//.........这里部分代码省略.........
示例15: _gatherMessageValues
//.........这里部分代码省略.........
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->id, 'contribution', 1);
if (!empty($lineItem)) {
$itemId = key($lineItem);
foreach ($lineItem as &$eachItem) {
if (is_array($this->_relatedObjects['membership']) && array_key_exists($eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
$eachItem['join_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->join_date);
$eachItem['start_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->start_date);
$eachItem['end_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->end_date);
}
}
$values['lineItem'][0] = $lineItem;
$values['priceSetID'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItem[$itemId]['price_field_id'], 'price_set_id');
}
}
$relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($this->id, $this->contact_id);
// if this is onbehalf of contribution then set related contact
if (!empty($relatedContact['individual_id'])) {
$values['related_contact'] = $ids['related_contact'] = $relatedContact['individual_id'];
}
} else {
// event
$eventParams = array('id' => $this->_relatedObjects['event']->id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
// add custom fields for event
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this->_relatedObjects['event'], $this->_relatedObjects['event']->id);
$eventCustomGroup = array();
foreach ($eventGroupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$eventCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['event']['customGroup'] = $eventCustomGroup;
//get participant details
$participantParams = array('id' => $this->_relatedObjects['participant']->id);
$values['participant'] = array();
CRM_Event_BAO_Participant::getValues($participantParams, $values['participant'], $participantIds);
// add custom fields for event
$participantGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this->_relatedObjects['participant'], $this->_relatedObjects['participant']->id);
$participantCustomGroup = array();
foreach ($participantGroupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$participantCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['participant']['customGroup'] = $participantCustomGroup;
//get location details
$locationParams = array('entity_id' => $this->_relatedObjects['event']->id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$values['custom_pre_id'] = $custom_pre_id;
$values['custom_post_id'] = $custom_post_ids;
// set lineItem for event contribution
if ($this->id) {
$participantIds = CRM_Event_BAO_Participant::getParticipantIds($this->id);
if (!empty($participantIds)) {
foreach ($participantIds as $pIDs) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($pIDs);
if (!CRM_Utils_System::isNull($lineItem)) {
$values['lineItem'][] = $lineItem;
}
}
}
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $this->id);
$customGroup = array();
foreach ($groupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$customGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['customGroup'] = $customGroup;
return $values;
}