Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTHAB-284: Add new entity to store membership rate #507

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CRM/MembershipExtras/BAO/MembershipRate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
use CRM_MembershipExtras_ExtensionUtil as E;

class CRM_MembershipExtras_BAO_MembershipRate extends CRM_MembershipExtras_DAO_MembershipRate {

/**
* Create a new MembershipRate based on array-data
*
* @param array $params key-value pairs
* @return CRM_MembershipExtras_DAO_MembershipRate|NULL
*
*/
public static function create($params) {
$className = 'CRM_MembershipExtras_DAO_MembershipRate';
$entityName = 'MembershipRate';
$hook = empty($params['id']) ? 'create' : 'edit';

CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

return $instance;
}

}
26 changes: 26 additions & 0 deletions CRM/MembershipExtras/BAO/MembershipRateMembershipType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
use CRM_MembershipExtras_ExtensionUtil as E;

class CRM_MembershipExtras_BAO_MembershipRateMembershipType extends CRM_MembershipExtras_DAO_MembershipRateMembershipType {

/**
* Create a new MembershipRateMembershipType based on array-data
*
* @param array $params key-value pairs
* @return CRM_MembershipExtras_DAO_MembershipRateMembershipType|NULL
*/
public static function create($params) {
$className = 'CRM_MembershipExtras_DAO_MembershipRateMembershipType';
$entityName = 'MembershipRateMembershipType';
$hook = empty($params['id']) ? 'create' : 'edit';

CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

return $instance;
}

}
77 changes: 53 additions & 24 deletions CRM/MembershipExtras/DAO/AutoMembershipUpgradeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from /home/vagrant/buildkit/build/me4test6/web/sites/all/modules/civicrm/tools/extensions/uk.co.compucorp.membershipextras/xml/schema/CRM/MembershipExtras/AutoMembershipUpgradeRule.xml
* Generated from uk.co.compucorp.membershipextras/xml/schema/CRM/MembershipExtras/AutoMembershipUpgradeRule.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:1d9c07a1da7a8b6f08144088e9354390)
* (GenCodeChecksum:2074fbde3a3969945123affa03e1baed)
*/
use CRM_MembershipExtras_ExtensionUtil as E;

/**
* Database access object for the AutoMembershipUpgradeRule entity.
*/
class CRM_MembershipExtras_DAO_AutoMembershipUpgradeRule extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';

/**
* Static instance to hold the table name.
Expand All @@ -29,63 +32,85 @@ class CRM_MembershipExtras_DAO_AutoMembershipUpgradeRule extends CRM_Core_DAO {
public static $_log = FALSE;

/**
* @var int
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;

/**
* @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $name;

/**
* @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $label;

/**
* FK to civicrm_membership_type table
*
* @var int
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $from_membership_type_id;

/**
* FK to civicrm_membership_type table
*
* @var int
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $to_membership_type_id;

/**
* @var int
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $upgrade_trigger_date_type;

/**
* @var int
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $period_length;

/**
* @var int
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $period_length_unit;

/**
* FK to civicrm_group table
*
* @var int
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $filter_group;

/**
* @var int
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $weight;

/**
* @var bool
* @var bool|string|null
* (SQL type: tinyint)
* Note that values will be retrieved from the database as a string.
*/
public $is_active;

