noalyss Version-9
ajax_follow_up_REMOTE_2737293.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 * NOALYSS 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 (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22if (!defined('ALLOWED'))
23 die('Appel direct ne sont pas permis');
24/**
25 * @file
26 * @brief Update description on file
27 */
28$op=$http->request('op');
29global $g_user;
30
31/*
32 * Ajax for modifying the description , does not support ITextarea + enrich text
33 *
34 */
35if ($op=='update_comment_followUp')
36{
37 $input=$http->request('input');
38 $action=$http->request('ieaction', 'string', 'display');
39 $d_id=$http->request('d_id', "number");
40
41 // Build inplace input
42 $inplace_description=Inplace_Edit::build($input);
43 $inplace_description->set_callback("ajax_misc.php");
44 $inplace_description->add_json_param("d_id", $d_id);
45 $inplace_description->add_json_param("gDossier", Dossier::id());
46 $inplace_description->add_json_param("op", "update_comment_followUp");
47 switch ($action)
48 {
49 case 'display':
50 echo $inplace_description->ajax_input();
51
52 break;
53 case 'ok':
54 if ($g_user->check_action(VIEWDOC)==1)
55 {
56 $value=$http->request('value');
57 $doc=new Document($cn, $d_id);
58 $doc->get();
59 if ($g_user->can_write_action($doc->ag_id))
60 {
61 // retrieve the document
62 $doc->update_description(strip_tags($value));
63 }
64 $inplace_description->set_value($value);
65 }
66
67 echo $inplace_description->value();
68 break;
69 case 'cancel':
70 echo $inplace_description->value();
71 break;
72 default:
73 throw new Exception(__FILE__.':'.__LINE__.'Invalide value');
74 break;
75 }
76 return;
77}
78
79
80// Modify followup
81if ($op == 'followup_comment_oneedit') {
82 $input=$http->request('input');
83 $action=$http->request('ieaction', 'string', 'display');
84 $agc_id=$http->request('agc_id', "number");
85 $ag_id=$http->request('ag_id', "number");
86 global $g_user;
87 // check comment is the comment of this ag_id
88 $ctl_ag_id=$cn->get_value("select ag_id from action_gestion_comment where agc_id=$1",[$agc_id]);
89 if ( $agc_id != -1 && $ctl_ag_id != $ag_id) {
90 record_log("FLP02 ag_id [$ag_id] <> ctl_ag_id [$ctl_ag_id]");
91 return;
92 }
93 // Build inplace input
94 $inplace_description=Inplace_Edit::build($input);
95 $inplace_description->set_callback("ajax_misc.php");
96
97 $inplace_description->add_json_param("ag_id", $ag_id);
98 $inplace_description->add_json_param("gDossier", Dossier::id());
99 $inplace_description->add_json_param("op", "followup_comment_oneedit");
100 switch ($action)
101 {
102 case 'display':
103 $inplace_description->add_json_param("agc_id", $agc_id);
104 echo $inplace_description->ajax_input();
105
106 break;
107 case 'ok':
108 if ($g_user->check_action(VIEWDOC)==1)
109 {
110 $value=$http->request('value');
111 if ($g_user->can_write_action($ag_id))
112 {
113 // retrieve the document
114 if ( $agc_id==-1) {
115 $agc_id= $cn->get_value("insert into action_gestion_comment(ag_id,agc_comment,agc_comment_raw,tech_user)
116 values ($1,$2,$3,$4) returning agc_id" ,[$ag_id,strip_tags($value),$value,$g_user->login]);
117 } else {
118 $cn->exec_sql("update action_gestion_comment set agc_comment=$1,tech_user=$2 ,
119 agc_comment_raw=$3
120 where agc_id=$4
121 " ,[strip_tags($value),$g_user->login,$value,$agc_id]);
122 }
123
124 }
125 $inplace_description->add_json_param("agc_id", $agc_id);
126 $inplace_description->set_value($value);
127 }
128 echo $inplace_description->value();
129 break;
130 case 'cancel':
131 $inplace_description->add_json_param("agc_id", $agc_id);
132 echo '<pre>';
133 echo $inplace_description->value();
134 echo '</pre>';
135 break;
136 default:
137 throw new Exception(__FILE__.':'.__LINE__.'Invalide value');
138 break;
139 }
140 return;
141}
142/********************************************************************************************************************
143 * list the existing filter for followup
144 ******************************************************************************************************************/
145if ( $op == 'list_filter_followup') {
146 $followup_filter=Follow_Up_Filter::display_list($g_user->getLogin());
147 return;
148}
149/*******************************************************************************************************************
150 * delete_filter_followup(p_dossier,filter_id)
151 *******************************************************************************************************************/
152if ( $op == 'delete_filter_followup') {
153 $cn->exec_delete("delete from action_gestion_id where af_id=$1 and af_user=$2",
154 [$http->get("filter_id","number"),$g_user->getLogin()]);
155}
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
$ag_id
Definition: action.inc.php:54
$action
$input
global $doc
Class Document corresponds to the table document.
static id()
return the 'gDossier' value after a check
static display_list($login)
display the list of recorded search
static build($p_serialize)
build a Inplace_Edit object from a serialized string (ajax json parameter = input)
const VIEWDOC