Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 if ($g_user->check_module('CFGPCMN') == 0)
00042 exit();
00043
00044 $var=array('action', 'p_oldu', 'p_valu', 'p_libu', 'p_parentu', 'acc_delete', 'p_typeu');
00045 for ($i=0; $i<count($var); $i++)
00046 {
00047 $name=$var[$i];
00048 if (!isset($$name))
00049 throw new Exception($name." is not set");
00050 }
00051 $ctl='ok';
00052 extract($_GET);
00053
00054
00055
00056 $message=_("opération réussie");
00057
00058 if ($action=="update" &&$acc_delete==0)
00059 {
00060
00061 try
00062 {
00063 $p_val=trim($p_valu);
00064 $p_lib=trim($p_libu);
00065 $p_parent=trim($p_parentu);
00066 $old_line=trim($p_oldu);
00067 $p_type=htmlentities($p_typeu);
00068 $acc=new Acc_Account($cn);
00069 $acc->set_parameter('libelle', $p_lib);
00070 $acc->set_parameter('value', $p_val);
00071 $acc->set_parameter('parent', $p_parent);
00072 $acc->set_parameter('type', $p_type);
00073 $acc->check();
00074 }
00075 catch (Exception $e)
00076 {
00077 $message=_("Valeurs invalides, pas de changement")." \n ".
00078 $e->getMessage();
00079 $ctl='nok';
00080 }
00081 if (strlen($p_val)!=0&&strlen($p_lib)!=0&&strlen($old_line)!=0)
00082 {
00083 if (strlen($p_val)==1)
00084 {
00085 $p_parent=0;
00086 }
00087 else
00088 {
00089 if (strlen($p_parent)==0)
00090 {
00091 $p_parent=substr($p_val, 0, strlen($p_val)-1);
00092 }
00093 }
00094
00095 $Ret=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val=$1", array($p_parent));
00096 if (($p_parent!=0&&Database::num_row($Ret)==0)||$p_parent==$old_line)
00097 {
00098 $message=_("Ne peut pas modifier; aucun poste parent");
00099 $ctl='nok';
00100 }
00101 else
00102 {
00103 try
00104 {
00105 $acc->update($old_line);
00106 }
00107 catch (Exception $e)
00108 {
00109 $message=$e->getMessage();
00110 $ctl='nok';
00111 }
00112 }
00113 }
00114 else
00115 {
00116 $message=_('Update Valeurs invalides');
00117 $ctl='nok';
00118 }
00119 }
00120
00121
00122 if ($action=="new")
00123 {
00124 $p_val=trim($p_valu);
00125 $p_parent=trim($p_parentu);
00126
00127 if (isset($p_valu)&&isset($p_libu))
00128 {
00129 $p_val=trim($p_valu);
00130
00131 if (strlen($p_valu)!=0&&strlen($p_libu)!=0)
00132 {
00133 if (strlen($p_valu)==1)
00134 {
00135 $p_parentu=0;
00136 }
00137 else
00138 {
00139 if (strlen(trim($p_parentu))==0&&
00140 (string) $p_parentu!=(string) (int) $p_parentu)
00141 {
00142 $p_parentu=substr($p_val, 0, strlen($p_valu)-1);
00143 }
00144 }
00145
00146 $Ret=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val=$1", array($p_parentu));
00147 if ($p_parent!=0&&Database::num_row($Ret)==0)
00148 {
00149 $message=_(" Ne peut pas modifier; aucun poste parent");
00150 $ctl='nok';
00151 }
00152 else
00153 {
00154
00155
00156 $Count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val=$1", array($p_val));
00157 if ($Count!=0)
00158 {
00159
00160 $message=_("Ce poste existe déjà ");
00161 $ctl='nok';
00162 }
00163 else
00164 {
00165 $Ret=$cn->exec_sql("insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) values ($1,$2,$3,$4)", array($p_val, $p_libu, $p_parent, $p_typeu));
00166 }
00167 }
00168 }
00169 else
00170 {
00171 $message=_("Valeurs invalides ");
00172 $ctl='nok';
00173 }
00174 }
00175 }
00176
00177
00178
00179 if ($action=="update"&&$acc_delete==1)
00180 {
00181
00182 $R=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val_parent=$1", array($p_valu));
00183 if (Database::num_row($R)!=0)
00184 {
00185 $message=_("Ne peut pas effacer le poste: d'autres postes en dépendent");
00186 $ctl='nok';
00187 }
00188 else
00189 {
00190
00191 $Res=$cn->exec_sql("select * from jrnx where j_poste=$1", array($p_valu));
00192 if (Database::num_row($Res)!=0)
00193 {
00194 $message=_("Ne peut pas effacer le poste: il est utilisé dans les journaux");
00195 $ctl='nok';
00196 }
00197 else
00198 {
00199 $Del=$cn->exec_sql("delete from tmp_pcmn where pcm_val=$1", array($p_valu));
00200 }
00201 }
00202 }
00203 $message=escape_xml($message);
00204 if ( ! headers_sent()) { header('Content-type: text/xml; charset=UTF-8');} else { echo "HTML".unescape_xml($html);}
00205
00206 echo <<<EOF
00207 <?xml version="1.0" encoding="UTF-8"?>
00208 <data>
00209 <ctl>$ctl</ctl>
00210 <code>$message</code>
00211 </data>
00212 EOF;
00213 ?>