Ejemplo n.º 1
0
    }
    print "<div style=\"overflow: auto\">";
    if ($n != null) {
        $n->setTableHeaderPadding(1);
        $n->setItemCount($count);
        $n->setNavBar(new AjaxNavBar($count, $filter));
        $n->start = 0;
        $n->end = $maxperpage;
        $n->display();
    }
    print "</div>";
    ?><a href='<?php echo  urlStr("inventory/inventory/csv", array('table'=>$table, 'uuid'=>$_GET["uuid"])) ?>'><img src='modules/inventory/graph/csv.png' alt='export csv'/></a><?php
} else {
    $display = $_GET['part'];
    $machines = getLastMachineInventoryPart($display, array('gid'=>$_GET["gid"], 'filter'=>$filter, 'min'=>$start, 'max'=>($start + $maxperpage), 'date'=>$date, 'software_filter'=>$software_filter));
    $count = countLastMachineInventoryPart($display, array('gid'=>$_GET["gid"], 'filter'=>$filter, 'date'=>$date, 'software_filter'=>$software_filter));

    $result = array();
    $index = 0;
    $params = array();
    foreach ($machines as $machine) {
        $name = $machine[0];
        if (count($machine[1]) == 0) {
            $result['Machine'][$index] = $name;
            $index += 1;
        }
        foreach ($machine[1] as $element) {
            $result['Machine'][$index] = $name;
            foreach ($element as $head => $val) {
                if ($head != 'id' && $head != 'timestamp') {
                    $result[$head][$index] = $val;
Ejemplo n.º 2
0
$get_uuid = $_GET['uuid'];
$gid = $_GET['gid'];
$filter = $_GET['filter'];
ob_end_clean();
$filename = implode('.', explode('|', $table));
/* The two following lines make the CSV export works for IE 7.x */
header('Pragma: ');
header('Cache-Control: ');
header('Content-type: text/txt');
header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
$tables = explode('|', $table);
if (count($tables) == 1) {
    # FIXME: only one table handled for now for CVS splitting :/
    $split = 1000;
    # results will be splitted by 1000 to reduce memory usage
    $count = countLastMachineInventoryPart($table, array('gid' => $gid, 'uuid' => $get_uuid, 'filter' => $filter));
    if ($count <= $split) {
        $range = array(0);
    } else {
        $range = range(0, $count - 1, $split);
    }
    $firstline = true;
    foreach ($range as $lower) {
        $upper = $lower + $split;
        foreach (getLastMachineInventoryPart($table, array('gid' => $gid, 'uuid' => $get_uuid, 'filter' => $filter, 'min' => $lower, 'max' => $upper)) as $machine) {
            $name = $machine[0];
            $uuid = $machine[2];
            $content = $machine[1];
            if ($firstline) {
                $header = array();
                foreach (array_keys($content[0]) as $column) {