コード例 #1
0
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     $config = CRM_Core_Config::singleton();
     $resources = CRM_Core_Resources::singleton();
     $resources->addSetting(array('kcfinderPath' => $config->userFrameworkResourceURL . 'packages' . DIRECTORY_SEPARATOR));
     $resources->addScriptFile('civicrm', 'templates/CRM/Badge/Form/Layout.js');
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'), true);
     $labelStyle = CRM_Core_BAO_LabelFormat::getList(TRUE, 'name_badge');
     $this->add('select', 'label_format_name', ts('Label Format'), array('' => ts('- select -')) + $labelStyle, TRUE);
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
     // get the tokens
     $contactTokens = CRM_Core_SelectValues::contactTokens();
     $eventTokens = array('{event.event_id}' => ts('Event ID'), '{event.title}' => ts('Event Title'), '{event.start_date}' => ts('Event Start Date'), '{event.end_date}' => ts('Event End Date'));
     $participantTokens = CRM_Core_SelectValues::participantTokens();
     $tokens = array_merge($contactTokens, $eventTokens, $participantTokens);
     asort($tokens);
     $tokens = array_merge(array('spacer' => ts('- spacer -')) + $tokens);
     $fontSizes = CRM_Core_BAO_LabelFormat::getFontSizes();
     $fontStyles = CRM_Core_BAO_LabelFormat::getFontStyles();
     $fontNames = CRM_Core_BAO_LabelFormat::getFontNames('name_badge');
     $textAlignment = CRM_Core_BAO_LabelFormat::getTextAlignments();
     $rowCount = self::FIELD_ROWCOUNT;
     for ($i = 1; $i <= $rowCount; $i++) {
         $this->add('select', "token[{$i}]", ts('Token'), array('' => ts('- skip -')) + $tokens);
         $this->add('select', "font_name[{$i}]", ts('Font Name'), $fontNames);
         $this->add('select', "font_size[{$i}]", ts('Font Size'), $fontSizes);
         $this->add('select', "font_style[{$i}]", ts('Font Style'), $fontStyles);
         $this->add('select', "text_alignment[{$i}]", ts('Alignment'), $textAlignment);
     }
     $rowCount++;
     $this->assign('rowCount', $rowCount);
     $barcodeTypes = CRM_Core_SelectValues::getBarcodeTypes();
     $this->add('checkbox', 'add_barcode', ts('Barcode?'));
     $this->add('select', "barcode_type", ts('Type'), $barcodeTypes);
     $this->add('select', "barcode_alignment", ts('Alignment'), $textAlignment);
     $attributes = array('readonly' => true);
     $this->add('text', 'image_1', ts('Image (top left)'), $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
     $this->add('text', 'width_image_1', ts('Width (mm)'), array('size' => 6));
     $this->add('text', 'height_image_1', ts('Height (mm)'), array('size' => 6));
     $this->add('text', 'image_2', ts('Image (top right)'), $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
     $this->add('text', 'width_image_2', ts('Width (mm)'), array('size' => 6));
     $this->add('text', 'height_image_2', ts('Height (mm)'), array('size' => 6));
     $this->add('checkbox', 'is_default', ts('Default?'));
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->add('checkbox', 'is_reserved', ts('Reserved?'));
     $this->addRule('width_image_1', ts('Enter valid width'), 'positiveInteger');
     $this->addRule('width_image_2', ts('Enter valid width'), 'positiveInteger');
     $this->addRule('height_image_1', ts('Enter valid height'), 'positiveInteger');
     $this->addRule('height_image_2', ts('Enter valid height'), 'positiveInteger');
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'refresh', 'name' => ts('Save and Preview')), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #2
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::COPY)) {
         $formatName = CRM_Core_BAO_LabelFormat::getFieldValue('CRM_Core_BAO_LabelFormat', $this->_id, 'label');
         $this->assign('formatName', $formatName);
         return;
     }
     $disabled = array();
     $required = TRUE;
     $is_reserved = $this->_id ? CRM_Core_BAO_LabelFormat::getFieldValue('CRM_Core_BAO_LabelFormat', $this->_id, 'is_reserved') : FALSE;
     if ($is_reserved) {
         $disabled['disabled'] = 'disabled';
         $required = FALSE;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat');
     $this->add('text', 'label', ts('Name'), $attributes['label'] + $disabled, $required);
     $this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE));
     $this->add('checkbox', 'is_default', ts('Is this Label Format the default?'));
     $this->add('select', 'paper_size', ts('Sheet Size'), array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, array('onChange' => "selectPaper( this.value );") + $disabled);
     $this->add('static', 'paper_dimensions', NULL, ts('Sheet Size (w x h)'));
     $this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_LabelFormat::getPageOrientations(), FALSE, array('onChange' => "updatePaperDimensions();") + $disabled);
     $this->add('select', 'font_name', ts('Font Name'), CRM_Core_BAO_LabelFormat::getFontNames());
     $this->add('select', 'font_size', ts('Font Size'), CRM_Core_BAO_LabelFormat::getFontSizes());
     $this->add('static', 'font_style', ts('Font Style'));
     $this->add('checkbox', 'bold', ts('Bold'));
     $this->add('checkbox', 'italic', ts('Italic'));
     $this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_LabelFormat::getUnits(), FALSE, array('onChange' => "selectMetric( this.value );"));
     $this->add('text', 'width', ts('Label Width'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
     $this->add('text', 'height', ts('Label Height'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
     $this->add('text', 'NX', ts('Labels Per Row'), array('size' => 3, 'maxlength' => 3) + $disabled, $required);
     $this->add('text', 'NY', ts('Labels Per Column'), array('size' => 3, 'maxlength' => 3) + $disabled, $required);
     $this->add('text', 'tMargin', ts('Top Margin'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
     $this->add('text', 'lMargin', ts('Left Margin'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
     $this->add('text', 'SpaceX', ts('Horizontal Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
     $this->add('text', 'SpaceY', ts('Vertical Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
     $this->add('text', 'lPadding', ts('Left Padding'), array('size' => 8, 'maxlength' => 8), $required);
     $this->add('text', 'tPadding', ts('Top Padding'), array('size' => 8, 'maxlength' => 8), $required);
     $this->add('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'weight'), TRUE);
     $this->addRule('label', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_BAO_LabelFormat', $this->_id));
     $this->addRule('NX', ts('Must be an integer'), 'integer');
     $this->addRule('NY', ts('Must be an integer'), 'integer');
     $this->addRule('tMargin', ts('Must be numeric'), 'numeric');
     $this->addRule('lMargin', ts('Must be numeric'), 'numeric');
     $this->addRule('SpaceX', ts('Must be numeric'), 'numeric');
     $this->addRule('SpaceY', ts('Must be numeric'), 'numeric');
     $this->addRule('lPadding', ts('Must be numeric'), 'numeric');
     $this->addRule('tPadding', ts('Must be numeric'), 'numeric');
     $this->addRule('width', ts('Must be numeric'), 'numeric');
     $this->addRule('height', ts('Must be numeric'), 'numeric');
     $this->addRule('weight', ts('Weight must be integer'), 'integer');
 }