noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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 */
26/*
27 * @var $g_user Noalyss_User
28 */
29global $g_user;
30// security
31if ( $g_user->check_module("C0CARD") == 0 ) {
32
33 record_log(new \Exception("C0CARD: not authorized"));
34 return;
35}
36
38
39try
40{
41 $action=$http->request("action", "string");
42}
43catch (Exception $ex)
44{
45 record_log("ACA01".$ex->getMessage().$ex->getTraceAsString());
46}
47
48if ($action=="enable_search")
49{
50 $value=$http->request("value");
51 $ad_id=$http->request("ad_id");
52 $name=$http->request("name");
53 if ($value==1)
54 {
55 $cn->exec_sql("update attr_def set ad_search_followup=0 where ad_id=$1", [$ad_id]);
56 $value=0;
57 }
58 else
59 {
60 $cn->exec_sql("update attr_def set ad_search_followup=1 where ad_id=$1", [$ad_id]);
61 $value=1;
62 }
63 $ic=new Inplace_Switch($name, $value);
64 $ic->set_callback("ajax_misc.php");
65 $ic->add_json_param("op", "card");
66 $ic->add_json_param("gDossier", Dossier::id());
67 $ic->add_json_param("op2", "attribute");
68 $ic->add_json_param("action", "enable_search");
69 $ic->add_json_param("ad_id", $ad_id);
70 $ic->add_json_param("ctl", $ad_id);
71 echo $ic->input();
72}
73else
74{
77 $mtable->add_json_param("op", "card");
78 $mtable->add_json_param("op2", "attribute");
79 $mtable->set_callback("ajax_misc.php");
80 $mtable->set_object_name($http->request("ctl"));
81 $ad_id=$http->request("p_id");
82 $mtable->get_table()->setp("ad_id", $ad_id);
83 switch ($action)
84 {
85 case "input":
86 $mtable->set_pk($ad_id);
87 if ( $ad_id < 0 ) $mtable->get_table()->set("ad_search_followup",0);
88 $mtable->send_header();
89 echo $mtable->ajax_input()->saveXML();
90
91 break;
92 case "save":
93 $mtable->set_pk($http->request("p_id"));
94 $mtable->send_header();
95 echo $mtable->ajax_save()->saveXML();
96
97
98 break;
99 case "delete":
100 $mtable->set_pk($http->request("p_id"));
101 $mtable->send_header();
102 echo $mtable->ajax_delete()->saveXML();
103 break;
104 default:
105 break;
106 }
107}
108?>
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
global $g_user
if no group available , then stop
catch(Exception $e) $obj
$ex
ORM of the table public.attr_def.
manage the table attr_def
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.