diff --git a/doc/developper/.cvsignore b/doc/developper/.cvsignore new file mode 100644 index 000000000..067823c13 --- /dev/null +++ b/doc/developper/.cvsignore @@ -0,0 +1,2 @@ +html/* +latex/* diff --git a/doc/manuel-fr.sgml b/doc/manuel-fr.sgml index 6ded08858..c14010026 100644 --- a/doc/manuel-fr.sgml +++ b/doc/manuel-fr.sgml @@ -583,6 +583,10 @@ requis, n'oubliez pas de mettre un mot de passe superutilisateurs PostgreSql avant de changer, sinon vous ne pourrez plus vous connecter. +Pour changer le port de postgresql, il suffit de changer dans +constant.php, la valeur phpcompta_psql_port, n'oubliez pas de changer + le paramétrage de postgresql. + Ensuite, changer les droits sur le répertoire où sont vos fichiers avec chmod 700, attention : le propriétaire des fichiers doit être le même que du propriétaire du process httpd, pour vérifier faite ps -ef|grep diff --git a/html/admin/test_me.php b/html/admin/test_me.php index 877bddade..53aaca8d4 100644 --- a/html/admin/test_me.php +++ b/html/admin/test_me.php @@ -7,30 +7,38 @@ include_once('class_poste.php'); include_once('class_balance.php'); +$cn=DbConnect(1); + echo "

check sql_filter_per

"; -$a=sql_filter_per('01.01.1999','01.01.1999'); +$a=sql_filter_per($cn,'01.01.1999','01.01.1999','date','jr_tech_per'); echo $a."
"; -$b= sql_filter_per('01.01.2000','01.11.2006'); +$b= sql_filter_per($cn,'01.01.2000','01.11.2006','date','j_tech_per'); echo "Received $b
"; echo '

check getRow function

'; echo 'Check Jrn
'; -$cn=DbConnect(-2,'dossier1'); $a=new jrn($cn,0); // grand livre -$b=$a->GetRow('01.02.2000','01.01.2006','off'); -echo 'class_jrn il y a '.sizeof($b).' données trouvée
'; +$b=$a->GetRow('1','9999','off'); -$b=$a->GetRow('01.02.2000','01.01.2006','on'); -echo 'Class_jrn il y a '.sizeof($b).' données Centralisees trouvée
'; -$a=new poste($cn,4519); // grand livre -$b=$a->GetRow('01.02.2000','01.01.2006'); -echo 'class_poste il y a '.sizeof($b).' données trouvée
'; + +echo 'class_jrn il y a '.count($b[0]).' données trouvée
'; + +$b=$a->GetRow('1','9999','on'); +echo 'Class_jrn il y a '.sizeof($b[0]).' données Centralisees trouvée
'; + +$a=new poste($cn,4511); // grand livre +$b=$a->GetRow('1','9999'); + +echo 'class_poste il y a '.sizeof($b[0]).' données trouvée
'; $a=new Balance($cn,4519); // grand livre -$b=$a->GetRow('01.02.2000','01.01.2006'); +$b=$a->GetRow('1','9999'); echo 'class_balance il y a '.sizeof($b).' données trouvée
'; +echo_debug('Testing echo_debug'); +echo_error('Testing echo_error'); + ?> diff --git a/html/commercial.php b/html/commercial.php index 47553bad2..e99f5298a 100644 --- a/html/commercial.php +++ b/html/commercial.php @@ -67,7 +67,7 @@ if ( ! isset ( $_SESSION['g_dossier'] ) ) { exit -2; } -include("preference.php"); +include_once("preference.php"); include_once("user_menu.php"); echo '
'; echo "

Commercial ".$_SESSION['g_name']."

"; diff --git a/html/fiche_csv.php b/html/fiche_csv.php index ffef32616..cbb598bc2 100644 --- a/html/fiche_csv.php +++ b/html/fiche_csv.php @@ -76,9 +76,9 @@ if ( isset ($_POST['fd_id'])) { if ( $dattribut->ad_id == ATTR_DEF_ACCOUNT && isset ($_REQUEST['with_amount'])) { $account=new poste ($cn,$dattribut->av_text); - $solde=$account->GetSoldeDetail("j_tech_per between ".$_REQUEST['from_periode']. - " and ". - $_REQUEST['to_periode']); + $sql_periode=sql_filter_per($cn,$_REQUEST['from_periode'],$_REQUEST['to_periode'],'p_id','j_tech_per'); + $solde= $account->GetSoldeDetail($sql_periode); + printf(";% 10.2f;% 10.2f;% 10.2f", $solde['debit'], diff --git a/html/index.php b/html/index.php index ac31e5b46..e9d25d3e6 100644 --- a/html/index.php +++ b/html/index.php @@ -76,7 +76,7 @@ BODY { -Version 2.0.6 - CVS +Version 2.0.7

Il est conseillé de ne PAS utiliser Internet Explorer.

diff --git a/html/parametre.php b/html/parametre.php index 8c57f1a86..a6f390676 100644 --- a/html/parametre.php +++ b/html/parametre.php @@ -46,7 +46,7 @@ include_once ("class_user.php"); $User=new cl_user($rep); $User->Check(); -include("preference.php"); +include_once("preference.php"); include_once("user_menu.php"); echo "

Paramètre ".$_SESSION['g_name']."

"; diff --git a/html/show_document.php b/html/show_document.php index e77ed7681..417c13a67 100644 --- a/html/show_document.php +++ b/html/show_document.php @@ -30,7 +30,7 @@ require_once( "class_document.php"); $cn=DbConnect($_SESSION['g_dossier']); -include ('class_user.php'); +require_once ('class_user.php'); $User=new cl_user(DbConnect()); /*!\todo Add security here */ diff --git a/html/show_document_modele.php b/html/show_document_modele.php index 50d983db1..f77866462 100644 --- a/html/show_document_modele.php +++ b/html/show_document_modele.php @@ -30,7 +30,7 @@ require_once("ac_common.php"); $cn=DbConnect($_SESSION['g_dossier']); -include ('class_user.php'); +require_once ('class_user.php'); $User=new cl_user(DbConnect()); /*!\todo Add security here */ diff --git a/html/show_pj.php b/html/show_pj.php index a005313e6..0ef9aeae0 100644 --- a/html/show_pj.php +++ b/html/show_pj.php @@ -33,7 +33,7 @@ $jr_grpt_id=$_GET['jr_grpt_id']; $cn=DbConnect($_SESSION['g_dossier']); -include ('class_user.php'); +include_once ('class_user.php'); $User=new cl_user(DbConnect()); $User->Check(); // retrieve the jrn diff --git a/html/user_impress.php b/html/user_impress.php index 68c517376..0972d4123 100644 --- a/html/user_impress.php +++ b/html/user_impress.php @@ -33,11 +33,11 @@ include_once ("postgres.php"); $cn=DbConnect($_SESSION['g_dossier']); -include ('class_user.php'); +require_once ('class_user.php'); $User=new cl_user($cn); $User->Check(); -include ("check_priv.php"); +require_once ("check_priv.php"); include_once ("user_menu.php"); echo '
'; @@ -76,26 +76,26 @@ if ( $User->admin == 0 ) { $default=( isset ($_REQUEST['type']))?$_REQUEST['type']:""; switch ($default) { case "jrn": - include ("impress_jrn.php"); + require_once ("impress_jrn.php"); break; case "poste": - include ("impress_poste.php"); + require_once ("impress_poste.php"); break; case "rapport": - include ("impress_rapport.php"); + require_once ("impress_rapport.php"); break; case "bilan": - include ("impress_bilan.php"); + require_once ("impress_bilan.php"); break; case "bal": - include ("balance.php"); + require_once ("balance.php"); break; case "fiche": - include ("impress_fiche.php"); + require_once ("impress_fiche.php"); break; case "list_client": - include ("impress_listing_client.php"); + require_once ("impress_listing_client.php"); break; } diff --git a/html/user_jrn.php b/html/user_jrn.php index b9aa6b325..b56531462 100644 --- a/html/user_jrn.php +++ b/html/user_jrn.php @@ -31,7 +31,7 @@ include_once ("class_widget.php"); require_once("jrn.php"); $cn=DbConnect($_SESSION['g_dossier']); -include ('class_user.php'); +include_once ('class_user.php'); $User=new cl_user($cn); $User->Check(); @@ -108,7 +108,7 @@ else { if ( $jrn_type=='NONE') { - include('user_action_gl.php'); + include_once('user_action_gl.php'); } else { // no journal are selected so we select the first one diff --git a/include/ac_common.php b/include/ac_common.php index 3f0d871ea..bf9d4557f 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -25,6 +25,7 @@ include_once("debug.php"); include_once("constant.php"); +require_once('preference.php'); /*! * \brief log error into the /tmp/phpcompta_error.log it doesn't work on windows * @@ -37,7 +38,7 @@ function echo_error ($p_log, $p_line="", $p_message="") { $fdebug=fopen($_ENV['TMP'].DIRECTORY_SEPARATOR."phpcompta_error.log","a+"); fwrite($fdebug,date("Ymd H:i:s").$p_log." ".$p_line." ".$p_message."\n"); fclose($fdebug); - echo_debug($p_log); + echo_debug($p_log,$p_line,$p_message); } /*! @@ -382,18 +383,41 @@ function Decode($p_html){ * thanks a from and to date. * \param $p_from start date (date) * \param $p_to end date (date) + * \param $p_form if the p_from and p_to are date or p_id * \param $p_field column name * \return a string containg the query */ -function sql_filter_per($p_from,$p_to,$p_field='jr_tech_per') +function sql_filter_per($p_cn,$p_from,$p_to,$p_form='p_id',$p_field='jr_tech_per') { - if ( $p_from == $p_to ) - $periode=" $p_field = to_date('$p_from','DD.MM.YYYY') "; - else - $periode = "$p_field in (select p_id from parm_periode ". - " where p_start >= to_date('$p_from','DD.MM.YYYY') and p_end <= to_date('$p_to','DD.MM.YYYY')) "; + echo_debug("sql_filter_per($p_cn,$p_from,$p_to,$p_form,$p_field)"); + if ( $p_form != 'p_id' && + $p_form != 'date' ) + { + echo_error (__FILE__,__LINE__,'Mauvais parametres '); + exit(-1); + } + if ( $p_form == 'p_id' ) + { + // retrieve the date + $a_start=GetPeriode($p_cn,$p_from); + $a_end=GetPeriode($p_cn,$p_to); + if ( $a_start == null or $a_end == null ) + { + echo_debug(__FILE__,__LINE__,'Attention periode '. + ' non trouvee periode p_from='.$p_from. + 'p_to_periode = '.$p_to); + } - return $periode; + $p_from=($a_start==null)?'01.01.1900':$a_start['p_start']; + $p_to=($a_end==null)?'01.01.2100':$a_end['p_end']; + } + if ( $p_from == $p_to ) + $periode=" $p_field = to_date('$p_from','DD.MM.YYYY') "; + else + $periode = "$p_field in (select p_id from parm_periode ". + " where p_start >= to_date('$p_from','DD.MM.YYYY') and p_end <= to_date('$p_to','DD.MM.YYYY')) "; + + return $periode; } diff --git a/include/class_balance.php b/include/class_balance.php index d6de72e08..68c9b2ccc 100644 --- a/include/class_balance.php +++ b/include/class_balance.php @@ -38,8 +38,8 @@ class Balance { /*! * \brief retrieve all the row from the ledger in the range of a periode - * \param $p_from_periode start periode - * \param $p_to_periode end periode + * \param $p_from_periode start periode (p_id) + * \param $p_to_periode end periode (p_id) * * \return a double array * array of @@ -52,7 +52,8 @@ class Balance { */ function GetRow($p_from_periode,$p_to_periode) { - $per_sql=sql_filter_per($p_from_periode,$p_to_periode,'j_tech_per'); + // filter on requested periode + $per_sql=sql_filter_per($this->db,$p_from_periode,$p_to_periode,'p_id','j_tech_per'); // if centralized $cent=""; diff --git a/include/class_jrn.php b/include/class_jrn.php index 6cc9a89f9..c7fd6ecab 100644 --- a/include/class_jrn.php +++ b/include/class_jrn.php @@ -66,7 +66,7 @@ class jrn { echo_debug('class_jrn.php',__LINE__,"GetRow ( $p_from,$p_to,$cent,$p_limit,$p_offset)"); - $periode=sql_filter_per($p_from,$p_to); + $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; diff --git a/include/class_poste.php b/include/class_poste.php index b5a63f9c6..7fc2e8cb7 100644 --- a/include/class_poste.php +++ b/include/class_poste.php @@ -47,7 +47,7 @@ class poste { */ function GetRow($p_from,$p_to) { - $periode=sql_filter_per($p_from,$p_to); + $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); $Res=ExecSql($this->db,"select to_char(j_date,'DD.MM.YYYY') as j_date,". diff --git a/include/constant.php b/include/constant.php index dad60a322..c3aed7f43 100644 --- a/include/constant.php +++ b/include/constant.php @@ -24,6 +24,7 @@ */ define ("phpcompta_password","dany"); +define ("phpcompta_psql_port","5432"); define ("domaine",""); define ("DEBUG","true"); diff --git a/include/impress_fiche.php b/include/impress_fiche.php index 06072442e..ecbbc415b 100644 --- a/include/impress_fiche.php +++ b/include/impress_fiche.php @@ -57,7 +57,7 @@ if ( isset ($_REQUEST['fd_id'])) { // propose de calculer aussi le solde //-- if ( $fiche_def->HasAttribute(ATTR_DEF_ACCOUNT) == true ) { - echo '
'; + echo ''; // filter on the current year $filter_year=" where p_exercice='".$User->getExercice()."'"; @@ -110,9 +110,9 @@ if ( isset ($_REQUEST['fd_id'])) { $with_amount) { $account=new poste ($cn,$dattribut->av_text); - $solde= $account->GetSoldeDetail("j_tech_per between ".$_REQUEST['from_periode']. - " and ". - $_REQUEST['to_periode']); + $sql_periode=sql_filter_per($cn,$_REQUEST['from_periode'],$_REQUEST['to_periode'],'p_id','j_tech_per'); + $solde= $account->GetSoldeDetail($sql_periode); + printf ("% 10.2f",$solde['debit']); printf ("% 10.2f",$solde['credit']); printf ("% 10.2f",$solde['solde']); diff --git a/include/impress_inc.php b/include/impress_inc.php index 4446bad60..6922c6480 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -730,7 +730,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true) { return $p_formula; } - $cond=sql_filter_per($p_start,$p_end,'j_tech_per'); + $cond=sql_filter_per($p_cn,$p_start,$p_end,'p_id','j_tech_per'); include_once("class_poste.php"); while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) { @@ -768,7 +768,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true) { // the clause from is something else // Compute the cond - $cond=sql_filter_per($from,$p_end,'j_tech_per'); + $cond=sql_filter_per($p_cn,$from,$p_end,'p_id','j_tech_per'); } // We remove FROM out of the p_formula $p_formula=substr_replace($p_formula,"",strpos($p_formula,"FROM")); diff --git a/include/postgres.php b/include/postgres.php index f8073bf9a..c0017c150 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -96,7 +96,8 @@ function DbConnect($p_db=-1,$p_type='dossier') { } } $password=phpcompta_password; - $a=pg_connect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password'"); + $port=phpcompta_psql_port; + $a=pg_connect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password' port=$port"); echo_debug ('postgres.php',__LINE__,"connect to $p_db dbname $l_dossier"); return $a; }