Tag : add color to tags

This commit is contained in:
sparkyx 2020-11-10 13:54:43 +01:00
parent fb1ade420a
commit 656ab45372
12 changed files with 350 additions and 18 deletions

View file

@ -3804,3 +3804,18 @@ function json_concat(p_json1,p_json2)
return result;
}
/**
* this function unchecks other checkbox , it mimics the way a radio behaves
* @param string p_click is the DOM id of the checkbox you clicked
* @param string p_name is the name of all the checkbox to uncheck
*/
function uncheck_other(p_click,p_name)
{
var aCheckbox=document.getElementsByName(p_name);
if (aCheckbox.length == 0) return;
var i=0;
for (i=0;i<aCheckbox.length;i++) {
aCheckbox[i].checked=false;
}
p_click.checked=true;
}

View file

@ -2451,4 +2451,90 @@ span.tagcell {
#action_add_action2_list {
height:15rem;
overflow: auto;
}
/*********************************************************************************************************************
* Color for tag
********************************************************************************************************************/
.tagcell-color1 {
/* Nothing no color */
}
.tagcell-color2 {
background-color: #002ba3 !important;
color : white !important;
}
.tagcell-color3 {
background-color: #336699 !important;
color: white !important;
}
.tagcell-color4 {
background-color: #5d90cd !important;
color: white !important;
}
.tagcell-color5 {
background-color: #C2E3FC !important;
color: #002ba3 !important;
}
.tagcell-color6 {
background-color: #006318 !important;
color : white !important;
}
.tagcell-color7 {
background-color: #008000 !important;
color : white !important;
}
.tagcell-color8 {
background-color: #00D000 !important;
color : white !important;
}
.tagcell-color9 {
background-color: #87D087 !important;
color: white !important;
}
.tagcell-color10 {
background-color: #C8EEC8 !important;
color: #006318 !important;
}
.tagcell-color11 {
background-color: red !important;
color: #edeff4 !important;
}
.tagcell-color12 {
background-color: #9D0244 !important;
color:#edeff4 !important;
}
.tagcell-color13 {
background-color: #C14064 !important;
color: #edeff4 !important;
}
.tagcell-color14 {
background-color: #F07396 !important;
color: #edeff4 !important;
}
.tagcell-color15 {
background-color: #F2AABE !important;
color: red !important;
}
.tagcell-color16 {
background-color: #77420A !important;
color: #edeff4 !important;
}
.tagcell-color17 {
background-color: #B06F2A !important;
color: #edeff4 !important;
}
.tagcell-color18 {
background-color: orange !important;
color: #edeff4 !important;
}
.tagcell-color19 {
background-color: #F2CFAA !important;
color: red !important;
}
.tagcell-color20 {
background-color: yellow !important;
color: orangered !important;
}

View file

@ -2497,3 +2497,89 @@ span.tagcell {
height:15rem;
overflow: auto;
}
/*********************************************************************************************************************
* Color for tag
********************************************************************************************************************/
.tagcell-color1 {
/* Nothing no color */
}
.tagcell-color2 {
background-color: #002ba3 !important;
color : white !important;
}
.tagcell-color3 {
background-color: #336699 !important;
color: white !important;
}
.tagcell-color4 {
background-color: #5d90cd !important;
color: white !important;
}
.tagcell-color5 {
background-color: #C2E3FC !important;
color: #002ba3 !important;
}
.tagcell-color6 {
background-color: #006318 !important;
color : white !important;
}
.tagcell-color7 {
background-color: #008000 !important;
color : white !important;
}
.tagcell-color8 {
background-color: #00D000 !important;
color : white !important;
}
.tagcell-color9 {
background-color: #87D087 !important;
color: white !important;
}
.tagcell-color10 {
background-color: #C8EEC8 !important;
color: #006318 !important;
}
.tagcell-color11 {
background-color: red !important;
color: #edeff4 !important;
}
.tagcell-color12 {
background-color: #9D0244 !important;
color:#edeff4 !important;
}
.tagcell-color13 {
background-color: #C14064 !important;
color: #edeff4 !important;
}
.tagcell-color14 {
background-color: #F07396 !important;
color: #edeff4 !important;
}
.tagcell-color15 {
background-color: #F2AABE !important;
color: red !important;
}
.tagcell-color16 {
background-color: #77420A !important;
color: #edeff4 !important;
}
.tagcell-color17 {
background-color: #B06F2A !important;
color: #edeff4 !important;
}
.tagcell-color18 {
background-color: orange !important;
color: #edeff4 !important;
}
.tagcell-color19 {
background-color: #F2CFAA !important;
color: red !important;
}
.tagcell-color20 {
background-color: yellow !important;
color: orangered !important;
}

View file

