From 57b2b9afdfce8450df5890df88333a688852b2cb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 27 Oct 2023 17:40:38 +1300 Subject: [PATCH] Load metadata from settings for Contribution Invoice Settings --- CRM/Admin/Form/Preferences/Contribute.php | 70 +++-------------------- settings/Contribute.setting.php | 5 +- 2 files changed, 13 insertions(+), 62 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index e6182123ee..6c2edd7ebc 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -42,67 +42,15 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { */ public function buildQuickForm() { parent::buildQuickForm(); + $metadata = \Civi\Core\SettingsMetadata::getMetadata(['name' => ['invoice_prefix', 'tax_term', 'invoice_notes', 'invoice_due_date', 'invoice_is_email_pdf', 'invoice_due_date_period', 'tax_display_settings']], NULL, TRUE); $this->invoiceSettings = [ - 'invoice_prefix' => [ - 'html_type' => 'text', - 'title' => ts('Invoice Prefix'), - 'weight' => 1, - 'description' => ts('Enter prefix to be display on PDF for invoice'), - ], - 'due_date' => [ - 'html_type' => 'text', - 'title' => ts('Due Date'), - 'weight' => 3, - 'description' => '', - ], - 'due_date_period' => [ - 'html_type' => 'select', - 'title' => ts('For transmission'), - 'weight' => 4, - 'description' => ts('Select the interval for due date.'), - 'option_values' => [ - 'select' => ts('- select -'), - 'days' => ts('Days'), - 'months' => ts('Months'), - 'years' => ts('Years'), - ], - ], - 'notes' => [ - 'html_type' => 'wysiwyg', - 'title' => ts('Notes or Standard Terms'), - 'weight' => 5, - 'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '), - 'attributes' => ['rows' => 2, 'cols' => 40], - ], - 'is_email_pdf' => [ - 'html_type' => 'checkbox', - 'title' => ts('Automatically email invoice when user purchases online'), - 'weight' => 6, - 'description' => ts('Should a pdf invoice be emailed automatically?'), - ], - 'tax_term' => [ - 'html_type' => 'text', - 'title' => ts('Tax Term'), - 'weight' => 7, - 'description' => '', - ], - 'tax_display_settings' => [ - 'html_type' => 'select', - 'title' => ts('Tax Display Settings'), - 'weight' => 8, - 'description' => '', - 'option_values' => [ - 'Do_not_show' => ts('Do not show breakdown, only show total - i.e %1', [ - 1 => CRM_Utils_Money::format(120), - ]), - 'Inclusive' => ts('Show [tax term] inclusive price - i.e. %1', [ - 1 => ts('%1 (includes [tax term] of %2)', [1 => CRM_Utils_Money::format(120), 2 => CRM_Utils_Money::format(20)]), - ]), - 'Exclusive' => ts('Show [tax term] exclusive price - i.e. %1', [ - 1 => ts('%1 + %2 [tax term]', [1 => CRM_Utils_Money::format(120), 2 => CRM_Utils_Money::format(20)]), - ]), - ], - ], + 'invoice_prefix' => $metadata['invoice_prefix'], + 'due_date' => $metadata['invoice_due_date'], + 'due_date_period' => $metadata['invoice_due_date_period'], + 'notes' => $metadata['invoice_notes'], + 'is_email_pdf' => $metadata['invoice_is_email_pdf'], + 'tax_term' => $metadata['tax_term'], + 'tax_display_settings' => $metadata['tax_display_settings'], ]; // @todo this is a faux metadata approach - we should be honest & add them correctly or find a way to make this @@ -131,7 +79,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { $this->addElement('select', $fieldName, $fieldValue['title'], - $fieldValue['option_values'], + $fieldValue['options'], CRM_Utils_Array::value('attributes', $fieldValue) ); break; diff --git a/settings/Contribute.setting.php b/settings/Contribute.setting.php index fca6aee40e..a03643f4e0 100644 --- a/settings/Contribute.setting.php +++ b/settings/Contribute.setting.php @@ -70,7 +70,7 @@ return [ 'add' => '5.23', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Invoice Prefix'), - 'description' => ts('Enter prefix to be be preprended when creating an invoice number'), + 'description' => ts('Enter prefix to be be pre-pended when creating an invoice number'), 'is_domain' => 1, 'is_contact' => 0, ], @@ -79,6 +79,7 @@ return [ 'name' => 'invoice_due_date', 'html_type' => 'text', 'title' => ts('Due Date'), + 'description' => '', 'add' => '5.23', 'type' => CRM_Utils_Type::T_INT, 'is_domain' => 1, @@ -133,6 +134,7 @@ return [ 'type' => CRM_Utils_Type::T_STRING, 'is_domain' => 1, 'is_contact' => 0, + 'description' => '', ], 'tax_display_settings' => [ 'default' => 'Inclusive', @@ -143,6 +145,7 @@ return [ 'title' => ts('Tax Display Settings'), 'is_domain' => 1, 'is_contact' => 0, + 'description' => '', 'pseudoconstant' => ['callback' => 'CRM_Core_SelectValues::taxDisplayOptions'], ], 'deferred_revenue_enabled' => [ -- 2.25.1