noalyss Version-9
ajax_follow_up_LOCAL_2734795.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 */
28global $http,$cn;
29$op=$http->request('op');
30global $g_user;
31
32/*
33 * Ajax for modifying the description , does not support ITextarea + enrich text
34 *
35 */
36if ($op=='update_comment_followUp')
37{
38 $input=$http->request('input');
39 $action=$http->request('ieaction', 'string', 'display');
40 $d_id=$http->request('d_id', "number");
41
42 // Build inplace input
43 $inplace_description=Inplace_Edit::build($input);
44 $inplace_description->set_callback("ajax_misc.php");
45 $inplace_description->add_json_param("d_id", $d_id);
46 $inplace_description->add_json_param("gDossier", Dossier::id());
47 $inplace_description->add_json_param("op", "update_comment_followUp");
48 switch ($action)
49 {
50 case 'display':
51 echo $inplace_description->ajax_input();
52
53 break;
54 case 'ok':
55 if ($g_user->check_action(VIEWDOC)==1)
56 {
57 $value=$http->request('value');
58 $doc=new Document($cn, $d_id);
59 $doc->get();
60 if ($g_user->can_write_action($doc->ag_id))
61 {
62 // retrieve the document
63 $doc->update_description(strip_tags($value));
64 }
65 $inplace_description->set_value($value);
66 }
67
68 echo $inplace_description->value();
69 break;
70 case 'cancel':
71 echo $inplace_description->value();
72 break;
73 default:
74 throw new Exception(__FILE__.':'.__LINE__.'Invalide value');
75 break;
76 }
77 return;
78}
79
80
81// Modify followup
82if ($op == 'followup_comment_oneedit') {
83 $input=$http->request('input');
84 $action=$http->request('ieaction', 'string', 'display');
85 $agc_id=$http->request('agc_id', "number");
86 $ag_id=$http->request('ag_id', "number");
87 global $g_user;
88 // check comment is the comment of this ag_id
89 $ctl_ag_id=$cn->get_value("select ag_id from action_gestion_comment where agc_id=$1",[$agc_id]);
90 if ( $agc_id != -1 && $ctl_ag_id != $ag_id) {
91 record_log("FLP02 ag_id [$ag_id] <> ctl_ag_id [$ctl_ag_id]");
92 return;
93 }
94 // Build inplace input
95 $inplace_description=Inplace_Edit::build($input);
96 $inplace_description->set_callback("ajax_misc.php");
97
98 $inplace_description->add_json_param("ag_id", $ag_id);
99 $inplace_description->add_json_param("gDossier", Dossier::id());
100 $inplace_description->add_json_param("op", "followup_comment_oneedit");
101 switch ($action)
102 {
103 case 'display':
104 $inplace_description->add_json_param("agc_id", $agc_id);
105 echo $inplace_description->ajax_input();
106
107 break;
108 case 'ok':
109 if ($g_user->check_action(VIEWDOC)==1)
110 {
111 $value=$http->request('value');
112 if ($g_user->can_write_action($ag_id))
113 {
114 // retrieve the document
115 if ( $agc_id==-1) {
116 $agc_id= $cn->get_value("insert into action_gestion_comment(ag_id,agc_comment,agc_comment_raw,tech_user)
117 values ($1,$2,$3,$4) returning agc_id" ,[$ag_id,strip_tags($value),$value,$g_user->login]);
118 } else {
119 $cn->exec_sql("update action_gestion_comment set agc_comment=$1,tech_user=$2 ,
120 agc_comment_raw=$3
121 where agc_id=$4
122 " ,[strip_tags($value),$g_user->login,$value,$agc_id]);
123 }
124
125 }
126 $inplace_description->add_json_param("agc_id", $agc_id);
127 $inplace_description->set_value($value);
128 }
129 echo $inplace_description->value();
130 break;
131 case 'cancel':
132 $inplace_description->add_json_param("agc_id", $agc_id);
133 echo '<pre>';
134 echo $inplace_description->value();
135 echo '</pre>';
136 break;
137 default:
138 throw new Exception(__FILE__.':'.__LINE__.'Invalide value');
139 break;
140 }
141 return;
142}
143
144/**************************************************************************
145 * See list of follow-up evebt
146 *************************************************************************/
147if ($op =="view_followup_card")
148{
149 $div=$http->get("div");
150 $card=new Fiche($cn,$http->get("f_id","number"));
151 echo HtmlInput::title_box("Suivi ".h($card->strAttribut(ATTR_DEF_NAME)),$div);
153 $followup=new Follow_Up($cn);
154 echo $followup->view_list($query);
155 echo \HtmlInput::button_close($div);
156 return;
157}
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
h( $row[ 'oa_description'])
$input
$div
global $doc
Class Document corresponds to the table document.
static id()
return the 'gDossier' value after a check
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
static create_query($cn, $p_array=null)
Get date from $_GET and create the sql stmt for the query.
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static build($p_serialize)
build a Inplace_Edit object from a serialized string (ajax json parameter = input)
const ATTR_DEF_NAME
Definition: constant.php:216
const ATTR_DEF_QUICKCODE
Definition: constant.php:237
const VIEWDOC