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

jrn_detail.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.29 $ */
00025 include_once ("ac_common.php");
00026 html_page_start($_SESSION['g_theme']);
00027 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00028   echo "You must choose a Dossier ";
00029   exit -2;
00030 }
00031 include_once ("postgres.php");
00032 /* Admin. Dossier */
00033 $rep=DbConnect();
00034 include_once ("class_user.php");
00035 $User=new cl_user($rep);
00036 $User->Check();
00037 
00038 //include_once ("top_menu_compta.php");
00039 include_once ("user_menu.php");
00040 
00041 
00042 echo '<div class="u_tmenu">';
00043 echo ShowMenuCompta($_SESSION['g_dossier']);
00044 echo '</div>';
00045 
00046 include_once("check_priv.php");
00047 
00048 $cn=DbConnect($_SESSION['g_dossier']);
00049 if ( $User->CheckAction($cn,GJRN) == 0 ){
00050   /* Cannot Access */
00051   NoAccess();
00052   exit -1;                      
00053 }
00054 // Javascript
00055 echo JS_SEARCH_POSTE;
00056 if ( isset( $_GET['p_jrn'] )) {
00057   $p_jrn=$_GET['p_jrn'];
00058  } else {
00059   echo '<h2 class="error">Journal inexistant</h2>';
00060   exit();
00061  }
00062 
00063 
00064 
00065 If ( isset ($_POST["JRN_UPD"] )) {
00066   if (  !isset($_POST["p_jrn_name"])  ) {
00067     echo '<H2 CLASS="error"> Un paramètre manque</H2>';
00068   }
00069   else {
00070     if ( $_POST['p_ech'] == 'no' ) {
00071       $p_ech='false';
00072       $p_ech_lib='null';
00073     } else {
00074       $p_ech='true';
00075       $p_ech_lib="'".$_POST['p_ech_lib']."'";
00076     }
00077    
00078     if ( strlen(trim($_POST['p_jrn_deb_max_line'])) == 0 || 
00079         (string) (int)$_POST['p_jrn_deb_max_line'] != (string)$_POST['p_jrn_deb_max_line'] ||
00080          $_POST['p_jrn_deb_max_line'] <= 0
00081          )
00082       $l_deb_max_line=1;
00083     else
00084       $l_deb_max_line=$_POST['p_jrn_deb_max_line'];
00085     
00086     $l_cred_max_line=$l_deb_max_line;
00087 
00088     $p_jrn_name=$_POST['p_jrn_name'];
00089      if (strlen(trim($p_jrn_name))==0) return;
00090      $p_jrn_name=FormatString($p_jrn_name);
00091        $p_jrn_fiche_deb="";
00092        $p_jrn_fiche_cred="";
00093 
00094      if ( isset    ($_POST["FICHEDEB"])) {
00095        $p_jrn_fiche_deb=join(",",$_POST["FICHEDEB"]);
00096      }
00097       if ( isset    ($_POST["FICHECRED"])) {
00098        $p_jrn_fiche_cred=join(",",$_POST["FICHECRED"]);
00099       }
00100     $Sql=sprintf("update jrn_def set jrn_def_name='%s',jrn_def_class_deb='%s',jrn_def_class_cred='%s',
00101                  jrn_deb_max_line=%s,jrn_cred_max_line=%s,jrn_def_ech=%s,jrn_def_ech_lib=%s,jrn_def_fiche_deb='%s',
00102                   jrn_def_fiche_cred='%s'
00103                  where jrn_def_id=%s",
00104                  $p_jrn_name,$_POST['p_jrn_class_deb'],$_POST['p_jrn_class_cred'],
00105                  $l_deb_max_line,$l_cred_max_line,
00106                  $p_ech,$p_ech_lib,
00107                  $p_jrn_fiche_deb,$p_jrn_fiche_cred,
00108                  $_GET['p_jrn']
00109                  );
00110     echo_debug($Sql);
00111     $Res=ExecSql($cn,$Sql);
00112   }
00113 }
00114 echo ShowMenuAdvanced();
00115 echo '<div class="lmenu">';
00116 MenuJrn($_SESSION['g_dossier']);
00117 echo '</div>';
00118 
00119 $Res=ExecSql($cn,"select jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,".
00120              "jrn_deb_max_line,jrn_cred_max_line,jrn_def_code".
00121                  ",jrn_def_type,jrn_def_ech, jrn_def_ech_lib,jrn_def_fiche_deb,jrn_def_fiche_cred".
00122                  " from jrn_def where".
00123                  " jrn_def_id=".$_GET['p_jrn']);
00124 $l_line=pg_fetch_array($Res,0);
00125 $sessid = $_REQUEST['PHPSESSID'];
00126 $search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$sessid."','not','".$_GET['p_jrn']."')\">";
00127 echo '<DIV CLASS="u_redcontent">';
00128 echo '<H2 class="info">'.$l_line['jrn_def_name'].'</H2>';
00129 echo '<FORM ACTION="jrn_detail.php?p_jrn='.$_GET['p_jrn'].'" METHOD="POST">';
00130 echo '<INPUT TYPE="HIDDEN" NAME="JRN_UPD">';
00131 echo '<TABLE>';
00132 
00133 echo '<TR>'; 
00134 echo '<TD> Nom journal </TD>';
00135 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_name" VALUE="'.$l_line['jrn_def_name'].'"></TD>';
00136 echo '</TR>';
00137 
00138 echo '<TR>'; 
00139 echo '<TD> Postes utilisables journal (débit) </TD>';
00140 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_class_deb" VALUE="'.$l_line['jrn_def_class_deb'].'">'.$search.'</TD>';
00141 echo '</TR>';
00142 
00143 echo '<TR>'; 
00144 echo '<TD> Nombre de lignes par défaut  </TD>';
00145 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_deb_max_line" VALUE="'.$l_line['jrn_deb_max_line'].'"></TD>';
00146 echo '</TR>';
00147 
00148 echo '<TR>'; 
00149 echo '<TD> Postes utilisables journal (crédit) </TD>';
00150 echo '<TD> <INPUT TYPE="text" NAME="p_jrn_class_cred" VALUE="'.$l_line['jrn_def_class_cred'].'">'.$search.'</TD>';
00151 echo '</TR>';
00152 
00153 
00154 echo '<TR>'; 
00155 echo '<TD> Date d\'échéance </TD>';
00156 if ( $l_line['jrn_def_ech'] == 't' ) {
00157   echo '<TD> <INPUT TYPE="radio" NAME="p_ech" VALUE="yes" checked> Oui';
00158   echo '<INPUT TYPE="radio" NAME="p_ech" VALUE="no">Non </TD>';
00159 }
00160 if ( $l_line['jrn_def_ech'] == 'f' ) {
00161   echo '<TD> <INPUT TYPE="radio" NAME="p_ech" VALUE="yes" >Oui';
00162   echo '<INPUT TYPE="radio" NAME="p_ech" VALUE="no" CHECKED>Non</TD>';
00163 }
00164 echo '</TR>';
00165 
00166 echo '<TR>'; 
00167 echo '<TD> Libellé echéance </TD>';
00168 echo '<TD> <INPUT TYPE="text" NAME="p_ech_lib" VALUE="'.$l_line['jrn_def_ech_lib'].'"></TD>';
00169 echo '</TR>';
00170 
00171 echo '<TR>'; 
00172 echo '<TD> Type de journal </TD>';
00173 echo '<TD> ';
00174 $Res=ExecSql($cn,"select jrn_type_id,jrn_desc from jrn_type where ".
00175         "trim(jrn_type_id)=trim('".$l_line['jrn_def_type']."')");
00176 $Max=pg_NumRows($Res);
00177 
00178 for ($i=0;$i<$Max;$i++) {
00179   $Line=pg_fetch_array($Res,$i);
00180 
00181   echo_debug('jrn_detail.php',__LINE__,"jrn type !".$Line['jrn_type_id']."!,!".$l_line['jrn_def_type']."!");
00182   printf (' %s',$Line['jrn_desc']);
00183 }
00184 echo '</TD>';
00185 echo '</TR>';
00186 echo "<TR><TD> Code </TD><TD>".$l_line['jrn_def_code']."</TD></TR>";
00187 
00188 
00189 ?>
00190 
00191 <?
00192 
00193 echo '</TABLE>';
00194 // Get all the fiches
00195 echo '<H2 class="info"> Fiches </H2>';
00196 $Res=ExecSql($cn,"select fd_id,fd_label from fiche_def order by fd_label");
00197 $num=pg_NumRows($Res);
00198 
00199 $rdeb=split(',',$l_line['jrn_def_fiche_deb']);
00200 
00201 $rcred=split(',',$l_line['jrn_def_fiche_cred']);
00202 echo '<TABLE>';
00203 echo '<TR>';
00204 echo '<th> Fiches Débit</TH>';
00205 echo '<th> Fiches Crédit</TH>';
00206 echo '</TR>';
00207 // Show the fiche in deb section
00208 for ($i=0;$i<$num;$i++) {
00209   $res=pg_fetch_array($Res,$i);
00210   $CHECKED=" unchecked";
00211   foreach ( $rdeb as $element) { 
00212     if ( $element == $res['fd_id'] ) {
00213     $CHECKED="CHECKED";
00214     break;
00215   }
00216   }
00217   echo '<TR>';
00218   printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHEDEB[]" %s>%s</TD>',
00219           $res['fd_id'],$CHECKED,$res['fd_label']);
00220   $CHECKED=" unchecked";
00221   foreach ( $rcred as $element) { 
00222     if ( $element == $res['fd_id'] ) {
00223     $CHECKED="CHECKED";
00224     break;
00225   }
00226   }
00227 
00228   printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHECRED[]" %s>%s</TD>',
00229           $res['fd_id'],$CHECKED,$res['fd_label']);
00230   echo '</TR>';
00231 }
00232 
00233 
00234 ?>
00235 
00236 <TABLE><TR><TD><INPUT TYPE="SUBMIT" VALUE="Sauve"></TD><TD><INPUT TYPE="RESET" VALUE="Reset"></TD></TR></TABLE>
00237 <?
00238 echo '</FORM>';
00239 echo "</DIV>";
00240 html_page_stop();
00241 ?>