Debug v16

This commit is contained in:
Laurent Destailleur 2022-06-04 02:08:08 +02:00
parent 0f7b84cfae
commit fc0f624445
4 changed files with 28 additions and 20 deletions

View File

@ -817,7 +817,8 @@ class ExtraFields
$array_name_label = array(); $array_name_label = array();
// We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode // We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode
$sql = "SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help"; $sql = "SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
$sql .= " css, cssview, csslist";
$sql .= " FROM ".$this->db->prefix()."extrafields"; $sql .= " FROM ".$this->db->prefix()."extrafields";
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
if ($elementtype) { if ($elementtype) {
@ -866,6 +867,9 @@ class ExtraFields
$this->attributes[$tab->elementtype]['entityid'][$tab->name] = $tab->entity; $this->attributes[$tab->elementtype]['entityid'][$tab->name] = $tab->entity;
$this->attributes[$tab->elementtype]['enabled'][$tab->name] = $tab->enabled; $this->attributes[$tab->elementtype]['enabled'][$tab->name] = $tab->enabled;
$this->attributes[$tab->elementtype]['help'][$tab->name] = $tab->help; $this->attributes[$tab->elementtype]['help'][$tab->name] = $tab->help;
$this->attributes[$tab->elementtype]['css'][$tab->name] = $tab->css;
$this->attributes[$tab->elementtype]['cssview'][$tab->name] = $tab->cssview;
$this->attributes[$tab->elementtype]['csslist'][$tab->name] = $tab->csslist;
$this->attributes[$tab->elementtype]['loaded'] = 1; $this->attributes[$tab->elementtype]['loaded'] = 1;
} }
@ -1838,7 +1842,7 @@ class ExtraFields
} }
/** /**
* Return tag to describe alignement to use for this extrafield * Return the CSS to use for this extrafield into list
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data
@ -1854,29 +1858,33 @@ class ExtraFields
$type = $this->attribute_type[$key]; $type = $this->attribute_type[$key];
} }
$align = ''; $cssstring = '';
if ($type == 'date') { if ($type == 'date') {
$align = "center"; $cssstring = "center";
} elseif ($type == 'datetime') { } elseif ($type == 'datetime') {
$align = "center"; $cssstring = "center";
} elseif ($type == 'int') { } elseif ($type == 'int') {
$align = "right"; $cssstring = "right";
} elseif ($type == 'price') { } elseif ($type == 'price') {
$align = "right"; $cssstring = "right";
} elseif ($type == 'double') { } elseif ($type == 'double') {
$align = "right"; $cssstring = "right";
} elseif ($type == 'boolean') { } elseif ($type == 'boolean') {
$align = "center"; $cssstring = "center";
} elseif ($type == 'radio') { } elseif ($type == 'radio') {
$align = "center"; $cssstring = "center";
} elseif ($type == 'checkbox') { } elseif ($type == 'checkbox') {
$align = "center"; $cssstring = "center";
} elseif ($type == 'price') { } elseif ($type == 'price') {
$align = "right"; $cssstring = "right";
} }
return $align; if (!empty($this->attributes[$extrafieldsobjectkey]['csslist'][$key])) {
$cssstring .= ($cssstring ? ' ' : '').$this->attributes[$extrafieldsobjectkey]['csslist'][$key];
}
return $cssstring;
} }
/** /**

View File

@ -24,10 +24,10 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) {
$align = $extrafields->getAlignFlag($key); $cssclass = $extrafields->getAlignFlag($key, $extrafieldsobjectkey);
$typeofextrafield = $extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; $typeofextrafield = $extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
print '<td class="liste_titre'.($align ? ' '.$align : '').'">'; print '<td class="liste_titre'.($cssclass ? ' '.$cssclass : '').'">';
$tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key); $tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key);
if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) { if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) {
$searchclass = ''; $searchclass = '';

View File

@ -22,7 +22,7 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) {
$align = $extrafields->getAlignFlag($key); $cssclass = $extrafields->getAlignFlag($key, $extrafieldsobjectkey);
$sortonfield = $extrafieldsobjectprefix.$key; $sortonfield = $extrafieldsobjectprefix.$key;
if (!empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) { if (!empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) {
$sortonfield = ''; $sortonfield = '';
@ -36,7 +36,7 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
$tooltip = empty($extrafields->attributes[$extrafieldsobjectkey]['help'][$key]) ? '' : $extrafields->attributes[$extrafieldsobjectkey]['help'][$key]; $tooltip = empty($extrafields->attributes[$extrafieldsobjectkey]['help'][$key]) ? '' : $extrafields->attributes[$extrafieldsobjectkey]['help'][$key];
print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align ? 'align="'.$align.'" data-titlekey="'.$key.'"' : 'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', $disablesortlink, $tooltip)."\n"; print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($cssclass ? 'class="'.$cssclass.'" data-titlekey="'.$key.'"' : 'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', $disablesortlink, $tooltip)."\n";
if (isset($totalarray) && isset($totalarray['nbfield'])) { if (isset($totalarray) && isset($totalarray['nbfield'])) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }

View File

@ -659,9 +659,9 @@ if ($action == "view_ticketlist") {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($arrayfields["ef.".$key]['checked'])) { if (!empty($arrayfields["ef.".$key]['checked'])) {
print '<td'; print '<td';
$align = $extrafields->getAlignFlag($key); $cssstring = $extrafields->getAlignFlag($key, $object->table_element);
if ($align) { if ($cssstring) {
print ' align="'.$align.'"'; print ' class="'.$cssstring.'"';
} }
print '>'; print '>';
$tmpkey = 'options_'.$key; $tmpkey = 'options_'.$key;