/[phpcompta]/phpcompta/include/impress_inc.php
ViewVC logotype

Diff of /phpcompta/include/impress_inc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by stanpinte, Mon Jul 4 17:58:51 2005 UTC revision 1.19 by sparkyx, Mon Jul 4 18:34:01 2005 UTC
# Line 704  function GetRappel($p_cn,$p_jrnx_id,$p_j Line 704  function GetRappel($p_cn,$p_jrnx_id,$p_j
704    } // if type==0    } // if type==0
705        
706  }  }
707    
708  /* function ParseFormula  /* function ParseFormula
709   * Purpose Parse a formula   * Purpose Parse a formula
710   *   *
# Line 720  function GetRappel($p_cn,$p_jrnx_id,$p_j Line 721  function GetRappel($p_cn,$p_jrnx_id,$p_j
721   * NOTE: problem: the formulas don't take date range parameters into account....TODO.   * NOTE: problem: the formulas don't take date range parameters into account....TODO.
722   * --> I would like to get the sum of operations between two specified dates.   * --> I would like to get the sum of operations between two specified dates.
723   */   */
724  function ParseFormula($p_cn,$p_label,$p_formula,$p_cond) {  function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end) {
725      if ( $p_start == $p_end )
726        $cond=" j_tech_per = $p_start ";
727      else
728        $cond = "(j_tech_per >= $p_start and j_tech_per <= $p_end) ";
729      
730    while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) {    while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) {
731      include_once("class_poste.php");      include_once("class_poste.php");
732      // remove the [ ]      // remove the [ ]
733      $x=$e;      $x=$e;
734      $e[0]=str_replace ("[","",$e[0]);      $e[0]=str_replace ("[","",$e[0]);
735      $e[0]=str_replace ("]","",$e[0]);      $e[0]=str_replace ("]","",$e[0]);
736        // If there is a FROM clause we must recompute
737        // the time cond
738        if ( ereg ("FROM=[0-9]+\.[0-9]+", $p_formula,$afrom) == true ){
739          // There is a FROM clause
740          // then we must modify the cond for the periode
741          $from=str_replace("FROM=","",$afrom[0]);
742          // Get the periode
743          $from=getPeriodeFromDate($p_cn,$from);
744    
745          //  Compute the cond
746          if ( $from == $p_end )
747            $cond=" j_tech_per = $from ";
748          else
749            $cond = "(j_tech_per >= $from and j_tech_per <= $p_end) ";
750          // We remove FROM out of the p_formula
751          $p_formula=substr_replace($p_formula,"",strpos($p_formula,"FROM"));
752        }
753      // Get sum of account      // Get sum of account
754      $P=new poste($p_cn,$e[0]);      $P=new poste($p_cn,$e[0]);
755      $i=$P->GetSolde($p_cond);      $i=$P->GetSolde($cond);
756      $p_formula=str_replace($x,$i,$p_formula);      $p_formula=str_replace($x,$i,$p_formula);
757    }    }
758    $p_formula="\$result=".$p_formula.";";    $p_formula="\$result=".$p_formula.";";

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26