$form->assign('dataURLEventFee', $dataURLEventFee);
- $eventId = $form->addEntityRef('event_id', ts('Event Name'), array(
+ $form->addEntityRef('event_id', ts('Event Name'), array(
'entity' => 'event',
'placeholder' => ts('- any -'),
'select' => array('minimumInputLength' => 0),
+ 'api' => array(
+ 'params' => array(
+ 'api.RecurringEntity.getcount' => array('entity_id' => "\$value.id", 'entity_table' => "civicrm_event"),
+ ),
+ ),
)
);
- $eventType = $form->addEntityRef('event_type_id', ts('Event Type'), array(
+ $form->addEntityRef('event_type_id', ts('Event Type'), array(
'entity' => 'option_value',
'placeholder' => ts('- any -'),
'select' => array('minimumInputLength' => 0),
$form->add('text', 'participant_fee_id', ts('Fee Level'), array('class' => 'big crm-ajax-select'));
CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
- $eventIncludeRepeatingEvents = &$form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include Repeating Events?'));
+
+ $form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', array(1 => '<em>%1</em>')));
$form->addSelect('participant_status_id',
array('entity' => 'participant', 'label' => ts('Participant Status'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['source_contact_id'], 'display_name'),
));
}
- foreach ($request['extra'] as $field) {
- $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
- }
$output[] = $data;
}
}
else {
$data['icon_class'] = $row['contact_type'];
}
- foreach ($request['extra'] as $field) {
- $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
- }
$output[] = $data;
}
}
if (!empty($row['summary'])) {
$data['description'][] = $row['summary'];
}
- foreach ($request['extra'] as $field) {
- $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
- }
$output[] = $data;
}
}
$fnName = function_exists($fnName) ? $fnName : '_civicrm_api3_generic_getlist_output';
$values = $fnName($result, $request);
+ _civicrm_api3_generic_getlist_postprocess($result, $request, $values);
+
$output = array('page_num' => $request['page_num']);
// Limit is set for searching but not fetching by id
if (!empty($request['image_field'])) {
$data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : '';
}
- foreach ($request['extra'] as $field) {
- $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
- }
$output[] = $data;
}
}
return $output;
}
+/**
+ * Common postprocess for getlist output
+ *
+ * @param $result
+ * @param $request
+ * @param $values
+ */
+function _civicrm_api3_generic_getlist_postprocess($result, $request, &$values) {
+ $chains = array();
+ foreach ($request['params'] as $field => $param) {
+ if (substr($field, 0, 4) === 'api.') {
+ $chains[] = $field;
+ }
+ }
+ if (!empty($result['values'])) {
+ foreach (array_values($result['values']) as $num => $row) {
+ foreach ($request['extra'] as $field) {
+ $values[$num]['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
+ }
+ foreach ($chains as $chain) {
+ $values[$num][$chain] = isset($row[$chain]) ? $row[$chain] : NULL;
+ }
+ }
+ }
+}
+
/**
* Provide metadata for this api
*
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * This api exposes CiviCRM recurring entity records.
+ *
+ * @package CiviCRM_APIv3
+ */
+
+/**
+ * Retrieve a recurring entity.
+ *
+ * @param array $params
+ * Input parameters.
+ *
+ * @return array
+ */
+function civicrm_api3_recurring_entity_get($params) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust Metadata for Get action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_recurring_entity_get_spec(&$params) {
+ $params['entity_table']['options'] = array(
+ 'civicrm_event' => 'civicrm_event',
+ 'civicrm_activity' => 'civicrm_activity',
+ );
+}
+
+/**
+ * Add or update a recurring entity.
+ *
+ * @param array $params
+ *
+ * @return array
+ */
+function civicrm_api3_recurring_entity_create($params) {
+ return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust Metadata for Create action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_recurring_entity_create_spec(&$params) {
+ $params['entity_table']['options'] = array(
+ 'civicrm_event' => 'civicrm_event',
+ 'civicrm_activity' => 'civicrm_activity',
+ );
+}
+
+/**
+ * Deletes an existing ReportInstance.
+ *
+ * @param array $params
+ *
+ * @return array
+ */
+function civicrm_api3_recurring_entity_delete($params) {
+ return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
*}
<tr>
<td class="crm-event-form-block-event_id">
- {$form.event_id.label} <br />{$form.event_id.html|crmAddClass:huge} <br/>
- {$form.event_include_repeating_events.label} {$form.event_include_repeating_events.html}
+ {$form.event_id.label} <br />{$form.event_id.html|crmAddClass:huge}
+ <div class="crm-event-form-block-event_include_repeating_events">
+ {$form.event_include_repeating_events.label} {$form.event_include_repeating_events.html}
+ </div>
</td>
<td class="crm-event-form-block-event_type_id"> {$form.event_type_id.label}<br />{$form.event_type_id.html} </td>
</tr>
{literal}
<script type="text/javascript">
CRM.$(function($) {
+ var recurringLabel = $('label[for=event_include_repeating_events]').html();
+ // Conditional rule for recurring checkbox
+ function toggleRecurrigCheckbox() {
+ if ($(this).val() && $(this).select2('data')['api.RecurringEntity.getcount']) {
+ $('.crm-event-form-block-event_include_repeating_events').show();
+ $('label[for=event_include_repeating_events]').html(recurringLabel.replace('%1', $(this).select2('data').label));
+ } else {
+ $('.crm-event-form-block-event_include_repeating_events').hide().find('input').prop('checked', false);
+ }
+ }
+ $('#event_id').each(toggleRecurrigCheckbox).change(toggleRecurrigCheckbox);
+
// FIXME: This could be much simpler as an entityRef field but the priceFieldValue api doesn't currently support the filters we need
$('#participant_fee_id').crmSelect2({
placeholder: {/literal}'{ts escape="js"}- any -{/ts}'{literal},