request("action");
$w=$http->request("w","string","widget");
} catch (\Exception $e) {
echo $e->getMessage();
}
/**************************************************************************
// action = display,
*
*************************************************************************/
if ($action == 'widget.display') {
try {
$widget=\Noalyss\Widget\Widget::build_user_widget($http->request('user_widget_id'),$http->request("widget_code"));
$widget?->set_var_name($http->request("var_name"),'string','');
$widget?->display();
} catch (\Exception $e) {
record_log($e);
echo $e->getMessage();
}
return;
}
/**************************************************************************
// call from a widget
*
*************************************************************************/
if ( $w != "widget") {
// security
// widget exists ? Protect against attack when w is a relative path to something else
$count=$cn->get_value("select count(*) from widget_dashboard where wd_code=$1",[$w]);
if ($count == 1 && file_exists(NOALYSS_INCLUDE."/widget/$w/ajax.php")) {
require NOALYSS_INCLUDE."/widget/$w/ajax.php";
return;
}
}
/**************************************************************************
// action == manage , display a dialog box to add , remove or change parameter of widget
// if must possible to add several time the same widget , example mini-report
*************************************************************************/
if ( $action == 'widget.manage') {
echo \HtmlInput::title_box(_("Elements"), 'widget_box_id',p_mod: 'none',p_draggable: 'y');
echo '
';
echo span(_('Organiser les éléments en utilisant la souris (Drag & Drop) puis sauver'),'class="text-muted text-center"');
\Noalyss\Widget\Widget::display_available();
echo '
';
echo '- '.\HtmlInput::button_action(_('Fermer'),'widget.remove_ident();removeDiv('."'widget_box_id'".')').'
';
echo '- '.\HtmlInput::button_action(_('Sauver'),'widget.save()').'
';
echo '- '.\HtmlInput::button_action(_('Ajouter'),'widget.input()').'
';
echo '';
echo create_script("widget.create_sortable()");
echo '
';
return;
}
/**************************************************************************
*
// save the order of the widget
*************************************************************************/
if ( $action == 'widget.save') {
$query=$http->request("param","string","");
try {
parse_str($query, $aWigdet);
if (isset ($aWigdet['contain_widget']))
\Noalyss\Widget\Widget::save($aWigdet['contain_widget']);
else
\Noalyss\Widget\Widget::save(array());
} catch (\Exception $e) {
echo "NOK";
echo $e->getMessage();
}
return;
}
/**************************************************************************
* refresh dashboard
*
*************************************************************************/
if ($action == 'widget.refresh') {
require NOALYSS_TEMPLATE."/dashboard.php";
return;
}
if ($action == "widget.input") {
echo \HtmlInput::title_box(_("Elements à ajouter"), 'widget_box_select_id',p_draggable: 'y');
echo '';
\Noalyss\Widget\Widget::select_available();
echo '
';
echo '';
echo '- '.\HtmlInput::button_close('widget_box_select_id','button').'
';
echo '';
echo '';
return;
}
/*************************************************************************
* insert a new widget with param if any
************************************************************************/
if ($action == 'widget.insert') {
// insert new widget in user_widget + list "contain_widget"
$param = $http->request("param","string",null);
$widget_code = $http->request("widget_code");
$widget_id=$cn->get_value("select wd_id from widget_dashboard where wd_code=$1 ",[$widget_code]);
if (empty($widget_id)) return;
$user_widget_id = $cn->get_value("insert into user_widget(use_login,dashboard_widget_id,uw_parameter,uw_order)
values ($1,$2,$3,1000) returning uw_id",[$g_user->getLogin(),$widget_id,$param]);
$widget=\Noalyss\Widget\Widget::build_user_widget($user_widget_id, $widget_code);
$widget->input(false);
return;
}