-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_item.php
48 lines (39 loc) · 1.38 KB
/
report_item.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>Sales Data Visualization</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" type="text/css" href="styles/report.css">
</head>
<body>
<h1>Sales Data Visualization</h1>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="partNo">Part No:</label>
<input type="text" name="partNo" id="partNo">
<br>
<input type="submit" value="Generate Graphs">
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Include the SQL connection script
include 'chart_functions.php';
include 'sql_functions.php';
// Retrieve the data from the item_report function
$data = item_report($_POST['partNo']);
// Get the names of the columns in the array
$columnNames = array_keys($data[0]);
// Get the values from the first column for labels
$labels = array_column($data, $columnNames[0]);
// Exclude the first column from the chart generation
$columnNames = array_slice($columnNames, 1);
// Loop through the columns (except the first) and generate a line chart for each one
foreach ($columnNames as $columnName) {
$dataForChart = array_column($data, $columnName);
// Generate the line chart
generateLineChart($columnName, $labels, $dataForChart, $columnName);
}
copy_table($data);
}
?>
</body>
</html>