25namespace Noalyss\Widget;
34 public function __construct(
protected int $user_widget_id=0,
protected string $widget_code=
"",
protected $db=
null)
37 $this->
db=\Dossier::connect();
43 return $this->user_widget_id;
48 $this->user_widget_id = $user_widget_id;
54 return $this->widget_code;
59 $this->widget_code = $widget_code;
89 [$this->widget_code]);
91 if ( $flnumber) $strNumber=
"[ $nb ]";
92 echo
"<li id=\"elt_{$this->user_widget_id}\"> $strNumber <span class='widget-name'>{$row['wd_name']}</span>{$row['wd_description']}";
94 if ( $this->user_widget_id > 0) {
95 if (
$row[
'wd_parameter'] == 1) {
98 echo
'<span style="float:right;color:red">'.\Icon_Action::trash(uniqid(),sprintf(
"widget.delete('%s')",$this->user_widget_id));
101 if (
$row[
'wd_parameter'] == 1) {
104 echo
'<span style="float:right;">'.\Icon_Action::icon_add(uniqid(),sprintf(
"widget.add('%s')",$this->widget_code));
118 return $cn->get_array(
"
121 uw.dashboard_widget_id ,
125join widget_dashboard wd on (uw.dashboard_widget_id=wd.wd_id)
126where use_login=$1 order by uw.uw_order
140 if (file_exists(NOALYSS_INCLUDE.
"/widget/$widget_code/$widget_code.php")) {
141 require_once NOALYSS_INCLUDE.
"/widget/$widget_code/$widget_code.php";
142 $class=sprintf(
"\\Noalyss\\Widget\\%s",$widget_code);
144 $obj->set_widget_code($widget_code);
145 $obj->set_user_widget_id($user_widget_id);
158 printf(
'<div id="%s" class="box widget-box">',$this->
get_div_domid());
166 return sprintf(
"%s_%s",$this->widget_code,$this->user_widget_id);
180 echo
h2(
_(
"Un instant, on charge :-)"),
' class="title" ');
183 print '<div style="display:flex;justify-content: center">';
184 print '<div style="margin-top: 50px;margin-left: 20px;">';
185 print '<div class="loading_msg"></div>';
186 print '<div class="loading_msg"></div>';
187 print '<div class="loading_msg"></div>';
188 print '<div class="loading_msg"></div>';
189 print '<div class="loading_msg"></div>';
196 $widgetjs=uniqid(
'widget');
199var {$widgetjs}=
new Widget(
'{$dossier_id}')
218 echo
'<ul class="list-unstyled" id="contain_widget">';
224 echo \HtmlInput::hidden(
"order_widget_hidden",
"");
237 $cn->exec_sql(
"delete from user_widget where use_login = $1",[
$g_user->getLogin()]);
243 $cn->exec_sql(
"create temporary table tmp_widget(user_widget_id integer,tw_order integer )");
244 foreach (
$array as $item) {
245 $cn->exec_sql(
'insert into tmp_widget(user_widget_id,tw_order ) values ($1,$2)',
249 $cn->exec_sql(
"delete from user_widget where use_login = $1 and uw_id not in (select user_widget_id from tmp_widget)",
252 $cn->exec_sql(
"update user_widget set uw_order =tw_order from tmp_widget where user_widget_id=uw_id");
256 }
catch (\Exception
$e) {
271 $aWidget=
$cn->get_array(
"select wd_code,wd_name, wd_description,wd_parameter from widget_dashboard order by wd_name");
272 echo
'<ul id="widget_add" class="list-unstyled">';
275 $widget?->input(
false);
289 printf (
'<form id="%s_param" style="display:inline">',$this->widget_code);
301 throw new \Exception(__FUNCTION__.
" not implemented");
312 throw new \Exception(__FUNCTION__.
" not implemented");
322 $handle=opendir(NOALYSS_INCLUDE.
"/widget");
323 while (($dir = readdir($handle)) !=
false ) {
324 $directory=NOALYSS_INCLUDE.
"/widget".DIRECTORY_SEPARATOR.$dir;
325 if (is_dir($directory) && $dir !=
"." && $dir !=
"..") {
327 $cnt=
$cn->get_value(
"select count(*) from widget_dashboard where wd_code = $1",[$dir]);
332 if (file_exists($directory . DIRECTORY_SEPARATOR .
"install.php")){
333 include $directory . DIRECTORY_SEPARATOR .
"install.php";
347 $param = $this->
db->get_value(
"select uw_parameter from user_widget where uw_id=$1",[$this->user_widget_id]);
348 if (empty ($param))
return [];
349 parse_str($param,$aParam);
367 $r=
'<div class="bxbutton">';
368 $r.=
'<span id="span_'.uniqid().
'" style="float:right;margin-right:5px">'.$this->
button_zoom().
"</span>";
370 $r.=sprintf(
'<h2 class="title">%s</h2>',
$title);
h2($p_string, $p_class="", $raw="")
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")
static zoom($p_div, $p_javascript)
Display a icon for zooming.
create_script($p_string)
create the HTML for adding the script tags around of the script