Пример #1
0
/**
 * Generate income fields and populate it with existing data
 */
function getIncomeEntries()
{
    global $incomeTypes;
    global $incomes;
    global $incomeEntries;
    global $inputErrors;
    $result = "";
    $incomeIndex = 0;
    $numEntries = $inputErrors ? count($incomeEntries) : count($incomes);
    do {
        $result .= '<div class="incomeEntry"> ';
        $result .= '<label for="incomeDesc' . $incomeIndex . '" class="altDescLabel">Description: </label>';
        $result .= '<input type="text" id="incomeDesc' . $incomeIndex . '" name="incomeDesc' . $incomeIndex . '" class="desc';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            if ($incomeEntries[$incomeIndex]["descError"]) {
                $result .= ' descError';
            }
        }
        $result .= '" placeholder="Description" maxlength="' . Income::MAX_DESC_LENGTH . '"';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            $result .= ' value="';
            $result .= htmlentities($incomeEntries[$incomeIndex]["desc"]);
            $result .= '"';
        } else {
            if (isset($incomes[$incomeIndex])) {
                $result .= ' value="';
                $result .= htmlentities($incomes[$incomeIndex]->description);
                $result .= '"';
            }
        }
        $result .= '> ';
        $result .= '<label for="incomeType' . $incomeIndex . '" class="altTypeLabel">Category: </label>';
        $result .= '<select id="incomeType' . $incomeIndex . '" name="incomeType' . $incomeIndex . '" class="type';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            if ($incomeEntries[$incomeIndex]["typeError"]) {
                $result .= ' typeError';
            }
        }
        $result .= '"> ';
        foreach ($incomeTypes as $incomeType) {
            $result .= '<option value="' . $incomeType->category . '"';
            if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
                if ($incomeEntries[$incomeIndex]["type"] === $incomeType->category) {
                    $result .= "selected";
                }
            } else {
                if (isset($incomes[$incomeIndex])) {
                    if ($incomes[$incomeIndex]->typeID === $incomeType->id) {
                        $result .= "selected";
                    }
                }
            }
            $result .= '>';
            $result .= $incomeType->category;
            $result .= '</option> ';
        }
        $result .= '</select> ';
        $result .= '<label for="incomeAmount' . $incomeIndex . '" class="altAmountLabel">Amount: </label>';
        $result .= '<input type="text" maxlength="20" id="incomeAmount' . $incomeIndex . '" name="incomeAmount' . $incomeIndex . '" class="amount';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            if ($incomeEntries[$incomeIndex]["amountError"]) {
                $result .= ' amountError';
            }
        }
        $result .= '" placeholder="Amount"';
        if ($inputErrors && isset($incomeEntries[$incomeIndex])) {
            $result .= ' value="';
            $result .= htmlentities($incomeEntries[$incomeIndex]["amount"]);
            $result .= '"';
        } else {
            if (isset($incomes[$incomeIndex])) {
                $result .= ' value="';
                $result .= htmlentities(Income::formatDisplayAmount($incomes[$incomeIndex]->amount));
                $result .= '"';
            }
        }
        $result .= '> ';
        $result .= '<label class="removeLabel">Remove: </label>';
        $result .= '<button type="button" id="deleteIncomeButton' . $incomeIndex . '" name="deleteIncomeButton' . $incomeIndex . '" class="deleteButton" title="Delete"> ';
        $result .= '&#10006;';
        $result .= '</button> ';
        $result .= '<br> ';
        $result .= '</div> ';
        $incomeIndex++;
    } while ($incomeIndex < $numEntries);
    return $result;
}
Пример #2
0
<script type="text/javascript">
    var totalIncome = <?php 
echo htmlentities($totalIncome);
?>
;
    var totalExpenses = <?php 
echo htmlentities($totalExpenses);
?>
;
    var totalIncomeDisplayString = "<?php 
echo htmlentities(Income::formatDisplayAmount($totalIncome));
?>
";
    var totalExpensesDisplayString = "<?php 
echo htmlentities(Expense::formatDisplayAmount($totalExpenses));
?>
";
    var totalTitle = "Income/Expenses";
    var incomeTitle = "Income";
    var expensesTitle = "Expenses";

    var totalChartArray = [<?php 
echo '["Type", "Amount"], ["Income", totalIncome], ["Expenses", totalExpenses]';
?>
];
    var incomeChartArray = [["Category", "Amount"],
        <?php 
foreach ($incomeTypeAmounts as $index => $incomeTypeAmount) {
    echo "['" . htmlentities($incomeTypeAmount["type"]) . "', " . htmlentities($incomeTypeAmount["amount"]) . "]";
    if ($index !== count($incomeTypeAmounts) - 1) {
        echo ", ";
Пример #3
0
<h3>Income</h3>
<table id="incomeSummaryTable">
    <tr>
        <th>Category</th>
        <th>Total</th>
    </tr>
    <?php 
foreach ($incomeTypeAmounts as $incomeTypeAmount) {
    ?>
        <tr>
            <td><?php 
    echo htmlentities($incomeTypeAmount["type"]);
    ?>
</td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeTypeAmount["amount"]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
<div id="incomeChart"></div>

<h3>Expenses</h3>
<table id="expensesSummaryTable">
    <tr>
        <th>Category</th>
        <th>Total</th>
    </tr>
Пример #4
0
        <th>Expenses</th>
        <th>Net</th>
    </tr>
    <?php 
for ($ii = 1; $ii <= $daysInSelectedMonth; $ii++) {
    ?>
        <tr>
            <td><a href="<?php 
    echo BASE_URL . "main/?month={$selectedMonth}&day={$ii}&year={$selectedYear}";
    ?>
"><?php 
    echo $selectedMonthName . " " . $ii;
    ?>
</a></td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeEachDay[$ii - 1]));
    ?>
</td>
            <td><?php 
    echo htmlentities(Expense::formatDisplayAmount($expenseEachDay[$ii - 1]));
    ?>
</td>
            <td><?php 
    echo htmlentities(IncomeExpenseObject::formatDisplayAmount($totalEachDay[$ii - 1]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
Пример #5
0
        <th>Expenses</th>
        <th>Net</th>
    </tr>
    <?php 
for ($ii = $firstYear; $ii <= $lastYear; $ii++) {
    ?>
        <tr>
            <td><a href="<?php 
    echo BASE_URL . "main/?view=yearly&year={$ii}";
    ?>
"><?php 
    echo $ii;
    ?>
</a></td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeEachYear[$ii]));
    ?>
</td>
            <td><?php 
    echo htmlentities(Expense::formatDisplayAmount($expenseEachYear[$ii]));
    ?>
</td>
            <td><?php 
    echo htmlentities(IncomeExpenseObject::formatDisplayAmount($totalEachYear[$ii]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>