From 9d4da08248bd2e2d44096a4c7fe2a1d6a5c15c1d Mon Sep 17 00:00:00 2001 From: Rohan Katkar Date: Thu, 22 May 2014 13:16:58 +0530 Subject: [PATCH] VAT-389 Added form for CiviContribute Component Settings --- CRM/Admin/Form/Preferences/Contribute.php | 77 +++++++++++++++++++ CRM/Contribute/BAO/Contribution.php | 15 ++++ CRM/Contribute/xml/Menu/Contribute.xml | 8 ++ .../CRM/Admin/Form/Preferences/Contribute.tpl | 26 +++++++ xml/templates/civicrm_navigation.tpl | 3 +- 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 CRM/Admin/Form/Preferences/Contribute.php create mode 100644 templates/CRM/Admin/Form/Preferences/Contribute.tpl diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php new file mode 100644 index 0000000000..f864de400b --- /dev/null +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -0,0 +1,77 @@ +_varNames = array( + CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME => + array( + 'invoice_prefix' => array( + 'html_type' => 'text', + 'title' => ts('Invoice Prefix'), + 'weight' => 1, + 'description' => ts('Enter prefix to be display on PDF for invoice'), + ), + 'credit_notes_prefix' => array( + 'html_type' => 'text', + 'title' => ts('Credit Notes Prefix'), + 'weight' => 2, + 'description' => ts('Enter prefix to be display on PDF for credit notes.'), + ), + 'due_date' => array( + 'html_type' => 'text', + 'title' => ts('Due Date'), + 'weight' => 3, + ), + 'due_date_period' => array( + 'html_type' => 'select', + 'weight' => 4, + 'description' => ts('Select the interval for due date.'), + ), + 'tax_display_settings'=> array( + 'html_type' => 'select', + 'weight' => 6, + ), + 'notes' => array( + 'html_type' => 'textarea', + 'title' => ts('Notes or Standard Terms'), + 'weight' => 5, + 'description' => ts('Enter note or message to be display on PDF invoice or credit notes '), + ), + ), + ); + parent::preProcess(); + } + + /** + * Function to build the form + * + * @return void + * @access public + */ + function buildQuickForm() { + $this->add('select', 'due_date_period', ts('For transmission'), + array( + 'select' => ts('- select -'), + 'days' => ts('Days'), + 'months' => ts('months'), + 'years' => ts('years') + ) + ); + $this->add('select','tax_display_settings', ts('Tax Display Settings'), + array( + 'Do_not_show' => ts('Do not show brakedown, only show total -i.e $120.00'), + 'Inclusive' => ts('Show VAT inclusive price - i.e. $120.00(include TAX LABLE -$20)'), + 'Exclusive' => ts('Show VAT exclusive price - i.e. $100 + TAX LABLE -$20)') + ) + ); + parent::buildQuickForm(); + } +} + + + diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index e92faa48a4..715ea11aba 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3368,4 +3368,19 @@ WHERE con.id = {$contributionId} } return $info; } + + /** + * Function to retreive the admin page data for contribution + * + */ + static function getContributionSettings() { + $fields = array('invoice_prefix','due_date','due_date_period','notes','credit_notes_prefix','tax_display_settings'); + foreach ($fields as $values) { + $fieldName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Setting',$values, 'value','name'); + if (preg_match('/"([^"]+)"/', $fieldName, $fieldData)) { + $fieldValue[$values] = $fieldData[1]; + } + } + return $fieldValue; + } } diff --git a/CRM/Contribute/xml/Menu/Contribute.xml b/CRM/Contribute/xml/Menu/Contribute.xml index 5710711e3e..eb4550badc 100644 --- a/CRM/Contribute/xml/Menu/Contribute.xml +++ b/CRM/Contribute/xml/Menu/Contribute.xml @@ -292,4 +292,12 @@ 1 CiviContribute + + civicrm/admin/setting/preferences/contribute + CiviContribute Component Settings + CRM_Admin_Form_Preferences_Contribute + Configure global CiviContribute behaviors. + access CiviContribute,administer CiviCRM + CiviContribute + diff --git a/templates/CRM/Admin/Form/Preferences/Contribute.tpl b/templates/CRM/Admin/Form/Preferences/Contribute.tpl new file mode 100644 index 0000000000..a6f85d8e90 --- /dev/null +++ b/templates/CRM/Admin/Form/Preferences/Contribute.tpl @@ -0,0 +1,26 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.5 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2013 | + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*} +{include file="CRM/Form/basicForm.tpl"} diff --git a/xml/templates/civicrm_navigation.tpl b/xml/templates/civicrm_navigation.tpl index 7e66f62437..03cd5e9943 100644 --- a/xml/templates/civicrm_navigation.tpl +++ b/xml/templates/civicrm_navigation.tpl @@ -515,7 +515,8 @@ VALUES ( @domainID, 'civicrm/admin/options/soft_credit_type?reset=1', '{ts escape="sql" skip="true"}Soft Credit Types{/ts}', 'Soft Credit Types', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', 1, 14 ), ( @domainID, 'civicrm/admin/price?reset=1&action=add', '{ts escape="sql" skip="true"}New Price Set{/ts}', 'New Price Set', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 15 ), ( @domainID, 'civicrm/admin/price?reset=1', '{ts escape="sql" skip="true"}Manage Price Sets{/ts}', 'Manage Price Sets', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 16 ), - ( @domainID, 'civicrm/admin/paymentProcessor?reset=1', '{ts escape="sql" skip="true"}Payment Processors{/ts}', 'Payment Processors', 'administer CiviCRM', '', @adminContributelastID, '1', NULL, 17 ); + ( @domainID, 'civicrm/admin/paymentProcessor?reset=1', '{ts escape="sql" skip="true"}Payment Processors{/ts}', 'Payment Processors', 'administer CiviCRM', '', @adminContributelastID, '1', NULL, 17 ), + ( @domainID, 'civicrm/admin/setting/preferences/contribute', '{ts escape="sql" skip="true"}CiviContribute Component Settings{/ts}', 'CiviContribute Component Settings', 'administer CiviCRM', '', @adminContributelastID, '1', NULL, 18 ) ; INSERT INTO civicrm_navigation ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight ) -- 2.25.1