$component = 'Membership';
}
elseif ($activity->__table == 'civicrm_participant') {
- $event = CRM_Event_BAO_Event::getEvents(TRUE, $activity->event_id, TRUE, FALSE);
+ $event = CRM_Event_BAO_Event::getEvents(1, $activity->event_id, TRUE, FALSE);
$roles = CRM_Event_PseudoConstant::participantRole();
$status = CRM_Event_PseudoConstant::participantStatus();
foreach ($event_type as $eventId => $eventName) {
$form->addElement('checkbox', "event_type_id[$eventId]", 'Event Type', $eventName);
}
- $events = CRM_Event_BAO_Event::getEvents(TRUE);
+ $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'));
/**
* Function to get current/future Events
*
- * @param $all boolean true if events all are required else returns current and future events
+ * @param $all int 0 returns current and future events
+ * 1 if events all are required
+ * 2 returns events since 3 months ago
* @param $id int id of a specific event to return
* @param $isActive boolean true if you need only active events
* @param $checkPermission boolean true if you need to check permission else false
*
* @static
*/
- static function getEvents($all = FALSE,
+ static function getEvents($all = 0,
$id = FALSE,
$isActive = TRUE,
$checkPermission = TRUE
if ($id) {
$query .= " AND `id` = {$id}";
}
- elseif (!$all) {
+ elseif ($all == 0) {
+ // find only events ending in the future
$endDate = date('YmdHis');
$query .= " AND ( `end_date` >= {$endDate} OR end_date IS NULL )";
}
+ elseif ($all == 2) {
+ // find only events starting in the last 3 months
+ $startDate = date('YmdHis', strtotime('3 months ago'));
+ $query .= " AND ( `start_date` >= {$startDate} OR start_date IS NULL )";
+ }
if ($isActive) {
$query .= " AND civicrm_event.is_active = 1";
}
if ($form->_eventId) {
//get receipt text and financial type
- $returnProperities = array( 'confirm_email_text', 'financial_type_id', 'campaign_id' );
+ $returnProperities = array( 'confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date' );
$details = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
if ( CRM_Utils_Array::value( 'financial_type_id', $details[$form->_eventId] ) ) {
//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) {
+ if ($form->_action == CRM_Core_Action::ADD && !$form->_mode && $form->_isPaidEvent
+ && strtotime(CRM_Utils_Array::value('start_date', $details[$form->_eventId])) >= time()) {
$defaults[$form->_pId]['record_contribution'] = 1;
}
if ( $this->_eID ) {
$eventEndDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID,'end_date');
}
- $this->assign('past', FALSE);
+ $this->assign('past', 0);
if ($this->_action & CRM_Core_Action::UPDATE) {
- $events = CRM_Event_BAO_Event::getEvents(TRUE, FALSE, FALSE);
+ $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)))) {
- $events = CRM_Event_BAO_Event::getEvents(TRUE);
- $this->assign('past', TRUE);
+ $pastval = $this->getElementValue('past_event');
+ $events = CRM_Event_BAO_Event::getEvents($pastval);
+ $this->assign('past', $pastval);
}
else {
$events = CRM_Event_BAO_Event::getEvents();
}
function eventList() {
- $events = CRM_Event_BAO_Event::getEvents(TRUE);
+ $listparams = CRM_Utils_Array::value('listall', $_REQUEST, 1);
+ $events = CRM_Event_BAO_Event::getEvents($listparams);
$elements = array(array('name' => ts('- select -'),
'value' => '',
{/if}
<tr class="crm-participant-form-block-event_id">
<td class="label">{$form.event_id.label}</td><td class="view-value bold">{$form.event_id.html}
- {if $action eq 1 && !$past }
- <br /><a href="#" onclick="buildSelect('event_id'); return false;"
- id='past-event'>» {ts}Include past event(s) in this select list.{/ts}</a>
+ {if $action eq 1 && $past neq 1 }<span id='past-event-section'>
+ <br />» {ts}Include past event(s) in this select list:{/ts}
+ {if !$past}<a href="#" onclick="buildSelect('event_id', 2); return false;" class='3-mo-past-event'>{ts}past three months{/ts}</a> <span class='3-mo-past-event'>|</span>{/if}
+ <a href="#" onclick="buildSelect('event_id', 1); return false;">{ts}all{/ts}</a></span>
{/if}
{if $is_test}
{ts}(test){/ts}
{literal}
<script type="text/javascript">
// event select
- function buildSelect( selectID ) {
+ function buildSelect( selectID, listallVal ) {
var elementID = '#' + selectID;
cj( elementID ).html('');
var postUrl = "{/literal}{crmURL p='civicrm/ajax/eventlist' h=0}{literal}";
- cj.post( postUrl, null, function ( response ) {
+ cj.post( postUrl, {listall:listallVal}, function ( response ) {
response = eval( response );
for (i = 0; i < response.length; i++) {
cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
}
- cj('#past-event').hide( );
- cj('input[name="past_event"]').val(1);
+ if (listallVal == 1) {
+ cj('#past-event-section').hide( );
+ }
+ else {
+ cj('.3-mo-past-event').hide( );
+ }
+ cj('input[name="past_event"]').val(listallVal);
cj("#feeBlock").html( '' );
});
}