Ejemplo n.º 1
0
 /**
  * initialize label format settings.
  *
  * @param $format
  * @param $unit
  */
 public function LabelSetFormat(&$format, $unit)
 {
     $this->defaults = CRM_Core_BAO_LabelFormat::getDefaultValues();
     $this->format =& $format;
     $this->formatName = $this->getFormatValue('name');
     $this->paperSize = $this->getFormatValue('paper-size');
     $this->orientation = $this->getFormatValue('orientation');
     $this->fontName = $this->getFormatValue('font-name');
     $this->charSize = $this->getFormatValue('font-size');
     $this->fontStyle = $this->getFormatValue('font-style');
     $this->xNumber = $this->getFormatValue('NX');
     $this->yNumber = $this->getFormatValue('NY');
     $this->metricDoc = $unit;
     $this->marginLeft = $this->getFormatValue('lMargin', TRUE);
     $this->marginTop = $this->getFormatValue('tMargin', TRUE);
     $this->xSpace = $this->getFormatValue('SpaceX', TRUE);
     $this->ySpace = $this->getFormatValue('SpaceY', TRUE);
     $this->width = $this->getFormatValue('width', TRUE);
     $this->height = $this->getFormatValue('height', TRUE);
     $this->paddingLeft = $this->getFormatValue('lPadding', TRUE);
     $this->paddingTop = $this->getFormatValue('tPadding', TRUE);
     $paperSize = CRM_Core_BAO_PaperSize::getByName($this->paperSize);
     $w = CRM_Utils_PDF_Utils::convertMetric($paperSize['width'], $paperSize['metric'], $this->metricDoc);
     $h = CRM_Utils_PDF_Utils::convertMetric($paperSize['height'], $paperSize['metric'], $this->metricDoc);
     $this->paper_dimensions = array($w, $h);
 }
Ejemplo n.º 2
0
 /**
  * Retrieve DB object based on input parameters.
  *
  * It also stores all the retrieved values in the default array.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $values
  *   (reference ) an assoc array to hold the flattened values.
  *
  * @return CRM_Core_DAO_OptionValue
  */
 public static function retrieve(&$params, &$values)
 {
     $optionValue = new CRM_Core_DAO_OptionValue();
     $optionValue->copyValues($params);
     $optionValue->option_group_id = self::_getGid();
     if ($optionValue->find(TRUE)) {
         // Extract fields that have been serialized in the 'value' column of the Option Value table.
         $values = json_decode($optionValue->value, TRUE);
         // Add any new fields that don't yet exist in the saved values.
         foreach (self::$optionValueFields as $name => $field) {
             if (!isset($values[$name])) {
                 $values[$name] = $field['default'];
                 if (isset($field['metric']) && $field['metric']) {
                     $values[$name] = CRM_Utils_PDF_Utils::convertMetric($field['default'], self::$optionValueFields['metric']['default'], $values['metric'], 3);
                 }
             }
         }
         // Add fields from the OptionValue base class
         CRM_Core_DAO::storeValues($optionValue, $values);
         return $optionValue;
     }
     return NULL;
 }
Ejemplo n.º 3
0
 /**
  * @param $value
  * @param $metric
  * @return int
  */
 public static function toTwip($value, $metric)
 {
     $point = CRM_Utils_PDF_Utils::convertMetric($value, $metric, 'pt');
     return \PhpOffice\PhpWord\Shared\Converter::pointToTwip($point);
 }