本文整理汇总了PHP中CRM_Event_BAO_Participant::fixEventLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant::fixEventLevel方法的具体用法?PHP CRM_Event_BAO_Participant::fixEventLevel怎么用?PHP CRM_Event_BAO_Participant::fixEventLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Participant
的用法示例。
在下文中一共展示了CRM_Event_BAO_Participant::fixEventLevel方法的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: setDefaultValues
//.........这里部分代码省略.........
//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'))) {
$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 && !empty($form->_priceSet['fields'])) {
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' && !empty($values['is_full'])) {
continue;
}
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]));
}
}
//CRM-4453
if (!empty($defaults[$form->_pId]['participant_fee_currency'])) {
$form->assign('fee_currency', $defaults[$form->_pId]['participant_fee_currency']);
}
// CRM-4395
if ($contriId = $form->get('onlinePendingContributionId')) {
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->id = $contriId;
$contribution->find(TRUE);
foreach (array('financial_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', 'total_amount') as $f) {
if ($f == 'receive_date') {
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults($contribution->{$f});
} else {
$defaults[$form->_pId][$f] = $contribution->{$f};
}
}
}
return $defaults[$form->_pId];
}
示例3: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_contributionClause);
// process the result of the query
$rows = array();
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Contact/BAO/Contact/Utils.php';
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = null;
if ($this->_context != 'contribute') {
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, null, false, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', false, false, false, null, 'name', false);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (Pay Later)';
} else {
if (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (Incomplete Transaction)';
}
}
if ($row['is_test']) {
$row['contribution_type'] = $row['contribution_type'] . ' (test)';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink(self::links($componentId, $componentAction, $qfKey, $componentContext), $mask, $actions);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, false, $result->contact_id);
if (CRM_Utils_Array::value('amount_level', $row)) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}
示例4: array
//.........这里部分代码省略.........
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_contributionClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = NULL;
if ($this->_context != 'contribute') {
// @todo explain the significance of context & why we do not get these i that context.
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
// @todo explain when this condition might occur.
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
// CRM-17628 for some reason qfKey is not always set when searching from contribution search.
// as a result if the edit link is opened using right-click + open in new tab
// then the browser is not returned to the search results on save.
// This is an effort to getting the qfKey without, sadly, understanding the intent of those who came before me.
if (empty($qfKey)) {
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$links = self::links($componentId, $componentAction, $qfKey, $componentContext);
$checkLineItem = FALSE;
$row = array();
// Now check for lineItems
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
$lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($result->id);
foreach ($lineItems as $items) {
if (!CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
$checkLineItem = TRUE;
break;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
if ($checkLineItem) {
continue;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
// @todo - I can't find any evidence that 'carrying' the campaign on selectors actually
// results in it being displayed anywhere so why do we do this???
$row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->contribution_campaign_id;
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
$links[CRM_Core_Action::ADD] = array('name' => ts('Pay with Credit Card'), 'url' => 'civicrm/contact/view/contribution', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%&mode=live', 'title' => ts('Pay with Credit Card'));
} elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')';
}
if ($row['is_test']) {
$row['financial_type'] = $row['financial_type'] . ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink($links, $mask, $actions, ts('more'), FALSE, 'contribution.selector.row', 'Contribution', $result->contribution_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
if (!empty($row['amount_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}
示例5: array
//.........这里部分代码省略.........
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
if ($this->_includeSoftCredits) {
// especial sort order when rows include soft credits
$sort = "civicrm_contribution.receive_date DESC, civicrm_contribution.id, civicrm_contribution_soft.id";
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_contributionClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = NULL;
if ($this->_context != 'contribute') {
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$links = self::links($componentId, $componentAction, $qfKey, $componentContext);
$checkLineItem = FALSE;
$row = array();
// Now check for lineItems
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
$lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($result->id);
foreach ($lineItems as $items) {
if (!CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
$checkLineItem = TRUE;
break;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
if ($checkLineItem) {
continue;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->contribution_campaign_id;
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
} elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')';
}
if ($row['is_test']) {
$row['financial_type'] = $row['financial_type'] . ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink($links, $mask, $actions, ts('more'), FALSE, 'contribution.selector.row', 'Contribution', $result->contribution_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
if (!empty($row['amount_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}
示例6: alterDisplay
/**
* Alter row display.
*
* @param array $rows
*/
public function alterDisplay(&$rows) {
// custom code to alter rows
$entryFound = FALSE;
$eventType = CRM_Core_OptionGroup::values('event_type');
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
$honorTypes = CRM_Core_OptionGroup::values('honor_type', FALSE, FALSE, FALSE, NULL, 'label');
$genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id', array('localize' => TRUE));
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
if ($value = $row['civicrm_participant_event_id']) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income',
'reset=1&force=1&id_op=in&id_value=' . $value,
$this->_absoluteUrl, $this->_id, $this->_drilldownReport
);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = TRUE;
}
// handle event type id
if (array_key_exists('civicrm_event_event_type_id', $row)) {
if ($value = $row['civicrm_event_event_type_id']) {
$rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value];
}
$entryFound = TRUE;
}
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
if ($value = $row['civicrm_participant_status_id']) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, FALSE, 'label');
}
$entryFound = TRUE;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
if ($value = $row['civicrm_participant_role_id']) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
$value = array();
foreach ($roles as $role) {
$value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
$rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
}
$entryFound = TRUE;
}
// Handle value separator in Fee Level
if (array_key_exists('civicrm_participant_participant_fee_level', $row)) {
if ($value = $row['civicrm_participant_participant_fee_level']) {
CRM_Event_BAO_Participant::fixEventLevel($value);
$rows[$rowNum]['civicrm_participant_participant_fee_level'] = $value;
}
$entryFound = TRUE;
}
// Convert display name to link
if (($displayName = CRM_Utils_Array::value('civicrm_contact_sort_name', $row)) &&
($cid = CRM_Utils_Array::value('civicrm_contact_id', $row)) &&
($id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row))
) {
$url = CRM_Report_Utils_Report::getNextUrl('contact/detail',
"reset=1&force=1&id_op=eq&id_value=$cid",
$this->_absoluteUrl, $this->_id, $this->_drilldownReport
);
$viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant",
"reset=1&id=$id&cid=$cid&action=view&context=participant"
);
$contactTitle = ts('View Contact Details');
$participantTitle = ts('View Participant Record');
$rows[$rowNum]['civicrm_contact_sort_name'] = "<a title='$contactTitle' href=$url>$displayName</a>";
if ($this->_outputMode !== 'csv' && $this->_outputMode !== 'pdf' && $this->_outputMode !== 'print') {
$rows[$rowNum]['civicrm_contact_sort_name'] .= "<span style='float: right;'>
<a title='$participantTitle' href=$viewUrl> " . ts('View') . "</a></span>";
}
$entryFound = TRUE;
}
// Handle country id
if (array_key_exists('civicrm_address_country_id', $row)) {
if ($value = $row['civicrm_address_country_id']) {
//.........这里部分代码省略.........
示例7: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Core/DAO.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'] = 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 (CRM_Utils_Array::value('participant_registered_by_id', $values[$participantID])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
require_once 'CRM/Contact/BAO/Contact.php';
$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);
$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 (!CRM_Utils_Array::value('event', $values[$participantID])) {
$values[$participantID]['event'] = $eventTitle;
}
$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");
$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");
}
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$displayName = CRM_Contact_BAO_Contact::displayName($contactID);
$participantCount = array();
foreach ($lineItem as $k => $v) {
if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) {
$participantCount[] = $lineItem['participant_count'];
}
}
if ($participantCount) {
$this->assign('pricesetFieldsCount', $participantCount);
}
$this->assign('displayName', $displayName);
$title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
require_once 'CRM/Core/DAO.php';
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
$viewRoles = array();
foreach (explode($sep, $values[$participantID]['role_id']) as $k => $v) {
//.........这里部分代码省略.........
示例8: 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);
}
示例9: 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]));
}
//.........这里部分代码省略.........
示例10: setDefaultValues
public function setDefaultValues()
{
$params = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_eventId);
$priceSetValues = CRM_Event_Form_EventFees::setDefaultPriceSet($this->_participantId, $this->_eventId, FALSE);
$priceFieldId = array_keys($this->_values['fee']);
if (!empty($priceSetValues)) {
$defaults[$this->_participantId] = array_merge($defaults[$this->_participantId], $priceSetValues);
} else {
foreach ($priceFieldId as $key => $value) {
if (!empty($value) && ($this->_values['fee'][$value]['html_type'] == 'Radio' || $this->_values['fee'][$value]['html_type'] == 'Select') && !$this->_values['fee'][$value]['is_required']) {
$fee_keys = array_keys($this->_values['fee']);
$defaults[$this->_participantId]['price_' . $fee_keys[$key]] = 0;
}
}
}
$this->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
if ($this->_action == CRM_Core_Action::UPDATE) {
$fee_level = $defaults[$this->_participantId]['fee_level'];
CRM_Event_BAO_Participant::fixEventLevel($fee_level);
$this->assign('fee_level', $fee_level);
$this->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
}
$defaults = $defaults[$this->_participantId];
return $defaults;
}
示例11: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = false;
$eventType = CRM_Core_OptionGroup::values('event_type');
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
if ($value = $row['civicrm_participant_event_id']) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, false);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $value, $this->_absoluteUrl, $this->_id);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = true;
}
// handle event type id
if (array_key_exists('civicrm_event_event_type_id', $row)) {
if ($value = $row['civicrm_event_event_type_id']) {
$rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value];
}
$entryFound = true;
}
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
if ($value = $row['civicrm_participant_status_id']) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, false);
}
$entryFound = true;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
if ($value = $row['civicrm_participant_role_id']) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
$value = array();
foreach ($roles as $role) {
$value[$role] = CRM_Event_PseudoConstant::participantRole($role, false);
}
$rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
}
$entryFound = true;
}
// Handel value seperator in Fee Level
if (array_key_exists('civicrm_participant_participant_fee_level', $row)) {
if ($value = $row['civicrm_participant_participant_fee_level']) {
CRM_Event_BAO_Participant::fixEventLevel($value);
$rows[$rowNum]['civicrm_participant_participant_fee_level'] = $value;
}
$entryFound = true;
}
// Convert display name to link
if (array_key_exists('civicrm_contact_display_name', $row) && $rows[$rowNum]['civicrm_contact_display_name'] && array_key_exists('civicrm_contact_id', $row)) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $row['civicrm_contact_id'], $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_display_name_link'] = $url;
$rows[$rowNum]['civicrm_contact_display_name_hover'] = ts("View Contact Summary for this Contact.");
$entryFound = true;
}
// Handle country id
if (array_key_exists('civicrm_address_country_id', $row)) {
if ($value = $row['civicrm_address_country_id']) {
$rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, true);
}
$entryFound = true;
}
// Handle state/province id
if (array_key_exists('civicrm_address_state_province_id', $row)) {
if ($value = $row['civicrm_address_state_province_id']) {
$rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, true);
}
$entryFound = true;
}
// Handle employer id
if (array_key_exists('civicrm_contact_employer_id', $row)) {
if ($value = $row['civicrm_contact_employer_id']) {
$rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($value);
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_employer_id_link'] = $url;
$rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.');
}
}
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
break;
}
}
}
示例12: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
if ($this->_includeSoftCredits) {
// especial sort order when rows include soft credits
$sort = "civicrm_contribution.receive_date DESC, civicrm_contribution.id, civicrm_contribution_soft.id";
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_contributionClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = NULL;
if ($this->_context != 'contribute') {
// @todo explain the significance of context & why we do not get these i that context.
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
// @todo explain when this condition might occur.
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
// CRM-17628 for some reason qfKey is not always set when searching from contribution search.
// as a result if the edit link is opened using right-click + open in new tab
// then the browser is not returned to the search results on save.
// This is an effort to getting the qfKey without, sadly, understanding the intent of those who came before me.
if (empty($qfKey)) {
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->contribution_campaign_id;
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
} elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')';
}
if ($row['is_test']) {
$row['financial_type'] = $row['financial_type'] . ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink(self::links($componentId, $componentAction, $qfKey, $componentContext), $mask, $actions, ts('more'), FALSE, 'contribution.selector.row', 'Contribution', $result->contribution_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
if (!empty($row['amount_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}
示例13: setDefaultValues
//.........这里部分代码省略.........
// // 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 {
$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]));
}
} else {
$optionGroupId = NULL;
// 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) {
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $form->_originalDiscountId, 'option_group_id');
$defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId;
}
}
}
if ($form->_action == CRM_Core_Action::ADD) {
// this case is for add mode, where we show discount automatically
if (!isset($form->_discountId)) {
$discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
} else {
$discountId = $form->_discountId;
}
if ($form->_eventId && $discountId) {
$defaultDiscountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'default_discount_fee_id');
if ($defaultDiscountId) {
$discountKey = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $defaultDiscountId, 'weight');
}
$defaults[$form->_pId]['discount_id'] = $discountId;
$defaults[$form->_pId]['amount'] = key(array_slice($form->_values['discount'][$discountId], $discountKey - 1, $discountKey, TRUE));
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id');
示例14: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = FALSE;
$eventType = CRM_Core_OptionGroup::values('event_type');
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
if ($value = $row['civicrm_participant_event_id']) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $value, $this->_absoluteUrl, $this->_id);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = TRUE;
}
// handle event type id
if (array_key_exists('civicrm_event_event_type_id', $row)) {
if ($value = $row['civicrm_event_event_type_id']) {
$rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value];
}
$entryFound = TRUE;
}
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
if ($value = $row['civicrm_participant_status_id']) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, FALSE, 'label');
}
$entryFound = TRUE;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
if ($value = $row['civicrm_participant_role_id']) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
$value = array();
foreach ($roles as $role) {
$value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
$rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
}
$entryFound = TRUE;
}
// Handel value seperator in Fee Level
if (array_key_exists('civicrm_participant_participant_fee_level', $row)) {
if ($value = $row['civicrm_participant_participant_fee_level']) {
CRM_Event_BAO_Participant::fixEventLevel($value);
$rows[$rowNum]['civicrm_participant_participant_fee_level'] = $value;
}
$entryFound = TRUE;
}
// Convert display name to link
if (($displayName = CRM_Utils_Array::value('civicrm_contact_sort_name_linked', $row)) && ($cid = CRM_Utils_Array::value('civicrm_contact_id', $row)) && ($id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row))) {
$url = CRM_Report_Utils_Report::getNextUrl('contact/detail', "reset=1&force=1&id_op=eq&id_value={$cid}", $this->_absoluteUrl, $this->_id);
$viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant", "reset=1&id={$id}&cid={$cid}&action=view&context=participant");
$contactTitle = ts('View Contact Details');
$participantTitle = ts('View Participant Record');
$rows[$rowNum]['civicrm_contact_sort_name_linked'] = "<a title='{$contactTitle}' href={$url}>{$displayName}</a>";
if ($this->_outputMode !== 'csv') {
$rows[$rowNum]['civicrm_contact_sort_name_linked'] .= "<span style='float: right;'><a title='{$participantTitle}' href={$viewUrl}>" . ts('View') . "</a></span>";
}
$entryFound = TRUE;
}
// Handle country id
if (array_key_exists('civicrm_address_country_id', $row)) {
if ($value = $row['civicrm_address_country_id']) {
$rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, TRUE);
}
$entryFound = TRUE;
}
// Handle state/province id
if (array_key_exists('civicrm_address_state_province_id', $row)) {
if ($value = $row['civicrm_address_state_province_id']) {
$rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, TRUE);
}
$entryFound = TRUE;
}
// Handle employer id
if (array_key_exists('civicrm_contact_employer_id', $row)) {
if ($value = $row['civicrm_contact_employer_id']) {
$rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($value);
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_employer_id_link'] = $url;
$rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.');
}
}
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
break;
}
}
}
示例15: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return array
* rows in the given offset and rowCount
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_eventClause);
// process the result of the query
$rows = array();
//lets handle view, edit and delete separately. CRM-4418
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit event participants')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$statusTypes = CRM_Event_PseudoConstant::participantStatus();
$statusClasses = CRM_Event_PseudoConstant::participantStatusClass();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->participant_campaign_id;
// gross hack to show extra information for pending status
$statusClass = NULL;
if (isset($row['participant_status_id']) && ($statusId = array_search($row['participant_status_id'], $statusTypes))) {
$statusClass = $statusClasses[$statusId];
}
$row['showConfirmUrl'] = $statusClass == 'Pending' ? TRUE : FALSE;
if (!empty($row['participant_is_test'])) {
$row['participant_status'] .= ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id;
$links = self::links($this->_key, $this->_context, $this->_compContext);
if ($statusTypes[$row['participant_status_id']] == 'Partially paid') {
$links[CRM_Core_Action::ADD] = array('name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment'));
}
if ($statusTypes[$row['participant_status_id']] == 'Pending refund') {
$links[CRM_Core_Action::ADD] = array('name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund'));
}
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'participant.selector.row', 'Participant', $result->participant_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']);
if (!empty($row['participant_fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']);
}
if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
// add line item details if applicable
$lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
}
if (!empty($row['participant_role_id'])) {
$viewRoles = array();
foreach (explode($sep, $row['participant_role_id']) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
}
$row['participant_role_id'] = implode(', ', $viewRoles);
}
$rows[] = $row;
}
CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems);
return $rows;
}