function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $statusTypes = array(); $dao = new CRM_Event_DAO_ParticipantStatusType(); $dao->orderBy('weight'); $dao->find(); $visibilities = CRM_Core_PseudoConstant::visibility(); // these statuses are reserved, but disabled by default - so should be disablable after being enabled $disablable = array('On waitlist', 'Awaiting approval', 'Pending from waitlist', 'Pending from approval', 'Rejected'); while ($dao->fetch()) { CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]); $action = array_sum(array_keys($this->links())); if ($dao->is_reserved) { $action -= CRM_Core_Action::DELETE; if (!in_array($dao->name, $disablable)) { $action -= CRM_Core_Action::DISABLE; } } $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'participantStatusType.manage.action', 'ParticipantStatusType', $dao->id); $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id]; } $this->assign('rows', $statusTypes); }
static function retrieve(&$params, &$defaults) { $result = null; $dao = new CRM_Event_DAO_ParticipantStatusType(); $dao->copyValues($params); if ($dao->find(true)) { CRM_Core_DAO::storeValues($dao, $defaults); $result = $dao; } return $result; }
public function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_ParticipantStatusType'); $this->add('text', 'name', ts('Name'), NULL, TRUE); $this->add('text', 'label', ts('Label'), $attributes['label'], TRUE); $classes = array(); foreach (array('Positive', 'Pending', 'Waiting', 'Negative') as $class) { $classes[$class] = CRM_Event_DAO_ParticipantStatusType::tsEnum('class', $class); } $this->add('select', 'class', ts('Class'), $classes, TRUE); $this->add('checkbox', 'is_active', ts('Active?')); $this->add('checkbox', 'is_counted', ts('Counted?')); $this->add('text', 'weight', ts('Weight'), $attributes['weight'], TRUE); $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility(), TRUE); }
/** * Function to get events Summary * * @static * * @return array Array of event summary values */ static function getEventSummary() { $eventSummary = $eventIds = array(); $config = CRM_Core_Config::singleton(); // get permission and include them here // does not scale, but rearranging code for now // FIXME in a future release $permissions = CRM_Event_BAO_Event::checkPermission(); $validEventIDs = ''; if (empty($permissions[CRM_Core_Permission::VIEW])) { $eventSummary['total_events'] = 0; return $eventSummary; } else { $validEventIDs = " AND civicrm_event.id IN ( " . implode(',', array_values($permissions[CRM_Core_Permission::VIEW])) . " ) "; } // We're fetching recent and upcoming events (where start date is 7 days ago OR later) $query = "\nSELECT count(id) as total_events\nFROM civicrm_event\nWHERE civicrm_event.is_active = 1 AND\n ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0) AND\n civicrm_event.start_date >= DATE_SUB( NOW(), INTERVAL 7 day )\n {$validEventIDs}"; $dao = CRM_Core_DAO::executeQuery($query); if ($dao->fetch()) { $eventSummary['total_events'] = $dao->total_events; } if (empty($eventSummary) || $dao->total_events == 0) { return $eventSummary; } //get the participant status type values. $cpstObject = new CRM_Event_DAO_ParticipantStatusType(); $cpst = $cpstObject->getTableName(); $query = "SELECT id, name, label, class FROM {$cpst}"; $status = CRM_Core_DAO::executeQuery($query); $statusValues = array(); while ($status->fetch()) { $statusValues[$status->id]['id'] = $status->id; $statusValues[$status->id]['name'] = $status->name; $statusValues[$status->id]['label'] = $status->label; $statusValues[$status->id]['class'] = $status->class; } // Get the Id of Option Group for Event Types $optionGroupDAO = new CRM_Core_DAO_OptionGroup(); $optionGroupDAO->name = 'event_type'; $optionGroupId = NULL; if ($optionGroupDAO->find(TRUE)) { $optionGroupId = $optionGroupDAO->id; } // Get the event summary display preferences $show_max_events = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'show_events'); // default to 10 if no option is set if (is_null($show_max_events)) { $show_max_events = 10; } // show all events if show_events is set to a negative value if ($show_max_events >= 0) { $event_summary_limit = "LIMIT 0, {$show_max_events}"; } else { $event_summary_limit = ""; } $query = "\nSELECT civicrm_event.id as id, civicrm_event.title as event_title, civicrm_event.is_public as is_public,\n civicrm_event.max_participants as max_participants, civicrm_event.start_date as start_date,\n civicrm_event.end_date as end_date, civicrm_event.is_online_registration, civicrm_event.is_monetary, civicrm_event.is_show_location,civicrm_event.is_map as is_map, civicrm_option_value.label as event_type, civicrm_tell_friend.is_active as is_friend_active,\n civicrm_event.slot_label_id,\n civicrm_event.summary as summary,\n civicrm_pcp_block.id as is_pcp_enabled\nFROM civicrm_event\nLEFT JOIN civicrm_option_value ON (\n civicrm_event.event_type_id = civicrm_option_value.value AND\n civicrm_option_value.option_group_id = %1 )\nLEFT JOIN civicrm_tell_friend ON ( civicrm_tell_friend.entity_id = civicrm_event.id AND civicrm_tell_friend.entity_table = 'civicrm_event' )\nLEFT JOIN civicrm_pcp_block ON ( civicrm_pcp_block.entity_id = civicrm_event.id AND civicrm_pcp_block.entity_table = 'civicrm_event')\nWHERE civicrm_event.is_active = 1 AND\n ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0) AND\n civicrm_event.start_date >= DATE_SUB( NOW(), INTERVAL 7 day )\n {$validEventIDs}\nGROUP BY civicrm_event.id\nORDER BY civicrm_event.start_date ASC\n{$event_summary_limit}\n"; $eventParticipant = array(); $properties = array('id' => 'id', 'eventTitle' => 'event_title', 'isPublic' => 'is_public', 'maxParticipants' => 'max_participants', 'startDate' => 'start_date', 'endDate' => 'end_date', 'eventType' => 'event_type', 'isMap' => 'is_map', 'participants' => 'participants', 'notCountedDueToRole' => 'notCountedDueToRole', 'notCountedDueToStatus' => 'notCountedDueToStatus', 'notCountedParticipants' => 'notCountedParticipants'); $params = array(1 => array($optionGroupId, 'Integer')); $mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'civicrm_event', 'id', 'entity_value'); $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { foreach ($properties as $property => $name) { $set = NULL; switch ($name) { case 'is_public': if ($dao->{$name}) { $set = 'Yes'; } else { $set = 'No'; } $eventSummary['events'][$dao->id][$property] = $set; break; case 'is_map': if ($dao->{$name} && $config->mapAPIKey) { $values = array(); $ids = array(); $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event'); $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); if (is_numeric(CRM_Utils_Array::value('geo_code_1', $values['location']['address'][1])) || $config->mapGeoCoding && !empty($values['location']['address'][1]['city']) && !empty($values['location']['address'][1]['state_province_id'])) { $set = CRM_Utils_System::url('civicrm/contact/map/event', "reset=1&eid={$dao->id}"); } } $eventSummary['events'][$dao->id][$property] = $set; if (in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) { $eventSummary['events'][$dao->id]['configure'] = CRM_Utils_System::url('civicrm/admin/event', "action=update&id={$dao->id}&reset=1"); } break; case 'end_date': case 'start_date': $eventSummary['events'][$dao->id][$property] = CRM_Utils_Date::customFormat($dao->{$name}, NULL, array('d')); break; case 'participants': case 'notCountedDueToRole': case 'notCountedDueToStatus': case 'notCountedParticipants': $set = NULL; $propertyCnt = 0; if ($name == 'participants') { $propertyCnt = self::getParticipantCount($dao->id); if ($propertyCnt) { $set = CRM_Utils_System::url('civicrm/event/search', "reset=1&force=1&event={$dao->id}&status=true&role=true"); } } elseif ($name == 'notCountedParticipants') { $propertyCnt = self::getParticipantCount($dao->id, TRUE, FALSE, TRUE, FALSE); if ($propertyCnt) { // FIXME : selector fail to search w/ OR operator. // $set = CRM_Utils_System::url( 'civicrm/event/search', // "reset=1&force=1&event=$dao->id&status=false&role=false" ); } } elseif ($name == 'notCountedDueToStatus') { $propertyCnt = self::getParticipantCount($dao->id, TRUE, FALSE, FALSE, FALSE); if ($propertyCnt) { $set = CRM_Utils_System::url('civicrm/event/search', "reset=1&force=1&event={$dao->id}&status=false"); } } else { $propertyCnt = self::getParticipantCount($dao->id, FALSE, FALSE, TRUE, FALSE); if ($propertyCnt) { $set = CRM_Utils_System::url('civicrm/event/search', "reset=1&force=1&event={$dao->id}&role=false"); } } $eventSummary['events'][$dao->id][$property] = $propertyCnt; $eventSummary['events'][$dao->id][$name . '_url'] = $set; break; default: $eventSummary['events'][$dao->id][$property] = $dao->{$name}; break; } } // prepare the area for per-status participant counts $statusClasses = array('Positive', 'Pending', 'Waiting', 'Negative'); $eventSummary['events'][$dao->id]['statuses'] = array_fill_keys($statusClasses, array()); $eventSummary['events'][$dao->id]['friend'] = $dao->is_friend_active; $eventSummary['events'][$dao->id]['is_monetary'] = $dao->is_monetary; $eventSummary['events'][$dao->id]['is_online_registration'] = $dao->is_online_registration; $eventSummary['events'][$dao->id]['is_show_location'] = $dao->is_show_location; $eventSummary['events'][$dao->id]['is_subevent'] = $dao->slot_label_id; $eventSummary['events'][$dao->id]['is_pcp_enabled'] = $dao->is_pcp_enabled; $eventSummary['events'][$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mappingID); $statusTypes = CRM_Event_PseudoConstant::participantStatus(); foreach ($statusValues as $statusId => $statusValue) { if (!array_key_exists($statusId, $statusTypes)) { continue; } $class = $statusValue['class']; $statusCount = self::eventTotalSeats($dao->id, "( participant.status_id = {$statusId} )"); if ($statusCount) { $urlString = "reset=1&force=1&event={$dao->id}&status={$statusId}"; $statusInfo = array('url' => CRM_Utils_System::url('civicrm/event/search', $urlString), 'name' => $statusValue['name'], 'label' => $statusValue['label'], 'count' => $statusCount); $eventSummary['events'][$dao->id]['statuses'][$class][] = $statusInfo; } } } $countedRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1'); $nonCountedRoles = CRM_Event_PseudoConstant::participantRole(NULL, '( filter = 0 OR filter IS NULL )'); $countedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $nonCountedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, '( is_counted = 0 OR is_counted IS NULL )'); $countedStatusANDRoles = array_merge($countedStatus, $countedRoles); $nonCountedStatusANDRoles = array_merge($nonCountedStatus, $nonCountedRoles); $eventSummary['nonCountedRoles'] = implode('/', array_values($nonCountedRoles)); $eventSummary['nonCountedStatus'] = implode('/', array_values($nonCountedStatus)); $eventSummary['countedStatusANDRoles'] = implode('/', array_values($countedStatusANDRoles)); $eventSummary['nonCountedStatusANDRoles'] = implode('/', array_values($nonCountedStatusANDRoles)); return $eventSummary; }
/** * adds $value['foo_display'] for each $value['foo'] enum from civicrm_participant_status_type * * @param array $values (reference) the array up for enhancing * @return void */ static function addDisplayEnums(&$values) { $enumFields =& CRM_Event_DAO_ParticipantStatusType::getEnums(); foreach ($enumFields as $enum) { if (isset($values[$enum])) { $values[$enum . '_display'] = CRM_Event_DAO_ParticipantStatusType::tsEnum($enum, $values[$enum]); } } }
/** * Returns the list of fields that can be exported * * @param bool $prefix * * @return array */ static function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields = self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['participant_status_type'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }