本文整理汇总了PHP中CRM_Price_BAO_PriceFieldValue类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceFieldValue类的具体用法?PHP CRM_Price_BAO_PriceFieldValue怎么用?PHP CRM_Price_BAO_PriceFieldValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Price_BAO_PriceFieldValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: CRM_Price_BAO_PriceFieldValue
/**
* insert/update a new entry in the database.
*
* @param array $params (reference), array $ids
*
* @return object CRM_Price_DAO_PriceFieldValue object
* @access public
* @static
*/
static function &add(&$params, $ids)
{
$fieldValueBAO = new CRM_Price_BAO_PriceFieldValue();
$fieldValueBAO->copyValues($params);
if ($id = CRM_Utils_Array::value('id', $ids)) {
$fieldValueBAO->id = $id;
}
if (CRM_Utils_Array::value('is_default', $params)) {
$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();
return $fieldValueBAO;
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:24,代码来源:PriceFieldValue.php
示例2: 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
示例3: civicrm_api3_price_field_value_create
/**
* Create or update a price_field_value
*
* @param array $params Associative array of property
* name/value pairs to insert in new 'price_field_value'
* @example PriceFieldValueCreate.php Std Create example
*
* @return array api result array
* {@getfields price_field_value_create}
* @access public
*/
function civicrm_api3_price_field_value_create($params)
{
$ids = array();
if (!empty($params['id'])) {
$ids['id'] = $params['id'];
}
$bao = CRM_Price_BAO_PriceFieldValue::create($params, $ids);
$values = array();
_civicrm_api3_object_to_array($bao, $values[$bao->id]);
return civicrm_api3_create_success($values, $params, 'price_field_value', 'create', $bao);
}
开发者ID:hguru,项目名称:224Civi,代码行数:22,代码来源:PriceFieldValue.php
示例4: CRM_Contribute_DAO_ContributionPage
/**
* takes an associative array and creates a contribution page object
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Contribute_DAO_ContributionPage object
* @access public
* @static
*/
public static function &create(&$params)
{
$financialTypeId = NULL;
if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
}
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->copyValues($params);
$dao->save();
if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']);
}
return $dao;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:23,代码来源:ContributionPage.php
示例5: empty
/**
* Takes an associative array and creates a contribution page object.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @return CRM_Contribute_DAO_ContributionPage
*/
public static function &create(&$params)
{
$financialTypeId = NULL;
if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
}
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params);
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->copyValues($params);
$dao->save();
if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']);
}
CRM_Utils_Hook::post($hook, 'ContributionPage', $dao->id, $dao);
return $dao;
}
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:25,代码来源:ContributionPage.php
示例6: format
/**
* This method will create the lineItem array required for
* processAmount method
*
* @param int $fid
* Price set field id.
* @param array $params
* Reference to form values.
* @param array $fields
* Reference to array of fields belonging.
* to the price set used for particular event
* @param array $values
* Reference to the values array(.
* this is
* lineItem array)
*
* @return void
*/
public static function format($fid, &$params, &$fields, &$values)
{
if (empty($params["price_{$fid}"])) {
return;
}
$optionIDs = implode(',', array_keys($params["price_{$fid}"]));
//lets first check in fun parameter,
//since user might modified w/ hooks.
$options = array();
if (array_key_exists('options', $fields)) {
$options = $fields['options'];
} else {
CRM_Price_BAO_PriceFieldValue::getValues($fid, $options, 'weight', TRUE);
}
$fieldTitle = CRM_Utils_Array::value('label', $fields);
if (!$fieldTitle) {
$fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $fid, 'label');
}
foreach ($params["price_{$fid}"] as $oid => $qty) {
$price = $options[$oid]['amount'];
// lets clean the price in case it is not yet cleant
// CRM-10974
$price = CRM_Utils_Rule::cleanMoney($price);
$participantsPerField = CRM_Utils_Array::value('count', $options[$oid], 0);
$values[$oid] = array('price_field_id' => $fid, 'price_field_value_id' => $oid, 'label' => CRM_Utils_Array::value('label', $options[$oid]), 'field_title' => $fieldTitle, 'description' => CRM_Utils_Array::value('description', $options[$oid]), 'qty' => $qty, 'unit_price' => $price, 'line_total' => $qty * $price, 'participant_count' => $qty * $participantsPerField, 'max_value' => CRM_Utils_Array::value('max_value', $options[$oid]), 'membership_type_id' => CRM_Utils_Array::value('membership_type_id', $options[$oid]), 'membership_num_terms' => CRM_Utils_Array::value('membership_num_terms', $options[$oid]), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]), 'html_type' => $fields['html_type'], 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $options[$oid]), 'tax_amount' => CRM_Utils_Array::value('tax_amount', $options[$oid]));
if ($values[$oid]['membership_type_id'] && empty($values[$oid]['auto_renew'])) {
$values[$oid]['auto_renew'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values[$oid]['membership_type_id'], 'auto_renew');
}
}
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:48,代码来源:LineItem.php
示例7: 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
示例8: edit
/**
* edit custom Option.
*
* editing would involved modifying existing fields + adding data to new fields.
*
* @param string $action the action to be invoked
*
* @return void
* @access public
*/
function edit($action)
{
$oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE, 0);
$params = array();
if ($oid) {
$params['oid'] = $oid;
$sid = CRM_Price_BAO_PriceSet::getSetId($params);
$usedBy = CRM_Price_BAO_PriceSet::getUsedBy($sid);
}
// set the userContext stack
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field/option', "reset=1&action=browse&fid={$this->_fid}&sid={$this->_sid}"));
$controller = new CRM_Core_Controller_Simple('CRM_Price_Form_Option', ts('Price Field Option'), $action);
$controller->set('fid', $this->_fid);
$controller->setEmbedded(TRUE);
$controller->process();
$controller->run();
$this->browse();
if ($action & CRM_Core_Action::DELETE) {
// add breadcrumb
$url = CRM_Utils_System::url('civicrm/admin/price/field/option', 'reset=1');
CRM_Utils_System::appendBreadCrumb(ts('Price Option'), $url);
$this->assign('usedPriceSetTitle', CRM_Price_BAO_PriceFieldValue::getOptionLabel($oid));
$this->assign('usedBy', $usedBy);
$comps = array("Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page");
$priceSetContexts = array();
foreach ($comps as $name => $table) {
if (array_key_exists($table, $usedBy)) {
$priceSetContexts[] = $name;
}
}
$this->assign('contexts', $priceSetContexts);
}
}
开发者ID:hguru,项目名称:224Civi,代码行数:44,代码来源:Option.php
示例9: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
if ($this->_action == CRM_Core_Action::DELETE) {
$fieldValues = array('price_field_id' => $this->_fid);
$wt = CRM_Utils_Weight::delWeight('CRM_Price_DAO_PriceFieldValue', $this->_oid, $fieldValues);
$label = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_oid, 'label', 'id');
if (CRM_Price_BAO_PriceFieldValue::del($this->_oid)) {
CRM_Core_Session::setStatus(ts('%1 option has been deleted.', array(1 => $label)), ts('Record Deleted'), 'success');
}
return NULL;
} else {
$params = $ids = array();
$params = $this->controller->exportValues('Option');
$fieldLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'label');
$params['amount'] = CRM_Utils_Rule::cleanMoney(trim($params['amount']));
$params['price_field_id'] = $this->_fid;
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$ids = array();
if ($this->_oid) {
$ids['id'] = $this->_oid;
}
$optionValue = CRM_Price_BAO_PriceFieldValue::create($params, $ids);
CRM_Core_Session::setStatus(ts("The option '%1' has been saved.", array(1 => $params['label'])), ts('Value Saved'), 'success');
}
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:Option.php
示例10: submit
/**
* Submit function.
*
* This is the guts of the postProcess made also accessible to the test suite.
*
* @param array $params
* Submitted values.
*/
public function submit($params)
{
//carry campaign from profile.
if (array_key_exists('contribution_campaign_id', $params)) {
$params['campaign_id'] = $params['contribution_campaign_id'];
}
$params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
$is_quick_config = 0;
if (!empty($params['priceSetId'])) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$priceField = new CRM_Price_DAO_PriceField();
$priceField->price_set_id = $params['priceSetId'];
$priceField->orderBy('weight');
$priceField->find();
$priceOptions = array();
while ($priceField->fetch()) {
CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions);
if (($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) != FALSE && $selectedPriceOptionID > 0) {
switch ($priceField->name) {
case 'membership_amount':
$this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
$this->set('selectMembership', $params['selectMembership']);
case 'contribution_amount':
$params['amount'] = $selectedPriceOptionID;
if ($priceField->name == 'contribution_amount' || $priceField->name == 'membership_amount' && CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
$this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
}
$this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['weight'] = CRM_Utils_Array::value('weight', $priceOptions[$selectedPriceOptionID]);
break;
case 'other_amount':
$params['amount_other'] = $selectedPriceOptionID;
break;
}
}
}
}
}
if (!empty($this->_ccid) && !empty($this->_pendingAmount)) {
$params['amount'] = $this->_pendingAmount;
} else {
// from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
$params['amount'] = self::computeAmount($params, $this->_values);
}
$params['separate_amount'] = $params['amount'];
$memFee = NULL;
if (!empty($params['selectMembership'])) {
if (empty($this->_membershipTypeValues)) {
$this->_membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, (array) $params['selectMembership']);
}
$membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
$memFee = $membershipTypeValues['minimum_fee'];
if (!$params['amount'] && !$this->_separateMembershipPayment) {
$params['amount'] = $memFee ? $memFee : 0;
}
}
//If the membership & contribution is used in contribution page & not separate payment
$fieldId = $memPresent = $membershipLabel = $fieldOption = $is_quick_config = NULL;
$proceFieldAmount = 0;
if (property_exists($this, '_separateMembershipPayment') && $this->_separateMembershipPayment == 0) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
foreach ($this->_priceSet['fields'] as $fieldKey => $fieldVal) {
if ($fieldVal['name'] == 'membership_amount' && !empty($params['price_' . $fieldKey])) {
$fieldId = $fieldVal['id'];
$fieldOption = $params['price_' . $fieldId];
$proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
$memPresent = TRUE;
} else {
if (!empty($params['price_' . $fieldKey]) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
$fieldId = $fieldVal['id'];
if ($fieldVal['name'] == 'other_amount') {
$proceFieldAmount += $this->_submitValues['price_' . $fieldId];
} elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) {
$proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
}
unset($params['price_' . $fieldId]);
break;
}
}
}
}
}
if (!isset($params['amount_other'])) {
$this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
}
if (!empty($this->_ccid)) {
$this->set('lineItem', $this->_lineItem);
} elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Main.php
示例11: postProcess
//.........这里部分代码省略.........
$setParams['name'] = $pageTitle . '_' . $this->_id;
} else {
$timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
$setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$priceSetID = $priceSet->id;
$fieldParams['price_set_id'] = $priceSet->id;
} elseif ($usedPriceSetId) {
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
$setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
$setParams['id'] = $usedPriceSetId;
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$priceSetID = $priceSet->id;
$fieldParams['price_set_id'] = $priceSet->id;
} else {
$fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params);
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
}
$editedFieldParams = array('price_set_id' => $priceSetID, 'name' => 'membership_amount');
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (empty($editedResults['id'])) {
$fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245));
if (empty($params['mem_price_field_id'])) {
CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID));
}
$fieldParams['weight'] = 1;
} else {
$fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults);
}
$fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership');
$fieldParams['is_active'] = 1;
$fieldParams['html_type'] = 'Radio';
$fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0;
$fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0;
$rowCount = 1;
$options = array();
if (!empty($fieldParams['id'])) {
CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
}
foreach ($membershipTypes as $memType => $memAutoRenew) {
if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
$fieldParams['option_id'][$rowCount] = $priceFieldID;
unset($options[$priceFieldID]);
}
$membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
$fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype);
$fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
$fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype);
$fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype);
$fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params);
$fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype);
$fieldParams['membership_type_id'][$rowCount] = $memType;
// [$rowCount] = $membetype[''];
$rowCount++;
}
foreach ($options as $priceFieldID => $memType) {
CRM_Price_BAO_PriceFieldValue::setIsActive($priceFieldID, '0');
}
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
} elseif (!$priceSetID) {
$deletePriceSet = 1;
}
$params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE);
if ($priceSetID) {
$params['membership_types'] = 'null';
$params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
$params['membership_types'] = serialize($membershipTypes);
$params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE);
$params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE);
}
$params['entity_table'] = 'civicrm_contribution_page';
$params['entity_id'] = $this->_id;
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->copyValues($params);
$dao->save();
if ($priceSetID && $params['is_active']) {
CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetID);
}
if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) {
if ($this->_memPriceSetId) {
$pFIDs = array();
$conditionParams = array('price_set_id' => $this->_memPriceSetId, 'html_type' => 'radio', 'name' => 'contribution_amount');
CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs);
if (empty($pFIDs['id'])) {
CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id);
CRM_Price_BAO_PriceSet::setIsQuickConfig($this->_memPriceSetId, '0');
} else {
CRM_Price_BAO_PriceField::setIsActive($params['mem_price_field_id'], '0');
}
}
}
}
parent::endPostProcess();
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:MembershipBlock.php
示例12: upgrade_3_3_beta1
/**
* @param $rev
*/
public function upgrade_3_3_beta1($rev)
{
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
// CRM-6902
// Add column price_field_value_id in civicrm_line_item.
// Do not drop option_group_id column now since we need it to
// update line items.
$updateLineItem1 = "ALTER TABLE civicrm_line_item ADD COLUMN price_field_value_id int(10) unsigned default NULL;";
CRM_Core_DAO::executeQuery($updateLineItem1);
$priceFieldDAO = new CRM_Price_DAO_PriceField();
$priceFieldDAO->find();
$ids = array();
while ($priceFieldDAO->fetch()) {
$opGroupDAO = new CRM_Core_DAO_OptionGroup();
$opGroupDAO->name = 'civicrm_price_field.amount.' . $priceFieldDAO->id;
if (!$opGroupDAO->find(TRUE)) {
$opGroupDAO->free();
continue;
}
$opValueDAO = new CRM_Core_DAO_OptionValue();
$opValueDAO->option_group_id = $opGroupDAO->id;
$opValueDAO->find();
while ($opValueDAO->fetch()) {
// FIX ME: not migrating description(?), there will
// be a field description for each option.
$fieldValue = array('price_field_id' => $priceFieldDAO->id, 'label' => $opValueDAO->label, 'name' => CRM_Utils_String::munge($opValueDAO->label, '_', 64), 'amount' => $opValueDAO->name, 'weight' => $opValueDAO->weight, 'is_default' => $opValueDAO->is_default, 'is_active' => $opValueDAO->is_active);
if ($priceFieldDAO->count) {
// Migrate Participant Counts on option level.
// count of each option will be the same
// as earlier field count.
$fieldValue['count'] = $priceFieldDAO->count;
}
$fieldValueDAO = CRM_Price_BAO_PriceFieldValue::add($fieldValue, $ids);
$lineItemDAO = new CRM_Price_DAO_LineItem();
$lineItemDAO->option_group_id = $opGroupDAO->id;
$lineItemDAO->label = $opValueDAO->label;
$lineItemDAO->unit_price = $opValueDAO->name;
$labelFound = $priceFound = FALSE;
// check with label and amount
if (!$lineItemDAO->find(TRUE)) {
$lineItemDAO->free();
$lineItemDAO = new CRM_Price_DAO_LineItem();
$lineItemDAO->option_group_id = $opGroupDAO->id;
$lineItemDAO->label = $opValueDAO->label;
// check with label only
if ($lineItemDAO->find(TRUE)) {
$labelFound = TRUE;
}
} else {
$labelFound = TRUE;
$priceFound = TRUE;
}
$lineItemDAO->free();
// update civicrm_line_item for price_field_value_id.
// Used query to avoid line by line update.
if ($labelFound || $priceFound) {
$lineItemParams = array(1 => array($fieldValueDAO->id, 'Integer'), 2 => array($opValueDAO->label, 'String'));
$updateLineItems = "UPDATE civicrm_line_item SET price_field_value_id = %1 WHERE label = %2";
if ($priceFound) {
$lineItemParams[3] = array($opValueDAO->name, 'Float');
$updateLineItems .= " AND unit_price = %3";
}
CRM_Core_DAO::executeQuery($updateLineItems, $lineItemParams);
}
}
$opGroupDAO->delete();
$opValueDAO->free();
$opGroupDAO->free();
}
$priceFieldDAO->free();
// Now drop option_group_id column from civicrm_line_item
$updateLineItem2 = "ALTER TABLE civicrm_line_item DROP option_group_id,\n ADD CONSTRAINT `FK_civicrm_price_field_value_id` FOREIGN KEY (price_field_value_id) REFERENCES civicrm_price_field_value(id) ON DELETE SET NULL;";
CRM_Core_DAO::executeQuery($updateLineItem2, array(), TRUE, NULL, FALSE, FALSE);
$updatePriceField = "ALTER TABLE civicrm_price_field DROP count";
CRM_Core_DAO::executeQuery($updatePriceField, array(), TRUE, NULL, FALSE, FALSE);
// as the table 'civicrm_price_field' is localised and column 'count' is dropped
// after the views are rebuild, we need to rebuild views to avoid invalid refrence of table.
if ($upgrade->multilingual) {
CRM_Core_I18n_Schema::rebuildMultilingualSchema($upgrade->locales, $rev);
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:85,代码来源:ThreeThree.php
示例13: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
$config = CRM_Core_Config::singleton();
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//carry campaign from profile.
if (array_key_exists('contribution_campaign_id', $params)) {
$params['campaign_id'] = $params['contribution_campaign_id'];
}
if (!empty($params['onbehalfof_id'])) {
$params['organization_id'] = $params['onbehalfof_id'];
}
$params['currencyID'] = $config->defaultCurrency;
if (!empty($params['priceSetId'])) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$priceField = new CRM_Price_DAO_PriceField();
$priceField->price_set_id = $params['priceSetId'];
$priceField->orderBy('weight');
$priceField->find();
$priceOptions = array();
while ($priceField->fetch()) {
CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions);
if ($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) {
switch ($priceField->name) {
case 'membership_amount':
$this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
$this->set('selectMembership', $params['selectMembership']);
if (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
$this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
}
break;
case 'contribution_amount':
$params['amount'] = $selectedPriceOptionID;
$this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['weight'] = CRM_Utils_Array::value('weight', $priceOptions[$selectedPriceOptionID]);
break;
case 'other_amount':
$params['amount_other'] = $selectedPriceOptionID;
break;
}
}
}
}
}
if ($this->_values['is_pay_later'] && empty($this->_paymentProcessor) && !array_key_exists('hidden_processor', $params) || !empty($params['payment_processor_id']) && $params['payment_processor_id'] == 0) {
$params['is_pay_later'] = 1;
} else {
$params['is_pay_later'] = 0;
}
$this->set('is_pay_later', $params['is_pay_later']);
// assign pay later stuff
$this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
}
// from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
$params['amount'] = self::computeAmount($params, $this->_values);
$params['separate_amount'] = $params['amount'];
$memFee = NULL;
if (!empty($params['selectMembership'])) {
if (!empty($this->_membershipTypeValues)) {
$membershipTypeValues = $this->_membershipTypeValues[$params['selectMembership']];
} else {
$membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $params['selectMembership']);
}
$memFee = $membershipTypeValues['minimum_fee'];
if (!$params['amount'] && !$this->_separateMembershipPayment) {
$params['amount'] = $memFee ? $memFee : 0;
}
}
//If the membership & contribution is used in contribution page & not separate payment
$fieldId = $memPresent = $membershipLabel = $fieldOption = $is_quick_config = NULL;
$proceFieldAmount = 0;
if (property_exists($this, '_separateMembershipPayment') && $this->_separateMembershipPayment == 0) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
foreach ($this->_priceSet['fields'] as $fieldKey => $fieldVal) {
if ($fieldVal['name'] == 'membership_amount' && !empty($params['price_' . $fieldKey])) {
$fieldId = $fieldVal['id'];
$fieldOption = $params['price_' . $fieldId];
$proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
$memPresent = TRUE;
} else {
if (!empty($params['price_' . $fieldKey]) && $memPresent && ($fieldVal['name'] == 'other_amount' || $fieldVal['name'] == 'contribution_amount')) {
$fieldId = $fieldVal['id'];
if ($fieldVal['name'] == 'other_amount') {
$proceFieldAmount += $this->_submitValues['price_' . $fieldId];
} elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) {
$proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount'];
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Main.php
示例14: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
$config = CRM_Core_Config::singleton();
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//carry campaign from profile.
if (array_key_exists('contribution_campaign_id', $params)) {
$params['campaign_id'] = $params['contribution_campaign_id'];
}
if (!empty($params['onbehalfof_id'])) {
$params['organization_id'] = $params['onbehalfof_id'];
}
$params['currencyID'] = $config->defaultCurrency;
if (!empty($params['priceSetId'])) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$priceField = new CRM_Price_DAO_PriceField();
$priceField->price_set_id = $params['priceSetId'];
$priceField->orderBy('weight');
$priceField->find();
$priceOptions = array();
while ($priceField->fetch()) {
CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions);
if ($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) {
switch ($priceField->name) {
case 'membership_amount':
$this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
$this->set('selectMembership', $params['selectMembership']);
if (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
$this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
}
break;
case 'contribution_amount':
$params['amount'] = $selectedPriceOptionID;
$this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
$this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID
|
请发表评论