Skip to content
Snippets Groups Projects
Commit fc11e61e authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #1152 from kurund/CRM-12965

CRM-12965
parents 8b4292a8 890a1fbb
No related branches found
No related tags found
No related merge requests found
...@@ -131,20 +131,23 @@ class CRM_Badge_BAO_Badge { ...@@ -131,20 +131,23 @@ class CRM_Badge_BAO_Badge {
} }
public function labelAvery5395(&$formattedRow) { public function labelAvery5395(&$formattedRow) {
$this->lMarginLogo = 20; $this->lMarginLogo = 18;
$this->tMarginName = 20; $this->tMarginName = 20;
$x = $this->pdf->GetAbsX(); $x = $this->pdf->GetAbsX();
$y = $this->pdf->GetY(); $y = $this->pdf->GetY();
$titleWidth = $titleLeftMargin = 0;
if (CRM_Utils_Array::value('image_1', $formattedRow)) { if (CRM_Utils_Array::value('image_1', $formattedRow)) {
$this->printImage($formattedRow['image_1']); $this->printImage($formattedRow['image_1']);
$titleWidth = $titleLeftMargin = $this->lMarginLogo;
} }
$titleWidth = $this->lMarginLogo; $titleRightMargin = 0;
if (CRM_Utils_Array::value('image_2', $formattedRow)) { if (CRM_Utils_Array::value('image_2', $formattedRow)) {
$this->printImage($formattedRow['image_2'], $x + 68); $this->printImage($formattedRow['image_2'], $x + 68);
$titleWidth = 38; $titleRightMargin = 36;
$titleWidth = $this->lMarginLogo;
} }
$this->pdf->SetLineStyle(array( $this->pdf->SetLineStyle(array(
...@@ -155,9 +158,13 @@ class CRM_Badge_BAO_Badge { ...@@ -155,9 +158,13 @@ class CRM_Badge_BAO_Badge {
'color' => array(0, 0, 200) 'color' => array(0, 0, 200)
)); ));
if ($titleLeftMargin && $titleRightMargin) {
$titleWidth = $titleRightMargin;
}
$this->pdf->SetFont($formattedRow['token'][1]['font_name'], '', $formattedRow['token'][1]['font_size']); $this->pdf->SetFont($formattedRow['token'][1]['font_name'], '', $formattedRow['token'][1]['font_size']);
$this->pdf->MultiCell($this->pdf->width - $titleWidth, 0, $formattedRow['token'][1]['value'], $this->pdf->MultiCell($this->pdf->width - $titleWidth, 0, $formattedRow['token'][1]['value'],
$this->border, $formattedRow['token'][1]['text_alignment'], 0, 1, $x + $this->lMarginLogo, $y); $this->border, $formattedRow['token'][1]['text_alignment'], 0, 1, $x + $titleLeftMargin, $y);
$this->pdf->SetFont($formattedRow['token'][2]['font_name'], '', $formattedRow['token'][2]['font_size']); $this->pdf->SetFont($formattedRow['token'][2]['font_name'], '', $formattedRow['token'][2]['font_size']);
$this->pdf->MultiCell($this->pdf->width, 10, $formattedRow['token'][2]['value'], $this->pdf->MultiCell($this->pdf->width, 10, $formattedRow['token'][2]['value'],
......
...@@ -106,6 +106,34 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form { ...@@ -106,6 +106,34 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
$this->add('checkbox', 'is_default', ts('Default?')); $this->add('checkbox', 'is_default', ts('Default?'));
$this->add('checkbox', 'is_active', ts('Enabled?')); $this->add('checkbox', 'is_active', ts('Enabled?'));
$this->add('checkbox', 'is_reserved', ts('Reserved?')); $this->add('checkbox', 'is_reserved', ts('Reserved?'));
$this->addFormRule(array('CRM_Badge_Form_Layout', 'formRule'));
}
/**
* form rule
*
* @param array $fields the input form values
*
* @return true if no errors, else array of errors
* @access public
* @static
*/
static function formRule($fields) {
$errors = array();
if (CRM_Utils_Array::value(4, $fields['token'])
&& CRM_Utils_Array::value('add_barcode', $fields)
&& (CRM_Utils_Array::value('barcode_alignment', $fields) == CRM_Utils_Array::value(4, $fields['text_alignment']))
) {
$errors['barcode_alignment'] = ts('You cannot have same alignment for barcode and #4 row.');
}
if (!empty($errors)) {
return $errors;
}
return empty($errors) ? TRUE : $errors;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment