Permalink
Browse files

Fix #345 better

  • Loading branch information...
tbar0970
tbar0970 committed Dec 7, 2017
1 parent 422e5ae commit bae04063b170769f3e8460095e2b52c027d3d370
Showing with 9 additions and 5 deletions.
  1. +6 −4 db_objects/custom_field.class.php
  2. +3 −1 db_objects/person_query.class.php
@@ -182,7 +182,7 @@ public function getInstancesQueryComps($params, $logic, $order)
{
$res = parent::getInstancesQueryComps($params, $logic, $order);
$res['from'] .= ' LEFT JOIN custom_field_option cfo ON cfo.fieldid = custom_field.id';
$res['select'][] = 'GROUP_CONCAT(CONCAT(cfo.id, "__:__", cfo.value) ORDER BY cfo.rank DESC SEPARATOR ";;;") as options';
$res['select'][] = 'GROUP_CONCAT(CONCAT(cfo.id, "__:__", cfo.value) ORDER BY cfo.rank ASC SEPARATOR ";;;") as options';
$res['select'][] = 'GROUP_CONCAT(CONCAT(cfo.id, "__:__", cfo.value) ORDER BY cfo.rank DESC SEPARATOR ";;;") as reverseoptions';
$res['select'][] = 'params';
$res['group_by'] = 'custom_field.id';
@@ -206,9 +206,10 @@ public function getInstancesData($params, $logic='OR', $order='')
$res[$k]['options'] = NULL;
$options = array_get($v, 'options', '');
if (strlen($options)) {
if ($options == strrev($v['reverseoptions'])) {
bam($options);
foreach (explode(';;;', substr($options, 0, -4)) as $pair) {
$pairs = explode(';;;', $options);
$revPairs = explode(';;;', $v['reverseoptions']);
if (reset($pairs) == end($revPairs)) {
foreach ($pairs as $pair) {
list($id, $val) = explode('__:__', $pair);
$opts[$id] = $val;
}
@@ -219,6 +220,7 @@ public function getInstancesData($params, $logic='OR', $order='')
}
}
}
unset($res[$k]['reverseoptions']);
$res[$k]['params'] = unserialize($v['params']);
}
return $res;
@@ -196,7 +196,9 @@ function printForm($prefix='', $fields=NULL)
<?php
if (empty($params['custom_fields'])) $params['custom_fields'] = Array();
$dummyField = new Custom_Field();
foreach ($this->_custom_fields as $fieldid => $fieldDetails) {
$dummyField->populate($fieldid, $fieldDetails);
?>
<tr>
<td>
@@ -284,7 +286,7 @@ class="select-rule-toggle"
print_widget('params_custom_field_'.$fieldid.'_criteria', $cparams, array_get($value, 'criteria'));
$vparams = Array(
'type' => 'select',
'options' => $fieldDetails['options'],
'options' => $dummyField->getOptions(),
'allow_multiple' => true,
'attrs' => Array(
'data-select-rule-type' => 'contains'

0 comments on commit bae0406

Please sign in to comment.