diff --git a/html/js/scripts.js b/html/js/scripts.js index b29f05653..f1658da90 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -2575,13 +2575,14 @@ function action_tag_select(p_dossier, ag_id) * @brief Add the current tag to the current ag_id * @param {type} p_dossier * @param {type} ag_id + * @param p_isgroup g it is a group , t is a single tag * @returns {undefined} */ -function action_tag_add(p_dossier, ag_id, t_id) +function action_tag_add(p_dossier, ag_id, t_id,p_isgroup) { try { waiting_box(); - var queryString = "t_id=" + t_id + "&ag_id=" + ag_id + "&op=tag_add&gDossier=" + p_dossier; + var queryString = "t_id=" + t_id + "&ag_id=" + ag_id + "&op=tag_add&gDossier=" + p_dossier+"&isgroup="+p_isgroup; var action = new Ajax.Request( "ajax_misc.php", { diff --git a/include/ajax/ajax_search_add_tag.php b/include/ajax/ajax_search_add_tag.php index 2e5b2d2a8..d1e3b853c 100644 --- a/include/ajax/ajax_search_add_tag.php +++ b/include/ajax/ajax_search_add_tag.php @@ -42,7 +42,7 @@ if ($http->request("obj")=='t') elseif ($http->request("obj")=="g") { // Add all the tag from the group - $aTag=$cn->get_array("select t_id,t_tag from jnt_tag_group_tag jtgt join tags on (tag_id=t_id) where tag_group_id=1 order by 2 "); + $aTag=$cn->get_array("select t_id,t_tag from jnt_tag_group_tag jtgt join tags on (tag_id=t_id) where tag_group_id=$1 order by 2 ",[$http->get("id", "number")]); $nb_atag=count($aTag); $pref=$http->get("pref"); if ( $nb_atag > 0) { diff --git a/include/ajax/ajax_tag_add_action.php b/include/ajax/ajax_tag_add_action.php index cdb4c4ad5..890966c0a 100644 --- a/include/ajax/ajax_tag_add_action.php +++ b/include/ajax/ajax_tag_add_action.php @@ -24,11 +24,26 @@ if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); *@see Follow_Up *@see Tag */ +$http=new HttpInput(); $fl=new Follow_Up($cn); -$fl->ag_id=$_REQUEST['ag_id']; -if ( $g_user->can_write_action($fl->ag_id) == TRUE ) - $fl->tag_add($_REQUEST['t_id']); + +$fl->ag_id=$http->request("ag_id","number"); + +if ( $g_user->can_write_action($fl->ag_id) != TRUE ) return; + +if ( $http->request("isgroup") == 't') { + $fl->tag_add($http->request('t_id',"number")); +} else { + // Add all the tag from the group + $aTag=$cn->get_array("select t_id,t_tag from jnt_tag_group_tag jtgt join tags on (tag_id=t_id) where tag_group_id=$1 order by 2 ",[$http->request("t_id","number")]); + $nb_atag=count($aTag); + if ( $nb_atag > 0) { + for ($i=0;$i<$nb_atag;$i++){ + $fl->tag_add($aTag[$i]['t_id']); + } + } +} ob_start(); diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 26a8927eb..6734dd238 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -1504,9 +1504,10 @@ class Follow_Up echo ' '; echo ' '; } - $js=sprintf("onclick=\"action_tag_select('%s','%s')\"", dossier::id(), $this->ag_id); + if ($g_user->can_write_action($this->ag_id)==true) { + $js=sprintf("onclick=\"action_tag_select('%s','%s')\"", dossier::id(), $this->ag_id); echo HtmlInput::button('tag_bt', 'Ajout tag', $js, 'smallbutton'); } } diff --git a/include/class/tag.class.php b/include/class/tag.class.php index 27e8b00ba..792e8cd26 100644 --- a/include/class/tag.class.php +++ b/include/class/tag.class.php @@ -42,6 +42,11 @@ class Tag function select() { $ret=$this->data->seek("where t_actif='Y' order by t_tag"); + $ret=$this->cn->exec_sql(" select t_id,t_tag,t_description,'t' as tag_type + from tags + where t_actif='Y' + union all + select tg_id,tg_name ,'G','g' from tag_group order by 2"); require_once NOALYSS_TEMPLATE.'/tag_select.php'; } /** diff --git a/include/template/tag_select.php b/include/template/tag_select.php index ea6d4bb12..709c9ff89 100644 --- a/include/template/tag_select.php +++ b/include/template/tag_select.php @@ -5,7 +5,9 @@ * @file * @brief list of tags */ -?> +cn->count($ret); if ( $max == 0 ) { @@ -26,13 +28,14 @@ if ( $max == 0 ) { request("ag_id","number"); for ($i=0;$i<$max;$i++): $row=Database::fetch_array($ret, $i); ?>