This question already has an answer here:
So, i have these two functions in b.php:
function calcValorAberto ($coluna_usu_planoAtual_td, $bon_direta_abertoFetch, $bon_indireta_abertoFetch){
if ($coluna_usu_planoAtual_td['usu_pgto_plano'] == '12' || $coluna_usu_planoAtual_td['usu_pgto_plano'] == '6' || $coluna_usu_planoAtual_td['usu_pgto_plano'] == '3' || $coluna_usu_planoAtual_td['usu_pgto_plano'] == '1') {
$calc_indicados_aberto = $coluna_usu_planoAtual_td['usu_pgto_valorTotal']*$coluna_usu_planoAtual_td['pla_porcent_ind']/100 * $bon_direta_abertoFetch['bon_porcentagem'];
$calc_subIndicados_aberto = $coluna_usu_planoAtual_td['usu_pgto_valorTotal']*$coluna_usu_planoAtual_td['pla_porcent_sub']/100 * $bon_indireta_abertoFetch['bon_porcentagem'];
$bonificacao_aberto = $calc_indicados_aberto + $calc_subIndicados_aberto;
echo $bonificacao_aberto;
}
}
function calcValorFechado ($coluna_usu_planoAtual_td, $bon_direta_fechadoFetch, $bon_indireta_fechadoFetch){
if ($coluna_usu_planoAtual_td['usu_pgto_plano'] == '12' || $coluna_usu_planoAtual_td['usu_pgto_plano'] == '6' || $coluna_usu_planoAtual_td['usu_pgto_plano'] == '3' || $coluna_usu_planoAtual_td['usu_pgto_plano'] == '1') {
$calc_indicados_fechado = $coluna_usu_planoAtual_td['usu_pgto_valorTotal']*$coluna_usu_planoAtual_td['pla_porcent_ind']/100 * $bon_direta_fechadoFetch['bon_porcentagem'];
$calc_subIndicados_fechado = $coluna_usu_planoAtual_td['usu_pgto_valorTotal']*$coluna_usu_planoAtual_td['pla_porcent_sub']/100 * $bon_indireta_fechadoFetch['bon_porcentagem'];
$bonificacao_fechado = $calc_indicados_fechado + $calc_subIndicados_fechado;
echo $bonificacao_fechado;
}
}
And I call them in page a.php:
<?php
if (calcValorFechado ($coluna_usu_planoAtual_td, $bon_direta_fechadoFetch, $bon_indireta_fechadoFetch) == 0){ ?>
<th class="tg-5zq5">
<?php
echo '</h4><h4><b>Saldo Aberto</b></h4>';
echo '<h4>Período: <b>' . $m1_sub_dia1 . '</b> a <b>' . $m1_sub_diaU . '</b>';
echo '<h4>Valor: <b>R$';
calcValorAberto($coluna_usu_planoAtual_td, $bon_direta_abertoFetch, $bon_indireta_abertoFetch);
?>
</th>
<?php
}
else if (calcValorFechado ($coluna_usu_planoAtual_td, $bon_direta_fechadoFetch, $bon_indireta_fechadoFetch) > 0) {?>
<th class="tg-5zq5"><?php
echo "<h4><b>Saldo Fechado</b></h4>";
echo '<h4>Período: <b>' . $m1_som_dia1 . '</b> a <b>' . $m1_som_diaU . '</b>';
echo '<h4>Valor: <b>R$';
calcValorFechado ($coluna_usu_planoAtual_td, $bon_direta_fechadoFetch, $bon_indireta_fechadoFetch);
?>
</th>
<th class="tg-5zq5">
<?php
echo '<h4><b>Saldo Aberto</b></h4>';
echo '<h4>Período: <b>' . $m1_som_dia1 . '</b> a <b>' . $m1_som_diaU . '</b>';
echo '<h4>Valor: </th>';
echo "<b>R$";
calcValorAberto($coluna_usu_planoAtual_td, $bon_direta_abertoFetch, $bon_indireta_abertoFetch);
echo '</b><br><br>';
?>
</th>
<?php }
else {
echo "Nenhum IF foi ativado :(";}
?>
The problem is that the function calcValorFechado is being activated in the first if statement even if the result of the function is not 0, the result is 27.8, so, it should activate the else if (calcValorFechado() > 0 )
I'm almost sure that it is syntax problem, but I've done some researches and couldn't find anything at all.
Aucun commentaire:
Enregistrer un commentaire