function transferOverview($bill_id, $start, $end)
{
    $tot = array();
    $traf = array();
    global $cur_days, $total_days;
    //$cur_days     = date('d', ($config['time']['now'] - strtotime($datefrom)));
    //$total_days   = date('d', (strtotime($dateto)));
    $res = "    <table class=\"table table-striped table-bordered table-hover table-condensed table-rounded\" style=\"margin-bottom: 0px;\">";
    $res .= "      <thead>";
    $res .= "        <tr>";
    $res .= "          <th>周期</th>";
    $res .= "          <th style=\"text-align: center;\">流入流量</th>";
    $res .= "          <th style=\"text-align: center;\">流出流量</th>";
    $res .= "          <th style=\"text-align: center;\">合计</th>";
    $res .= "          <th style=\"text-align: center;\">小计</th>";
    $res .= "        </tr>";
    $res .= "      </thead>";
    $res .= "      <tbody>";
    foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data) {
        $date = strftime("%A, %e %B %Y", $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), "3");
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), "3");
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), "3");
        $traf['stot'] = formatStorage(gbConvert($tot['tot']), "3");
        $res .= "        <tr>";
        $res .= "          <td><i class=\"icon-calendar\"></i> " . $date . "</td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-success\">" . $traf['in'] . "</span></td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-info\">" . $traf['out'] . "</span></td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-inverse\">" . $traf['tot'] . "</span></td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge\">" . $traf['stot'] . "</span></td>";
        $res .= "        </tr>";
    }
    $est['in'] = formatStorage($tot['in'] / $cur_days * $total_days);
    $est['out'] = formatStorage($tot['out'] / $cur_days * $total_days);
    $est['tot'] = formatStorage($tot['tot'] / $cur_days * $total_days);
    $res .= "        <tr class=\"alert\">";
    $res .= "          <td><strong>Estimated for this billing period</strong></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-success\"><strong>" . $est['in'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-info\"><strong>" . $est['out'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-inverse\"><strong>" . $est['tot'] . "</strong></span></td>";
    $res .= "          <td></td>";
    $res .= "        </tr>";
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= "        <tr class=\"info\">";
    $res .= "          <td><strong>Total of this billing period</strong></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-success\"><strong>" . $tot['in'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-info\"><strong>" . $tot['out'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-inverse\"><strong>" . $tot['tot'] . "</strong></span></td>";
    $res .= "          <td></td>";
    $res .= "        </tr>";
    $res .= "      </tbody>";
    $res .= "    </table>";
    return $res;
}
function transferOverview($bill_id, $history)
{
    global $list_colour_a, $list_colour_b, $config;
    $i = 0;
    $tot = array();
    $traf = array();
    $start = $history['timestampfrom'];
    $end = $history['timestampto'];
    //$background= $history['background'];
    $res = "";
    $res .= "<table class=\"transferOverview\">";
    $res .= "  <tr bgcolor=\"#000\">";
    $res .= "    <th class=\"period\">Date</th>";
    $res .= "    <th class=\"inbound\">Inbound</th>";
    $res .= "    <th class=\"outbound\">Outbound</th>";
    $res .= "    <th class=\"total\">Total</th>";
    $res .= "  </tr>";
    foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data) {
        $date = strftime("%A, %e %B %Y", $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), "3");
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), "3");
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), "3");
        $row_colour = !is_integer($i / 2) ? $list_colour_a : $list_colour_b;
        $res .= "  <tr bgcolor=\"" . $row_colour . "\">";
        $res .= "    <td>" . $date . "</td>";
        $res .= "    <td class=\"right\">" . $traf['in'] . "</td>";
        $res .= "    <td class=\"right\">" . $traf['out'] . "</td>";
        $res .= "    <td class=\"right\">" . $traf['tot'] . "</td>";
        $res .= "  </tr>";
        $i++;
    }
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= "  <tr bgcolor=\"#ccc\" style=\"border-top: 1px solid #000;\">";
    $res .= "    <td></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['in'] . "</b></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['out'] . "</b></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['tot'] . "</b></td>";
    $res .= "  </tr>";
    $res .= "</table>";
    return $res;
}
Пример #3
0
function transferOverview($bill_id, $history)
{
    global $list_colour_a, $list_colour_b, $config;
    $i = 0;
    $tot = array();
    $traf = array();
    $start = $history['timestampfrom'];
    $end = $history['timestampto'];
    // $background= $history['background'];
    $res = '';
    $res .= '<table class="transferOverview">';
    $res .= '  <tr bgcolor="#000">';
    $res .= '    <th class="period">Date</th>';
    $res .= '    <th class="inbound">Inbound</th>';
    $res .= '    <th class="outbound">Outbound</th>';
    $res .= '    <th class="total">Total</th>';
    $res .= '  </tr>';
    foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $data) {
        $date = strftime('%A, %e %B %Y', $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), '3');
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), '3');
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), '3');
        $row_colour = !is_integer($i / 2) ? $list_colour_a : $list_colour_b;
        $res .= '  <tr bgcolor="' . $row_colour . '">';
        $res .= '    <td>' . $date . '</td>';
        $res .= '    <td class="right">' . $traf['in'] . '</td>';
        $res .= '    <td class="right">' . $traf['out'] . '</td>';
        $res .= '    <td class="right">' . $traf['tot'] . '</td>';
        $res .= '  </tr>';
        $i++;
    }
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= '  <tr bgcolor="#ccc" style="border-top: 1px solid #000;">';
    $res .= '    <td></td>';
    $res .= '    <td class="right"><b>' . $tot['in'] . '</b></td>';
    $res .= '    <td class="right"><b>' . $tot['out'] . '</b></td>';
    $res .= '    <td class="right"><b>' . $tot['tot'] . '</b></td>';
    $res .= '  </tr>';
    $res .= '</table>';
    return $res;
}