Esempio n. 1
0
function get_users_graph_data()
{
    $users = array();
    $query = "\n        SELECT " . sql_format_date('timest') . " AS timest2\n        FROM\n            users\n        WHERE\n            uid != 1\n        ORDER BY\n            timest;\n    ";
    $result = do_query($query);
    $count = 0;
    while ($row = mysql_fetch_array($result)) {
        $timest = $row['timest2'];
        $count++;
        $users[$timest] = $count;
    }
    return $users;
}
Esempio n. 2
0
function show_withdrawals()
{
    echo "<div class='content_box'>\n";
    echo "<h3>" . _("Withdraw requests") . "</h3>\n";
    $result = do_query("\n        SELECT requests.reqid as reqid, uid, amount, " . sql_format_date("timest") . " as timest, name, bank, acc_num, sort_code\n        FROM requests\n        JOIN uk_requests\n        ON uk_requests.reqid = requests.reqid\n        WHERE req_type = 'WITHDR'\n          AND curr_type = '" . CURRENCY . "'\n          AND status = 'VERIFY'");
    $first = true;
    while ($row = mysql_fetch_assoc($result)) {
        if ($first) {
            $first = false;
            echo "<table class='display_data'>\n";
            echo "<tr>";
            // echo "<th>User</th>";
            echo "<th>" . CURRENCY . "</th>";
            echo "<th>Time</th>";
            echo "<th>Name</th>";
            echo "<th>Bank</th>";
            echo "<th>Account#</th>";
            echo "<th>BSB</th>";
            echo "</tr>\n";
        }
        $reqid = $row['reqid'];
        // $uid = $row['uid'];
        $amount = internal_to_numstr($row['amount']);
        $timest = $row['timest'];
        $name = $row['name'];
        $bank = $row['bank'];
        $acc_num = $row['acc_num'];
        $sort_code = $row['sort_code'];
        echo "<tr>";
        echo active_table_row("me", "?page=view_request&reqid={$reqid}&show_finish");
        // echo "<td>$uid</td>";
        echo "<td>{$amount}</td>";
        echo "<td>{$timest}</td>";
        echo "<td>{$name}</td>";
        echo "<td>{$bank}</td>";
        echo "<td>{$acc_num}</td>";
        echo "<td>{$sort_code}</td>";
        echo "</tr>\n";
    }
    if ($first) {
        echo "<p>No pending withdrawals.</p>\n";
    } else {
        echo "</table>\n";
    }
    echo "</div>\n";
}
Esempio n. 3
0
/**
 * @param array $config
 * @param array $response
 * @return array
 */
function paybox_traite_reponse_transaction($config, $response)
{
    $mode = $config['presta'];
    if (isset($config['mode_test']) and $config['mode_test']) {
        $mode .= "_test";
    }
    $config_id = bank_config_id($config);
    // $response['id_transaction'] Peut contenir /email ou IBSxx... en cas d'abo
    $id_transaction = intval($response['id_transaction']);
    if (!($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction)))) {
        return bank_transaction_invalide($id_transaction, array('mode' => $mode, 'erreur' => "transaction inconnue", 'log' => paybox_shell_args($response)));
    }
    // ok, on traite le reglement
    $date = $_SERVER['REQUEST_TIME'];
    $date_paiement = sql_format_date(date('Y', $date), date('m', $date), date('d', $date), date('H', $date), date('i', $date), date('s', $date));
    $erreur = paybox_response_code($response['erreur']);
    $authorisation_id = $response['auth'];
    $transaction = $response['trans'];
    if (!$transaction or !$authorisation_id or $erreur !== true) {
        // regarder si l'annulation n'arrive pas apres un reglement (internaute qui a ouvert 2 fenetres de paiement)
        if ($row['reglee'] == 'oui') {
            return array($id_transaction, true);
        }
        // sinon enregistrer l'absence de paiement et l'erreur
        return bank_transaction_echec($id_transaction, array('mode' => $mode, 'config_id' => $config_id, 'date_paiement' => $date_paiement, 'code_erreur' => $response['erreur'], 'erreur' => $erreur, 'log' => paybox_shell_args($response), 'send_mail' => in_array($response['erreur'], array(3, 6)) ? true : false));
    }
    // Ouf, le reglement a ete accepte
    // on verifie que le montant est bon !
    $montant_regle = $response['montant'] / 100;
    if ($montant_regle != $row['montant']) {
        spip_log($t = "call_response : id_transaction {$id_transaction}, montant regle {$montant_regle}!=" . $row['montant'] . ":" . paybox_shell_args($response), $mode);
        // on log ca dans un journal dedie
        spip_log($t, $mode . '_reglements_partiels');
    }
    $set = array("autorisation_id" => "{$transaction}/{$authorisation_id}", "mode" => "{$mode}/{$config_id}", "montant_regle" => $montant_regle, "date_paiement" => $date_paiement, "statut" => 'ok', "reglee" => 'oui');
    // type et numero de carte ?
    if (isset($response['carte']) or isset($response['BIN6'])) {
        // par defaut on note carte et BIN6 dans refcb
        $set['refcb'] = '';
        if (isset($response['carte'])) {
            $set['refcb'] .= $response['carte'];
        }
        if (isset($response['BIN6'])) {
            $set['refcb'] .= " " . $response['BIN6'];
        }
        $set['refcb'] = trim($set['refcb']);
    }
    // validite de carte ?
    if (isset($response['valid']) and $response['valid']) {
        $set['validite'] = "20" . substr($response['valid'], 0, 2) . "-" . substr($response['valid'], 2, 2);
    }
    // si on a envoye un U il faut recuperer les donnees CB et les stocker sur le compte client
    if (isset($response['ppps']) and $response['ppps']) {
        $set['pay_id'] = $response['ppps'];
    }
    // si abonnement, stocker les 2 infos importantes : uid et validite
    if (isset($response['abo']) and $response['abo']) {
        $set['abo_uid'] = $response['abo'];
    }
    // il faudrait stocker le $transaction aussi pour d'eventuels retour vers paybox ?
    sql_updateq("spip_transactions", $set, "id_transaction=" . intval($id_transaction));
    spip_log("call_response : id_transaction {$id_transaction}, reglee", $mode);
    $regler_transaction = charger_fonction('regler_transaction', 'bank');
    $regler_transaction($id_transaction, array('row_prec' => $row));
    return array($id_transaction, true);
}
Esempio n. 4
0
function fetch_order_info($orderid)
{
    $query = "\n        SELECT\n            *,\n            " . sql_format_date("timest") . " AS timest_format\n        FROM orderbook\n        WHERE orderid='{$orderid}';\n    ";
    $result = do_query($query);
    $row = get_row($result);
    $info = new OrderInfo($row);
    return $info;
}
Esempio n. 5
0
File: dater.php Progetto: JLuc/SPIP
/**
 * Traitement du formulaire d'édition d'une date
 *
 * @param string $objet
 *     Type d'objet
 * @param int $id_objet
 *     Identifiant de l'objet
 * @param string $retour
 *     URL de redirection après le traitement
 * @param array|string $options
 *     Options.
 * @return Array
 *     Retours des traitements
 */
