140 |
if ($Max==0) return $ret=""; |
if ($Max==0) return $ret=""; |
141 |
for ($i=0;$i<$Max;$i++) { |
for ($i=0;$i<$Max;$i++) { |
142 |
$l_line=pg_fetch_array($Res,$i); |
$l_line=pg_fetch_array($Res,$i); |
143 |
$col=ParseFormula($p_cn, |
$col=GetFormulaValue($p_cn, |
144 |
$l_line['fo_label'], |
$l_line['fo_label'], |
145 |
$l_line['fo_formula'],$cond); |
$l_line['fo_formula'],$cond); |
146 |
echo "<div>"; |
echo "<div>"; |
705 |
|
|
706 |
} |
} |
707 |
/* function ParseFormula |
/* function ParseFormula |
708 |
|
* Purpose Parse a formula |
709 |
|
* |
710 |
|
* parm : |
711 |
|
* - $p_cn connexion |
712 |
|
* - $p_label |
713 |
|
* - $p_formula |
714 |
|
* gen : |
715 |
|
* - none |
716 |
|
* return: |
717 |
|
* - array |
718 |
|
* |
719 |
|
*/ |
720 |
|
function ParseFormula($p_cn,$p_label,$p_formula,$p_cond) { |
721 |
|
while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) { |
722 |
|
include_once("class_poste.php"); |
723 |
|
// remove the [ ] |
724 |
|
$x=$e; |
725 |
|
$e[0]=str_replace ("[","",$e[0]); |
726 |
|
$e[0]=str_replace ("]","",$e[0]); |
727 |
|
// Get sum of account |
728 |
|
$P=new poste($p_cn,$e[0]); |
729 |
|
$i=$P->GetSolde($p_cond); |
730 |
|
$p_formula=str_replace($x,$i,$p_formula); |
731 |
|
} |
732 |
|
$p_formula="\$result=".$p_formula.";"; |
733 |
|
echo_debug(__FILE__,__LINE__, $p_formula); |
734 |
|
|
735 |
|
eval("$p_formula"); |
736 |
|
$aret=array('desc'=>$p_label, |
737 |
|
'montant'=>$result); |
738 |
|
return $aret; |
739 |
|
} |
740 |
|
/* function GetFormulaValue |
741 |
* Purpose : Parse the formula contained in the fo_formula |
* Purpose : Parse the formula contained in the fo_formula |
742 |
* field and return a array containing all the columns |
* field and return a array containing all the columns |
743 |
* |
* |
751 |
* - array |
* - array |
752 |
* |
* |
753 |
*/ |
*/ |
754 |
function ParseFormula($p_cn,$p_label,$p_formula,$p_cond) |
function GetFormulaValue($p_cn,$p_label,$p_formula,$p_cond) |
755 |
{ |
{ |
756 |
$aret=array(); |
$aret=array(); |
757 |
$l_debit=0; |
$l_debit=0; |