<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Skullpluggery
 * Date: 8/13/2016
 * Time: 7:00 PM
 */

require_once 'public/include/db_connect.php';

$error = false;
$areaName = array('Select an area', 'SLEX', 'Bancal', 'All');
$a_name = "";

if(isset($_POST["btnGenerate"]))
{

    // CODE HERE TO DETERMINE IF MAY LAMAN BA UNG DB BASED SA GANERN OK OK


    $area = $_POST["drpArea"];
    $pollutant = $_POST["drpPollutant"];
    $dateTimeFrom = $_POST["txtDateTimeFrom"];
    $dateTimeTo = $_POST["txtDateTimeTo"];
    $order = $_POST["drpOrder"];

if($area == 3) {
    if ($pollutant == 'All') {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp, AREA_NAME
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";

        $result = mysqli_query($con, $query);
        $row = mysqli_num_rows($result);
        mysqli_close($con);

    } else {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE ELEMENTS.e_symbol = '$pollutant' and DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";
        $result = mysqli_query($con, $query);

        $result = mysqli_query($con, $query);
        $row = mysqli_num_rows($result);

        mysqli_close($con);
    }
}
else{
    if ($pollutant == 'All') {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE area_name = '$areaName[$area]' and DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";

    } else {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE area_name = '$areaName[$area]' and ELEMENTS.e_symbol = '$pollutant' and DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";
        $result = mysqli_query($con, $query);
    }
    $result = mysqli_query($con, $query);
    $row = mysqli_num_rows($result);

    mysqli_close($con);
}
    if($row == 0){
        //$error = true;
        echo "<script>alert('No available data')</script>";

    }else{
        //$error = false; // THEN SET THIS TO TRUE / FALSE OK OK

        session_start();

        $_SESSION['drpArea'] = $_POST["drpArea"];
        $_SESSION['drpPollutant'] = $_POST["drpPollutant"];
        $_SESSION['txtDateTimeFrom'] = $_POST["txtDateTimeFrom"];
        $_SESSION['txtDateTimeTo'] = $_POST["txtDateTimeTo"];
        $_SESSION['drpOrder'] = $_POST["drpOrder"];

        header("Location: generatepdf.php");

    }

    unset($_POST['btnGenerate']);
}
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>History - Air Quality Monitoring System</title>
    <link rel="icon" href="res/favicon.ico" type="image/x-icon">

    <!-- CSS  -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="css/materialize.min.css" type="text/css" rel="stylesheet" media="screen,projection">
    <link href="css/flatpickr.css" type="text/css" rel="stylesheet" media="screen">
    <link href="css/style.css" type="text/css" rel="stylesheet" media="screen">
    <link rel="icon" href="res/favicon.ico" type="image/x-icon">


    <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
    <script type ="text/javascript">

        /*function getData(area) {
            $.ajax({
                type: 'POST',
                url: 'history.php',
                data: {
                    get_option:area
                },
                success: function (response) {
                    document.getElementById("drpPollutant").innerHTML=response;
                }
            });
        }*/


//        var errorMessage = "<?//= $errorMessage    ?>//";
//
//        if(errorMessage == "No available data!")
//        {
//            alert(errorMessage);
//            $errorMessage = "";
//        }
//
//        errorMessage = "";
       // alert(errorMessage);

    </script>

</head>

<body>

<?php  include('public/_header.php'); ?>


<div id="content-holder">
    <br>
    <h1 class="header center teal-text" style="margin-bottom: 0; padding-bottom: 0;"><span class="material-icons" style="font-size: 2em;">library_books</span></h1>
    <h2 class="header center teal-text" style="margin-top: 0; padding-top: 0;"><b>History Report</b></h2>


   <div class="section no-pad-bot">
        <div class="container">
            <div class="divider"></div>
            <br>
            <div class="row">
                <div class="col s12">
                    <div>
                        <form method = "post" action="">
                        <!--<form method = "post" action="generatepdf.php">--><commit_msg>Add idiomatic expression in history.php<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Skullpluggery
 * Date: 8/13/2016
 * Time: 7:00 PM
 */

require_once 'public/include/db_connect.php';

$error = false;
$areaName = array('Select an area', 'SLEX', 'Bancal', 'All');
$a_name = "";

