First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
2299
sites/all/modules/civicrm/CRM/Event/BAO/Event.php
Normal file
2299
sites/all/modules/civicrm/CRM/Event/BAO/Event.php
Normal file
File diff suppressed because it is too large
Load diff
1980
sites/all/modules/civicrm/CRM/Event/BAO/Participant.php
Normal file
1980
sites/all/modules/civicrm/CRM/Event/BAO/Participant.php
Normal file
File diff suppressed because it is too large
Load diff
130
sites/all/modules/civicrm/CRM/Event/BAO/ParticipantPayment.php
Normal file
130
sites/all/modules/civicrm/CRM/Event/BAO/ParticipantPayment.php
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| 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 |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Event_BAO_ParticipantPayment extends CRM_Event_DAO_ParticipantPayment {
|
||||
|
||||
/**
|
||||
* Creates or updates a participant payment record.
|
||||
*
|
||||
* @param array $params
|
||||
* of values to initialize the record with.
|
||||
* @param array $ids
|
||||
* with one values of id for this participantPayment record (for update).
|
||||
*
|
||||
* @return object
|
||||
* the partcipant payment record
|
||||
*/
|
||||
public static function create(&$params, &$ids) {
|
||||
if (isset($ids['id'])) {
|
||||
CRM_Utils_Hook::pre('edit', 'ParticipantPayment', $ids['id'], $params);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_Hook::pre('create', 'ParticipantPayment', NULL, $params);
|
||||
}
|
||||
|
||||
$participantPayment = new CRM_Event_BAO_ParticipantPayment();
|
||||
$participantPayment->copyValues($params);
|
||||
if (isset($ids['id'])) {
|
||||
$participantPayment->id = CRM_Utils_Array::value('id', $ids);
|
||||
}
|
||||
else {
|
||||
$participantPayment->find(TRUE);
|
||||
}
|
||||
$participantPayment->save();
|
||||
|
||||
if (isset($ids['id'])) {
|
||||
CRM_Utils_Hook::post('edit', 'ParticipantPayment', $ids['id'], $participantPayment);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_Hook::post('create', 'ParticipantPayment', NULL, $participantPayment);
|
||||
}
|
||||
|
||||
//generally if people are creating participant_payments via the api they won't be setting the line item correctly - we can't help them if they are doing complex transactions
|
||||
// but if they have a single line item for the contribution we can assume it should refer to the participant line
|
||||
$lineItemCount = CRM_Core_DAO::singleValueQuery("select count(*) FROM civicrm_line_item WHERE contribution_id = %1", array(
|
||||
1 => array(
|
||||
$participantPayment->contribution_id,
|
||||
'Integer',
|
||||
),
|
||||
));
|
||||
if ($lineItemCount == 1) {
|
||||
$sql = "UPDATE civicrm_line_item li
|
||||
SET entity_table = 'civicrm_participant', entity_id = %1
|
||||
WHERE contribution_id = %2 AND entity_table = 'civicrm_contribution'";
|
||||
CRM_Core_DAO::executeQuery($sql, array(
|
||||
1 => array($participantPayment->participant_id, 'Integer'),
|
||||
2 => array($participantPayment->contribution_id, 'Integer'),
|
||||
));
|
||||
}
|
||||
|
||||
return $participantPayment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the record that are associated with this ParticipantPayment.
|
||||
* Also deletes the associated contribution for this participant
|
||||
*
|
||||
* @param array $params
|
||||
* Associative array whose values match the record to be deleted.
|
||||
*
|
||||
* @return bool
|
||||
* true if deleted false otherwise
|
||||
*/
|
||||
public static function deleteParticipantPayment($params) {
|
||||
$participantPayment = new CRM_Event_DAO_ParticipantPayment();
|
||||
|
||||
$valid = FALSE;
|
||||
foreach ($params as $field => $value) {
|
||||
if (!empty($value)) {
|
||||
$participantPayment->$field = $value;
|
||||
$valid = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$valid) {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
|
||||
if ($participantPayment->find(TRUE)) {
|
||||
CRM_Utils_Hook::pre('delete', 'ParticipantPayment', $participantPayment->id, $params);
|
||||
CRM_Contribute_BAO_Contribution::deleteContribution($participantPayment->contribution_id);
|
||||
$participantPayment->delete();
|
||||
CRM_Utils_Hook::post('delete', 'ParticipantPayment', $participantPayment->id, $participantPayment);
|
||||
return $participantPayment;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,327 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| 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 |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Event_BAO_ParticipantStatusType extends CRM_Event_DAO_ParticipantStatusType {
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return this|null
|
||||
*/
|
||||
public static function add(&$params) {
|
||||
if (empty($params)) {
|
||||
return NULL;
|
||||
}
|
||||
$dao = new CRM_Event_DAO_ParticipantStatusType();
|
||||
$dao->copyValues($params);
|
||||
return $dao->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return this|null
|
||||
*/
|
||||
public static function &create(&$params) {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
$statusType = self::add($params);
|
||||
if (is_a($statusType, 'CRM_Core_Error')) {
|
||||
$transaction->rollback();
|
||||
return $statusType;
|
||||
}
|
||||
$transaction->commit();
|
||||
return $statusType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function deleteParticipantStatusType($id) {
|
||||
// return early if there are participants with this status
|
||||
$participant = new CRM_Event_DAO_Participant();
|
||||
$participant->status_id = $id;
|
||||
if ($participant->find()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
|
||||
|
||||
$dao = new CRM_Event_DAO_ParticipantStatusType();
|
||||
$dao->id = $id;
|
||||
if (!$dao->find()) {
|
||||
return FALSE;
|
||||
}
|
||||
$dao->delete();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param $defaults
|
||||
*
|
||||
* @return CRM_Event_DAO_ParticipantStatusType|null
|
||||
*/
|
||||
public 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $isActive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function setIsActive($id, $isActive) {
|
||||
return CRM_Core_DAO::setFieldValue('CRM_Event_BAO_ParticipantStatusType', $id, 'is_active', $isActive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function process($params) {
|
||||
|
||||
$returnMessages = array();
|
||||
|
||||
$participantRole = CRM_Event_PseudoConstant::participantRole();
|
||||
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
|
||||
$expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
|
||||
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
|
||||
|
||||
//build the required status ids.
|
||||
$statusIds = '(' . implode(',', array_merge(array_keys($pendingStatuses), array_keys($waitingStatuses))) . ')';
|
||||
|
||||
$participantDetails = $fullEvents = array();
|
||||
$expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
|
||||
|
||||
//get all participant who's status in class pending and waiting
|
||||
$query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
|
||||
|
||||
$query = "
|
||||
SELECT participant.id,
|
||||
participant.contact_id,
|
||||
participant.status_id,
|
||||
participant.register_date,
|
||||
participant.registered_by_id,
|
||||
participant.event_id,
|
||||
event.title as eventTitle,
|
||||
event.registration_start_date,
|
||||
event.registration_end_date,
|
||||
event.end_date,
|
||||
event.expiration_time,
|
||||
event.requires_approval
|
||||
FROM civicrm_participant participant
|
||||
LEFT JOIN civicrm_event event ON ( event.id = participant.event_id )
|
||||
WHERE participant.status_id IN {$statusIds}
|
||||
AND (event.end_date > now() OR event.end_date IS NULL)
|
||||
AND event.is_active = 1
|
||||
ORDER BY participant.register_date, participant.id
|
||||
";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
while ($dao->fetch()) {
|
||||
$participantDetails[$dao->id] = array(
|
||||
'id' => $dao->id,
|
||||
'event_id' => $dao->event_id,
|
||||
'status_id' => $dao->status_id,
|
||||
'contact_id' => $dao->contact_id,
|
||||
'register_date' => $dao->register_date,
|
||||
'registered_by_id' => $dao->registered_by_id,
|
||||
'eventTitle' => $dao->eventTitle,
|
||||
'registration_start_date' => $dao->registration_start_date,
|
||||
'registration_end_date' => $dao->registration_end_date,
|
||||
'end_date' => $dao->end_date,
|
||||
'expiration_time' => $dao->expiration_time,
|
||||
'requires_approval' => $dao->requires_approval,
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($participantDetails)) {
|
||||
//cron 1. move participant from pending to expire if needed
|
||||
foreach ($participantDetails as $participantId => $values) {
|
||||
//process the additional participant at the time of
|
||||
//primary participant, don't process separately.
|
||||
if (!empty($values['registered_by_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$expirationTime = CRM_Utils_Array::value('expiration_time', $values);
|
||||
if ($expirationTime && array_key_exists($values['status_id'], $pendingStatuses)) {
|
||||
|
||||
//get the expiration and registration pending time.
|
||||
$expirationSeconds = $expirationTime * 3600;
|
||||
$registrationPendingSeconds = CRM_Utils_Date::unixTime($values['register_date']);
|
||||
|
||||
// expired registration since registration cross allow confirmation time.
|
||||
if (($expirationSeconds + $registrationPendingSeconds) < time()) {
|
||||
|
||||
//lets get the transaction mechanism.
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$ids = array($participantId);
|
||||
$expiredId = array_search('Expired', $expiredStatuses);
|
||||
$results = CRM_Event_BAO_Participant::transitionParticipants($ids, $expiredId, $values['status_id'], TRUE, TRUE);
|
||||
$transaction->commit();
|
||||
|
||||
if (!empty($results)) {
|
||||
//diaplay updated participants
|
||||
if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
|
||||
foreach ($results['updatedParticipantIds'] as $processedId) {
|
||||
$expiredParticipantCount += 1;
|
||||
$returnMessages[] .= "<br />Status updated to: Expired";
|
||||
|
||||
//mailed participants.
|
||||
if (is_array($results['mailedParticipants']) &&
|
||||
array_key_exists($processedId, $results['mailedParticipants'])
|
||||
) {
|
||||
$returnMessages[] .= "<br />Expiration Mail sent to: {$results['mailedParticipants'][$processedId]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//cron 1 end.
|
||||
|
||||
//cron 2. lets move participants from waiting list to pending status
|
||||
foreach ($participantDetails as $participantId => $values) {
|
||||
//process the additional participant at the time of
|
||||
//primary participant, don't process separately.
|
||||
if (!empty($values['registered_by_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists($values['status_id'], $waitingStatuses) &&
|
||||
!array_key_exists($values['event_id'], $fullEvents)
|
||||
) {
|
||||
|
||||
if ($waitingStatuses[$values['status_id']] == 'On waitlist' &&
|
||||
CRM_Event_BAO_Event::validRegistrationDate($values)
|
||||
) {
|
||||
|
||||
//check the target event having space.
|
||||
$eventOpenSpaces = CRM_Event_BAO_Participant::eventFull($values['event_id'], TRUE, FALSE);
|
||||
|
||||
if ($eventOpenSpaces && is_numeric($eventOpenSpaces) || ($eventOpenSpaces === NULL)) {
|
||||
|
||||
//get the additional participant if any.
|
||||
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
|
||||
|
||||
$allIds = array($participantId);
|
||||
if (!empty($additionalIds)) {
|
||||
$allIds = array_merge($allIds, $additionalIds);
|
||||
}
|
||||
$pClause = ' participant.id IN ( ' . implode(' , ', $allIds) . ' )';
|
||||
$requiredSpaces = CRM_Event_BAO_Event::eventTotalSeats($values['event_id'], $pClause);
|
||||
|
||||
//need to check as to see if event has enough speces
|
||||
if (($requiredSpaces <= $eventOpenSpaces) || ($eventOpenSpaces === NULL)) {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$ids = array($participantId);
|
||||
$updateStatusId = array_search('Pending from waitlist', $pendingStatuses);
|
||||
|
||||
//lets take a call to make pending or need approval
|
||||
if ($values['requires_approval']) {
|
||||
$updateStatusId = array_search('Awaiting approval', $waitingStatuses);
|
||||
}
|
||||
$results = CRM_Event_BAO_Participant::transitionParticipants($ids, $updateStatusId,
|
||||
$values['status_id'], TRUE, TRUE
|
||||
);
|
||||
//commit the transaction.
|
||||
$transaction->commit();
|
||||
|
||||
if (!empty($results)) {
|
||||
//diaplay updated participants
|
||||
if (is_array($results['updatedParticipantIds']) &&
|
||||
!empty($results['updatedParticipantIds'])
|
||||
) {
|
||||
foreach ($results['updatedParticipantIds'] as $processedId) {
|
||||
if ($values['requires_approval']) {
|
||||
$waitingApprovalCount += 1;
|
||||
$returnMessages[] .= "<br /><br />- status updated to: Awaiting approval";
|
||||
$returnMessages[] .= "<br />Will send you Confirmation Mail when registration gets approved.";
|
||||
}
|
||||
else {
|
||||
$waitingConfirmCount += 1;
|
||||
$returnMessages[] .= "<br /><br />- status updated to: Pending from waitlist";
|
||||
if (is_array($results['mailedParticipants']) &&
|
||||
array_key_exists($processedId, $results['mailedParticipants'])
|
||||
) {
|
||||
$returnMessages[] .= "<br />Confirmation Mail sent to: {$results['mailedParticipants'][$processedId]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//target event is full.
|
||||
$fullEvents[$values['event_id']] = $values['eventTitle'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
//target event is full.
|
||||
$fullEvents[$values['event_id']] = $values['eventTitle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//cron 2 ends.
|
||||
}
|
||||
|
||||
$returnMessages[] .= "<br /><br />Number of Expired registration(s) = {$expiredParticipantCount}";
|
||||
$returnMessages[] .= "<br />Number of registration(s) require approval = {$waitingApprovalCount}";
|
||||
$returnMessages[] .= "<br />Number of registration changed to Pending from waitlist = {$waitingConfirmCount}<br /><br />";
|
||||
if (!empty($fullEvents)) {
|
||||
foreach ($fullEvents as $eventId => $title) {
|
||||
$returnMessages[] .= "Full Event : {$title}<br />";
|
||||
}
|
||||
}
|
||||
|
||||
return array('is_error' => 0, 'messages' => $returnMessages);
|
||||
}
|
||||
|
||||
}
|
695
sites/all/modules/civicrm/CRM/Event/BAO/Query.php
Normal file
695
sites/all/modules/civicrm/CRM/Event/BAO/Query.php
Normal file
|
@ -0,0 +1,695 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| 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 |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
class CRM_Event_BAO_Query extends CRM_Core_BAO_Query {
|
||||
|
||||
/**
|
||||
* Function get the import/export fields for contribution.
|
||||
*
|
||||
* @param bool $checkPermission
|
||||
*
|
||||
* @return array
|
||||
* Associative array of contribution fields
|
||||
*/
|
||||
public static function &getFields($checkPermission = TRUE) {
|
||||
$fields = array();
|
||||
$fields = array_merge($fields, CRM_Event_DAO_Event::import());
|
||||
$fields = array_merge($fields, self::getParticipantFields());
|
||||
$fields = array_merge($fields, CRM_Core_DAO_Discount::export());
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function &getParticipantFields() {
|
||||
$fields = CRM_Event_BAO_Participant::importableFields('Individual', TRUE, TRUE);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build select for CiviEvent.
|
||||
*
|
||||
* @param $query
|
||||
*/
|
||||
public static function select(&$query) {
|
||||
if (($query->_mode & CRM_Contact_BAO_Query::MODE_EVENT) ||
|
||||
CRM_Contact_BAO_Query::componentPresent($query->_returnProperties, 'participant_')
|
||||
) {
|
||||
$query->_select['participant_id'] = "civicrm_participant.id as participant_id";
|
||||
$query->_element['participant_id'] = 1;
|
||||
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
|
||||
|
||||
//add fee level
|
||||
if (!empty($query->_returnProperties['participant_fee_level'])) {
|
||||
$query->_select['participant_fee_level'] = "civicrm_participant.fee_level as participant_fee_level";
|
||||
$query->_element['participant_fee_level'] = 1;
|
||||
}
|
||||
|
||||
//add participant contact ID
|
||||
if (!empty($query->_returnProperties['participant_contact_id'])) {
|
||||
$query->_select['participant_contact_id'] = "civicrm_participant.contact_id as participant_contact_id";
|
||||
$query->_element['participant_contact_id'] = 1;
|
||||
}
|
||||
|
||||
//add fee amount
|
||||
if (!empty($query->_returnProperties['participant_fee_amount'])) {
|
||||
$query->_select['participant_fee_amount'] = "civicrm_participant.fee_amount as participant_fee_amount";
|
||||
$query->_element['participant_fee_amount'] = 1;
|
||||
}
|
||||
|
||||
//add fee currency
|
||||
if (!empty($query->_returnProperties['participant_fee_currency'])) {
|
||||
$query->_select['participant_fee_currency'] = "civicrm_participant.fee_currency as participant_fee_currency";
|
||||
$query->_element['participant_fee_currency'] = 1;
|
||||
}
|
||||
|
||||
//add event title also if event id is select
|
||||
if (!empty($query->_returnProperties['event_id']) || !empty($query->_returnProperties['event_title'])) {
|
||||
$query->_select['event_id'] = "civicrm_event.id as event_id";
|
||||
$query->_select['event_title'] = "civicrm_event.title as event_title";
|
||||
$query->_element['event_id'] = 1;
|
||||
$query->_element['event_title'] = 1;
|
||||
$query->_tables['civicrm_event'] = 1;
|
||||
$query->_whereTables['civicrm_event'] = 1;
|
||||
}
|
||||
|
||||
//add start date / end date
|
||||
if (!empty($query->_returnProperties['event_start_date'])) {
|
||||
$query->_select['event_start_date'] = "civicrm_event.start_date as event_start_date";
|
||||
$query->_element['event_start_date'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['event_end_date'])) {
|
||||
$query->_select['event_end_date'] = "civicrm_event.end_date as event_end_date";
|
||||
$query->_element['event_end_date'] = 1;
|
||||
}
|
||||
|
||||
//event type
|
||||
if (!empty($query->_returnProperties['event_type'])) {
|
||||
$query->_select['event_type'] = "event_type.label as event_type";
|
||||
$query->_element['event_type'] = 1;
|
||||
$query->_tables['event_type'] = 1;
|
||||
$query->_whereTables['event_type'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['event_type_id'])) {
|
||||
$query->_select['event_type_id'] = "event_type.id as event_type_id";
|
||||
$query->_element['event_type_id'] = 1;
|
||||
$query->_tables['event_type'] = 1;
|
||||
$query->_whereTables['event_type'] = 1;
|
||||
}
|
||||
|
||||
//add status_id
|
||||
if (!empty($query->_returnProperties['participant_status_id'])) {
|
||||
$query->_select['participant_status_id'] = "civicrm_participant.status_id as participant_status_id";
|
||||
$query->_element['participant_status_id'] = 1;
|
||||
$query->_tables['civicrm_participant'] = 1;
|
||||
$query->_whereTables['civicrm_participant'] = 1;
|
||||
}
|
||||
|
||||
// get particupant_status label
|
||||
if (!empty($query->_returnProperties['participant_status'])) {
|
||||
$query->_select['participant_status'] = "participant_status.label as participant_status";
|
||||
$query->_element['participant_status'] = 1;
|
||||
$query->_tables['participant_status'] = 1;
|
||||
$query->_whereTables['civicrm_participant'] = 1;
|
||||
}
|
||||
|
||||
//add participant_role_id
|
||||
if (!empty($query->_returnProperties['participant_role_id'])) {
|
||||
$query->_select['participant_role_id'] = "civicrm_participant.role_id as participant_role_id";
|
||||
$query->_element['participant_role_id'] = 1;
|
||||
$query->_tables['civicrm_participant'] = 1;
|
||||
$query->_whereTables['civicrm_participant'] = 1;
|
||||
$query->_pseudoConstantsSelect['participant_role_id'] = array(
|
||||
'pseudoField' => 'participant_role_id',
|
||||
'idCol' => 'participant_role_id',
|
||||
);
|
||||
}
|
||||
|
||||
//add participant_role
|
||||
if (!empty($query->_returnProperties['participant_role'])) {
|
||||
$query->_select['participant_role'] = "civicrm_participant.role_id as participant_role";
|
||||
$query->_element['participant_role'] = 1;
|
||||
$query->_tables['participant_role'] = 1;
|
||||
$query->_whereTables['civicrm_participant'] = 1;
|
||||
$query->_pseudoConstantsSelect['participant_role'] = array(
|
||||
'pseudoField' => 'participant_role',
|
||||
'idCol' => 'participant_role',
|
||||
);
|
||||
}
|
||||
|
||||
//add register date
|
||||
if (!empty($query->_returnProperties['participant_register_date'])) {
|
||||
$query->_select['participant_register_date'] = "civicrm_participant.register_date as participant_register_date";
|
||||
$query->_element['participant_register_date'] = 1;
|
||||
}
|
||||
|
||||
//add source
|
||||
if (!empty($query->_returnProperties['participant_source'])) {
|
||||
$query->_select['participant_source'] = "civicrm_participant.source as participant_source";
|
||||
$query->_element['participant_source'] = 1;
|
||||
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
|
||||
}
|
||||
|
||||
//participant note
|
||||
if (!empty($query->_returnProperties['participant_note'])) {
|
||||
$query->_select['participant_note'] = "civicrm_note.note as participant_note";
|
||||
$query->_element['participant_note'] = 1;
|
||||
$query->_tables['participant_note'] = 1;
|
||||
$query->_whereTables['civicrm_note'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['participant_is_pay_later'])) {
|
||||
$query->_select['participant_is_pay_later'] = "civicrm_participant.is_pay_later as participant_is_pay_later";
|
||||
$query->_element['participant_is_pay_later'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['participant_is_test'])) {
|
||||
$query->_select['participant_is_test'] = "civicrm_participant.is_test as participant_is_test";
|
||||
$query->_element['participant_is_test'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['participant_registered_by_id'])) {
|
||||
$query->_select['participant_registered_by_id'] = "civicrm_participant.registered_by_id as participant_registered_by_id";
|
||||
$query->_element['participant_registered_by_id'] = 1;
|
||||
}
|
||||
|
||||
// get discount name
|
||||
if (!empty($query->_returnProperties['participant_discount_name'])) {
|
||||
$query->_select['participant_discount_name'] = "discount_name.title as participant_discount_name";
|
||||
$query->_element['participant_discount_name'] = 1;
|
||||
$query->_tables['civicrm_discount'] = 1;
|
||||
$query->_tables['participant_discount_name'] = 1;
|
||||
$query->_whereTables['civicrm_discount'] = 1;
|
||||
$query->_whereTables['participant_discount_name'] = 1;
|
||||
}
|
||||
|
||||
//carry campaign id to selectors.
|
||||
if (!empty($query->_returnProperties['participant_campaign_id'])) {
|
||||
$query->_select['participant_campaign_id'] = 'civicrm_participant.campaign_id as participant_campaign_id';
|
||||
$query->_element['participant_campaign_id'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*/
|
||||
public static function where(&$query) {
|
||||
$grouping = NULL;
|
||||
foreach (array_keys($query->_params) as $id) {
|
||||
if (empty($query->_params[$id][0])) {
|
||||
continue;
|
||||
}
|
||||
if (substr($query->_params[$id][0], 0, 6) == 'event_' ||
|
||||
substr($query->_params[$id][0], 0, 12) == 'participant_'
|
||||
) {
|
||||
if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
|
||||
$query->_useDistinct = TRUE;
|
||||
}
|
||||
$grouping = $query->_params[$id][3];
|
||||
self::whereClauseSingle($query->_params[$id], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $values
|
||||
* @param $query
|
||||
*/
|
||||
public static function whereClauseSingle(&$values, &$query) {
|
||||
$checkPermission = empty($query->_skipPermission);
|
||||
list($name, $op, $value, $grouping, $wildcard) = $values;
|
||||
$fields = array_merge(CRM_Event_BAO_Event::fields(), CRM_Event_BAO_Participant::exportableFields());
|
||||
|
||||
switch ($name) {
|
||||
case 'event_start_date_low':
|
||||
case 'event_start_date_high':
|
||||
$query->dateQueryBuilder($values,
|
||||
'civicrm_event', 'event_start_date', 'start_date', 'Start Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'event_end_date_low':
|
||||
case 'event_end_date_high':
|
||||
$query->dateQueryBuilder($values,
|
||||
'civicrm_event', 'event_end_date', 'end_date', 'End Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'event_include_repeating_events':
|
||||
/**
|
||||
* Include Repeating Events
|
||||
*/
|
||||
//Get parent of this event
|
||||
$exEventId = '';
|
||||
if ($query->_where[$grouping]) {
|
||||
foreach ($query->_where[$grouping] as $key => $val) {
|
||||
if (strstr($val, 'civicrm_event.id =')) {
|
||||
$exEventId = $val;
|
||||
$extractEventId = explode(" ", $val);
|
||||
$value = $extractEventId[2];
|
||||
$where = $query->_where[$grouping][$key];
|
||||
}
|
||||
elseif (strstr($val, 'civicrm_event.id IN')) {
|
||||
//extract the first event id if multiple events are selected
|
||||
preg_match('/civicrm_event.id IN \(\"(\d+)/', $val, $matches);
|
||||
$value = $matches[1];
|
||||
$where = $query->_where[$grouping][$key];
|
||||
}
|
||||
}
|
||||
if ($exEventId) {
|
||||
$extractEventId = explode(" ", $exEventId);
|
||||
$value = $extractEventId[2];
|
||||
}
|
||||
elseif (!empty($matches[1])) {
|
||||
$value = $matches[1];
|
||||
}
|
||||
$where = $query->_where[$grouping][$key];
|
||||
}
|
||||
$thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event');
|
||||
if ($thisEventHasParent) {
|
||||
$getAllConnections = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($thisEventHasParent, 'civicrm_event');
|
||||
$allEventIds = array();
|
||||
foreach ($getAllConnections as $key => $val) {
|
||||
$allEventIds[] = $val['id'];
|
||||
}
|
||||
if (!empty($allEventIds)) {
|
||||
$op = "IN";
|
||||
$value = "(" . implode(",", $allEventIds) . ")";
|
||||
}
|
||||
}
|
||||
$query->_where[$grouping][] = "{$where} OR civicrm_event.id $op {$value}";
|
||||
$query->_qill[$grouping][] = ts('Include Repeating Events');
|
||||
$query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
|
||||
return;
|
||||
|
||||
case 'participant_is_test':
|
||||
$key = array_search('civicrm_participant.is_test = 0', $query->_where[$grouping]);
|
||||
if (!empty($key)) {
|
||||
unset($query->_where[$grouping][$key]);
|
||||
}
|
||||
case 'participant_test':
|
||||
// We dont want to include all tests for sql OR CRM-7827
|
||||
if (!$value || $query->getOperator() != 'OR') {
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_test",
|
||||
$op,
|
||||
$value,
|
||||
"Boolean"
|
||||
);
|
||||
|
||||
$isTest = $value ? 'a Test' : 'not a Test';
|
||||
$query->_qill[$grouping][] = ts("Participant is %1", array(1 => $isTest));
|
||||
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
|
||||
}
|
||||
return;
|
||||
|
||||
case 'participant_fee_id':
|
||||
foreach ($value as $k => &$val) {
|
||||
$val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label');
|
||||
$val = CRM_Core_DAO::escapeString(trim($val));
|
||||
}
|
||||
$feeLabel = implode('|', $value);
|
||||
$query->_where[$grouping][] = "civicrm_participant.fee_level REGEXP '{$feeLabel}'";
|
||||
$query->_qill[$grouping][] = ts("Fee level") . " IN " . implode(', ', $value);
|
||||
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
|
||||
return;
|
||||
|
||||
case 'participant_fee_amount_high':
|
||||
case 'participant_fee_amount_low':
|
||||
$query->numberRangeBuilder($values,
|
||||
'civicrm_participant', 'participant_fee_amount', 'fee_amount', 'Fee Amount'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'participant_status_id':
|
||||
if ($value && is_array($value) && strpos($op, 'IN') === FALSE) {
|
||||
$op = 'IN';
|
||||
}
|
||||
case 'participant_status':
|
||||
case 'participant_source':
|
||||
case 'participant_id':
|
||||
case 'participant_contact_id':
|
||||
case 'participant_is_pay_later':
|
||||
case 'participant_fee_amount':
|
||||
case 'participant_fee_level':
|
||||
case 'participant_campaign_id':
|
||||
case 'participant_registered_by_id':
|
||||
|
||||
$qillName = $name;
|
||||
if (in_array($name, array(
|
||||
'participant_status_id',
|
||||
'participant_source',
|
||||
'participant_id',
|
||||
'participant_contact_id',
|
||||
'participant_fee_amount',
|
||||
'participant_fee_level',
|
||||
'participant_is_pay_later',
|
||||
'participant_campaign_id',
|
||||
'participant_registered_by_id',
|
||||
))
|
||||
) {
|
||||
$name = str_replace('participant_', '', $name);
|
||||
if ($name == 'is_pay_later') {
|
||||
$qillName = $name;
|
||||
}
|
||||
}
|
||||
elseif ($name == 'participant_status') {
|
||||
$name = 'status_id';
|
||||
}
|
||||
|
||||
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
|
||||
$tableName = empty($tableName) ? 'civicrm_participant' : $tableName;
|
||||
if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
|
||||
$op = key($value);
|
||||
$value = $value[$op];
|
||||
}
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);
|
||||
|
||||
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
|
||||
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
|
||||
return;
|
||||
|
||||
case 'participant_role':
|
||||
case 'participant_role_id':
|
||||
$qillName = $name;
|
||||
$name = 'role_id';
|
||||
|
||||
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
|
||||
$tableName = empty($tableName) ? 'civicrm_participant' : $tableName;
|
||||
if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
|
||||
$op = key($value);
|
||||
$value = $value[$op];
|
||||
}
|
||||
if (!strstr($op, 'NULL') && !strstr($op, 'EMPTY') && !strstr($op, 'LIKE')) {
|
||||
$regexOp = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT REGEXP' : 'REGEXP';
|
||||
$regexp = "([[:cntrl:]]|^)" . implode('([[:cntrl:]]|$)|([[:cntrl:]]|^)', (array) $value) . "([[:cntrl:]]|$)";
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.$name", $regexOp, $regexp, 'String');
|
||||
}
|
||||
else {
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);
|
||||
}
|
||||
|
||||
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
|
||||
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
|
||||
return;
|
||||
|
||||
case 'participant_register_date':
|
||||
case 'participant_register_date_high':
|
||||
case 'participant_register_date_low':
|
||||
$query->dateQueryBuilder($values,
|
||||
'civicrm_participant', 'participant_register_date', 'register_date', 'Register Date'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'event_id':
|
||||
case 'participant_event_id':
|
||||
$name = str_replace('participant_', '', $name);
|
||||
case 'event_is_public':
|
||||
case 'event_type_id':
|
||||
case 'event_title':
|
||||
$qillName = $name;
|
||||
if (in_array($name, array(
|
||||
'event_id',
|
||||
'event_title',
|
||||
'event_is_public',
|
||||
)
|
||||
)
|
||||
) {
|
||||
$name = str_replace('event_', '', $name);
|
||||
}
|
||||
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
|
||||
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_event.$name", $op, $value, $dataType);
|
||||
$query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
|
||||
if (!array_key_exists($qillName, $fields)) {
|
||||
break;
|
||||
}
|
||||
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op, array('check_permission' => $checkPermission));
|
||||
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $mode
|
||||
* @param $side
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public static function from($name, $mode, $side) {
|
||||
$from = NULL;
|
||||
switch ($name) {
|
||||
case 'civicrm_participant':
|
||||
$from = " LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id ";
|
||||
break;
|
||||
|
||||
case 'civicrm_event':
|
||||
//CRM-17121
|
||||
$from = " LEFT JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id ";
|
||||
break;
|
||||
|
||||
case 'event_type':
|
||||
$from = " $side JOIN civicrm_option_group option_group_event_type ON (option_group_event_type.name = 'event_type')";
|
||||
$from .= " $side JOIN civicrm_option_value event_type ON (civicrm_event.event_type_id = event_type.value AND option_group_event_type.id = event_type.option_group_id ) ";
|
||||
break;
|
||||
|
||||
case 'participant_note':
|
||||
$from .= " $side JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_participant' AND
|
||||
civicrm_participant.id = civicrm_note.entity_id )";
|
||||
break;
|
||||
|
||||
case 'participant_status':
|
||||
$from .= " $side JOIN civicrm_participant_status_type participant_status ON (civicrm_participant.status_id = participant_status.id) ";
|
||||
break;
|
||||
|
||||
case 'participant_role':
|
||||
$from = " $side JOIN civicrm_option_group option_group_participant_role ON (option_group_participant_role.name = 'participant_role')";
|
||||
$from .= " $side JOIN civicrm_option_value participant_role ON ((civicrm_participant.role_id = participant_role.value OR SUBSTRING_INDEX(role_id,'', 1) = participant_role.value)
|
||||
AND option_group_participant_role.id = participant_role.option_group_id ) ";
|
||||
break;
|
||||
|
||||
case 'participant_discount_name':
|
||||
$from = " $side JOIN civicrm_discount discount ON ( civicrm_participant.discount_id = discount.id )";
|
||||
$from .= " $side JOIN civicrm_option_group discount_name ON ( discount_name.id = discount.price_set_id ) ";
|
||||
break;
|
||||
}
|
||||
return $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mode
|
||||
* @param bool $includeCustomFields
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function defaultReturnProperties(
|
||||
$mode,
|
||||
$includeCustomFields = TRUE
|
||||
) {
|
||||
$properties = NULL;
|
||||
if ($mode & CRM_Contact_BAO_Query::MODE_EVENT) {
|
||||
$properties = array(
|
||||
'contact_type' => 1,
|
||||
'contact_sub_type' => 1,
|
||||
'sort_name' => 1,
|
||||
'display_name' => 1,
|
||||
'event_id' => 1,
|
||||
'event_title' => 1,
|
||||
'event_start_date' => 1,
|
||||
'event_end_date' => 1,
|
||||
'event_type' => 1,
|
||||
'participant_id' => 1,
|
||||
'participant_status' => 1,
|
||||
'participant_status_id' => 1,
|
||||
'participant_role' => 1,
|
||||
'participant_role_id' => 1,
|
||||
'participant_note' => 1,
|
||||
'participant_register_date' => 1,
|
||||
'participant_source' => 1,
|
||||
'participant_fee_level' => 1,
|
||||
'participant_is_test' => 1,
|
||||
'participant_is_pay_later' => 1,
|
||||
'participant_fee_amount' => 1,
|
||||
'participant_discount_name' => 1,
|
||||
'participant_fee_currency' => 1,
|
||||
'participant_registered_by_id' => 1,
|
||||
'participant_campaign_id' => 1,
|
||||
);
|
||||
|
||||
if ($includeCustomFields) {
|
||||
// also get all the custom participant properties
|
||||
$fields = CRM_Core_BAO_CustomField::getFieldsForImport('Participant');
|
||||
if (!empty($fields)) {
|
||||
foreach ($fields as $name => $dontCare) {
|
||||
$properties[$name] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
*/
|
||||
public static function buildSearchForm(&$form) {
|
||||
$dataURLEventFee = CRM_Utils_System::url('civicrm/ajax/eventFee',
|
||||
"reset=1",
|
||||
FALSE, NULL, FALSE
|
||||
);
|
||||
|
||||
$form->assign('dataURLEventFee', $dataURLEventFee);
|
||||
|
||||
$form->addEntityRef('event_id', ts('Event Name'), array(
|
||||
'entity' => 'event',
|
||||
'placeholder' => ts('- any -'),
|
||||
'multiple' => 1,
|
||||
'select' => array('minimumInputLength' => 0),
|
||||
)
|
||||
);
|
||||
$form->addEntityRef('event_type_id', ts('Event Type'), array(
|
||||
'entity' => 'option_value',
|
||||
'placeholder' => ts('- any -'),
|
||||
'select' => array('minimumInputLength' => 0),
|
||||
'api' => array(
|
||||
'params' => array('option_group_id' => 'event_type'),
|
||||
),
|
||||
)
|
||||
);
|
||||
$obj = new CRM_Report_Form_Event_ParticipantListing();
|
||||
$form->add('select', 'participant_fee_id',
|
||||
ts('Fee Level'),
|
||||
$obj->getPriceLevels(),
|
||||
FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -'))
|
||||
);
|
||||
|
||||
CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
|
||||
|
||||
CRM_Core_Form_Date::buildDateRange($form, 'participant', 1, '_register_date_low', '_register_date_high', ts('From'), FALSE);
|
||||
|
||||
$form->addElement('hidden', 'event_date_range_error');
|
||||
$form->addElement('hidden', 'participant_date_range_error');
|
||||
$form->addFormRule(array('CRM_Event_BAO_Query', 'formRule'), $form);
|
||||
|
||||
$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 -'),
|
||||
)
|
||||
);
|
||||
|
||||
$form->addSelect('participant_role_id',
|
||||
array(
|
||||
'entity' => 'participant',
|
||||
'label' => ts('Participant Role'),
|
||||
'multiple' => 'multiple',
|
||||
'option_url' => NULL,
|
||||
'placeholder' => ts('- any -'),
|
||||
)
|
||||
);
|
||||
|
||||
$form->addYesNo('participant_test', ts('Participant is a Test?'), TRUE);
|
||||
$form->addYesNo('participant_is_pay_later', ts('Participant is Pay Later?'), TRUE);
|
||||
$form->addElement('text', 'participant_fee_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
|
||||
$form->addElement('text', 'participant_fee_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
|
||||
|
||||
$form->addRule('participant_fee_amount_low', ts('Please enter a valid money value.'), 'money');
|
||||
$form->addRule('participant_fee_amount_high', ts('Please enter a valid money value.'), 'money');
|
||||
|
||||
self::addCustomFormFields($form, array('Participant', 'Event'));
|
||||
|
||||
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'participant_campaign_id');
|
||||
|
||||
$form->assign('validCiviEvent', TRUE);
|
||||
$form->setDefaults(array('participant_test' => 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tables
|
||||
*/
|
||||
public static function tableNames(&$tables) {
|
||||
//add participant table
|
||||
if (!empty($tables['civicrm_event'])) {
|
||||
$tables = array_merge(array('civicrm_participant' => 1), $tables);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the values in the date range are in correct chronological order.
|
||||
*
|
||||
* @todo Get this to work with CRM_Utils_Rule::validDateRange
|
||||
*
|
||||
* @param array $fields
|
||||
* @param array $files
|
||||
* @param CRM_Core_Form $form
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function formRule($fields, $files, $form) {
|
||||
$errors = array();
|
||||
|
||||
if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high'])) && (empty($fields['participant_register_date_low']) || empty($fields['participant_register_date_high']))) {
|
||||
return TRUE;
|
||||
}
|
||||
$lowDate = strtotime($fields['event_start_date_low']);
|
||||
$highDate = strtotime($fields['event_end_date_high']);
|
||||
|
||||
if ($lowDate > $highDate) {
|
||||
$errors['event_date_range_error'] = ts('Please check that your Event Date Range is in correct chronological order.');
|
||||
}
|
||||
|
||||
$lowDate1 = strtotime($fields['participant_register_date_low']);
|
||||
$highDate1 = strtotime($fields['participant_register_date_high']);
|
||||
|
||||
if ($lowDate1 > $highDate1) {
|
||||
$errors['participant_date_range_error'] = ts('Please check that your Registration Date Range is in correct chronological order.');
|
||||
}
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue