本文整理汇总了PHP中CRM_Price_BAO_PriceField类 的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceField类的具体用法?PHP CRM_Price_BAO_PriceField怎么用?PHP CRM_Price_BAO_PriceField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Price_BAO_PriceField类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Insert/update a new entry in the database.
*
* @param array $params
* (reference), array $ids.
*
* @param $ids
*
* @return CRM_Price_DAO_PriceFieldValue
*/
public static function add(&$params, $ids = array())
{
$fieldValueBAO = new CRM_Price_BAO_PriceFieldValue();
$fieldValueBAO->copyValues($params);
if ($id = CRM_Utils_Array::value('id', $ids)) {
$fieldValueBAO->id = $id;
}
if (!empty($params['is_default'])) {
$query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE price_field_id = %1';
$p = array(1 => array($params['price_field_id'], 'Integer'));
CRM_Core_DAO::executeQuery($query, $p);
}
$fieldValueBAO->save();
// Reset the cached values in this function.
CRM_Price_BAO_PriceField::getOptions(CRM_Utils_Array::value('price_field_id', $params), FALSE, TRUE);
return $fieldValueBAO;
}
开发者ID:utkarshsharma, 项目名称:civicrm-core, 代码行数:27, 代码来源:PriceFieldValue.php
示例2: build_price_options
function build_price_options($event)
{
$price_fields_for_event = array();
$base_field_name = "event_{$event->id}_amount";
$price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $event->id);
if ($price_set_id) {
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE, TRUE);
$price_set = $price_sets[$price_set_id];
$index = -1;
foreach ($price_set['fields'] as $field) {
$index++;
$field_name = "event_{$event->id}_price_{$field['id']}";
CRM_Price_BAO_PriceField::addQuickFormElement($this, $field_name, $field['id'], FALSE);
$price_fields_for_event[] = $field_name;
}
}
return $price_fields_for_event;
}
开发者ID:hguru, 项目名称:224Civi, 代码行数:18, 代码来源:ParticipantsAndPrices.php
示例3: _addParticipantWithPayment
/**
* helper function to record participant with paid contribution.
* @param $feeTotal
* @param $actualPaidAmt
*
* @return array
* @throws Exception
*/
public function _addParticipantWithPayment($feeTotal, $actualPaidAmt)
{
// creating price set, price field
$paramsSet['title'] = 'Price Set';
$paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
$paramsSet['is_active'] = FALSE;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceset->id);
$priceSetId = $priceset->id;
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => $feeTotal, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => $feeTotal), 'option_name' => array('1' => $feeTotal), 'option_weight' => array('1' => 1), 'option_amount' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
$ids = array();
$pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
// create participant record
$eventId = $this->_eventId;
$participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 14, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
$participant = $this->callAPISuccess('participant', 'create', $participantParams);
$this->callAPISuccessGetSingle('participant', array('id' => $participant['id']));
// create participant contribution with partial payment
$contributionParams = array('total_amount' => $actualPaidAmt, 'source' => 'Fall Fundraiser Dinner: Offline registration', 'currency' => 'USD', 'non_deductible_amount' => 'null', 'receipt_date' => date('Y-m-d') . " 00:00:00", 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'payment_instrument_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Y-m-d') . " 00:00:00", 'skipLineItem' => 1, 'partial_payment_total' => $feeTotal, 'partial_amount_pay' => $actualPaidAmt);
$contribution = CRM_Contribute_BAO_Contribution::create($contributionParams);
$contributionId = $contribution->id;
$participant = $this->callAPISuccessGetSingle('participant', array('id' => $participant['id']));
// add participant payment entry
$this->callAPISuccess('participant_payment', 'create', array('participant_id' => $participant['id'], 'contribution_id' => $contributionId));
// -- processing priceSet using the BAO
$lineItem = array();
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$params['price_2'] = $feeTotal;
CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItem);
$lineItemVal[$priceSetId] = $lineItem;
CRM_Price_BAO_LineItem::processPriceSet($participant['id'], $lineItemVal, $contribution, 'civicrm_participant');
return array($participant, $contribution);
}
开发者ID:rajeshrhino, 项目名称:civicrm-core, 代码行数:48, 代码来源:AdditionalPaymentTest.php
示例4: addParticipantWithContribution
/**
* Add participant with contribution
*
* @return array
*/
protected function addParticipantWithContribution()
{
// creating price set, price field
require_once 'CiviTest/Event.php';
$this->_contactId = Contact::createIndividual();
$this->_eventId = Event::create($this->_contactId);
$paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 4);
$paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
$paramsSet['is_active'] = TRUE;
$paramsSet['financial_type_id'] = 4;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
$priceSetId = $priceset->id;
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'CheckBox', 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_value' => array('1' => 100, '2' => 200), 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_weight' => array('1' => 1, '2' => 2), 'option_amount' => array('1' => 100, '2' => 200), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1, '2' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1, 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'));
$priceField = CRM_Price_BAO_PriceField::create($paramsField);
$eventParams = array('id' => $this->_eventId, 'financial_type_id' => 4, 'is_monetary' => 1);
CRM_Event_BAO_Event::create($eventParams);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetId);
$priceFields = $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id));
$participantParams = array('financial_type_id' => 4, 'event_id' => $this->_eventId, 'role_id' => 1, 'status_id' => 14, 'fee_currency' => 'USD', 'contact_id' => $this->_contactId);
$participant = CRM_Event_BAO_Participant::add($participantParams);
$contributionParams = array('total_amount' => 150, 'currency' => 'USD', 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'contribution_status_id' => 1, 'partial_payment_total' => 300.0, 'partial_amount_pay' => 150, 'contribution_mode' => 'participant', 'participant_id' => $participant->id);
foreach ($priceFields['values'] as $key => $priceField) {
$lineItems[1][$key] = array('price_field_id' => $priceField['price_field_id'], 'price_field_value_id' => $priceField['id'], 'label' => $priceField['label'], 'field_title' => $priceField['label'], 'qty' => 1, 'unit_price' => $priceField['amount'], 'line_total' => $priceField['amount'], 'financial_type_id' => $priceField['financial_type_id']);
}
$contributionParams['line_item'] = $lineItems;
$contributions = CRM_Contribute_BAO_Contribution::create($contributionParams);
$paymentParticipant = array('participant_id' => $participant->id, 'contribution_id' => $contributions->id);
$ids = array();
CRM_Event_BAO_ParticipantPayment::create($paymentParticipant, $ids);
return array($lineItems, $contributions);
}
开发者ID:konadave, 项目名称:civicrm-core, 代码行数:39, 代码来源:ContributionTest.php
示例5: postProcess
/**
* Process the form.
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues('Field');
$params['is_display_amounts'] = CRM_Utils_Array::value('is_display_amounts', $params, FALSE);
$params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, FALSE);
if (isset($params['active_on'])) {
$params['active_on'] = CRM_Utils_Date::processDate($params['active_on'], CRM_Utils_Array::value('active_on_time', $params), TRUE);
}
if (isset($params['expire_on'])) {
$params['expire_on'] = CRM_Utils_Date::processDate($params['expire_on'], CRM_Utils_Array::value('expire_on_time', $params), TRUE);
}
$params['visibility_id'] = CRM_Utils_Array::value('visibility_id', $params, FALSE);
$params['count'] = CRM_Utils_Array::value('count', $params, FALSE);
// need the FKEY - price set id
$params['price_set_id'] = $this->_sid;
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
$fieldValues = array('price_set_id' => $this->_sid);
$oldWeight = NULL;
if ($this->_fid) {
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id');
}
$params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', $oldWeight, $params['weight'], $fieldValues);
}
// make value <=> name consistency.
if (isset($params['option_name'])) {
$params['option_value'] = $params['option_name'];
}
$params['is_enter_qty'] = CRM_Utils_Array::value('is_enter_qty', $params, FALSE);
if ($params['html_type'] == 'Text') {
// if html type is Text, force is_enter_qty on
$params['is_enter_qty'] = 1;
// modify params values as per the option group and option
// value
$params['option_amount'] = array(1 => $params['price']);
$params['option_label'] = array(1 => $params['label']);
$params['option_count'] = array(1 => $params['count']);
$params['option_max_value'] = array(1 => CRM_Utils_Array::value('max_value', $params));
//$params['option_description'] = array( 1 => $params['description'] );
$params['option_weight'] = array(1 => $params['weight']);
$params['option_financial_type_id'] = array(1 => $params['financial_type_id']);
}
if ($this->_fid) {
$params['id'] = $this->_fid;
}
$params['membership_num_terms'] = !empty($params['membership_type_id']) ? CRM_Utils_Array::value('membership_num_terms', $params, 1) : NULL;
$priceField = CRM_Price_BAO_PriceField::create($params);
if (!is_a($priceField, 'CRM_Core_Error')) {
CRM_Core_Session::setStatus(ts('Price Field \'%1\' has been saved.', array(1 => $priceField->label)), ts('Saved'), 'success');
}
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($buttonName == $this->getButtonName('next', 'new')) {
CRM_Core_Session::setStatus(ts(' You can add another price set field.'), '', 'info');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=add&sid=' . $this->_sid));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid));
}
}
开发者ID:hyebahi, 项目名称:civicrm-core, 代码行数:64, 代码来源:Field.php
示例6: postProcess
/**
* Process the form.
*/
public function postProcess()
{
$eventTitle = '';
$params = $this->exportValues();
$this->set('discountSection', 0);
if (!empty($_POST['_qf_Fee_submit'])) {
$this->buildAmountLabel();
$this->set('discountSection', 2);
return;
}
if (!empty($params['payment_processor'])) {
$params['payment_processor'] = str_replace(',', CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']);
} else {
$params['payment_processor'] = 'null';
}
$params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
$params['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $params, 0);
if ($this->_id) {
// delete all the prior label values or discounts in the custom options table
// and delete a price set if one exists
//@todo note that this removes the reference from existing participants -
// even where there is not change - redress?
// note that a more tentative form of this is invoked by passing price_set_id as an array
// to event.create see CRM-14069
// @todo get all of this logic out of form layer (currently partially in BAO/api layer)
if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $this->_id)) {
CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
}
}
if ($params['is_monetary']) {
if (!empty($params['price_set_id'])) {
//@todo this is now being done in the event BAO if passed price_set_id as an array
// per notes on that fn - looking at the api converting to an array
// so calling via the api may cause this to be done in the api
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $params['price_set_id']);
if (!empty($params['price_field_id'])) {
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
}
} else {
// if there are label / values, create custom options for them
$labels = CRM_Utils_Array::value('label', $params);
$values = CRM_Utils_Array::value('value', $params);
$default = CRM_Utils_Array::value('default', $params);
$options = array();
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
$options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
if (!empty($options)) {
$params['default_fee_id'] = NULL;
if (empty($params['price_set_id'])) {
if (empty($params['price_field_id'])) {
$setParams['title'] = $eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
$eventTitle = strtolower(CRM_Utils_String::munge($eventTitle, '_', 245));
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle, 'id', 'name')) {
$setParams['name'] = $eventTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle . '_' . $this->_id, 'id', 'name')) {
$setParams['name'] = $eventTitle . '_' . $this->_id;
} else {
$timeSec = explode('.', microtime(TRUE));
$setParams['name'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['financial_type_id'] = $params['financial_type_id'];
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$fieldParams['name'] = strtolower(CRM_Utils_String::munge($params['fee_label'], '_', 245));
$fieldParams['price_set_id'] = $priceSet->id;
} else {
foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
CRM_Price_BAO_PriceFieldValue::setIsActive($fieldValueID, '0');
unset($params['price_field_value'][$arrayID]);
}
}
$fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
$fieldParams['option_id'] = $params['price_field_value'];
$priceSet = new CRM_Price_BAO_PriceSet();
$priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) {
CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $priceSet->id, 'financial_type_id', $params['financial_type_id']);
}
}
$fieldParams['label'] = $params['fee_label'];
$fieldParams['html_type'] = 'Radio';
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $priceSet->id);
$fieldParams['option_label'] = $params['label'];
$fieldParams['option_amount'] = $params['value'];
$fieldParams['financial_type_id'] = $params['financial_type_id'];
foreach ($options as $value) {
$fieldParams['option_weight'][$value['weight']] = $value['weight'];
}
$fieldParams['default_option'] = $params['default'];
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
//.........这里部分代码省略.........
开发者ID:saurabhbatra96, 项目名称:civicrm-core, 代码行数:101, 代码来源:Fee.php
示例7: eventPriceSetCreate
/**
* Create a price set for an event.
*
* @param int $feeTotal
*
* @return int
* Price Set ID.
*/
protected function eventPriceSetCreate($feeTotal)
{
// creating price set, price field
$paramsSet['title'] = 'Price Set';
$paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
$paramsSet['is_active'] = FALSE;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
$priceSetId = $priceset->id;
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => $feeTotal, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => $feeTotal), 'option_name' => array('1' => $feeTotal), 'option_weight' => array('1' => 1), 'option_amount' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1, 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'));
CRM_Price_BAO_PriceField::create($paramsField);
return $priceSetId;
}
开发者ID:vincent1892, 项目名称:civicrm-core, 代码行数:23, 代码来源:CiviUnitTestCase.php
示例8: buildAmount
/**
* build the radio/text form elements for the amount field
*
* @param object $form form object
* @param boolean $required true if you want to add formRule
* @param int $discountId discount id for the event
*
* @return void
* @access public
* @static
*/
public static function buildAmount(&$form, $required = TRUE, $discountId = NULL)
{
//if payment done, no need to build the fee block.
if (!empty($form->_paymentId)) {
//fix to display line item in update mode.
$form->assign('priceSet', isset($form->_priceSet) ? $form->_priceSet : NULL);
return;
}
$feeFields = CRM_Utils_Array::value('fee', $form->_values);
if (is_array($feeFields)) {
$form->_feeBlock =& $form->_values['fee'];
}
//check for discount.
$discountedFee = CRM_Utils_Array::value('discount', $form->_values);
if (is_array($discountedFee) && !empty($discountedFee)) {
if (!$discountId) {
$form->_discountId = $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
}
if ($discountId) {
$form->_feeBlock =& $form->_values['discount'][$discountId];
}
}
if (!is_array($form->_feeBlock)) {
$form->_feeBlock = array();
}
//its time to call the hook.
CRM_Utils_Hook::buildAmount('event', $form, $form->_feeBlock);
//reset required if participant is skipped.
$button = substr($form->controller->getButtonName(), -4);
if ($required && $button == 'skip') {
$required = FALSE;
}
$className = CRM_Utils_System::getClassName($form);
//build the priceset fields.
if (isset($form->_priceSetId) && $form->_priceSetId) {
//format price set fields across option full.
self::formatFieldsForOptionFull($form);
if (CRM_Utils_Array::value('is_quick_config', $form->_priceSet)) {
$form->_quickConfig = $form->_priceSet['is_quick_config'];
}
$form->add('hidden', 'priceSetId', $form->_priceSetId);
foreach ($form->_feeBlock as $field) {
if (CRM_Utils_Array::value('visibility', $field) == 'public' || $className == 'CRM_Event_Form_Participant') {
$fieldId = $field['id'];
$elementName = 'price_' . $fieldId;
$isRequire = CRM_Utils_Array::value('is_required', $field);
if ($button == 'skip') {
$isRequire = FALSE;
}
//user might modified w/ hook.
$options = CRM_Utils_Array::value('options', $field);
if (!is_array($options)) {
continue;
}
$optionFullIds = CRM_Utils_Array::value('option_full_ids', $field, array());
//soft suppress required rule when option is full.
if (!empty($optionFullIds) && count($options) == count($optionFullIds)) {
$isRequire = FALSE;
}
//build the element.
CRM_Price_BAO_PriceField::addQuickFormElement($form, $elementName, $fieldId, FALSE, $isRequire, NULL, $options, $optionFullIds);
}
}
$form->assign('priceSet', $form->_priceSet);
} else {
$eventFeeBlockValues = array();
foreach ($form->_feeBlock as $fee) {
if (is_array($fee)) {
//CRM-7632, CRM-6201
$totalAmountJs = NULL;
if ($className == 'CRM_Event_Form_Participant') {
$totalAmountJs = array('onClick' => "fillTotalAmount(" . $fee['value'] . ")");
}
$eventFeeBlockValues['amount_id_' . $fee['amount_id']] = $fee['value'];
$elements[] =& $form->createElement('radio', NULL, '', CRM_Utils_Money::format($fee['value']) . ' ' . $fee['label'], $fee['amount_id'], $totalAmountJs);
}
}
$form->assign('eventFeeBlockValues', json_encode($eventFeeBlockValues));
$form->_defaults['amount'] = CRM_Utils_Array::value('default_fee_id', $form->_values['event']);
$element =& $form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
if (isset($form->_online) && $form->_online) {
$element->freeze();
}
if ($required) {
$form->addRule('amount', ts('Fee Level is a required field.'), 'required');
}
}
}
开发者ID:TheCraftyCanvas, 项目名称:aegir-platforms, 代码行数:99, 代码来源:Register.php
示例9: processMembership
/**
* process membership records
*
* @param array $params associated array of submitted values
*
* @access public
*
* @return bool
*/
private function processMembership(&$params)
{
$dateTypes = array('join_date' => 'joinDate', 'membership_start_date' => 'startDate', 'membership_end_date' => 'endDate');
$dates = array('join_date', 'start_date', 'end_date', 'reminder_date');
// get the price set associated with offline memebership
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
if (isset($params['field'])) {
$customFields = array();
foreach ($params['field'] as $key => $value) {
// if contact is not selected we should skip the row
if (empty($params['primary_contact_id'][$key])) {
continue;
}
$value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']);
// update contact information
$this->updateContactInfo($value);
$membershipTypeId = $value['membership_type_id'] = $value['membership_type'][1];
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($value[$dateField]);
}
$calcDates = array();
$calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId, $joinDate, $startDate, $endDate);
foreach ($calcDates as $memType => $calcDate) {
foreach ($dates as $d) {
//first give priority to form values then calDates.
$date = CRM_Utils_Array::value($d, $value);
if (!$date) {
$date = CRM_Utils_Array::value($d, $calcDate);
}
$value[$d] = CRM_Utils_Date::processDate($date);
}
}
if (!empty($value['send_receipt'])) {
$value['receipt_date'] = date('Y-m-d His');
}
if (!empty($value['membership_source'])) {
$value['source'] = $value['membership_source'];
}
unset($value['membership_source']);
//Get the membership status
if (!empty($value['membership_status'])) {
$value['status_id'] = $value['membership_status'];
unset($value['membership_status']);
}
if (empty($customFields)) {
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $membershipTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
}
//check for custom data
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key], $customFields, $key, 'Membership', $membershipTypeId);
if (!empty($value['financial_type'])) {
$value['financial_type_id'] = $value['financial_type'];
}
if (!empty($value['payment_instrument'])) {
$value['payment_instrument_id'] = $value['payment_instrument'];
}
// handle soft credit
if (is_array(CRM_Utils_Array::value('soft_credit_contact_id', $params)) && !empty($params['soft_credit_contact_id'][$key]) && CRM_Utils_Array::value($key, $params['soft_credit_amount'])) {
$value['soft_credit'][$key]['contact_id'] = $params['soft_credit_contact_id'][$key];
$value['soft_credit'][$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
}
if (!empty($value['receive_date'])) {
$value['receive_date'] = CRM_Utils_Date::processDate($value['receive_date'], $value['receive_date_time'], TRUE);
}
$params['actualBatchTotal'] += $value['total_amount'];
unset($value['financial_type']);
unset($value['payment_instrument']);
$value['batch_id'] = $this->_batchId;
$value['skipRecentView'] = TRUE;
// make entry in line item for contribution
$editedFieldParams = array('price_set_id' => $priceSetId, 'name' => $value['membership_type'][0]);
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (!empty($editedResults)) {
unset($this->_priceSet['fields']);
$this->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
unset($this->_priceSet['fields'][$editedResults['id']]['options']);
$fid = $editedResults['id'];
$editedFieldParams = array('price_field_id' => $editedResults['id'], 'membership_type_id' => $value['membership_type_id']);
$editedResults = array();
CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
if (!empty($value['total_amount'])) {
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']]['amount'] = $value['total_amount'];
}
$fieldID = key($this->_priceSet['fields']);
$value['price_' . $fieldID] = $editedResults['id'];
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
//.........这里部分代码省略.........
开发者ID:prashantgajare, 项目名称:civicrm-core, 代码行数:101, 代码来源:Entry.php
示例10: processMembership
/**
* Process membership records.
*
* @param array $params
* Associated array of submitted values.
*
*
* @return bool
*/
private function processMembership(&$params)
{
$dateTypes = array('join_date' => 'joinDate', 'membership_start_date' => 'startDate', 'membership_end_date' => 'endDate');
$dates = array('join_date', 'start_date', 'end_date', 'reminder_date');
// get the price set associated with offline membership
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
if (isset($params['field'])) {
$customFields = array();
foreach ($params['field'] as $key => $value) {
// if contact is not selected we should skip the row
if (empty($params['primary_contact_id'][$key])) {
continue;
}
$value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']);
// update contact information
$this->updateContactInfo($value);
$membershipTypeId = $value['membership_type_id'] = $value['membership_type'][1];
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($value[$dateField]);
$fDate[$dateField] = CRM_Utils_Array::value($dateField, $value);
}
$calcDates = array();
$calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId, $joinDate, $startDate, $endDate);
foreach ($calcDates as $memType => $calcDate) {
foreach ($dates as $d) {
//first give priority to form values then calDates.
$date = CRM_Utils_Array::value($d, $value);
if (!$date) {
$date = CRM_Utils_Array::value($d, $calcDate);
}
$value[$d] = CRM_Utils_Date::processDate($date);
}
}
if (!empty($value['send_receipt'])) {
$value['receipt_date'] = date('Y-m-d His');
}
if (!empty($value['membership_source'])) {
$value['source'] = $value['membership_source'];
}
unset($value['membership_source']);
//Get the membership status
if (!empty($value['membership_status'])) {
$value['status_id'] = $value['membership_status'];
unset($value['membership_status']);
}
if (empty($customFields)) {
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $membershipTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
}
//check for custom data
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key], $key, 'Membership', $membershipTypeId);
if (!empty($value['financial_type'])) {
$value['financial_type_id'] = $value['financial_type'];
}
if (!empty($value['payment_instrument'])) {
$value['payment_instrument_id'] = $value['payment_instrument'];
}
// handle soft credit
if (!empty($params['soft_credit_contact_id'][$key]) && !empty($params['soft_credit_amount'][$key])) {
$value['soft_credit'][$key]['contact_id'] = $params['soft_credit_contact_id'][$key];
$value['soft_credit'][$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
//CRM-15350: if soft-credit-type profile field is disabled or removed then
//we choose Gift as default value as per Gift Membership rule
if (!empty($params['soft_credit_type'][$key])) {
$value['soft_credit'][$key]['soft_credit_type_id'] = $params['soft_credit_type'][$key];
} else {
$value['soft_credit'][$key]['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
}
if (!empty($value['receive_date'])) {
$value['receive_date'] = CRM_Utils_Date::processDate($value['receive_date'], $value['receive_date_time'], TRUE);
}
$params['actualBatchTotal'] += $value['total_amount'];
unset($value['financial_type']);
unset($value['payment_instrument']);
$value['batch_id'] = $this->_batchId;
$value['skipRecentView'] = TRUE;
// make entry in line item for contribution
$editedFieldParams = array('price_set_id' => $priceSetId, 'name' => $value['membership_type'][0]);
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (!empty($editedResults)) {
unset($this->_priceSet['fields']);
$this->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
unset($this->_priceSet['fields'][$editedResults['id']]['options']);
$fid = $editedResults['id'];
$editedFieldParams = array('price_field_id' => $editedResults['id'], 'membership_type_id' => $value['membership_type_id']);
$editedResults = array();
CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
//.........这里部分代码省略.........
开发者ID:kcristiano, 项目名称:civicrm-core, 代码行数:101, 代码来源:Entry.php
示例11: formRule
/**
* Global form rule.
*
* @param array $fields
* The input form values.
* @param array $files
* The uploaded files if any.
* @param $self
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $self)
{
$errors = array();
// Check for Credit Card Contribution.
if ($self->_mode) {
if (empty($fields['payment_processor_id'])) {
$errors['payment_processor_id'] = ts('Payment Processor is a required field.');
} else {
// validate payment instrument (e.g. credit card number)
CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, NULL);
}
}
// Do the amount validations.
if (empty($fields['total_amount']) && empty($self->_lineItems)) {
if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $fields, $errors);
}
}
$softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
$sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
// For taxable contribution we need to deduct taxable amount from
// (net amount + fee amount) before comparing it with total amount
if (!empty($self->_values['tax_amount'])) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($self->_id);
if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
$sum = CRM_Utils_Money::format($sum - $self->_values['tax_amount'], NULL, '%a');
}
}
if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
$errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
}
}
//CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
// Form rule for status http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
if ($self->_action & CRM_Core_Action::UPDATE && $self->_id && $self->_values['contribution_status_id'] != $fields['contribution_status_id']) {
CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors);
}
// CRM-16015, add form-rule to restrict change of financial type if using price field of different financial type
if ($self->_action & CRM_Core_Action::UPDATE && $self->_id && $self->_values['financial_type_id'] != $fields['financial_type_id']) {
CRM_Contribute_BAO_Contribution::checkFinancialTypeChange(NULL, $self->_id, $errors);
}
//FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
if (!empty($fields['fee_amount']) && !empty($fields['financial_type_id']) && ($financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id']))) {
$errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
}
// $trxn_id must be unique CRM-13919
if (!empty($fields['trxn_id'])) {
$queryParams = array(1 => array($fields['trxn_id'], 'String'));
$query = 'select count(*) from civicrm_contribution where trxn_id = %1';
if ($self->_id) {
$queryParams[2] = array((int) $self->_id, 'Integer');
$query .= ' and id !=%2';
}
$tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams);
if ($tCnt) {
$errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
}
}
$errors = array_merge($errors, $softErrors);
return $errors;
}
开发者ID:hyebahi, 项目名称:civicrm-core, 代码行数:75, 代码来源:Contribution.php
示例12: createPriceSet
/**
* Create price set
*
* @param string $component
* @param int $componentId
*
* @return array
*/
protected function createPriceSet($component = 'contribution_page', $componentId = NULL)
{
$paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 7);
$paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
$paramsSet['is_active'] = TRUE;
$paramsSet['financial_type_id'] = 4;
$paramsSet['extends'] = 1;
$priceSet = $this->callAPISuccess('price_set', 'create', $paramsSet);
$priceSetId = $priceSet['id'];
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'CheckBox', 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_value' => array('1' => 100, '2' => 200), 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_weight' => array('1' => 1, '2' => 2), 'option_amount' => array('1' => 100, '2' => 200), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1, '2' => 1), 'price_set_id' => $priceSet['id'], 'is_enter_qty' => 1, 'financial_type_id' => $this->getFinancialTypeId('Event Fee'));
$priceField = CRM_Price_BAO_PriceField::create($paramsField);
if ($componentId) {
CRM_Price_BAO_PriceSet::addTo('civicrm_' . $component, $componentId, $priceSetId);
}
return $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id));
}
开发者ID:nielosz, 项目名称:civicrm-core, 代码行数:26, 代码来源:CiviUnitTestCase.php
示例13: build_price_options
/**
* Build price options.
*
* @param CRM_Event_BAO_Event $event
*
* @return array
*/
public function build_price_options($event)
{
$price_fields_for_event = array();
$base_field_name = "event_{$event->id}_amount";
$price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $event->id);
//CRM-14492 display admin fields only if user is admin
$adminFieldVisible = FALSE;
if (CRM_Core_Permission::check('administer CiviCRM')) {
$adminFieldVisible = TRUE;
}
if ($price_set_id) {
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE, TRUE);
$price_set = $price_sets[$price_set_id];
$index = -1;
foreach ($price_set['fields'] as $field) {
$index++;
if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE) {
$field_name = "event_{$event->id}_price_{$field['id']}";
CRM_Price_BAO_PriceField::addQuickFormElement($this, $field_name, $field['id'], FALSE);
$price_fields_for_event[] = $field_name;
}
}
}
return $price_fields_for_event;
}
开发者ID:kcristiano, 项目名称:civicrm-core, 代码行数:32, 代码来源:ParticipantsAndPrices.php
librespeed/speedtest: Self-hosted Speedtest for HTML5 and more. Easy setup, exam
阅读:1218| 2022-08-30
avehtari/BDA_m_demos: Bayesian Data Analysis demos for Matlab/Octave
阅读:1130| 2022-08-17
女人怀孕后,为了有一个健康聪明的宝宝,经历各种体检、筛查。其实这些体检和筛查中的
阅读:938| 2022-11-06
medfreeman/markdown-it-toc-and-anchor: markdown-it plugin to add a toc and ancho
阅读:1334| 2022-08-18
微慕小程序专业版支持在文章的详情页跳转商品卡片和公众号文章卡片;不过这些跳转卡片
阅读:588| 2022-07-18
微信小程序不知不觉都走过了三个年头。
从当初的一夜成名到今天火爆的市场占有率,微
阅读:608| 2022-07-18
** REJECT ** DO NOT USE THIS CANDIDATE NUMBER. ConsultIDs: none. Reason: This ca
阅读:504| 2022-07-08
sydney0zq/covid-19-detection: The implementation of A Weakly-supervised Framewor
阅读:484| 2022-08-16
kubernetes-client/python: Official Python client library for kubernetes
阅读:582| 2022-08-15
离中国最远的国家是阿根廷。从太平洋直线计算,即往东线走,北京到阿根廷的布宜诺斯艾
阅读:636| 2022-11-06
请发表评论