Example #1
0
function action_get_transactions_page_json($db)
{
    $results = filter_input(INPUT_GET, 'results', FILTER_SANITIZE_NUMBER_INT);
    $start = filter_input(INPUT_GET, 'startIndex', FILTER_SANITIZE_NUMBER_INT);
    $category = filter_input(INPUT_GET, 'category', FILTER_SANITIZE_STRING);
    $account = filter_input(INPUT_GET, 'account', FILTER_SANITIZE_STRING);
    $modifiers = extract_date_modifiers($_GET['date_modifier'], 'All Transactions');
    $expenses_only = filter_input(INPUT_GET, 'expenses_only', FILTER_SANITIZE_STRING);
    $transactions = get_transactions_page($db, $start, $results, $category, $account, $modifiers, $expenses_only);
    $count = count_transactions($db, $category, $account, $modifiers, $expenses_only);
    return json_encode(array('records' => $transactions, 'recordsReturned' => sizeof($transactions), 'totalRecords' => intval($count), 'sort' => 'transaction_date', 'dir' => 'desc', 'startIndex' => intval($start), 'pageSize' => intval($results)));
}
Example #2
0
</th>
        </tr><?php 
    do {
        $orderid = $row['orderid'];
        $amount = $row['amount'];
        $initial_amount = $row['initial_amount'];
        $type = $row['type'];
        $initial_want_amount = $row['initial_want_amount'];
        $want_type = $row['want_type'];
        $timest = $row['timest'];
        // $timest = str_replace(" ", "<br/>", $timest);
        $status_code = $row['status'];
        $status = translate_order_code($status_code);
        $price = $type == 'BTC' ? fiat_and_btc_to_price($initial_want_amount, $initial_amount) : fiat_and_btc_to_price($initial_amount, $initial_want_amount);
        $percent_complete = sprintf("%.0f", bcdiv(gmp_strval(gmp_mul(gmp_sub($initial_amount, $amount), 100)), $initial_amount, 1));
        $trade_count = count_transactions($orderid);
        $give_precision = $type == 'BTC' ? BTC_PRECISION : FIAT_PRECISION;
        $want_precision = $type == 'BTC' ? FIAT_PRECISION : BTC_PRECISION;
        echo "    ", active_table_row("active", "?page=view_order&orderid={$orderid}"), "\n";
        echo "        <td class='right'>" . internal_to_numstr($initial_amount, $give_precision) . "&nbsp;{$type}</td>\n";
        echo "        <td class='right'>" . internal_to_numstr($initial_want_amount, $want_precision) . "&nbsp;{$want_type}</td>\n";
        echo "        <td class='right'>{$price}</td>\n";
        echo "        <td>{$timest}</td>\n";
        echo "        <td>{$status} ({$percent_complete}%)</td>\n";
        echo "        <td>{$trade_count}</td>\n";
        echo "    </tr>\n";
    } while ($row = mysql_fetch_assoc($result));
    echo "</table></div>";
}
// also used when you view an order
display_transactions($uid, 0);