<!-- Input Here --> <select class="selectpicker" name="brewStyle" id="type" data-live-search="true" data-size="10" data-width="auto"> <?php do { // Build style drop-down // Option value variable $style_value = ltrim($row_styles['brewStyleGroup'], "0") . "-" . $row_styles['brewStyleNum']; // Determine if the subcategory limit has been reached for various conditions if ($_SESSION['userLevel'] == 2) { $subcat_limit = limit_subcategory($style_value, $user_subcat_limit, $user_subcat_limit_exception, $row_limits['prefsUSCLEx'], $_SESSION['user_id']); } elseif ($_SESSION['userLevel'] <= 1 && $filter != "admin" && $id == "default") { $subcat_limit = limit_subcategory($style_value, $user_subcat_limit, $user_subcat_limit_exception, $row_limits['prefsUSCLEx'], $filter); } elseif ($_SESSION['userLevel'] <= 1 && $filter != "admin" && $id != "default") { $subcat_limit = limit_subcategory($style_value, $user_subcat_limit, $user_subcat_limit_exception, $row_limits['prefsUSCLEx'], $row_log['brewBrewerID']); } elseif ($_SESSION['userLevel'] <= 1 && $filter == "admin") { $subcat_limit = limit_subcategory($style_value, $user_subcat_limit, $user_subcat_limit_exception, $row_limits['prefsUSCLEx'], $_SESSION['user_id']); } // Build selected/disabled variable if ($action == "edit") { if ($row_styles['brewStyleGroup'] . $row_styles['brewStyleNum'] == $row_log['brewCategorySort'] . $row_log['brewSubCategory']) { $selected_disabled = "SELECTED"; } if ($row_styles['brewStyleGroup'] . $row_styles['brewStyleNum'] != $row_log['brewCategorySort'] . $row_log['brewSubCategory']) { $selected_disabled = $subcat_limit; } } if ($action == "add" && $remaining_entries > 0 && !$disable_fields) { $selected_disabled = $subcat_limit; } elseif ($disable_fields) { $selected_disabled = "DISABLED"; }
function insertRecipe($recipe) { // inserts into `recipes` DB table include CONFIG . 'config.php'; include INCLUDES . 'scrubber.inc.php'; //include (INCLUDES.'url_variables.inc.php'); $brewing = $connection; $sqlQuery = "INSERT INTO " . $prefix . "brewing"; $fields = "(brewName"; $values = " VALUES('" . strtr($recipe->name, $html_string) . "'"; $vf = array(); $counter = array(); $vf["brewBrewerFirstName"] = $_POST["brewBrewerFirstName"]; $vf["brewBrewerLastName"] = $_POST["brewBrewerLastName"]; $query_limits = sprintf("SELECT * FROM %s WHERE id='1'", $prefix . "preferences"); $limits = mysql_query($query_limits, $brewing) or die(mysql_error()); $row_limits = mysql_fetch_assoc($limits); $style_value = ltrim($recipe->style->categoryNumber, "0") . "-" . $recipe->style->styleLetter; if (empty($row_limits['prefsUserSubCatLimit'])) { $user_subcat_limit = "99999"; } else { $user_subcat_limit = $row_limits['prefsUserSubCatLimit']; } if (empty($row_limits['prefsUSCLExLimit'])) { $user_subcat_limit_exception = "99999"; } else { $user_subcat_limit_exception = $row_limits['prefsUSCLExLimit']; } // Determine if the subcategory limit has been reached $subcat_limit = limit_subcategory($style_value, $user_subcat_limit, $user_subcat_limit_exception, $row_limits['prefsUSCLEx'], $_SESSION['loginUsername']); if (!$subcat_limit) { $vf["brewStyle"] = strtr($recipe->style->name, $html_string); $vf["brewCategory"] = ltrim($recipe->style->categoryNumber, "0"); $vf["brewCategorySort"] = $recipe->style->categoryNumber; $vf["brewSubCategory"] = $recipe->style->styleLetter; } else { $vf["brewStyle"] = ""; $vf["brewCategory"] = ""; $vf["brewCategorySort"] = ""; $vf["brewSubCategory"] = ""; } //$vf["brewSource"] = $recipe->brewer; //$vf["brewYield"] = $this->convertUnit($recipe->batchSize, "volume"); //$vf["brewNotes"] = strtr($recipe->notes, $html_string); //$vf["brewMethod"] = $recipe->type; $counter["grain"] = 0; $counter["extract"] = 0; $counter["adjunct"] = 0; foreach ($recipe->fermentables->fermentables as $fermentable) { switch ($fermentable->type) { case "Grain": $counter["grain"]++; if ($counter["grain"] <= 15) { $vf["brewGrain" . $counter["grain"]] = strtr($fermentable->name, $html_string); $vf["brewGrain" . $counter["grain"] . "Weight"] = number_format($this->convertUnit($fermentable->amount, "weight"), 2); $vf["brewGrain" . $counter["grain"] . "Use"] = "Mash"; } break; case "Extract": $counter["extract"]++; if ($counter["extract"] <= 5) { $vf["brewExtract" . $counter["extract"]] = strtr($fermentable->name, $html_string); $vf["brewExtract" . $counter["extract"] . "Weight"] = number_format($this->convertUnit($fermentable->amount, "weight"), 2); $vf["brewExtract" . $counter["extract"] . "Use"] = "Other"; } break; case "Dry Extract": $counter["extract"]++; if ($counter["extract"] <= 5) { $vf["brewExtract" . $counter["extract"]] = strtr($fermentable->name, $html_string); $vf["brewExtract" . $counter["extract"] . "Weight"] = number_format($this->convertUnit($fermentable->amount, "weight"), 2); $vf["brewExtract" . $counter["extract"] . "Use"] = "Other"; } break; case "Adjunct": $counter["adjunct"]++; if ($counter["adjunct"] <= 9) { $vf["brewAddition" . $counter["adjunct"]] = strtr($fermentable->name, $html_string); $vf["brewAddition" . $counter["adjunct"] . "Amt"] = number_format($this->convertUnit($fermentable->amount, "weight"), 2); $vf["brewAddition" . $counter["adjunct"] . "Use"] = "Other"; } break; case "Sugar": $counter["adjunct"]++; if ($counter["adjunct"] <= 9) { $vf["brewAddition" . $counter["adjunct"]] = strtr($fermentable->name, $html_string); $vf["brewAddition" . $counter["adjunct"] . "Amt"] = number_format($this->convertUnit($fermentable->amount, "weight"), 2); $vf["brewAddition" . $counter["adjunct"] . "Use"] = "Other"; } break; default: break; } } /* $counter["misc"] = 0; foreach($recipe->miscs->miscs as $misc){ $counter["misc"]++; if($counter["misc"] <= 4){ $vf["brewMisc" . $counter["misc"] . "Name"] = strtr($misc->name, $html_string); $vf["brewMisc" . $counter["misc"] . "Type"] = $misc->type; // BeerXML differntiates between liquid and volume - BB 2.2 does not - item for future release $vf["brewMisc" . $counter["misc"] . "Use"] = $misc->useFor; $vf["brewMisc" . $counter["misc"] . "Time"] = round($misc->time, 0); $vf["brewMisc" . $counter["misc"] . "Amount"] = number_format(round($misc->amount, 2),2); // Beer XML standard is kg or liters - will need to address in subsequent release } } */ $counter["hops"] = 0; foreach ($recipe->hops->hops as $hop) { $counter["hops"]++; if ($counter["hops"] <= 15) { $vf["brewHops" . $counter["hops"]] = strtr($hop->name, $html_string); $vf["brewHops" . $counter["hops"] . "Weight"] = number_format($this->convertUnit($hop->amount, "hopWeight"), 2); $vf["brewHops" . $counter["hops"] . "IBU"] = number_format($hop->alpha, 1); $vf["brewHops" . $counter["hops"] . "Time"] = round($hop->time, 0); $vf["brewHops" . $counter["hops"] . "Use"] = $hop->use; $vf["brewHops" . $counter["hops"] . "Type"] = $hop->type; $vf["brewHops" . $counter["hops"] . "Form"] = $hop->form; } } $counter["yeast"] = 0; foreach ($recipe->yeasts->yeasts as $yeast) { $vf["brewYeast"] = strtr($yeast->name, $html_string); $vf["brewYeast" . "Man"] = $yeast->laboratory; $vf["brewYeast" . "Form"] = $yeast->form; $vf["brewYeast" . "Type"] = $yeast->type; if ($yeast->amountIsWeight == "TRUE") { $vf["brewYeast" . "Amount"] = number_format($this->convertUnit($yeast->amount, "weight"), 0); } else { $vf["brewYeast" . "Amount"] = $this->convertUnit($yeast->amount, "volume"); } } $vf["brewOG"] = number_format($recipe->og, 3); $vf["brewFG"] = number_format($recipe->fg, 3); // $vf["brewProcedure"] = $recipe->notes; if ($recipe->primaryAge != "") { $vf["brewPrimary"] = number_format(round($recipe->primaryAge, 0), 0); } if ($recipe->primaryTemp != "") { $vf["brewPrimaryTemp"] = number_format($this->convertUnit($recipe->primaryTemp, "temperature"), 0); } if ($recipe->secondaryAge != "") { $vf["brewSecondary"] = number_format(round($recipe->secondaryAge, 0), 0); } if ($recipe->secondaryTemp != "") { $vf["brewSecondaryTemp"] = number_format($this->convertUnit($recipe->secondaryTemp, "temperature"), 0); } $vf["brewBrewerID"] = $_POST["brewBrewerID"]; $vf["brewConfirmed"] = "0"; if (!empty($vf["brewStyle"])) { $vf["brewJudgingNumber"] = generate_judging_num($vf["brewCategory"]); } else { $vf["brewJudgingNumber"] = ""; } foreach ($vf as $field => $value) { $fields .= ", " . $field; $values .= ", '" . $value . "'"; } mysql_select_db($database, $brewing) or die(mysql_error()); $fields .= ", brewUpdated"; $fields .= ")"; $values .= ", NOW( )"; $values .= ")"; $sqlQuery .= $fields . $values; $Result1 = mysql_query($sqlQuery, $brewing) or die(mysql_error()); $this->insertedRecipes[mysql_insert_id()] = $recipe->name; //header(sprintf("Location: %s", $base_url."index.php?section=list")); }