Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

line_update.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00020 // $Revision: 1.16 $
00024 include_once ("ac_common.php");
00025 
00026 if ( !isset ($_SESSION['g_dossier'])) {
00027     echo "You must choose a Dossier ";
00028    exit -2;
00029 }
00030 include_once ("postgres.php");
00031 include_once("check_priv.php");
00032 
00033 /* Admin. Dossier */
00034 $rep=DbConnect();
00035 include_once ("class_user.php");
00036 $User=new cl_user($rep);
00037 $User->Check();
00038 html_page_start($User->theme,"onLoad='window.focus();'");
00039 
00040 if ( $User->CheckAction(DbConnect($_SESSION['g_dossier']),MPCMN) == 0 ) {
00041   /* Cannot Access */
00042   NoAccess();
00043   exit -1;                      
00044  }
00045 
00046 include ("user_menu.php");
00047 
00048 /* Modif d'une ligne */
00049 if ( isset ($_POST["update"] ) ) {
00050   foreach ($HTTP_POST_VARS as $name => $element) {
00051     echo_debug('line_update.php',__LINE__,"name $name $element");
00052   }
00053   echo JS_UPDATE_PCMN;
00054   $cn=DbConnect($_SESSION['g_dossier']);
00055     $p_val=trim($_POST["p_val"]);
00056     $p_lib=FormatString($_POST["p_name"]);
00057     $p_parent=trim($_POST["p_val_parent"]);
00058     $old_line=trim($_POST["p_old"]);
00059     echo_debug('line_update.php',__LINE__,"Update old : $old_line News = $p_val $p_lib");
00060     if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 && strlen($old_line)!=0 ) {
00061       if (strlen ($p_val) == 1 ) {
00062         $p_parent=0;
00063       } else {
00064         if ( strlen($p_parent)==0 ) {
00065           $p_parent=substr($p_val,0,strlen($p_val)-1);
00066           echo_debug('line_update.php',__LINE__,"Modif valeur = $p_val parent = $p_parent");
00067         }
00068       }
00069       /* Parent existe */
00070       $Ret=ExecSql($cn,"select pcm_val from tmp_pcmn where pcm_val=$p_parent");
00071       if ( pg_NumRows($Ret) == 0 || $p_parent==$old_line ) {
00072         echo '<SCRIPT> alert(" Ne peut pas modifier; aucune poste parent"); </SCRIPT>';
00073       } else {
00074         
00075         $Ret=ExecSql($cn,"update tmp_pcmn set pcm_val=$p_val, pcm_lib='$p_lib',pcm_val_parent=$p_parent where pcm_val=$old_line");
00076       }
00077     } else {
00078       echo '<script> alert(\'Update Valeurs invalides\'); </script>';
00079     }
00080 
00081   echo "<script> 
00082         window.close();
00083          self.opener.RefreshMe();
00084 
00085         </script>";
00086 
00087 }
00088 
00089 ?>
00090 <FORM ACTION="line_update.php" METHOD="POST">
00091 <TABLE>
00092 <TR>
00093 <?
00094 $l=$_GET['l'];
00095 $p=$_GET['p'];
00096 $n=$_GET['n'];
00097 
00098 printf ('<TD>Numéro de classe </TD><TD><INPUT TYPE="TEXT" name="p_val" value="%s"></TD>',$l);
00099 echo "</TR><TR>";
00100 printf('<TD>Libellé </TD><TD><INPUT TYPE="TEXT" size="70" NAME="p_name" value="%s"></TD>',urldecode($n));
00101 echo "</TR><TR>";
00102 printf ('<TD>Classe Parent</TD><TD><INPUT TYPE="TEXT" name="p_val_parent" value="%s"></TD>',$p);
00103 ?>
00104 </TR>
00105 </TABLE>
00106 <TABLE>
00107 <TR>
00108 <TD><INPUT TYPE="Submit" VALUE="Sauve">
00109 <INPUT TYPE="HIDDEN" name="update">
00110 <? printf ('<INPUT TYPE="HIDDEN" name="p_old" value="%s">',$l); ?>
00111 </TD><TD><input type="button"  Value="Retour sans sauver" onClick='window.close();'></TD></TR>
00112 </TABLE>
00113 </FORM>
00114 
00115 
00116 <?
00117 html_page_stop();
00118 ?>