noalyss Version-9
ajax_anc_plan.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS 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 NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder dany@alchimerys.be
22 /**
23 *\file
24 *\brief ajax answer to update or change name or description of an analytic plan
25 */
26if (!defined('ALLOWED'))
27 die('Appel direct ne sont pas permis');
28
29
30if ( $g_user->check_module("PLANANC ") ) die("forbidden");
31
32$input = $http->request("input");
33$action = $http->request("ieaction", "string", "display");
34$pa_id=$http->post("id","number");
35
37$answer->add_json_param("gDossier", Dossier::id());
38$answer->set_callback("ajax_misc.php");
39$answer->add_json_param("action","anc_updatedescription");
40$answer->add_json_param("op","anc_updatedescription");
41$answer->add_json_param("id",$pa_id);
42
43$input=$answer->get_input();
44if ($action=="display") {
45 echo $answer->ajax_input() ;
46}
47if ($action=="ok") {
48 $value=$http->post("value");
49 if ( $input->name=="pa_name" && trim($value) == "")
50 {
51 echo _("Le nom ne peut ĂȘtre vide"),$answer->ajax_input();
52 }else {
53 if ($input->name=="pa_name") {
54 $cn->exec_sql(" update plan_analytique set pa_name=$1 where pa_id=$2",array($value,$pa_id));
55 }
56 if ($input->name=="pa_description") {
57 if ( trim($value ) == "" ) $value=NULL;
58 $cn->exec_sql(" update plan_analytique set pa_description=$1 where pa_id=$2",array($value,$pa_id));
59 if ( trim($value ) == NULL ) $value=_("Aucune description");
60 }
61 $answer->set_value($value);
62 echo $answer->value();
63 }
64}
65if ($action=="cancel") {
66 echo $answer->value();
67}
global $g_user
if no group available , then stop
$pa_id
$input
$answer
$action
static id()
return the 'gDossier' value after a check
static build($p_serialize)
build a Inplace_Edit object from a serialized string (ajax json parameter = input)