本文整理汇总了PHP中CRM_Price_BAO_PriceSet::getDefaultPriceSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::getDefaultPriceSet方法的具体用法?PHP CRM_Price_BAO_PriceSet::getDefaultPriceSet怎么用?PHP CRM_Price_BAO_PriceSet::getDefaultPriceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceSet
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceSet::getDefaultPriceSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPriceSetDetails
/**
* Get the details for the selected price set.
*
* @param array $params
* Parameters submitted to the form.
*
* @return array
*/
protected static function getPriceSetDetails($params)
{
$priceSetID = CRM_Utils_Array::value('price_set_id', $params);
if ($priceSetID) {
return CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
} else {
$priceSet = CRM_Price_BAO_PriceSet::getDefaultPriceSet('membership');
$priceSet = reset($priceSet);
return CRM_Price_BAO_PriceSet::getSetDetail($priceSet['setID']);
}
}
示例2: getLineItemArray
/**
* Function to build line items array.
* @param int $params form values
*
* @param string $entityId entity id
*
* @param string $entityTable entity Table
*
* @access public
* @return void
* @static
*/
static function getLineItemArray(&$params, $entityId = NULL, $entityTable = 'contribution')
{
if (!$entityId) {
$priceSetDetails = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
foreach ($priceSetDetails as $values) {
$params['line_item'][$values['setID']][$values['priceFieldID']] = array('price_field_id' => $values['priceFieldID'], 'price_field_value_id' => $values['priceFieldValueID'], 'label' => $values['label'], 'qty' => 1, 'unit_price' => $params['total_amount'], 'line_total' => $params['total_amount'], 'financial_type_id' => $params['financial_type_id']);
}
} else {
$setID = NULL;
$totalEntityId = count($entityId);
foreach ($entityId as $id) {
$lineItems = CRM_Price_BAO_LineItem::getLineItems($id, $entityTable);
foreach ($lineItems as $key => $values) {
if (!$setID && $values['price_field_id']) {
$setID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $values['price_field_id'], 'price_set_id');
$params['is_quick_config'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'is_quick_config');
}
if (CRM_Utils_Array::value('is_quick_config', $params) && array_key_exists('total_amount', $params) && $totalEntityId == 1) {
$values['line_total'] = $values['unit_price'] = $params['total_amount'];
}
$values['id'] = $key;
$params['line_item'][$setID][$key] = $values;
}
}
}
}
示例3: getLineItemArray
/**
* Build line items array.
* @param array $params
* Form values.
*
* @param string $entityId
* Entity id.
*
* @param string $entityTable
* Entity Table.
*
* @return void
*/
public static function getLineItemArray(&$params, $entityId = NULL, $entityTable = 'contribution', $isRelatedID = FALSE)
{
if (!$entityId) {
$priceSetDetails = CRM_Price_BAO_PriceSet::getDefaultPriceSet($entityTable);
$totalAmount = CRM_Utils_Array::value('total_amount', $params);
$financialType = CRM_Utils_Array::value('financial_type_id', $params);
foreach ($priceSetDetails as $values) {
if ($entityTable == 'membership') {
if ($isRelatedID != $values['membership_type_id']) {
continue;
}
if (!$totalAmount) {
$totalAmount = $values['amount'];
}
$financialType = $values['financial_type_id'];
}
$params['line_item'][$values['setID']][$values['priceFieldID']] = array('price_field_id' => $values['priceFieldID'], 'price_field_value_id' => $values['priceFieldValueID'], 'label' => $values['label'], 'qty' => 1, 'unit_price' => $totalAmount, 'line_total' => $totalAmount, 'financial_type_id' => $financialType, 'membership_type_id' => $values['membership_type_id']);
break;
}
} else {
$setID = NULL;
$totalEntityId = count($entityId);
foreach ($entityId as $id) {
$lineItems = CRM_Price_BAO_LineItem::getLineItems($id, $entityTable, NULL, TRUE, $isRelatedID);
foreach ($lineItems as $key => $values) {
if (!$setID && $values['price_field_id']) {
$setID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $values['price_field_id'], 'price_set_id');
$params['is_quick_config'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'is_quick_config');
}
if (!empty($params['is_quick_config']) && array_key_exists('total_amount', $params) && $totalEntityId == 1) {
$values['line_total'] = $values['unit_price'] = $params['total_amount'];
}
$values['id'] = $key;
$params['line_item'][$setID][$key] = $values;
}
}
}
}
示例4: task_4_2_alpha1_convertContributions
/**
* (Queue Task Callback)
*
* Find any contribution records and create corresponding line-item
* records.
*
* @param CRM_Queue_TaskContext $ctx
* @param int $startId
* the first/lowest contribution ID to convert.
* @param int $endId
* the last/highest contribution ID to convert.
*
* @return bool
*/
public static function task_4_2_alpha1_convertContributions(CRM_Queue_TaskContext $ctx, $startId, $endId)
{
$upgrade = new CRM_Upgrade_Form();
$query = "\n INSERT INTO civicrm_line_item(`entity_table` ,`entity_id` ,`price_field_id` ,`label` , `qty` ,`unit_price` ,`line_total` ,`participant_count` ,`price_field_value_id`)\n SELECT 'civicrm_contribution',cc.id, cpf.id as price_field_id, cpfv.label, 1, cc.total_amount, cc.total_amount line_total, 0, cpfv.id as price_field_value\n FROM civicrm_membership_payment cmp\n LEFT JOIN `civicrm_contribution` cc ON cc.id = cmp.contribution_id\n LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'\n LEFT JOIN civicrm_membership cm ON cm.id=cmp.membership_id\n LEFT JOIN civicrm_membership_type cmt ON cmt.id = cm.membership_type_id\n LEFT JOIN civicrm_price_field cpf ON BINARY cpf.name = cmt.member_of_contact_id\n LEFT JOIN civicrm_price_field_value cpfv ON cpfv.membership_type_id = cm.membership_type_id AND cpf.id = cpfv.price_field_id\n WHERE (cc.id BETWEEN %1 AND %2) AND cli.entity_id IS NULL ;\n ";
$sqlParams = array(1 => array($startId, 'Integer'), 2 => array($endId, 'Integer'));
CRM_Core_DAO::executeQuery($query, $sqlParams);
// create lineitems for contribution done for membership
$sql = "\nSELECT cc.id, cmp.membership_id, cpse.price_set_id, cc.total_amount\nFROM civicrm_contribution cc\nLEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id AND cli.entity_table = 'civicrm_contribution'\nLEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id\nLEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id\nLEFT JOIN civicrm_price_set_entity cpse on cpse.entity_table = 'civicrm_contribution_page' AND cpse.entity_id = cc.contribution_page_id\nWHERE (cc.id BETWEEN %1 AND %2)\nAND cli.entity_id IS NULL AND cc.contribution_page_id IS NOT NULL AND cpp.contribution_id IS NULL\nGROUP BY cc.id\n";
$result = CRM_Core_DAO::executeQuery($sql, $sqlParams);
while ($result->fetch()) {
$sql = "\nSELECT cpf.id, cpfv.id as price_field_value_id, cpfv.label, cpfv.amount, cpfv.count\nFROM civicrm_price_field cpf\nLEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id\nWHERE cpf.price_set_id = %1\n";
$lineParams = array('entity_table' => 'civicrm_contribution', 'entity_id' => $result->id);
if ($result->membership_id) {
$sql .= " AND cpf.name = %2 AND cpfv.membership_type_id = %3 ";
$params = array('1' => array($result->price_set_id, 'Integer'), '2' => array('membership_amount', 'String'), '3' => array(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $result->membership_id, 'membership_type_id'), 'Integer'));
$res = CRM_Core_DAO::executeQuery($sql, $params);
if ($res->fetch()) {
$lineParams += array('price_field_id' => $res->id, 'label' => $res->label, 'qty' => 1, 'unit_price' => $res->amount, 'line_total' => $res->amount, 'participant_count' => $res->count ? $res->count : 0, 'price_field_value_id' => $res->price_field_value_id);
} else {
$lineParams['price_field_id'] = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
$lineParams['label'] = 'Membership Amount';
$lineParams['qty'] = 1;
$lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
$lineParams['participant_count'] = 0;
}
} else {
$sql .= "AND cpfv.amount = %2";
//CRM-12273
//check if price_set_id is exist, if not use the default contribution amount
if (isset($result->price_set_id)) {
$priceSetId = $result->price_set_id;
} else {
$defaultPriceSets = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
foreach ($defaultPriceSets as $key => $pSet) {
if ($pSet['name'] == 'contribution_amount') {
$priceSetId = $pSet['setID'];
}
}
}
$params = array('1' => array($priceSetId, 'Integer'), '2' => array($result->total_amount, 'String'));
$res = CRM_Core_DAO::executeQuery($sql, $params);
if ($res->fetch()) {
$lineParams += array('price_field_id' => $res->id, 'label' => $res->label, 'qty' => 1, 'unit_price' => $res->amount, 'line_total' => $res->amount, 'participant_count' => $res->count ? $res->count : 0, 'price_field_value_id' => $res->price_field_value_id);
} else {
$params = array('price_set_id' => $priceSetId, 'name' => 'other_amount');
$defaults = array();
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::retrieve($params, $defaults);
if (!empty($defaults)) {
$lineParams['price_field_id'] = $defaults['id'];
$lineParams['label'] = $defaults['label'];
$lineParams['price_field_value_id'] = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $defaults['id'], 'id', 'price_field_id');
} else {
$lineParams['price_field_id'] = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $priceSetId, 'id', 'price_set_id');
$lineParams['label'] = 'Contribution Amount';
}
$lineParams['qty'] = 1;
$lineParams['participant_count'] = 0;
$lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
}
}
CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
}
return TRUE;
}