- $htmlFields = array();
- foreach ($this->_settings as $setting => $group) {
- // @todo - remove this whole loop! The parent form does this - it's just because of the werid handling
- // of $htmlFields for this form that needs to be unwound that we have it atm.
- // The 'basicform' has been contaminated with processing $htlFields
- // to cater to this form - probably due to the way invoicing settings were handled as
- // an array not a bunch of keys.
- $settingMetaData = civicrm_api3('setting', 'getfields', array('name' => $setting));
- $props = $settingMetaData['values'][$setting];
- if (isset($props['quick_form_type'])) {
- $add = 'add' . $props['quick_form_type'];
- if ($add == 'addElement') {
- if (in_array($props['html_type'], array('checkbox', 'textarea'))) {
- }
- else {
- if ($props['html_type'] == 'select') {
- $functionName = CRM_Utils_Array::value('name', CRM_Utils_Array::value('pseudoconstant', $props));
- if ($functionName) {
- $props['option_values'] = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::$functionName();
- }
- }
- }
- }
+ parent::buildQuickForm();
+ $config = CRM_Core_Config::singleton();
+ $this->invoiceSettings = [
+ 'invoice_prefix' => [
+ 'html_type' => 'text',
+ 'title' => ts('Invoice Prefix'),
+ 'weight' => 1,
+ 'description' => ts('Enter prefix to be display on PDF for invoice'),
+ ],
+ 'credit_notes_prefix' => [
+ 'html_type' => 'text',
+ 'title' => ts('Credit Notes Prefix'),
+ 'weight' => 2,
+ 'description' => ts('Enter prefix to be display on PDF for credit notes.'),
+ ],
+ 'due_date' => [
+ 'html_type' => 'text',
+ 'title' => ts('Due Date'),
+ 'weight' => 3,
+ ],
+ 'due_date_period' => [
+ 'html_type' => 'select',
+ 'title' => ts('For transmission'),
+ 'weight' => 4,
+ 'description' => ts('Select the interval for due date.'),
+ 'option_values' => [
+ 'select' => ts('- select -'),
+ 'days' => ts('Days'),
+ 'months' => ts('Months'),
+ 'years' => ts('Years'),
+ ],
+ ],
+ 'notes' => [
+ 'html_type' => 'wysiwyg',
+ 'title' => ts('Notes or Standard Terms'),
+ 'weight' => 5,
+ 'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '),
+ 'attributes' => ['rows' => 2, 'cols' => 40],
+ ],
+ 'is_email_pdf' => [
+ 'html_type' => 'checkbox',
+ 'title' => ts('Automatically email invoice when user purchases online'),
+ 'weight' => 6,
+ 'description' => ts('Should a pdf invoice be emailed automatically?'),
+ ],
+ 'tax_term' => [
+ 'html_type' => 'text',
+ 'title' => ts('Tax Term'),
+ 'weight' => 7,
+ ],
+ 'tax_display_settings' => [
+ 'html_type' => 'select',
+ 'title' => ts('Tax Display Settings'),
+ 'weight' => 8,
+ 'option_values' => [
+ 'Do_not_show' => ts('Do not show breakdown, 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]'),
+ ],
+ ],
+ ];
+
+ // @todo this is a faux metadata approach - we should be honest & add them correctly or find a way to make this
+ // compatible with our settings standards.
+ foreach ($this->invoiceSettings as $fieldName => $fieldValue) {
+ switch ($fieldValue['html_type']) {
+ case 'text':
+ $this->addElement('text',
+ $fieldName,
+ $fieldValue['title'],
+ [
+ 'maxlength' => 64,
+ 'size' => 32,
+ ]
+ );
+ break;
+
+ case 'checkbox':
+ $this->add($fieldValue['html_type'],
+ $fieldName,
+ $fieldValue['title']
+ );
+ break;
+
+ case 'select':
+ $this->addElement('select',
+ $fieldName,
+ $fieldValue['title'],
+ $fieldValue['option_values'],
+ CRM_Utils_Array::value('attributes', $fieldValue)
+ );
+ break;
+
+ case 'wysiwyg':
+ $this->add('wysiwyg', $fieldName, $fieldValue['title'], $fieldValue['attributes']);
+ break;