예제 #1
0
function recalculate($wallet_id)
{
    $amount_in = 0;
    $amount_out = 0;
    foreach (wallet_operations($wallet_id) as $o) {
        if ($o['type'] == 'I') {
            $amount_in += $o['amount'];
        } else {
            $amount_out += $o['amount'];
        }
    }
    mysql_query("UPDATE wallets SET amount_in=" . $amount_in . ", amount_out=" . $amount_out . " WHERE id=" . $wallet_id);
}
예제 #2
0
<section class="rounded-corners add-opacity bg-white">
<strong style="font-size:0.8em;">Historia wszystkich operacji w ramach portfela (<?php 
echo mb_convert_case(get_wallet_name_by_id($wallet_id), MB_CASE_UPPER, "UTF-8");
?>
)</strong><br />
<span style="font-size:0.8em;" class="gray">Tu możesz usunąć operację jeżeli dane zostały błędnie wprowadzone</span>

<table class="operations">
    <tr>
        <th style="width:150px;">Data</th>
        <th style="width:200px;">Kwota</th>
        <th style="width:520px;">Cel</th>
        <th style="width:50px;"></th>
    </tr>
<?php 
foreach (wallet_operations($wallet_id) as $o) {
    ?>
    <tr>
        <td style="text-align:center;"><?php 
    echo date("d-m-Y", strtotime($o['when_created']));
    ?>
</td>
        <td style="text-align:right; padding-right:20px;">
            <?php 
    if ($o['type'] == 'I') {
        echo '<span class="green">' . number_format($o["amount"], $decimals = 2, $dec_point = ".", $thousands_sep = "") . ' PLN</span>';
    } else {
        echo '<span class="red">-' . number_format($o["amount"], $decimals = 2, $dec_point = ".", $thousands_sep = "") . ' PLN</span>';
    }
    ?>
        </td>