Esempio n. 1
0
    <link rel="stylesheet" type="text/css" href="css/chart-custom.css">
    <script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/Chart.js"></script>
</head>
<header class="jumbotron"><h1>Temperature History</h1></header>
<body class="container">
    <section class="col-lg-12">
        <h2>Temperature (Last 24 hours)</h2>
        <div id="canvas-holder">
            <canvas id="temperature-chart" width="450" height="200"></canvas>
        </div>
    </section>
    <section class="col-lg-12">
        <?php 
$readingObject = new Readings();
$reading = $readingObject->getReadings();
?>
    </section>
    <script>
        var lineChartData = {
            labels: [
                <?php 
foreach ($reading as $row) {
    print "'" . date('d-m-Y G:i:s', strtotime($row['timestamp'])) . "', ";
}
?>
            ],
            datasets: [{
                fillColor: "rgba(151,187,205,0.2)",
                strokeColor: "rgba(151,187,205,1)",
<?php

/**
 * Created by PhpStorm.
 * User: Barisi
 * Date: 09/10/2015
 * Time: 17:56
 */
include '../models/Readings.php';
$action = new Readings();
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['save'])) {
    if ($_POST['action_id'] != null && $_POST['action_party'] != null && $_POST['recommended_by'] != null && $_POST['mcdr_id'] != null) {
        if ($action->createReading($_POST) == true) {
            header('Location: ../../views/actions/index.php?add=success');
        } else {
            header('Location: ../../views/actions/index.php?add=failure');
        }
    } else {
        header('Location: ../../views/actions/add.php?status=failure');
    }
} else {
    if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['delete'])) {
        if ($action->deleteReading($_GET['id']) == true) {
            header('Location: ../../views/actions/index.php?delete=success');
        } else {
            header('Location: ../../views/actions/index.php?delete=failed');
        }
    } else {
        if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['update'])) {
            if ($_POST['action_id'] != null && $_POST['action_party'] != null && $_POST['recommended_by'] != null && $_POST['mcdr_id'] != null) {
                if ($action->updateReading($_POST) == true) {