3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
37 * This class generates form components for the display preferences
40 class CRM_Admin_Form_Preferences_Contribute
extends CRM_Admin_Form_Preferences
{
42 * Process the form submission.
47 public function preProcess() {
48 $config = CRM_Core_Config
::singleton();
49 CRM_Utils_System
::setTitle(ts('CiviContribute Component Settings'));
50 $this->_varNames
= array(
51 CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
=> array(
52 'invoice_prefix' => array(
53 'html_type' => 'text',
54 'title' => ts('Invoice Prefix'),
56 'description' => ts('Enter prefix to be display on PDF for invoice'),
58 'credit_notes_prefix' => array(
59 'html_type' => 'text',
60 'title' => ts('Credit Notes Prefix'),
62 'description' => ts('Enter prefix to be display on PDF for credit notes.'),
65 'html_type' => 'text',
66 'title' => ts('Due Date'),
69 'due_date_period' => array(
70 'html_type' => 'select',
71 'title' => ts('For transmission'),
73 'description' => ts('Select the interval for due date.'),
74 'option_values' => array(
75 'select' => ts('- select -'),
77 'months' => ts('Months'),
78 'years' => ts('Years'),
82 'html_type' => 'wysiwyg',
83 'title' => ts('Notes or Standard Terms'),
85 'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '),
86 'attributes' => array('rows' => 2, 'cols' => 40),
88 'is_email_pdf' => array(
89 'html_type' => 'checkbox',
90 'title' => ts('Automatically email invoice when user purchases online'),
94 'html_type' => 'text',
95 'title' => ts('Tax Term'),
98 'tax_display_settings' => array(
99 'html_type' => 'select',
100 'title' => ts('Tax Display Settings'),
102 'option_values' => array(
103 'Do_not_show' => ts('Do not show breakdown, only show total -i.e ' .
104 $config->defaultCurrencySymbol
. '120.00'),
105 'Inclusive' => ts('Show [tax term] inclusive price - i.e. ' .
106 $config->defaultCurrencySymbol
.
107 '120.00 (includes [tax term] of ' .
108 $config->defaultCurrencySymbol
. '20.00)'),
109 'Exclusive' => ts('Show [tax term] exclusive price - i.e. ' .
110 $config->defaultCurrencySymbol
. '100.00 + ' .
111 $config->defaultCurrencySymbol
. '20.00 [tax term]'),
116 parent
::preProcess();
120 * Build the form object.
124 public function buildQuickForm() {
125 $this->add('checkbox', 'invoicing', ts('Enable Tax and Invoicing'));
126 parent
::buildQuickForm();
130 * Set default values for the form.
131 * default values are retrieved from the database
136 public function setDefaultValues() {
137 $defaults = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
142 * Process the form after the input has been submitted and validated.
147 public function postProcess() {
148 // store the submitted values in an array
149 $params = $this->controller
->exportValues($this->_name
);
150 unset($params['qfKey']);
151 unset($params['entryURL']);
152 $setInvoiceSettings = CRM_Core_BAO_Setting
::setItem($params, CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
154 // to set default value for 'Invoices / Credit Notes' checkbox on display preferences
155 $values = CRM_Core_BAO_Setting
::getItem("CiviCRM Preferences");
156 $optionValues = CRM_Core_OptionGroup
::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
157 $setKey = array_search('Invoices / Credit Notes', $optionValues);
159 if (isset($params['invoicing'])) {
160 $value = array($setKey => $optionValues[$setKey]);
161 $setInvoice = CRM_Core_DAO
::VALUE_SEPARATOR
.
162 implode(CRM_Core_DAO
::VALUE_SEPARATOR
, array_keys($value)) .
163 CRM_Core_DAO
::VALUE_SEPARATOR
;
164 CRM_Core_BAO_Setting
::setItem($values['user_dashboard_options'] .
165 $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options');
168 $setting = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, substr($values['user_dashboard_options'], 1, -1));
169 $invoiceKey = array_search($setKey, $setting);
170 unset($setting[$invoiceKey]);
171 $settingName = CRM_Core_DAO
::VALUE_SEPARATOR
.
172 implode(CRM_Core_DAO
::VALUE_SEPARATOR
, array_values($setting)) .
173 CRM_Core_DAO
::VALUE_SEPARATOR
;
174 CRM_Core_BAO_Setting
::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options');