4 * This class generates form components for the display preferences
7 class CRM_Admin_Form_Preferences_Contribute
extends CRM_Admin_Form_Preferences
{
9 * Process the form submission.
14 public function preProcess() {
15 $config = CRM_Core_Config
::singleton();
16 CRM_Utils_System
::setTitle(ts('CiviContribute Component Settings'));
17 $this->_varNames
= array(
18 CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
=> array(
19 'invoice_prefix' => array(
20 'html_type' => 'text',
21 'title' => ts('Invoice Prefix'),
23 'description' => ts('Enter prefix to be display on PDF for invoice'),
25 'credit_notes_prefix' => array(
26 'html_type' => 'text',
27 'title' => ts('Credit Notes Prefix'),
29 'description' => ts('Enter prefix to be display on PDF for credit notes.'),
32 'html_type' => 'text',
33 'title' => ts('Due Date'),
36 'due_date_period' => array(
37 'html_type' => 'select',
38 'title' => ts('For transmission'),
40 'description' => ts('Select the interval for due date.'),
41 'option_values' => array(
42 'select' => ts('- select -'),
44 'months' => ts('Months'),
45 'years' => ts('Years'),
49 'html_type' => 'wysiwyg',
50 'title' => ts('Notes or Standard Terms'),
52 'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '),
53 'attributes' => array('rows' => 2, 'cols' => 40),
55 'is_email_pdf' => array(
56 'html_type' => 'checkbox',
57 'title' => ts('Automatically email invoice when user purchases online'),
61 'html_type' => 'text',
62 'title' => ts('Tax Term'),
65 'tax_display_settings' => array(
66 'html_type' => 'select',
67 'title' => ts('Tax Display Settings'),
69 'option_values' => array(
70 'Do_not_show' => ts('Do not show breakdown, only show total -i.e ' .
71 $config->defaultCurrencySymbol
. '120.00'),
72 'Inclusive' => ts('Show [tax term] inclusive price - i.e. ' .
73 $config->defaultCurrencySymbol
.
74 '120.00 (includes [tax term] of ' .
75 $config->defaultCurrencySymbol
. '20.00)'),
76 'Exclusive' => ts('Show [tax term] exclusive price - i.e. ' .
77 $config->defaultCurrencySymbol
. '100.00 + ' .
78 $config->defaultCurrencySymbol
. '20.00 [tax term]'),
87 * Build the form object.
91 public function buildQuickForm() {
92 $this->add('checkbox', 'invoicing', ts('Enable Tax and Invoicing'));
93 parent
::buildQuickForm();
97 * Set default values for the form.
98 * default values are retrieved from the database
103 public function setDefaultValues() {
104 $defaults = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
109 * Process the form after the input has been submitted and validated.
114 public function postProcess() {
115 // store the submitted values in an array
116 $params = $this->controller
->exportValues($this->_name
);
117 unset($params['qfKey']);
118 unset($params['entryURL']);
119 $setInvoiceSettings = CRM_Core_BAO_Setting
::setItem($params, CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
121 // to set default value for 'Invoices / Credit Notes' checkbox on display preferences
122 $values = CRM_Core_BAO_Setting
::getItem("CiviCRM Preferences");
123 $optionValues = CRM_Core_OptionGroup
::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
124 $setKey = array_search('Invoices / Credit Notes', $optionValues);
126 if (isset($params['invoicing'])) {
127 $value = array($setKey => $optionValues[$setKey]);
128 $setInvoice = CRM_Core_DAO
::VALUE_SEPARATOR
.
129 implode(CRM_Core_DAO
::VALUE_SEPARATOR
, array_keys($value)) .
130 CRM_Core_DAO
::VALUE_SEPARATOR
;
131 CRM_Core_BAO_Setting
::setItem($values['user_dashboard_options'] .
132 $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options');
135 $setting = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, substr($values['user_dashboard_options'], 1, -1));
136 $invoiceKey = array_search($setKey, $setting);
137 unset($setting[$invoiceKey]);
138 $settingName = CRM_Core_DAO
::VALUE_SEPARATOR
.
139 implode(CRM_Core_DAO
::VALUE_SEPARATOR
, array_values($setting)) .
140 CRM_Core_DAO
::VALUE_SEPARATOR
;
141 CRM_Core_BAO_Setting
::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options');