本文整理汇总了PHP中CRM_Event_BAO_Event::getEvents方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event::getEvents方法的具体用法?PHP CRM_Event_BAO_Event::getEvents怎么用?PHP CRM_Event_BAO_Event::getEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Event
的用法示例。
在下文中一共展示了CRM_Event_BAO_Event::getEvents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Find Totals for Events');
/**
* Define the search form fields here
*/
$form->addElement('checkbox', 'paid_online', ts('Only show Credit Card Payments'));
$form->addElement('checkbox', 'show_payees', ts('Show payees'));
$event_type = CRM_Core_OptionGroup::values('event_type', FALSE);
foreach ($event_type as $eventId => $eventName) {
$form->addElement('checkbox', "event_type_id[{$eventId}]", 'Event Type', $eventName);
}
$events = CRM_Event_BAO_Event::getEvents(1);
$form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events);
$form->addDate('start_date', ts('Payments Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id'));
}
示例2: buildQuickForm
function buildQuickForm()
{
$events = CRM_Event_BAO_Event::getEvents(0);
$additionalOptions = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10');
if ($this->_soInstance) {
$soInstances = (array) $this->_soInstance;
$numString = $this->_soInstance;
$aEvents = array();
foreach ($events as $eventId => $eventVal) {
if (!array_key_exists($eventId, $this->_getreturn)) {
$aEvents[$eventId] = $eventVal;
}
}
$events = $aEvents;
} elseif (!empty($this->_getreturn)) {
$soInstances = range(1, count($this->_getreturn), 1);
$numString = 2;
} else {
$soInstances = array(1);
$numString = 1;
}
$allEvents = CRM_Event_BAO_Event::getEvents(0);
if ($soInstances[0] <= count($allEvents)) {
foreach ($soInstances as $instance) {
$this->addElement('select', "event_id_{$instance}", ts('Event Name'), array('' => ts('- select -')) + $events);
$this->addElement('select', "additional_participants_{$instance}", ts('Max_Participants'), $additionalOptions);
}
}
$this->assign('numStrings', $numString);
$cancelURL = CRM_Utils_System::url('civicrm/participant/config', 'reset=1');
$this->assign('elementNames', $this->getRenderableElementNames());
if ($this->_soInstance) {
return;
}
$cancelURL = CRM_Utils_System::url('civicrm/participant/config', 'reset=1');
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"))));
$this->addFormRule(array('CRM_maxadditionalparticipants_Form_Admin', 'formRule'), $this);
}
示例3: addActivity
/**
* Add activity for Membership/Event/Contribution.
*
* @param object $activity
* (reference) particular component object.
* @param string $activityType
* For Membership Signup or Renewal.
* @param int $targetContactID
*
* @return bool|NULL
*/
public static function addActivity(&$activity, $activityType = 'Membership Signup', $targetContactID = NULL)
{
if ($activity->__table == 'civicrm_membership') {
$membershipType = CRM_Member_PseudoConstant::membershipType($activity->membership_type_id);
if (!$membershipType) {
$membershipType = ts('Membership');
}
$subject = "{$membershipType}";
if (!empty($activity->source) && $activity->source != 'null') {
$subject .= " - {$activity->source}";
}
if ($activity->owner_membership_id) {
$query = "\nSELECT display_name\n FROM civicrm_contact, civicrm_membership\n WHERE civicrm_contact.id = civicrm_membership.contact_id\n AND civicrm_membership.id = {$activity->owner_membership_id}\n";
$displayName = CRM_Core_DAO::singleValueQuery($query);
$subject .= " (by {$displayName})";
}
$subject .= " - Status: " . CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $activity->status_id, 'label');
// CRM-72097 changed from start date to today
$date = date('YmdHis');
$component = 'Membership';
} elseif ($activity->__table == 'civicrm_participant') {
$event = CRM_Event_BAO_Event::getEvents(1, $activity->event_id, TRUE, FALSE);
$roles = CRM_Event_PseudoConstant::participantRole();
$status = CRM_Event_PseudoConstant::participantStatus();
$subject = $event[$activity->event_id];
if (!empty($roles[$activity->role_id])) {
$subject .= ' - ' . $roles[$activity->role_id];
}
if (!empty($status[$activity->status_id])) {
$subject .= ' - ' . $status[$activity->status_id];
}
$date = date('YmdHis');
if ($activityType != 'Email') {
$activityType = 'Event Registration';
}
$component = 'Event';
} elseif ($activity->__table == 'civicrm_contribution') {
// create activity record only for Completed Contributions
if ($activity->contribution_status_id != 1) {
return NULL;
}
$subject = NULL;
$subject .= CRM_Utils_Money::format($activity->total_amount, $activity->currency);
if (!empty($activity->source) && $activity->source != 'null') {
$subject .= " - {$activity->source}";
}
$date = CRM_Utils_Date::isoToMysql($activity->receive_date);
$activityType = $component = 'Contribution';
}
$activityParams = array('source_contact_id' => $activity->contact_id, 'source_record_id' => $activity->id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'is_test' => $activity->is_test, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => TRUE, 'campaign_id' => $activity->campaign_id);
// create activity with target contacts
$session = CRM_Core_Session::singleton();
$id = $session->get('userID');
if ($id) {
$activityParams['source_contact_id'] = $id;
$activityParams['target_contact_id'][] = $activity->contact_id;
}
// CRM-14945
if (property_exists($activity, 'details')) {
$activityParams['details'] = $activity->details;
}
//CRM-4027
if ($targetContactID) {
$activityParams['target_contact_id'][] = $targetContactID;
}
if (is_a(self::create($activityParams), 'CRM_Core_Error')) {
CRM_Core_Error::fatal("Failed creating Activity for {$component} of id {$activity->id}");
return FALSE;
}
}
示例4: buildQillForFieldValue
/**
* Build qill for field.
*
* Qill refers to the query detail visible on the UI.
*
* @param string $daoName
* @param string $fieldName
* @param mixed $fieldValue
* @param string $op
* @param array $pseudoExtraParam
* @param int $type
* Type of the field per CRM_Utils_Type
*
* @return array
*/
public static function buildQillForFieldValue($daoName, $fieldName, $fieldValue, $op, $pseudoExtraParam = array(), $type = CRM_Utils_Type::T_STRING)
{
$qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators();
// if Operator chosen is NULL/EMPTY then
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
return array(CRM_Utils_Array::value($op, $qillOperators, $op), '');
}
if ($fieldName == 'activity_type_id') {
$pseudoOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
} elseif ($fieldName == 'country_id') {
$pseduoOptions = CRM_Core_PseudoConstant::country();
} elseif ($fieldName == 'county_id') {
$pseduoOptions = CRM_Core_PseudoConstant::county();
} elseif ($fieldName == 'world_region') {
$pseduoOptions = CRM_Core_PseudoConstant::worldRegion();
} elseif ($daoName == 'CRM_Event_DAO_Event' && $fieldName == 'id') {
$pseudoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, TRUE, TRUE);
} elseif ($fieldName == 'contribution_product_id') {
$pseudoOptions = CRM_Contribute_PseudoConstant::products();
} elseif ($daoName == 'CRM_Contact_DAO_Group' && $fieldName == 'id') {
$pseudoOptions = CRM_Core_PseudoConstant::group();
} elseif ($fieldName == 'country_id') {
$pseudoOptions = CRM_Core_PseudoConstant::country();
} elseif ($daoName) {
$pseudoOptions = CRM_Core_PseudoConstant::get($daoName, $fieldName, $pseudoExtraParam);
}
//API usually have fieldValue format as array(operator => array(values)),
//so we need to separate operator out of fieldValue param
if (is_array($fieldValue) && in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($fieldValue);
$fieldValue = $fieldValue[$op];
}
if (is_array($fieldValue)) {
$qillString = array();
if (!empty($pseudoOptions)) {
foreach ((array) $fieldValue as $val) {
$qillString[] = CRM_Utils_Array::value($val, $pseudoOptions, $val);
}
$fieldValue = implode(', ', $qillString);
} else {
if ($type == CRM_Utils_Type::T_DATE) {
foreach ($fieldValue as $index => $value) {
$fieldValue[$index] = CRM_Utils_Date::customFormat($value);
}
}
$separator = ', ';
// @todo - this is a bit specific (one operator).
// However it is covered by a unit test so can be altered later with
// some confidence.
if ($op == 'BETWEEN') {
$separator = ' AND ';
}
$fieldValue = implode($separator, $fieldValue);
}
} elseif (!empty($pseudoOptions) && array_key_exists($fieldValue, $pseudoOptions)) {
$fieldValue = $pseudoOptions[$fieldValue];
} elseif ($type === CRM_Utils_Type::T_DATE) {
$fieldValue = CRM_Utils_Date::customFormat($fieldValue);
}
return array(CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue);
}
示例5: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
require_once 'CRM/Event/BAO/Event.php';
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_participantId, null, $this->_contactID, false, true)) - 1;
if ($additionalParticipant) {
$this->assign("additionalParticipant", $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single) {
$urlPath = 'civicrm/contact/view/participant';
$urlParams = "reset=1&cid={$this->_contactID}&context=participant";
if ($this->_context == 'standalone') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
$urlParams = "reset=1&context=standalone";
$urlPath = 'civicrm/participant/add';
}
if ($this->_participantId) {
$urlParams .= "&action=update&id={$this->_participantId}";
} else {
$urlParams .= "&action=add";
}
if (CRM_Utils_Request::retrieve('past', 'Boolean', $this)) {
$urlParams .= "&past=true";
}
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$url = CRM_Utils_System::url($urlPath, $urlParams, false, null, false);
} else {
$currentPath = CRM_Utils_System::currentPath();
$url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', false, null, false);
}
$this->assign("refreshURL", $url);
$url .= "&past=true";
$this->assign("pastURL", $url);
$events = array();
$this->assign("past", false);
require_once "CRM/Event/BAO/Event.php";
if (CRM_Utils_Request::retrieve('past', 'Boolean', $this) || $this->_action & CRM_Core_Action::UPDATE) {
$events = CRM_Event_BAO_Event::getEvents(true);
$this->assign("past", true);
} else {
$events = CRM_Event_BAO_Event::getEvents();
}
if ($this->_mode) {
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true);
}
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, true, array('onchange' => "buildFeeBlock( this.value ); buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} );", 'class' => 'huge'));
//frozen the field fix for CRM-4171
if ($this->_action & CRM_Core_Action::UPDATE && $this->_participantId) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id')) {
$element->freeze();
}
}
$this->addDateTime('register_date', ts('Registration Date'), true);
if ($this->_participantId) {
$this->assign('entityID', $this->_participantId);
}
$this->add('select', 'role_id', ts('Participant Role'), array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), true, array('onchange' => "buildCustomData( 'Participant', this.value, {$this->_roleCustomDataTypeID} );"));
// CRM-4395
$checkCancelledJs = array('onchange' => "return sendNotification( );");
if ($this->_onlinePendingContributionId) {
$cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus());
$cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(null, 'name'));
$checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});");
}
$this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(null, null, 'label'), true, $checkCancelledJs);
$this->addElement('checkbox', 'is_notify', ts('Send Notification'), null);
$this->add('text', 'source', ts('Event Source'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
//.........这里部分代码省略.........
示例6: buildQillForFieldValue
/**
* Build qill for field.
*
* Qill refers to the query detail visible on the UI.
*
* @param $daoName
* @param $fieldName
* @param $fieldValue
* @param $op
* @param array $pseduoExtraParam
*
* @return array
*/
public static function buildQillForFieldValue($daoName = NULL, $fieldName, $fieldValue, $op, $pseduoExtraParam = array())
{
$qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators();
if ($fieldName == 'activity_type_id') {
$pseduoOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
} elseif ($daoName == 'CRM_Event_DAO_Event' && $fieldName == 'id') {
$pseduoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, TRUE, TRUE);
} elseif ($fieldName == 'contribution_product_id') {
$pseduoOptions = CRM_Contribute_PseudoConstant::products();
} elseif ($daoName) {
$pseduoOptions = CRM_Core_PseudoConstant::get($daoName, $fieldName, $pseduoExtraParam = array());
}
//API usually have fieldValue format as array(operator => array(values)),
//so we need to separate operator out of fieldValue param
if (is_array($fieldValue) && in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($fieldValue);
$fieldValue = $fieldValue[$op];
}
if (is_array($fieldValue)) {
$qillString = array();
if (!empty($pseduoOptions)) {
foreach ((array) $fieldValue as $val) {
$qillString[] = $pseduoOptions[$val];
}
$fieldValue = implode(', ', $qillString);
} else {
$fieldValue = implode(', ', $fieldValue);
}
} elseif (!empty($pseduoOptions) && array_key_exists($fieldValue, $pseduoOptions)) {
$fieldValue = $pseduoOptions[$fieldValue];
}
return array(CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue);
}
示例7: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1;
if ($additionalParticipant) {
$deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
$this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
$this->setDefaults(array('delete_participant' => 1));
$this->assign('additionalParticipant', $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single) {
$urlPath = 'civicrm/contact/view/participant';
$urlParams = "reset=1&cid={$this->_contactId}&context=participant";
if ($this->_context == 'standalone') {
CRM_Contact_Form_NewContact::buildQuickForm($this);
$urlParams = 'reset=1&context=standalone';
$urlPath = 'civicrm/participant/add';
}
if ($this->_id) {
$urlParams .= "&action=update&id={$this->_id}";
} else {
$urlParams .= "&action=add";
}
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$url = CRM_Utils_System::url($urlPath, $urlParams, FALSE, NULL, FALSE);
} else {
$currentPath = CRM_Utils_System::currentPath();
$url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', FALSE, NULL, FALSE);
}
$this->assign('refreshURL', $url);
$this->add('hidden', 'past_event');
$events = array();
if ($this->_eID) {
$eventEndDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'end_date');
}
$this->assign('past', 0);
if ($this->_action & CRM_Core_Action::UPDATE) {
$events = CRM_Event_BAO_Event::getEvents(1, FALSE, FALSE);
} elseif ($this->getElementValue('past_event') || isset($eventEndDate) && CRM_Utils_Date::currentDBDate() > CRM_Utils_Date::processDate($eventEndDate)) {
$pastval = $this->getElementValue('past_event');
$events = CRM_Event_BAO_Event::getEvents($pastval);
$this->assign('past', $pastval);
} else {
$events = CRM_Event_BAO_Event::getEvents();
}
if ($this->_mode) {
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
// build array(event -> eventType) mapper
$query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0";
$dao = CRM_Core_DAO::executeQuery($query);
$eventAndTypeMapping = array();
while ($dao->fetch()) {
$eventAndTypeMapping[$dao->id] = $dao->event_type_id;
}
$eventAndTypeMapping = json_encode($eventAndTypeMapping);
// building of mapping ends --
//inherit the campaign from event.
$eventCampaigns = array();
$allEventIds = array_keys($events);
if (!empty($allEventIds)) {
CRM_Core_PseudoConstant::populate($eventCampaigns, 'CRM_Event_DAO_Event', TRUE, 'campaign_id');
}
$eventCampaigns = json_encode($eventCampaigns);
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, TRUE, array('onchange' => "buildFeeBlock( this.value ); CRM.buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' ); loadCampaign( this.value, {$eventCampaigns} );", 'class' => 'huge'));
// CRM-6111
// note that embedding JS within PHP files is quite awful, IMO
// but we do the same for the onChange element and this form is complex
// and i did not want to break it late in the 3.2 cycle
$preloadJSSnippet = NULL;
//.........这里部分代码省略.........
示例8: eventList
function eventList()
{
$listparams = CRM_Utils_Array::value('listall', $_REQUEST, 1);
$events = CRM_Event_BAO_Event::getEvents($listparams);
$elements = array(array('name' => ts('- select -'), 'value' => ''));
foreach ($events as $id => $name) {
$elements[] = array('name' => $name, 'value' => $id);
}
CRM_Utils_JSON::output($elements);
}
示例9: buildQuickForm
public function buildQuickForm()
{
if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) {
$this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => ' ', 'isDefault' => TRUE)));
return;
}
$ccPane = NULL;
if ($this->_mode) {
if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
$ccPane = array(ts('Direct Debit Information') => 'DirectDebit');
} else {
$ccPane = array(ts('Credit Card Information') => 'CreditCard');
}
$defaults = $this->_values;
$showAdditionalInfo = FALSE;
foreach ($ccPane as $name => $type) {
if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
$showAdditionalInfo = TRUE;
$allPanes[$name]['open'] = 'true';
}
$urlParams = "snippet=4&formType={$type}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$open = 'false';
if ($type == 'CreditCard' || $type == 'DirectDebit') {
$open = 'true';
}
$allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/payment/add', $urlParams), 'open' => $open, 'id' => $type);
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
$qfKey = $this->controller->_key;
$this->assign('qfKey', $qfKey);
$this->assign('allPanes', $allPanes);
$this->assign('showAdditionalInfo', $showAdditionalInfo);
if ($this->_formType) {
$this->assign('formType', $this->_formType);
return;
}
}
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialTrxn');
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL);
$label = $this->_refund ? ts('Refund Amount') : ts('Payment Amount');
$this->addMoney('total_amount', $label, FALSE, $attributes['total_amount'], TRUE, 'currency', NULL);
$this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
$this->add('text', 'check_number', ts('Check Number'), $attributes['financial_trxn_check_number']);
$this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']);
//add receipt for offline contribution
$this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'));
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']);
$this->add('textarea', 'receipt_text', ts('Confirmation Message'));
// add various dates
$dateLabel = $this->_refund ? ts('Refund Date') : ts('Date Received');
$this->addDateTime('trxn_date', $dateLabel, FALSE, array('formatType' => 'activityDateTime'));
if ($this->_contactId && $this->_id) {
if ($this->_component == 'event') {
$eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
$event = CRM_Event_BAO_Event::getEvents(0, $eventId);
$this->assign('eventName', $event[$eventId]);
}
}
$this->assign('displayName', $this->_contributorDisplayName);
$this->assign('component', $this->_component);
$this->assign('email', $this->_contributorEmail);
$this->add('text', 'fee_amount', ts('Fee Amount'), $attributes['fee_amount']);
$this->addRule('fee_amount', ts('Please enter a valid monetary value for Fee Amount.'), 'money');
$this->add('text', 'net_amount', ts('Net Amount'), $attributes['net_amount']);
$this->addRule('net_amount', ts('Please enter a valid monetary value for Net Amount.'), 'money');
$js = NULL;
if (!$this->_mode) {
$js = array('onclick' => "return verify( );");
}
$buttonName = $this->_refund ? 'Record Refund' : 'Record Payment';
$this->addButtons(array(array('type' => 'upload', 'name' => ts('%1', array(1 => $buttonName)), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$mailingInfo = Civi::settings()->get('mailing_backend');
$this->assign('outBound_option', $mailingInfo['outBound_option']);
$this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this);
}
示例10: checkACLPermission
/**
* Check API for ACL permission.
*
* @param array $apiRequest
*
* @return bool
*/
public function checkACLPermission($apiRequest)
{
switch ($apiRequest['entity']) {
case 'UFGroup':
case 'UFField':
$ufGroups = \CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
$aclCreate = \CRM_ACL_API::group(\CRM_Core_Permission::CREATE, NULL, 'civicrm_uf_group', $ufGroups);
$aclEdit = \CRM_ACL_API::group(\CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', $ufGroups);
$ufGroupId = $apiRequest['entity'] == 'UFGroup' ? $apiRequest['params']['id'] : $apiRequest['params']['uf_group_id'];
if (in_array($ufGroupId, $aclEdit) or $aclCreate) {
return TRUE;
}
break;
//CRM-16777: Disable schedule reminder with ACLs.
//CRM-16777: Disable schedule reminder with ACLs.
case 'ActionSchedule':
$events = \CRM_Event_BAO_Event::getEvents();
$aclEdit = \CRM_ACL_API::group(\CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $events);
$param = array('id' => $apiRequest['params']['id']);
$eventId = \CRM_Core_BAO_ActionSchedule::retrieve($param, $value = array());
if (in_array($eventId->entity_value, $aclEdit)) {
return TRUE;
}
break;
}
return FALSE;
}
示例11: buildQuickForm
public function buildQuickForm()
{
$statuses = CRM_Event_PseudoConstant::participantStatus();
$this->assign('partiallyPaid', array_search('Partially paid', $statuses));
$this->assign('pendingRefund', array_search('Pending refund', $statuses));
$this->assign('participantStatus', $this->_participantStatus);
$config = CRM_Core_Config::singleton();
$this->assign('currencySymbol', $config->defaultCurrencySymbol);
// line items block
$lineItem = $event = array();
$params = array('id' => $this->_eventId);
CRM_Event_BAO_Event::retrieve($params, $event);
//retrieve custom information
$this->_values = array();
CRM_Event_Form_Registration::initEventFee($this, $event['id']);
CRM_Event_Form_Registration_Register::buildAmount($this, TRUE);
if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $this->_values))) {
$lineItem[] = $this->_values['line_items'];
}
$this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
$event = CRM_Event_BAO_Event::getEvents(0, $this->_eventId);
$this->assign('eventName', $event[$this->_eventId]);
$statusOptions = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + $statusOptions, TRUE);
$this->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);"));
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']);
$this->add('textarea', 'receipt_text', ts('Confirmation Message'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
$buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE);
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_participantId)) {
$buttons[] = array('type' => 'upload', 'name' => ts('Save and Record Payment'), 'subName' => 'new');
}
$buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
$this->addButtons($buttons);
$this->addFormRule(array('CRM_Event_Form_ParticipantFeeSelection', 'formRule'), $this);
}
示例12: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
require_once 'CRM/Event/BAO/Event.php';
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, null, $this->_contactId, false, true)) - 1;
if ($additionalParticipant) {
$deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
$this->addRadio('delete_participant', null, $deleteParticipants, null, '<br />');
$this->setDefaults(array('delete_participant' => 1));
$this->assign("additionalParticipant", $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single) {
$urlPath = 'civicrm/contact/view/participant';
$urlParams = "reset=1&cid={$this->_contactId}&context=participant";
if ($this->_context == 'standalone') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
$urlParams = "reset=1&context=standalone";
$urlPath = 'civicrm/participant/add';
}
if ($this->_id) {
$urlParams .= "&action=update&id={$this->_id}";
} else {
$urlParams .= "&action=add";
}
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$url = CRM_Utils_System::url($urlPath, $urlParams, false, null, false);
} else {
$currentPath = CRM_Utils_System::currentPath();
$url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', false, null, false);
}
$this->assign("refreshURL", $url);
$this->add('hidden', 'past_event');
$events = array();
$this->assign("past", false);
require_once "CRM/Event/BAO/Event.php";
if ($this->_action & CRM_Core_Action::UPDATE) {
$events = CRM_Event_BAO_Event::getEvents(true, false, false);
} elseif ($this->getElementValue('past_event')) {
$events = CRM_Event_BAO_Event::getEvents(true);
$this->assign("past", true);
} else {
$events = CRM_Event_BAO_Event::getEvents();
}
if ($this->_mode) {
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true);
}
// build array(event -> eventType) mapper
$query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0";
$dao =& CRM_Core_DAO::executeQuery($query);
$eventAndTypeMapping = array();
while ($dao->fetch()) {
$eventAndTypeMapping[$dao->id] = $dao->event_type_id;
}
$eventAndTypeMapping = json_encode($eventAndTypeMapping);
// building of mapping ends --
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, true, array('onchange' => "buildFeeBlock( this.value ); buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );", 'class' => 'huge'));
// CRM-6111
// note that embedding JS within PHP files is quite awful, IMO
// but we do the same for the onChange element and this form is complex
// and i did not want to break it late in the 3.2 cycle
$preloadJSSnippet = null;
if (CRM_Utils_Array::value('reset', $_GET)) {
$this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
if ($this->_eID) {
$preloadJSSnippet = "\ncj(function() {\ncj('#event_id').val( '{$this->_eID}' );\nbuildFeeBlock( {$this->_eID} ); \nbuildCustomData( 'Participant', {$this->_eID}, {$this->_eventNameCustomDataTypeID} );\nbuildEventTypeCustomData( {$this->_eID}, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );\n});\n";
}
}
$this->assign('preloadJSSnippet', $preloadJSSnippet);
//frozen the field fix for CRM-4171
//.........这里部分代码省略.........
示例13: addActivity
/**
* Function to add activity for Membership/Event/Contribution
*
* @param object $activity (reference) perticular component object
* @param string $activityType for Membership Signup or Renewal
*
*
* @static
* @access public
*/
static function addActivity(&$activity, $activityType = 'Membership Signup', $targetContactID = null)
{
if ($activity->__table == 'civicrm_membership') {
require_once "CRM/Member/PseudoConstant.php";
$membershipType = CRM_Member_PseudoConstant::membershipType($activity->membership_type_id);
if (!$membershipType) {
$membershipType = ts('Membership');
}
$subject = "{$membershipType}";
if ($activity->source != 'null') {
$subject .= " - {$activity->source}";
}
if ($activity->owner_membership_id) {
$query = "\nSELECT display_name \n FROM civicrm_contact, civicrm_membership \n WHERE civicrm_contact.id = civicrm_membership.contact_id\n AND civicrm_membership.id = {$activity->owner_membership_id}\n";
$displayName = CRM_Core_DAO::singleValueQuery($query);
$subject .= " (by {$displayName})";
}
require_once 'CRM/Member/DAO/MembershipStatus.php';
$subject .= " - Status: " . CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $activity->status_id);
$date = $activity->start_date;
$component = 'Membership';
} else {
if ($activity->__table == 'civicrm_participant') {
require_once "CRM/Event/BAO/Event.php";
$event = CRM_Event_BAO_Event::getEvents(true, $activity->event_id);
require_once "CRM/Event/PseudoConstant.php";
$roles = CRM_Event_PseudoConstant::participantRole();
$status = CRM_Event_PseudoConstant::participantStatus();
$subject = $event[$activity->event_id];
if (CRM_Utils_Array::value($activity->role_id, $roles)) {
$subject .= ' - ' . $roles[$activity->role_id];
}
if (CRM_Utils_Array::value($activity->status_id, $status)) {
$subject .= ' - ' . $status[$activity->status_id];
}
$date = date('YmdHis');
$activityType = 'Event Registration';
$component = 'Event';
} else {
if ($activity->__table == 'civicrm_contribution') {
//create activity record only for Completed Contributions
if ($activity->contribution_status_id != 1) {
return;
}
$subject = null;
require_once "CRM/Utils/Money.php";
$subject .= CRM_Utils_Money::format($activity->total_amount, $activity->currency);
if ($activity->source != 'null') {
$subject .= " - {$activity->source}";
}
$date = CRM_Utils_Date::isoToMysql($activity->receive_date);
$activityType = $component = 'Contribution';
}
}
}
require_once "CRM/Core/OptionGroup.php";
$activityParams = array('source_contact_id' => $activity->contact_id, 'source_record_id' => $activity->id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'is_test' => $activity->is_test, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => true);
//CRM-4027
if ($targetContactID) {
$activityParams['target_contact_id'] = $targetContactID;
}
require_once 'api/v2/Activity.php';
if (is_a(civicrm_activity_create($activityParams), 'CRM_Core_Error')) {
CRM_Core_Error::fatal("Failed creating Activity for {$component} of id {$activity->id}");
return false;
}
}
示例14: eventList
function eventList()
{
$events = CRM_Event_BAO_Event::getEvents(TRUE);
$elements = array(array('name' => ts('- select -'), 'value' => ''));
foreach ($events as $id => $name) {
$elements[] = array('name' => $name, 'value' => $id);
}
echo json_encode($elements);
CRM_Utils_System::civiExit();
}
示例15: buildQillForFieldValue
/**
* Build qill for field.
*
* Qill refers to the query detail visible on the UI.
*
* @param $daoName
* @param $fieldName
* @param $fieldValue
* @param $op
* @param array $pseduoExtraParam
*
* @return array
*/
public static function buildQillForFieldValue($daoName, $fieldName, $fieldValue, $op, $pseduoExtraParam = array())
{
$qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators();
if ($fieldName == 'activity_type_id') {
$pseduoOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
} elseif ($daoName == 'CRM_Event_DAO_Event' && $fieldName == 'id') {
$pseduoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, TRUE, TRUE);
} else {
$pseduoOptions = CRM_Core_PseudoConstant::get($daoName, $fieldName, $pseduoExtraParam = array());
}
//For those $fieldName which don't have any associated pseudoconstant defined
if (empty($pseduoOptions)) {
if (is_array($fieldValue)) {
$op = key($fieldValue);
$fieldValue = $fieldValue[$op];
if (is_array($fieldValue)) {
$fieldValue = implode(', ', $fieldValue);
}
}
} elseif (is_array($fieldValue)) {
$qillString = array();
if (in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($fieldValue);
$fieldValue = $fieldValue[$op];
}
foreach ((array) $fieldValue as $val) {
$qillString[] = $pseduoOptions[$val];
}
$fieldValue = implode(', ', $qillString);
} else {
if (array_key_exists($fieldValue, $pseduoOptions)) {
$fieldValue = $pseduoOptions[$fieldValue];
}
}
return array(CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue);
}