function displayRecipe($id) { global $sql; $ret = ""; $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.current_margin,i.info\n from recipes as r, info as i where r.id=i.recipeID and r.id=?"); $r = $sql->execute($q, array($id)); $w = $sql->fetch_array($r); $name = $w['name']; $upc = $w['upc']; $margin = $w['margin']; $price = $w['price']; $servings = $w['servings']; $current_margin = $w['current_margin']; $info = $w['info']; $ret .= "<span style=\"font-size: 150%\"><b>{$name}</b></span><br />"; $ret .= "\n<b>UPC</b>: {$upc}<br />"; $ret .= "\n<b>Servings</b>: {$servings}<br />"; $ret .= "<br /><b>Ingredients</b>"; $ret .= "<div id=recipeingredients>"; $ret .= getIngredients($id); $ret .= "</div>"; $ret .= "<br /><br /><b>Steps</b>:"; $ret .= "<div id=recipesteps>"; $ret .= getSteps($id); $ret .= "</div>"; $ret .= "<br /><br /><b>Info</b>:"; $ret .= "<div id=infovalue>" . $info . "</div>"; return $ret; }
function calcBest($in) { $populationSize = 20; $survivorSize = 5; $ingredients = getIngredients($in); $pop = generateInitialPopulation($ingredients, $populationSize); $bestSize = 0; $bestSizeUnchanged = 0; $count = 0; while (true) { //Sort by fitness usort($pop, function ($a, $b) { return $b['score'] - $a['score']; }); $lastBestSize = $bestSize; $bestSize = $pop[0]['score']; if ($lastBestSize === $bestSize) { $bestSizeUnchanged++; } else { $bestSizeUnchanged = 0; } if ($bestSizeUnchanged > 20000) { break; } //Choose the n best $pop = array_slice($pop, 0, $survivorSize); //Breed new population $pop = breedNewpop($pop, $populationSize, $ingredients); $count++; } uasort($pop, function ($a, $b) { return $b['score'] - $a['score']; }); print_r(array_shift($pop)); }
echo "<form method=\"post\">\n\t\t\t\t\t\t\t<center>\n\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>Zutat:</td>\n\t\t\t\t\t\t\t\t\t<td><select name=\"delIngredientItem\" data-size=5>"; //generate ingredients $array = getIngredients(); foreach ($array as $d) { echo "<option value=\"" . $d[0] . "\">" . $d[1] . "</option>"; } echo "</select></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table></center>\n\t\t\t\t\t\t\t<center><input type=\"submit\" name=\"delIngredientSubmit\" class=\"btn btn-sm btn-default\" style=\"margin-top:10px;\" value=\"Löschen\" /></center>\n\t\t\t\t\t\t\t</form>"; } ?> </div> <div class="col-sm-4"> <?php if ($isAdmin) { echo "<form method=\"post\">\n\t\t\t\t\t\t\t<center><table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>Produkt:</td>\n\t\t\t\t\t\t\t\t\t<td><select name=\"editIngredientItem\" data-size=5>"; //generate ingredients $array = getIngredients(); foreach ($array as $d) { echo "<option value=\"" . $d[0] . "\">" . $d[1] . "</option>"; } echo "</select></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>Neuer Name:</td>\n\t\t\t\t\t\t\t\t\t<td><input type=\"text\" class=\"form-control-nosize\" style=\"width:220px\" name=\"editIngredientName\"></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table></center> \n\t\t\t\t\t\t\t<center><input type=\"submit\" name=\"editIngredientSubmit\" class=\"btn btn-sm btn-default\" style=\"margin-top:10px;\" value=\"Ersetzen\" /></center>\n\t\t\t\t\t\t\t</form>"; } ?> </div> </div> </div> </div> <div class="col-sm-12"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title" align="center">Rabattaktionen</h3> </div>
function displayRecipe($id) { global $sql; $ret = ""; $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.shelflife,r.current_margin,i.info,\n c.name as category\n from recipes as r, info as i, categories as c\n where r.id=i.recipeID and c.id=r.categoryID and r.id=?"); $r = $sql->execute($q, array($id)); $w = $sql->fetch_array($r); $name = $w['name']; $upc = $w['upc']; $margin = $w['margin']; $price = $w['price']; $servings = $w['servings']; $shelflife = $w['shelflife']; $current_margin = $w['current_margin']; $info = $w['info']; $category = $w['category']; $ret .= "<input type=hidden id=recipeID value=\"{$id}\" />"; $ret .= "<b>Name</b>: <span id=recipename> {$name} "; $ret .= "<a href=\"\" onClick=\"editRecipeField('name'); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "<input type=hidden id=hrecipename value=\"{$name}\" /></span>"; $ret .= "<a href=\"\" onClick=\"deleteRecipe('{$name}'); return false;\">"; $ret .= "<img src='images/b_drop.png'></a><br />"; $ret .= "<b>Category</b>: <span id=recipecategory> {$category} "; $ret .= "<a href=\"\" onClick=\"changeCategory('{$category}'); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "</span><br />"; $ret .= "\n<b>UPC</b>: <span id=recipeupc> {$upc} "; $ret .= "<a href=\"\" onClick=\"editRecipeField('upc'); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "<input type=hidden id=hrecipeupc value=\"{$upc}\" /></span><br />"; $ret .= "<div id=recipeprice><b>Price</b>: {$price} "; $ret .= "<a href=\"\" onclick=\"editPrice(); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "<input type=hidden id=hrecipeprice value=\"{$price}\" /></div>"; $ret .= "\n<b>Servings</b>: <span id=recipeservings> {$servings} "; $ret .= "<a href=\"\" onClick=\"editRecipeField('servings'); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "<input type=hidden id=hrecipeservings value=\"{$servings}\" /></span><br />"; $ret .= "\n<b>Shelf Life</b>: <span id=recipeshelflife> {$shelflife} "; $ret .= "<a href=\"\" onClick=\"editRecipeField('shelflife'); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "<input type=hidden id=hrecipeshelflife value=\"{$shelflife}\" /></span><br />"; $ret .= "\n<b>Desired Margin</b>: <span id=recipemargin> {$margin} "; $ret .= "<a href=\"\" onClick=\"editRecipeField('margin'); return false;\">"; $ret .= "<img src='images/b_edit.png'></a> "; $ret .= "<input type=hidden id=hrecipemargin value=\"{$margin}\" /></span><br />"; $ret .= "<div id=recipecurrentmargin>"; if ($current_margin < $margin) { $ret .= currentMarginDiv($current_margin, '#bb0000'); } else { $ret .= currentMarginDiv($current_margin, '#00bb00'); } $ret .= "</div>"; $ret .= "<br /><b>Ingredients</b>"; $ret .= "<div id=recipeingredients>"; $ret .= getIngredients($id); $ret .= "</div>"; $ret .= "( <a href=\"\" onClick=\"addIngredient(); return false;\">New ingredient</a> ) "; $ret .= "( <a href=\"\" onclick=\"addLabel(); return false;\">New label</a> )"; $ret .= "<br /><br /><b>Steps</b>:"; $ret .= "<div id=recipesteps>"; $ret .= getSteps($id); $ret .= "</div>"; $ret .= "( <a href=\"\" onClick=\"addStep(); return false;\">New step</a> )"; $ret .= "<br /><br /><b>Info</b>:"; $ret .= "<div id=recipeinfo>"; $ret .= "<div id=infovalue>" . $info . "</div>"; $ret .= "<br />( <a href=\"\" onClick=\"editInfo({$id}); return false;\"><img src='images/b_edit.png'></a> )"; $ret .= "</div>"; $ret .= "<br /><b>Status</b>: "; $ret .= "<span id=recipestatus>"; $ret .= getStatus($id); $ret .= "</span> "; $ret .= "[ <a href=\"\" onclick=\"restatus({$id}); return false;\">Refresh</a> ]"; return $ret; }
function printIngredients($post_id) { echo '<div class="panel">'; echo '<ul>'; $ingredients = getIngredients($post_id); if ($ingredients) { foreach ($ingredients as $ingredient) { echo '<li>' . $ingredient . '</li>'; } } else { echo '<li>Brak składników!</li>'; } echo '</ul>'; echo '</div>'; }
function displayRecipe($id) { global $sql; $ret = ""; $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.current_margin,i.info\n from recipes as r, info as i where r.id=i.recipeID and r.id=?"); $r = $sql->execute($q, array($id)); $w = $sql->fetch_array($r); $name = $w['name']; $upc = $w['upc']; $margin = $w['margin']; $price = $w['price']; $servings = $w['servings']; $current_margin = $w['current_margin']; $info = $w['info']; $ret .= "<b>Name</b>: {$name}<br />"; $ret .= "\n<b>UPC</b>: {$upc}<br />"; $ret .= "<div id=recipeprice><b>Price</b>: {$price}</div>"; $ret .= "\n<b>Servings</b>: {$servings}<br />"; $ret .= "<b>Multiplier</b>: <input type=text value=1 id=multiplier size=3 /> "; $ret .= "<a href=\"\" onclick=\"mult({$id}); return false;\">Change</a> | "; $ret .= "<a href=\"print.php?id={$id}\" target=\"print_window\">Print</a><br />"; $ret .= "<br /><b>Ingredients</b>"; $ret .= "<div id=recipeingredients>"; $ret .= getIngredients($id); $ret .= "</div>"; $ret .= "<br /><br /><b>Steps</b>:"; $ret .= "<div id=recipesteps>"; $ret .= getSteps($id); $ret .= "</div>"; $ret .= "<br /><br /><b>Info</b>:"; $ret .= "<div id=infovalue>" . $info . "</div>"; return $ret; }
<?php $productid = (int) $_GET['productid']; require_once 'mod/default/catering/catering.function.php'; $ingredients = getIngredients($productid); $smarty->assign('ingredients', $ingredients); $smarty->display('../mod/default/catering/show.ingredients.tpl');
</div> <!-- #endregion --> </div> <!-- #endregion --> </div> <!-- #endregion --> <!-- #region Modals --> <!-- #region printIngredients --> <div id="printList" class="reveal-modal" style="width: 50%;" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog"> <?php $ingredients = getIngredients($post->ID); ?> <div class="medium-8 column medium-centered"> <?php echo '<h3>' . get_the_title() . '</h3>'; ?> <table> <tbody> <?php foreach ($ingredients as $ingredient) { ?> <tr> <td><?php echo $ingredient; ?>
foreach ($h->find('li[class=ingredient]') as $data) { $ingredient = $data->plaintext; if (isset($h->href)) { $href = $h->href; } //foreach($domFoods->find('ul[class=kv-ingred-list1]',1)->children() as $data){ //echo $data->plaintext; scraperwiki::save(array('ing'), array('ing' => $ingredient, 'href' => $href)); } } # Blank PHP require 'scraperwiki/simple_html_dom.php'; $myFood = "maccheroni"; $foodNet = "http://www.foodnetwork.com/search/delegate.do?fnSearchString=" . $myFood . "&fnSearchType=site"; $html = scraperwiki::scrape($foodNet); getIngredients($html); function getIngredients($html) { $i = 0; $dom = new simple_html_dom(); $dom->load($html); //foreach($dom->find('result-item',1)->href as $data) //{ // if ($data != null) //$res = trim($data->plaintext); $res = $dom->find('a[class=callout]', 1)->href; $res = str_replace("reviews/", "", $res); echo "http://www.foodnetwork.com" . $res; $html1 = scraperwiki::scrape("http://www.foodnetwork.com" . $res); $domFoods = new simple_html_dom(); //$domFoods->load($html1);
$ret .= "<input type=checkbox id=\"" . $statusW['name'] . $statusW['id'] . "\" "; if ($statusW['flag'] == 1) { $ret .= "checked "; } $ret .= "onclick=\"flipStatus({$id},'{$statusW['name']}',{$statusW['id']});\" /><br />"; } return $ret; } ?> <html> <head><title>Recipizer::Ingredients</title> <script type="text/javascript" src="ingredients.js"></script> <link rel="stylesheet" type="text/css" href="index.css"> </head> <div id="top"> <a href="index.php">Recipes</a> :: <a href="ingredients.php">Ingredients</a> :: <a href="viewer.php">Viewer</a> </div> <div id="left"> <?php echo getIngredients(); ?> </div> <div id="right"> </div> </body> </html>