noalyss Version-9
tag_group_mtable.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
21
22
23/**
24 * @file
25 * @brief manage tag_group table
26 *
27 *
28 */
29
30/**
31 * @class Tag_Group_MTable
32 * @brief manage tag_group table
33 *
34 *
35 */
36require_once NOALYSS_INCLUDE.'/database/tag_group_sql.class.php';
37
39{
40
41 function __construct(Tag_Group_SQL $p_obj)
42 {
43 parent::__construct($p_obj);
44 $this->set_property_visible("tg_id", false);
45 $this->set_property_updatable("tg_id", false);
46 $this->set_col_label("tg_name", _('Nom'));
47 }
48
49 function input()
50 {
51
52
53 parent::input();
54
55
56 echo '<div id="d_tag_group_add">';
57 $this->input_tag();
58 echo '</div>';
59 }
60
61 /**
62 * Display a select widget for adding new tag
63 */
64 function input_tag()
65 {
67 $data_sql=$this->get_table();
68
69 // Display containing tag_id
70 $aTag=$cn->get_array("select jt_id,t_tag
71 from tags join jnt_tag_group_tag on (tag_id=t_id)
72 where tag_group_id=$1 order by 2", [$data_sql->tg_id]);
73 // not possible to add tag to inexisting group
74 if ( $data_sql->tg_id == -1){
75 return;
76 }
77 echo '<ol id="ol_tag_group">';
78 $nb=count($aTag);
80 for ($i=0; $i<$nb; $i++)
81 {
82 // js to remove id
83 $js=Icon_Action::trash(uniqid(), sprintf("o_tagGroup.remove('%s','%s')", $aTag[$i]['jt_id'], $dossier_id));
84 printf('<li id="t%s"> %s %s %s</li>', $aTag[$i]['jt_id'],$aTag[$i]['t_tag'],$dossier_id,$js);
85 }
86 echo '</ol>';
87
88
89 // Add new tag
90 $select=new ISelect("is_tag", [], "s_tag_group");
91 $select->value=$cn->make_array("select t_id,t_tag
92 from tags
93 where
94 t_id not in (select tag_id from jnt_tag_group_tag
95 where tag_group_id=$1 ) order by 2", 0,[$data_sql->tg_id]);
96 echo $select->input();
97 echo HtmlInput::button('b_add_group', _("Ajout"),
98 sprintf("onclick=\"o_tagGroup.add_tag('%s','%s','%s'); \"", $data_sql->tg_id, $select->id, $dossier_id));
99 }
100
101}
$dossier_id
Definition: ajax_poste.php:43
static id()
return the 'gDossier' value after a check
static connect()
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_col_label($p_key, $p_display)
set the name to display for a column
manage tag_group table
__construct(Tag_Group_SQL $p_obj)
input()
display into a dialog box the datarow in order to be appended or modified.
input_tag()
Display a select widget for adding new tag.