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

jrn_add.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.24 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 /* $Revision: 1.24 $ */
00026 include_once ("ac_common.php");
00027 include_once("jrn.php");
00028 html_page_start($_SESSION['g_theme']);
00029 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00030   echo "You must choose a Dossier ";
00031   exit -2;
00032 }
00033 include_once ("postgres.php");
00034 /* Admin. Dossier */
00035 $rep=DbConnect();
00036 include_once ("class_user.php");
00037 $User=new cl_user($rep);
00038 $User->Check();
00039 include_once("check_priv.php");
00040 include_once ("user_menu.php");
00041 
00042 echo '<div class="u_tmenu">';
00043 echo ShowMenuCompta($_SESSION['g_dossier']);
00044 echo '</div>';
00045 
00046 
00047 
00048 $cn=DbConnect($_SESSION['g_dossier']);
00049 if ($User->CheckAction($cn,GJRN) == 0 ){
00050   /* Cannot Access */
00051   NoAccess();
00052   exit -1;                      
00053   
00054  }
00055 
00056 echo JS_SEARCH_POSTE;
00057 
00058 If ( isset ($_POST["JRN_ADD"]) ) {
00059   if (  !isset($_POST["p_jrn_name"]) || ! isset($_POST["p_jrn_type"] )) {
00060     echo '<H2 CLASS="error"> Un paramètre manque</H2>';
00061   }
00062   else {
00063     if ( $_POST['p_ech'] == 'no' ) {
00064       $p_ech='false';
00065       $p_ech_lib='null';
00066     } else {
00067       $p_ech='true';
00068       $p_ech_lib="'".$_POST['p_ech_lib']."'";
00069     }
00070       if (strlen(trim($_POST['p_jrn_deb_max_line'])) == 0 || 
00071           (string) (int)$_POST['p_jrn_deb_max_line'] != (string)$_POST['p_jrn_deb_max_line'] )
00072       $l_deb_max_line=1;
00073     else
00074       $l_deb_max_line=$_POST['p_jrn_deb_max_line'];
00075 
00076 
00077      $p_jrn_name=$_POST["p_jrn_name"];
00078 echo_debug('jrn_add.php',__LINE__,"nom journal $p_jrn_name");
00079      $p_jrn_class_deb=FormatString($_POST["p_jrn_class_deb"]);
00080      if (strlen(trim($p_jrn_name))==0) return;
00081      $p_jrn_name=FormatString($p_jrn_name);
00082      $p_jrn_class_cred=FormatString($_POST["p_jrn_class_cred"]);
00083      // compute the jrn_def.jrn_def_code
00084      $p_code=sprintf("%s-%02d",trim($_POST['p_jrn_type']),NextJrn($cn,$_POST['p_jrn_type']));
00085        $p_jrn_fiche_deb="";
00086        $p_jrn_fiche_cred="";
00087 
00088      if ( isset    ($_POST["FICHEDEB"])) {
00089        $p_jrn_fiche_deb=join(",",$_POST["FICHEDEB"]);
00090      }
00091       if ( isset    ($_POST["FICHECRED"])) {
00092        $p_jrn_fiche_cred=join(",",$_POST["FICHECRED"]);
00093       }
00094       $l_cred_max_line=$l_deb_max_line;
00095     $Sql=sprintf("insert into jrn_def(jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
00096                   jrn_def_type,jrn_def_fiche_deb,jrn_def_fiche_cred,jrn_def_code) 
00097                   values ('%s','%s','%s',%s,%s,'%s','%s','%s','%s')",
00098                  $p_jrn_name,$p_jrn_class_deb,$p_jrn_class_cred,
00099                  $l_deb_max_line,$l_cred_max_line,$_POST['p_jrn_type'],
00100                  $p_jrn_fiche_deb,$p_jrn_fiche_cred,
00101                  $p_code
00102                  );
00103     echo_debug($Sql);
00104     $Res=ExecSql($cn,$Sql);
00105   }
00106 }
00107 echo ShowMenuAdvanced();
00108 echo '<div class="lmenu">';
00109 MenuJrn($_SESSION['g_dossier']);
00110 echo '</div>';
00111 
00112 $sessid=$_REQUEST['PHPSESSID'];
00113 $search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$sessid."','not')\">";
00114 
00115 echo '<DIV CLASS="u_redcontent">';
00116 echo '<FORM ACTION="jrn_add.php" METHOD="POST">';
00117 echo '<INPUT TYPE="HIDDEN" NAME="JRN_ADD">';
00118 echo '<TABLE>';
00119 
00120 echo '<TR>'; 
00121 echo '<TD> Nom journal </TD>';
00122 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_name"></TD>';
00123 echo '</TR>';
00124 
00125 echo '<TR>'; 
00126 echo '<TD> Postes utilisables journal (débit) </TD>';
00127 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_class_deb">'.$search.'</TD>';
00128 echo '</TR>';
00129 
00130 echo '<TR>'; 
00131 echo '<TD> Nombre de lignes par défaut  </TD>';
00132 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_deb_max_line" ></TD>';
00133 echo '</TR>';
00134 
00135 echo '<TR>'; 
00136 echo '<TD> Postes utilisables journal (crédit) </TD>';
00137 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_class_cred">'.$search.'</TD>';
00138 echo '</TR>';
00139 
00140 
00141 echo '<TR>'; 
00142 echo '<TD> Date d\'échéance </TD>';
00143 echo '<TD> <INPUT TYPE="radio" NAME="p_ech" VALUE="yes" >Oui';
00144 echo '<INPUT TYPE="radio" NAME="p_ech" VALUE="no" CHECKED>Non</TD>';
00145 
00146 echo '</TR>';
00147 
00148 echo '<TR>'; 
00149 echo '<TD> Libellé echéance </TD>';
00150 echo '<TD> <INPUT TYPE="text" NAME="p_ech_lib" ></TD>';
00151 echo '</TR>';
00152 
00153 
00154 echo '<TR>'; 
00155 echo '<TD> Type de journal </TD>';
00156 echo '<TD> ';
00157 $Res=ExecSql($cn,"select jrn_type_id,jrn_desc from jrn_type");
00158 $Max=pg_NumRows($Res);
00159 echo '<SELECT NAME="p_jrn_type">';
00160 for ($i=0;$i<$Max;$i++) {
00161   $Line=pg_fetch_array($Res,$i);
00162   printf ('<OPTION VALUE="%s">%s',$Line['jrn_type_id'],$Line['jrn_desc']);
00163 }
00164 echo '</SELECT>';
00165 echo '</TD>';
00166 echo '</TR>';
00167 ?>
00168 <?
00169 // Get all the fiches
00170 echo '<tr> <td colspan="2"><H2 class="info"> Fiches </H2></TD></TR>';
00171 $Res=ExecSql($cn,"select fd_id,fd_label from fiche_def order by fd_label");
00172 $num=pg_NumRows($Res);
00173 
00174 
00175 echo '<TR>';
00176 echo '<th> Fiches Dédit</TH>';
00177 echo '<th> Fiches Crébit</TH>';
00178 echo '</TR>';
00179 // Show the fiche in deb section
00180 for ($i=0;$i<$num;$i++) {
00181   $res=pg_fetch_array($Res,$i);
00182   echo '<TR>';
00183   printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHEDEB[]">%s</TD>',
00184           $res['fd_id'],$res['fd_label']);
00185   printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHECRED[]">%s</TD>',
00186           $res['fd_id'],$res['fd_label']);
00187   echo '</TR>';
00188 }
00189 ?>
00190 <TR><TD><INPUT TYPE="SUBMIT" VALUE="Sauve"></TD><TD><INPUT TYPE="RESET" VALUE="Reset"></TD></TR>
00191 <?
00192 echo '</TABLE>';
00193 echo '</FORM>';
00194 echo "</DIV>";
00195 html_page_stop();
00196 ?>