Expand All @@ -99,9 +124,12 @@ public function __construct() {

/**
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle() {
return ts('Auto Membership Upgrade Rules');
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Auto Membership Upgrade Rules') : E::ts('Auto Membership Upgrade Rule');
}

/**
Expand Down Expand Up @@ -132,19 +160,20 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Id'),
'title' => E::ts('Id'),
'required' => TRUE,
'where' => 'membershipextras_auto_membership_upgrade_rule.id',
'table_name' => 'membershipextras_auto_membership_upgrade_rule',
'entity' => 'AutoMembershipUpgradeRule',
'bao' => 'CRM_MembershipExtras_DAO_AutoMembershipUpgradeRule',
'localizable' => 0,
'readonly' => TRUE,
'add' => NULL,
],
'name' => [
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Name'),
'title' => E::ts('Name'),
'required' => 1,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
Expand All @@ -158,7 +187,7 @@ public static function &fields() {
'label' => [
'name' => 'label',
'type' => CRM_Utils_Type::T_STRING,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Label'),
'title' => E::ts('Label'),
'required' => 1,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
Expand All @@ -172,7 +201,7 @@ public static function &fields() {
'from_membership_type_id' => [
'name' => 'from_membership_type_id',
'type' => CRM_Utils_Type::T_INT,
'description' => CRM_MembershipExtras_ExtensionUtil::ts('FK to civicrm_membership_type table'),
'description' => E::ts('FK to civicrm_membership_type table'),
'required' => 1,
'where' => 'membershipextras_auto_membership_upgrade_rule.from_membership_type_id',
'table_name' => 'membershipextras_auto_membership_upgrade_rule',
Expand All @@ -185,7 +214,7 @@ public static function &fields() {
'to_membership_type_id' => [
'name' => 'to_membership_type_id',
'type' => CRM_Utils_Type::T_INT,
'description' => CRM_MembershipExtras_ExtensionUtil::ts('FK to civicrm_membership_type table'),
'description' => E::ts('FK to civicrm_membership_type table'),
'required' => 1,
'where' => 'membershipextras_auto_membership_upgrade_rule.to_membership_type_id',
'table_name' => 'membershipextras_auto_membership_upgrade_rule',
Expand All @@ -198,7 +227,7 @@ public static function &fields() {
'upgrade_trigger_date_type' => [
'name' => 'upgrade_trigger_date_type',
'type' => CRM_Utils_Type::T_INT,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Upgrade Trigger Date Type'),
'title' => E::ts('Upgrade Trigger Date Type'),
'required' => 1,
'where' => 'membershipextras_auto_membership_upgrade_rule.upgrade_trigger_date_type',
'default' => '1',
Expand All @@ -214,7 +243,7 @@ public static function &fields() {
'period_length' => [
'name' => 'period_length',
'type' => CRM_Utils_Type::T_INT,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Period Length'),
'title' => E::ts('Period Length'),
'required' => 1,
'where' => 'membershipextras_auto_membership_upgrade_rule.period_length',
'default' => '1',
Expand All @@ -227,7 +256,7 @@ public static function &fields() {
'period_length_unit' => [
'name' => 'period_length_unit',
'type' => CRM_Utils_Type::T_INT,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Period Length Unit'),
'title' => E::ts('Period Length Unit'),
'required' => 1,
'where' => 'membershipextras_auto_membership_upgrade_rule.period_length_unit',
'default' => '1',
Expand All @@ -243,8 +272,8 @@ public static function &fields() {
'filter_group' => [
'name' => 'filter_group',
'type' => CRM_Utils_Type::T_INT,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Filter Group'),
'description' => CRM_MembershipExtras_ExtensionUtil::ts('FK to civicrm_group table'),
'title' => E::ts('Filter Group'),
'description' => E::ts('FK to civicrm_group table'),
'where' => 'membershipextras_auto_membership_upgrade_rule.filter_group',
'table_name' => 'membershipextras_auto_membership_upgrade_rule',
'entity' => 'AutoMembershipUpgradeRule',
Expand All @@ -256,7 +285,7 @@ public static function &fields() {
'weight' => [
'name' => 'weight',
'type' => CRM_Utils_Type::T_INT,
'title' => CRM_MembershipExtras_ExtensionUtil::ts('Weight'),
'title' => E::ts('Weight'),
'required' => 1,
'where' => 'membershipextras_auto_membership_upgrade_rule.weight',
'table_name' => 'membershipextras_auto_membership_upgrade_rule',
Expand Down
Loading
Loading