From 037a423a3ba4746bfc71262ba0d02f55cabac8b3 Mon Sep 17 00:00:00 2001
From: Dany De Bontridder
Date: Sun, 4 Oct 2020 20:34:09 +0200
Subject: [PATCH] Tag and Group Tag
new : Tag and Group : available in search
new : all tags or only one,
---
html/ajax_misc.php | 6 +-
html/js/scripts.js | 11 +--
html/js/taggroup.js | 70 ++++++++++++++++++
include/ajax/ajax_search_add_tag.php | 40 ++++++++---
include/ajax/ajax_search_display_tag.php | 5 +-
include/ajax/ajax_tag_detail.php | 2 +-
include/ajax/ajax_tag_group.php | 64 +++++++++++++++++
include/ajax/ajax_tag_set_group.php | 77 ++++++++++++++++++++
include/cfgtags.inc.php | 81 ++++++++++++++++-----
include/class/follow_up.class.php | 25 +++++--
include/class/tag.class.php | 6 +-
include/class/tag_group_mtable.class.php | 91 ++++++++++++++++++++++++
include/database/tag_group_sql.class.php | 62 ++++++++++++++++
include/lib/function_javascript.php | 1 +
include/lib/html_input.class.php | 14 ++--
include/template/action_search.php | 12 ++++
include/template/tag_list.php | 14 +++-
include/template/tag_search_select.php | 61 ++++++++++++++--
sql/upgrade.sql | 35 ++++++++-
19 files changed, 617 insertions(+), 60 deletions(-)
create mode 100644 html/js/taggroup.js
create mode 100644 include/ajax/ajax_tag_group.php
create mode 100644 include/ajax/ajax_tag_set_group.php
create mode 100644 include/class/tag_group_mtable.class.php
create mode 100644 include/database/tag_group_sql.class.php
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 3ac6686d7..9a74ce07c 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -261,7 +261,11 @@ $path = array(
// cfgaction type of document
"cfgaction"=>'ajax_cfgaction',
// list options for multiple contact
- "contact_option_list"=>'ajax_contact_option_list'
+ "contact_option_list"=>'ajax_contact_option_list',
+ // Add group of tags
+ 'tag_group'=>'ajax_tag_group',
+ // set the group for a tag
+ 'tag_set_group'=>"ajax_tag_set_group"
) ;
if (array_key_exists($op, $path)) {
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 0961481b5..b29f05653 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -24,7 +24,8 @@
*
*/
var ask_reload = 0;
-var tag_choose = '';
+// tag_choose Element which contains all the selected tags
+var tag_choose = '';
var aDraggableElement = new Array();
/**
* return undefined if nothing is found , otherwise return the DOM elemnt
@@ -2487,7 +2488,7 @@ function show_tag(p_dossier, p_ac, p_tag_id, p_post)
code_html = unescape_xml(code_html);
remove_waiting_box();
var posy = calcy(250);
- add_div({id: 'tag_div', cssclass: 'inner_box', drag: 0, style: "position:fixed;top:" + posy + "px"});
+ add_div({id: 'tag_div', cssclass: 'inner_box', drag: 0, style: "position:fixed;top:15%;"});
$('tag_div').innerHTML = code_html;
try
{
@@ -2711,8 +2712,10 @@ function search_display_tag(p_dossier, p_prefix)
* in the search screen
* @param {type} p_dossier
* @param {type} p_tag_id
+ * @param p_prefix is the prefix of the widget
+ * @param p_obj is either g for group of tag or t for a single tag
*/
-function search_add_tag(p_dossier, p_tag_id, p_prefix)
+function search_add_tag(p_dossier, p_tag_id, p_prefix,p_obj)
{
try {
var clear_button = 0;
@@ -2721,7 +2724,7 @@ function search_add_tag(p_dossier, p_tag_id, p_prefix)
clear_button = 1;
}
waiting_box();
- var queryString = "op=search_add_tag&gDossier=" + p_dossier + "&id=" + p_tag_id + "&clear=" + clear_button + '&pref=' + p_prefix;
+ var queryString = "op=search_add_tag&gDossier=" + p_dossier + "&id=" + p_tag_id + "&clear=" + clear_button + '&pref=' + p_prefix+"&obj="+p_obj;
var action = new Ajax.Request(
"ajax_misc.php",
{
diff --git a/html/js/taggroup.js b/html/js/taggroup.js
new file mode 100644
index 000000000..b159a0f6c
--- /dev/null
+++ b/html/js/taggroup.js
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2020 Dany De Bontridder
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+// Copyright (2002-2020) Author Dany De Bontridder
+
+
+var TagGroup = function ()
+{
+ this.callback = "ajax_misc.php";
+ this.param_operation = "tag_set_group";
+ this.list_tag = "ol_tag_group";
+ this.div_tag_add = "d_tag_group_add";
+ /**
+ * Add a tag to group and redraw the div "div_tag_add"
+ * @param {int} p_tag_group_id
+ * @param {int} p_tag_id
+ * @param {int} p_dossier
+ */
+ this.add_tag = function (p_tag_group_id, p_select, p_dossier) {
+ waiting_box();
+ // retrieve value from p_select
+ var p_tag_id = $(p_select).value;
+ new Ajax.Request(this.callback, {
+ method: "get",
+ parameters: {op: this.param_operation, gDossier: p_dossier, act: "add", tag_group: p_tag_group_id, tag: p_tag_id},
+ onSuccess: function (req) {
+ remove_waiting_box();
+ // redraw div_tag_add
+ $("d_tag_group_add").update(req.responseText);
+ }
+ });
+ };
+ /**
+ * removing a tag from a group and redraw the div "div_tag_add"
+ * @param {int} p_tag_group_id
+ * @param {int} p_tag_id
+ * @param {int} p_dossier
+ */
+ this.remove = function (p_jt_tag, p_dossier) {
+ waiting_box();
+
+ new Ajax.Request(this.callback, {
+ method: "get",
+ parameters: {op: this.param_operation,
+ gDossier: p_dossier,
+ act: "remove",
+ jt_tag: p_jt_tag
+ },
+ onSuccess: function (req) {
+ remove_waiting_box();
+ // redraw div_tag_add
+ $("d_tag_group_add").update(req.responseText);
+ }
+ });
+ };
+};
\ No newline at end of file
diff --git a/include/ajax/ajax_search_add_tag.php b/include/ajax/ajax_search_add_tag.php
index 339b45cec..2e5b2d2a8 100644
--- a/include/ajax/ajax_search_add_tag.php
+++ b/include/ajax/ajax_search_add_tag.php
@@ -1,4 +1,5 @@
update_search_cell($_GET['pref']);
+if ($http->request("obj")=='t')
+{
-$response= ob_get_clean();
+ $tag=new Tag($cn, $http->get("id", "number"));
+ $tag->update_search_cell($http->get("pref"));
+}
+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 ");
+ $nb_atag=count($aTag);
+ $pref=$http->get("pref");
+ if ( $nb_atag > 0) {
+ for ($i=0;$i<$nb_atag;$i++){
+ $tag=new Tag($cn,$aTag[$i]['t_id']);
+ $tag->update_search_cell($pref);
+ }
+ }
+
+}
+$response=ob_get_clean();
$html=escape_xml($response);
header('Content-type: text/xml; charset=UTF-8');
echo <<
EOF;
exit();
-
-
?>
diff --git a/include/ajax/ajax_search_display_tag.php b/include/ajax/ajax_search_display_tag.php
index 59d962739..b4295cc38 100644
--- a/include/ajax/ajax_search_display_tag.php
+++ b/include/ajax/ajax_search_display_tag.php
@@ -25,11 +25,10 @@ if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
*/
require_once NOALYSS_INCLUDE.'/class/tag.class.php';
-ob_start();
$tag=new Tag($cn);
-$tag->select_search($_GET['pref']);
-$response= ob_get_clean();
+$response= $tag->select_search($_GET['pref']);
+
$html=escape_xml($response);
header('Content-type: text/xml; charset=UTF-8');
echo <<data->t_id=$_GET['tag'];
$tag->data->load();
-echo HtmlInput::title_box(_("Détail du dossier ou étiquette"), "tag_div");
+echo HtmlInput::title_box(_("Détail du dossier ou étiquette"), "tag_div","close","","y");
?>
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+require_once NOALYSS_INCLUDE."/class/tag_group_mtable.class.php";
+/**
+ * @file
+ * @brief Manage the group of tags
+ */
+try {
+ $table=$http->request('table');
+ $action=$http->request('action');
+ $p_id=$http->request('p_id', "number");
+ $ctl_id=$http->request('ctl');
+
+} catch(Exception $e) {
+ echo $e->getMessage();
+ return;
+}
+$obj=new Tag_Group_SQL($cn,$p_id);
+$obj_manage=new Tag_Group_MTable($obj);
+$obj_manage->set_callback("ajax_misc.php");
+$obj_manage->add_json_param("op", "tag_group");
+$obj_manage->set_object_name($ctl_id);
+
+
+if ($action=="input")
+{
+
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $obj_manage->ajax_input()->saveXML();
+ return;
+}
+elseif ($action=="save")
+{
+ $xml=$obj_manage->ajax_save();
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $xml->saveXML();
+}
+elseif ($action=="delete")
+{
+ $xml=$obj_manage->ajax_delete();
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $xml->saveXML();
+}
\ No newline at end of file
diff --git a/include/ajax/ajax_tag_set_group.php b/include/ajax/ajax_tag_set_group.php
new file mode 100644
index 000000000..4d3634830
--- /dev/null
+++ b/include/ajax/ajax_tag_set_group.php
@@ -0,0 +1,77 @@
+
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+
+require_once NOALYSS_INCLUDE."/class/tag_group_mtable.class.php";
+
+/**
+ * @file
+ * @brief
+ */
+global $g_user;
+$g_user->can_request('CFGTAG');
+
+/*
+ * Received parameter
+ * gDossier
+ * act : action to perform
+ * tag_group : tag_group.tg_id
+ * tag=tags.t_id
+ *
+ */
+try
+{
+ $act=$http->request("act");
+}
+catch (Exception $e)
+{
+
+ record_log(__FILE__.$e->getMessage()." ".$e->getTraceAsString());
+ echo $e->getMessage()." ".$e->getTraceAsString();
+}
+$obj=new Tag_Group_SQL($cn);
+$obj_manage=new Tag_Group_MTable($obj);
+$obj_manage->set_callback("ajax_misc.php");
+$obj_manage->add_json_param("op", "tag_group");
+if ($act=="add")
+{
+ $tag_group_id=$http->request("tag_group");
+ $tag=$http->request("tag");
+ $obj_manage->set_pk($tag_group_id);
+ // add tag to group tag
+ // protect against duplicate
+ if ($cn->get_value("select count (*) from jnt_tag_group_tag where tag_id = $1 and tag_group_id = $2",
+ [$tag, $tag_group_id])==0)
+ {
+ $cn->exec_sql("insert into jnt_tag_group_tag(tag_id,tag_group_id) values ($1,$2)", [$tag, $tag_group_id]);
+ }
+}
+elseif ($act=="remove")
+{
+ $tag=$http->request("jt_tag");
+ $tag_group_id=$cn->get_value("select tag_group_id from jnt_tag_group_tag where jt_id = $1",[$tag]);
+ $obj_manage->set_pk($tag_group_id);
+ // remove tag from tag_group
+ $cn->exec_sql("delete from jnt_tag_group_tag where jt_id=$1", [$tag]);
+}
+$obj_manage->input_tag();
diff --git a/include/cfgtags.inc.php b/include/cfgtags.inc.php
index e9aef771f..9a6188597 100644
--- a/include/cfgtags.inc.php
+++ b/include/cfgtags.inc.php
@@ -17,7 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu
-if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
/**
* @file
@@ -26,34 +27,82 @@ if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
*/
require_once NOALYSS_INCLUDE.'/class/tag.class.php';
require_once NOALYSS_INCLUDE.'/lib/single_record.class.php';
+require_once NOALYSS_INCLUDE."/lib/html_tab.class.php";
+require_once NOALYSS_INCLUDE."/lib/output_html_tab.class.php";
+require_once NOALYSS_INCLUDE."/class/tag_group_mtable.class.php";
+/* * *****************************************************************************
+ * Tags
+ *
+ * ***************************************************************************** */
+$tabs=new Html_Tab("tg", _("Etiquette"));
+
+ob_start();
$tag=new Tag($cn);
$uos=new Single_Record('tag');
-if ( isset ($_POST['save_tag_sb']))
+if (isset($_POST['save_tag_sb']))
{
- if ( ! isset ($_POST['remove']))
+ if (!isset($_POST['remove']))
{
- try {
+ try
+ {
$uos->check();
$tag->save($_POST);
$uos->save();
- } catch (Exception $e)
+ }
+ catch (Exception $e)
{
alert("déjà sauvé");
}
- } else {
+ }
+ else
+ {
$tag->remove($_POST);
}
}
?>
-
-
-
+
+
-
- show_list();
- $js=sprintf("onclick=\"show_tag('%s','%s','%s','p')\"",Dossier::id(),$_REQUEST['ac'],'-1');
- echo HtmlInput::button("tag_add", "Ajout d'un tag", $js);
- ?>
\ No newline at end of file
+ à plusieurs dossiers ou avoir plusieurs étiquettes."); ?>
+
+show_list();
+$js=sprintf("onclick=\"show_tag('%s','%s','%s','p')\"", Dossier::id(), $_REQUEST['ac'], '-1');
+echo HtmlInput::button("tag_add", "Ajout d'un tag", $js);
+?>
+
+set_content(ob_get_contents());
+ob_end_clean();
+/* * *****************************************************************************
+ * Group of Tags
+ *
+ * ***************************************************************************** */
+$tag_group=new Html_Tab("grp_tg", _("Groupe étiquettes"));
+
+$obj=new Tag_Group_SQL($cn);
+$obj_manage=new Tag_Group_MTable($obj);
+$obj_manage->set_callback("ajax_misc.php");
+$obj_manage->add_json_param("op", "tag_group");
+ob_start();
+$obj_manage->display_table();
+$r=ob_get_contents();
+$tag_group->set_content($r);
+ob_end_clean();
+
+
+$out=new Output_Html_Tab();
+$out->add($tabs);
+$out->add($tag_group);
+$out->output();
+$obj_manage->create_js_script();
+?>
+
\ No newline at end of file
diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php
index e38f4a74e..4ff340d6a 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -1202,15 +1202,26 @@ class Follow_Up
if ($p_array==null)
$p_array=$_GET;
- $query="";
if (count($p_array['searchtag'])==0)
return "";
+ $query="";
+ $operand = "1 = 0 ";
+ if ($p_array['tag_option'] == 0 )
+ {
+ $operand=" and ";
+ } elseif ($p_array['tag_option']==1)
+ {
+ $operand=" or ";
+ }
+ $and=" ";
for ($i=0; $i';
+ echo '';
echo $a_tag[$e]['t_tag'];
if ($g_user->can_write_action($this->ag_id)==true)
{
- $js_remove=sprintf("onclick=\"action_tag_remove('%s','%s','%s')\"", dossier::id(), $this->ag_id, $a_tag[$e]['t_id']);
- echo HtmlInput::anchor(SMALLX, "javascript:void(0)", $js_remove, ' class="smallbutton" style="padding:0px;display:inline" ');
+ $js_remove=sprintf("action_tag_remove('%s','%s','%s')", dossier::id(), $this->ag_id, $a_tag[$e]['t_id']);
+ echo Icon_Action::trash(uniqid(), $js_remove);
}
echo '';
echo ' ';
diff --git a/include/class/tag.class.php b/include/class/tag.class.php
index a6a6855f0..d35799b88 100644
--- a/include/class/tag.class.php
+++ b/include/class/tag.class.php
@@ -90,18 +90,20 @@ class Tag
*/
function select_search($p_prefix)
{
+ $res="";
$ret=$this->data->seek(' order by t_tag');
require_once NOALYSS_TEMPLATE.'/tag_search_select.php';
+ return HtmlInput::title_box('Tag', $p_prefix.'tag_div').$res;
}
/**
* In the screen search add this data to the cell
*/
function update_search_cell($p_prefix) {
- echo '';
+ echo '';
echo h($this->data->t_tag);
echo HtmlInput::hidden($p_prefix.'tag[]', $this->data->t_id);
$js=sprintf("$('sp_".$p_prefix.$this->data->t_id."').remove();");
- echo HtmlInput::anchor( SMALLX, "javascript:void(0)", "onclick=\"$js\"", ' class="smallbutton " style="padding:0px;display:inline" ');
+ echo Icon_Action::trash(uniqid(), $js);
echo '';
}
/**
diff --git a/include/class/tag_group_mtable.class.php b/include/class/tag_group_mtable.class.php
new file mode 100644
index 000000000..e225d6243
--- /dev/null
+++ b/include/class/tag_group_mtable.class.php
@@ -0,0 +1,91 @@
+
+
+
+/**
+ * @file
+ * @brief manage tag_group table
+ *
+ *
+ */
+require_once NOALYSS_INCLUDE.'/lib/manage_table_sql.class.php';
+require_once NOALYSS_INCLUDE.'/database/tag_group_sql.class.php';
+
+class Tag_Group_MTable extends Manage_Table_SQL
+{
+
+ function __construct(Tag_Group_SQL $p_obj)
+ {
+ parent::__construct($p_obj);
+ $this->set_property_visible("tg_id", false);
+ $this->set_property_updatable("tg_id", false);
+ $this->set_col_label("tg_name", _('Nom'));
+ }
+
+ function input()
+ {
+
+
+ parent::input();
+
+
+ echo '
';
+ $this->input_tag();
+ echo '
';
+ }
+
+ /**
+ * Display a select widget for adding new tag
+ */
+ function input_tag()
+ {
+ $cn=Dossier::connect();
+ $data_sql=$this->get_table();
+
+ // Display containing tag_id
+ $aTag=$cn->get_array("select jt_id,t_tag
+ from tags join jnt_tag_group_tag on (tag_id=t_id)
+ where tag_group_id=$1 order by 2", [$data_sql->tg_id]);
+ echo '';
+ $nb=count($aTag);
+ $dossier_id=Dossier::id();
+ for ($i=0; $i<$nb; $i++)
+ {
+ // js to remove id
+ $js=Icon_Action::trash(uniqid(), sprintf("o_tagGroup.remove('%s','%s')", $aTag[$i]['jt_id'], $dossier_id));
+ printf('
%s %s %s
', $aTag[$i]['jt_id'],$aTag[$i]['t_tag'],$dossier_id,$js);
+ }
+ echo '';
+
+
+ // Add new tag
+ $select=new ISelect("is_tag", [], "s_tag_group");
+ $select->value=$cn->make_array("select t_id,t_tag
+ from tags
+ where
+ t_id not in (select tag_id from jnt_tag_group_tag
+ where tag_group_id=$1 ) order by 2", 0,[$data_sql->tg_id]);
+ echo $select->input();
+ echo HtmlInput::button('b_add_group', _("Ajout"),
+ sprintf("onclick=\"o_tagGroup.add_tag('%s','%s','%s'); \"", $data_sql->tg_id, $select->id, $dossier_id));
+ }
+
+}
diff --git a/include/database/tag_group_sql.class.php b/include/database/tag_group_sql.class.php
new file mode 100644
index 000000000..279232377
--- /dev/null
+++ b/include/database/tag_group_sql.class.php
@@ -0,0 +1,62 @@
+table = "public.tag_group";
+ $this->primary_key = "tg_id";
+/*
+ * List of columns
+ */
+ $this->name=array(
+ "tg_id"=>"tg_id"
+ ,"tg_name"=>"tg_name"
+ );
+/*
+ * Type of columns
+ */
+ $this->type = array(
+ "tg_id"=>"numeric"
+ ,"tg_name"=>"text"
+ );
+
+
+ $this->default = array(
+ "tg_id" => "auto"
+ );
+
+ $this->date_format = "DD.MM.YYYY";
+ parent::__construct($p_cn,$p_id);
+ }
+
+
+}
\ No newline at end of file
diff --git a/include/lib/function_javascript.php b/include/lib/function_javascript.php
index 10079acf5..b34b68cb0 100644
--- a/include/lib/function_javascript.php
+++ b/include/lib/function_javascript.php
@@ -2782,6 +2782,7 @@ function load_all_script()
echo js_include('sorttable.js');
echo js_include('nicEdit.js');
echo js_include('managetable.js');
+ echo js_include('taggroup.js');
}
diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php
index 7dd1ccdf3..e7e22bf96 100755
--- a/include/lib/html_input.class.php
+++ b/include/lib/html_input.class.php
@@ -828,12 +828,12 @@ class HtmlInput
/**
* Title for boxes, you can customize the symbol thanks symbol with
* the mode "custom"
- * @param type $name Title
- * @param type $div element id, except for mode none or custom
- * @param type $mod hide , close , zoom , custom or none, with
+ * @param string $p_name Title
+ * @param string $div element id, except for mode none or custom
+ * @param string $p_mod hide , close , zoom , custom or none, with
* custom , the $name contains all the code
- * @param type $p_js contains the javascript if mod = "custom" or "zoom" contains button + code
- * @param type $p_draggable , if set to yes the box will be draggable
+ * @param string $p_js contains the javascript if mod = "custom" or "zoom" contains button + code
+ * @param char $p_draggable , y = yes n = no ,if set to yes the box will be draggable
* @return type
*/
static function title_box($p_name, $p_div, $p_mod="close", $p_js="",
@@ -868,7 +868,9 @@ class HtmlInput
$r.="";
}
else
- die(__FILE__.":".__LINE__._('Paramètre invaide'));
+ {
+ throw new Exception(__FILE__.":".__LINE__._("Paramètre invalide p_mod = '$p_mod'"));
+ }
$r.='';
diff --git a/include/template/action_search.php b/include/template/action_search.php
index e7bb169e9..657f5d940 100644
--- a/include/template/action_search.php
+++ b/include/template/action_search.php
@@ -140,6 +140,18 @@
?>
+
+ value=array(
+ array("value"=>0,"label"=>_("Toutes les étiquettes")),
+ array("value"=>1,"label"=>_("Au moins une étiquette"))
+ );
+ $iselect->set_value($http->request("tag_option","number",0));
+ echo $iselect->input();
+ ?>
+
diff --git a/include/template/tag_list.php b/include/template/tag_list.php
index 962e3ab28..fb4802a95 100644
--- a/include/template/tag_list.php
+++ b/include/template/tag_list.php
@@ -2,6 +2,7 @@
//This file is part of NOALYSS and is under GPL
//see licence.txt
?>cn->count($ret);
echo HtmlInput::filter_table("tag_tb", '0,1', '1');
$nDossier=Dossier::id();
@@ -14,13 +15,19 @@ $nDossier=Dossier::id();
@@ -51,7 +54,55 @@ $gDossier=Dossier::id();
endfor;
?>
+
+set_content(ob_get_contents());
+ ob_end_clean();
+// Tab for the groups
+//
+$tab_tag_group=new Html_Tab($p_prefix."tab_tag_group",_("Groupe"));
+$aGroup=$this->cn->get_array("select tg_id, tg_name from tag_group order by 2 desc");
+$nb_agroup=count($aGroup);
+?>
+
+
+
=_("Groupe")?>
+
+
+
+
+
+
+
+
+
+
+set_content(ob_get_contents());
+ob_end_clean();
+
+// Both tab
+$output=new Output_Html_Tab();
+$output->add($tab_tag);
+$output->add($tab_tag_group);
+ob_start();
+$output->output();
+
+?>
+
+=HtmlInput::button_close($p_prefix.'tag_div')?>
+
-=HtmlInput::button_close($p_prefix.'tag_div')?>
\ No newline at end of file
+ =$output->build_js($p_prefix."tab_tag");?>
+
+
\ No newline at end of file
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 1dae36d28..f311690f7 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -139,4 +139,37 @@ ALTER TABLE public.contact_option_ref DROP COLUMN document_option_id;
-- on utilise un varchar pour stocker les possibilités
ALTER TABLE public.contact_option_ref DROP COLUMN cor_value_json;
ALTER TABLE public.contact_option_ref ADD cor_value_select varchar NULL;
-COMMENT ON COLUMN public.contact_option_ref.cor_value_select IS 'Select values';
\ No newline at end of file
+COMMENT ON COLUMN public.contact_option_ref.cor_value_select IS 'Select values';
+
+
+CREATE TABLE public.tag_group (
+ tg_id bigserial NOT NULL,
+ tg_name varchar NOT NULL
+);
+COMMENT ON TABLE public.tag_group IS 'Group of tags';
+
+-- Column comments
+
+COMMENT ON COLUMN public.tag_group.tg_name IS 'Nom du groupe';
+ALTER TABLE public.tag_group ADD CONSTRAINT tag_group_pk PRIMARY KEY (tg_id);
+
+-- public.jnt_tag_group_tag definition
+
+-- Drop table
+
+-- DROP TABLE public.jnt_tag_group_tag;
+
+CREATE TABLE public.jnt_tag_group_tag (
+ tag_group_id int8 NOT NULL,
+ tag_id int8 NOT NULL,
+ jt_id serial NOT NULL,
+ CONSTRAINT jnt_tag_group_tag_pkey PRIMARY KEY (jt_id),
+ CONSTRAINT jnt_tag_group_tag_un UNIQUE (tag_id, tag_group_id)
+);
+COMMENT ON TABLE public.jnt_tag_group_tag IS 'Many to Many table betwwen tag and tag group';
+
+
+-- public.jnt_tag_group_tag foreign keys
+
+ALTER TABLE public.jnt_tag_group_tag ADD CONSTRAINT jnt_tag_group_tag_fk FOREIGN KEY (tag_id) REFERENCES tags(t_id) ON UPDATE CASCADE ON DELETE CASCADE;
+ALTER TABLE public.jnt_tag_group_tag ADD CONSTRAINT jnt_tag_group_tag_fk_1 FOREIGN KEY (tag_group_id) REFERENCES tag_group(tg_id) ON UPDATE CASCADE ON DELETE CASCADE;
\ No newline at end of file