if(isset($_POST["btnGenerate"]))
{

    // CODE HERE TO DETERMINE IF MAY LAMAN BA UNG DB BASED SA GANERN OK OK


    $area = $_POST["drpArea"];
    $pollutant = $_POST["drpPollutant"];
    $dateTimeFrom = $_POST["txtDateTimeFrom"];
    $dateTimeTo = $_POST["txtDateTimeTo"];
    $order = $_POST["drpOrder"];

if($area == 3) {
    if ($pollutant == 'All') {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp, AREA_NAME
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";

        $result = mysqli_query($con, $query);
        $row = mysqli_num_rows($result);
        mysqli_close($con);

    } else {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE ELEMENTS.e_symbol = '$pollutant' and DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";
        $result = mysqli_query($con, $query);

        $result = mysqli_query($con, $query);
        $row = mysqli_num_rows($result);

        mysqli_close($con);
    }
}
else{
    if ($pollutant == 'All') {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE area_name = '$areaName[$area]' and DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";

    } else {
        $query = "SELECT E_NAME, E_SYMBOL, CONCENTRATION_VALUE, timestamp
                          FROM MASTER INNER JOIN ELEMENTS ON MASTER.e_id = ELEMENTS.e_id
                          WHERE area_name = '$areaName[$area]' and ELEMENTS.e_symbol = '$pollutant' and DATE(timestamp) BETWEEN DATE('$dateTimeFrom') and DATE('$dateTimeTo')
                          ORDER BY TIMESTAMP DESC";
        $result = mysqli_query($con, $query);
    }
    $result = mysqli_query($con, $query);
    $row = mysqli_num_rows($result);

    mysqli_close($con);
}
    if($row == 0){
        //$error = true;
        echo "<script>alert('No available data')</script>";

    }else{
        //$error = false; // THEN SET THIS TO TRUE / FALSE OK OK

        session_start();

        $_SESSION['drpArea'] = $_POST["drpArea"];
        $_SESSION['drpPollutant'] = $_POST["drpPollutant"];
        $_SESSION['txtDateTimeFrom'] = $_POST["txtDateTimeFrom"];
        $_SESSION['txtDateTimeTo'] = $_POST["txtDateTimeTo"];
        $_SESSION['drpOrder'] = $_POST["drpOrder"];

        header("Location: generatepdf.php");

    }

    unset($_POST['btnGenerate']);
}
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>History - Air Quality Monitoring System</title>
    <link rel="icon" href="res/favicon.ico" type="image/x-icon">

    <!-- CSS  -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="css/materialize.min.css" type="text/css" rel="stylesheet" media="screen,projection">
    <link href="css/flatpickr.css" type="text/css" rel="stylesheet" media="screen">
    <link href="css/style.css" type="text/css" rel="stylesheet" media="screen">
    <link rel="icon" href="res/favicon.ico" type="image/x-icon">


    <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
    <script type ="text/javascript">

        /*function getData(area) {
            $.ajax({
                type: 'POST',
                url: 'history.php',
                data: {
                    get_option:area
                },
                success: function (response) {
                    document.getElementById("drpPollutant").innerHTML=response;
                }
            });
        }*/


//        var errorMessage = "<?//= $errorMessage    ?>//";
//
//        if(errorMessage == "No available data!")
//        {
//            alert(errorMessage);
//            $errorMessage = "";
//        }
//
//        errorMessage = "";
       // alert(errorMessage);

    </script>

</head>

<body>

<?php  include('public/_header.php'); ?>


<div id="content-holder">
    <br>
    <h1 class="header center teal-text" style="margin-bottom: 0; padding-bottom: 0;"><span class="material-icons" style="font-size: 2em;">library_books</span></h1>
    <h2 class="header center teal-text" style="margin-top: 0; padding-top: 0;"><b>History Report</b></h2>
    <p class="header center grey-text" style="margin-top: 0; padding-top: 0;">By filling out and submitting this form, the page would generate a PDF file.</p>

   <div class="section no-pad-bot">
        <div class="container">
            <div class="divider"></div>
            <br>
            <div class="row">
                <div class="col s12">
                    <div>
                        <form method = "post" action="">
                        <!--<form method = "post" action="generatepdf.php">-->
{'fraction_non_alphanumeric': 0.15713244671160503, 'fraction_numerical': 0.005283293860448169, 'mean_word_length': 2.3462359036879, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2164066', 'n_tokens_mistral': 3608, 'n_tokens_neox': 3393, 'n_words': 726}