NEW show links for select and multi-select in category extra field
This commit is contained in:
parent
1736ecfa26
commit
bf338b4d4f
@ -1621,6 +1621,13 @@ class ExtraFields
|
|||||||
$keyList .= implode(', ', $fields_label);
|
$keyList .= implode(', ', $fields_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter_categorie = false;
|
||||||
|
if (count($InfoFieldList) > 5) {
|
||||||
|
if ($InfoFieldList[0] == 'categorie') {
|
||||||
|
$filter_categorie = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT '.$keyList;
|
$sql = 'SELECT '.$keyList;
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
|
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
|
||||||
if (strpos($InfoFieldList[4], 'extra') !== false)
|
if (strpos($InfoFieldList[4], 'extra') !== false)
|
||||||
@ -1641,6 +1648,7 @@ class ExtraFields
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
if ($filter_categorie === false) {
|
||||||
$value = ''; // value was used, so now we reste it to use it to build final output
|
$value = ''; // value was used, so now we reste it to use it to build final output
|
||||||
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
@ -1648,10 +1656,8 @@ class ExtraFields
|
|||||||
// Several field into label (eq table:code|libelle:rowid)
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
|
|
||||||
if (is_array($fields_label) && count($fields_label) > 1)
|
if (is_array($fields_label) && count($fields_label) > 1) {
|
||||||
{
|
foreach ($fields_label as $field_toshow) {
|
||||||
foreach ($fields_label as $field_toshow)
|
|
||||||
{
|
|
||||||
$translabel = '';
|
$translabel = '';
|
||||||
if (!empty($obj->$field_toshow)) {
|
if (!empty($obj->$field_toshow)) {
|
||||||
$translabel = $langs->trans($obj->$field_toshow);
|
$translabel = $langs->trans($obj->$field_toshow);
|
||||||
@ -1673,6 +1679,19 @@ class ExtraFields
|
|||||||
$value = $obj->{$InfoFieldList[1]};
|
$value = $obj->{$InfoFieldList[1]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
|
||||||
|
$toprint = array();
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$c = new Categorie($this->db);
|
||||||
|
$c->fetch($obj->rowid);
|
||||||
|
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
|
||||||
|
foreach ($ways as $way) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
|
||||||
|
}
|
||||||
|
$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
||||||
|
}
|
||||||
} else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
} else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
||||||
} elseif ($type == 'radio')
|
} elseif ($type == 'radio')
|
||||||
{
|
{
|
||||||
@ -1710,6 +1729,13 @@ class ExtraFields
|
|||||||
$keyList .= implode(', ', $fields_label);
|
$keyList .= implode(', ', $fields_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter_categorie = false;
|
||||||
|
if (count($InfoFieldList) > 5) {
|
||||||
|
if ($InfoFieldList[0] == 'categorie') {
|
||||||
|
$filter_categorie = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT '.$keyList;
|
$sql = 'SELECT '.$keyList;
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
|
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
|
||||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||||
@ -1721,6 +1747,7 @@ class ExtraFields
|
|||||||
dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
|
dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
if ($filter_categorie === false) {
|
||||||
$value = ''; // value was used, so now we reste it to use it to build final output
|
$value = ''; // value was used, so now we reste it to use it to build final output
|
||||||
$toprint = array();
|
$toprint = array();
|
||||||
while ($obj = $this->db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
@ -1752,6 +1779,21 @@ class ExtraFields
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
|
||||||
|
$toprint = array();
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||||
|
$c = new Categorie($this->db);
|
||||||
|
$c->fetch($obj->rowid);
|
||||||
|
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
|
||||||
|
foreach ($ways as $way) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
||||||
} else {
|
} else {
|
||||||
dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user