Beispiel #1
0
function print_chart($params, $line, $option = NULL, $select = 0)
{
    global $conn;
    $height = 300;
    $chart_height = 360;
    $max_width = 800;
    $chart_width = 900;
    if (!isset($params['FILTER'])) {
        $params['FILTER'] = NULL;
    } elseif (!isset($params['SORT'])) {
        $params['SORT'] = NULL;
    }
    if (!isset($params['GROUP'])) {
        $params['GROUP'] = NULL;
    }
    if (!isset($params['ADD'])) {
        $params['ADD'] = NULL;
    }
    $result = db_mysql_query(select_tbody($params['TABLE'], $params['SORT'], $params['FILTER'], $params['GROUP'], $params['ADD']), $conn);
    $max = 0;
    $base_arr = array();
    $count = db_mysql_num_rows($result);
    while ($arr = db_mysql_fetch_array($result)) {
        if ($arr[$line['VAL']] >= $max) {
            $max = $arr[$line['VAL']];
        }
        if ($line['DATA'] == 'date') {
            $date = explode('-', $arr['datefromto']);
            if ($option == 'hour') {
                array_push($base_arr, date('H', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('H', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('H', strtotime('-1 hour', $date[0])));
                    array_push($base_arr, date('H', strtotime('+1 hour', $date[0])));
                }
            }
            if ($option == 'day') {
                array_push($base_arr, date('d.m', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('d.m', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('d.m', strtotime('-1 day', $date[0])));
                    array_push($base_arr, date('d.m', strtotime('+1 day', $date[0])));
                }
            }
            if ($option == 'month') {
                array_push($base_arr, date('F', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('F', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('F', strtotime('-1 month', $date[0])));
                    array_push($base_arr, date('F', strtotime('+1 month', $date[0])));
                }
            }
            if ($option == 'year') {
                array_push($base_arr, date('Y', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('Y', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('Y', strtotime('-1 year', $date[0])));
                    array_push($base_arr, date('Y', strtotime('+1 year', $date[0])));
                }
            }
        } else {
            array_push($base_arr, $arr[$line['DATA']]);
            $data_arr[$arr[$line['KEY']]][$arr[$line['DATA']]] = $arr[$line['VAL']];
        }
    }
    foreach ($data_arr as $key => $value) {
        if (count($value) == 1) {
            array_unshift($data_arr[$key], 0);
            array_push($data_arr[$key], 0);
        }
    }
    print "<div class='chart-wrapper'>";
    print "<svg version='1.2' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' class='chart' aria-labelledby='title' role='img' height='100%' width='100%' viewBox='0 0 " . $chart_width . " " . $chart_height . "'>";
    print base_chart($base_arr, array(floor($max / 2), $max), $height, $max_width, 50);
    if ($select != 0) {
        print data_chart($data_arr[$select], 1, $max, $height, $max_width, 50);
    } else {
        $i = 1;
        foreach ($data_arr as $key => $value) {
            print data_chart($value, $i, $max, $height, $max_width, 50);
            $i++;
        }
    }
    print "</svg>";
    if (count($data_arr) > 1) {
        print "<ul class='legend'>";
        $i = 1;
        foreach ($data_arr as $key => $value) {
            print "<li><div class='color-box color-" . $i . "'></div>" . $key . "</li>";
            $i++;
        }
        print "</ul>";
    }
    print "</div>";
}
Beispiel #2
0
function tbody($params)
{
    global $conn, $modul, $sub_page, $pages;
    if (!isset($sub_page) or $sub_page == 0) {
        $sub_page = 1;
    }
    if ($modul == 'content_tree') {
        if (isset($params['FILTER'])) {
            $arr_tmp = create_tree('content_tree', 0, $params['FILTER']);
        } else {
            $arr_tmp = create_tree('content_tree', 0);
        }
        if ($arr_tmp) {
            $tbody = "<div class='table-body tree'>";
            $tbody .= tree_nav_table($params, 'content', $arr_tmp, tree_get_parents('content_tree', NULL));
            $tbody .= "</div><!-- /.table-body -->";
        }
    } else {
        if (!isset($params['FILTER'])) {
            $params['FILTER'] = NULL;
        } elseif (!isset($params['SORT'])) {
            $params['SORT'] = NULL;
        }
        if (!isset($params['GROUP'])) {
            $params['GROUP'] = NULL;
        }
        if (!isset($params['ADD'])) {
            $params['ADD'] = NULL;
        }
        $result = db_mysql_query(select_tbody($params['TABLE'], $params['SORT'], $params['FILTER'], $params['GROUP'], $params['ADD'], 100), $conn);
        if ($sub_page <= 1) {
            $sql_sub = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $_SESSION['TABLE_PREFIX'] . $modul . "' AND COLUMN_NAME = 'sort_order' ";
            $result_sub = db_mysql_query($sql_sub, $conn);
            if ($modul == 'content_tree') {
                $tbody = "<div class='table-body tree'>";
            } else {
                if (db_mysql_num_rows($result_sub)) {
                    $tbody = "<div class='table-body sortable'>";
                } else {
                    $tbody = "<div class='table-body " . $modul . "'>";
                }
            }
        }
        while ($arr = db_mysql_fetch_array($result)) {
            $tbody .= "<div class='table-row' id='" . $arr['id'] . "' >";
            foreach ($params['TABLE'] as $key => $value) {
                $data = init($arr[$key], $value, $key);
                if ($value == 'activate') {
                    $tbody .= "<div class='table-cell icon-only " . $key . "'>";
                    if ($arr[$key]) {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "_de" . $value . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $value . "-active'></i>";
                    } else {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "_" . $value . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $value . "'></i>";
                    }
                    $tbody .= "</div><!-- /.table-cell -->";
                } else {
                    $tbody .= "<div class='table-cell " . $key . "'>" . $data . "</div><!-- /.table-cell -->";
                }
            }
            if (count(array_filter($params['CONSTRUCT']))) {
                $width = 40 + 26 * count(array_filter($params['CONSTRUCT']));
                $tbody .= "<div class='table-cell tools' style='width: " . $width . "px;'>";
                foreach ($params['CONSTRUCT'] as $key => $value) {
                    if ($value === true) {
                        if ($key == 'activate') {
                            if (!isset($arr['c_default']) or $arr['c_default'] == 0) {
                                if ($arr['c_active']) {
                                    $tbody .= "<a href='#' class='icon-cell de" . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "-active'></i>";
                                } else {
                                    $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i>";
                                }
                                $tbody .= "</a>";
                            }
                        } elseif ($key == 'delete') {
                            if (!isset($arr['c_default']) or $arr['c_default'] == 0) {
                                $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                            }
                        } else {
                            $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                        }
                    }
                }
                $tbody .= "</div><!-- /.table-cell -->";
            }
            $tbody .= "</div><!-- /.table-row -->";
        }
        if (ceil($pages) != $sub_page) {
            $next_page = $sub_page + 1;
            $tbody .= "<form id='next_rows' method='POST'>";
            $tbody .= "<input type='hidden' name='modul' value='" . $modul . "'>";
            $tbody .= "<input type='hidden' name='params' value='" . serialize($params) . "'>";
            $tbody .= "<input type='hidden' name='sub_page' value='" . $next_page . "'>";
            $tbody .= "</form>";
        }
        $tbody .= "</div><!-- /.table-body -->";
    }
    if (isset($tbody)) {
        print $tbody;
    }
}