noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
ajax_pcmn_update.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 2015 Author Dany De Bontridder danydb@aevalys.eu
22 // require_once '.php';
23 if (!defined('ALLOWED'))
24  die('Appel direct ne sont pas permis');
25 
27 
28 // Security check if user can connect and update
29 if ($g_user->check_module('CFGPCMN')==0)
30 {
31  $html=h2(_('Action interdite'), ' class="notice"');
33 
34  header('Content-type: text/xml; charset=UTF-8');
35  echo <<<EOF
36 <?xml version="1.0" encoding="UTF-8"?>
37 <data>
38 <ctl>pcmn_update</ctl>
39 <code>$html</code>
40 <status>NOTALLOWED</status>
41 </data>
42 EOF;
43  return;
44 }
46 ob_start();
47 try
48 {
49 
50 
51  $pcmn_val=$http->get('value', "string");
52 
53  $action='new';
54  $val=new IText('p_valu');
55  $parent=new IText('p_parentu');
56  $lib=new IText('p_libu');
57  $lib->size="60";
58  $type=new ISelect('p_typeu');
60 
61  if ($pcmn_val!="")
62  {
63  $action='update';
64  /*
65  * Not empty, show the default value
66  */
67  $account=new Acc_Account($cn);
68  $account->set_parameter('value', $pcmn_val);
69  $account->load();
70 
71  $val->value=$account->get_parameter('value');
72  $parent->value=$account->get_parameter('parent');
73  $lib->value=$account->get_parameter('libelle');
74  $type->selected=$account->get_parameter('type');
75  }
76 
77  require NOALYSS_TEMPLATE.'/pcmn_update.php';
78  $response=ob_get_clean();
80  if (headers_sent())
81  {
82  echo $response;
83  echo $html;
84  }
85  else
86  {
87  header('Content-type: text/xml; charset=UTF-8');
88  echo <<<EOF
89 <?xml version="1.0" encoding="UTF-8"?>
90 <data>
91 <ctl></ctl>
92 <code>$html</code>
93 <status>ok</status>
94 </data>
95 EOF;
96  }
97 }
98 catch (Exception $exc)
99 {
100  $html=$exc->getMessage();
102  header('Content-type: text/xml; charset=UTF-8');
103  echo <<<EOF
104 <?xml version="1.0" encoding="UTF-8"?>
105 <data>
106 <ctl></ctl>
107 <code>$html</code>
108 <status>NOTALLOWED</status>
109 </data>
110 EOF;
111 }
if($g_user->check_module('CFGPCMN')==0) $http
Manage the account from the table tmp_pcmn.
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
global $g_parameter
global $cn
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character...
function pcmn_update(p_dossier, p_val)
Display a box with accounting detail for update, delete or add, update the table account_tbl_id.
global $g_user