First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,634 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Business objects for managing price fields.
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field {
|
||||
|
||||
protected $_options;
|
||||
|
||||
/**
|
||||
* Takes an associative array and creates a price field object.
|
||||
*
|
||||
* the function extract all the params it needs to initialize the create a
|
||||
* price field object. the params array could contain additional unused name/value
|
||||
* pairs
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field
|
||||
*/
|
||||
public static function &add(&$params) {
|
||||
$priceFieldBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field();
|
||||
|
||||
$priceFieldBAO->copyValues($params);
|
||||
|
||||
if ($id = CRM_Utils_Array::value('id', $params)) {
|
||||
$priceFieldBAO->id = $id;
|
||||
}
|
||||
|
||||
$priceFieldBAO->save();
|
||||
return $priceFieldBAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an associative array and creates a price field object.
|
||||
*
|
||||
* This function is invoked from within the web form layer and also from the api layer
|
||||
*
|
||||
* @param array $params
|
||||
* (reference) an assoc array of name/value pairs.
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$priceField = self::add($params);
|
||||
|
||||
if (is_a($priceField, 'CRM_Core_Error')) {
|
||||
$transaction->rollback();
|
||||
return $priceField;
|
||||
}
|
||||
|
||||
$options = $optionsIds = array();
|
||||
$maxIndex = CRM_Price_Form_Field::NUM_OPTION;
|
||||
|
||||
if ($priceField->html_type == 'Text') {
|
||||
$maxIndex = 1;
|
||||
|
||||
$fieldValue = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
|
||||
$fieldValue->price_field_id = $priceField->id;
|
||||
|
||||
// update previous field values( if any )
|
||||
if ($fieldValue->find(TRUE)) {
|
||||
$optionsIds['id'] = $fieldValue->id;
|
||||
}
|
||||
}
|
||||
$defaultArray = array();
|
||||
if ($params['html_type'] == 'CheckBox' && isset($params['default_checkbox_option'])) {
|
||||
$tempArray = array_keys($params['default_checkbox_option']);
|
||||
foreach ($tempArray as $v) {
|
||||
if ($params['option_amount'][$v]) {
|
||||
$defaultArray[$v] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!empty($params['default_option'])) {
|
||||
$defaultArray[$params['default_option']] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for ($index = 1; $index <= $maxIndex; $index++) {
|
||||
|
||||
if (array_key_exists('option_amount', $params) &&
|
||||
array_key_exists($index, $params['option_amount']) &&
|
||||
(CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_label', $params)) || !empty($params['is_quick_config'])) &&
|
||||
!CRM_Utils_System::isNull($params['option_amount'][$index])
|
||||
) {
|
||||
$options = array(
|
||||
'price_field_id' => $priceField->id,
|
||||
'label' => trim($params['option_label'][$index]),
|
||||
'name' => CRM_Utils_String::munge($params['option_label'][$index], '_', 64),
|
||||
'amount' => CRM_Utils_Rule::cleanMoney(trim($params['option_amount'][$index])),
|
||||
'count' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_count', $params), NULL),
|
||||
'max_value' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_max_value', $params), NULL),
|
||||
'description' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_description', $params), NULL),
|
||||
'membership_type_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_type_id', $params), NULL),
|
||||
'weight' => $params['option_weight'][$index],
|
||||
'is_active' => 1,
|
||||
'is_default' => CRM_Utils_Array::value($params['option_weight'][$index], $defaultArray) ? $defaultArray[$params['option_weight'][$index]] : 0,
|
||||
);
|
||||
|
||||
if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
|
||||
if ($opId = CRM_Utils_Array::value($index, $opIds)) {
|
||||
$optionsIds['id'] = $opId;
|
||||
}
|
||||
else {
|
||||
$optionsIds['id'] = NULL;
|
||||
}
|
||||
}
|
||||
CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::create($options, $optionsIds);
|
||||
}
|
||||
}
|
||||
|
||||
$transaction->commit();
|
||||
return $priceField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch object based on array of properties.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
* @param array $defaults
|
||||
* (reference ) an assoc array to hold the flattened values.
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $params, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the is_active flag in the db.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of the database record.
|
||||
* @param bool $is_active
|
||||
* Value we want to set the is_active field.
|
||||
*
|
||||
* @return Object
|
||||
* DAO object on success, null otherwise
|
||||
*/
|
||||
public static function setIsActive($id, $is_active) {
|
||||
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'is_active', $is_active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field title.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of field.
|
||||
*
|
||||
* @return string
|
||||
* name
|
||||
*/
|
||||
public static function getTitle($id) {
|
||||
return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'label');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function for building custom fields.
|
||||
*
|
||||
* @param CRM_Core_Form $qf
|
||||
* Form object (reference).
|
||||
* @param string $elementName
|
||||
* Name of the custom field.
|
||||
* @param int $fieldId
|
||||
* @param bool $inactiveNeeded
|
||||
* @param bool $useRequired
|
||||
* True if required else false.
|
||||
* @param string $label
|
||||
* Label for custom field.
|
||||
* @param null $fieldOptions
|
||||
* @param array $freezeOptions
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function addQuickFormElement(
|
||||
&$qf,
|
||||
$elementName,
|
||||
$fieldId,
|
||||
$inactiveNeeded,
|
||||
$useRequired = TRUE,
|
||||
$label = NULL,
|
||||
$fieldOptions = NULL,
|
||||
$freezeOptions = array()
|
||||
) {
|
||||
|
||||
$field = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
|
||||
$field->id = $fieldId;
|
||||
if (!$field->find(TRUE)) {
|
||||
/* FIXME: failure! */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$otherAmount = $qf->get('values');
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$qf->assign('currencySymbol', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Currency', $config->defaultCurrency, 'symbol', 'name'));
|
||||
// get currency name for price field and option attributes
|
||||
$currencyName = $config->defaultCurrency;
|
||||
|
||||
if (!isset($label)) {
|
||||
$label = (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount' && empty($otherAmount['is_allow_other_amount'])) ? ts('Additional Contribution') : $field->label;
|
||||
}
|
||||
|
||||
if ($field->name == 'contribution_amount') {
|
||||
$qf->_contributionAmount = 1;
|
||||
}
|
||||
|
||||
if (isset($qf->_online) && $qf->_online) {
|
||||
$useRequired = FALSE;
|
||||
}
|
||||
|
||||
$customOption = $fieldOptions;
|
||||
if (!is_array($customOption)) {
|
||||
$customOption = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
|
||||
}
|
||||
|
||||
//use value field.
|
||||
$valueFieldName = 'amount';
|
||||
$seperator = '|';
|
||||
switch ($field->html_type) {
|
||||
case 'Text':
|
||||
$optionKey = key($customOption);
|
||||
$count = CRM_Utils_Array::value('count', $customOption[$optionKey], '');
|
||||
$max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], '');
|
||||
$priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName], $count, $max_value));
|
||||
|
||||
$extra = array();
|
||||
if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
|
||||
$qf->assign('priceset', $elementName);
|
||||
$extra = array('onclick' => 'useAmountOther();');
|
||||
}
|
||||
|
||||
// if separate membership payment is used with quick config priceset then change the other amount label
|
||||
if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $qf->_quickConfig && $field->name == 'other_amount' && !property_exists($qf, '_contributionAmount')) {
|
||||
$label = ts('Additional Contribution');
|
||||
$useRequired = 0;
|
||||
}
|
||||
elseif (!empty($fieldOptions[$optionKey]['label'])) {
|
||||
$label = $fieldOptions[$optionKey]['label'];
|
||||
}
|
||||
|
||||
if ($field->is_display_amounts) {
|
||||
$label .= ' - ';
|
||||
$label .= CRM_Utils_Money::format(CRM_Utils_Array::value($valueFieldName, $customOption[$optionKey]));
|
||||
}
|
||||
|
||||
$element = &$qf->add('text', $elementName, $label,
|
||||
array_merge($extra,
|
||||
array(
|
||||
'price' => json_encode(array($optionKey, $priceVal)),
|
||||
'size' => '4',
|
||||
)
|
||||
),
|
||||
$useRequired && $field->is_required
|
||||
);
|
||||
|
||||
// CRM-6902
|
||||
if (in_array($optionKey, $freezeOptions)) {
|
||||
$element->freeze();
|
||||
}
|
||||
|
||||
//CRM-10117
|
||||
if (property_exists($qf, '_quickConfig') && $qf->_quickConfig) {
|
||||
$message = ts("Please enter a valid amount.");
|
||||
$type = "money";
|
||||
}
|
||||
else {
|
||||
$message = ts('%1 must be an integer (whole number).', array(1 => $label));
|
||||
$type = "positiveInteger";
|
||||
}
|
||||
// integers will have numeric rule applied to them.
|
||||
$qf->addRule($elementName, $message, $type);
|
||||
break;
|
||||
|
||||
case 'Radio':
|
||||
$choice = array();
|
||||
|
||||
if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
|
||||
$qf->assign('contriPriceset', $elementName);
|
||||
}
|
||||
|
||||
foreach ($customOption as $opId => $opt) {
|
||||
if ($field->is_display_amounts) {
|
||||
$opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : '';
|
||||
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
|
||||
}
|
||||
$count = CRM_Utils_Array::value('count', $opt, '');
|
||||
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
|
||||
$priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
|
||||
$extra = array(
|
||||
'price' => json_encode(array($elementName, $priceVal)),
|
||||
'data-amount' => $opt[$valueFieldName],
|
||||
'data-currency' => $currencyName,
|
||||
);
|
||||
if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'contribution_amount') {
|
||||
$extra += array('onclick' => 'clearAmountOther();');
|
||||
}
|
||||
elseif (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'membership_amount') {
|
||||
$extra += array(
|
||||
'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
|
||||
'membership-type' => $opt['membership_type_id'],
|
||||
);
|
||||
$qf->assign('membershipFieldID', $field->id);
|
||||
}
|
||||
$choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
|
||||
|
||||
// CRM-6902
|
||||
if (in_array($opId, $freezeOptions)) {
|
||||
$choice[$opId]->freeze();
|
||||
}
|
||||
}
|
||||
|
||||
if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount') {
|
||||
$choice[] = $qf->createElement('radio', NULL, '', 'No thank you', '-1',
|
||||
array(
|
||||
'onclick' => 'clearAmountOther();',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$field->is_required) {
|
||||
// add "none" option
|
||||
if (!empty($otherAmount['is_allow_other_amount']) && $field->name == 'contribution_amount') {
|
||||
$none = ts('Other Amount');
|
||||
}
|
||||
elseif (property_exists($qf, '_membershipBlock') && empty($qf->_membershipBlock['is_required']) && $field->name == 'membership_amount') {
|
||||
$none = ts('No thank you');
|
||||
}
|
||||
else {
|
||||
$none = ts('-none-');
|
||||
}
|
||||
|
||||
$choice[] = $qf->createElement('radio', NULL, '', $none, '0',
|
||||
array('price' => json_encode(array($elementName, "0")))
|
||||
);
|
||||
}
|
||||
|
||||
$element = &$qf->addGroup($choice, $elementName, $label);
|
||||
|
||||
// make contribution field required for quick config when membership block is enabled
|
||||
if (($field->name == 'contribution_amount' || $field->name == 'membership_amount') && property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock) && !$field->is_required) {
|
||||
$useRequired = $field->is_required = TRUE;
|
||||
}
|
||||
|
||||
if ($useRequired && $field->is_required) {
|
||||
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Select':
|
||||
$selectOption = $allowedOptions = $priceVal = array();
|
||||
|
||||
foreach ($customOption as $opt) {
|
||||
$count = CRM_Utils_Array::value('count', $opt, '');
|
||||
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
|
||||
$priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
|
||||
|
||||
if ($field->is_display_amounts) {
|
||||
$opt['label'] .= ' - ';
|
||||
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
|
||||
}
|
||||
$selectOption[$opt['id']] = $opt['label'];
|
||||
|
||||
if (!in_array($opt['id'], $freezeOptions)) {
|
||||
$allowedOptions[] = $opt['id'];
|
||||
}
|
||||
}
|
||||
$element = &$qf->add('select', $elementName, $label,
|
||||
array('' => ts('- select -')) + $selectOption,
|
||||
$useRequired && $field->is_required,
|
||||
array('price' => json_encode($priceVal))
|
||||
);
|
||||
|
||||
// CRM-6902
|
||||
$button = substr($qf->controller->getButtonName(), -4);
|
||||
if (!empty($freezeOptions) && $button != 'skip') {
|
||||
$qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'CheckBox':
|
||||
|
||||
$check = array();
|
||||
foreach ($customOption as $opId => $opt) {
|
||||
$count = CRM_Utils_Array::value('count', $opt, '');
|
||||
$max_value = CRM_Utils_Array::value('max_value', $opt, '');
|
||||
$priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
|
||||
|
||||
if ($field->is_display_amounts) {
|
||||
$opt['label'] .= ' - ';
|
||||
$opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
|
||||
}
|
||||
$check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'],
|
||||
array(
|
||||
'price' => json_encode(array($opt['id'], $priceVal)),
|
||||
'data-amount' => $opt[$valueFieldName],
|
||||
'data-currency' => $currencyName,
|
||||
)
|
||||
);
|
||||
|
||||
// CRM-6902
|
||||
if (in_array($opId, $freezeOptions)) {
|
||||
$check[$opId]->freeze();
|
||||
}
|
||||
}
|
||||
$element = &$qf->addGroup($check, $elementName, $label);
|
||||
if ($useRequired && $field->is_required) {
|
||||
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (isset($qf->_online) && $qf->_online) {
|
||||
$element->freeze();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a list of options for the specified field.
|
||||
*
|
||||
* @param int $fieldId
|
||||
* Price field ID.
|
||||
* @param bool $inactiveNeeded
|
||||
* Include inactive options.
|
||||
* @param bool $reset
|
||||
* Ignore stored values\.
|
||||
*
|
||||
* @return array
|
||||
* array of options
|
||||
*/
|
||||
public static function getOptions($fieldId, $inactiveNeeded = FALSE, $reset = FALSE) {
|
||||
static $options = array();
|
||||
|
||||
if ($reset || empty($options[$fieldId])) {
|
||||
$values = array();
|
||||
CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fieldId, $values, 'weight', !$inactiveNeeded);
|
||||
$options[$fieldId] = $values;
|
||||
}
|
||||
|
||||
return $options[$fieldId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $optionLabel
|
||||
* @param int $fid
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getOptionId($optionLabel, $fid) {
|
||||
if (!$optionLabel || !$fid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$optionGroupName = "civicrm_price_field.amount.{$fid}";
|
||||
|
||||
$query = "
|
||||
SELECT
|
||||
option_value.id as id
|
||||
FROM
|
||||
civicrm_option_value option_value,
|
||||
civicrm_option_group option_group
|
||||
WHERE
|
||||
option_group.name = %1
|
||||
AND option_group.id = option_value.option_group_id
|
||||
AND option_value.label = %2";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, array(
|
||||
1 => array($optionGroupName, 'String'),
|
||||
2 => array($optionLabel, 'String'),
|
||||
));
|
||||
|
||||
while ($dao->fetch()) {
|
||||
return $dao->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the price set field.
|
||||
*
|
||||
* @param int $id
|
||||
* Field Id.
|
||||
*
|
||||
* @return mixed
|
||||
* Boolean-ish
|
||||
*/
|
||||
public static function deleteField($id) {
|
||||
$field = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
|
||||
$field->id = $id;
|
||||
|
||||
if ($field->find(TRUE)) {
|
||||
// delete the options for this field
|
||||
CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::deleteValues($id);
|
||||
|
||||
// reorder the weight before delete
|
||||
$fieldValues = array('price_set_id' => $field->price_set_id);
|
||||
|
||||
CRM_Utils_Weight::delWeight('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $field->id, $fieldValues);
|
||||
|
||||
// now delete the field
|
||||
return $field->delete();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function &htmlTypes() {
|
||||
static $htmlTypes = NULL;
|
||||
if (!$htmlTypes) {
|
||||
$htmlTypes = array(
|
||||
'Text' => ts('Text / Numeric Quantity'),
|
||||
'Select' => ts('Select'),
|
||||
'Radio' => ts('Radio'),
|
||||
'CheckBox' => ts('CheckBox'),
|
||||
);
|
||||
}
|
||||
return $htmlTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the priceset.
|
||||
*
|
||||
* @param int $priceSetId
|
||||
* @param array $fields
|
||||
* @param array $error
|
||||
*/
|
||||
public static function priceSetValidation($priceSetId, $fields, &$error) {
|
||||
// check for at least one positive
|
||||
// amount price field should be selected.
|
||||
$priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
|
||||
$priceField->price_set_id = $priceSetId;
|
||||
$priceField->find();
|
||||
|
||||
$priceFields = array();
|
||||
|
||||
while ($priceField->fetch()) {
|
||||
$key = "price_{$priceField->id}";
|
||||
if (!empty($fields[$key])) {
|
||||
$priceFields[$priceField->id] = $fields[$key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($priceFields)) {
|
||||
// we should has to have positive amount.
|
||||
$sql = "
|
||||
SELECT id, html_type
|
||||
FROM civicrm_price_field
|
||||
WHERE id IN (" . implode(',', array_keys($priceFields)) . ')';
|
||||
$fieldDAO = CRM_Core_DAO::executeQuery($sql);
|
||||
$htmlTypes = array();
|
||||
while ($fieldDAO->fetch()) {
|
||||
$htmlTypes[$fieldDAO->id] = $fieldDAO->html_type;
|
||||
}
|
||||
|
||||
$selectedAmounts = array();
|
||||
|
||||
foreach ($htmlTypes as $fieldId => $type) {
|
||||
$options = array();
|
||||
CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fieldId, $options);
|
||||
|
||||
if (empty($options)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if ($type == 'Text') {
|
||||
foreach ($options as $opId => $option) {
|
||||
$selectedAmounts[$opId] = $priceFields[$fieldId] * $option['amount'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif (is_array($fields["price_{$fieldId}"])) {
|
||||
foreach (array_keys($fields["price_{$fieldId}"]) as $opId) {
|
||||
$selectedAmounts[$opId] = $options[$opId]['amount'];
|
||||
}
|
||||
}
|
||||
elseif (in_array($fields["price_{$fieldId}"], array_keys($options))) {
|
||||
$selectedAmounts[$fields["price_{$fieldId}"]] = $options[$fields["price_{$fieldId}"]]['amount'];
|
||||
}
|
||||
}
|
||||
|
||||
list($componentName) = explode(':', $fields['_qf_default']);
|
||||
// now we have all selected amount in hand.
|
||||
$totalAmount = array_sum($selectedAmounts);
|
||||
if ($totalAmount < 0) {
|
||||
$error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', array(1 => $componentName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$error['_qf_default'] = ts("Please select at least one option from price set.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Business objects for managing price fields values.
|
||||
*
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue {
|
||||
|
||||
/**
|
||||
* Insert/update a new entry in the database.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference), array $ids.
|
||||
*
|
||||
* @param $ids
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
|
||||
*/
|
||||
public static function &add(&$params, $ids) {
|
||||
|
||||
$fieldValueBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue();
|
||||
$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();
|
||||
return $fieldValueBAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new entry in the database.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference), array $ids.
|
||||
*
|
||||
* @param $ids
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
|
||||
*/
|
||||
public static function create(&$params, $ids) {
|
||||
|
||||
if (!is_array($params) || empty($params)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($id = CRM_Utils_Array::value('id', $ids)) {
|
||||
if (isset($params['name'])) {
|
||||
unset($params['name']);
|
||||
}
|
||||
|
||||
$oldWeight = NULL;
|
||||
if ($id) {
|
||||
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'weight', 'id');
|
||||
}
|
||||
|
||||
$fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0));
|
||||
$params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $oldWeight, $params['weight'], $fieldValues);
|
||||
}
|
||||
else {
|
||||
if (empty($params['name'])) {
|
||||
$params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64);
|
||||
}
|
||||
if (empty($params['weight'])) {
|
||||
$params['weight'] = 1;
|
||||
}
|
||||
}
|
||||
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
|
||||
|
||||
return self::add($params, $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve DB object based on input parameters.
|
||||
*
|
||||
* It also stores all the retrieved values in the default array.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array.
|
||||
* @param array $defaults
|
||||
* (reference ) an assoc array to hold the flattened values.
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $params, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive the all values for given field id.
|
||||
*
|
||||
* @param int $fieldId
|
||||
* Price_field_id.
|
||||
* @param array $values
|
||||
* (reference ) to hold the values.
|
||||
* @param string $orderBy
|
||||
* For order by, default weight.
|
||||
* @param bool|int $isActive is_active, default false
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public static function getValues($fieldId, &$values, $orderBy = 'weight', $isActive = FALSE) {
|
||||
$fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
|
||||
$fieldValueDAO->price_field_id = $fieldId;
|
||||
$fieldValueDAO->orderBy($orderBy, 'label');
|
||||
if ($isActive) {
|
||||
$fieldValueDAO->is_active = 1;
|
||||
}
|
||||
$fieldValueDAO->find();
|
||||
|
||||
while ($fieldValueDAO->fetch()) {
|
||||
CRM_Core_DAO::storeValues($fieldValueDAO, $values[$fieldValueDAO->id]);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the price field option label.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of field option.
|
||||
*
|
||||
* @return string
|
||||
* name
|
||||
*
|
||||
*/
|
||||
public static function getOptionLabel($id) {
|
||||
return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'label');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the is_active flag in the db.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of the database record.
|
||||
* @param bool $is_active
|
||||
* Value we want to set the is_active field.
|
||||
*
|
||||
* @return Object
|
||||
* DAO object on success, null otherwise
|
||||
*
|
||||
*/
|
||||
public static function setIsActive($id, $is_active) {
|
||||
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'is_active', $is_active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all values of the given field id.
|
||||
*
|
||||
* @param int $fieldId
|
||||
* Price field id.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public static function deleteValues($fieldId) {
|
||||
if (!$fieldId) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
|
||||
$fieldValueDAO->price_field_id = $fieldId;
|
||||
$fieldValueDAO->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the value.
|
||||
*
|
||||
* @param int $id
|
||||
* Id.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public static function del($id) {
|
||||
if (!$id) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
|
||||
$fieldValueDAO->id = $id;
|
||||
return $fieldValueDAO->delete();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,311 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @author Marshal Newrock <marshal@idealso.com>
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Business objects for Line Items generated by monetary transactions
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem {
|
||||
|
||||
/**
|
||||
* Creates a new entry in the database.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference) an assoc array of name/value pairs.
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
//create mode only as we don't support editing line items
|
||||
|
||||
CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
|
||||
|
||||
$lineItemBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
|
||||
$lineItemBAO->copyValues($params);
|
||||
|
||||
$return = $lineItemBAO->save();
|
||||
|
||||
CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve DB object based on input parameters.
|
||||
*
|
||||
* It also stores all the retrieved values in the default array.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
* @param array $defaults
|
||||
* (reference ) an assoc array to hold the flattened values.
|
||||
*
|
||||
* @return CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
$lineItem = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
|
||||
$lineItem->copyValues($params);
|
||||
if ($lineItem->find(TRUE)) {
|
||||
CRM_Core_DAO::storeValues($lineItem, $defaults);
|
||||
return $lineItem;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a participant id/contribution id,
|
||||
* return contribution/fee line items
|
||||
*
|
||||
* @param int $entityId
|
||||
* participant/contribution id.
|
||||
* @param string $entity
|
||||
* participant/contribution.
|
||||
*
|
||||
* @param null $isQuick
|
||||
*
|
||||
* @return array
|
||||
* Array of line items
|
||||
*/
|
||||
public static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL) {
|
||||
$selectClause = $whereClause = $fromClause = NULL;
|
||||
|
||||
$selectClause = "
|
||||
SELECT li.id,
|
||||
li.label,
|
||||
li.qty,
|
||||
li.unit_price,
|
||||
li.line_total,
|
||||
pf.label as field_title,
|
||||
pf.html_type,
|
||||
pfv.membership_type_id,
|
||||
li.price_field_id,
|
||||
li.participant_count,
|
||||
li.price_field_value_id,
|
||||
pfv.description";
|
||||
|
||||
$fromClause = "
|
||||
FROM civicrm_%2 as %2
|
||||
LEFT JOIN civicrm_line_item li ON ( li.entity_id = %2.id AND li.entity_table = 'civicrm_%2')
|
||||
LEFT JOIN civicrm_price_field_value pfv ON ( pfv.id = li.price_field_value_id )
|
||||
LEFT JOIN civicrm_price_field pf ON (pf.id = li.price_field_id )";
|
||||
$whereClause = "
|
||||
WHERE %2.id = %1";
|
||||
|
||||
if ($isQuick) {
|
||||
$fromClause .= " LEFT JOIN civicrm_price_set cps on cps.id = pf.price_set_id ";
|
||||
$whereClause .= " and cps.is_quick_config = 0";
|
||||
}
|
||||
$lineItems = array();
|
||||
|
||||
if (!$entityId || !$entity || !$fromClause) {
|
||||
return $lineItems;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
1 => array($entityId, 'Integer'),
|
||||
2 => array($entity, 'Text'),
|
||||
);
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery("$selectClause $fromClause $whereClause", $params);
|
||||
while ($dao->fetch()) {
|
||||
if (!$dao->id) {
|
||||
continue;
|
||||
}
|
||||
$lineItems[$dao->id] = array(
|
||||
'qty' => $dao->qty,
|
||||
'label' => $dao->label,
|
||||
'unit_price' => $dao->unit_price,
|
||||
'line_total' => $dao->line_total,
|
||||
'price_field_id' => $dao->price_field_id,
|
||||
'participant_count' => $dao->participant_count,
|
||||
'price_field_value_id' => $dao->price_field_value_id,
|
||||
'field_title' => $dao->field_title,
|
||||
'html_type' => $dao->html_type,
|
||||
'description' => $dao->description,
|
||||
'entity_id' => $entityId,
|
||||
'membership_type_id' => $dao->membership_type_id,
|
||||
);
|
||||
}
|
||||
return $lineItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
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_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fid, $options, 'weight', TRUE);
|
||||
}
|
||||
$fieldTitle = CRM_Utils_Array::value('label', $fields);
|
||||
if (!$fieldTitle) {
|
||||
$fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $fid, 'label');
|
||||
}
|
||||
|
||||
foreach ($params["price_{$fid}"] as $oid => $qty) {
|
||||
$price = $options[$oid]['amount'];
|
||||
|
||||
// lets clean the price in case it is not yet cleaned
|
||||
// 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]),
|
||||
'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]),
|
||||
'html_type' => $fields['html_type'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete line items for given entity.
|
||||
*
|
||||
* @param int $entityId
|
||||
* @param int $entityTable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function deleteLineItems($entityId, $entityTable) {
|
||||
$result = FALSE;
|
||||
if (!$entityId || !$entityTable) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($entityId && !is_array($entityId)) {
|
||||
$entityId = array($entityId);
|
||||
}
|
||||
|
||||
$query = "DELETE FROM civicrm_line_item where entity_id IN ('" . implode("','", $entityId) . "') AND entity_table = '$entityTable'";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $entityId
|
||||
* @param string $entityTable
|
||||
* @param $amount
|
||||
* @param array $otherParams
|
||||
*/
|
||||
public static function syncLineItems($entityId, $entityTable = 'civicrm_contribution', $amount, $otherParams = NULL) {
|
||||
if (!$entityId || CRM_Utils_System::isNull($amount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$from = " civicrm_line_item li
|
||||
LEFT JOIN civicrm_price_field pf ON pf.id = li.price_field_id
|
||||
LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id ";
|
||||
|
||||
$set = " li.unit_price = %3,
|
||||
li.line_total = %3 ";
|
||||
|
||||
$where = " li.entity_id = %1 AND
|
||||
li.entity_table = %2 ";
|
||||
|
||||
$params = array(
|
||||
1 => array($entityId, 'Integer'),
|
||||
2 => array($entityTable, 'String'),
|
||||
3 => array($amount, 'Float'),
|
||||
);
|
||||
|
||||
if ($entityTable == 'civicrm_contribution') {
|
||||
$entityName = 'default_contribution_amount';
|
||||
$where .= " AND ps.name = %4 ";
|
||||
$params[4] = array($entityName, 'String');
|
||||
}
|
||||
elseif ($entityTable == 'civicrm_participant') {
|
||||
$from .= "
|
||||
LEFT JOIN civicrm_price_set_entity cpse ON cpse.price_set_id = ps.id
|
||||
LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = pf.id and cpfv.label = %4 ";
|
||||
$set .= " ,li.label = %4,
|
||||
li.price_field_value_id = cpfv.id ";
|
||||
$where .= " AND cpse.entity_table = 'civicrm_event' AND cpse.entity_id = %5 ";
|
||||
$amount = empty($amount) ? 0 : $amount;
|
||||
$params += array(
|
||||
4 => array($otherParams['fee_label'], 'String'),
|
||||
5 => array($otherParams['event_id'], 'String'),
|
||||
);
|
||||
}
|
||||
|
||||
$query = "
|
||||
UPDATE $from
|
||||
SET $set
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
CRM_Core_DAO::executeQuery($query, $params);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,443 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field extends CRM_Core_DAO {
|
||||
/**
|
||||
* static instance to hold the table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_price_field';
|
||||
/**
|
||||
* static instance to hold the field values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_fields = NULL;
|
||||
/**
|
||||
* static instance to hold the FK relationships
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_links = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be imported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_import = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be exported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_export = NULL;
|
||||
/**
|
||||
* static value to see if we should log any modifications to
|
||||
* this table in the civicrm_log table
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = TRUE;
|
||||
/**
|
||||
* Price Field
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to civicrm_price_set
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $price_set_id;
|
||||
/**
|
||||
* Variable name/programmatic handle for this field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Text for form field label (also friendly name for administering this field).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $label;
|
||||
/**
|
||||
*
|
||||
* @var enum('Text', 'Select', 'Radio', 'CheckBox')
|
||||
*/
|
||||
public $html_type;
|
||||
/**
|
||||
* Enter a quantity for this field?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_enter_qty;
|
||||
/**
|
||||
* Description and/or help text to display before this field.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $help_pre;
|
||||
/**
|
||||
* Description and/or help text to display after this field.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $help_post;
|
||||
/**
|
||||
* Order in which the fields should appear
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $weight;
|
||||
/**
|
||||
* Should the price be displayed next to the label for each option?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_display_amounts;
|
||||
/**
|
||||
* number of options per line for checkbox and radio
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $options_per_line;
|
||||
/**
|
||||
* Is this price field active
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Is this price field required (value must be > 1)
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_required;
|
||||
/**
|
||||
* If non-zero, do not show this field before the date specified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
public $active_on;
|
||||
/**
|
||||
* If non-zero, do not show this field after the date specified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
public $expire_on;
|
||||
/**
|
||||
* Optional scripting attributes for field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $javascript;
|
||||
/**
|
||||
* Implicit FK to civicrm_option_group with name = \'visibility\'
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $visibility_id;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_price_field';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return foreign links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
'price_set_id' => 'civicrm_price_set:id',
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &fields() {
|
||||
if (!(self::$_fields)) {
|
||||
self::$_fields = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'price_set_id' => array(
|
||||
'name' => 'price_set_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
|
||||
),
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Name'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'label' => array(
|
||||
'name' => 'label',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Label'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'html_type' => array(
|
||||
'name' => 'html_type',
|
||||
'type' => CRM_Utils_Type::T_ENUM,
|
||||
'title' => ts('Html Type'),
|
||||
'required' => TRUE,
|
||||
'enumValues' => 'Text, Select, Radio, CheckBox',
|
||||
),
|
||||
'is_enter_qty' => array(
|
||||
'name' => 'is_enter_qty',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
),
|
||||
'help_pre' => array(
|
||||
'name' => 'help_pre',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Help Pre'),
|
||||
'rows' => 4,
|
||||
'cols' => 80,
|
||||
),
|
||||
'help_post' => array(
|
||||
'name' => 'help_post',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Help Post'),
|
||||
'rows' => 4,
|
||||
'cols' => 80,
|
||||
),
|
||||
'weight' => array(
|
||||
'name' => 'weight',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Weight'),
|
||||
'default' => '',
|
||||
),
|
||||
'is_display_amounts' => array(
|
||||
'name' => 'is_display_amounts',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'default' => '',
|
||||
),
|
||||
'options_per_line' => array(
|
||||
'name' => 'options_per_line',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Options Per Line'),
|
||||
'default' => '',
|
||||
),
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'default' => '',
|
||||
),
|
||||
'is_required' => array(
|
||||
'name' => 'is_required',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'default' => '',
|
||||
),
|
||||
'active_on' => array(
|
||||
'name' => 'active_on',
|
||||
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
|
||||
'title' => ts('Active On'),
|
||||
'default' => 'UL',
|
||||
),
|
||||
'expire_on' => array(
|
||||
'name' => 'expire_on',
|
||||
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
|
||||
'title' => ts('Expire On'),
|
||||
'default' => 'UL',
|
||||
),
|
||||
'javascript' => array(
|
||||
'name' => 'javascript',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Javascript'),
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'visibility_id' => array(
|
||||
'name' => 'visibility_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'default' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the names of this table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName() {
|
||||
return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if this table needs to be logged.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the list of fields that can be imported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = FALSE) {
|
||||
if (!(self::$_import)) {
|
||||
self::$_import = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['import'])) {
|
||||
if ($prefix) {
|
||||
self::$_import['price_field'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_import[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_import;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be exported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = FALSE) {
|
||||
if (!(self::$_export)) {
|
||||
self::$_export = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['export'])) {
|
||||
if ($prefix) {
|
||||
self::$_export['price_field'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_export[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_export;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array containing the enum fields of the civicrm_price_field table.
|
||||
*
|
||||
* @return array
|
||||
* (reference) the array of enum fields
|
||||
*/
|
||||
static function &getEnums() {
|
||||
static $enums = array(
|
||||
'html_type',
|
||||
);
|
||||
return $enums;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a ts()-translated enum value for display purposes
|
||||
*
|
||||
* @param string $field
|
||||
* The enum field in question.
|
||||
* @param string $value
|
||||
* The enum value up for translation.
|
||||
*
|
||||
* @return string
|
||||
* the display value of the enum
|
||||
*/
|
||||
public static function tsEnum($field, $value) {
|
||||
static $translations = NULL;
|
||||
if (!$translations) {
|
||||
$translations = array(
|
||||
'html_type' => array(
|
||||
'Text' => ts('Text'),
|
||||
'Select' => ts('Select'),
|
||||
'Radio' => ts('Radio'),
|
||||
'CheckBox' => ts('CheckBox'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return $translations[$field][$value];
|
||||
}
|
||||
|
||||
/**
|
||||
* adds $value['foo_display'] for each $value['foo'] enum from civicrm_price_field
|
||||
*
|
||||
* @param array $values
|
||||
* (reference) the array up for enhancing.
|
||||
*/
|
||||
public static function addDisplayEnums(&$values) {
|
||||
$enumFields = &Snapshot_v4p2_Price_DAO_Field::getEnums();
|
||||
foreach ($enumFields as $enum) {
|
||||
if (isset($values[$enum])) {
|
||||
$values[$enum . '_display'] = Snapshot_v4p2_Price_DAO_Field::tsEnum($enum, $values[$enum]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue extends CRM_Core_DAO {
|
||||
/**
|
||||
* static instance to hold the table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_price_field_value';
|
||||
/**
|
||||
* static instance to hold the field values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_fields = NULL;
|
||||
/**
|
||||
* static instance to hold the FK relationships
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_links = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be imported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_import = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be exported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_export = NULL;
|
||||
/**
|
||||
* static value to see if we should log any modifications to
|
||||
* this table in the civicrm_log table
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = FALSE;
|
||||
/**
|
||||
* Price Field Value
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* FK to civicrm_price_field
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $price_field_id;
|
||||
/**
|
||||
* Price field option name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Price field option label
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $label;
|
||||
/**
|
||||
* >Price field option description.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $description;
|
||||
/**
|
||||
* Price field option amount
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $amount;
|
||||
/**
|
||||
* Number of participants per field option
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $count;
|
||||
/**
|
||||
* Max number of participants per field options
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $max_value;
|
||||
/**
|
||||
* Order in which the field options should appear
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $weight;
|
||||
/**
|
||||
* FK to Membership Type
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $membership_type_id;
|
||||
/**
|
||||
* Is this default price field option
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_default;
|
||||
/**
|
||||
* Is this price field value active
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_price_field_value';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return foreign links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
'price_field_id' => 'civicrm_price_field:id',
|
||||
'membership_type_id' => 'civicrm_membership_type:id',
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &fields() {
|
||||
if (!(self::$_fields)) {
|
||||
self::$_fields = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'price_field_id' => array(
|
||||
'name' => 'price_field_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
|
||||
),
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Name'),
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'label' => array(
|
||||
'name' => 'label',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Label'),
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'description' => array(
|
||||
'name' => 'description',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Description'),
|
||||
'rows' => 2,
|
||||
'cols' => 60,
|
||||
'default' => 'UL',
|
||||
),
|
||||
'amount' => array(
|
||||
'name' => 'amount',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Amount'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 512,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'count' => array(
|
||||
'name' => 'count',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Count'),
|
||||
'default' => 'UL',
|
||||
),
|
||||
'max_value' => array(
|
||||
'name' => 'max_value',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Max Value'),
|
||||
'default' => 'UL',
|
||||
),
|
||||
'weight' => array(
|
||||
'name' => 'weight',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Weight'),
|
||||
'default' => '',
|
||||
),
|
||||
'membership_type_id' => array(
|
||||
'name' => 'membership_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'default' => 'UL',
|
||||
'FKClassName' => 'CRM_Member_DAO_MembershipType',
|
||||
),
|
||||
'is_default' => array(
|
||||
'name' => 'is_default',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
),
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'default' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the names of this table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName() {
|
||||
return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if this table needs to be logged.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be imported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = FALSE) {
|
||||
if (!(self::$_import)) {
|
||||
self::$_import = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['import'])) {
|
||||
if ($prefix) {
|
||||
self::$_import['price_field_value'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_import[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_import;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be exported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = FALSE) {
|
||||
if (!(self::$_export)) {
|
||||
self::$_export = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['export'])) {
|
||||
if ($prefix) {
|
||||
self::$_export['price_field_value'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_export[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_export;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,308 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem extends CRM_Core_DAO {
|
||||
/**
|
||||
* static instance to hold the table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_line_item';
|
||||
/**
|
||||
* static instance to hold the field values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_fields = NULL;
|
||||
/**
|
||||
* static instance to hold the FK relationships
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_links = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be imported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_import = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be exported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_export = NULL;
|
||||
/**
|
||||
* static value to see if we should log any modifications to
|
||||
* this table in the civicrm_log table
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = TRUE;
|
||||
/**
|
||||
* Line Item
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* table which has the transaction
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* entry in table
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* FK to price_field
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $price_field_id;
|
||||
/**
|
||||
* descriptive label for item - from price_field_value.label
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $label;
|
||||
/**
|
||||
* How many items ordered
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $qty;
|
||||
/**
|
||||
* price of each item
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $unit_price;
|
||||
/**
|
||||
* qty * unit_price
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $line_total;
|
||||
/**
|
||||
* Participant count for field
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $participant_count;
|
||||
/**
|
||||
* Implicit FK to civicrm_option_value
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $price_field_value_id;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_line_item';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return foreign links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
'price_field_id' => 'civicrm_price_field:id',
|
||||
'price_field_value_id' => 'civicrm_price_field_value:id',
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &fields() {
|
||||
if (!(self::$_fields)) {
|
||||
self::$_fields = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Entity Table'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
),
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'price_field_id' => array(
|
||||
'name' => 'price_field_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
|
||||
),
|
||||
'label' => array(
|
||||
'name' => 'label',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Label'),
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'default' => 'UL',
|
||||
),
|
||||
'qty' => array(
|
||||
'name' => 'qty',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Qty'),
|
||||
'required' => TRUE,
|
||||
),
|
||||
'unit_price' => array(
|
||||
'name' => 'unit_price',
|
||||
'type' => CRM_Utils_Type::T_MONEY,
|
||||
'title' => ts('Unit Price'),
|
||||
'required' => TRUE,
|
||||
),
|
||||
'line_total' => array(
|
||||
'name' => 'line_total',
|
||||
'type' => CRM_Utils_Type::T_MONEY,
|
||||
'title' => ts('Line Total'),
|
||||
'required' => TRUE,
|
||||
),
|
||||
'participant_count' => array(
|
||||
'name' => 'participant_count',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Participant Count'),
|
||||
'default' => 'UL',
|
||||
),
|
||||
'price_field_value_id' => array(
|
||||
'name' => 'price_field_value_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'default' => 'UL',
|
||||
'FKClassName' => 'Snapshot_v4p2_Price_DAO_FieldValue',
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the names of this table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if this table needs to be logged.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the list of fields that can be imported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = FALSE) {
|
||||
if (!(self::$_import)) {
|
||||
self::$_import = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['import'])) {
|
||||
if ($prefix) {
|
||||
self::$_import['line_item'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_import[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_import;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be exported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = FALSE) {
|
||||
if (!(self::$_export)) {
|
||||
self::$_export = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['export'])) {
|
||||
if ($prefix) {
|
||||
self::$_export['line_item'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_export[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_export;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set extends CRM_Core_DAO {
|
||||
/**
|
||||
* static instance to hold the table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_price_set';
|
||||
/**
|
||||
* static instance to hold the field values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_fields = NULL;
|
||||
/**
|
||||
* static instance to hold the FK relationships
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_links = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be imported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_import = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be exported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_export = NULL;
|
||||
/**
|
||||
* static value to see if we should log any modifications to
|
||||
* this table in the civicrm_log table
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = TRUE;
|
||||
/**
|
||||
* Price Set
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Which Domain is this price-set for
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $domain_id;
|
||||
/**
|
||||
* Variable name/programmatic handle for this set of price fields.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Displayed title for the Price Set.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
/**
|
||||
* Is this price set active
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Description and/or help text to display before fields in form.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $help_pre;
|
||||
/**
|
||||
* Description and/or help text to display after fields in form.
|
||||
*
|
||||
* @var text
|
||||
*/
|
||||
public $help_post;
|
||||
/**
|
||||
* Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $javascript;
|
||||
/**
|
||||
* What components are using this price set?
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $extends;
|
||||
/**
|
||||
* FK to Contribution Type(for membership price sets only).
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contribution_type_id;
|
||||
/**
|
||||
* Is set if edited on Contribution or Event Page rather than through Manage Price Sets
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_quick_config;
|
||||
/**
|
||||
* Is this a predefined system price set (i.e. it can not be deleted, edited)?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_reserved;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_price_set';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return foreign links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
'domain_id' => 'civicrm_domain:id',
|
||||
'contribution_type_id' => 'civicrm_contribution_type:id',
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &fields() {
|
||||
if (!(self::$_fields)) {
|
||||
self::$_fields = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'domain_id' => array(
|
||||
'name' => 'domain_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'FKClassName' => 'CRM_Core_DAO_Domain',
|
||||
),
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Name'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'title' => array(
|
||||
'name' => 'title',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Title'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'default' => '',
|
||||
),
|
||||
'help_pre' => array(
|
||||
'name' => 'help_pre',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Help Pre'),
|
||||
'rows' => 4,
|
||||
'cols' => 80,
|
||||
),
|
||||
'help_post' => array(
|
||||
'name' => 'help_post',
|
||||
'type' => CRM_Utils_Type::T_TEXT,
|
||||
'title' => ts('Help Post'),
|
||||
'rows' => 4,
|
||||
'cols' => 80,
|
||||
),
|
||||
'javascript' => array(
|
||||
'name' => 'javascript',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Javascript'),
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
),
|
||||
'extends' => array(
|
||||
'name' => 'extends',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Extends'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
),
|
||||
'contribution_type_id' => array(
|
||||
'name' => 'contribution_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'default' => 'UL',
|
||||
'FKClassName' => 'CRM_Contribute_DAO_ContributionType',
|
||||
),
|
||||
'is_quick_config' => array(
|
||||
'name' => 'is_quick_config',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
),
|
||||
'is_reserved' => array(
|
||||
'name' => 'is_reserved',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the names of this table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName() {
|
||||
return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if this table needs to be logged.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be imported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = FALSE) {
|
||||
if (!(self::$_import)) {
|
||||
self::$_import = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['import'])) {
|
||||
if ($prefix) {
|
||||
self::$_import['price_set'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_import[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_import;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the list of fields that can be exported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = FALSE) {
|
||||
if (!(self::$_export)) {
|
||||
self::$_export = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['export'])) {
|
||||
if ($prefix) {
|
||||
self::$_export['price_set'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_export[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_export;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
|
||||
/**
|
||||
* Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
|
||||
*/
|
||||
class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity extends CRM_Core_DAO {
|
||||
/**
|
||||
* static instance to hold the table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_price_set_entity';
|
||||
/**
|
||||
* static instance to hold the field values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_fields = NULL;
|
||||
/**
|
||||
* static instance to hold the FK relationships
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_links = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be imported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_import = NULL;
|
||||
/**
|
||||
* static instance to hold the values that can
|
||||
* be exported
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_export = NULL;
|
||||
/**
|
||||
* static value to see if we should log any modifications to
|
||||
* this table in the civicrm_log table
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = TRUE;
|
||||
/**
|
||||
* Price Set Entity
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Table which uses this price set
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* Item in table
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* price set being used
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $price_set_id;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_price_set_entity';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return foreign links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
'price_set_id' => 'civicrm_price_set:id',
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &fields() {
|
||||
if (!(self::$_fields)) {
|
||||
self::$_fields = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Entity Table'),
|
||||
'required' => TRUE,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
),
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
),
|
||||
'price_set_id' => array(
|
||||
'name' => 'price_set_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'required' => TRUE,
|
||||
'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the names of this table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if this table needs to be logged.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be imported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = FALSE) {
|
||||
if (!(self::$_import)) {
|
||||
self::$_import = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['import'])) {
|
||||
if ($prefix) {
|
||||
self::$_import['price_set_entity'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_import[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_import;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the list of fields that can be exported.
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = FALSE) {
|
||||
if (!(self::$_export)) {
|
||||
self::$_export = array();
|
||||
$fields = self::fields();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['export'])) {
|
||||
if ($prefix) {
|
||||
self::$_export['price_set_entity'] = &$fields[$name];
|
||||
}
|
||||
else {
|
||||
self::$_export[$name] = &$fields[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$_export;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue