Infolog: Avoid JS error 'Uncaught TypeError: Cannot read properties of undefined (reading 'getWidgetById')' caused by sending invalid pl_id

Fixed by not sending invalid pl_id which triggered fix_bad_value()
This commit is contained in:
nathan 2022-10-18 16:52:27 -06:00
parent 48eb9c1968
commit ab32872988
2 changed files with 10 additions and 0 deletions

View File

@ -578,6 +578,11 @@ class infolog_so
$to_write[$key] = $this->data[$key] = $val; // update internal data
}
}
// If no price list use NULL not 0
if($to_write['pl_id'] == '')
{
$to_write['pl_id'] = NULL;
}
// writing no price as SQL NULL (required by postgres)
if ($to_write['info_price'] === '') $to_write['info_price'] = NULL;

View File

@ -2222,6 +2222,11 @@ class infolog_ui
{
unset($content['info_cat']);
}
// Don't send '0' if there is no price list
if($content['pl_id'] == '0')
{
unset($content['pl_id']);
}
$content['duration_format'] = $this->duration_format;
$content['hours_per_workday'] = $this->hours_per_workday;
if ($this->prefs['show_id']) $content['info_number'] = $info_id;