======================================================================================
January 07, 2019 Add Keg Weight Calculator to RaspberryPints
- Log into system and fire up Mysql:
sudo mysql -u root -p
- Copy and paste the following into the terminal session:
use raspberrypints;
INSERT INTO config ( configName, configValue, displayName, showOnPanel, createdDate, modifiedDate ) VALUES
( 'altitude', '0', 'Altitude', '0', NOW(), NOW() ),
( 'temperature', '0', 'Temperature', '0', NOW(), NOW() ),
( 'pressure', '0', 'Pressure', '0', NOW(), NOW() );
ALTER TABLE kegs
ADD COLUMN maxVolume decimal(6,3) NOT NULL AFTER weight;
UPDATE kegs SET maxVolume = '5' WHERE kegTypeId = '1';
UPDATE kegs SET maxVolume = '2.5' WHERE kegTypeId = '2';
UPDATE kegs SET maxVolume = '3' WHERE kegTypeId = '3';
UPDATE kegs SET maxVolume = '10' WHERE kegTypeId = '4';
UPDATE kegs SET maxVolume = '5' WHERE kegTypeId = '5';
UPDATE kegs SET maxVolume = '5.16' WHERE kegTypeId = '6';
UPDATE kegs SET maxVolume = '7.75' WHERE kegTypeId = '7';
UPDATE kegs SET maxVolume = '7.75' WHERE kegTypeId = '8';
UPDATE kegs SET maxVolume = '15.5' WHERE kegTypeId = '9';
UPDATE kegs SET maxVolume = '13.2' WHERE kegTypeId = '10';
UPDATE kegs SET maxVolume = '10.81' WHERE kegTypeId = '11';
UPDATE kegs SET maxVolume = '10.81' WHERE kegTypeId = '12';
UPDATE kegs SET maxVolume = '21.62' WHERE kegTypeId = '13';
UPDATE kegs SET maxVolume = '43.23' WHERE kegTypeId = '14';
UPDATE kegs SET maxVolume = '64.85' WHERE kegTypeId = '15';
Quit;
======================================================================================
terminal session:
pi@rpints ~ $ sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.5.41-0+wheezy1 (Debian)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use raspberrypints;
INSERT INTO config ( configName, configValue, displayName, showOnPanel, createdDate, modifiedDate ) VALUES
( 'altitude', '0', 'Altitude', '0', NOW(), NOW() ),
( 'temperature', '0', 'Temperature', '0', NOW(), NOW() ),
( 'pressure', '0', 'Pressure', '0', NOW(), NOW() );
ALTER TABLE kegs
ADD COLUMN maxVolume decimal(6,3) NOT NULL AFTER weight;
UPDATE kegs SET maxVolume = '5' WHERE kegTypeId = '1';
UPDATE kegs SET maxVolume = '2.5' WHERE kegTypeId = '2';
UPDATE kegs SET maxVolume = '3' WHERE kegTypeId = '3';
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
UPDATE kegs SET maxVolume = '10' WHERE kegTypeId = '4';
UPDATE kegs SET maxVolume = '5' WHERE kegTypeId = '5';
UPDATE kegs SET maxVolume = '5.16' WHERE kegTypeId = '6';
UPDATE kegs SET maxVolume = '7.75' WHERE kegTypeId = '7';
UPDATE kegs SET maxVolume = '7.75' WHERE kegTypeId = '8';
UPDATE kegs SET maxVolume = '15.5' WHERE kegTypeId = '9';
UPDATE kegs SET maxVolume = '13.2' WHERE kegTypeId = '10';
UPDATE kegs SET maxVolume = '10.81' WHERE kegTypeId = '11';
UPDATE kegs SET maxVolume = '10.81' WHERE kegTypeId = '12';
UPDATE kegs SET maxVolume = '21.62' WHERE kegTypeId = '13';
UPDATE kegs SET maxVolume = '43.23' WHERE kegTypeId = '14';
UPDATE kegs SET maxVolume = '64.85' WHERE kegTypeId = '15';
Quit;Database changed
mysql> INSERT INTO config ( configName, configValue, displayName, showOnPanel, createdDate, modifiedDate ) VALUES
-> ( 'altitude', '0', 'Altitude', '0', NOW(), NOW() ),
-> ( 'temperature', '0', 'Temperature', '0', NOW(), NOW() ),
-> ( 'pressure', '0', 'Pressure', '0', NOW(), NOW() );
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> ALTER TABLE kegs
-> ADD COLUMN maxVolume decimal(6,3) NOT NULL AFTER weight;
Query OK, 16 rows affected (0.05 sec)
Records: 16 Duplicates: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '5' WHERE kegTypeId = '1';
Query OK, 16 rows affected (0.01 sec)
Rows matched: 16 Changed: 16 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '2.5' WHERE kegTypeId = '2';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '3' WHERE kegTypeId = '3';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '10' WHERE kegTypeId = '4';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '5' WHERE kegTypeId = '5';
Query OK, 0 rows affected (0.01 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '5.16' WHERE kegTypeId = '6';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '7.75' WHERE kegTypeId = '7';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '7.75' WHERE kegTypeId = '8';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '15.5' WHERE kegTypeId = '9';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '13.2' WHERE kegTypeId = '10';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '10.81' WHERE kegTypeId = '11';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '10.81' WHERE kegTypeId = '12';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '21.62' WHERE kegTypeId = '13';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '43.23' WHERE kegTypeId = '14';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> UPDATE kegs SET maxVolume = '64.85' WHERE kegTypeId = '15';
Query OK, 0 rows affected (0.01 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> Quit;
Bye
pi@rpints ~ $
======================================================================================
- check these files against their original versions:
/var/www/admin/includes/managers/keg_manager.php
/var/www/admin/includes/models/keg.php
/var/www/admin/keg_form.php
/var/www/admin/keg_list.php
/var/www/admin/left_bar.php
/var/www/admin/personalize.php
/var/www/admin/tap_form.php
/var/www/includes/config_names.php
No changes from originals found
- copy these files:
/var/www/admin/includes/managers/keg_manager.php
/var/www/admin/includes/models/keg.php
/var/www/admin/keg_form.php
/var/www/admin/keg_list.php
/var/www/admin/left_bar.php
/var/www/admin/personalize.php
/var/www/admin/tap_form.php
/var/www/admin/update_altitude.php
/var/www/admin/update_pressure.php
/var/www/admin/update_temperature.php
/var/www/includes/config_names.php
- After copying the files set access rights:
$ sudo chmod -R 777 /var/www (didn't do this - properties look correct already)
- Edit index.php
Find this line and comment it out:
$sql = "SELECT `kegTypes`.`maxAmount` as kVolume FROM `kegs`,`kegTypes` where kegs.kegTypeId = kegTypes.id and kegs.id =".$kegID[0]."";
Insert this line directly after the above:
$sql = "SELECT `kegs`.`maxVolume` as kVolume FROM `kegs` where kegs.id =".$kegID[0]."";
- Restart and it works!