diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index 52bd6c68d..f58efc19b 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -2795,6 +2795,7 @@ div.menu2 td.mtitle a{ } .icon:hover { font-family: "fontello"; + background-color: transparent; } *.icon { text-decoration: none; diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index d4051de21..e7bd7bd53 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -60,7 +60,7 @@ function errorFid(request,json) */ function ajaxFid(p_ctl) { - debugger + try { var gDossier=id$('gDossier').value; diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js index 080b9c483..8d2351f5b 100644 --- a/html/js/noalyss_script.js +++ b/html/js/noalyss_script.js @@ -4390,10 +4390,11 @@ Widget = function(dossier_id) { * Display the widget in the elt box * @param box DOMID of the target * @param dossier_id - * @param user_widget_id - * @param widget_code + * @param user_widget_id int + * @param widget_code string + * @param var_name string name of the variable */ -Widget.prototype.display = function (box,user_widget_id,widget_code) { +Widget.prototype.display = function (box,user_widget_id,widget_code,var_name) { try { var queryString = { @@ -4401,6 +4402,7 @@ Widget.prototype.display = function (box,user_widget_id,widget_code) { 'op': 'widget', 'user_widget_id': user_widget_id, 'widget_code': widget_code, + 'var_name':var_name, 'action': 'widget.display' } var action = new Ajax.Request( diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index bfdb2b10b..75cf68e44 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -872,7 +872,7 @@ class HtmlInput * @return type */ static function title_box($p_name, $p_div, $p_mod="close", $p_js="", - $p_draggable="n",$p_enlarge='n',$raw="") + $p_draggable="n",$p_enlarge='n',$raw="",$refresh='') { $p_div=strip_tags($p_div); $r='
'; @@ -885,6 +885,9 @@ class HtmlInput if ( $p_enlarge=='y') { $r.=Icon_Action::full_size($p_div); } + if ( $refresh != '') { + $r.=Icon_Action::refresh(uniqid(), $refresh); + } if ($p_mod=='close') { $r.=Icon_Action::close($p_div, $p_js); diff --git a/include/lib/icon_action.class.php b/include/lib/icon_action.class.php index 31f0f4277..d3fa269a1 100644 --- a/include/lib/icon_action.class.php +++ b/include/lib/icon_action.class.php @@ -509,5 +509,15 @@ class Icon_Action ); return $r; } + static function refresh($p_id,$javascript) + { + $javascript=str_replace('"', '"',$javascript); + //icon-arrows-cw + $r=sprintf('', + $p_id,$javascript + ); + + return $r; + } } diff --git a/include/template/status_operation_event-main_display.php b/include/template/status_operation_event-main_display.php index 78c0aa3b8..8858bbd4c 100644 --- a/include/template/status_operation_event-main_display.php +++ b/include/template/status_operation_event-main_display.php @@ -21,7 +21,7 @@ * \file * \brief main display for situation */ - +$http=new \HttpInput(); $Operation=new Follow_Up($cn); $last_operation=$Operation->get_today(); $late_operation=$Operation->get_late(); @@ -38,8 +38,10 @@ $customer_late=$Ledger->get_customer_late(); $gDossier_id=Dossier::id(); +// var refresh : string javascript code to refresh this widget +$refresh=sprintf("event_display_main('%s')",Dossier::id()); ?> - +
diff --git a/include/widget/agenda/agenda.php b/include/widget/agenda/agenda.php index e60198fda..024bc9765 100644 --- a/include/widget/agenda/agenda.php +++ b/include/widget/agenda/agenda.php @@ -39,13 +39,25 @@ class Agenda extends Widget global $g_user; /* others report */ $cal=new \Calendar(); + $cal->default_periode=$g_user->get_periode(); + + $box= sprintf( '%s_%s',$this->get_widget_code(),$this->get_user_widget_id()); + $obj=sprintf("{gDossier:%d,invalue:'%s',outdiv:'%s','distype':'%s'}", \Dossier::id(),'per','calendar_zoom_div','cal'); $this->open_div(); - echo \HtmlInput::title_box(_('Calendrier'),'cal_div','zoom',"calendar_zoom($obj)",'n',raw:'📅'); + // var $refresh string javascript to refresh the widget + $refresh=''; + if ( $this->get_var_name() !="") { + $refresh=Widget::build_refresh_js( $this->get_widget_code(), + $this->get_user_widget_id(), + $this->get_var_name()); + + } + echo \HtmlInput::title_box(_('Calendrier'),'cal_div','zoom',"calendar_zoom($obj)",'n',raw:'📅',refresh: $refresh); echo $cal->display('short',0); $this->close_div(); } diff --git a/include/widget/ajax.php b/include/widget/ajax.php index cbf57fbac..a434f22ce 100644 --- a/include/widget/ajax.php +++ b/include/widget/ajax.php @@ -44,20 +44,27 @@ try { } 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 diff --git a/include/widget/last_operation/last_operation.php b/include/widget/last_operation/last_operation.php index 7fdb4f994..77305b715 100644 --- a/include/widget/last_operation/last_operation.php +++ b/include/widget/last_operation/last_operation.php @@ -40,8 +40,11 @@ class Last_Operation extends Widget { global $cn; $this->open_div(); - - echo \HtmlInput::title_box(_('Dernières opérations'),"last_operation_box_div",'zoom','popup_recherche('.\Dossier::id().')','n'); + $refresh=""; + if ( $this->get_var_name() != "") { + $refresh = Widget::build_refresh_js($this->widget_code, $this->user_widget_id,$this->var_name); + } + echo \HtmlInput::title_box(_('Dernières opérations'),"last_operation_box_div",'zoom','popup_recherche('.\Dossier::id().')','n','','',$refresh); require_once "last_operation-display.php"; $this->close_div(); } diff --git a/include/widget/widget.php b/include/widget/widget.php index 8c4dc4ef8..eee2dfa9e 100644 --- a/include/widget/widget.php +++ b/include/widget/widget.php @@ -30,12 +30,34 @@ namespace Noalyss\Widget; */ abstract class Widget { + //!< $var_name string name of the variable in javascript + protected $var_name; + + public function __construct(protected int $user_widget_id=0,protected string $widget_code="",protected $db=null) { if ($db == null) { $this->db=\Dossier::connect(); } + $this->var_name=''; + } + + /** + * @return mixed + */ + public function get_var_name() + { + return $this->var_name; + } + + /** + * @param mixed $var_name + */ + public function set_var_name($var_name):Widget + { + $this->var_name = $var_name; + return $this; } public function get_user_widget_id(): int @@ -197,7 +219,7 @@ where use_login=$1 order by uw.uw_order echo << var {$widgetjs}= new Widget('{$dossier_id}') -{$widgetjs}.display('{$box}',{$widget->get_user_widget_id()},'{$widget->get_widget_code()}') +{$widgetjs}.display('{$box}',{$widget->get_user_widget_id()},'{$widget->get_widget_code()}','{$widgetjs}') @@ -359,15 +381,43 @@ EOF; return $bt; } /** - * @brief display the title and the icon for zooming + * @brief display the title and the icon for zooming + refresh if possible * @param $title string title of the widget */ function title( $title) { + // var $refresh string javascript to refresh the widget + $refresh=''; + if ( $this->get_var_name() !="") { + $refresh=Widget::build_refresh_js( $this->get_widget_code(), + $this->get_user_widget_id(), + $this->get_var_name()); + + } $r='
'; + $r.=\Icon_Action::refresh(uniqid(), $refresh); $r.=''.$this->button_zoom().""; $r.='
'; $r.=sprintf('

%s

',$title); echo $r; } + /** + * @brief build refresh javascript + * @param $widget_id int id from DB + * @param $widget_code string code of the widget + * @param $var_name string name of the js variable + */ + static function build_refresh_js($widget_code,$widget_id,$var_name) + { + // var $box string DOM ID of the DIV containing the widget + $box= sprintf( '%s_%s',$widget_code,$widget_id); + $refresh=sprintf("%s.display('%s','%s','%s','%s')", + $var_name, + $box, + $widget_id, + $widget_code, + $var_name + ); + return $refresh; + } } \ No newline at end of file diff --git a/scenario/LIB/icon_actionTest.php b/scenario/LIB/icon_actionTest.php index 551f5d590..2f1417e79 100644 --- a/scenario/LIB/icon_actionTest.php +++ b/scenario/LIB/icon_actionTest.php @@ -117,4 +117,7 @@ include_once NOALYSS_INCLUDE."/lib/icon_action.class.php"; - +

+

+ +