function formulaires_dater_traiter_dist($objet, $id_objet, $retour = '', $options = array())
{
    $res = array('editable' => ' ');
    if (_request('changer')) {
        $_id_objet = id_table_objet($objet);
        $table = table_objet($objet);
        $trouver_table = charger_fonction('trouver_table', 'base');
        $desc = $trouver_table($table);
        if (!$desc) {
            return array('message_erreur' => _L('erreur'));
        }
        #impossible en principe
        $champ_date = $desc['date'] ? $desc['date'] : 'date';
        $set = array();
        $charger = charger_fonction("charger", "formulaires/dater/");
        $v = $charger($objet, $id_objet, $retour, $options);
        if ($v['_editer_date']) {
            if (!($d = dater_recuperer_date_saisie(_request('date_jour')))) {
                $d = array(date('Y'), date('m'), date('d'));
            }
            if (!($h = dater_recuperer_heure_saisie(_request('date_heure')))) {
                $h = array(0, 0);
            }
            $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]);
        }
        if (isset($desc['field']['date_redac']) and $v['_editer_date_anterieure']) {
            if (!_request('date_redac_jour') or _request('sans_redac')) {
                $set['date_redac'] = sql_format_date(0, 0, 0, 0, 0, 0);
            } else {
                if (!($d = dater_recuperer_date_saisie(_request('date_redac_jour'), "date_redac"))) {
                    $d = array(date('Y'), date('m'), date('d'));
                }
                if (!($h = dater_recuperer_heure_saisie(_request('date_redac_heure')))) {
                    $h = array(0, 0);
                }
                $set['date_redac'] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]);
            }
        }
        if (count($set)) {
            $publie_avant = objet_test_si_publie($objet, $id_objet);
            include_spip('action/editer_objet');
            objet_modifier($objet, $id_objet, $set);
            $publie_apres = objet_test_si_publie($objet, $id_objet);
            if ($publie_avant !== $publie_apres) {
                // on refuse ajax pour forcer le rechargement de la page ici
                // on refera traiter une 2eme fois, mais c'est sans consequence
                refuser_traiter_formulaire_ajax();
            }
        }
    }
    if ($retour) {
        $res['redirect'] = $retour;
    }
    set_request('date_jour');
    set_request('date_redac_jour');
    set_request('date_heure');
    set_request('date_redac_heure');
    return $res;
}
/**
 * Insertion dans le pipeline formulaire_traiter (SPIP)
 * 
 * Traitement du champ date_depublie du formulaire dater
 * 
 * @param array $flux
 * @return array $flux
 */
