From e0d683cf0311d086cb2a2f22cbad28653a4c3a47 Mon Sep 17 00:00:00 2001 From: Parag Bhilkar Date: Tue, 5 Aug 2014 18:05:04 +0530 Subject: [PATCH] VAT-638 Checked and unchecked the Invoice/Credit Notes option when switch on invoicing and added help text for it. Remove email/print option from search contribution when invoicing is off. --- CRM/Admin/Form/Preferences/Contribute.php | 21 +++++ CRM/Admin/Form/Preferences/Display.php | 7 ++ CRM/Contribute/Task.php | 6 ++ .../CRM/Admin/Form/Preferences/Display.hlp | 82 ++++++++++--------- .../CRM/Admin/Form/Preferences/Display.tpl | 10 ++- 5 files changed, 88 insertions(+), 38 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index af3d257d7d..3b829fd4f3 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -82,6 +82,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { 'Exclusive' => ts('Show [tax term] exclusive price - i.e. '.$config->defaultCurrencySymbol.'100.00 + '.$config->defaultCurrencySymbol.'20.00 [tax term]') ) ); + $this->add('checkbox', 'invoicing', ts('Enable Tax and Invoicing')); parent::buildQuickForm(); } @@ -109,6 +110,26 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { // 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'); + + // to set default value for 'Invoices / Credit Notes' checkbox on display preferences + $values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences"); + $optionValues = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName("user_dashboard_options"); + $setKey = array_search('Invoices / Credit Notes', $optionValues); + + if (isset($params['invoicing'])) { + $value = array($setKey => $optionValues[$setKey]); + $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, + array_keys($value)) . CRM_Core_DAO::VALUE_SEPARATOR; + CRM_Core_BAO_Setting::setItem($values['user_dashboard_options'].$setInvoice, 'CiviCRM Preferences', 'user_dashboard_options'); + } + else { + $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1)); + $invoiceKey = array_search ($setKey, $setting); + unset($setting[$invoiceKey]); + $settingName = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, + array_values($setting)) . CRM_Core_DAO::VALUE_SEPARATOR; + CRM_Core_BAO_Setting::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options'); + } } } diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 8b26ac2595..871e91b6ca 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -148,6 +148,10 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { public function buildQuickForm() { $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup::values('wysiwyg_editor'); + //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck + $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); + $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $this->assign('invoicing', $invoicing); $config = CRM_Core_Config::singleton(); $extra = array(); @@ -193,6 +197,9 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences')); + $optionValues = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName("user_dashboard_options"); + $invoicesKey = array_search('Invoices / Credit Notes', $optionValues); + $this->assign('invoicesKey', $invoicesKey); parent::buildQuickForm(); } diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php index b2a2f62f7e..b0e45c5316 100644 --- a/CRM/Contribute/Task.php +++ b/CRM/Contribute/Task.php @@ -126,6 +126,12 @@ class CRM_Contribute_Task { unset(self::$_tasks[1]); } + // remove action "Print or Email Contribution Invoices" + $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); + $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + if (!$invoicing) { + unset(self::$_tasks[9]); + } CRM_Utils_Hook::searchTasks('contribution', self::$_tasks); asort(self::$_tasks); } diff --git a/templates/CRM/Admin/Form/Preferences/Display.hlp b/templates/CRM/Admin/Form/Preferences/Display.hlp index e20a955b96..49da061251 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.hlp +++ b/templates/CRM/Admin/Form/Preferences/Display.hlp @@ -1,37 +1,45 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.4 | - +--------------------------------------------------------------------+ - | 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 | - +--------------------------------------------------------------------+ -*} -{htxt id="id-editor_id-title"} - {ts}WYSIWYG Editor{/ts} -{/htxt} -{htxt id="id-editor_id"} -

{ts}Select the HTML WYSIWYG Editor provided for fields that allow HTML formatting. Select 'Textarea' if you don't want to provide a WYSIWYG Editor (users will type text and / or HTML code into plain text fields).{/ts}

-

{ts}Spell-checking: ckEditor includes a Spell-check button by default. There is also an optional plugin which does spell-checking automatically (as you type). However, this plugin is not enabled by default since it sends user input to a 3rd party service (spellchecker.net) without informing the user - and this may pose privacy issues for some sites.{/ts} -

{ts}To enable auto spell check, in packages/ckeditor/config.js - change this value to true:{/ts}
-config.scayt_autoStartup = false; -

{ts}To remove the Spell Check button, in packages/ckeditor/config.js - remove this item in the config.toolbar_Full list:{/ts}
-'SpellChecker' -

{ts}NOTE: If you are modifying config.js you should first have configured a Custom PHP Path under Administer > System Settings > Directories, and place your modified version in the custom path.{/ts}

-{/htxt} +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.4 | + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*} +{htxt id="id-editor_id-title"} + {ts}WYSIWYG Editor{/ts} +{/htxt} +{htxt id="id-editor_id"} +

{ts}Select the HTML WYSIWYG Editor provided for fields that allow HTML formatting. Select 'Textarea' if you don't want to provide a WYSIWYG Editor (users will type text and / or HTML code into plain text fields).{/ts}

+

{ts}Spell-checking: ckEditor includes a Spell-check button by default. There is also an optional plugin which does spell-checking automatically (as you type). However, this plugin is not enabled by default since it sends user input to a 3rd party service (spellchecker.net) without informing the user - and this may pose privacy issues for some sites.{/ts} +

{ts}To enable auto spell check, in packages/ckeditor/config.js - change this value to true:{/ts}
+config.scayt_autoStartup = false; +

{ts}To remove the Spell Check button, in packages/ckeditor/config.js - remove this item in the config.toolbar_Full list:{/ts}
+'SpellChecker' +

{ts}NOTE: If you are modifying config.js you should first have configured a Custom PHP Path under Administer > System Settings > Directories, and place your modified version in the custom path.{/ts}

+{/htxt} + +{htxt id="id-invoices_id-title"} + {ts}Invoices / Credit Notes{/ts} +{/htxt} +{htxt id="id-invoices_id"} +{capture assign=invoiceURL}{crmURL p='civicrm/admin/setting/preferences/contribute' q="reset=1"}{/capture} +{ts 1=$invoiceURL}In order to enable logged in users to download invoices and credit notes from the dashboard. Please first enable CiviCRM invoicing functionality Administer > CiviContribute > CiviContribute Component Settings{/ts} +{/htxt} diff --git a/templates/CRM/Admin/Form/Preferences/Display.tpl b/templates/CRM/Admin/Form/Preferences/Display.tpl index faf3b1c383..a73dd34579 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.tpl +++ b/templates/CRM/Admin/Form/Preferences/Display.tpl @@ -154,7 +154,7 @@ {$form.user_dashboard_options.label} - {$form.user_dashboard_options.html} + {$form.user_dashboard_options.html} {help id="id-invoices_id"}   @@ -258,6 +258,14 @@ } cj('#contact_edit_preferences').val(params.toString()); } + cj(document).ready(function() { + var invoicesKey = '{/literal}{$invoicesKey}{literal}'; + var invoicing = '{/literal}{$invoicing}{literal}'; + if (!invoicing) { + cj('#user_dashboard_options_'+invoicesKey).attr("disabled", true); + } + cj("#invoice_help").insertAfter("label[for='user_dashboard_options_"+invoicesKey+"']"); + }); {/literal} {/if} -- 2.25.1