Sun, 31 May 2020 12:23:01 +0200
Version 0.3.34 Changed log messages in the daemon. Added yeast_pitchrate field to the product database. Added yeast pitchrate edit field to the yeast tab. Initial value is guessed. There is also a popup window for predefined values. An finally the value can be edited by the user. All popup windows are initialized together.
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | if (! $link) { |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | } |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | if (! mysqli_set_charset($link, "utf8" )) { |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | echo "error"; |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | return 1; |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | } |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | $result = mysqli_query($link, "SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | $row = mysqli_fetch_array($result); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | |
608
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
18 | function field($x, $field, $value) { |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
19 | xmlwriter_start_element($x, $field); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
20 | xmlwriter_text($x, $value); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
21 | xmlwriter_end_element($x); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
22 | } |
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | $yeasttype = array( 'Lager', 'Ale', 'Wheat', 'Wine', 'Champagne', 'Other', 'Other', 'Other', 'Other', 'Other' ); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | $yeastform = array( 'Liquid', 'Dry', 'Slant', 'Culture', 'Frozen', 'Bottle', 'Dry' ); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | $yeastflocculation = array( 'Low', 'Medium', 'High', 'Very high' ); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | /* |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | * Create beerxml output |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | */ |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | $xw = xmlwriter_open_memory(); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | xmlwriter_set_indent($xw, 1); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | $res = xmlwriter_set_indent_string($xw, ' '); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | xmlwriter_start_document($xw, '1.0', 'UTF-8'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | xmlwriter_start_element($xw, 'YEASTS'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | while ($row = mysqli_fetch_array($result)) { |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | xmlwriter_start_element($xw, 'YEAST'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
608
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
44 | field($xw, 'VERSION', '1'); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
45 | field($xw, 'NAME', $row['name']); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
46 | field($xw, 'TYPE', $yeasttype[$row['type']]); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
47 | field($xw, 'FORM', $yeastform[$row['form']]); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
48 | field($xw, 'AMOUNT_IS_WEIGHT', ($row['form'] == '1' || $row['form'] == '6') ? 'TRUE':'FALSE'); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
49 | field($xw, 'LABORATORY', $row['laboratory']); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
50 | if (strlen($row['product_id'])) |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
51 | field($xw, 'PRODUCT_ID', $row['product_id']); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
52 | field($xw, 'MIN_TEMPERATURE', sprintf("%.4f",floatval($row['min_temperature']))); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
53 | field($xw, 'MAX_TEMPERATURE', sprintf("%.4f",floatval($row['max_temperature']))); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
54 | field($xw, 'ATTENUATION', sprintf("%.4f",floatval($row['attenuation']))); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
55 | field($xw, 'ADD_TO_SECONDARY', ($row['use'] == 0) ? 'FALSE':'TRUE'); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
56 | field($xw, 'FLOCCULATION', $yeastflocculation[$row['flocculation']]); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
57 | field($xw, 'MAX_REUSE', $row['max_reuse']); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
58 | if (floatval($row['cost']) > 0) |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
59 | field($xw, 'COST', sprintf("%.5f",floatval($row['cost']))); |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
60 | if (strlen($row['notes'])) |
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
61 | field($xw, 'NOTES', $row['notes']); |
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | |
608
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
63 | xmlwriter_end_element($xw); // YEAST |
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | } |
608
0a8495edf53c
Fixed wrong AMOUNT_IS_WEIGHT values in yeasts export.
Michiel Broek <mbroek@mbse.eu>
parents:
563
diff
changeset
|
65 | xmlwriter_end_element($xw); // YEASTS |
563
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | $beerxml = xmlwriter_output_memory($xw); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | Header('Content-type: text/xml'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | header('Content-Disposition: attachment; filename="yeasts.xml"'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | header('Content-Transfer-Encoding: binary'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | header('Expires: 0'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | header('Pragma: no-cache'); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | header('Content-Length: '.strlen($beerxml)); |
acdd54144838
Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | exit($beerxml); |