Exemple #1
0
function estimate_multi_month($current_month)
{
    global $connection;
    $query = "SELECT * FROM expenses WHERE num_months > 1";
    $result = mysql_query($query, $connection);
    while ($q_result = mysql_fetch_array($result)) {
        $a = allocated($q_result[num_months], $q_result[total_exp], $q_result[due_date], $current_month);
        $total = +$a;
    }
    return $total;
}
    $spent = sum_variable_exp($expense[id], $first_stamp);
    echo my_money_format($spent);
}
?>
</td>
    <!-- ALLOCATED -->
    <td><?php 
//ALLOCATED
if ($paid && $expense['type'] != 2) {
    //NOT variable AND PAID. just set $alloated to zero
    $allocated = 0;
} else {
    //NOT paid
    if ($expense['type'] != 2) {
        //not a variable expense...outputs what is allocated/month
        $allocated = allocated($expense['num_months'], $expense['total_exp'], $expense['due_date'], $thismonth);
        echo my_money_format($allocated);
    } else {
        //this is a variable expense allocate will = budgeted less spent
        if ($total > $spent) {
            //normal situation more budgeted than spent
            $allocated = $total + $spent;
            //spent will be a negative so the difference can be achieved thru simple addition
        } else {
            //more spent than budgeted
            $allocated = 0;
        }
        echo my_money_format($allocated);
    }
    //running total
    if ($expense['type'] == 0) {