function depublie_formulaire_traiter($flux)
{
    if ($flux['args']['form'] == 'dater' && _request('changer')) {
        //récupère les arguments objet/id_objet
        $objet = $flux['args']['args'][0];
        $id_objet = $flux['args']['args'][1];
        //on teste si il y a déjà une entrée dans spip_depublies
        $possedeDateDepublie = sql_getfetsel('date_depublie', "spip_depublies", 'id_objet=' . intval($id_objet) . ' AND objet=' . sql_quote($objet));
        $set = array();
        $set['statut'] = lire_config('depublie/statut_depublie', 'prepa');
        $set['objet'] = $objet;
        $set['id_objet'] = $id_objet;
        if ($objet && intval($id_objet)) {
            if (_request('date_depublie_jour') && !_request('sans_depublie')) {
                $d = dater_recuperer_date_saisie(_request('date_depublie_jour'));
                if (!($h = dater_recuperer_heure_saisie(_request('date_depublie_heure')))) {
                    $h = array(0, 0);
                }
                $set['date_depublie'] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]);
                //update ou insert
                if ($possedeDateDepublie) {
                    sql_updateq('spip_depublies', $set, 'id_objet=' . intval($id_objet) . ' AND objet=' . sql_quote($objet));
                } else {
                    sql_insertq('spip_depublies', $set);
                }
            } else {
                if ($possedeDateDepublie) {
                    sql_delete('spip_depublies', 'id_objet=' . intval($id_objet) . ' AND objet=' . sql_quote($objet));
                }
            }
        }
    }
    return $flux;
}
Esempio n. 7
0
function show_statement($userid, $interval = 'forever', $from_zero, $deposit_btc, $withdraw_btc, $deposit_fiat, $withdraw_fiat, $buy, $sell)
{
    global $is_logged_in, $is_admin;
    if ($userid) {
        $specified_user = true;
    } else {
        $specified_user = false;
        $userid = $is_logged_in;
    }
    $show_increments = false;
    $show_prices = true;
    echo "<div class='content_box'>\n";
    $all_users = $userid == 'all';
    $deposit_address = $create_timestamp = false;
    if ($all_users) {
        echo "<h3>" . _("Statement for All Users") . "</h3>\n";
        $check_stuff = "";
    } else {
        $openid = get_openid_for_user($userid);
        echo "<h3>" . sprintf(_("Statement for UID %s"), $userid) . "</h3>\n";
        $check_stuff = "uid='{$userid}' AND ";
        if ($is_admin) {
            $create_timestamp = get_account_creation_timest_for_user($userid);
            try {
                $deposit_address = bitcoin_get_account_address($userid);
            } catch (Exception $e) {
            }
        }
    }
    echo "<form method='get'>\n" . "<p>\n" . _("Show entries from ") . "\n" . "<input type='hidden' name='page' value='statement' />\n";
    echo "<select onChange='this.form.submit()' name='interval'>\n";
    foreach (array('4 hour' => _('the last 4 hours'), '12 hour' => _('the last 12 hours'), '1 day' => _('the last 24 hours'), '3 day' => _('the last 3 days'), '1 week' => _('the last 7 days'), '1 month' => _('the last month'), '2 month' => _('the last 2 months'), '3 month' => _('the last 3 months'), '6 month' => _('the last 6 months'), '1 year' => _('the last year'), 'forever' => _('forever'), 'pending' => _('still pending')) as $key => $text) {
        printf("<option %s value='%s'>%s</option>\n", $interval == $key ? "selected='selected'" : "", $key, $text);
    }
    echo "</select>\n";
    if ($is_admin) {
        echo " for <select onChange='this.form.submit()' name='user'>\n";
        if ($all_users) {
            printf("<option value='{$is_logged_in}'>%s</option>\n", _("my account"));
            printf("<option value='all' selected='selected'>all users</option>\n");
        } else {
            if ($userid != $is_logged_in) {
                printf("<option value='{$is_logged_in}'>%s</option>\n", _("my account"));
            }
            printf("<option value='{$userid}' selected='selected'>%s</option>\n", $userid == $is_logged_in ? _("my account") : "UID {$userid}");
            echo "<option value='all'>all users</option>\n";
        }
        echo "</select>\n";
        echo " or UID or OpenID: ";
        echo "<input class='nline' type='text' name='uid'>\n";
    }
    $pending = $interval == 'pending';
    $use_interval = $interval != 'forever' && !$pending;
    $args = $specified_user ? "user={$userid}&" : "";
    $args .= "interval={$interval}";
    if ($from_zero) {
        $args .= "&fromz=1";
    }
    echo "<input type='hidden' name='form' value='1' /><br />\n";
    echo statement_checkbox('dbtc', $deposit_btc, _("Deposit") . " " . "BTC", $args);
    echo statement_checkbox('wbtc', $withdraw_btc, _("Withdraw") . " " . "BTC", $args);
    echo statement_checkbox('dfiat', $deposit_fiat, _("Deposit") . " " . CURRENCY, $args);
    echo statement_checkbox('wfiat', $withdraw_fiat, _("Withdraw") . " " . CURRENCY, $args);
    echo statement_checkbox('bbtc', $buy, _("Buy") . " " . "BTC", $args);
    echo statement_checkbox('sbtc', $sell, _("Sell") . " " . "BTC", $args);
    if ($interval != 'forever') {
        echo statement_checkbox('fromz', $from_zero, _("Start at Zero"));
    } else {
        if ($from_zero) {
            echo "<input type='hidden' name='fromz' value='1' />\n";
        }
    }
    echo "</p>\n";
    echo "</form>\n";
    if (!$all_users) {
        echo "<p>" . _("OpenID") . ": <a href=\"{$openid}\">{$openid}</a></p>\n";
        if ($deposit_address) {
            echo "<p>" . _("Deposit Address") . ": {$deposit_address}</p>\n";
        }
    }
    $query = "\n        SELECT\n            uid,\n            txid, a_orderid AS orderid,\n            a_amount AS gave_amount, '" . CURRENCY . "' AS gave_curr,\n            (b_amount-b_commission) AS got_amount,  'BTC' AS got_curr,\n            NULL as reqid,  NULL as req_type,\n            NULL as amount, NULL as curr_type, NULL as addy, NULL as voucher, NULL as final, NULL as bank, NULL as acc_num,\n            " . sql_format_date('transactions.timest') . " AS date,\n            transactions.timest as timest, " . ($use_interval ? "transactions.timest > NOW() - INTERVAL {$interval}" : ($pending ? "0" : "1")) . " AS new\n        FROM\n            transactions\n        JOIN\n            orderbook\n        ON\n            orderbook.orderid = transactions.a_orderid\n        WHERE\n            {$check_stuff}\n            b_amount != -1\n\n    UNION\n\n        SELECT\n            uid,\n            txid, b_orderid AS orderid,\n            b_amount AS gave_amount, 'BTC' AS gave_curr,\n            (a_amount-a_commission) AS got_amount,  '" . CURRENCY . "' AS got_curr,\n            NULL, NULL,\n            NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n            " . sql_format_date('transactions.timest') . " AS date,\n            transactions.timest as timest, " . ($use_interval ? "transactions.timest > NOW() - INTERVAL {$interval}" : ($pending ? "0" : "1")) . " AS new\n        FROM\n            transactions\n        JOIN\n            orderbook\n        ON\n            orderbook.orderid=transactions.b_orderid\n        WHERE\n            {$check_stuff}\n            b_amount != -1\n\n    UNION\n\n        SELECT\n            uid,\n            NULL, NULL,\n            NULL, NULL,\n            NULL, NULL,\n            requests.reqid,  req_type,\n            amount, curr_type, addy, CONCAT(prefix, '-...') as voucher, status = 'FINAL', bank, acc_num,\n            " . sql_format_date('timest') . " AS date,\n            timest, " . ($use_interval ? "timest > NOW() - INTERVAL {$interval}" : ($pending ? "status != 'FINAL'" : "1")) . " AS new\n        FROM\n            requests\n        LEFT JOIN\n            bitcoin_requests\n        ON\n            requests.reqid = bitcoin_requests.reqid\n        LEFT JOIN\n            voucher_requests\n        ON\n            (requests.reqid = voucher_requests.reqid OR\n             requests.reqid = voucher_requests.redeem_reqid)\n        LEFT JOIN\n            uk_requests\n        ON\n            requests.reqid = uk_requests.reqid\n        WHERE\n            {$check_stuff}\n            status != 'CANCEL'\n\n    ORDER BY\n        timest, txid, got_curr\n    ";
    $first = true;
    $result = do_query($query);
    $fiat = $btc = numstr_to_internal(0);
    $total_fiat_deposit = $total_fiat_withdrawal = $total_btc_deposit = $total_btc_withdrawal = numstr_to_internal(0);
    $total_fiat_got = $total_fiat_given = $total_btc_got = $total_btc_given = numstr_to_internal(0);
    $period_fiat_deposit = $period_fiat_withdrawal = $period_btc_deposit = $period_btc_withdrawal = numstr_to_internal(0);
    $period_fiat_got = $period_fiat_given = $period_btc_got = $period_btc_given = numstr_to_internal(0);
    echo "<table class='display_data'>\n";
    echo "<tr>";
    echo "<th>" . _("Date") . "</th>";
    if ($all_users) {
        echo "<th>" . _("User") . "</th>";
    }
    echo "<th>" . _("Description") . "</th>";
    if (!$pending) {
        if ($show_prices) {
            echo "<th class='right'>" . _("Price") . "</th>";
        }
        if ($show_increments) {
            echo "<th class='right'>+/-</th>";
        }
        echo "<th class='right'>BTC</th>";
        if ($show_increments) {
            echo "<th class='right'>+/-</th>";
        }
        echo "<th class='right'>" . CURRENCY . "</th>";
    }
    echo "</tr>\n";
    if ($create_timestamp && !$pending) {
        printf("<tr><td>%s</td><td>%s</td></tr>\n", $create_timestamp, _("Create Account"));
    }
    $all_final = true;
    while ($row = mysql_fetch_array($result)) {
        $new = $row['new'];
        $uid = $row['uid'];
        $date = $row['date'];
        if ($first && $new) {
            if ($from_zero) {
                $btc = $fiat = numstr_to_internal(0);
            }
            show_balances_in_statement(_("Opening Balances"), $btc, $fiat, $all_users, $show_prices, $show_increments, $pending);
            $first = false;
        }
        if (isset($row['txid'])) {
            /* buying or selling */
            $txid = $row['txid'];
            $orderid = $row['orderid'];
            $gave_amount = $row['gave_amount'];
            $gave_curr = $row['gave_curr'];
            $got_amount = $row['got_amount'];
            $got_curr = $row['got_curr'];
            if ($got_curr == 'BTC') {
                /* buying BTC */
                if ($buy) {
                    $fiat = gmp_sub($fiat, $gave_amount);
                    $btc = gmp_add($btc, $got_amount);
                }
                $total_btc_got = gmp_add($total_btc_got, $got_amount);
                $total_fiat_given = gmp_add($total_fiat_given, $gave_amount);
                $got_str = internal_to_numstr($got_amount, BTC_PRECISION);
                $gave_str = internal_to_numstr($gave_amount, FIAT_PRECISION);
                if ($new && $buy) {
                    $period_btc_got = gmp_add($period_btc_got, $got_amount);
                    $period_fiat_given = gmp_add($period_fiat_given, $gave_amount);
                    if (string_is_zero($got_str) && string_is_zero($gave_str)) {
                        continue;
                    }
                    echo "<tr><td>{$date}</td>";
                    if ($all_users) {
                        echo active_table_cell_link_to_user_statement($uid, $interval);
                    }
                    active_table_cell_for_order(sprintf(_("Buy %s %s for %s %s"), $got_str, $got_curr, $gave_str, $gave_curr), $orderid);
                    if ($show_prices) {
                        printf("<td>%s</td>", trade_price($got_amount, $gave_amount));
                    }
                    if ($show_increments) {
                        printf("<td class='right'>+ %s</td>", $got_str);
                    }
                    printf("<td class='right'> %s</td>", internal_to_numstr($btc, BTC_PRECISION));
                    if ($show_increments) {
                        printf("<td class='right'>- %s</td>", $gave_str);
                    }
                    printf("<td class='right'> %s</td>", internal_to_numstr($fiat, FIAT_PRECISION));
                    echo "</tr>\n";
                }
            } else {
                /* selling BTC */
                if ($sell) {
                    $fiat = gmp_add($fiat, $got_amount);
                    $btc = gmp_sub($btc, $gave_amount);
                }
                $total_fiat_got = gmp_add($total_fiat_got, $got_amount);
                $total_btc_given = gmp_add($total_btc_given, $gave_amount);
                $gave_str = internal_to_numstr($gave_amount, BTC_PRECISION);
                $got_str = internal_to_numstr($got_amount, FIAT_PRECISION);
                if ($new && $sell) {
                    $period_fiat_got = gmp_add($period_fiat_got, $got_amount);
                    $period_btc_given = gmp_add($period_btc_given, $gave_amount);
                    if (string_is_zero($got_str) && string_is_zero($gave_str)) {
                        continue;
                    }
                    echo "<tr><td>{$date}</td>";
                    if ($all_users) {
                        echo active_table_cell_link_to_user_statement($uid, $interval);
                    }
                    active_table_cell_for_order(sprintf(_("Sell %s %s for %s %s"), $gave_str, $gave_curr, $got_str, $got_curr), $orderid);
                    if ($show_prices) {
                        printf("<td>%s</td>", trade_price($gave_amount, $got_amount));
                    }
                    if ($show_increments) {
                        printf("<td class='right'>-%s</td>", $gave_str);
                    }
                    // don't show balances between pairs of buy and sell rows if we're showing buy as well as sell
                    printf("<td class='right'>%s</td>", $all_users && $buy ? "" : internal_to_numstr($btc, BTC_PRECISION));
                    if ($show_increments) {
                        printf("<td class='right'>+%s</td>", $got_str);
                    }
                    printf("<td class='right'>%s</td>", $all_users && $buy ? "" : internal_to_numstr($fiat, FIAT_PRECISION));
                    echo "</tr>\n";
                }
            }
        } else {
            /* withdrawal or deposit */
            $reqid = $row['reqid'];
            $req_type = $row['req_type'];
            $amount = $row['amount'];
            $curr_type = $row['curr_type'];
            $voucher = $row['voucher'];
            $final = $row['final'];
            // echo "final is $final<br/>\n";
            $show = $req_type == 'DEPOS' && ($curr_type == 'BTC' && $deposit_btc || $curr_type != 'BTC' && $deposit_fiat) || $req_type != 'DEPOS' && ($curr_type == 'BTC' && $withdraw_btc || $curr_type != 'BTC' && $withdraw_fiat);
            if ($new && $show) {
                echo "<tr><td>{$date}</td>";
                if ($all_users) {
                    echo active_table_cell_link_to_user_statement($uid, $interval);
                }
            }
            if (!$final) {
                $all_final = false;
            }
            if ($req_type == 'DEPOS') {
                /* deposit */
                $title = '';
                if ($voucher) {
                    $title = sprintf(_("from voucher") . " &quot;%s&quot;", $voucher);
                }
                if ($curr_type == 'BTC') {
                    /* deposit BTC */
                    if ($show) {
                        $btc = gmp_add($btc, $amount);
                    }
                    $total_btc_deposit = gmp_add($total_btc_deposit, $amount);
                    if ($new && $show) {
                        $period_btc_deposit = gmp_add($period_btc_deposit, $amount);
                        active_table_cell_for_request(sprintf("<strong title='%s'>%s%s %s BTC%s</strong>", $title, $final ? "" : "* ", $voucher ? _("Redeem voucher") . ":" : _("Deposit"), internal_to_numstr($amount, BTC_PRECISION), $final ? "" : " *"), $reqid);
                        if (!$pending) {
                            if ($show_prices) {
                                printf("<td></td>");
                            }
                            if ($show_increments) {
                                printf("<td class='right'>+%s</td>", internal_to_numstr($amount, BTC_PRECISION));
                            }
                            printf("<td class='right'>%s</td>", internal_to_numstr($btc, BTC_PRECISION));
                            if ($show_increments) {
                                printf("<td></td>");
                            }
                            printf("<td></td>");
                        }
                    }
                } else {
                    /* deposit FIAT */
                    if ($show) {
                        $fiat = gmp_add($fiat, $amount);
                    }
                    $total_fiat_deposit = gmp_add($total_fiat_deposit, $amount);
                    if ($new && $show) {
                        $period_fiat_deposit = gmp_add($period_fiat_deposit, $amount);
                        active_table_cell_for_request(sprintf("<strong title='%s'>%s%s %s %s%s</strong>", $title, $final ? "" : "* ", $voucher ? _("Redeem voucher") . ":" : _("Deposit"), internal_to_numstr($amount, FIAT_PRECISION), CURRENCY, $final ? "" : " *"), $reqid);
                        if (!$pending) {
                            if ($show_prices) {
                                printf("<td></td>");
                            }
                            if ($show_increments) {
                                printf("<td></td>");
                            }
                            printf("<td></td>");
                            if ($show_increments) {
                                printf("<td class='right'>+%s</td>", internal_to_numstr($amount, FIAT_PRECISION));
                            }
                            printf("<td class='right'>%s</td>", internal_to_numstr($fiat, FIAT_PRECISION));
                        }
                    }
                }
            } else {
                /* withdrawal */
                if ($curr_type == 'BTC') {
                    /* withdraw BTC */
                    if ($show) {
                        $btc = gmp_sub($btc, $amount);
                    }
                    $total_btc_withdrawal = gmp_add($total_btc_withdrawal, $amount);
                    if ($new && $show) {
                        $period_btc_withdrawal = gmp_add($period_btc_withdrawal, $amount);
                        $addy = $row['addy'];
                        if ($addy) {
                            $title = sprintf(_("to Bitcoin address") . " &quot;%s&quot;", $addy);
                        } else {
                            if ($voucher) {
                                $title = sprintf(_("to %svoucher") . " &quot;%s&quot;", $final ? "" : _("unredeemed") . " ", $voucher);
                            }
                        }
                        active_table_cell_for_request(sprintf("<strong title='%s'>%s%s %s BTC%s</strong>", $title, $final ? "" : "* ", $voucher ? _("Create voucher") . ":" : _("Withdraw"), internal_to_numstr($amount, BTC_PRECISION), $final ? "" : " *"), $reqid);
                        if (!$pending) {
                            if ($show_prices) {
                                printf("<td></td>");
                            }
                            if ($show_increments) {
                                printf("<td class='right'>-%s</td>", internal_to_numstr($amount, BTC_PRECISION));
                            }
                            printf("<td class='right'>%s</td>", internal_to_numstr($btc, BTC_PRECISION));
                            if ($show_increments) {
                                printf("<td></td>");
                            }
                            printf("<td></td>");
                        }
                    }
                } else {
                    /* withdraw FIAT */
                    if ($show) {
                        $fiat = gmp_sub($fiat, $amount);
                    }
                    $total_fiat_withdrawal = gmp_add($total_fiat_withdrawal, $amount);
                    if ($new && $show) {
                        $period_fiat_withdrawal = gmp_add($period_fiat_withdrawal, $amount);
                        $title = '';
                        if ($voucher) {
                            $title = sprintf(_("to %svoucher") . " &quot;%s&quot;", $final ? "" : _("unredeemed") . " ", $voucher);
                        } else {
                            $title = sprintf(_("to account %s at %s"), $row['acc_num'], $row['bank']);
                        }
                        active_table_cell_for_request(sprintf("<strong title='%s'>%s%s %s %s%s</strong>", $title, $final ? "" : "* ", $voucher ? _("Create voucher") . ":" : _("Withdraw"), internal_to_numstr($amount, FIAT_PRECISION), CURRENCY, $final ? "" : " *"), $reqid);
                        if (!$pending) {
                            if ($show_prices) {
                                printf("<td></td>");
                            }
                            if ($show_increments) {
                                printf("<td></td>");
                            }
                            printf("<td></td>");
                            if ($show_increments) {
                                printf("<td class='right'>-%s</td>", internal_to_numstr($amount, FIAT_PRECISION));
                            }
                            printf("<td class='right'>%s</td>", internal_to_numstr($fiat, FIAT_PRECISION));
                        }
                    }
                }
            }
            if ($new) {
                echo "</tr>\n";
            }
        }
    }
    if ($first && $from_zero) {
        $fiat = $btc = numstr_to_internal(0);
    }
    show_balances_in_statement($first ? _("There are no entries for this period") : _("Closing Balances"), $btc, $fiat, $all_users, $show_prices, $show_increments, $pending);
    echo "</table>\n";
    if (!$all_final) {
        echo "<p>" . _("Items marked with '*' are not yet final.") . "</p>\n";
        echo "<p>" . _("Any such withdrawals and vouchers can be cancelled.") . "</p>\n";
        echo "<p>" . _("Any such deposits are pending, and should be finalised within a minute or two.") . "</p>\n";
    }
    echo "</div>";
    if (gmp_cmp($total_fiat_deposit, $period_fiat_deposit) != 0 || gmp_cmp($total_fiat_withdrawal, $period_fiat_withdrawal) != 0 || gmp_cmp($total_btc_deposit, $period_btc_deposit) != 0 || gmp_cmp($total_btc_withdrawal, $period_btc_withdrawal) != 0 || gmp_cmp($total_fiat_got, $period_fiat_got) != 0 || gmp_cmp($total_fiat_given, $period_fiat_given) != 0 || gmp_cmp($total_btc_got, $period_btc_got) != 0 || gmp_cmp($total_btc_given, $period_btc_given) != 0) {
        show_statement_summary(_("Summary of displayed entries"), $period_fiat_deposit, $period_fiat_withdrawal, $period_btc_deposit, $period_btc_withdrawal, $period_fiat_got, $period_fiat_given, $period_btc_got, $period_btc_given);
    }
    show_statement_summary(_("Account Summary"), $total_fiat_deposit, $total_fiat_withdrawal, $total_btc_deposit, $total_btc_withdrawal, $total_fiat_got, $total_fiat_given, $total_btc_got, $total_btc_given);
}
Esempio n. 8
0
/**
 * Traitement 
 *
 * @param string $objet
 * @param integer $id_objet
 * @param string $retour
 * @return Array
 */
