diff --git a/html/admin/test_me.php b/html/admin/test_me.php
index 4066ca15e..877bddade 100644
--- a/html/admin/test_me.php
+++ b/html/admin/test_me.php
@@ -1,15 +1,36 @@
-
+ini_set('include_path','.:../../include');
require_once('ac_common.php');
+include_once('postgres.php');
+include_once('class_jrn.php');
+include_once('class_poste.php');
+include_once('class_balance.php');
+
echo "
check sql_filter_per
";
-$a=sql_filter_per(1,1);
-$ra=($a==" jr_tech_per = 1 ")?'OK':'ERROR';
-echo $a." ".$ra."
";
-$b= FormatString(sql_filter_per('3','7'));
-$exp=FormatString('jr_tech_per in (select p_id from parm_periode where p_start >= 3 and p_end <= 7)');
-$rb=(strcmp($b,$exp)==0)?'OK':'ERROR';
+$a=sql_filter_per('01.01.1999','01.01.1999');
+echo $a."
";
+$b= sql_filter_per('01.01.2000','01.11.2006');
+
+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('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
';
+
+$a=new Balance($cn,4519); // grand livre
+$b=$a->GetRow('01.02.2000','01.01.2006');
+echo 'class_balance il y a '.sizeof($b).' données trouvée
';
-echo "Received $b
Expected $exp $rb
";
?>
diff --git a/html/ecrit_ouv.php b/html/ecrit_ouv.php
index 3a868bd81..b2bc34d46 100644
--- a/html/ecrit_ouv.php
+++ b/html/ecrit_ouv.php
@@ -110,7 +110,6 @@ if ( isset ($_GET['import'])) {
if ( strlen ( $_FILES['import_file']['tmp_name']) != 0 ) {
if ( move_uploaded_file($_FILES['import_file']['tmp_name'],$new_name) ) {
// upload succeed
- //echo "Opening: " . $new_name . "\r";
$h_file=fopen($new_name,'r') ;
// test if the file is opened
if ( $h_file == false) { echo 'Je ne peux ouvrir pas ce fichier';exit(-1);}
@@ -121,24 +120,21 @@ if ( isset ($_GET['import'])) {
$line=fgets($h_file);
// check if the first line contains the signature
- //echo "Testing line: [" . $line . "]";
- if ( $valid )
- {
- // skip blank line
- if (strlen (trim($line)) == 0 ) continue;
- // put the line into several array with the same index
- list($sign,$poste,$label,$amount)=explode(";",$line);
- $asign[$idx]=$sign; $aposte[$idx]=$poste;$aamount[$idx]=$amount;
- $alabel[$idx]=$label;
- $idx++;
+ if ( $valid )
+ {
+ // skip blank line
+ if (strlen (trim($line)) == 0 ) continue;
+ // put the line into several array with the same index
+ list($sign,$poste,$label,$amount)=explode(";",$line);
+ $asign[$idx]=$sign; $aposte[$idx]=$poste;$aamount[$idx]=$amount;
+ $alabel[$idx]=$label;
+ $idx++;
}
- else
- {
- //$valid=(($line=="OUVERTURE\n" && $valid==false) || $valid)?true:false;
- $valid = strpos($line, "OUVERTURE") !== false;
- //echo "valid: [" . $valid . "]\r";
- //echo "strpos: [" . strpos($line, "OUVERTURE") . "]\r";
- }
+ else
+ {
+ $valid = strpos($line, "OUVERTURE") !== false;
+
+ }
} // read the file
// if valid is still false then there is nothing to do
if ( ! $valid) { echo 'Aucun enregistrement valide'; return ;}
diff --git a/include/ac_common.php b/include/ac_common.php
index 554b7d77f..303bc823a 100644
--- a/include/ac_common.php
+++ b/include/ac_common.php
@@ -378,4 +378,23 @@ function Decode($p_html){
$p_html=urldecode($p_html);
return $p_html;
}
+/*!\brief Create the condition to filter on the j_tech_per
+ * thanks a from and to date.
+ * \param $p_from start date (date)
+ * \param $p_to end date (date)
+ * \param $p_field column name
+ * \return a string containg the query
+ */
+function sql_filter_per($p_from,$p_to,$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')) ";
+
+ return $periode;
+}
+
+
?>
diff --git a/include/class_balance.php b/include/class_balance.php
index d83a5b814..d6de72e08 100644
--- a/include/class_balance.php
+++ b/include/class_balance.php
@@ -52,19 +52,7 @@ class Balance {
*/
function GetRow($p_from_periode,$p_to_periode) {
- if ( $p_from_periode == $p_to_periode )
- {
- $per_sql=" jr_tech_per = $p_from_periode ";
- }
- else
- {
-// $per_sql = "p_start >= (select p_start from parm_periode where p_id = $p_from_periode) ".
-// "and p_end <= (select p_end from parm_periode where p_id = $p_to_periode)";
- $periode = "jr_tech_per in (select p_id from parm_periode ".
- " where p_start >= $p_from_periode and p_end <= $p_to_periode) ";
-
- }
-
+ $per_sql=sql_filter_per($p_from_periode,$p_to_periode,'j_tech_per');
// if centralized
$cent="";
diff --git a/include/class_jrn.php b/include/class_jrn.php
index b5b3352e9..6cc9a89f9 100644
--- a/include/class_jrn.php
+++ b/include/class_jrn.php
@@ -66,13 +66,9 @@ class jrn {
echo_debug('class_jrn.php',__LINE__,"GetRow ( $p_from,$p_to,$cent,$p_limit,$p_offset)");
- if ( $p_from == $p_to )
- $periode=" jr_tech_per = $p_from ";
- else
- $periode = "jr_tech_per in (select p_id from parm_periode where p_start >= $p_from and p_end <= $p_to) ";
- // $periode = "(jr_tech_per >= $p_from and jr_tech_per <= $p_to) ";
+ $periode=sql_filter_per($p_from,$p_to);
- $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:"";
+ $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:"";
// Grand livre == 0
if ( $this->id != 0 ) {
diff --git a/include/class_poste.php b/include/class_poste.php
index 845f8352f..8792f67fa 100644
--- a/include/class_poste.php
+++ b/include/class_poste.php
@@ -47,13 +47,8 @@ class poste {
*/
function GetRow($p_from,$p_to)
{
- if ( $p_from == $p_to )
- $periode=" jr_tech_per = $p_from ";
- else
- $periode = "jr_tech_per in (select p_id from parm_periode ".
- " where p_start >= $p_from and p_end <= $p_to) ";
+ $periode=sql_filter_per($p_from,$p_to);
-// $periode = "(jr_tech_per >= $p_from and jr_tech_per <= $p_to) ";
$Res=ExecSql($this->db,"select to_char(j_date,'DD.MM.YYYY') as j_date,".
"case when j_debit='t' then j_montant else 0 end as deb_montant,".
diff --git a/include/constant.php b/include/constant.php
index 8ddbd67c4..dad60a322 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -26,7 +26,7 @@
define ("phpcompta_password","dany");
define ("domaine","");
-define ("DEBUG","false");
+define ("DEBUG","true");
// securite correspond a la table
// action
diff --git a/include/impress_inc.php b/include/impress_inc.php
index 5785a625a..87cf22979 100644
--- a/include/impress_inc.php
+++ b/include/impress_inc.php
@@ -732,13 +732,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true) {
return $p_formula;
}
-
- if ( $p_start == $p_end )
- $cond=" j_tech_per = $p_start ";
- else
- $cond = "jr_tech_per in (select p_id from parm_periode ".
- " where p_start >= $p_start and p_end <= $p_end) ";
- // $cond = "(j_tech_per >= $p_start and j_tech_per <= $p_end) ";
+ $cond=sql_filter_per($p_start,$p_end);
while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) {
include_once("class_poste.php");
diff --git a/include/postgres.php b/include/postgres.php
index 33c5ca74c..f8073bf9a 100644
--- a/include/postgres.php
+++ b/include/postgres.php
@@ -66,7 +66,17 @@ function ShowDossier($p_type,$p_first=0,$p_max=10,$p_Num=0) {
/*!
* \brief connect to the database
- * \param : p_db : db_name
+ *
example
+ *
+ * - DbConnect () connects to account_repository
+ * - DbConnect(1) connects to dossier1
+ * - DbConnect(1,'mod') connects to mod1
+ * - DbConnect(-2,'postgres') connects to the db postgres
+ *
+ *
+ * \param p_db : db_name id (or -1 for account_repository or -2 if p_type contains the full name of a database
+ *
+ * \param p_type = dossier, mod or the name of a datase
* \return the connection
*/
function DbConnect($p_db=-1,$p_type='dossier') {