From 1be9403de3d33a830f3a788c3e66a68b38181d6b Mon Sep 17 00:00:00 2001 From: dpradeep Date: Tue, 1 Jul 2014 16:39:27 +0530 Subject: [PATCH] VAT-389 Resubmit the changes with some modifications. --- CRM/Admin/Form/Preferences/Contribute.php | 59 +++++++++++++++---- CRM/Contribute/BAO/Contribution.php | 15 ----- .../Incremental/sql/4.5.alpha1.mysql.tpl | 16 ++++- 3 files changed, 64 insertions(+), 26 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index f864de400b..af3d257d7d 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -5,6 +5,13 @@ * */ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { + /** + * Function to process the form + * + * @access public + * + * @return void + */ function preProcess() { CRM_Utils_System::setTitle(ts('CiviContribute Component Settings')); $this->_varNames = array( @@ -31,17 +38,22 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { '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 '), ), + 'tax_term' => array( + 'html_type' => 'text', + 'title' => ts('Tax Term'), + 'weight' => 6, + ), + 'tax_display_settings'=> array( + 'html_type' => 'select', + 'weight' => 7, + ), ), ); parent::preProcess(); @@ -54,23 +66,50 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { * @access public */ function buildQuickForm() { + $config = CRM_Core_Config::singleton(); $this->add('select', 'due_date_period', ts('For transmission'), array( 'select' => ts('- select -'), 'days' => ts('Days'), - 'months' => ts('months'), - 'years' => ts('years') + '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)') + 'Do_not_show' => ts('Do not show brakedown, only show total -i.e '.$config->defaultCurrencySymbol.'120.00'), + 'Inclusive' => ts('Show [tax term] inclusive price - i.e. '.$config->defaultCurrencySymbol.'120.00 (includes [tax term] of '.$config->defaultCurrencySymbol.'20.00)'), + 'Exclusive' => ts('Show [tax term] exclusive price - i.e. '.$config->defaultCurrencySymbol.'100.00 + '.$config->defaultCurrencySymbol.'20.00 [tax term]') ) ); parent::buildQuickForm(); } + + /** + * This function sets the default values for the form. + * default values are retrieved from the database + * + * @access public + * + * @return void + */ + function setDefaultValues() { + $defaults = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); + return $defaults; + } + + /** + * process the form after the input has been submitted and validated + * + * @access public + * + * @return void + */ + public function postProcess() { + // store the submitted values in an array + $params = $this->controller->exportValues($this->_name); + $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($params, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); + } } diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index cd66e95c2f..ea59e9dd70 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3389,19 +3389,4 @@ 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/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl index 45fb73dba2..1db293c456 100644 --- a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl @@ -530,4 +530,18 @@ VALUES -- Add new column tax_amount in contribution and lineitem table ALTER TABLE `civicrm_contribution` ADD `tax_amount` DECIMAL( 20, 2 ) DEFAULT NULL COMMENT 'Total tax amount of this contribution.'; -ALTER TABLE `civicrm_line_item` ADD `tax_amount` DECIMAL( 20, 2 ) DEFAULT NULL COMMENT 'tax of each item'; \ No newline at end of file +ALTER TABLE `civicrm_line_item` ADD `tax_amount` DECIMAL( 20, 2 ) DEFAULT NULL COMMENT 'tax of each item'; + +-- Insert menu item at Administer > CiviContribute, below the Payment Processors. +SELECT @parent_id := id from `civicrm_navigation` where name = 'CiviContribute' AND domain_id = {$domainID}; +SELECT @add_weight_id := weight from `civicrm_navigation` where `name` = 'Payment Processors' and `parent_id` = @parent_id; + +UPDATE `civicrm_navigation` +SET `weight` = `weight`+1 +WHERE `parent_id` = @parent_id +AND `weight` > @add_weight_id; + +INSERT INTO `civicrm_navigation` + ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight ) +VALUES + ( {$domainID}, 'civicrm/admin/setting/preferences/contribute', '{ts escape="sql" skip="true"}CiviContribute Component Settings{/ts}', 'CiviContribute Component Settings', 'administer CiviCRM', '', @parent_id, '1', NULL, @add_weight_id + 1 ); \ No newline at end of file -- 2.25.1