function formulaires_dater_traiter_dist($objet, $id_objet, $retour = '')
{
    $res = array('editable' => ' ');
    if (_request('changer')) {
        $_id_objet = id_table_objet($objet);
        $table = table_objet($objet);
        $trouver_table = charger_fonction('trouver_table', 'base');
        $desc = $trouver_table($table);
        if (!$desc) {
            return array('message_erreur' => _L('erreur'));
        }
        #impossible en principe
        $champ_date = $desc['date'] ? $desc['date'] : 'date';
        $set = array();
        if (!($d = dater_recuperer_date_saisie(_request('date_jour')))) {
            $d = array(date('Y'), date('m'), date('d'));
        }
        if (!($h = dater_recuperer_heure_saisie(_request('date_heure')))) {
            $h = array(0, 0);
        }
        $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]);
        if (isset($desc['field']['date_redac'])) {
            if (!_request('date_redac_jour') or _request('sans_redac')) {
                $set['date_redac'] = sql_format_date(0, 0, 0, 0, 0, 0);
            } else {
                if (!($d = dater_recuperer_date_saisie(_request('date_redac_jour'), "date_redac"))) {
                    $d = array(date('Y'), date('m'), date('d'));
                }
                if (!($h = dater_recuperer_heure_saisie(_request('date_redac_heure')))) {
                    $h = array(0, 0);
                }
                $set['date_redac'] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]);
            }
        }
        include_spip('action/editer_objet');
        objet_modifier($objet, $id_objet, $set);
    }
    if ($retour) {
        $res['redirect'] = $retour;
    }
    set_request('date_jour');
    set_request('date_redac_jour');
    set_request('date_heure');
    set_request('date_redac_heure');
    return $res;
}
Esempio n. 9
0
            echo "    <div class='content_box'>\n";
            echo "        <h3>" . _("Finished!") . "</h3>\n";
            echo "        <p>" . sprintf(_("Request %s has been set to %s status."), $reqid, translate_request_code("FINAL")) . "</p>\n";
        } else {
            echo "    <div class='content_box'>\n";
            echo "        <h3>" . _("Warning!") . "</h3>\n";
            echo "        <p>" . sprintf(_("Request %s was cancelled before we could mark it as finished."), $reqid) . "</p>\n";
        }
        release_lock($request_uid);
    } else {
        if ($is_admin) {
            $uid_check = "";
        } else {
            $uid_check = "AND uid='{$uid}'";
        }
        $query = "\n        SELECT\n            req_type,\n            amount,\n            curr_type,\n            " . sql_format_date("timest") . " AS timest,\n            status\n        FROM requests\n        WHERE reqid='{$reqid}' {$uid_check}\n    ";
        $result = do_query($query);
        if (!has_results($result)) {
            throw new Problem('No request here', "Don't have viewing permissions.");
        }
        $row = get_row($result);
        $req_type = $row['req_type'];
        $amount = internal_to_numstr($row['amount']);
        $curr_type = $row['curr_type'];
        $timest = $row['timest'];
        $status = $row['status'];
        ?>
 <div class='content_box'>
        <h3><?php 
        echo _("Order info");
        ?>
Esempio n. 10
0
<?php

require_once 'util.php';
require_once 'view_util.php';
require_once 'openid.php';
echo "<div class='content_box'>\n";
echo "<h3>Recent Trades</h3>\n";
$query = "\n    SELECT txid,\n           a_amount,\n           a_orderid,\n           b_amount,\n           b_orderid,\n           " . sql_format_date("t.timest") . " AS timest,\n           a.uid AS a_uid,\n           b.uid AS b_uid\n    FROM transactions AS t\n    JOIN orderbook AS a\n    ON a.orderid = a_orderid\n    JOIN orderbook AS b\n    ON b.orderid = b_orderid\n    WHERE b_amount > 0\n          AND t.timest > NOW() - INTERVAL 1 DAY\n    ORDER BY txid DESC;\n";
$result = do_query($query);
$first = true;
$amount_fiat_total = $amount_btc_total = '0';
$mine = 0;
while ($row = mysql_fetch_assoc($result)) {
    $txid = $row['txid'];
    $a_amount = $row['a_amount'];
    $a_orderid = $row['a_orderid'];
    $b_amount = $row['b_amount'];
    $b_orderid = $row['b_orderid'];
    $timest = $row['timest'];
    $a_uid = $row['a_uid'];
    $b_uid = $row['b_uid'];
    $price = fiat_and_btc_to_price($a_amount, $b_amount);
    $amount_fiat_total = gmp_add($amount_fiat_total, $a_amount);
    $amount_btc_total = gmp_add($amount_btc_total, $b_amount);
    $a_amount_str = internal_to_numstr($a_amount, FIAT_PRECISION);
    $b_amount_str = internal_to_numstr($b_amount, BTC_PRECISION);
    if (string_is_zero($a_amount_str) || string_is_zero($b_amount_str)) {
        continue;
    }
    if ($first) {
        $first = false;
Esempio n. 11
0
        $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);
$query = "\n    SELECT\n        reqid,\n        req_type,\n        amount,\n        curr_type,\n        " . sql_format_date("timest") . " AS timest,\n        status\n    FROM requests\n    WHERE\n        uid='{$uid}' \n        AND (req_type='WITHDR' OR req_type='DEPOS') \n        AND status!='IGNORE'\n    ORDER BY requests.timest DESC;\n";
$result = do_query($query);
$row = mysql_fetch_assoc($result);
if ($row) {
    ?>
    <div class='content_box'>
    <h3><?php 
    echo _("Your requests");
    ?>
</h3>
    <table class='display_data'>
        <tr>
            <th><?php 
    echo _("Amount");
    ?>
</th>
Esempio n. 12
0
function paybox_traite_reponse_transaction($response, $mode = 'paybox')
{
    $id_transaction = $response['id_transaction'];
    if (!($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction)))) {
        spip_log($t = "call_response : id_transaction {$id_transaction} inconnu:" . paybox_shell_args($response), $mode);
        // on log ca dans un journal dedie
        spip_log($t, $mode . "_douteux");
        // on mail le webmestre
        $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
        $envoyer_mail($GLOBALS['meta']['email_webmaster'], "[{$mode}]Transaction Frauduleuse", $t, "{$mode}@" . $_SERVER['HTTP_HOST']);
        $message = "Une erreur est survenue, les donn&eacute;es re&ccedil;ues de la banque ne sont pas conformes. ";
        $message .= "Votre r&egrave;glement n'a pas &eacute;t&eacute; pris en compte (Ref : {$id_transaction})";
        sql_updateq("spip_transactions", array("message" => $message, 'statut' => 'echec'), "id_transaction=" . intval($id_transaction));
        return array($id_transaction, false);
    }
    // ok, on traite le reglement
    $date = time();
    $date_paiement = sql_format_date(date('Y', $date), date('m', $date), date('d', $date), date('H', $date), date('i', $date), date('s', $date));
    $erreur = paybox_response_code($response['erreur']);
    $authorisation_id = $response['auth'];
    $transaction = $response['trans'];
    if (!$transaction or !$authorisation_id or $erreur !== true) {
        // regarder si l'annulation n'arrive pas apres un reglement (internaute qui a ouvert 2 fenetres de paiement)
        if ($row['reglee'] == 'oui') {
            return array($id_transaction, true);
        }
        // sinon enregistrer l'absence de paiement et l'erreur
        spip_log($t = "call_response : transaction {$id_transaction} refusee :[{$erreur}]:" . paybox_shell_args($response), $mode);
        sql_updateq("spip_transactions", array("statut" => 'echec[' . $response['erreur'] . ']', 'date_paiement' => $date_paiement), "id_transaction=" . intval($id_transaction));
        if ($response['erreur'] == 3 or $response['erreur'] == 6) {
            // Erreur paybox, avertir le webmestre
            $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
            $envoyer_mail($GLOBALS['meta']['email_webmaster'], "[{$mode}]Transaction Impossible", $t, "{$mode}@" . $_SERVER['HTTP_HOST']);
        }
        $message = "Aucun r&egrave;glement n'a &eacute;t&eacute; r&eacute;alis&eacute;" . ($erreur === true ? "" : " ({$erreur})");
        sql_updateq("spip_transactions", array("message" => $message), "id_transaction=" . intval($id_transaction));
        return array($id_transaction, false);
    }
    // Ouf, le reglement a ete accepte
    // on verifie que le montant est bon !
    $montant_regle = $response['montant'] / 100;
    if ($montant_regle != $row['montant']) {
        spip_log($t = "call_response : id_transaction {$id_transaction}, montant regle {$montant_regle}!=" . $row['montant'] . ":" . paybox_shell_args($response), $mode);
        // on log ca dans un journal dedie
        spip_log($t, $mode . '_reglements_partiels');
    }
    // il faudrait stocker le $transaction aussi pour d'eventuels retour vers paybox ?
    sql_updateq("spip_transactions", array("autorisation_id" => "{$transaction}/{$authorisation_id}", "mode" => $mode, "montant_regle" => $montant_regle, "date_paiement" => $date_paiement, "statut" => 'ok', "reglee" => 'oui'), "id_transaction=" . intval($id_transaction));
    spip_log("call_response : id_transaction {$id_transaction}, reglee", $mode);
    $regler_transaction = charger_fonction('regler_transaction', 'bank');
    $regler_transaction($id_transaction, "", $row);
    return array($id_transaction, true);
}
Esempio n. 13
0
{
    $url = "?page=view_order&orderid={$orderid}&uid={$uid}";
    echo "<td class='active right' id='cell_{$txid}_{$orderid}_{$sub}' onmouseover='In(\"{$orderid}\");' onmouseout='Out(\"{$orderid}\");' onclick='document.location=\"{$url}\"'>", internal_to_numstr($amount, $precision), "</td>";
}
?>
<div class='content_box'>
<h3><?php 
echo _("Rates");
?>
</h3>
<?php 
show_commission_rates();
echo "</div>\n";
echo "<div class='content_box'>\n";
echo "<h3>" . _("Commission") . "</h3>\n";
$query = "\n    SELECT txid,\n           a_orderid, a_amount, a_commission,\n           b_orderid, b_amount, b_commission, " . sql_format_date("t.timest") . " as timest,\n           a.uid as a_uid, b.uid as b_uid\n    FROM transactions AS t\n    JOIN\n        orderbook AS a\n    ON\n        a.orderid = a_orderid\n    JOIN\n        orderbook AS b\n    ON\n        b.orderid = b_orderid\n    WHERE a_commission != 0\n          OR b_commission != 0\n    ORDER BY txid;\n";
$result = do_query($query);
$first = true;
$commission_fiat_total = $commission_btc_total = '0';
$amount_fiat_total = $amount_btc_total = '0';
$cells = array();
while ($row = mysql_fetch_assoc($result)) {
    if ($first) {
        $first = false;
        echo "<table class='display_data'>\n";
        echo "<tr>";
        echo "<th></th>";
        echo "<th style='text-align: center;' colspan=2>" . CURRENCY . "</th>";
        echo "<th style='text-align: center;' colspan=2>BTC</th>";
        echo "</tr>";
        echo "<tr>";
Esempio n. 14
0
function display_transactions($uid, $orderid)
{
    global $is_logged_in, $is_admin;
    $ordselq = '';
    if (!$orderid) {
        $sort = "DESC";
    } else {
        $sort = "ASC";
        $ordselq = " AND orderbook.orderid='{$orderid}' ";
    }
    $query = "\n        SELECT\n            orderbook.orderid AS orderid,\n            IF(transactions.a_orderid=orderbook.orderid, 'A', 'B') AS who,\n            transactions.a_amount AS a_amount,\n            transactions.b_amount AS b_amount,\n            transactions.a_commission AS a_commission,\n            transactions.b_commission AS b_commission,\n            orderbook.type AS type,\n            orderbook.want_type AS want_type,\n            " . sql_format_date("transactions.timest") . " AS timest\n        FROM transactions\n        JOIN orderbook\n        ON\n            transactions.a_orderid=orderbook.orderid\n            OR transactions.b_orderid=orderbook.orderid\n        WHERE orderbook.uid='{$uid}' {$ordselq}\n        ORDER BY transactions.txid {$sort};\n    ";
    $result = do_query($query);
    $first = true;
    $a_total = 0;
    $b_total = 0;
    $commission_total = 0;
    $count = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $count++;
        $who = $row['who'];
        $a_amount = $row['a_amount'];
        $b_amount = $row['b_amount'];
        $a_commission = $row['a_commission'];
        $b_commission = $row['b_commission'];
        if ($who == 'B') {
            list($a_amount, $b_amount) = array($b_amount, $a_amount);
            $b_commission = $a_commission;
        }
        // skip cancelled orders since we already show those
        if ((int) $b_amount == -1) {
            continue;
        }
        if ($first) {
            $first = false;
            ?>
 <div class='content_box'>
            <h3>
<?php 
            if ($is_logged_in == $uid) {
                echo _("Your trades") . " ";
            } else {
                echo _("Trades") . " ";
            }
            if ($orderid) {
                echo _('for this order');
            }
            ?>
</h3>
            <table class='display_data'>
                <tr>
<?php 
            if (!$orderid) {
                ?>
                    <th class='right'><?php 
                echo _("Order");
                ?>
</th>
<?php 
            }
            ?>
                    <th class='right'><?php 
            echo _("You gave");
            ?>
</th>
                    <th class='right'><?php 
            echo _("You got");
            ?>
</th>
                    <th class='right'><?php 
            echo _("Commission");
            ?>
</th>
                    <th class='right'><?php 
            echo _("Price");
            ?>
</th>
                    <th class='center'><?php 
            echo _("Time");
            ?>
</th>
                </tr><?php 
        }
        $a_total = gmp_add($a_total, $a_amount);
        $b_total = gmp_add($b_total, $b_amount);
        $commission_total = gmp_add($commission_total, $b_commission);
        if ($b_amount) {
            $commission_percent = bcdiv(bcmul($b_commission, 100), $b_amount, 3);
        } else {
            $commission_percent = 0;
        }
        $b_amount = gmp_sub($b_amount, $b_commission);
        $type = $row['type'];
        $want_type = $row['want_type'];
        $price = 0;
        if ($type == 'BTC') {
            if ($a_amount) {
                $price = fiat_and_btc_to_price($b_amount, $a_amount);
            }
        } else {
            if ($b_amount) {
                $price = fiat_and_btc_to_price($a_amount, $b_amount);
            }
        }
        $this_orderid = $row['orderid'];
        $timest = $row['timest'];
        $give_precision = $type == 'BTC' ? BTC_PRECISION : FIAT_PRECISION;
        $want_precision = $type == 'BTC' ? FIAT_PRECISION : BTC_PRECISION;
        if (!$orderid) {
            echo "    ", active_table_row("active", "?page=view_order&orderid={$this_orderid}"), "\n";
        } else {
            echo "    <tr>\n";
        }
        echo "        ";
        if (!$orderid) {
            echo "<td class='right'>{$this_orderid}</td>";
        }
        echo "<td class='right'>" . internal_to_numstr($a_amount, $give_precision) . " {$type}</td>";
        echo "<td class='right'>" . internal_to_numstr($b_amount, $want_precision) . " {$want_type}</td>";
        echo "<td class='right'>" . internal_to_numstr($b_commission, $want_precision) . " {$want_type} (", sprintf("%.2f", $commission_percent), "%)</td>";
        echo "<td class='right'>{$price}</td>";
        echo "<td class='right'>{$timest}</td>\n";
        echo "    </tr>\n";
    }
    // if we showed any table at all
    if (!$first) {
        // if we need to show a summary line
        if ($orderid && $count > 1) {
            $commission_percent = bcdiv(bcmul(gmp_strval($commission_total), 100), gmp_strval($b_total), 3);
            $b_total = gmp_sub($b_total, $commission_total);
            $price = 0;
            if ($type == 'BTC') {
                if ($a_total) {
                    $price = fiat_and_btc_to_price($b_total, $a_total);
                }
            } else {
                if ($b_total) {
                    $price = fiat_and_btc_to_price($a_total, $b_total);
                }
            }
            $a_total = internal_to_numstr($a_total, $give_precision);
            $b_total = internal_to_numstr($b_total, $want_precision);
            $commission_total = internal_to_numstr($commission_total, $want_precision);
            echo "    <tr>\n";
            echo "        <td class='right'>--------</td><td class='right'>--------</td><td class='right'>--------</td><td class='right'>--------</td>\n";
            echo "        <td></td>\n";
            echo "    </tr>\n";
            echo "    <tr>\n";
            echo "        <td class='right'>{$a_total} {$type}</td><td class='right'>{$b_total} {$want_type}</td><td class='right'>{$commission_total} {$want_type} (", sprintf("%.2f", $commission_percent), "%)</td><td class='right'>{$price}</td>\n";
            echo "        <td></td>\n";
            echo "    </tr>\n";
        }
        echo "</table>\n";
        echo "<p>" . _("The 'you got' column is the amount you received after commission was taken off.") . "</p>";
        echo "<p>" . _("The 'price' column shows the effective price of the trade, after commission.") . "</p>";
        echo "</div>\n";
    }
}