forked from RaspberryPints/RaspberryPints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·377 lines (335 loc) · 13.1 KB
/
index.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?php
if (!file_exists(__DIR__.'/includes/config.php')) {
header('Location: install/index.php', true, 303);
die();
}
?>
<?php
require_once __DIR__.'/includes/config_names.php';
require_once __DIR__.'/includes/config.php';
require_once __DIR__.'/admin/includes/managers/tap_manager.php';
//This can be used to choose between CSV or MYSQL DB
$db = true;
// Setup array for all the beers that will be contained in the list
$beers = array();
if($db){
// Connect to the database
db();
$config = array();
$sql = "SELECT * FROM config";
$qry = mysql_query($sql);
while($c = mysql_fetch_array($qry)){
$config[$c['configName']] = $c['configValue'];
}
$sql = "SELECT * FROM vwGetActiveTaps";
$qry = mysql_query($sql);
while($b = mysql_fetch_array($qry))
{
$beeritem = array(
"id" => $b['id'],
"beername" => $b['name'],
"style" => $b['style'],
"notes" => $b['notes'],
"og" => $b['ogAct'],
"fg" => $b['fgAct'],
"srm" => $b['srmAct'],
"ibu" => $b['ibuAct'],
"startAmount" => $b['startAmount'],
"amountPoured" => $b['amountPoured'],
"remainAmount" => $b['remainAmount'],
"tapNumber" => $b['tapNumber'],
"srmRgb" => $b['srmRgb']
);
$beers[$b['tapNumber']] = $beeritem;
}
$tapManager = new TapManager();
$numberOfTaps = $tapManager->GetTapNumber();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>RaspberryPints</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Set location of Cascading Style Sheet -->
<link rel="stylesheet" type="text/css" href="style.css">
<?php if($config[ConfigNames::UseHighResolution]) { ?>
<link rel="stylesheet" type="text/css" href="high-res.css">
<?php } ?>
<link rel="shortcut icon" href="img/pint.ico">
</head>
<body>
<div class="bodywrapper">
<!-- Header with Brewery Logo and Project Name -->
<div class="header clearfix">
<div class="HeaderLeft">
<?php if($config[ConfigNames::UseHighResolution]) { ?>
<a href="admin/admin.php"><img src="<?php echo $config[ConfigNames::LogoUrl] . "?" . time(); ?>" height="200" alt=""></a>
<?php } else { ?>
<a href="admin/admin.php"><img src="<?php echo $config[ConfigNames::LogoUrl] . "?" . time(); ?>" height="100" alt=""></a>
<?php } ?>
</div>
<div class="HeaderCenter">
<h1 id="HeaderTitle">
<?php
if (mb_strlen($config[ConfigNames::HeaderText], 'UTF-8') > ($config[ConfigNames::HeaderTextTruncLen])) {
$headerTextTrunced = substr($config[ConfigNames::HeaderText],0,$config[ConfigNames::HeaderTextTruncLen]) . "...";
echo $headerTextTrunced ; }
else
echo $config[ConfigNames::HeaderText];
?>
</h1>
</div>
<div class="HeaderRight">
<?php if($config[ConfigNames::UseHighResolution]) { ?>
<a href="http://www.raspberrypints.com"><img src="img/RaspberryPints-4k.png" height="200" alt=""></a>
<?php } else { ?>
<a href="http://www.raspberrypints.com"><img src="img/RaspberryPints.png" height="100" alt=""></a>
<?php } ?>
</div>
</div>
<!-- End Header Bar -->
<table>
<thead>
<tr>
<?php if($config[ConfigNames::ShowTapNumCol]){ ?>
<th class="tap-num">
TAP<br>#
</th>
<?php } ?>
<?php if($config[ConfigNames::ShowSrmCol]){ ?>
<th class="srm">
GRAVITY<hr>COLOR
</th>
<?php } ?>
<?php if($config[ConfigNames::ShowIbuCol]){ ?>
<th class="ibu">
BALANCE<hr>BITTERNESS
</th>
<?php } ?>
<th class="name">
BEER NAME & STYLE<hr>TASTING NOTES
</th>
<?php if($config[ConfigNames::ShowAbvCol]){ ?>
<th class="abv">
CALORIES<hr>ALCOHOL
</th>
<?php } ?>
<?php if($config[ConfigNames::ShowKegCol]){ ?>
<th class="keg">
POURED<hr>REMAINING
</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php for($i = 1; $i <= $numberOfTaps; $i++) {
if( isset($beers[$i]) ) {
$beer = $beers[$i];
?>
<tr class="<?php if($i%2 > 0){ echo 'altrow'; }?>" id="<?php echo $beer['id']; ?>">
<?php if($config[ConfigNames::ShowTapNumCol]){ ?>
<td class="tap-num">
<span class="tapcircle"><?php echo $i; ?></span>
</td>
<?php } ?>
<?php if($config[ConfigNames::ShowSrmCol]){ ?>
<td class="srm">
<h3><?php echo $beer['og']; ?> OG</h3>
<div class="srm-container">
<div class="srm-indicator" style="background-color: rgb(<?php echo $beer['srmRgb'] != "" ? $beer['srmRgb'] : "0,0,0" ?>)"></div>
<div class="srm-stroke"></div>
</div>
<h2><?php echo $beer['srm']; ?> SRM</h2>
</td>
<?php } ?>
<?php if($config[ConfigNames::ShowIbuCol]){ ?>
<td class="ibu">
<h3>
<?php
if( $beer['og'] > 1 ){
echo number_format((($beer['ibu'])/(($beer['og']-1)*1000)), 2, '.', '');
}else{
echo '0.00';
}
?>
BU:GU
</h3>
<div class="ibu-container">
<div class="ibu-indicator"><div class="ibu-full" style="height:<?php echo $beer['ibu'] > 100 ? 100 : $beer['ibu']; ?>%"></div></div>
<?php
/*
if( $remaining > 0 ){
?><img class="ibu-max" src="img/ibu/offthechart.png" /><?php
}
*/
?>
</div>
<h2><?php echo $beer['ibu']; ?> IBU</h2>
</td>
<?php } ?>
<td class="name">
<h1><?php echo $beer['beername']; ?></h1>
<h2 class="subhead"><?php echo str_replace("_","",$beer['style']); ?></h2>
<p><?php echo $beer['notes']; ?></p>
</td>
<?php if(($config[ConfigNames::ShowAbvCol]) && ($config[ConfigNames::ShowAbvImg])){ ?>
<td class="abv">
<h3><?php
$calfromalc = (1881.22 * ($beer['fg'] * ($beer['og'] - $beer['fg'])))/(1.775 - $beer['og']);
$calfromcarbs = 3550.0 * $beer['fg'] * ((0.1808 * $beer['og']) + (0.8192 * $beer['fg']) - 1.0004);
if ( ($beer['og'] == 1) && ($beer['fg'] == 1 ) ) {
$calfromalc = 0;
$calfromcarbs = 0;
}
echo number_format($calfromalc + $calfromcarbs), " kCal";
?>
</h3>
<div class="abv-container">
<?php
$abv = ($beer['og'] - $beer['fg']) * 131;
$numCups = 0;
$remaining = $abv * 20;
do{
if( $remaining < 100 ){
$level = $remaining;
}else{
$level = 100;
}
?><div class="abv-indicator"><div class="abv-full" style="height:<?php echo $level; ?>%"></div></div><?php
$remaining = $remaining - $level;
$numCups++;
}while($remaining > 0 && $numCups < 2);
if( $remaining > 0 ){
?><div class="abv-offthechart"></div><?php
}
?>
</div>
<h2><?php echo number_format($abv, 1, '.', ',')."%"; ?> ABV</h2>
</td>
<?php } ?>
<?php if(($config[ConfigNames::ShowAbvCol]) && ! ($config[ConfigNames::ShowAbvImg])){ ?>
<td class="abv">
<h3><?php
$calfromalc = (1881.22 * ($beer['fg'] * ($beer['og'] - $beer['fg'])))/(1.775 - $beer['og']);
$calfromcarbs = 3550.0 * $beer['fg'] * ((0.1808 * $beer['og']) + (0.8192 * $beer['fg']) - 1.0004);
if ( ($beer['og'] == 1) && ($beer['fg'] == 1 ) ) {
$calfromalc = 0;
$calfromcarbs = 0;
}
echo number_format($calfromalc + $calfromcarbs), " kCal";
?>
</h3>
<div class="abv">
<?php
$abv = ($beer['og'] - $beer['fg']) * 131;
?>
</div>
<h2><?php echo number_format($abv, 1, '.', ',')."%"; ?> ABV</h2>
</td>
<?php } ?>
<?php if($config[ConfigNames::ShowKegCol]){ ?>
<td class="keg">
<h3><?php echo number_format((($beer['startAmount'] - $beer['remainAmount']) * 128)); ?> fl oz poured</h3>
<?php
// Code for new kegs that are not full
$tid = $beer['id'];
$sql = "Select kegId from taps where id=".$tid." limit 1";
$kegID = mysql_query($sql);
$kegID = mysql_fetch_array($kegID);
//echo $kegID[0];
$sql = "SELECT `kegTypes`.`maxAmount` as kVolume FROM `kegs`,`kegTypes` where kegs.kegTypeId = kegTypes.id and kegs.id =".$kegID[0]."";
$kvol = mysql_query($sql);
$kvol = mysql_fetch_array($kvol);
$kvol = $kvol[0];
$kegImgClass = "";
if ($beer['startAmount']>=$kvol) {
$percentRemaining = $beer['remainAmount'] / $beer['startAmount'] * 100;
} else {
$percentRemaining = $beer['remainAmount'] / $kvol * 100;
}
if( $beer['remainAmount'] <= 0 ) {
$kegImgClass = "keg-empty";
$percentRemaining = 100; }
else if( $percentRemaining < 15 )
$kegImgClass = "keg-red";
else if( $percentRemaining < 25 )
$kegImgClass = "keg-orange";
else if( $percentRemaining < 45 )
$kegImgClass = "keg-yellow";
else if ( $percentRemaining < 100 )
$kegImgClass = "keg-green";
else if( $percentRemaining >= 100 )
$kegImgClass = "keg-full";
?>
<div class="keg-container">
<div class="keg-indicator"><div class="keg-full <?php echo $kegImgClass ?>" style="height:<?php echo $percentRemaining; ?>%"></div></div>
</div>
<h2><?php echo number_format(($beer['remainAmount'] * 128)); ?> fl oz left</h2>
</td>
<?php } ?>
</tr>
<?php }else{ ?>
<tr class="<?php if($i%2 > 0){ echo 'altrow'; }?>">
<?php if($config[ConfigNames::ShowTapNumCol]){ ?>
<td class="tap-num">
<span class="tapcircle"><?php echo $i; ?></span>
</td>
<?php } ?>
<?php if($config[ConfigNames::ShowSrmCol]){ ?>
<td class="srm">
<h3></h3>
<div class="srm-container">
<div class="srm-indicator"></div>
<div class="srm-stroke"></div>
</div>
<h2></h2>
</td>
<?php } ?>
<?php if($config[ConfigNames::ShowIbuCol]){ ?>
<td class="ibu">
<h3></h3>
<div class="ibu-container">
<div class="ibu-indicator"><div class="ibu-full" style="height:0%"></div></div>
</div>
<h2></h2>
</td>
<?php } ?>
<td class="name">
<h1>Nothing on tap</h1>
<h2 class="subhead"></h2>
<p></p>
</td>
<?php if(($config[ConfigNames::ShowAbvCol]) && ($config[ConfigNames::ShowAbvImg])){ ?>
<td class="abv">
<h3></h3>
<div class="abv-container">
<div class="abv-indicator"><div class="abv-full" style="height:0%"></div></div>
</div>
<h2></h2>
</td>
<?php } ?>
<?php if(($config[ConfigNames::ShowAbvCol]) && ! ($config[ConfigNames::ShowAbvImg])){ ?>
<td class="abv">
<h3></h3>
<h2></h2>
</td>
<?php } ?>
<?php if($config[ConfigNames::ShowKegCol]){ ?>
<td class="keg">
<h3></h3>
<div class="keg-container">
<div class="keg-indicator"><div class="keg-full keg-empty" style="height:0%"></div></div>
</div>
<h2>0 fl oz left</h2>
</td>
<?php } ?>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
</body>
</html>