@ -2384,4 +2384,91 @@ span.tagcell {
#action_add_action2_list {
height:15rem;
overflow: auto;
}
/*********************************************************************************************************************
* Color for tag
********************************************************************************************************************/
.tagcell-color1 {
/* Nothing no color */
}
.tagcell-color2 {
background-color: #002ba3 !important;
color : white !important;
}
.tagcell-color3 {
background-color: #336699 !important;
color: white !important;
}
.tagcell-color4 {
background-color: #5d90cd !important;
color: white !important;
}
.tagcell-color5 {
background-color: #C2E3FC !important;
color: #002ba3 !important;
}
.tagcell-color6 {
background-color: #006318 !important;
color : white !important;
}
.tagcell-color7 {
background-color: #008000 !important;
color : white !important;
}
.tagcell-color8 {
background-color: #00D000 !important;
color : white !important;
}
.tagcell-color9 {
background-color: #87D087 !important;
color: white !important;
}
.tagcell-color10 {
background-color: #C8EEC8 !important;
color: #006318 !important;
}
.tagcell-color11 {
background-color: red !important;
color: #edeff4 !important;
}
.tagcell-color12 {
background-color: #9D0244 !important;
color:#edeff4 !important;
}
.tagcell-color13 {
background-color: #C14064 !important;
color: #edeff4 !important;
}
.tagcell-color14 {
background-color: #F07396 !important;
color: #edeff4 !important;
}
.tagcell-color15 {
background-color: #F2AABE !important;
color: red !important;
}
.tagcell-color16 {
background-color: #77420A !important;
color: #edeff4 !important;
}
.tagcell-color17 {
background-color: #B06F2A !important;
color: #edeff4 !important;
}
.tagcell-color18 {
background-color: orange !important;
color: #edeff4 !important;
}
.tagcell-color19 {
background-color: #F2CFAA !important;
color: red !important;
}
.tagcell-color20 {
background-color: yellow !important;
color: orangered !important;
}

View file

