www/upl_yeasts.php

Thu, 05 Dec 2019 22:47:40 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 05 Dec 2019 22:47:40 +0100
changeset 563
acdd54144838
parent 311
f6fafccd8a6d
child 785
aa79acfdf8a9
permissions
-rw-r--r--

Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.

311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 require_once('config.php');
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require("version.php");
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 require("includes/formulas.php");
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 $target_dir = "tmp/";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 $uploadOk = 1;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 // Check if file already exists
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 if (file_exists($target_file)) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 echo "Fout 1: bestand bestaat al. ";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 $uploadOk = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 // Check file size
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 if ($_FILES["fileToUpload"]["size"] > 500000 && $uploadOk) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 echo "Fout 2: het bestand is te groot. ";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 $uploadOk = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 // Allow certain file formats
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 if ($imageFileType != "xml" && $uploadOk) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 echo "Fout 3: alleen XML bestanden toegestaan. ";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 $uploadOk = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 // Check if $uploadOk is set to 0 by an error
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 if ($uploadOk == 0) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 exit;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 echo "Verwerken bestand ". basename( $_FILES["fileToUpload"]["name"]). "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 echo "Fout 4: er ging iets fout met de upload.";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 exit;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 $db = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 if (! $db) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 echo "Fout 5: ".mysqli_connect_errno()." ".mysqli_connect_error();
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 exit;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 mysqli_set_charset($db, "utf8" );
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 date_default_timezone_set('Europe/Amsterdam');
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 $imported = 0;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 $yeasts = simplexml_load_file($target_file);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 foreach ($yeasts->YEAST as $yeast) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 $sql = "INSERT INTO inventory_yeasts SET name='" . mysqli_real_escape_string($db, $yeast->NAME);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 if ($yeast->TYPE == 'Lager')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 $sql .= "', type='0";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 else if ($yeast->TYPE == 'Ale')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 $sql .= "', type='1";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 else if ($yeast->TYPE == 'Wheat')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 $sql .= "', type='2";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 else if ($yeast->TYPE == 'Wine')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 $sql .= "', type='3";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 else if ($yeast->TYPE == 'Champagne')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 $sql .= "', type='4";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 echo "Unknown TYPE " . $yeast->TYPE . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 if ($yeast->FORM == 'Liquid')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 $sql .= "', form='0";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 else if ($yeast->FORM == 'Dry')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 $sql .= "', form='1";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 else if ($yeast->FORM == 'Slant')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 $sql .= "', form='2";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 else if ($yeast->FORM == 'Culture')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 $sql .= "', form='3";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 else if ($yeast->FORM == 'Frozen')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 $sql .= "', form='4";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 else if ($yeast->FORM == 'Bottle')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 $sql .= "', form='5";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 echo "Unknown FORM " . $yeast->FORM . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 $sql .= "', laboratory='" . mysqli_real_escape_string($db, $yeast->LABORATORY);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 $sql .= "', product_id='" . mysqli_real_escape_string($db, $yeast->PRODUCT_ID);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 if ($yeast->MIN_TEMPERATURE)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 $sql .= "', min_temperature='" . floatval($yeast->MIN_TEMPERATURE);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 if ($yeast->MAX_TEMPERATURE)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 $sql .= "', max_temperature='" . floatval($yeast->MAX_TEMPERATURE);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 if ($yeast->FLOCCULATION == 'Low')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 $sql .= "', flocculation='0";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 else if ($yeast->FLOCCULATION == 'Medium')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 $sql .= "', flocculation='1";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 else if ($yeast->FLOCCULATION == 'High')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 $sql .= "', flocculation='2";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 else if ($yeast->FLOCCULATION == 'Very high')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 $sql .= "', flocculation='3";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 echo "Unknown FLOCCULATION " . $yeast->FLOCCULATION . PHP_EOL;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 if ($yeast->ATTENUATION)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 $sql .= "', attenuation='" . floatval($yeast->ATTENUATION);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 $sql .= "', notes='" . mysqli_real_escape_string($db, $yeast->NOTES);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 $sql .= "', best_for='" . mysqli_real_escape_string($db, $yeast->BEST_FOR);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 if ($yeast->MAX_REUSE)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 $sql .= "', max_reuse='" . $yeast->MAX_REUSE;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 if ($yeast->FORM == 'Liquid') {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 if ($yeast->LABORATORY == 'Imperial Yeast')
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 $sql .= "', cells='200000000000"; // 200 billion cells per pack
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 else
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 $sql .= "', cells='100000000000"; // 100 billion cells per pack
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 if ($yeast->COST)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 $sql .= "', cost='" . floatval($yeast->COST);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 if ($yeast->INVENTORY)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 $sql .= "', inventory='" . floatval($yeast->INVENTORY);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 } else if ($yeast->FORM == 'Dry') {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 $sql .= "', cells='15000000000"; // 6..15 billion per gram
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 if ($yeast->INVENTORY)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To kg
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 if ($yeast->COST)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/kg
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 $sql .= "', cells='1700000000"; // 1.7 billion cells per ml.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 if ($yeast->INVENTORY)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To liter
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 if ($yeast->COST)
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/liter
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 if ($yeast->CULTURE_DATE) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 $sql .= "', production_date='" . $date;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 $sql .= "';";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 if (! $result = mysqli_query($db, $sql)) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 echo "Fout 8: " . mysqli_error($db) . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 echo "+ " . $yeast->NAME . "<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 $imported++;
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 if ($imported == 0) {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 echo "Fout 7: geen gisten in dit bestand.<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 } else {
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 echo $imported . " gisten toegevoegd.<br />";
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 }
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 // Don't clutter the upload directory.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 unlink($target_file);
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 ?>

mercurial