function testIngredientExistence() { $ingredient = new Ingredient(7); $this->assertTrue($ingredient->exists()); $this->assertTrue(!empty($ingredient->name())); $this->assertTrue(!empty($ingredient->unit())); }
/** * [haveEnoughStocks description] * @param [type] $ingredients [description] * @param [type] $amount_g [converted amount in grams] * @param [type] $amount [original inputted amount(for eggs)] * @return [type] [description] */ public function haveEnoughStocks($ingredients, $amount_g, $amount) { $i = 0; $ingredient_obj = new Ingredient(); $flag = true; foreach ($ingredients as $ing) { //get current stock in grams $ingredient = $ingredient_obj->findOrFail($ing); $current_stock = $ingredient->in_grams; // print $current_stock;exit(); if ($ingredient->name == 'Eggs') { if ($ingredient->stocks < $amount[$i]) { $flag = false; } } else { if ($amount_g[$i] > $current_stock) { //have enough stocks // return print "not enough stocks on ingredient ". $ing . 'tobe paid'.$amount_g[$i];exit(); $flag = false; } } $i++; } return $flag; }
function InsertIngredient() { require_once "models/Ingredient.php"; $newIngredient = new Ingredient(); $name = $_POST["name"]; Ingredient::insert($dbh, $name); $newIngredient->find($dbh, $name); return json_encode($newIngredient); }
static function findAll($dbh) { $stmt = $dbh->prepare("select * from " . Ingredient::$tableName); $stmt->execute(); $result = array(); while ($row = $stmt->fetch()) { $p = new Ingredient(); $p->copyFromRow($row); $result[] = $p; } return $result; }
static function findAll($dbh, $withSteps = false) { $stmt = $dbh->prepare("select * from " . Ingredient::$tableName . " order by id"); $stmt->execute(); $result = array(); while ($row = $stmt->fetch()) { $i = new Ingredient(); $i->copyFromRow($row); $result[] = $i; } return $result; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $ingredient = Ingredient::find($id); $ingredient->delete(); return Redirect::to('ingredient'); }
public function run() { $ingredients = [['ingredient_name' => 'dough', 'current_stock' => 100, 'price' => 25, 'size' => 'solo', 'category' => 'base', 'image_location' => '../images/ingredients/base.png'], ['ingredient_name' => 'dough', 'current_stock' => 100, 'price' => 45, 'size' => 'large', 'category' => 'base', 'image_location' => '../images/ingredients/base.png'], ['ingredient_name' => 'shoestring fries', 'current_stock' => 100, 'price' => 20, 'size' => 'solo', 'category' => 'base', 'image_location' => '../images/ingredients/shoestring.png'], ['ingredient_name' => 'crisscross fries', 'current_stock' => 100, 'price' => 25, 'size' => 'solo', 'category' => 'base', 'image_location' => '../images/ingredients/crisscross.png'], ['ingredient_name' => 'marinara', 'current_stock' => 100, 'price' => 0, 'size' => 'solo', 'category' => 'sauce', 'image_location' => '../images/ingredients/marinara.png'], ['ingredient_name' => 'olive oil', 'current_stock' => 100, 'price' => 0, 'size' => 'solo', 'category' => 'sauce', 'image_location' => '../images/ingredients/oliveoil.png'], ['ingredient_name' => 'mozzarella', 'current_stock' => 100, 'price' => 25, 'size' => 'solo', 'category' => 'cheese', 'image_location' => '../images/ingredients/mozzarella.png'], ['ingredient_name' => 'mozzarella', 'current_stock' => 100, 'price' => 45, 'size' => 'large', 'category' => 'cheese', 'image_location' => '../images/ingredients/mozzarella.png'], ['ingredient_name' => 'quickmelt', 'current_stock' => 100, 'price' => 19, 'size' => 'solo', 'category' => 'cheese', 'image_location' => '../images/ingredients/quickmelt.png'], ['ingredient_name' => 'quickmelt', 'current_stock' => 100, 'price' => 30, 'size' => 'large', 'category' => 'cheese', 'image_location' => '../images/ingredients/quickmelt.png'], ['ingredient_name' => 'pepperoni', 'current_stock' => 100, 'price' => 20, 'size' => 'solo', 'category' => 'meat', 'image_location' => '../images/ingredients/pepperoni.png'], ['ingredient_name' => 'pepperoni', 'current_stock' => 100, 'price' => 35, 'size' => 'large', 'category' => 'meat', 'image_location' => '../images/ingredients/pepperoni.png'], ['ingredient_name' => 'hungarian sausage', 'current_stock' => 100, 'price' => 20, 'size' => 'solo', 'category' => 'meat', 'image_location' => '../images/ingredients/sausage.png'], ['ingredient_name' => 'hungarian sausage', 'current_stock' => 100, 'price' => 35, 'size' => 'large', 'category' => 'meat', 'image_location' => '../images/ingredients/sausage.png'], ['ingredient_name' => 'ham', 'current_stock' => 100, 'price' => 15, 'size' => 'solo', 'category' => 'meat', 'image_location' => '../images/ingredients/ham.png'], ['ingredient_name' => 'ham', 'current_stock' => 100, 'price' => 25, 'size' => 'large', 'category' => 'meat', 'image_location' => '../images/ingredients/ham.png'], ['ingredient_name' => 'hotdog', 'current_stock' => 100, 'price' => 15, 'size' => 'solo', 'category' => 'meat', 'image_location' => '../images/ingredients/hotdog.png'], ['ingredient_name' => 'hotdog', 'current_stock' => 100, 'price' => 25, 'size' => 'large', 'category' => 'meat', 'image_location' => '../images/ingredients/hotdog.png'], ['ingredient_name' => 'bacon', 'current_stock' => 100, 'price' => 15, 'size' => 'solo', 'category' => 'meat', 'image_location' => '../images/ingredients/bacon.png'], ['ingredient_name' => 'bacon', 'current_stock' => 100, 'price' => 25, 'size' => 'large', 'category' => 'meat', 'image_location' => '../images/ingredients/bacon.png'], ['ingredient_name' => 'green bell pepper', 'current_stock' => 100, 'price' => 10, 'size' => 'solo', 'category' => 'chili', 'image_location' => '../images/ingredients/greenbellpepper.png'], ['ingredient_name' => 'red bell pepper', 'current_stock' => 100, 'price' => 10, 'size' => 'solo', 'category' => 'chili', 'image_location' => '../images/ingredients/redbellpepper.png'], ['ingredient_name' => 'chili flakes', 'current_stock' => 100, 'price' => 5, 'size' => 'solo', 'category' => 'chili', 'image_location' => '../images/ingredients/chiliflakes.png'], ['ingredient_name' => 'pineapple', 'current_stock' => 100, 'price' => 10, 'size' => 'solo', 'category' => 'topping', 'image_location' => '../images/ingredients/pineapple.png'], ['ingredient_name' => 'pineapple', 'current_stock' => 100, 'price' => 15, 'size' => 'large', 'category' => 'topping', 'image_location' => '../images/ingredients/pineapple.png'], ['ingredient_name' => 'mushroom', 'current_stock' => 100, 'price' => 10, 'size' => 'solo', 'category' => 'topping', 'image_location' => '../images/ingredients/mushroom.png'], ['ingredient_name' => 'mushroom', 'current_stock' => 100, 'price' => 15, 'size' => 'large', 'category' => 'topping', 'image_location' => '../images/ingredients/mushroom.png'], ['ingredient_name' => 'tomatoes', 'current_stock' => 100, 'price' => 5, 'size' => 'solo', 'category' => 'topping', 'image_location' => '../images/ingredients/tomatoes.png'], ['ingredient_name' => 'onions', 'current_stock' => 100, 'price' => 5, 'size' => 'solo', 'category' => 'topping', 'image_location' => '../images/ingredients/onion.png']]; foreach ($ingredients as $ingredient) { Ingredient::create($ingredient); } }
/** * getById function. Get Ingredient Object by id in array. In fact it is only a more modern and convenient way to access data. For the sake of coherence ! * * @access public * @static * @param int id - $id * @return Ingredient Object */ public static function getById($id) { if (Ingredient::getDataAt($id)) { return new Ingredient($id); } return null; }
private static function set_product_ingredients($product, $ingredients) { foreach ($ingredients as $ingredient_name) { if ($ingredient_name != 'empty') { $product->ingredients[] = Ingredient::findByName($ingredient_name); } } }
public function run() { DB::table('ingredients')->delete(); Ingredient::create(["nom" => "sel"]); Ingredient::create(["nom" => "poivre"]); Ingredient::create(["nom" => "farine"]); Ingredient::create(["nom" => "levure"]); }
/** * @return string[] * @param bool $sendBase */ public function ToArray($sendBase = true) { $result = array('id' => (int) $this->ID, 'title' => $this->Title, 'description' => $this->Description, 'created' => $this->CreateStamp, 'modified' => $this->ModifyStamp); if ($sendBase && $this->BaseIngredient) { $result += array('base' => $this->BaseIngredient->ToArray(false)); } return $result; }
/** * Display a listing of the resource. * * @return Response */ public function index() { //get the low level ingredients list // $threshold = Ingredient::where('stocks', '<','alert_level')->get(); $threshold = Ingredient::getThresholdIngredients(); // return $threshold; //show the view return View::make('inventory.index')->with('title', 'Store Inventory')->with('ingredients', Ingredient::all())->with('threshold', $threshold); }
/** * Return the list of items on the main page * * @return items */ protected function index() { //enabled Voice Command by default Session::put('VC', 'enabled'); //get the first most recent 10 logs $logs = Audit::orderBy('id', 'desc')->take(10)->get(); $low_stocks = Ingredient::selectRaw("fposs_ingredients.name,fposs_suppliers.name as supp,\n\t\t\t\t\tfposs_suppliers.resource_person,fposs_ingredients.stocks,\n\t\t\t\t\tfposs_ingredients.alert_level,fposs_ingredients.shipment_unit")->where('stocks', '<=', 'alert_level')->leftJoin('fposs_suppliers', 'fposs_ingredients.supplier_id', '=', 'fposs_suppliers.id')->get(); // $low_stocks = DB::table('fposs_ingredients')->where('stocks', '<', 'alert_level')->count(); $items = $this->production_item->getCurrentProduction(); return View::make('index')->with('title', "Flibbys Point of Sale System")->with('items', $items)->with('ingredients', $low_stocks)->with('logs', $logs); }
function loadIngredients($id) { $result_fields = array("ingredient_id", "quantity"); $table = "RecipeIngredient"; $eid = new stdClass(); $eid->column = "recipe_id"; $eid->compare = "="; $eid->logical = ""; $eid->value = $id; $query_params = array($eid); $con1 = new SQLconnection(); $obj = $con1->pdo_query_wparam($result_fields, $table, $query_params); if (!empty($obj)) { foreach ($obj->results as $ing) { $ingredient = new Ingredient($ing->ingredient_id); $ingredient->setQuantity($ing->quantity); array_push($this->ingredients, $ingredient); } } else { array_push($this->ingredients, "No Ingredients available"); } }
public function show($id) { if ($id == 0) { $ingredients = Ingredient::all(); foreach ($ingredients as $key => $item) { $ingredients[$key]['type'] = \App\Type::find($item->type_id); } return response()->json(['ingredients' => $ingredients]); } else { $aux = \App\Type::all(); $types = $this->getTypes($aux); $ingredient = Ingredient::find($id); return response()->json(['ingredient' => $ingredient, 'types' => $types]); } }
/** * Display a listing of the resource. * GET /reports * * @return Response */ public function index() { // return Carbon\Carbon::createFromDate(2015,21,22)->addYears(9); $sales_per_month = $this->sale->salesPerMonth(); // return $sales_per_month; $items = $this->sale->topThreebestSellersName(); $amounts = $this->sale->topThreebestSellersAmount(); $items_by_sales = $this->sale->getItemsBySales(); $data = $this->sale->bestSellersThisWeek(); //get all the cashiers $cashiers = User::lists('username', 'username'); $ingredients = Ingredient::lists('name', 'id'); // return $data; return View::make('reports.reports')->with('title', 'Reports Module')->with('sales', $sales_per_month)->with('items', $items)->with('amounts', $amounts)->with('sales_items', $items_by_sales)->with('cashiers', $cashiers)->with('ingredients', $ingredients); // ->with('amount',$amount); // ->with('value',$amount); }
public function actionTestManyToMany() { $items = Item::model()->findAll(); $ingredients = Ingredient::model()->findAll(); foreach ($items as $item) { echo $item->name . " has " . count($item->ingredients) . " ingredients. They are:<br />"; foreach ($item->ingredients as $ingredient) { echo $ingredient->name . "<br />"; } echo "<br />"; } echo "<hr />"; foreach ($ingredients as $ingredient) { echo $ingredient->name . " is associated with " . count($ingredient->items) . " items. They are:<br />"; foreach ($ingredient->items as $item) { echo $item->name . "<br />"; } echo "<br />"; } }
public static function getRecommendedByItem($id) { global $db; //get all ingredients recommended for the item $recommendedSQL = "SELECT * FROM items_have_recommended_ingredients WHERE itemid=?"; $values = array($id); $recList = $db->qwv($recommendedSQL, $values); //get info for each ingredient $recommendedSQL = "SELECT * FROM ingredients WHERE ingredientid=?"; $recommends = array(); $db->prep($recommendedSQL); foreach($recList as $recID) { $values = array($recID['ingredientid']); $ing = $db->qwv(null, $values); array_push($recommends, $ing[0]); } return Ingredient::wrap($recommends); }
public function updateProductionUnits() { //equivalent in grams $equivalents = Input::get('prod_units'); //unit ids $unit_id = Input::get('unit_id'); //ingredient id $ing_id = Input::get('ing_id'); //update the item $prod_unit = new ProductionUnit(); //check for redundunt unit types $ing_units = $prod_unit->getIngredientUnits($ing_id); // for($i = 0; $i < count($unit_id); $i++){ // if(in_array($unit_id[$i], $ing_units)){ // return Response::json(['response' => 300,'msg' => 'Unit already exists.']); // } // } $prod_unit->updateProductionUnits($ing_id, $equivalents, $unit_id); //redirect to the view $ingredients = Ingredient::lists('name', 'id'); return Redirect::to('/settings')->with('title', 'Settings')->with('flash_message', 'Changes has been saved.')->with('flash_type', 'alert alert-success')->with('ingredients', $ingredients); }
<?php require_once '../../functions.php'; $data = $_POST; $resp = new Ajax_Response($data['action'], true); if (!empty($data) && is_array($data)) { // $data['product_type'] $ingredient_type = new Ingredient_Type($data['type']); $ingredient = new Ingredient(); $options = $ingredient->get_ingredients_by_type($ingredient_type->ingredient_type_id); if (is_array($options) && !empty($options)) { $data['type'] = 'select'; $data['name'] = 'ingredients[' . $ingredient_type->ingredient_type_slug . ']'; $data['val'] = $options; $data['data_attr'] = ''; $data['placeholder'] = 'Select an Ice Cream Flavor'; $resp->set_status(true); $resp->set_data(array('field' => Form_Helper::build_field($data))); } else { $resp->set_message('Could not load field. Sorry, <a href="#" data-ajax-get data-action="add_field" data-extra-data="ice_cream">try again</a>?'); } } echo $resp->encode_response(); die;
public function destroy() { // poista kommentit Comment::delete_all_from_recipe($this->id); //poista ainesosat Ingredient::delete_from_recipe($this->id); Ingredient::delete_unused(); //poista avainsanat Keyword::delete_junctions($this->id); Keyword::delete_unused(); $query = DB::connection()->prepare("DELETE FROM Recipe WHERE id = :id"); $query->execute(array('id' => $this->id)); }
public function put(Ingredient $ingredient) { if (!$ingredient->hasExpired()) { $this->items[] = $ingredient; } }
<?php require_once '../models/DB.php'; require_once '../models/Ingredient.php'; $ing = new Ingredient(); $ing->name = $_POST['name']; $ing->save($dbh); header("Content-type: text/json"); echo json_encode($ing);
public function __get($var) { if( $var == 'order_item' ) { return Order_Item::getByID($this->order_itemid); } elseif( $var == 'modifier' ) { return Modifier::getByID($this->modifierid); } elseif( $var == 'ingredient' ) { return Ingredient::getByID($this->ingredientid); } else { return $this->$var; } }
<?php require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'trest_init.php'); require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'Sandwich.php'); require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'Ingredient.php'); header('Content-Type: application/json'); $id = @$_GET['id']; $id = (int) $id; if ($id) { $result = Ingredient::find($id); } else { $result = Ingredient::findAll(); } echo json_encode($result);
}); $app->get('/getIngredientByRecette/:recetteId', function ($recetteId) { //renvoi les ingrédients de la recette $ingredient = Ingredient::getIngredientByRecette($recetteId); }); $app->post('/AddIngredient', function () { //Ajoute un ingredient $ingredient = Ingredient::AddIngredient($_POST["nom"], $_POST["prix"], $_POST["unite"]); }); $app->put('/ModifIngredient', function () { //Ajoute un ingredient $ingredient = Ingredient::ModifIngredient($_POST["nom"], $_POST["prix"], $_POST["unite"], $_POST["id"]); }); $app->delete('/DelIngredient', function () { //Ajoute un ingredient $ingredient = Ingredient::DelIngredient($_POST["id"]); }); /*-------------------------------------------------- CATEGORY --------------------------------------------------*/ $app->get('/getCategoryName/:categoryId', function ($categoryId) { //Retourne le nom de la catégorie de l'id passé en paramètre $category = Categorie::getCategoryName($categoryId); }); $app->get('/getCategoryID/:categoryName', function ($categoryName) { //Retourne l'id de la catégorie avec pour nom celui passé en paramètre $category = Categorie::getCategoryId($categoryId); }); $app->get('/getAllCategory', function () { //renvoi toutes les catégories $categorie = Categorie::getAllCategory();
/** * @param Ingredient $ingredient The ingredient object to add. */ protected function doAddIngredient($ingredient) { $this->collIngredients[] = $ingredient; $ingredient->setRecipe($this); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Ingredient::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
function replaceName($str, $type) { $itms = array(); foreach( $str as $splt ) { if( $splt != null && $splt != '' ) { array_push($itms, trim($splt)); } } $ints = array(); foreach( $itms as $name ) { switch( $type ) { case 0: $cat = Category::getByName($name); if( $cat instanceof Category ) { array_push($ints, $cat->categoryid); } break; case 1: $ing = Ingredient::getByName($name); if( $ing instanceof Ingredient ) { array_push($ints, $ing->ingredientid); } break; case 2: $char = Characteristic::getByCharacteristic($name); if( $char instanceof Characteristic ) { array_push($ints, $char->characteristicid); } break; default: break; } } return $ints; }
public static function add($name, $isVeg, $isAll, $side) { global $db; $ing = Ingredient::getByName($name); if( $ing ) { return $ing; } else { $ing = new Ingredient(null, $name, $isVeg, $isAll, $side); return $ing->save(); } }