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$ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 /* $Revision$ */
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      if (  strlen(trim($_POST['p_jrn_cred_max_line'])) == 0 ||
00077            (string) (int)$_POST['p_jrn_cred_max_line'] != (string)$_POST['p_jrn_cred_max_line'] )
00078       $l_cred_max_line=1;
00079     else
00080       $l_cred_max_line=$_POST['p_jrn_cred_max_line'];
00081      $p_jrn_name=$_POST["p_jrn_name"];
00082 echo_debug('jrn_add.php',__LINE__,"nom journal $p_jrn_name");
00083      $p_jrn_class_deb=FormatString($_POST["p_jrn_class_deb"]);
00084      if (strlen(trim($p_jrn_name))==0) return;
00085      $p_jrn_name=FormatString($p_jrn_name);
00086      $p_jrn_class_cred=FormatString($_POST["p_jrn_class_cred"]);
00087      // compute the jrn_def.jrn_def_code
00088      $p_code=sprintf("%s-%02d",trim($_POST['p_jrn_type']),NextJrn($cn,$_POST['p_jrn_type']));
00089        $p_jrn_fiche_deb="";
00090        $p_jrn_fiche_cred="";
00091 
00092      if ( isset    ($_POST["FICHEDEB"])) {
00093        $p_jrn_fiche_deb=join(",",$_POST["FICHEDEB"]);
00094      }
00095       if ( isset    ($_POST["FICHECRED"])) {
00096        $p_jrn_fiche_cred=join(",",$_POST["FICHECRED"]);
00097       }
00098 
00099     $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,
00100                   jrn_def_type,jrn_def_fiche_deb,jrn_def_fiche_cred,jrn_def_code) 
00101                   values ('%s','%s','%s',%s,%s,'%s','%s','%s','%s')",
00102                  $p_jrn_name,$p_jrn_class_deb,$p_jrn_class_cred,
00103                  $l_deb_max_line,$l_cred_max_line,$_POST['p_jrn_type'],
00104                  $p_jrn_fiche_deb,$p_jrn_fiche_cred,
00105                  $p_code
00106                  );
00107     echo_debug($Sql);
00108     $Res=ExecSql($cn,$Sql);
00109   }
00110 }
00111 echo ShowMenuAdvanced();
00112 echo '<div class="lmenu">';
00113 MenuJrn($_SESSION['g_dossier']);
00114 echo '</div>';
00115 
00116 $sessid=$_REQUEST['PHPSESSID'];
00117 $search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$sessid."','not')\">";
00118 
00119 echo '<DIV CLASS="u_redcontent">';
00120 echo '<FORM ACTION="jrn_add.php" METHOD="POST">';
00121 echo '<INPUT TYPE="HIDDEN" NAME="JRN_ADD">';
00122 echo '<TABLE>';
00123 
00124 echo '<TR>'; 
00125 echo '<TD> Nom journal </TD>';
00126 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_name"></TD>';
00127 echo '</TR>';
00128 
00129 echo '<TR>'; 
00130 echo '<TD> Postes utilisables journal (débit) </TD>';
00131 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_class_deb">'.$search.'</TD>';
00132 echo '</TR>';
00133 
00134 echo '<TR>'; 
00135 echo '<TD> Nombre de lignes par défaut (débit) </TD>';
00136 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_deb_max_line" ></TD>';
00137 echo '</TR>';
00138 
00139 echo '<TR>'; 
00140 echo '<TD> Postes utilisables journal (crédit) </TD>';
00141 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_class_cred">'.$search.'</TD>';
00142 echo '</TR>';
00143 
00144 
00145 echo '<TR>'; 
00146 echo '<TD> Nombre de lignes par défaut (crédit) </TD>';
00147 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_cred_max_line"></TD>';
00148 echo '</TR>';
00149 
00150 echo '<TR>'; 
00151 echo '<TD> Date d\'échéance </TD>';
00152 echo '<TD> <INPUT TYPE="radio" NAME="p_ech" VALUE="yes" >Oui';
00153 echo '<INPUT TYPE="radio" NAME="p_ech" VALUE="no" CHECKED>Non</TD>';
00154 
00155 echo '</TR>';
00156 
00157 echo '<TR>'; 
00158 echo '<TD> Libellé echéance </TD>';
00159 echo '<TD> <INPUT TYPE="text" NAME="p_ech_lib" ></TD>';
00160 echo '</TR>';
00161 
00162 
00163 echo '<TR>'; 
00164 echo '<TD> Type de journal </TD>';
00165 echo '<TD> ';
00166 $Res=ExecSql($cn,"select jrn_type_id,jrn_desc from jrn_type");
00167 $Max=pg_NumRows($Res);
00168 echo '<SELECT NAME="p_jrn_type">';
00169 for ($i=0;$i<$Max;$i++) {
00170   $Line=pg_fetch_array($Res,$i);
00171   printf ('<OPTION VALUE="%s">%s',$Line['jrn_type_id'],$Line['jrn_desc']);
00172 }
00173 echo '</SELECT>';
00174 echo '</TD>';
00175 echo '</TR>';
00176 ?>
00177 <?
00178 // Get all the fiches
00179 echo '<tr> <td colspan="2"><H2 class="info"> Fiches </H2></TD></TR>';
00180 $Res=ExecSql($cn,"select fd_id,fd_label from fiche_def order by fd_label");
00181 $num=pg_NumRows($Res);
00182 
00183 
00184 echo '<TR>';
00185 echo '<th> Fiches Dédit</TH>';
00186 echo '<th> Fiches Crébit</TH>';
00187 echo '</TR>';
00188 // Show the fiche in deb section
00189 for ($i=0;$i<$num;$i++) {
00190   $res=pg_fetch_array($Res,$i);
00191   echo '<TR>';
00192   printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHEDEB[]">%s</TD>',
00193           $res['fd_id'],$res['fd_label']);
00194   printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHECRED[]">%s</TD>',
00195           $res['fd_id'],$res['fd_label']);
00196   echo '</TR>';
00197 }
00198 ?>
00199 <TR><TD><INPUT TYPE="SUBMIT" VALUE="Sauve"></TD><TD><INPUT TYPE="RESET" VALUE="Reset"></TD></TR>
00200 <?
00201 echo '</TABLE>';
00202 echo '</FORM>';
00203 echo "</DIV>";
00204 html_page_stop();
00205 ?>

Generated on Fri Jun 23 00:12:45 2006 for phpcompta by  doxygen 1.4.4