Wed, 06 May 2020 14:14:14 +0200
Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
<?php require_once('config.php'); require("version.php"); require("includes/formulas.php"); $target_dir = "tmp/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if file already exists if (file_exists($target_file)) { echo "Fout 1: bestand bestaat al. "; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000 && $uploadOk) { echo "Fout 2: het bestand is te groot. "; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "xml" && $uploadOk) { echo "Fout 3: alleen XML bestanden toegestaan. "; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { exit; } if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "Verwerken bestand ". basename( $_FILES["fileToUpload"]["name"]). "<br />"; } else { echo "Fout 4: er ging iets fout met de upload."; exit; } $db = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); if (! $db) { echo "Fout 5: ".mysqli_connect_errno()." ".mysqli_connect_error(); exit; } mysqli_set_charset($db, "utf8" ); date_default_timezone_set('Europe/Amsterdam'); $imported = 0; $miscs = simplexml_load_file($target_file); foreach ($miscs->MISC as $misc) { $sql = "INSERT INTO inventory_miscs SET name='" . mysqli_real_escape_string($db, $misc->NAME); if ($misc->NOTES) $sql .= "', notes='" . mysqli_real_escape_string($db, $misc->NOTES); if ($misc->TYPE == 'Spice') $sql .= "', type='0"; else if ($misc->TYPE == 'Herb') $sql .= "', type='1"; else if ($misc->TYPE == 'Flavor') $sql .= "', type='2"; else if ($misc->TYPE == 'Fining') $sql .= "', type='3"; else if ($misc->TYPE == 'Water agent') $sql .= "', type='4"; else if ($misc->TYPE == 'Yeast nutrient') $sql .= "', type='5"; else if ($misc->TYPE == 'Other') $sql .= "', type='6"; else echo "Unknown TYPE " . $misc->TYPE . "<br />"; if ($misc->USE == 'Starter') $sql .= "', use_use='0"; else if ($misc->USE == 'Mash') $sql .= "', use_use='1"; else if ($misc->USE == 'Boil') $sql .= "', use_use='2"; else if ($misc->USE == 'Primary') $sql .= "', use_use='3"; else if ($misc->USE == 'Secondary') $sql .= "', use_use='4"; else if ($misc->USE == 'Bottling') $sql .= "', use_use='5"; else echo "Unknown USE " . $misc->USE . "<br />"; $sql .= "', time='" . $misc->TIME; ($misc->AMOUNT_IS_WEIGHT == 'TRUE') ? $sql .= "', amount_is_weight='1" : $sql .= "', amount_is_weight='0"; if ($misc->USE_FOR) $sql .= "', use_for='" . mysqli_real_escape_string($db, $misc->USE_FOR); if ($misc->ALWAYS_ON_STOCK) ($misc->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; if ($misc->INVENTORY) $sql .= "', inventory='" . floatval($misc->INVENTORY) / 1000.0; if ($misc->COST) $sql .= "', cost='" . floatval($misc->COST); $sql .= "';"; if (! $result = mysqli_query($db, $sql)) { echo "Fout 8: " . mysqli_error($db) . "<br />"; } else { echo "+ " . $misc->NAME . "<br />"; $imported++; } } if ($imported == 0) { echo "Fout 7: geen diverse ingredienten in dit bestand.<br />"; } else { echo $imported . " diverse ingredienten toegevoegd.<br />"; } // Don't clutter the upload directory. unlink($target_file); ?>