Example #1
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_PreferencesDate');
     $this->applyFilter('__ALL__', 'trim');
     $name =& $this->add('text', 'name', ts('Name'), $attributes['name'], true);
     $name->freeze();
     $this->add('text', 'description', ts('Description'), $attributes['description'], false);
     $this->add('text', 'start', ts('Start Offset'), $attributes['start'], true);
     $this->add('text', 'end', ts('End Offset'), $attributes['end'], true);
     $formatType = CRM_Core_Dao::getFieldValue('CRM_Core_DAO_PreferencesDate', $this->_id, 'name');
     if ($formatType == 'creditCard') {
         $this->add('text', 'date_format', ts('Format'), $attributes['date_format'], true);
     } else {
         $this->add('select', 'date_format', ts('Format'), array('' => ts('- default input format -')) + CRM_Core_SelectValues::getDatePluginInputFormats());
         $this->add('select', 'time_format', ts('Time'), array('' => ts('- none -')) + CRM_Core_SelectValues::getTimeFormats());
     }
     $this->addRule('start', ts('Value should be a positive number'), 'positiveInteger');
     $this->addRule('end', ts('Value should be a positive number'), 'positiveInteger');
     // add a form rule
     $this->addFormRule(array('CRM_Admin_Form_PreferencesDate', 'formRule'));
 }
Example #2
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Settings - Date'));
     $this->addElement('text', 'dateformatDatetime', ts('Complete Date and Time'));
     $this->addElement('text', 'dateformatFull', ts('Complete Date'));
     $this->addElement('text', 'dateformatPartial', ts('Month and Year'));
     $this->addElement('text', 'dateformatYear', ts('Year Only'));
     $this->addElement('text', 'dateformatTime', ts('Time Only'));
     $this->add('select', 'dateInputFormat', ts('Complete Date'), CRM_Core_SelectValues::getDatePluginInputFormats());
     $this->add('select', 'timeInputFormat', ts('Time'), CRM_Core_SelectValues::getTimeFormats());
     $this->add('date', 'fiscalYearStart', ts('Fiscal Year Start'), CRM_Core_SelectValues::date(null, 'M d'));
     parent::buildQuickForm();
 }
