diff --git a/CRM/Civicase/Setup/Manage/MembershipTypeCustomFieldManager.php b/CRM/Civicase/Setup/Manage/MembershipTypeCustomFieldManager.php new file mode 100644 index 000000000..710425708 --- /dev/null +++ b/CRM/Civicase/Setup/Manage/MembershipTypeCustomFieldManager.php @@ -0,0 +1,34 @@ + self::OPTION_GROUP_NAME, + "label" => "Membership Type", + "value" => "MembershipType", + "name" => "civicrm_membership_type", + 'is_active' => TRUE, + 'is_reserved' => TRUE, + ]); + } + + /** + * {@inheritDoc} + */ + public function remove(): void {} + + /** + * {@inheritDoc} + */ + protected function toggle($status): void {} + +} diff --git a/CRM/Civicase/Upgrader.php b/CRM/Civicase/Upgrader.php index f188ebf40..d3de92044 100644 --- a/CRM/Civicase/Upgrader.php +++ b/CRM/Civicase/Upgrader.php @@ -1,23 +1,24 @@ create(); (new CaseSalesOrderStatusManager())->create(); (new QuotationTemplateManager())->create(); + (new MembershipTypeCustomFieldManager())->create(); } /** diff --git a/CRM/Civicase/Upgrader/Steps/Step0020.php b/CRM/Civicase/Upgrader/Steps/Step0020.php new file mode 100644 index 000000000..1011d2db4 --- /dev/null +++ b/CRM/Civicase/Upgrader/Steps/Step0020.php @@ -0,0 +1,30 @@ +create(); + } + catch (\Throwable $th) { + \Civi::log()->error('Error upgrading Civicase', [ + 'context' => [ + 'backtrace' => $th->getTraceAsString(), + 'message' => $th->getMessage(), + ], + ]); + } + + return TRUE; + } + +} diff --git a/managed/CustomGroup_Product_Discounts.mgd.php b/managed/CustomGroup_Product_Discounts.mgd.php new file mode 100644 index 000000000..163677024 --- /dev/null +++ b/managed/CustomGroup_Product_Discounts.mgd.php @@ -0,0 +1,94 @@ + 'CustomGroup_Product_Discounts', + 'entity' => 'CustomGroup', + 'cleanup' => 'always', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Product_Discounts', + 'title' => 'Product Discounts', + 'extends' => 'MembershipType', + 'extends_entity_column_value' => NULL, + 'style' => 'Inline', + 'collapse_display' => FALSE, + 'help_pre' => '', + 'help_post' => '', + 'weight' => 107, + 'is_active' => TRUE, + 'is_multiple' => FALSE, + 'min_multiple' => NULL, + 'max_multiple' => NULL, + 'collapse_adv_display' => TRUE, + 'created_date' => '2023-08-25 07:22:08', + 'is_reserved' => FALSE, + 'is_public' => TRUE, + 'icon' => '', + 'extends_entity_column_id' => NULL, + ], + ], + ], + [ + 'name' => 'CustomGroup_Product_Discounts_CustomField_Product_Discount_Amount', + 'entity' => 'CustomField', + 'cleanup' => 'always', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Product_Discounts', + 'name' => 'Product_Discount_Amount', + 'label' => 'Product Discount Amount', + 'data_type' => 'Float', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => 'Specify a discount that will automatically be applied when adding a product line item to a quotation if the contact is a member of this type.', + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'product_discount_amount', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], +]; + +$rowCount = OptionValue::get(FALSE) + ->selectRowCount() + ->addSelect('*') + ->addWhere('option_group_id:name', '=', 'cg_extend_objects') + ->addWhere('name', '=', 'civicrm_membership_type') + ->execute() + ->count(); + +if ($rowCount == 1) { + return $mgd; +} + +return [];