本文整理汇总了PHP中CRM_Event_BAO_Participant::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant::getValues方法的具体用法?PHP CRM_Event_BAO_Participant::getValues怎么用?PHP CRM_Event_BAO_Participant::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Participant
的用法示例。
在下文中一共展示了CRM_Event_BAO_Participant::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Event/BAO/Participant.php';
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
require_once 'CRM/Core/Error.php';
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (CRM_Utils_Array::value('fee_level', $values[$participantID])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
require_once 'CRM/Price/BAO/LineItem.php';
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount'];
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['role_id'], $roleCustomDataTypeID);
$eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign($values[$participantID]);
// add viewed participant to recent items list
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
$displayName = CRM_Contact_BAO_Contact::displayName($contactID);
$this->assign('displayName', $displayName);
$title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
// add Participant to Recent Items
CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null);
}
示例2: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (!empty($values[$participantID]['fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
$this->assign('hasPayment', $paymentId);
if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
$parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
$this->assign('parentHasPayment', $parentHasPayment);
}
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
if ($status == 'Transferred') {
$transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
$pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
$transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
$this->assign('pid', $pid);
$this->assign('transferId', $transferId);
$this->assign('transferName', $transferName);
}
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($values[$participantID]['participant_registered_by_id'])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
$values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
}
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
$values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
}
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
$groupTree = array();
$finalTree = array();
foreach ($allRoleIDs as $k => $v) {
$roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
foreach ($groupTree as $treeId => $trees) {
$finalTree[$treeId] = $trees;
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
//CRM-7150, show event name on participant view even if the event is disabled
if (empty($values[$participantID]['event'])) {
$values[$participantID]['event'] = $eventTitle;
}
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
$this->assign($values[$participantID]);
// add viewed participant to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
//.........这里部分代码省略.........
示例3: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::setDefaultValues($this);
}
$defaults = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if ($this->_id) {
$ids = array();
$params = array('id' => $this->_id);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
if ($defaults[$this->_id]['role_id']) {
$roleIDs = explode($sep, $defaults[$this->_id]['role_id']);
}
$this->_contactId = $defaults[$this->_id]['contact_id'];
$this->_statusId = $defaults[$this->_id]['participant_status_id'];
//set defaults for note
$noteDetails = CRM_Core_BAO_Note::getNote($this->_id, 'civicrm_participant');
$defaults[$this->_id]['note'] = array_pop($noteDetails);
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$this->assign('additionalParticipants', CRM_Event_BAO_Participant::getAdditionalParticipants($this->_id));
}
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($defaults[$this->_id]['participant_registered_by_id'])) {
$registered_by_contact_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $defaults[$this->_id]['participant_registered_by_id'], 'contact_id', 'id');
$this->assign('participant_registered_by_id', $defaults[$this->_id]['participant_registered_by_id']);
$this->assign('registered_by_contact_id', $registered_by_contact_id);
$this->assign('registered_by_display_name', CRM_Contact_BAO_Contact::displayName($registered_by_contact_id));
}
}
if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
$inactiveNeeded = TRUE;
$viewMode = TRUE;
} else {
$viewMode = FALSE;
$inactiveNeeded = FALSE;
}
//setting default register date
if ($this->_action == CRM_Core_Action::ADD) {
$statuses = array_flip($this->_participantStatuses);
$defaults[$this->_id]['status_id'] = CRM_Utils_Array::value(ts('Registered'), $statuses);
if (!empty($defaults[$this->_id]['event_id'])) {
$contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], 'financial_type_id');
if ($contributionTypeId) {
$defaults[$this->_id]['financial_type_id'] = $contributionTypeId;
}
}
if ($this->_mode) {
$fields["email-{$this->_bltID}"] = 1;
$fields['email-Primary'] = 1;
if ($this->_contactId) {
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $fields, $defaults);
}
if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults['email-Primary'])) {
$defaults[$this->_id]["email-{$this->_bltID}"] = $defaults['email-Primary'];
}
}
$submittedRole = $this->getElementValue('role_id');
if (!empty($submittedRole[0])) {
$roleID = $submittedRole[0];
}
$submittedEvent = $this->getElementValue('event_id');
if (!empty($submittedEvent[0])) {
$eventID = $submittedEvent[0];
}
} else {
$defaults[$this->_id]['record_contribution'] = 0;
if ($defaults[$this->_id]['participant_is_pay_later']) {
$this->assign('participant_is_pay_later', TRUE);
}
$this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']);
$eventID = $defaults[$this->_id]['event_id'];
$this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id');
$this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'discount_id');
if ($this->_discountId) {
$this->set('discountId', $this->_discountId);
}
}
list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');
//assign event and role id, this is needed for Custom data building
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
if (!empty($defaults[$this->_id]['participant_role_id'])) {
$roleIDs = explode($sep, $defaults[$this->_id]['participant_role_id']);
}
if (isset($_POST['event_id'])) {
$eventID = $_POST['event_id'];
}
if ($this->_eID) {
$eventID = $this->_eID;
//.........这里部分代码省略.........
示例4: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function setDefaultValues(&$form)
{
$defaults = array();
if ($form->_eventId) {
//get receipt text and financial type
$returnProperities = array('confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date');
$details = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
if (!empty($details[$form->_eventId]['financial_type_id'])) {
$defaults[$form->_pId]['financial_type_id'] = $details[$form->_eventId]['financial_type_id'];
}
}
if ($form->_pId) {
$ids = array();
$params = array('id' => $form->_pId);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
if ($form->_action == CRM_Core_Action::UPDATE) {
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$value = current($value);
$discounts[$key] = $value['name'];
}
}
if ($form->_discountId && !empty($discounts[$defaults[$form->_pId]['discount_id']])) {
$form->assign('discount', $discounts[$defaults[$form->_pId]['discount_id']]);
}
$form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
$form->assign('fee_level', CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]));
}
$defaults[$form->_pId]['send_receipt'] = 0;
} else {
$defaults[$form->_pId]['send_receipt'] = strtotime(CRM_Utils_Array::value('start_date', $details[$form->_eventId])) >= time() ? 1 : 0;
if ($form->_eventId && !empty($details[$form->_eventId]['confirm_email_text'])) {
//set receipt text
$defaults[$form->_pId]['receipt_text'] = $details[$form->_eventId]['confirm_email_text'];
}
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults();
}
//CRM-11601 we should keep the record contribution
//true by default while adding participant
if ($form->_action == CRM_Core_Action::ADD && !$form->_mode && $form->_isPaidEvent) {
$defaults[$form->_pId]['record_contribution'] = 1;
}
//CRM-13420
if (empty($defaults['payment_instrument_id'])) {
$defaults[$form->_pId]['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
if ($form->_mode) {
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (empty($defaults[$form->_pId]["billing_country_id-{$form->_bltID}"])) {
$defaults[$form->_pId]["billing_country_id-{$form->_bltID}"] = $config->defaultContactCountry;
}
if (empty($defaults["billing_state_province_id-{$form->_bltID}"])) {
$defaults[$form->_pId]["billing_state_province_id-{$form->_bltID}"] = $config->defaultContactStateProvince;
}
$billingDefaults = $form->getProfileDefaults('Billing', $form->_contactId);
$defaults[$form->_pId] = array_merge($defaults[$form->_pId], $billingDefaults);
// // hack to simplify credit card entry for testing
// $defaults[$form->_pId]['credit_card_type'] = 'Visa';
// $defaults[$form->_pId]['credit_card_number'] = '4807731747657838';
// $defaults[$form->_pId]['cvv2'] = '000';
// $defaults[$form->_pId]['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
}
// if user has selected discount use that to set default
if (isset($form->_discountId)) {
$defaults[$form->_pId]['discount_id'] = $form->_discountId;
//hack to set defaults for already selected discount value
if ($form->_action == CRM_Core_Action::UPDATE && !$form->_originalDiscountId) {
$form->_originalDiscountId = $defaults[$form->_pId]['discount_id'];
if ($form->_originalDiscountId) {
$defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId;
}
}
$discountId = $form->_discountId;
} else {
$discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
}
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
} else {
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $form->_eventId);
}
if ($form->_action == CRM_Core_Action::ADD && $form->_eventId && $discountId) {
// this case is for add mode, where we show discount automatically
$defaults[$form->_pId]['discount_id'] = $discountId;
}
if ($priceSetId) {
// get price set default values, CRM-4090
if (in_array(get_class($form), array('CRM_Event_Form_Participant', 'CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_AdditionalParticipant'))) {
//.........这里部分代码省略.........
示例5: recordAdditionalPayment
//.........这里部分代码省略.........
$trxnId = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($contributionDAO->payment_instrument_id);
} else {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' "));
$queryParams = array(1 => array($relationTypeId, 'Integer'));
$trxnId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = %1", $queryParams);
}
// update statuses
// criteria for updates contribution total_amount == financial_trxns of partial_payments
$sql = "SELECT SUM(ft.total_amount) as sum_of_payments, SUM(ft.net_amount) as net_amount_total\nFROM civicrm_financial_trxn ft\nLEFT JOIN civicrm_entity_financial_trxn eft\n ON (ft.id = eft.financial_trxn_id)\nWHERE eft.entity_table = 'civicrm_contribution'\n AND eft.entity_id = {$contributionId}\n AND ft.to_financial_account_id != {$toFinancialAccount}\n AND ft.status_id = {$statusId}\n";
$query = CRM_Core_DAO::executeQuery($sql);
$query->fetch();
$sumOfPayments = $query->sum_of_payments;
// update statuses
if ($contributionDAO->total_amount == $sumOfPayments) {
// update contribution status and
// clean cancel info (if any) if prev. contribution was updated in case of 'Refunded' => 'Completed'
$contributionDAO->contribution_status_id = $statusId;
$contributionDAO->cancel_date = 'null';
$contributionDAO->cancel_reason = NULL;
$netAmount = !empty($trxnsData['net_amount']) ? NULL : $trxnsData['total_amount'];
$contributionDAO->net_amount = $query->net_amount_total + $netAmount;
$contributionDAO->fee_amount = $contributionDAO->total_amount - $contributionDAO->net_amount;
$contributionDAO->save();
//Change status of financial record too
$financialTrxn->status_id = $statusId;
$financialTrxn->save();
// note : not using the self::add method,
// the reason because it performs 'status change' related code execution for financial records
// which in 'Partial Paid' => 'Completed' is not useful, instead specific financial record updates
// are coded below i.e. just updating financial_item status to 'Paid'
if ($participantId) {
// update participant status
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
foreach ($ids as $val) {
$participantUpdate['id'] = $val;
$participantUpdate['status_id'] = array_search('Registered', $participantStatuses);
CRM_Event_BAO_Participant::add($participantUpdate);
}
}
// update financial item statuses
$financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
$paidStatus = array_search('Paid', $financialItemStatus);
$baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId);
$sqlFinancialItemUpdate = "\nUPDATE civicrm_financial_item fi\n LEFT JOIN civicrm_entity_financial_trxn eft\n ON (eft.entity_id = fi.id AND eft.entity_table = 'civicrm_financial_item')\nSET status_id = {$paidStatus}\nWHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})\n";
CRM_Core_DAO::executeQuery($sqlFinancialItemUpdate);
}
} elseif ($paymentType == 'refund') {
// build params for recording financial trxn entry
$params['contribution'] = $contributionDAO;
$params = array_merge($defaults, $params);
$params['skipLineItem'] = TRUE;
$trxnsData['trxn_date'] = !empty($trxnsData['trxn_date']) ? $trxnsData['trxn_date'] : date('YmdHis');
$trxnsData['total_amount'] = -$trxnsData['total_amount'];
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$trxnsData['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($contributionDAO->financial_type_id, $relationTypeId);
$trxnsData['status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name');
// record the entry
$financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData);
// note : not using the self::add method,
// the reason because it performs 'status change' related code execution for financial records
// which in 'Pending Refund' => 'Completed' is not useful, instead specific financial record updates
// are coded below i.e. just updating financial_item status to 'Paid'
$contributionDetails = CRM_Core_DAO::setFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'contribution_status_id', $statusId);
// add financial item entry
$financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
$getLine['entity_id'] = $contributionDAO->id;
$getLine['entity_table'] = 'civicrm_contribution';
$lineItemId = CRM_Price_BAO_LineItem::retrieve($getLine, CRM_Core_DAO::$_nullArray);
if (!empty($lineItemId->id)) {
$addFinancialEntry = array('transaction_date' => $financialTrxn->trxn_date, 'contact_id' => $contributionDAO->contact_id, 'amount' => $financialTrxn->total_amount, 'status_id' => array_search('Paid', $financialItemStatus), 'entity_id' => $lineItemId->id, 'entity_table' => 'civicrm_line_item');
$trxnIds['id'] = $financialTrxn->id;
CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds);
}
if ($participantId) {
// update participant status
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
foreach ($ids as $val) {
$participantUpdate['id'] = $val;
$participantUpdate['status_id'] = array_search('Registered', $participantStatuses);
CRM_Event_BAO_Participant::add($participantUpdate);
}
}
}
// activity creation
if (!empty($financialTrxn)) {
if ($participantId) {
$inputParams['id'] = $participantId;
$values = array();
$ids = array();
$component = 'event';
$entityObj = CRM_Event_BAO_Participant::getValues($inputParams, $values, $ids);
$entityObj = $entityObj[$participantId];
}
$activityType = $paymentType == 'refund' ? 'Refund' : 'Payment';
self::addActivityForPayment($entityObj, $financialTrxn, $activityType, $component, $contributionId);
}
return $financialTrxn;
}
示例6: preProcess
/**
* Set variables up before form is built based on participant ID from URL
*
* @return void
*/
public function preProcess()
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
$participant = $values = array();
$this->_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST');
$params = array('id' => $this->_participant_id);
$this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant);
$this->_part_values = $values[$this->_participant_id];
$this->set('values', $this->_part_values);
//fetch Event by event_id, verify that this event can still be xferred/cancelled
$this->_event_id = $this->_part_values['event_id'];
$url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
$this->_contact_id = $this->_part_values['participant_contact_id'];
$this->assign('action', $this->_action);
if ($this->_participant_id) {
$this->assign('participantId', $this->_participant_id);
}
$event = array();
$daoName = 'title';
$this->_event_title = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
$daoName = 'start_date';
$this->_event_start_date = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contact_id);
$this->_contact_name = $displayName;
$this->_contact_email = $email;
$details = array();
$details = CRM_Event_BAO_Participant::participantDetails($this->_participant_id);
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
$contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participant_id, 'contribution_id', 'participant_id');
$this->assign('contributionId', $contributionId);
$query = "\n SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, cp.status_id\n FROM civicrm_participant cp\n LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id\n LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}\n WHERE cp.id = {$this->_participant_id}";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
while ($dao->fetch()) {
$details['status'] = $dao->status;
$details['role'] = $dao->role;
$details['fee_level'] = $dao->fee_level;
$details['fee_amount'] = $dao->fee_amount;
$details['register_date'] = $dao->register_date;
}
//verify participant status is still Registered
if ($details['status'] != "Registered") {
$status = "You are no longer registered for " . $this->_event_title;
CRM_Core_Session::setStatus($status, ts('Event status error.'), 'alert');
CRM_Utils_System::redirect($url);
}
$query = "select start_date as start, selfcancelxfer_time as time from civicrm_event where id = " . $this->_event_id;
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
while ($dao->fetch()) {
$time_limit = $dao->time;
$start_date = $dao->start;
}
$start_time = new Datetime($start_date);
$timenow = new Datetime();
if (!empty($start_time) && $start_time < $timenow) {
$status = ts("The event has been started, cannot transfer or cancel this event");
$session->setStatus($status, ts('Oops.'), 'alert');
CRM_Utils_System::redirect($url);
}
if (!empty($time_limit) && $time_limit > 0) {
$interval = $timenow->diff($start_time);
$days = $interval->format('%d');
$hours = $interval->format('%h');
if ($hours <= $time_limit && $days < 1) {
$status = ts("Less than %1 hours to start time, cannot transfer or cancel this event", array(1 => $time_limit));
$session->setStatus($status, ts('Oops.'), 'alert');
CRM_Utils_System::redirect($url);
}
}
$this->assign('details', $details);
$this->selfsvcupdateUrl = CRM_Utils_System::url('civicrm/event/selfsvcupdate', "reset=1&id={$this->_participant_id}&id=0");
$this->selfsvcupdateText = ts('Update');
$this->selfsvcupdateButtonText = ts('Update');
// Based on those ids retrieve event and verify it is eligible
// for self update (event.start_date > today, event can be 'self_updated'
// retrieve contact name and email, and let user verify his/her identity
}
示例7: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::setDefaultValues($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if ($this->_participantId) {
$ids = array();
$params = array('id' => $this->_participantId);
require_once "CRM/Event/BAO/Participant.php";
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$this->_contactID = $defaults[$this->_participantId]['contact_id'];
$this->_statusId = $defaults[$this->_participantId]['participant_status_id'];
//set defaults for note
$noteDetails = CRM_Core_BAO_Note::getNote($this->_participantId, 'civicrm_participant');
$defaults[$this->_participantId]['note'] = array_pop($noteDetails);
}
if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
$inactiveNeeded = true;
$viewMode = true;
} else {
$viewMode = false;
$inactiveNeeded = false;
}
//setting default register date
if ($this->_action == CRM_Core_Action::ADD) {
if (CRM_Utils_Array::value('event_id', $defaults[$this->_participantId])) {
$contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_participantId]['event_id'], 'contribution_type_id');
if ($contributionTypeId) {
$defaults[$this->_participantId]['contribution_type_id'] = $contributionTypeId;
}
}
if ($this->_mode) {
$fields["email-{$this->_bltID}"] = 1;
$fields["email-Primary"] = 1;
require_once "CRM/Core/BAO/UFGroup.php";
if ($this->_contactID) {
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $defaults);
}
if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults["email-Primary"])) {
$defaults[$this->_participantId]["email-{$this->_bltID}"] = $defaults["email-Primary"];
}
}
$submittedRole = $this->getElementValue('role_id');
if ($submittedRole[0]) {
$roleID = $submittedRole[0];
}
$submittedEvent = $this->getElementValue('event_id');
if ($submittedEvent[0]) {
$eventID = $submittedEvent[0];
}
} else {
$defaults[$this->_participantId]['record_contribution'] = 0;
$recordContribution = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $defaults[$this->_participantId]['id'], 'contribution_id', 'participant_id');
//contribution record exists for this participation
if ($recordContribution) {
foreach (array('contribution_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date') as $field) {
$defaults[$this->_participantId][$field] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $recordContribution, $field);
}
}
if ($defaults[$this->_participantId]['participant_is_pay_later']) {
$this->assign('participant_is_pay_later', true);
}
$this->assign('participant_status_id', $defaults[$this->_participantId]['participant_status_id']);
$roleID = $defaults[$this->_participantId]['participant_role_id'];
$eventID = $defaults[$this->_participantId]['event_id'];
$this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'discount_id');
if ($this->_discountId) {
$this->set('discountId', $this->_discountId);
}
}
list($defaults[$this->_participantId]['register_date'], $defaults[$this->_participantId]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_participantId]));
//assign event and role id, this is needed for Custom data building
if (isset($_POST['role_id'])) {
$roleID = $_POST['role_id'];
}
if (isset($roleID)) {
$this->assign('roleID', $roleID);
}
if (isset($_POST['event_id'])) {
$eventID = $_POST['event_id'];
}
if (isset($eventID)) {
$this->assign('eventID', $eventID);
$this->set('eventId', $eventID);
}
//.........这里部分代码省略.........
示例8: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
static function setDefaultValues(&$form)
{
$defaults = array();
if ($form->_eventId) {
//get receipt text and contribution type
$returnProperities = array('confirm_email_text', 'contribution_type_id', 'campaign_id');
$details = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
if (CRM_Utils_Array::value('contribution_type_id', $details[$form->_eventId])) {
$defaults[$form->_pId]['contribution_type_id'] = $details[$form->_eventId]['contribution_type_id'];
}
}
if ($form->_pId) {
$ids = array();
$params = array('id' => $form->_pId);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
if ($form->_action == CRM_Core_Action::UPDATE) {
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$discounts[$key] = $value['name'];
}
}
if ($form->_discountId) {
$form->assign('discount', $discounts[$defaults[$form->_pId]['discount_id']]);
}
$form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
$form->assign('fee_level', CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]));
}
$defaults[$form->_pId]['send_receipt'] = 0;
} else {
$defaults[$form->_pId]['send_receipt'] = 1;
if ($form->_eventId && CRM_Utils_Array::value('confirm_email_text', $details[$form->_eventId])) {
//set receipt text
$defaults[$form->_pId]['receipt_text'] = $details[$form->_eventId]['confirm_email_text'];
}
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults();
}
if ($form->_mode) {
$fields = array();
foreach ($form->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$names = array('first_name', 'middle_name', 'last_name', "street_address-{$form->_bltID}", "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "country_id-{$form->_bltID}", "state_province_id-{$form->_bltID}");
foreach ($names as $name) {
$fields[$name] = 1;
}
$fields["state_province-{$form->_bltID}"] = 1;
$fields["country-{$form->_bltID}"] = 1;
$fields["email-{$form->_bltID}"] = 1;
$fields['email-Primary'] = 1;
if ($form->_contactId) {
CRM_Core_BAO_UFGroup::setProfileDefaults($form->_contactId, $fields, $form->_defaults);
}
// use primary email address if billing email address is empty
if (empty($form->_defaults["email-{$form->_bltID}"]) && !empty($form->_defaults['email-Primary'])) {
$defaults[$form->_pId]["email-{$form->_bltID}"] = $form->_defaults['email-Primary'];
}
foreach ($names as $name) {
if (!empty($form->_defaults[$name])) {
$defaults[$form->_pId]['billing_' . $name] = $form->_defaults[$name];
}
}
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (!CRM_Utils_Array::value("billing_country_id-{$form->_bltID}", $defaults[$form->_pId])) {
$defaults[$form->_pId]["billing_country_id-{$form->_bltID}"] = $config->defaultContactCountry;
}
// // hack to simplify credit card entry for testing
// $defaults[$form->_pId]['credit_card_type'] = 'Visa';
// $defaults[$form->_pId]['credit_card_number'] = '4807731747657838';
// $defaults[$form->_pId]['cvv2'] = '000';
// $defaults[$form->_pId]['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
}
if ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $form->_eventId)) {
// get price set default values, CRM-4090
if (in_array(get_class($form), array('CRM_Event_Form_Participant', 'CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_AdditionalParticipant'))) {
$priceSetValues = self::setDefaultPriceSet($form->_pId, $form->_eventId);
if (!empty($priceSetValues)) {
$defaults[$form->_pId] = array_merge($defaults[$form->_pId], $priceSetValues);
}
}
if ($form->_action == CRM_Core_Action::ADD && CRM_Utils_Array::value('fields', $form->_priceSet)) {
foreach ($form->_priceSet['fields'] as $key => $val) {
foreach ($val['options'] as $keys => $values) {
if ($values['is_default']) {
if (get_class($form) != 'CRM_Event_Form_Participant' && CRM_Utils_Array::value('is_full', $values)) {
continue;
}
if ($val['html_type'] == 'CheckBox') {
$defaults[$form->_pId]["price_{$key}"][$keys] = 1;
} else {
//.........这里部分代码省略.........
示例9: postProcess
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$feeBlock = $this->_values['fee'];
$lineItems = $this->_values['line_items'];
CRM_Event_BAO_Participant::changeFeeSelections($params, $this->_participantId, $this->_contributionId, $feeBlock, $lineItems, $this->_paidAmount, $params['priceSetId']);
$this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount');
// email sending
if (CRM_Utils_Array::value('send_receipt', $params)) {
$fetchParticipantVals = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($fetchParticipantVals, $participantDetails, CRM_Core_DAO::$_nullArray);
$participantParams = array_merge($params, $participantDetails[$this->_participantId]);
$mailSent = $this->emailReceipt($participantParams);
}
// update participant
CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'status_id', $params['status_id']);
if (!empty($params['note'])) {
$noteParams = array('entity_table' => 'civicrm_participant', 'note' => $params['note'], 'entity_id' => $this->_participantId, 'contact_id' => $this->_contactId, 'modified_date' => date('Ymd'));
CRM_Core_BAO_Note::add($noteParams);
}
CRM_Core_Session::setStatus(ts("The fee selection has been changed for this participant"), ts('Saved'), 'success');
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/payment/add', "reset=1&action=add&component=event&id={$this->_participantId}&cid={$this->_contactId}"));
}
}
示例10: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::setDefaultValues($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if ($this->_id) {
$ids = array();
$params = array('id' => $this->_id);
require_once "CRM/Event/BAO/Participant.php";
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
if ($defaults[$this->_id]['role_id']) {
foreach (explode($sep, $defaults[$this->_id]['role_id']) as $k => $v) {
$defaults[$this->_id]["role_id[{$v}]"] = 1;
}
unset($defaults[$this->_id]['role_id']);
}
$this->_contactId = $defaults[$this->_id]['contact_id'];
$this->_statusId = $defaults[$this->_id]['participant_status_id'];
//set defaults for note
$noteDetails = CRM_Core_BAO_Note::getNote($this->_id, 'civicrm_participant');
$defaults[$this->_id]['note'] = array_pop($noteDetails);
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$this->assign('additionalParticipants', CRM_Event_BAO_Participant::getAdditionalParticipants($this->_id));
}
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (CRM_Utils_Array::value('participant_registered_by_id', $defaults[$this->_id])) {
$registered_by_contact_id = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $defaults[$this->_id]['participant_registered_by_id'], 'contact_id', 'id');
$this->assign('participant_registered_by_id', $defaults[$this->_id]['participant_registered_by_id']);
$this->assign('registered_by_contact_id', $registered_by_contact_id);
require_once 'CRM/Contact/BAO/Contact.php';
$this->assign('registered_by_display_name', CRM_Contact_BAO_Contact::displayName($registered_by_contact_id));
}
}
if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
$inactiveNeeded = true;
$viewMode = true;
} else {
$viewMode = false;
$inactiveNeeded = false;
}
//setting default register date
if ($this->_action == CRM_Core_Action::ADD) {
$statuses = array_flip($this->_participantStatuses);
$defaults[$this->_id]['status_id'] = CRM_Utils_Array::value(ts('Registered'), $statuses);
if (CRM_Utils_Array::value('event_id', $defaults[$this->_id])) {
$contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], 'contribution_type_id');
if ($contributionTypeId) {
$defaults[$this->_id]['contribution_type_id'] = $contributionTypeId;
}
}
if ($this->_mode) {
$fields["email-{$this->_bltID}"] = 1;
$fields["email-Primary"] = 1;
if ($this->_contactId) {
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $fields, $defaults);
}
if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults["email-Primary"])) {
$defaults[$this->_id]["email-{$this->_bltID}"] = $defaults["email-Primary"];
}
}
$submittedRole = $this->getElementValue('role_id');
if (CRM_Utils_Array::value(0, $submittedRole)) {
$roleID = $submittedRole[0];
}
$submittedEvent = $this->getElementValue('event_id');
if ($submittedEvent[0]) {
$eventID = $submittedEvent[0];
}
} else {
$defaults[$this->_id]['record_contribution'] = 0;
if ($defaults[$this->_id]['participant_is_pay_later']) {
$this->assign('participant_is_pay_later', true);
}
$this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']);
$roleID = $defaults[$this->_id]['participant_role_id'];
$eventID = $defaults[$this->_id]['event_id'];
$this->_eventTypeId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $eventID, 'event_type_id', 'id');
$this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'discount_id');
if ($this->_discountId) {
$this->set('discountId', $this->_discountId);
}
}
list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');
//.........这里部分代码省略.........
示例11: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
static function setDefaultValues(&$form)
{
$defaults = array();
if ($form->_eventId) {
//get receipt text and contribution type
$returnProperities = array('confirm_email_text', 'contribution_type_id');
$details = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
$defaults[$form->_pId]['contribution_type_id'] = $details[$form->_eventId]['contribution_type_id'];
}
if ($form->_pId) {
$ids = array();
$params = array('id' => $form->_pId);
require_once "CRM/Event/BAO/Participant.php";
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
if ($form->_action == CRM_Core_Action::UPDATE) {
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$discounts[$key] = $value['name'];
}
}
if ($form->_discountId) {
$form->assign('discount', $discounts[$defaults[$form->_pId]['discount_id']]);
}
$form->assign('fee_amount', $defaults[$form->_pId]['fee_amount']);
$form->assign('fee_level', $defaults[$form->_pId]['fee_level']);
}
$defaults[$form->_pId]['send_receipt'] = 0;
} else {
$defaults[$form->_pId]['send_receipt'] = 1;
if ($form->_eventId) {
//set receipt text
$defaults[$form->_pId]['receipt_text'] = $details[$form->_eventId]['confirm_email_text'];
}
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults();
}
if ($form->_mode) {
$fields = array();
foreach ($form->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$names = array("first_name", "middle_name", "last_name", "street_address-{$form->_bltID}", "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "country_id-{$form->_bltID}", "state_province_id-{$form->_bltID}");
foreach ($names as $name) {
$fields[$name] = 1;
}
$fields["state_province-{$form->_bltID}"] = 1;
$fields["country-{$form->_bltID}"] = 1;
$fields["email-{$form->_bltID}"] = 1;
$fields["email-Primary"] = 1;
require_once "CRM/Core/BAO/UFGroup.php";
if ($form->_contactID) {
CRM_Core_BAO_UFGroup::setProfileDefaults($form->_contactID, $fields, $form->_defaults);
}
// use primary email address if billing email address is empty
if (empty($form->_defaults["email-{$form->_bltID}"]) && !empty($form->_defaults["email-Primary"])) {
$defaults[$form->_pId]["email-{$form->_bltID}"] = $form->_defaults["email-Primary"];
}
foreach ($names as $name) {
if (!empty($form->_defaults[$name])) {
$defaults[$form->_pId]["billing_" . $name] = $form->_defaults[$name];
}
}
}
require_once 'CRM/Price/BAO/Set.php';
if ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $form->_eventId)) {
// get price set default values, CRM-4090
if (in_array(get_class($form), array('CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_AdditionalParticipant'))) {
$priceSetValues = self::setDefaultPriceSet($form->_pId, $form->_eventId);
if (!empty($priceSetValues)) {
$defaults[$form->_pId] = array_merge($defaults[$form->_pId], $priceSetValues);
}
}
if ($form->_action == CRM_Core_Action::ADD) {
foreach ($form->_priceSet['fields'] as $key => $val) {
foreach ($val['options'] as $keys => $values) {
if ($values['is_default']) {
if ($val['html_type'] == 'CheckBox') {
$defaults[$form->_pId]["price_{$key}"][$keys] = 1;
} else {
$defaults[$form->_pId]["price_{$key}"] = $keys;
}
}
}
}
}
$form->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
if ($form->_action == CRM_Core_Action::UPDATE) {
$fee_level = $defaults[$form->_pId]['fee_level'];
CRM_Event_BAO_Participant::fixEventLevel($fee_level);
$form->assign("fee_level", $fee_level);
$form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
}
//.........这里部分代码省略.........
示例12: preProcess
/**
* Get source values for transfer based on participant id in URL. Line items will
* be transferred to this participant - at this point no transaction changes processed
*
* return @void
*/
public function preProcess()
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
$this->_from_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST');
$this->_userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE, NULL, 'REQUEST');
$params = array('id' => $this->_from_participant_id);
$participant = $values = array();
$this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant);
$this->_part_values = $values[$this->_from_participant_id];
$this->set('values', $this->_part_values);
$this->_event_id = $this->_part_values['event_id'];
$url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}");
$this->_from_contact_id = $this->_part_values['participant_contact_id'];
$validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($this->_from_contact_id, $this->_userChecksum);
if (!$validUser && !CRM_Core_Permission::check('edit all events')) {
CRM_Core_Error::statusBounce(ts('You do not have sufficient permission to transfer/cancel this participant.'), $url);
}
$this->assign('action', $this->_action);
if ($this->_from_participant_id) {
$this->assign('participantId', $this->_from_participant_id);
}
$event = array();
$daoName = 'title';
$this->_event_title = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
$daoName = 'start_date';
$this->_event_start_date = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_from_contact_id);
$this->_contact_name = $displayName;
$this->_contact_email = $email;
$details = array();
$details = CRM_Event_BAO_Participant::participantDetails($this->_from_participant_id);
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
$query = "\n SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, civicrm_event.start_date\n FROM civicrm_participant cp\n LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id\n LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}\n LEFT JOIN civicrm_event ON civicrm_event.id = cp.event_id\n WHERE cp.id = {$this->_from_participant_id}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$details['status'] = $dao->status;
$details['role'] = $dao->role;
$details['fee_level'] = $dao->fee_level;
$details['fee_amount'] = $dao->fee_amount;
$details['register_date'] = $dao->register_date;
$details['event_start_date'] = $dao->start_date;
}
$this->assign('details', $details);
//This participant row will be cancelled. Get line item(s) to cancel
$this->selfsvctransferUrl = CRM_Utils_System::url('civicrm/event/selfsvcupdate', "reset=1&id={$this->_from_participant_id}&id=0");
$this->selfsvctransferText = ts('Update');
$this->selfsvctransferButtonText = ts('Update');
}
示例13: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
function preProcess()
{
$this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
//CRM-4320
$this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
// current mode
$this->_mode = $this->_action == 1024 ? 'test' : 'live';
$this->_values = $this->get('values');
$this->_fields = $this->get('fields');
$this->_bltID = $this->get('bltID');
$this->_paymentProcessor = $this->get('paymentProcessor');
$this->_priceSetId = $this->get('priceSetId');
$this->_priceSet = $this->get('priceSet');
//check if participant allow to walk registration wizard.
$this->_allowConfirmation = $this->get('allowConfirmation');
// check for Approval
$this->_requireApproval = $this->get('requireApproval');
// check for waitlisting.
$this->_allowWaitlist = $this->get('allowWaitlist');
//get the additional participant ids.
$this->_additionalParticipantIds = $this->get('additionalParticipantIds');
$config =& CRM_Core_Config::singleton();
if (!$this->_values) {
// create redirect URL to send folks back to event info page is registration not available
$infoUrl = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}", false, null, false, true);
// this is the first time we are hitting this, so check for permissions here
if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId)) {
CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
}
// get all the values from the dao object
$this->_values = array();
$this->_fields = array();
// get the participant values, CRM-4320
$this->_allowConfirmation = false;
if ($this->_participantId) {
require_once 'CRM/Event/BAO/Event.php';
$ids = $participantValues = array();
$participantParams = array('id' => $this->_participantId);
require_once 'CRM/Event/BAO/Participant.php';
CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
$this->_values['participant'] = $participantValues[$this->_participantId];
//allow pending status class walk registration wizard.
require_once 'CRM/Core/PseudoConstant.php';
if (array_key_exists($participantValues[$this->_participantId]['status_id'], CRM_Event_PseudoConstant::participantStatus(null, "class = 'Pending'"))) {
$this->_allowConfirmation = true;
$this->set('allowConfirmation', true);
}
}
//retrieve event information
require_once 'CRM/Event/BAO/Event.php';
$params = array('id' => $this->_eventId);
CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
require_once 'CRM/Event/BAO/Participant.php';
//check for additional participants.
if ($this->_allowConfirmation && $this->_values['event']['is_multiple_registrations']) {
$this->_additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
$this->set('additionalParticipantIds', $this->_additionalParticipantIds);
}
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
$this->_allowWaitlist = false;
if ($eventFull && !$this->_allowConfirmation) {
//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('allowWaitlist', $this->_allowWaitlist);
//check for require requires approval.
$this->_requireApproval = false;
if (CRM_Utils_Array::value('requires_approval', $this->_values['event']) && !$this->_allowConfirmation) {
$this->_requireApproval = true;
}
$this->set('requireApproval', $this->_requireApproval);
// also get the accounting code
if (CRM_Utils_Array::value('contribution_type_id', $this->_values['event'])) {
$this->_values['event']['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $this->_values['event']['contribution_type_id'], 'accounting_code');
}
if (isset($this->_values['event']['default_role_id'])) {
require_once 'CRM/Core/OptionGroup.php';
$participant_role = CRM_Core_OptionGroup::values('participant_role');
$this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
}
// is the event active (enabled)?
if (!$this->_values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::statusBounce(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
}
// is online registration is enabled?
if (!$this->_values['event']['is_online_registration']) {
CRM_Core_Error::statusBounce(ts('Online registration is not currently available for this event (contact the site administrator for assistance).'), $infoUrl);
}
// is this an event template ?
//.........这里部分代码省略.........
示例14: testfixEventLevel
/**
* FixEventLevel() method (Setting ',' values), resolveDefaults(assinging value to array) method
*/
public function testfixEventLevel()
{
$paramsSet['title'] = 'Price Set';
$paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
$paramsSet['is_active'] = FALSE;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => 10, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => 10), 'option_name' => array('1' => 10), 'option_weight' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
$ids = array();
$pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
$eventId = $this->_eventId;
$participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 1, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
$participant = CRM_Event_BAO_Participant::add($participantParams);
//Checking for participant added in the table.
$this->assertDBCompareValue('CRM_Event_BAO_Participant', $this->_contactId, 'id', 'contact_id', $participant->id, 'Check DB for created participant');
$values = array();
$ids = array();
$params = array('id' => $participant->id);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
$this->assertNotEquals(count($values), 0, 'Checking for empty array.');
CRM_Event_BAO_Participant::resolveDefaults($values[$participant->id]);
if ($values[$participant->id]['fee_level']) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participant->id]['fee_level']);
}
$deletePricefield = CRM_Price_BAO_PriceField::deleteField($pricefield->id);
$this->assertDBNull('CRM_Price_BAO_PriceField', $pricefield->id, 'name', 'id', 'Check DB for non-existence of Price Field.');
$deletePriceset = CRM_Price_BAO_PriceSet::deleteSet($priceset->id);
$this->assertDBNull('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', 'Check DB for non-existence of Price Set.');
Participant::delete($participant->id);
Contact::delete($this->_contactId);
Event::delete($eventId);
}
示例15: postProcess
//.........这里部分代码省略.........
$primaryParticipant['participants_info'][$participantID] = $params[$participantNum];
}
//get event custom field information
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_eventId, 0, $this->_values['event']['event_type_id']);
$primaryParticipant['eventCustomFields'] = $groupTree;
// call postprocess hook before leaving
$this->postProcessHook();
// this does not return
$payment->doPayment($primaryParticipant, 'event');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
} else {
//otherwise send mail Confirmation/Receipt
$primaryContactId = $this->get('primaryContactId');
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($registerByID, NULL, $primaryContactId, $isTest, TRUE);
//lets send mails to all with meaningful text, CRM-4320.
$this->assign('isOnWaitlist', $this->_allowWaitlist);
$this->assign('isRequireApproval', $this->_requireApproval);
//need to copy, since we are unsetting on the way.
$copyParticipantCount = $participantCount;
//lets carry all paticipant params w/ values.
foreach ($additionalIDs as $participantID => $contactId) {
$participantNum = NULL;
if ($participantID == $registerByID) {
$participantNum = 0;
} else {
if ($participantNum = array_search('participant', $copyParticipantCount)) {
unset($copyParticipantCount[$participantNum]);
}
}
if ($participantNum === NULL) {
break;
}
//carry the participant submitted values.
$this->_values['params'][$participantID] = $params[$participantNum];
}
foreach ($additionalIDs as $participantID => $contactId) {
$participantNum = 0;
if ($participantID == $registerByID) {
//set as Primary Participant
$this->assign('isPrimary', 1);
//build an array of custom profile and assigning it to template.
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($participantID, $this->_values, NULL, $isTest);
if (count($customProfile)) {
$this->assign('customProfile', $customProfile);
$this->set('customProfile', $customProfile);
}
$this->_values['params']['additionalParticipant'] = FALSE;
} else {
//take the Additional participant number.
if ($participantNum = array_search('participant', $participantCount)) {
unset($participantCount[$participantNum]);
}
// Change $this->_values['participant'] to include additional participant values
$ids = $participantValues = array();
$participantParams = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
$this->_values['participant'] = $participantValues[$participantID];
$this->assign('isPrimary', 0);
$this->assign('customProfile', NULL);
//Additional Participant should get only it's payment information
if (!empty($this->_amount)) {
$amount = array();
$params = $this->get('params');
$amount[$participantNum]['label'] = preg_replace('//', '', $params[$participantNum]['amount_level']);
$amount[$participantNum]['amount'] = $params[$participantNum]['amount'];
$this->assign('amounts', $amount);
}
if ($this->_lineItem) {
$lineItems = $this->_lineItem;
$lineItem = array();
if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) {
$lineItem[] = $lineItemValue;
}
if ($invoicing) {
$individual = $this->get('individual');
$dataArray[key($dataArray)] = $individual[$participantNum]['totalTaxAmt'];
$this->assign('dataArray', $dataArray);
$this->assign('totalAmount', $individual[$participantNum]['totalAmtWithTax']);
$this->assign('totalTaxAmount', $individual[$participantNum]['totalTaxAmt']);
$this->assign('individual', array($individual[$participantNum]));
}
$this->assign('lineItem', $lineItem);
}
$this->_values['params']['additionalParticipant'] = TRUE;
$this->assign('isAdditionalParticipant', $this->_values['params']['additionalParticipant']);
}
//pass these variables since these are run time calculated.
$this->_values['params']['isOnWaitlist'] = $this->_allowWaitlist;
$this->_values['params']['isRequireApproval'] = $this->_requireApproval;
//send mail to primary as well as additional participants.
$this->assign('contactID', $contactId);
$this->assign('participantID', $participantID);
CRM_Event_BAO_Event::sendMail($contactId, $this->_values, $participantID, $isTest);
}
}
}