Topic: Dashboard

I'm getting this error when setting up dashboard

At file C:\frontaccounting\modules\dashboard\includes\dashboard_db.inc:52:
The widget could not be updated
error code : 1366
error message : Incorrect integer value: '' for column 'collapsed' at row 1
sql that failed was : UPDATE 0_dashboard_widgets SET user_id='1',app='orders',column_id='1',sort_no='1',collapsed='',widget='customers',description='test',param='{"top":"10","data_filter":"","graph_type":"ColumnChart"}' WHERE id = '40'

Re: Dashboard

The field definition for it is:

`collapsed` tinyint(4) NOT NULL

Check your databse if there is any default value such as 0 for the said field. Also see if changing it to NULL or VARCHAR makes any difference.

CREATE TABLE IF NOT EXISTS `0_dashboard_widgets` (
  `id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `app` varchar(50) NOT NULL,
  `column_id` int(11) NOT NULL,
  `sort_no` int(11) NOT NULL,
  `collapsed` tinyint(4) NOT NULL,
  `widget` varchar(100) NOT NULL,
  `description` varchar(100) NOT NULL,
  `param` text,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

Wonder why the AUTO_INCREMENT was set to 6 !
Wonder why the tinyint(4) should not be tinyint(1) !

The relevant function that updates it is:

function update_dashboard_widget($selected_id, $app, $user_id, $column_id, $sort_no, $collapsed, $widget, $description, $param)
{
    $sql = "UPDATE ".TB_PREF."dashboard_widgets SET user_id=" . db_escape($user_id)
        . ",app=" . db_escape($app)
        . ",column_id=" . db_escape($column_id)
        . ",sort_no=" . db_escape($sort_no)
        . ",collapsed=" . db_escape($collapsed)
        . ",widget=" . db_escape($widget)
        . ",description=" . db_escape($description)
        . ",param=" . db_escape($param)
        . " WHERE id = " .db_escape($selected_id);
    db_query($sql,"The widget could not be updated");
}

The simplest fix may yet be:

function update_dashboard_widget($selected_id, $app, $user_id, $column_id, $sort_no, $collapsed, $widget, $description, $param)
{
    $sql = "UPDATE ".TB_PREF."dashboard_widgets SET user_id=" . db_escape($user_id)
        . ",app=" . db_escape($app)
        . ",column_id=" . db_escape($column_id)
        . ",sort_no=" . db_escape($sort_no)
        . ",collapsed=" . ((isset($collapsed) && $collapsed <> 1) ? 0 : 1)
        . ",widget=" . db_escape($widget)
        . ",description=" . db_escape($description)
        . ",param=" . db_escape($param)
        . " WHERE id = " .db_escape($selected_id);
    db_query($sql,"The widget could not be updated");
}