Add group of tag to an action

This commit is contained in:
Dany De Bontridder 2020-10-05 16:25:42 +02:00
parent 3effa4bb84
commit a5b27d9253
6 changed files with 34 additions and 9 deletions

View file

@ -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",
{

View file

@ -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) {

View file

@ -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();

View file

@ -1504,9 +1504,10 @@ class Follow_Up
echo '&nbsp;';
echo '&nbsp;';
}
$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');
}
}

View file

@ -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';
}
/**

View file

@ -5,7 +5,9 @@
* @file
* @brief list of tags
*/
?><?php
$http=new HttpInput();
?>
<?php
echo HtmlInput::title_box('Tag', 'tag_div');
$max=$this->cn->count($ret);
if ( $max == 0 ) {
@ -26,13 +28,14 @@ if ( $max == 0 ) {
<?php
$gDossier=Dossier::id();
if (isNumber($_REQUEST['ag_id']) == 0 ) die ('ERROR : parameters invalid');
$ag_id=$http->request("ag_id","number");
for ($i=0;$i<$max;$i++):
$row=Database::fetch_array($ret, $i);
?>
<tr class="<?php echo (($i%2==0)?'even':'odd');?>">
<td>
<?php
$js=sprintf("action_tag_add('%s','%s','%s')",$gDossier,$_REQUEST['ag_id'],$row['t_id']);
$js=sprintf("action_tag_add('%s','%s','%s','%s')",$gDossier,$ag_id,$row['t_id'],$row['tag_type']);
echo HtmlInput::anchor($row['t_tag'], "", "onclick=\"$js\"");
?>
</td>