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

CIWEMB-372: Update the payment scheme form #481

Merged
Merged
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
78 changes: 39 additions & 39 deletions CRM/MembershipExtras/DAO/PaymentScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from uk.co.compucorp.membershipextras/xml/schema/CRM/MembershipExtras/PaymentScheme.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:08284c4d333470d57b11f295d2159886)
* (GenCodeChecksum:4c9369ab33edde1eedc52b603af295af)
*/
use CRM_MembershipExtras_ExtensionUtil as E;

Expand Down Expand Up @@ -42,39 +42,46 @@ class CRM_MembershipExtras_DAO_PaymentScheme extends CRM_Core_DAO {

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

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

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

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

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

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

/**
* @var string
* (SQL type: varchar(10))
Expand All @@ -96,13 +103,6 @@ class CRM_MembershipExtras_DAO_PaymentScheme extends CRM_Core_DAO {
*/
public $parameters;

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

/**
* Class constructor.
*/
Expand Down Expand Up @@ -165,7 +165,7 @@ public static function &fields() {
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Name'),
'required' => TRUE,
'maxlength' => 255,
'maxlength' => 250,
'size' => CRM_Utils_Type::HUGE,
'where' => 'membershipextras_payment_scheme.name',
'table_name' => 'membershipextras_payment_scheme',
Expand All @@ -178,8 +178,7 @@ public static function &fields() {
'name' => 'admin_title',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Admin title'),
'required' => TRUE,
'maxlength' => 255,
'maxlength' => 250,
'size' => CRM_Utils_Type::HUGE,
'where' => 'membershipextras_payment_scheme.admin_title',
'table_name' => 'membershipextras_payment_scheme',
Expand All @@ -188,13 +187,13 @@ public static function &fields() {
'localizable' => 0,
'add' => NULL,
],
'admin_description' => [
'name' => 'admin_description',
'description' => [
'name' => 'description',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Admin Description'),
'maxlength' => 255,
'title' => E::ts('Description'),
'maxlength' => 500,
'size' => CRM_Utils_Type::HUGE,
'where' => 'membershipextras_payment_scheme.admin_description',
'where' => 'membershipextras_payment_scheme.description',
'table_name' => 'membershipextras_payment_scheme',
'entity' => 'PaymentScheme',
'bao' => 'CRM_MembershipExtras_DAO_PaymentScheme',
Expand All @@ -206,7 +205,7 @@ public static function &fields() {
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Public title'),
'required' => TRUE,
'maxlength' => 255,
'maxlength' => 250,
'size' => CRM_Utils_Type::HUGE,
'where' => 'membershipextras_payment_scheme.public_title',
'table_name' => 'membershipextras_payment_scheme',
Expand All @@ -219,7 +218,8 @@ public static function &fields() {
'name' => 'public_description',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Public description'),
'maxlength' => 255,
'required' => TRUE,
'maxlength' => 500,
'size' => CRM_Utils_Type::HUGE,
'where' => 'membershipextras_payment_scheme.public_description',
'table_name' => 'membershipextras_payment_scheme',
Expand All @@ -228,6 +228,19 @@ public static function &fields() {
'localizable' => 0,
'add' => NULL,
],
'payment_processor' => [
'name' => 'payment_processor',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Payment Processor'),
'required' => TRUE,
'where' => 'membershipextras_payment_scheme.payment_processor',
'table_name' => 'membershipextras_payment_scheme',
'entity' => 'PaymentScheme',
'bao' => 'CRM_MembershipExtras_DAO_PaymentScheme',
'localizable' => 0,
'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
'add' => NULL,
],
'permission' => [
'name' => 'permission',
'type' => CRM_Utils_Type::T_STRING,
Expand Down Expand Up @@ -267,19 +280,6 @@ public static function &fields() {
'localizable' => 0,
'add' => NULL,
],
'payment_processor' => [
'name' => 'payment_processor',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Payment Processor'),
'required' => TRUE,
'where' => 'membershipextras_payment_scheme.payment_processor',
'table_name' => 'membershipextras_payment_scheme',
'entity' => 'PaymentScheme',
'bao' => 'CRM_MembershipExtras_DAO_PaymentScheme',
'localizable' => 0,
'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
Expand Down
26 changes: 13 additions & 13 deletions CRM/MembershipExtras/Form/PaymentScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ public function buildQuickForm() {
return;
}

$this->add('text', 'name', ts('Name'), NULL, TRUE);
$this->add('text', 'admin_title', ts('Admin Title'), NULL, TRUE);
$this->add('textarea', 'admin_description', ts('Admin Description'));
$this->add('text', 'public_title', ts('Public Title'), NULL, TRUE);
$this->add('textarea', 'public_description', ts('Public Description'));
$this->add('text', 'name', ts('Name'), ['maxlength' => 250, 'size' => 50], TRUE);
$this->add('text', 'admin_title', ts('Admin Title'), ['maxlength' => 250, 'size' => 50]);
$this->add('textarea', 'description', ts('Description'), ['maxlength' => 500, 'cols' => 49]);
$this->add('text', 'public_title', ts('Public Title'), ['maxlength' => 250, 'size' => 50], TRUE);
$this->add('textarea', 'public_description', ts('Public Description'), ['maxlength' => 500, 'cols' => 49], TRUE);
$this->addPaymentProcessorField();
$this->add(
'select',
'permission',
'permission',
ts('Permission'),
[
'public' => ts('Public'),
'admin' => ts('Admin'),
],
TRUE
);
$this->add('checkbox', 'enabled', ts('Enabled'), NULL, FALSE);
$this->addPaymentProcessorField();
$this->add('textarea', 'parameters', ts('Parameters'), NULL, TRUE);
$this->add('textarea', 'parameters', ts('Parameters'), ['cols' => 49], TRUE);

$this->addButtons([
[
Expand Down Expand Up @@ -115,13 +115,13 @@ public function setDefaultValues() {
'id' => $scheme['id'],
'name' => $scheme['name'],
'admin_title' => $scheme['admin_title'],
'admin_description' => $scheme['admin_title'],
'description' => $scheme['description'],
'public_title' => $scheme['public_title'],
'public_description' => $scheme['public_description'],
'payment_processor' => $scheme['payment_processor'],
'permission' => $scheme['permission'],
'enabled' => $scheme['enabled'],
'parameters' => $scheme['parameters'],
'payment_processor' => $scheme['payment_processor'],
];
}

Expand All @@ -138,6 +138,7 @@ public function getRenderableElementNames() {
$elementNames[] = $element->getName();
}
}

return $elementNames;
}

Expand Down Expand Up @@ -165,7 +166,6 @@ private function addPaymentProcessorField() {
$select = ['' => ts('- select -')] + $paymentProcessors;

$this->add('select', 'payment_processor', ts('Payment Processor'), $select, TRUE);

}

private function isDeleteContext() {
Expand All @@ -189,13 +189,13 @@ private function postProcessFormSubmission() {
$params = [
'name' => $values['name'],
'admin_title' => $values['admin_title'],
'admin_description' => $values['admin_description'],
'description' => $values['description'],
'public_title' => $values['public_title'],
'public_description' => $values['public_description'],
'payment_processor' => $values['payment_processor'],
'permission' => $values['permission'],
'enabled' => CRM_Utils_Array::value('enabled', $values, FALSE),
'parameters' => $values['parameters'],
'payment_processor' => $values['payment_processor'],
];

if (!empty($this->id)) {
Expand Down
21 changes: 12 additions & 9 deletions sql/auto_install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ DROP TABLE IF EXISTS `membershipextras_payment_scheme`;
SET FOREIGN_KEY_CHECKS=1;

-- /*******************************************************
-- * Create recurring contribution line items table
-- *******************************************************/
CREATE TABLE `membershipextras_subscription_line` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Discount Item ID',
Expand Down Expand Up @@ -32,20 +31,24 @@ CREATE TABLE `membershipextras_subscription_line` (
);

-- /*******************************************************
-- * Creates membershipextras_payment_scheme
-- *
-- * membershipextras_payment_scheme
-- *
-- * A table that store payment scheme that will be used for creating a payment plan
-- *
-- *******************************************************/
CREATE TABLE `membershipextras_payment_scheme` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique PaymentScheme ID',
`name` varchar(255) NOT NULL,
`admin_title` varchar(255) NOT NULL,
`admin_description` varchar(255),
`public_title` varchar(255) NOT NULL,
`public_description` varchar(255),
`name` varchar(250) NOT NULL,
`admin_title` varchar(250),
`description` varchar(500),
`public_title` varchar(250) NOT NULL,
`public_description` varchar(500) NOT NULL,
`payment_processor` int unsigned NOT NULL,
`permission` varchar(10) NOT NULL,
`enabled` tinyint NOT NULL DEFAULT false,
`parameters` text NOT NULL,
`payment_processor` int unsigned NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT FK_membershipextras_payment_scheme_payment_processor FOREIGN KEY (`payment_processor`) REFERENCES `civicrm_payment_processor`(`id`) ON DELETE CASCADE
)
ENGINE=InnoDB;
ENGINE=InnoDB;
12 changes: 6 additions & 6 deletions sql/upgrade/Step0010.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
-- *******************************************************/
CREATE TABLE `membershipextras_payment_scheme` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique PaymentScheme ID',
`name` varchar(255) NOT NULL,
`admin_title` varchar(255) NOT NULL,
`admin_description` varchar(255),
`public_title` varchar(255) NOT NULL,
`public_description` varchar(255),
`name` varchar(250) NOT NULL,
`admin_title` varchar(250),
`description` varchar(500),
`public_title` varchar(250) NOT NULL,
`public_description` varchar(500) NOT NULL,
`payment_processor` int unsigned NOT NULL,
`permission` varchar(10) NOT NULL,
`enabled` tinyint NOT NULL DEFAULT false,
`parameters` text NOT NULL,
`payment_processor` int unsigned NOT NULL,
PRIMARY KEY (`id`),

CONSTRAINT FK_membershipextras_payment_scheme_payment_processor
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/MembershipExtras/BAO/PaymentSchemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testCreatePaymentScheme() {
$params = [
'name' => 'Test scheme',
'admin_title' => 'Admin title',
'admin_description' => 'Admin description',
'description' => 'description',
'public_title' => 'Public value',
'public_description' => 'Public description',
'permission' => 'public',
Expand All @@ -39,7 +39,7 @@ public function testGetAll() {

$param = [
'admin_title' => 'Admin title',
'admin_description' => 'Admin description',
'description' => 'description',
'public_title' => 'Public value',
'public_description' => 'Public description',
'permission' => 'public',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function createPaymentScheme() {
$params = [
'name' => 'Test scheme',
'admin_title' => 'Admin title',
'admin_description' => 'Admin description',
'description' => 'description',
'public_title' => 'Public value',
'public_description' => 'Public description',
'permission' => 'public',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function createPaymentSchemeAndLinkToPaymentPlanOrder() {
$params = [
'name' => 'Test scheme',
'admin_title' => 'Admin title',
'admin_description' => 'Admin description',
'description' => 'description',
'public_title' => 'Public value',
'public_description' => 'Public description',
'permission' => 'public',
Expand Down
Loading
Loading