Example #3
0
 /**
  * Function to actually build the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_gid) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'title');
         CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Custom Fields'));
     }
     // lets trim all the whitespace
     $this->applyFilter('__ALL__', 'trim');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_CustomField');
     // label
     $this->add('text', 'label', ts('Field Label'), $attributes['label'], TRUE);
     $dt =& self::$_dataTypeValues;
     $it = array();
     foreach ($dt as $key => $value) {
         $it[$key] = self::$_dataToLabels[$key];
     }
     $sel =& $this->addElement('hierselect', 'data_type', ts('Data and Input Field Type'), 'onclick="clearSearchBoxes();custom_option_html_type(this.form)"; onBlur="custom_option_html_type(this.form)";', '   ');
     $sel->setOptions(array($dt, $it));
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $this->freeze('data_type');
     }
     $includeFieldIds = NULL;
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $includeFieldIds = $this->_values['id'];
     }
     $optionGroups = CRM_Core_BAO_CustomField::customOptionGroup($includeFieldIds);
     $emptyOptGroup = FALSE;
     if (empty($optionGroups)) {
         $emptyOptGroup = TRUE;
         $optionTypes = array('1' => ts('Create a new set of options'));
     } else {
         $optionTypes = array('1' => ts('Create a new set of options'), '2' => ts('Reuse an existing set'));
         $this->add('select', 'option_group_id', ts('Multiple Choice Option Sets'), array('' => ts('- select -')) + $optionGroups);
     }
     $element =& $this->addRadio('option_type', ts('Option Type'), $optionTypes, array('onclick' => "showOptionSelect();"), '<br/>');
     $contactGroups = CRM_Core_PseudoConstant::group();
     asort($contactGroups);
     $this->add('select', 'group_id', ts('Limit List to Group'), $contactGroups, FALSE, array('multiple' => 'multiple'));
     $this->add('text', 'filter', ts('Advanced Filter'), $attributes['filter']);
     $this->add('hidden', 'filter_selected', 'Group', array('id' => 'filter_selected'));
     //if empty option group freeze the option type.
     if ($emptyOptGroup) {
         $element->freeze();
     }
     // form fields of Custom Option rows
     $defaultOption = array();
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     for ($i = 1; $i <= self::NUM_OPTION; $i++) {
         //the show hide blocks
         $showBlocks = 'optionField_' . $i;
         if ($i > 2) {
             $_showHide->addHide($showBlocks);
             if ($i == self::NUM_OPTION) {
                 $_showHide->addHide('additionalOption');
             }
         } else {
             $_showHide->addShow($showBlocks);
         }
         $optionAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue');
         // label
         $this->add('text', 'option_label[' . $i . ']', ts('Label'), $optionAttributes['label']);
         // value
         $this->add('text', 'option_value[' . $i . ']', ts('Value'), $optionAttributes['value']);
         // weight
         $this->add('text', "option_weight[{$i}]", ts('Order'), $optionAttributes['weight']);
         // is active ?
         $this->add('checkbox', "option_status[{$i}]", ts('Active?'));
         $defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
         //for checkbox handling of default option
         $this->add('checkbox', "default_checkbox_option[{$i}]", NULL);
     }
     //default option selection
     $this->addGroup($defaultOption, 'default_option');
     $_showHide->addToTemplate();
     // text length for alpha numeric data types
     $this->add('text', 'text_length', ts('Database field length'), $attributes['text_length'], FALSE);
     $this->addRule('text_length', ts('Value should be a positive number'), 'integer');
     $this->add('text', 'start_date_years', ts('Dates may be up to'), $attributes['start_date_years'], FALSE);
     $this->add('text', 'end_date_years', ts('Dates may be up to'), $attributes['end_date_years'], FALSE);
     $this->addRule('start_date_years', ts('Value should be a positive number'), 'integer');
     $this->addRule('end_date_years', ts('Value should be a positive number'), 'integer');
     $this->add('select', 'date_format', ts('Date Format'), array('' => ts('- select -')) + CRM_Core_SelectValues::getDatePluginInputFormats());
     $this->add('select', 'time_format', ts('Time'), array('' => ts('- none -')) + CRM_Core_SelectValues::getTimeFormats());
     // for Note field
     $this->add('text', 'note_columns', ts('Width (columns)') . ' ', $attributes['note_columns'], FALSE);
     $this->add('text', 'note_rows', ts('Height (rows)') . ' ', $attributes['note_rows'], FALSE);
     $this->add('text', 'note_length', ts('Maximum length') . ' ', $attributes['text_length'], FALSE);
     $this->addRule('note_columns', ts('Value should be a positive number'), 'positiveInteger');
     $this->addRule('note_rows', ts('Value should be a positive number'), 'positiveInteger');
     $this->addRule('note_length', ts('Value should be a positive number'), 'positiveInteger');
     // weight
     $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     // is required ?
     $this->add('checkbox', 'is_required', ts('Required?'));
     // checkbox / radio options per line
     $this->add('text', 'options_per_line', ts('Options Per Line'));
     $this->addRule('options_per_line', ts('must be a numeric value'), 'numeric');
     // default value, help pre, help post, mask, attributes, javascript ?
     $this->add('text', 'default_value', ts('Default Value'), $attributes['default_value']);
     $this->add('textarea', 'help_pre', ts('Field Pre Help'), $attributes['help_pre']);
     $this->add('textarea', 'help_post', ts('Field Post Help'), $attributes['help_post']);
     $this->add('text', 'mask', ts('Mask'), $attributes['mask']);
     // is active ?
     $this->add('checkbox', 'is_active', ts('Active?'));
     // is active ?
     $this->add('checkbox', 'is_view', ts('View Only?'));
     // is searchable ?
     $this->addElement('checkbox', 'is_searchable', ts('Is this Field Searchable?'), NULL, array('onclick' => "showSearchRange(this)"));
     // is searchable by range?
     $searchRange = array();
     $searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1');
     $searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0');
     $this->addGroup($searchRange, 'is_search_range', ts('Search by Range?'));
     // add buttons
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     // add a form rule to check default value
     $this->addFormRule(array('CRM_Custom_Form_Field', 'formRule'), $this);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $url = CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid);
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='{$url}'"));
     }
 }