本文整理汇总了PHP中CRM_Event_BAO_Participant::priceSetOptionsCount方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant::priceSetOptionsCount方法的具体用法?PHP CRM_Event_BAO_Participant::priceSetOptionsCount怎么用?PHP CRM_Event_BAO_Participant::priceSetOptionsCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Participant
的用法示例。
在下文中一共展示了CRM_Event_BAO_Participant::priceSetOptionsCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatFieldsForOptionFull
public static function formatFieldsForOptionFull(&$form)
{
$priceSet = $form->get('priceSet');
$priceSetId = $form->get('priceSetId');
if (!$priceSetId || !is_array($priceSet) || empty($priceSet) || !CRM_Utils_Array::value('optionsMaxValueTotal', $priceSet)) {
return;
}
$skipParticipants = $formattedPriceSetDefaults = array();
if ($form->_allowConfirmation && (isset($form->_pId) || isset($form->_additionalParticipantId))) {
$participantId = isset($form->_pId) ? $form->_pId : $form->_additionalParticipantId;
$pricesetDefaults = CRM_Event_Form_EventFees::setDefaultPriceSet($participantId, $form->_eventId);
// modify options full to respect the selected fields
// options on confirmation.
$formattedPriceSetDefaults = self::formatPriceSetParams($form, $pricesetDefaultOptions);
// to skip current registered participants fields option count on confirmation.
$skipParticipants[] = $form->_participantId;
if (!empty($form->_additionalParticipantIds)) {
$skipParticipants = array_merge($skipParticipants, $form->_additionalParticipantIds);
}
}
$className = CRM_Utils_System::getClassName($form);
//get the current price event price set options count.
$currentOptionsCount = self::getPriceSetOptionCount($form);
$recordedOptionsCount = CRM_Event_BAO_Participant::priceSetOptionsCount($form->_eventId, $skipParticipants);
foreach ($form->_feeBlock as &$field) {
$optionFullIds = array();
$fieldId = $field['id'];
if (!is_array($field['options'])) {
continue;
}
foreach ($field['options'] as &$option) {
$optId = $option['id'];
$count = CRM_Utils_Array::value('count', $option, 0);
$maxValue = CRM_Utils_Array::value('max_value', $option, 0);
$dbTotalCount = CRM_Utils_Array::value($optId, $recordedOptionsCount, 0);
$currentTotalCount = CRM_Utils_Array::value($optId, $currentOptionsCount, 0);
// Do not consider current count for select field,
// since we are not going to freeze the options.
if ($field['html_type'] == 'Select') {
$totalCount = $dbTotalCount;
} else {
$totalCount = $currentTotalCount + $dbTotalCount;
}
$isFull = FALSE;
if ($maxValue && ($totalCount >= $maxValue || $totalCount + $count > $maxValue)) {
$isFull = TRUE;
$optionFullIds[$optId] = $optId;
}
//here option is not full,
//but we don't want to allow participant to increase
//seats at the time of re-walking registration.
if ($count && $form->_allowConfirmation && !empty($formattedPriceSetDefaults)) {
if (!CRM_Utils_Array::value("price_{$field}", $formattedPriceSetDefaults) || !CRM_Utils_Array::value($opId, $formattedPriceSetDefaults["price_{$fieldId}"])) {
$optionFullIds[$optId] = $optId;
$isFull = TRUE;
}
}
$option['is_full'] = $isFull;
$option['db_total_count'] = $dbTotalCount;
$option['total_option_count'] = $dbTotalCount + $currentTotalCount;
}
//ignore option full for offline registration.
if ($className == 'CRM_Event_Form_Participant') {
$optionFullIds = array();
}
//finally get option ids in.
$field['option_full_ids'] = $optionFullIds;
}
}