diff --git a/include/dashboard.inc.php b/include/dashboard.inc.php
index 2a00531bc..90903bf23 100644
--- a/include/dashboard.inc.php
+++ b/include/dashboard.inc.php
@@ -11,3 +11,6 @@ echo \HtmlInput::button_action(_('Elements du tableau de bord'), "widget.manage(
?>
+
diff --git a/include/widget/ajax.php b/include/widget/ajax.php
index b3dd83897..b6f095490 100644
--- a/include/widget/ajax.php
+++ b/include/widget/ajax.php
@@ -95,7 +95,10 @@ if ( $action == 'widget.save') {
$query=$http->request("param","string","");
try {
parse_str($query, $aWigdet);
- \Noalyss\Widget\Widget::save($aWigdet['contain_widget']);
+ if (isset ($aWigdet['contain_widget']))
+ \Noalyss\Widget\Widget::save($aWigdet['contain_widget']);
+ else
+ \Noalyss\Widget\Widget::save(array());
} catch (\Exception $e) {
echo "NOK";
diff --git a/include/widget/widget.php b/include/widget/widget.php
index d96d31e46..3ccb38c34 100644
--- a/include/widget/widget.php
+++ b/include/widget/widget.php
@@ -180,10 +180,11 @@ where use_login=$1 order by uw.uw_order
$widget->close_div();
$dossier_id=\Dossier::id();
+ $widgetjs=uniqid('widget');
echo <<
-var widget= new Widget('{$dossier_id}')
-widget.display('{$box}',{$widget->get_user_widget_id()},'{$widget->get_widget_code()}')
+var {$widgetjs}= new Widget('{$dossier_id}')
+{$widgetjs}.display('{$box}',{$widget->get_user_widget_id()},'{$widget->get_widget_code()}')
@@ -218,8 +219,11 @@ EOF;
* @exception DatabaseCore fails , cannot update
*/
static function save($array) {
- if (empty($array)) return;
global $cn,$g_user;
+ if (empty($array)) {
+ $cn->exec_sql("delete from user_widget where use_login = $1",[$g_user->getLogin()]);
+ return;
+ }
try {
$cn->start();
$order=10;