);
/**
- *
*/
public function __construct() {
parent::__construct();
$noteValue = NULL;
$hasNoteField = FALSE;
foreach (array(
- 'note', 'participant_note') as $noteFld) {
+ 'note',
+ 'participant_note',
+ ) as $noteFld) {
if (array_key_exists($noteFld, $params)) {
$noteValue = $params[$noteFld];
$hasNoteField = TRUE;
* @param bool $returnWaitingCount
* @param bool $considerTestParticipant
*
- * @return bool|int|null|string 1. false => If event having some empty spaces.@static
+ * @return bool|int|null|string
+ * 1. false => If event having some empty spaces.
+ * @static
*/
static function eventFull(
$eventId,
// It might be case there are some empty spaces and still event
// is full, as waitlist might represent group require spaces > empty.
- $participantRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
- $countedStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
- $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
+ $participantRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
+ $countedStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
+ $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
$onWaitlistStatusId = array_search('On waitlist', $waitingStatuses);
//when we do require only waiting count don't consider counted.
if ($includeWaitingList && $onWaitlistStatusId) {
//build the where clause.
- $whereClause = ' WHERE ' . implode(' AND ', $where);
- $whereClause .= " AND participant.status_id = $onWaitlistStatusId ";
+ $whereClause = ' WHERE ' . implode(' AND ', $where);
+ $whereClause .= " AND participant.status_id = $onWaitlistStatusId ";
$eventSeatsWhere = implode(' AND ', $where) . " AND ( participant.status_id = $onWaitlistStatusId )";
$query = "
}
//consider only counted participants.
- $where[] = ' participant.status_id IN ( ' . implode(', ', array_keys($countedStatuses)) . ' ) ';
- $whereClause = ' WHERE ' . implode(' AND ', $where);
+ $where[] = ' participant.status_id IN ( ' . implode(', ', array_keys($countedStatuses)) . ' ) ';
+ $whereClause = ' WHERE ' . implode(' AND ', $where);
$eventSeatsWhere = implode(' AND ', $where);
$query = "
$eventMaxSeats = NULL;
$eventFullText = ts('This event is full.');
- $participants = CRM_Core_DAO::executeQuery($query, $eventParams);
+ $participants = CRM_Core_DAO::executeQuery($query, $eventParams);
while ($participants->fetch()) {
if ($participants->event_full_text) {
$eventFullText = $participants->event_full_text;
* @param bool $considerWaiting
* @param bool $considerTestParticipants
*
- * @return array $optionsCount an array of each option id and total count
+ * @return array
+ * an array of each option id and total count
* @static
*/
static function priceSetOptionsCount(
* @param int $eventId
* Event id.
*
- * @return int $spaces Number of Empty Seats/null.
+ * @return int
+ * $spaces Number of Empty Seats/null.
* @static
*/
public static function pendingToConfirmSpaces($eventId) {
* @param bool $status
* @param bool $onlyParticipant
*
- * @return array array of importable Fields
+ * @return array
+ * array of importable Fields
* @static
*/
public static function &importableFields($contactType = 'Individual', $status = TRUE, $onlyParticipant = FALSE) {
'title' => ts('Participant Note'),
'name' => 'participant_note',
'headerPattern' => '/(participant.)?note$/i',
- ));
+ ),
+ );
// Split status and status id into 2 fields
// Fixme: it would be better to leave as 1 field and intelligently handle both during import
'title' => ts('Participant Status'),
'name' => 'participant_status',
'data_type' => CRM_Utils_Type::T_STRING,
- ));
+ ),
+ );
$tmpFields['participant_status_id']['title'] = ts('Participant Status Id');
// Split role and role id into 2 fields
'title' => ts('Participant Role'),
'name' => 'participant_role',
'data_type' => CRM_Utils_Type::T_STRING,
- ));
+ ),
+ );
$tmpFields['participant_role_id']['title'] = ts('Participant Role Id');
$eventType = array(
'title' => ts('Event Type'),
'name' => 'event_type',
'data_type' => CRM_Utils_Type::T_STRING,
- ));
+ ),
+ );
$tmpContactField = $contactFields = array();
- $contactFields = array( );
+ $contactFields = array();
if (!$onlyParticipant) {
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// Using new Dedupe rule.
$ruleParams = array(
'contact_type' => $contactType,
- 'used' => 'Unsupervised',
+ 'used' => 'Unsupervised',
);
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
/**
* Combine all the exportable fields from the lower levels object
*
- * @return array array of exportable Fields
+ * @return array
+ * array of exportable Fields
* @static
*/
public static function &exportableFields() {
$participantFields = CRM_Event_DAO_Participant::export();
$noteField = array(
- 'participant_note' => array('title' => 'Participant Note',
+ 'participant_note' => array(
+ 'title' => 'Participant Note',
'name' => 'participant_note',
- ));
+ ),
+ );
$participantStatus = array(
- 'participant_status' => array('title' => 'Participant Status',
+ 'participant_status' => array(
+ 'title' => 'Participant Status',
'name' => 'participant_status',
- ));
+ ),
+ );
$participantRole = array(
- 'participant_role' => array('title' => 'Participant Role',
+ 'participant_role' => array(
+ 'title' => 'Participant Role',
'name' => 'participant_role',
- ));
+ ),
+ );
//CRM-13595 add event id to participant export
$eventid = array(
- 'event_id' => array('title' => 'Event ID',
+ 'event_id' => array(
+ 'title' => 'Event ID',
'name' => 'event_id',
- ));
+ ),
+ );
$eventtitle = array(
- 'event_title' => array('title' => 'Event Title',
+ 'event_title' => array(
+ 'title' => 'Event Title',
'name' => 'event_title',
- ));
+ ),
+ );
- $discountFields = CRM_Core_DAO_Discount::export();
+ $discountFields = CRM_Core_DAO_Discount::export();
$fields = array_merge($participantFields, $participantStatus, $participantRole, $eventid, $eventtitle, $noteField, $discountFields);
*
* @param int $participantId
* Id of the participant.
-
*
- * @return array $name associated array with sort_name and event title
+ * @return array
+ * associated array with sort_name and event title
* @static
*/
public static function participantDetails($participantId) {
$details = array();
while ($dao->fetch()) {
- $details['name'] = $dao->name;
+ $details['name'] = $dao->name;
$details['title'] = $dao->title;
- $details['cid'] = $dao->cid;
+ $details['cid'] = $dao->cid;
}
return $details;
}
/**
- * This function is used to convert associative array names to values
+ * convert associative array names to values
* and vice-versa.
*
* This function is used by both the web form layer and the api. Note that
CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
// cleanup line items.
- $participantsId = array();
- $participantsId = self::getAdditionalParticipantIds($id);
+ $participantsId = array();
+ $participantsId = self::getAdditionalParticipantIds($id);
$participantsId[] = $id;
CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant');
$clause = implode(' AND ', $clause);
- $query = "SELECT id FROM civicrm_participant WHERE $clause";
- $dao = CRM_Core_DAO::executeQuery($query, $input);
+ $query = "SELECT id FROM civicrm_participant WHERE $clause";
+ $dao = CRM_Core_DAO::executeQuery($query, $input);
$result = FALSE;
while ($dao->fetch()) {
$duplicates[] = $dao->id;
}
elseif ((substr($eventLevel, 0, 1) == CRM_Core_DAO::VALUE_SEPARATOR)) {
$eventLevel = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR,
- substr($eventLevel, 0, 1)
- ));
+ substr($eventLevel, 0, 1)
+ ));
}
elseif ((substr($eventLevel, -1, 1) == CRM_Core_DAO::VALUE_SEPARATOR)) {
$eventLevel = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR,
- substr($eventLevel, 0, -1)
- ));
+ substr($eventLevel, 0, -1)
+ ));
}
}
*
* @param int $oldStatusId
*
- * @return array $additionalParticipantIds
+ * @return array
* @static
*/
public static function getAdditionalParticipantIds($primaryParticipantId, $excludeCancel = TRUE, $oldStatusId = NULL) {
$where = "participant.registered_by_id={$primaryParticipantId}";
if ($excludeCancel) {
- $cancelStatusId = 0;
+ $cancelStatusId = 0;
$negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
- $cancelStatusId = array_search('Cancelled', $negativeStatuses);
+ $cancelStatusId = array_search('Cancelled', $negativeStatuses);
$where .= " AND participant.status_id != {$cancelStatusId}";
}
* @param bool $hasLineItems
* Do fetch from line items.
*
- * @return array $feeDetails
+ * @return array
* @static
*/
public function getFeeDetails($participantIds, $hasLineItems = FALSE) {
$where = 'WHERE participant.id IN ( ' . implode(', ', $participantIds) . ' )';
$query = "$select $from $where";
- $feeInfo = CRM_Core_DAO::executeQuery($query);
- $feeProperties = array('fee_level', 'fee_amount');
+ $feeInfo = CRM_Core_DAO::executeQuery($query);
+ $feeProperties = array('fee_level', 'fee_amount');
$lineProperties = array(
- 'lineId', 'label', 'qty', 'unit_price',
- 'line_total', 'field_title', 'html_type',
- 'price_field_id', 'participant_count', 'price_field_value_id', 'description',
+ 'lineId',
+ 'label',
+ 'qty',
+ 'unit_price',
+ 'line_total',
+ 'field_title',
+ 'html_type',
+ 'price_field_id',
+ 'participant_count',
+ 'price_field_value_id',
+ 'description',
);
while ($feeInfo->fetch()) {
if ($hasLineItems) {
}
}
else {
- foreach ($feeProperties as $property) $feeDetails[$feeInfo->id][$property] = $feeInfo->$property;
+ foreach ($feeProperties as $property) {
+ $feeDetails[$feeInfo->id][$property] = $feeInfo->$property;
+ }
}
}
* @param int $primaryParticipantID
* Id of primary participant record.
*
- * @return array $additionalParticipants $displayName => $viewUrl
+ * @return array
+ * $displayName => $viewUrl
* @static
*/
public static function getAdditionalParticipants($primaryParticipantID) {
* @return array
* @static
*/
- static function transitionParticipants($participantIds, $toStatusId,
+ static function transitionParticipants(
+ $participantIds, $toStatusId,
$fromStatusId = NULL, $returnResult = FALSE, $skipCascadeRule = FALSE
) {
if (!is_array($participantIds) || empty($participantIds) || !$toStatusId) {
$contactIds = $eventIds = $participantDetails = array();
- $statusTypes = CRM_Event_PseudoConstant::participantStatus();
+ $statusTypes = CRM_Event_PseudoConstant::participantStatus();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
- $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL,
+ $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL,
"class = 'Pending'"
);
if (empty($domainValues)) {
// making all tokens available to templates.
$domain = CRM_Core_BAO_Domain::getDomain();
- $tokens = array('domain' => array('name', 'phone', 'address', 'email'),
+ $tokens = array(
+ 'domain' => array('name', 'phone', 'address', 'email'),
'contact' => CRM_Core_SelectValues::contactTokens(),
);
//now we are ready w/ all required data.
//take a decision as per statuses.
- $emailType = NULL;
- $toStatus = $statusTypes[$toStatusId];
+ $emailType = NULL;
+ $toStatus = $statusTypes[$toStatusId];
$fromStatus = CRM_Utils_Array::value($fromStatusId, $statusTypes);
switch ($toStatus) {
// 3. create activity record.
if ($mailSent) {
- $now = date('YmdHis');
- $activityType = 'Event Registration';
+ $now = date('YmdHis');
+ $activityType = 'Event Registration';
$activityParams = array(
'subject' => $subject,
'source_contact_id' => $contactId,
array_key_exists($processedId, $results['mailedParticipants'])
) {
$statusMsg .= '<br /> ' . ts("Participant status has been updated to '%1'. An email has been sent to %2.",
- array(
- 1 => $allStatuses[$statusChangeTo],
- 2 => $results['mailedParticipants'][$processedId],
- )
- );
+ array(
+ 1 => $allStatuses[$statusChangeTo],
+ 2 => $results['mailedParticipants'][$processedId],
+ )
+ );
}
}
}
if (is_string($emptySeats) && $emptySeats !== NULL) {
$maxParticipants = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'max_participants');
$eventfullMsg = ts("This event currently has the maximum number of participants registered (%1). However, you can still override this limit and register additional participants using this form.", array(
- 1 => $maxParticipants)) . '<br />';
+ 1 => $maxParticipants,
+ )) . '<br />';
}
$hasWaiting = FALSE;
*
* @param int $participantId
*
- * @return true if participant is primary
+ * @return bool
+ * true if participant is primary
*/
public static function isPrimaryParticipant($participantId) {
* @param int $newStatusId
* New status.
*
- * @return true if allowed
+ * @return bool
+ * true if allowed
*/
public static function getValidAdditionalIds($participantId, $oldStatusId, $newStatusId) {
*
* @param int $contactID
*
- * @return int count of participant records
+ * @return int
+ * count of participant records
* @static
*/
public static function getContactParticipantCount($contactID) {
* @param bool $excludeCancelled
* Exclude cancelled additional participant.
*
- * @return array $participantsId
+ * @return array
* @static
*/
public static function getParticipantIds($contributionId, $excludeCancelled = FALSE) {
// get additional participant ids (including cancelled)
if ($participantId) {
$ids = array_merge(array(
- $participantId), self::getAdditionalParticipantIds($participantId,
- $excludeCancelled
- ));
+ $participantId,
+ ), self::getAdditionalParticipantIds($participantId,
+ $excludeCancelled
+ ));
}
return $ids;
* @param array $participantIds
* An array of additional participant ids.
*
- * @return array of Urls.
+ * @return array
+ * of Urls.
* @static
*/
public static function getAdditionalParticipantUrl($participantIds) {
foreach ($participantIds as $value) {
- $links = array();
+ $links = array();
$details = self::participantDetails($value);
$viewUrl = CRM_Utils_System::url('civicrm/contact/view/participant',
"action=view&reset=1&id={$value}&cid={$details['cid']}"
}
/**
- * To create trxn entry if an event has discount.
+ * create trxn entry if an event has discount.
*
* @param int $eventID
* Event id.
*/
public static function createDiscountTrxn($eventID, $contributionParams, $feeLevel) {
// CRM-11124
- $checkDiscount = CRM_Core_BAO_Discount::findSet($eventID,'civicrm_event');
+ $checkDiscount = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if (!empty($checkDiscount)) {
$feeLevel = current($feeLevel);
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID, NULL);
$query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv
LEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id
WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
- $params = array(1 => array($priceSetId, 'Integer'),
- 2 => array($feeLevel, 'String'));
+ $params = array(
+ 1 => array($priceSetId, 'Integer'),
+ 2 => array($feeLevel, 'String'),
+ );
$mainAmount = CRM_Core_DAO::singleValueQuery($query, $params);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Discounts Account is' "));
$contributionParams['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType(
if (!empty($contributionParams['trxnParams']['from_financial_account_id'])) {
$contributionParams['trxnParams']['total_amount'] = $mainAmount - $contributionParams['total_amount'];
$contributionParams['trxnParams']['payment_processor_id'] = $contributionParams['trxnParams']['payment_instrument_id'] =
- $contributionParams['trxnParams']['check_number'] = $contributionParams['trxnParams']['trxn_id'] =
- $contributionParams['trxnParams']['net_amount'] = $contributionParams['trxnParams']['fee_amount'] = NULL;
+ $contributionParams['trxnParams']['check_number'] = $contributionParams['trxnParams']['trxn_id'] =
+ $contributionParams['trxnParams']['net_amount'] = $contributionParams['trxnParams']['fee_amount'] = NULL;
CRM_Core_BAO_FinancialTrxn::create($contributionParams['trxnParams']);
}
unset($insertLines[$previousLineItem['price_field_value_id']]);
// for updating the line items i.e. use-case - once deselect-option selecting again
if (($previousLineItem['line_total'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total']) ||
- ($submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1)) {
+ ($submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1)
+ ) {
$updateLines[$previousLineItem['price_field_value_id']] = $submittedLineItems[$previousLineItem['price_field_value_id']];
$updateLines[$previousLineItem['price_field_value_id']]['id'] = $id;
}
// if not submitted and difference is not 0 make it negative
if (!in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] != 0) {
// INSERT negative financial_items
- $updateFinancialItemInfoValues['amount'] = - $updateFinancialItemInfoValues['amount'];
+ $updateFinancialItemInfoValues['amount'] = -$updateFinancialItemInfoValues['amount'];
CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
// INSERT negative financial_items for tax amount
if ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']) {
- $updateFinancialItemInfoValues['amount'] = - ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
+ $updateFinancialItemInfoValues['amount'] = -($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
$updateFinancialItemInfoValues['description'] = $taxTerm;
if ($updateFinancialItemInfoValues['financial_type_id']) {
$updateFinancialItemInfoValues['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateFinancialItemInfoValues['financial_type_id']);
}
}
}
- elseif (empty($submittedFields) && empty($submittedFieldValues)){
+ elseif (empty($submittedFields) && empty($submittedFieldValues)) {
$updateLineItem = "UPDATE civicrm_line_item li
INNER JOIN civicrm_financial_item fi
ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')
$partUpdateFeeAmt['id'] = $participantId;
foreach ($lineItems as $lineValue) {
if ($lineValue['price_field_value_id']) {
- $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - '. $lineValue['qty'];
- }
+ $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - ' . $lineValue['qty'];
+ }
}
$partUpdateFeeAmt['fee_level'] = implode(', ', $line);
'payment_instrument_id' => $updatedContribution->payment_instrument_id,
'contribution_id' => $updatedContribution->id,
'trxn_date' => date('YmdHis'),
- 'currency' => $updatedContribution->currency
+ 'currency' => $updatedContribution->currency,
);
$adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
}