This repository was archived by the owner on Mar 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-measurement.php
More file actions
160 lines (159 loc) · 6.24 KB
/
create-measurement.php
File metadata and controls
160 lines (159 loc) · 6.24 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
#error_reporting(E_ALL);
require_once './scripts/session-handler.php';
session_name("2Org-Cows");
session_start();
include_once "./scripts/check-session_restricted.php";
$date = date("U");
$_SESSION["expire"] = $date + (60*60*24);
include_once "./scripts/agri_star_001_connect.php";
?>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="./static/2Org-Cows.css"/>
<link rel="shortcut icon" href="./static/Favicon-2Org-Cows.ico" type="image"/>
<title>create measurement</title>
</head>
<body>
<div class="page">
<div class="text a">
<header class="header">
<nav class="dropdown">
<span>Menu</span>
<nav class="dropdown-content">
<p><a href="./search">Search</a></p>
<p><a href="./admin">Admin</a></p>
<p><a href="./upload">Upload files</a></p>
<p><a href="./cow">Cow</a></p>
<p><a href="./user">User</a></p>
<p><a href="./home">Home</a></p>
<p><a href="./logout">Logout</a></p>
<p><a href="./help.php">Help</a></p>
</nav>
</nav>
Please provide the information required to create new measurement methods
</header>
<div class="logo">
<a href="./home">
<picture>
<source srcset="./static/Logo-2Org-Cows.png" media="(min-width: 800px)">
<source srcset="./static/Logo-2Org-Cows64.png">
<img src="./static/Logo-2Org-Cows.png" alt="2Org-Cows logo">
</picture>
</a>
</div>
<div class="center">
<div class="center_1">
<?php
$user_role = $_SESSION["role"];
if ($user_role > 1) {
?>
<h3>Create new measurement method</h3>
<form method="POST" action="./scripts/measurement_script.php">
<table>
<tr>
<td>Measurement name</td>
<td><input type="text" name="measurement_name" required autofocus /></td>
</tr>
<tr>
<td>Abbreviation for measurement</td>
<td><input type="text" name="measurement_abbreviation" required /></td>
</tr>
<tr>
<td>Measurement Unit</td>
<td>
<select name="measurement_unit">
<?php
$measurement_units = [
" " => " ", "kg" => "kg", "m" => "m", "l" => "l", "m³" => "m³"];
foreach($measurement_units as $key => $unit){
?>
<option value="<?= $key ?>"><?= $unit ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Measurement Error</td>
<td><input type="text" name="measurement_error" required /></td>
</tr>
<tr>
<td>Link to description</td>
<td><input type="text" name="description_link" placeholder="http://" required /></td>
</tr>
<tr>
<td>Vendor</td>
<td><input type="text" name="vendor" required /></td>
</tr>
<tr>
<td>Link to Vendor</td>
<td><input type="text" name="vendor_link" placeholder="http://" required /></td>
</tr>
<tr style="height:10vh;">
<td>Optional description text</td>
<td><textarea name="description_text"/></textarea></td>
</tr>
</table>
<?php
$_SESSION["token"] = bin2hex(random_bytes(32)); //this part is for CSRF protection
?>
<input type="hidden" name="token" value="<?= $_SESSION["token"] ?>" />
<input type="submit" value="create method" formaction="./scripts/measurement_script.php" />
</form>
<br>
<?php
$echo = $_GET;
echo implode(" ",$echo);
}
?>
</div>
<div class="center_2">
<?php
if ($user_role > 1) {
?>
<h3>Measurement methods, created by your group</h3>
<table style="border:1px solid black; border-collapse:collapse;">
<tr>
<th style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse; background-color:green;">Measurement Method</th>
<th style="min-width:2vw; text-align:center; border:1px solid black; border-collapse:collapse; background-color:green;">Unit</th>
<th style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse; background-color:green;">Measurement Error</th>
<th style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse; background-color:green;">Vendor</th>
</tr>
<?php
$group = intval($_SESSION["group"]);
$sql = "SELECT `Gage_LongName`,`Gage_ShortName`,`Unit`,`Measurement_Error`, `Vendor`, `Vendor_Link`, `Gage_Description_Text`, `Gage_Description_Link` FROM Dim_Gage WHERE `Group` = '$group'";
$measurements = $agri_star_001->query($sql);
while($measurement_array = $measurements->fetch_assoc()) {
?>
<tr>
<td style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse;"><?= $measurement_array['Gage_LongName'] ?></td>
<td style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse;"><?= $measurement_array['Unit'] ?></td>
<td style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse;"><?= $measurement_array['Measurement_Error'] ?></td>
<td style="min-width:3.5vw; text-align:center; border:1px solid black; border-collapse:collapse;">
<a target="_blank" href="<?= $measurement_array["Vendor_Link"] ?>" >
<?= $measurement_array['Vendor'] ?>
</a>
</td>
</tr>
<tr>
<td colspan="4" style="text-align:center; border:1px solid black; border-collapse:collapse;">
<?= $measurement_array['Gage_Description_Text'] ?> - See also this <a target="_blank" href="<?= $measurement_array['Gage_Description_Link'] ?>">Link</a>
</td>
</tr>
<?php
}
}
?>
</table>
</div>
</div>
<footer class="footer">
This page was developed for the 2-Org-Cows project and underlies the <a href="./license" style="color:white;">BSD-license</a>
</footer>
</div>
</div>
</body>
</html>