noalyss Version-9
ajax_card_attribute.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 * @file
24 * @brief answer to card_attr_inc.php
25 */
26global $g_user;
27// security
28$g_user->can_request("CCARDAT");
29
31
32try
33{
34 $action=$http->request("action", "string");
35}
36catch (Exception $ex)
37{
38 record_log("ACA01".$ex->getMessage().$ex->getTraceAsString());
39}
40
41if ($action=="enable_search")
42{
43 $value=$http->request("value");
44 $ad_id=$http->request("ad_id");
45 $name=$http->request("name");
46 if ($value==1)
47 {
48 $cn->exec_sql("update attr_def set ad_search_followup=0 where ad_id=$1", [$ad_id]);
49 $value=0;
50 }
51 else
52 {
53 $cn->exec_sql("update attr_def set ad_search_followup=1 where ad_id=$1", [$ad_id]);
54 $value=1;
55 }
56 $ic=new Inplace_Switch($name, $value);
57 $ic->set_callback("ajax_misc.php");
58 $ic->add_json_param("op", "card");
59 $ic->add_json_param("gDossier", Dossier::id());
60 $ic->add_json_param("op2", "attribute");
61 $ic->add_json_param("action", "enable_search");
62 $ic->add_json_param("ad_id", $ad_id);
63 $ic->add_json_param("ctl", $ad_id);
64 echo $ic->input();
65}
66else
67{
70 $mtable->add_json_param("op", "card");
71 $mtable->add_json_param("op2", "attribute");
72 $mtable->set_callback("ajax_misc.php");
73 $mtable->set_object_name($http->request("ctl"));
74 $ad_id=$http->request("p_id");
75 $mtable->get_table()->setp("ad_id", $ad_id);
76 switch ($action)
77 {
78 case "input":
79 $mtable->set_pk($ad_id);
80 if ( $ad_id < 0 ) $mtable->get_table()->set("ad_search_followup",0);
81 $mtable->send_header();
82 echo $mtable->ajax_input()->saveXML();
83
84 break;
85 case "save":
86 $mtable->set_pk($http->request("p_id"));
87 $mtable->send_header();
88 echo $mtable->ajax_save()->saveXML();
89
90
91 break;
92 case "delete":
93 $mtable->set_pk($http->request("p_id"));
94 $mtable->send_header();
95 echo $mtable->ajax_delete()->saveXML();
96 break;
97 default:
98 break;
99 }
100}
101?>
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
$action
global $g_user
$ex
Definition: balance.inc.php:45
ORM of the table public.attr_def.
manage the table attr_def
static id()
return the 'gDossier' value after a check
manage the http input (get , post, request) and extract from an array
A switch let you switch between 2 values : 0 and 1, it is used to replace the check.