@ -36,7 +36,7 @@ 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")]);
$aTag=$cn->get_array("select t_id,t_tag ,t_color 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++){

View file

@ -12,9 +12,10 @@ require_once NOALYSS_INCLUDE.'/class/tag.class.php';
ob_start();
$tag=new Tag($cn);
$http=new HttpInput();
$tag->data->t_id=$http->get("tag","number");
if ($tag->data->t_id == -1 && $g_user->check_action(TAGADD) == 0 ) return;
$tag->data->load();
$data=$tag->get_data();
$data->t_id=$http->get("tag","number");
if ($data->t_id == -1 && $g_user->check_action(TAGADD) == 0 ) return;
$data->load();
echo HtmlInput::title_box(_("Détail du dossier ou étiquette"), "tag_div","close","","y");
?>
@ -32,9 +33,10 @@ else :
<?php endif; ?>
<?php
echo dossier::hidden();
echo HtmlInput::hidden('t_id', $_GET['tag']);
echo HtmlInput::hidden('ac',$_GET['ac']);
$data=$tag->data;
echo HtmlInput::hidden('t_id', $http->get('tag') );
echo HtmlInput::hidden('ac',$http->get('ac'));
require_once NOALYSS_TEMPLATE.'/tag_detail.php';
echo HtmlInput::submit("save_tag_sb", "Valider");
echo HtmlInput::button_close("tag_div");
@ -43,8 +45,12 @@ else :
</form>
<?php
$response= ob_get_clean();
$html=escape_xml($response);
if (headers_sent() && DEBUG ) {
echo $response;
}else {
header('Content-type: text/xml; charset=UTF-8');
}
$html=escape_xml($response);
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>

View file

@ -663,7 +663,8 @@ class Follow_Up
ag_title,dt_value,ag_ref, ag_priority,ag_state,
coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest,
(select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=1) as name,
array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags
array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags,
array_to_string((select array_agg(t1.t_color) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags_color
from action_gestion as ag
join document_type on (ag_type=dt_id)
join document_state on (ag_state=s_id)
@ -769,7 +770,19 @@ class Follow_Up
$r.='<td>'.$href.
h($row['ag_title'])."</A></td>";
$r.="<td>".$row['s_value']."</td>";
$r.="<td>".$href."<span style=\"font-size:75%\">".h($row['tags']).'</span>'.'</a>'."</td>";
$r.="<td>";
if ($row['tags']!=""){
$r.=$href;
$aColor=explode(",", $row["tags_color"]);
$aTags=explode(",", $row["tags"]);
$nb_tag=count($aTags);
for ( $x=0;$x<$nb_tag;$x++) {
$r.=sprintf('<span style="font-size:75%%" class="tagcell-color%s">%s</span>',$aColor[$x],$aTags[$x]);
$r.="&nbsp;";
} // end loop $x
$r.='</a>';
}
$r.="</td>";
$r.="<td>".$href.h($row['dest']).'</a>'."</td>";
@ -1488,7 +1501,7 @@ class Follow_Up
{
if ($this->ag_id==0)
return;
$sql='select b.ag_id,b.t_id,b.at_id,a.t_tag'
$sql='select b.ag_id,b.t_id,b.at_id,a.t_tag,a.t_color'
.' from '
.' tags as a join action_tags as b on (a.t_id=b.t_id)'
.' where ag_id=$1 '
@ -1537,7 +1550,7 @@ class Follow_Up
$c=count($a_tag);
for ($e=0; $e<$c; $e++)
{
echo '<span class="tagcell">';
echo '<span class="tagcell tagcell-color'.$a_tag[$e]['t_color'].'">';
echo $a_tag[$e]['t_tag'];
if ($g_user->can_write_action($this->ag_id)==true && $p_view != 'READ')
{

View file

@ -21,12 +21,24 @@ require_once NOALYSS_INCLUDE.'/database/tag_sql.class.php';
class Tag
{
private $data; //<! Tag_SQL
function __construct($p_cn,$id=-1)
{
$this->cn=$p_cn;
$this->data=new Tag_SQL($p_cn,$id);
}
/**
public function get_data()
{
return $this->data;
}
public function set_data($data)
{
$this->data=$data;
return $this;
}
/**
* Show the list of available tag
* @return HTML
*/
@ -42,11 +54,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
$ret=$this->cn->exec_sql(" select t_id,t_tag,t_description,'t' as tag_type ,t_color
from tags
where t_actif='Y'
union all
select tg_id,tg_name ,'G','g' from tag_group order by 2");
select tg_id,tg_name ,'G','g' ,1 from tag_group order by 2");
require_once NOALYSS_TEMPLATE.'/tag_select.php';
}
/**
@ -73,6 +85,7 @@ class Tag
$this->data->t_tag= strip_tags($p_array['t_tag']);
$this->data->t_description=strip_tags($p_array['t_description']);
$this->data->t_actif=$p_array['t_actif'];
$this->data->t_color=$p_array['tagcell_color'];
$this->data->save();
}
function remove($p_array)

View file

@ -37,12 +37,14 @@ class Tag_SQL extends Noalyss_SQL
, "t_tag" => "t_tag"
, "t_description" => "t_description"
,'t_actif'=>'t_actif'
,'t_color'=>'t_color'
);
$this->type = array(
"t_id" => "numeric"
, "t_tag" => "text"
, "t_description" => "text"
,'t_actif'=>"text"
,'t_color'=>"numeric"
);
$this->default = array(
"t_id" => "auto",

View file

@ -16,6 +16,8 @@ $t_actif->value=[
['label'=>_('Non actif'),'value'=>'N']
];
$t_actif->selected=$data->t_actif;
$icheckbox=new ICheckBox("tagcell_color");
$icheckbox->javascript='onclick="uncheck_other(this,\'tagcell_color\');"';
?>
<p>
<?php echo _("Etiquette (tag)")?> : <?php echo $t_tag->input(); ?>
@ -24,7 +26,29 @@ $t_actif->selected=$data->t_actif;
<?php echo _("Description")?> : <?php echo $t_description->input(); ?>
</p>
<p>
<?=_("Etiquette(tag) actif") ?><?=$t_actif->input()?>
<?=_("Couleur")?>
</p>
<?php
if ( $data->t_id == '-1') $data->t_color=1;
$nb_color=20;
for ($i=1 ; $i != $nb_color+1 ; $i++ ) {
?>
<span class="tagcell <?="tagcell-color".$i?>">
<?=_("Exemple").$i ?>
<?php $icheckbox->value=$i;
if ( $data->t_color==$i) { $icheckbox->set_check($i);} else {$icheckbox->selected=false;}
echo $icheckbox->input();
?>
</span>
<?php if ( $i % 5 == 0 ) echo '<br>';?>
<?php
} // end loop $i
?>
<p>
<?=_("Etiquette actif") ?><?=$t_actif->input()?>
</p>
<?php
// If exist you can remove it

View file

@ -29,7 +29,7 @@ $ac=$http->request('ac');
$row=Database::fetch_array($ret, $i);
?>
<tr class="<?php echo (($i%2==0)?'even':'odd');?>">
<td>
<td class="tagcell-color<?=$row['t_color']?>">
<?php
$js=sprintf("show_tag('%s','%s','%s','p')",$gDossier,$ac,$row['t_id']);
echo HtmlInput::anchor($row['t_tag'], "", "onclick=\"$js\"");

View file

@ -33,7 +33,7 @@ if (isNumber($ag_id) == 0 ) die ('ERROR : parameters invalid');
$row=Database::fetch_array($ret, $i);
?>
<tr class="<?php echo (($i%2==0)?'even':'odd');?>">
<td>
<td class="tagcell-color<?=$row['t_color']?>">
<?php
$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\"");