if ($udevice == 'Mac') {
                $argsday = array('width' => 1800, 'height' => 800, 'hide_legend' => true, 'responsive' => true, 'background_color' => '#000', 'chart_div' => 'graphday', 'colors' => array('FFFFFF', 'FF0000', '0000FF', '33FF33', 'FFFF44', '8888FF', '00FFFF'), 'margins' => array(0, 0, 0, 49), 'y_axis_text_style' => array('fontSize' => 18, 'color' => 'FFFFFF'), 'text_style' => array('fontSize' => 12, 'color' => 'FFFFFF'), 'legend_position' => 'bottom');
            } else {
                if ($udevice == 'S4') {
                    $argsday = array('width' => 480, 'height' => 200, 'hide_legend' => true, 'responsive' => true, 'background_color' => '#111', 'chart_div' => 'graphday', 'colors' => array('FFFFFF', 'FF0000', '0000FF', '33FF33', 'FFFF44', '8888FF', '00FFFF'), 'margins' => array(0, 0, 0, 49), 'y_axis_text_style' => array('fontSize' => 18, 'color' => 'FFFFFF'), 'text_style' => array('fontSize' => 12, 'color' => 'FFFFFF'), 'legend_position' => 'bottom');
                } else {
                    if ($udevice == 'Stablet') {
                        $argsday = array('width' => 480, 'height' => 200, 'hide_legend' => true, 'responsive' => true, 'background_color' => '#111', 'chart_div' => 'graphday', 'colors' => array('FFFFFF', 'FF0000', '0000FF', '33FF33', 'FFFF44', '8888FF', '00FFFF'), 'margins' => array(0, 0, 0, 49), 'y_axis_text_style' => array('fontSize' => 18, 'color' => 'FFFFFF'), 'text_style' => array('fontSize' => 12, 'color' => 'FFFFFF'), 'legend_position' => 'bottom');
                    } else {
                        $argsday = array('width' => 480, 'height' => 200, 'hide_legend' => true, 'responsive' => false, 'background_color' => '#111', 'chart_div' => 'graphday', 'colors' => array('FFFFFF', 'FF0000', '0000FF', '33FF33', 'FFFF44', '8888FF', '00FFFF'), 'margins' => array(0, 0, 0, 49), 'y_axis_text_style' => array('fontSize' => 18, 'color' => 'FFFFFF'), 'text_style' => array('fontSize' => 12, 'color' => 'FFFFFF'), 'legend_position' => 'bottom');
                    }
                }
            }
        }
        if (!($result = $db->query($query))) {
            die('There was an error running the query [' . $query . ' - ' . $db->error . ']');
        }
        while ($row = $result->fetch_assoc()) {
            $graphday[] = $row;
        }
        $result->free();
        $chartday = array_to_chart($graphday, $argsday);
        echo $chartday['script'];
        echo $chartday['div'];
        unset($chart);
    }
    $db->close();
} else {
    header("Location: index.php");
    die("Redirecting to: index.php");
}
    }
    $dagen = array_reverse($dagen);
    $sql = "SELECT substr(Date,0,8) AS Date, min(Temp_Min) as min, max(Temp_Max) as max FROM Temperature_Calendar WHERE DeviceRowID = {$sensor} GROUP BY substr(Date,0,8) ORDER BY Date DESC LIMIT 0,48";
    if (!($result = $dbd->query($sql))) {
        echo 'There was an error running the query [' . $dbd->error . ']';
    }
    $maanden = array();
    while ($row = $result->fetchArray()) {
        array_push($maanden, array('Date' => $row['Date'], 'min' => $row['min'], 'max' => $row['max']));
    }
    $maanden = array_reverse($maanden);
    echo '<div class="item temprain gradient" style="min-width:315px"><h2>' . $sensor . ' - ' . $sensornaam . '</h2>';
    $args = array('chart' => 'AreaChart', 'width' => 464, 'height' => 650, 'hide_legend' => false, 'responsive' => true, 'background_color' => '#E5E5E5', 'chart_div' => 'times', 'margins' => array(30, 10, 15, 35));
    $chart = array_to_chart($timeschart, $args);
    echo $chart['script'];
    echo $chart['div'];
    echo "</div>";
    echo "<div class='item temprain gradient' style='min-width:315px'><h2>Laatste 30 dagen</h2>";
    $args = array('chart' => 'AreaChart', 'width' => 464, 'height' => 650, 'hide_legend' => true, 'responsive' => true, 'background_color' => '#E5E5E5', 'chart_div' => 'dagen', 'margins' => array(30, 10, 15, 35));
    $chart = array_to_chart($dagen, $args);
    echo $chart['script'];
    echo $chart['div'];
    echo "</div>";
    echo "<div class='item temprain gradient' style='min-width:315px'><h2>Per maanden</h2>";
    $args = array('chart' => 'AreaChart', 'width' => 464, 'height' => 650, 'hide_legend' => true, 'responsive' => true, 'background_color' => '#E5E5E5', 'chart_div' => 'maanden', 'margins' => array(30, 10, 15, 35));
    $chart = array_to_chart($maanden, $args);
    echo $chart['script'];
    echo $chart['div'];
}
echo "</div></div></div>";
require_once "secure/footer.php";