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

periode.inc.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 /* $Revision: 1.3 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00026 require_once("preference.php");
00027 $cn=DbConnect($_SESSION['g_dossier']);
00028 //-----------------------------------------------------
00029 // Periode
00030 //-----------------------------------------------------
00031 $action="";
00032 if ( isset($_REQUEST['action'])) 
00033      $action=$_REQUEST['action'];
00034 
00035 if ( $action=="change_per") {
00036   foreach($HTTP_GET_VARS as $key=>$element) 
00037     ${"$key"}=$element;
00038   echo "<TABLE>";
00039   echo '<TR> <FORM ACTION="user_advanced.php?p_action=periode" METHOD="POST">';
00040   echo ' <INPUT TYPE="HIDDEN" NAME="p_per" VALUE="'.$p_per.'">';
00041   echo '<TD> <INPUT TYPE="text" NAME="p_date_start" VALUE="'.$p_date_start.'"></TD>';
00042   echo '<TD> <INPUT TYPE="text" NAME="p_date_end" VALUE="'.$p_date_end.'"></TD>';
00043   echo '<TD> <INPUT TYPE="text" NAME="p_exercice" VALUE="'.$p_exercice.'"></TD>';
00044   echo '<TD> <INPUT TYPE="SUBMIT" NAME="conf_chg_per" Value="Change"</TD>';
00045   echo '</FORM></TR>';
00046   echo "</TABLE>";
00047 
00048 }
00049 if ( isset ($_POST["conf_chg_per"] ) ) {
00050   foreach($HTTP_POST_VARS as $key=>$element) 
00051     ${"$key"}=$element;
00052   if (isDate($p_date_start) == null ||
00053       isDate($p_date_end) == null ||
00054       strlen (trim($p_exercice)) == 0 ||
00055      (string) $p_exercice != (string)(int) $p_exercice)
00056     { 
00057       echo "<H2 class=\"error\"> Valeurs invalides</H2>";
00058       ShowPeriode($cn);
00059       return;
00060     }
00061   $Res=ExecSql($cn," update parm_periode ".
00062                "set p_start=to_date('". $p_date_start."','DD.MM.YYYY'),".
00063                " p_end=to_date('". $p_date_end."','DD.MM.YYYY'),".
00064                " p_exercice='".$p_exercice."'".
00065                " where p_id=".$p_per);
00066 
00067 
00068 
00069 }
00070 if ( isset ($_POST["add_per"] )) {
00071   foreach($HTTP_POST_VARS as $key=>$element) 
00072     ${"$key"}=$element;
00073   if (isDate($p_date_start) == null ||
00074       isDate($p_date_end) == null ||
00075       strlen (trim($p_exercice)) == 0 ||
00076      (string) $p_exercice != (string)(int) $p_exercice)
00077     { 
00078       echo "<H2 class=\"error\"> Valeurs invalides</H2>";
00079       ShowPeriode($cn);
00080       return;
00081     }
00082   $Res=ExecSql($cn,sprintf(" insert into parm_periode(p_start,p_end,p_closed,p_exercice)".
00083                            "values (to_date('%s','DD.MM.YYYY'),to_date('%s','DD.MM.YYYY')".
00084                            ",'f','%s')",
00085                            $p_date_start,
00086                            $p_date_end,
00087                            $p_exercice));
00088 
00089 
00090 }
00091 
00092 echo_debug('periode.inc',__LINE__,"Action $p_action");
00093 if ( $action=="closed") {
00094   $p_per=$_GET['p_per'];
00095   $Res=ExecSql($cn,"update parm_periode set p_closed=true where p_id=$p_per");
00096 }
00097 
00098 if ( $action== "delete_per" ) {
00099   $p_per=$_GET["p_per"];
00100 // Check if the periode is not used
00101   if ( CountSql($cn,"select * from jrnx where j_tech_per=$p_per") != 0 ) {
00102   echo '<h2 class="error"> Désolé mais cette période est utilisée</h2>';
00103   } else
00104   {
00105   $Res=ExecSql($cn,"delete from parm_periode where p_id=$p_per");
00106   }
00107 }
00108 
00109 
00110 ShowPeriode($cn);
00111 
00112 ?>