noalyss Version-9
ajax_operation_tag.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
22if (!defined('ALLOWED'))
23 die('Appel direct ne sont pas permis');
24
25/**
26 * @file
27 * @brief manage the ajax calls for adding , deleting tag on operations
28 */
29try
30{
31 $op=$http->request('op');
32 $jrn_id=$http->request('jrn_id', "number");
33}
34catch (Exception $ex)
35{
36 echo $ex->getMessage();
37}
38
39// Security : check ledger accessible
40global $g_user;
41$ledger=$cn->get_value("select jr_def_id from jrn where jr_id=$1", [$jrn_id]);
42
43if ($g_user->get_ledger_access($ledger)!='W')
44{
45 record_log("AJT0001");
46 return;
47}
48switch ($op)
49{
50 case 'operation_tag_select':
51 //--------------------------------------------------------------------------------------------------
52 // Display a list of available tag
53 //--------------------------------------------------------------------------------------------------
54 ob_start();
56 echo $tag_operation->select($ctl);
57
58 //------------------- Propose to add a tag
59
60 $js=sprintf("onclick=\"show_tag('%s','%s','%s','j')\"", Dossier::id(), '', '-1');
61 if ($g_user->check_action(TAGADD)==1)
62 {
63 echo HtmlInput::button("tag_add", _("Création étiquette"), $js);
64 }
65 echo HtmlInput::button_close("tag_div");
66
67 $response=ob_get_clean();
68 if (headers_sent()&& DEBUGNOALYSS > 0 )
69 {
70 echo $response;
71 }
72 else
73 {
74 header('Content-type: text/xml; charset=UTF-8');
75 }
77 echo <<<EOF
78<?xml version="1.0" encoding="UTF-8"?>
79 <data>
80 <ctl></ctl>
81 <code>$html</code>
82 </data>
83EOF;
84 return;
85 case 'operation_tag_add':
86 //--------------------------------------------------------------------------------------------------
87 // Display all the tags attached to this operation
88 //--------------------------------------------------------------------------------------------------
90 $tag_operation->set_jrn_id($jrn_id);
91 $pref=$http->request("ctl");
92
93 if ($http->request("isgroup")=='t')
94 {
95 $tag_operation->tag_add($http->request('t_id', "number"));
96 }
97 else
98 {
99 // Add all the tag from the group
100 $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 ",
101 [$http->request("t_id", "number")]);
102 $nb_atag=count($aTag);
103 if ($nb_atag>0)
104 {
105 for ($i=0; $i<$nb_atag; $i++)
106 {
107 $tag_operation->tag_add($aTag[$i]['t_id']);
108 }
109 }
110 }
111
112 ob_start();
113
114 $tag_operation->tag_cell($ctl);
115
116 $response=ob_get_clean();
117 if (headers_sent()&& DEBUGNOALYSS > 0)
118 {
119 echo $response;
120 }
121 else
122 {
123 header('Content-type: text/xml; charset=UTF-8');
124 }
126 echo <<<EOF
127<?xml version="1.0" encoding="UTF-8"?>
128<data>
129<ctl></ctl>
130<code>$html</code>
131</data>
132EOF;
133 return;
134 break;
135 case 'operation_tag_remove':
137 $tag_operation->set_jrn_id($jrn_id);
138 $pref=$http->request("ctl");
139 $tag_operation->tag_remove($http->request("t_id", "number"));
140
141 ob_start();
142
143 $tag_operation->tag_cell($pref);
144
145 $response=ob_get_clean();
146 if (headers_sent()&& DEBUGNOALYSS > 0)
147 {
148 echo $response;
149 }
150 else
151 {
152 header('Content-type: text/xml; charset=UTF-8');
153 }
155 echo <<<EOF
156<?xml version="1.0" encoding="UTF-8"?>
157<data>
158<ctl></ctl>
159<code>$html</code>
160</data>
161EOF;
162 return;
163 break;
164}
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
if(headers_sent() &&DEBUGNOALYSS > 0) $html
$op
Definition: ajax_admin.php:38
catch(Exception $ex) global $g_user
$ex
Definition: balance.inc.php:45
static id()
return the 'gDossier' value after a check
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
concerns the tags linked to an accountancy writing
const TAGADD
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...
$tag_operation