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 |
* |
* |
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.";"; |