/** * process the form after the input has been submitted and validated * * @access public * * @return None */ public function postProcess() { $params = $this->exportValues(); $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); if (isset($params['field'])) { foreach ($params['field'] as $key => $value) { //check for custom data $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, CRM_Core_DAO::$_nullObject, $key, 'Participant'); $value['id'] = $key; if (CRM_Utils_Array::value('participant_register_date', $value)) { $value['register_date'] = CRM_Utils_Date::processDate($value['participant_register_date'], $value['participant_register_date_time']); } if (CRM_Utils_Array::value('participant_role', $value)) { $participantRoles = CRM_Event_PseudoConstant::participantRole(); if (is_array($value['participant_role'])) { $value['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value['participant_role'])); } else { $value['role_id'] = $value['participant_role']; } } //need to send mail when status change $statusChange = FALSE; $relatedStatusChange = FALSE; if (CRM_Utils_Array::value('participant_status', $value)) { $value['status_id'] = $value['participant_status']; $fromStatusId = CRM_Utils_Array::value($key, $this->_fromStatusIds); if (!$fromStatusId) { $fromStatusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $key, 'status_id'); } if ($fromStatusId != $value['status_id']) { $relatedStatusChange = TRUE; } if ($statusClasses[$fromStatusId] != $statusClasses[$value['status_id']]) { $statusChange = TRUE; } } if (CRM_Utils_Array::value('participant_source', $value)) { $value['source'] = $value['participant_source']; } unset($value['participant_register_date']); unset($value['participant_status']); unset($value['participant_source']); CRM_Event_BAO_Participant::create($value); //need to trigger mails when we change status if ($statusChange) { CRM_Event_BAO_Participant::transitionParticipants(array($key), $value['status_id'], $fromStatusId); } if ($relatedStatusChange) { //update related contribution status, CRM-4395 self::updatePendingOnlineContribution($key, $value['status_id']); } } CRM_Core_Session::setStatus(ts('The updates have been saved.'), ts('Saved'), 'success'); } else { CRM_Core_Session::setStatus(ts('No updates have been saved.'), ts('Not Saved'), 'alert'); } }
/** * 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; }
/** * 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 array rows in the given offset and rowCount */ 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); require_once 'CRM/Event/BAO/Event.php'; require_once 'CRM/Event/PseudoConstant.php'; $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); while ($result->fetch()) { $row = array(); // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->{$property})) { $row[$property] = $result->{$property}; } } // gross hack to show extra information for pending status $statusClass = null; if ($statusId = array_search($row['participant_status_id'], $statusTypes)) { $statusClass = $statusClasses[$statusId]; } $extraInfo = array(); $row['showConfirmUrl'] = false; if ($statusClass == 'Pending') { $row['showConfirmUrl'] = true; } if (CRM_Utils_Array::value('participant_is_test', $row)) { $extraInfo[] = ts('test'); } if ($extraInfo) { $row['participant_status_id'] .= ' (' . implode(', ', $extraInfo) . ')'; } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; $row['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context)); require_once 'CRM/Contact/BAO/Contact/Utils.php'; $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type); $row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']); if (CRM_Utils_Array::value('participant_fee_level', $row)) { CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']); } if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) { // add line item details if applicable require_once 'CRM/Price/BAO/LineItem.php'; $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']); } $rows[] = $row; } CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems); return $rows; }