diff --git a/include/class_balance.php b/include/class_balance.php index 9c1a7d2ef..d83a5b814 100644 --- a/include/class_balance.php +++ b/include/class_balance.php @@ -51,14 +51,20 @@ class Balance { * - $a['solde_cred'] */ function GetRow($p_from_periode,$p_to_periode) { - // compute periode - if ( $p_from_periode==$p_to_periode ) { - $per_sql=" j_tech_per = $p_from_periode "; - } else { - $per_sql = "j_tech_per >= $p_from_periode and j_tech_per <= $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) "; + } + // if centralized $cent=""; @@ -69,7 +75,8 @@ class Balance { ( select j_poste, case when j_debit='t' then j_montant else 0 end as deb, case when j_debit='f' then j_montant else 0 end as cred - from jrnx join tmp_pcmn on j_poste=pcm_val + from jrnx join tmp_pcmn on j_poste=pcm_val + left join parm_periode on j_tech_per = p_id where $cent $per_sql ) as m group by j_poste order by j_poste::text"; diff --git a/include/class_jrn.php b/include/class_jrn.php index 06b81fde6..b5b3352e9 100644 --- a/include/class_jrn.php +++ b/include/class_jrn.php @@ -69,7 +69,9 @@ class jrn { if ( $p_from == $p_to ) $periode=" jr_tech_per = $p_from "; else - $periode = "(jr_tech_per >= $p_from and jr_tech_per <= $p_to) "; + $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) "; + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; // Grand livre == 0 diff --git a/include/class_poste.php b/include/class_poste.php index 5c75f6081..845f8352f 100644 --- a/include/class_poste.php +++ b/include/class_poste.php @@ -50,7 +50,10 @@ class poste { if ( $p_from == $p_to ) $periode=" jr_tech_per = $p_from "; else - $periode = "(jr_tech_per >= $p_from and jr_tech_per <= $p_to) "; + $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) "; $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/import_inc.php b/include/import_inc.php index 1cdc58ce0..f23adce16 100644 --- a/include/import_inc.php +++ b/include/import_inc.php @@ -282,8 +282,6 @@ function TransferCSV($p_cn, $periode){ //remove annoying double-quote $num_compte=str_replace('"','',$num_compte); $code=str_replace('\"','',$code); - if ( strlen(trim($num_compte)) == 0 ) - $num_compte=$val['detail']; $r=InsertJrn($p_cn,$date_exec,NULL,$jrn,$detail.$num_compte." ".$code,$montant,$seq,$periode); if ( $r == false ) { Rollback($p_cn); exit(" Error 'import_inc.php' __LINE__");} diff --git a/include/impress_inc.php b/include/impress_inc.php index ec926bab4..5785a625a 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -736,7 +736,9 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true) { if ( $p_start == $p_end ) $cond=" j_tech_per = $p_start "; else - $cond = "(j_tech_per >= $p_start and j_tech_per <= $p_end) "; + $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) "; while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) { include_once("class_poste.php"); @@ -771,7 +773,10 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true) { if ( $from == $p_end ) $cond=" j_tech_per = $from "; else - $cond = "(j_tech_per >= $from and j_tech_per <= $p_end) "; + + $cond = "jr_tech_per in (select p_id from parm_periode ". + " where p_start >= $from and p_end <= $p_to) "; + } // We remove FROM out of the p_formula $p_formula=substr_replace($p_formula,"",strpos($p_formula,"FROM"));