diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 9874b565ccd..fc9f5c14f95 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -383,6 +383,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b $bookkeeping->label_compte = $account_label; $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $account_label); + $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 5cbb0e3567c..64f76e3b793 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -494,7 +494,7 @@ if ($action == 'encrypt') { $sql .= " AND te.".$attributekey." IS NOT NULL"; $sql .= " AND te.".$attributekey." <> ''"; if ($extrafields->attributes[$elementtype]['entityid'][$attributekey] == $conf->entity) { - $sql .= " AND t.entity = ".getEntity($arrayofelement['table_element'], 0); + $sql .= " AND t.entity = ".getEntity($arrayofelement['element'], 0); } //print $sql; diff --git a/htdocs/core/class/cleadstatus.class.php b/htdocs/core/class/cleadstatus.class.php index 48fc1934e4b..8c1cf667cf6 100644 --- a/htdocs/core/class/cleadstatus.class.php +++ b/htdocs/core/class/cleadstatus.class.php @@ -58,6 +58,10 @@ class CLeadStatus extends CommonDict */ public $percent; + public $fields = array( + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"), + 'label' => array('type' => 'varchar(128)', 'label' => 'Label', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'comment' => "Label of status"), + ); /** * Constructor diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cc7f5816b13..39ef25cb706 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8369,7 +8369,7 @@ abstract class CommonObject $isDependList = 1; } - $data[(int) $obj->rowid] = $labeltoshow; + $data[$obj->rowid] = $labeltoshow; // Warning: $obj->rowid is an alias and can be an int, but also a string ref. } $i++; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index b8866064d59..2d17e02ec1c 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -750,7 +750,9 @@ class DolGraph foreach ($this->data as $x) { // Loop on each x for ($i = 0; $i < $nbseries; $i++) { // Loop on each series if (is_null($max)) { - $max = $x[$i + 1]; // $i+1 because the index 0 is the legend + if (isset($x[$i + 1])) { + $max = $x[$i + 1]; // $i+1 because the index 0 is the legend + } } elseif ($max < $x[$i + 1]) { $max = $x[$i + 1]; } @@ -780,7 +782,9 @@ class DolGraph foreach ($this->data as $x) { // Loop on each x for ($i = 0; $i < $nbseries; $i++) { // Loop on each series if (is_null($min)) { - $min = $x[$i + 1]; // $i+1 because the index 0 is the legend + if (isset($x[$i + 1])) { + $min = $x[$i + 1]; // $i+1 because the index 0 is the legend + } } elseif ($min > $x[$i + 1]) { $min = $x[$i + 1]; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e96a7121f09..f5b10b11efd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9289,7 +9289,7 @@ class Form // If table need a multientity restriction if (!empty($objecttmp->ismultientitymanaged)) { if ($objecttmp->ismultientitymanaged == 1) { - $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")"; + $sql .= " AND t.entity IN (" . getEntity($objecttmp->element) . ")"; } if (!is_numeric($objecttmp->ismultientitymanaged)) { $sql .= " AND parenttable.entity = t." . $this->db->sanitize($tmparray[0]); diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 084caf97c0c..c5cb56bc25a 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -244,7 +244,11 @@ if ($user->socid > 0) { // Protection if external user $extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects //$extrafields->fetch_name_optionals_label($object->table_element_line); -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +if (!empty($object->table_element)) { + $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +} else { + $search_array_options = array(); +} $search_component_params = array(''); $search_component_params_hidden = trim(GETPOST('search_component_params_hidden', 'alphanohtml')); @@ -353,7 +357,11 @@ $arrayofgroupby = array(); $arrayofyaxis = array(); $arrayofvaluesforgroupby = array(); -$features = $object->element; +if (!empty($object->element)) { + $features = $object->element; +} else { + $features = ''; +} if (!empty($object->element_for_permission)) { $features = $object->element_for_permission; } else { @@ -516,28 +524,30 @@ if (count($search_groupby)) { } $regs = array(); - if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { - $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; - if (is_null($valuetranslated)) { - $valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey"); - } - $valuetranslated = $langs->trans($valuetranslated); - } elseif (preg_match('/integer:([^:]+):([^:]+)$/', $object->fields[$gvalwithoutprefix]['type'], $regs)) { - $classname = $regs[1]; - $classpath = $regs[2]; - dol_include_once($classpath); - if (class_exists($classname)) { - $tmpobject = new $classname($db); - '@phan-var-force CommonObject $tmpobject'; - $tmpobject->fetch($obj->val); - foreach ($tmpobject->fields as $fieldkey => $field) { - if ($field['showoncombobox']) { - $valuetranslated = $tmpobject->$fieldkey; - //if ($valuetranslated == '-') $valuetranslated = $langs->transnoentitiesnoconv("Unknown") - break; - } + if (isset($object->fields[$gvalwithoutprefix])) { + if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { + $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; + if (is_null($valuetranslated)) { + $valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey"); + } + $valuetranslated = $langs->trans($valuetranslated); + } elseif (preg_match('/integer:([^:]+):([^:]+)$/', $object->fields[$gvalwithoutprefix]['type'], $regs)) { + $classname = $regs[1]; + $classpath = $regs[2]; + dol_include_once($classpath); + if (class_exists($classname)) { + $tmpobject = new $classname($db); + '@phan-var-force CommonObject $tmpobject'; + $tmpobject->fetch($obj->val); + foreach ($tmpobject->fields as $fieldkey => $field) { + if ($field['showoncombobox']) { + $valuetranslated = $tmpobject->$fieldkey; + //if ($valuetranslated == '-') $valuetranslated = $langs->transnoentitiesnoconv("Unknown") + break; + } + } + //$valuetranslated = $tmpobject->ref.'eee'; } - //$valuetranslated = $tmpobject->ref.'eee'; } } @@ -545,7 +555,7 @@ if (count($search_groupby)) { } // Add also the possible NULL value if field is a parent field that is not a strict join $tmpfield = explode('.', $gval); - if ($tmpfield[0] != 't' || (is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) { + if ($tmpfield[0] != 't' || (isset($object->fields[$tmpfield[1]]) && is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) { dol_syslog("The group by field ".$gval." may be null (because field is null or it is a left join), so we add __NULL__ entry in list of possible values"); //var_dump($gval); var_dump($object->fields); $arrayofvaluesforgroupby['g_'.$gkey]['__NULL__'] = $langs->transnoentitiesnoconv("NotDefined"); @@ -1270,10 +1280,14 @@ if ($mode == 'graph') { $dir = $conf->user->dir_temp; dol_mkdir($dir); // $customreportkey may be defined when using customreports.php as an include - $filenamekey = $dir.'/customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; - $fileurlkey = DOL_URL_ROOT.'/viewimage.php?modulepart=user&file=customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; + if (!empty($object->element)) { + $filenamekey = $dir.'/customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; + $fileurlkey = DOL_URL_ROOT.'/viewimage.php?modulepart=user&file=customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png'; + } - $px1->draw($filenamekey, $fileurlkey); + if (isset($filenamekey) && isset($fileurlkey)) { + $px1->draw($filenamekey, $fileurlkey); + } $texttoshow = $langs->trans("NoRecordFound"); if (!GETPOSTISSET('search_measures') || !GETPOSTISSET('search_xaxis')) { diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 109c2157f3d..4036151638a 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -446,7 +446,7 @@ if (empty($reshook)) { $product_type, $rang, $lines[$i]->special_code, - $objecttmp->origin, + $objecttmp->origin_type, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice,