コード例 #1
0
 function testIngredientExistence()
 {
     $ingredient = new Ingredient(7);
     $this->assertTrue($ingredient->exists());
     $this->assertTrue(!empty($ingredient->name()));
     $this->assertTrue(!empty($ingredient->unit()));
 }
コード例 #2
0
ファイル: ProductionIngredient.php プロジェクト: fagray/fposs
 /**
  * [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;
 }
コード例 #3
0
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);
}
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 /**
  * 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');
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
 private static function set_product_ingredients($product, $ingredients)
 {
     foreach ($ingredients as $ingredient_name) {
         if ($ingredient_name != 'empty') {
             $product->ingredients[] = Ingredient::findByName($ingredient_name);
         }
     }
 }
コード例 #10
0
 public function run()
 {
     DB::table('ingredients')->delete();
     Ingredient::create(["nom" => "sel"]);
     Ingredient::create(["nom" => "poivre"]);
     Ingredient::create(["nom" => "farine"]);
     Ingredient::create(["nom" => "levure"]);
 }
コード例 #11
0
 /**
  * @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;
 }
コード例 #12
0
ファイル: InventoryController.php プロジェクト: fagray/fposs
 /**
  * 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);
 }
コード例 #13
0
ファイル: BaseController.php プロジェクト: fagray/fposs
 /**
  * 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);
 }
コード例 #14
0
 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");
     }
 }
コード例 #15
0
 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]);
     }
 }
コード例 #16
0
ファイル: ReportsController.php プロジェクト: fagray/fposs
 /**
  * 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);
 }
コード例 #17
0
 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 />";
     }
 }
コード例 #18
0
ファイル: Ingredient.php プロジェクト: nickparker88/capstone
		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);
		}
コード例 #19
0
ファイル: SettingsController.php プロジェクト: fagray/fposs
 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);
 }
コード例 #20
0
ファイル: add_field.php プロジェクト: TrevorMW/SoftServer2.0
<?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;
コード例 #21
0
ファイル: recipe.php プロジェクト: emivo/Tsoha-Bootstrap
 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));
 }
コード例 #22
0
ファイル: Fridge.php プロジェクト: y2khjh/test1
 public function put(Ingredient $ingredient)
 {
     if (!$ingredient->hasExpired()) {
         $this->items[] = $ingredient;
     }
 }
コード例 #23
0
<?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);
コード例 #24
0
ファイル: Customization.php プロジェクト: rockerest/capstone
		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;
			}
		}
コード例 #25
0
<?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);
コード例 #26
0
ファイル: index.php プロジェクト: juliobasito/videtonfrigo
});
$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();
コード例 #27
0
ファイル: BaseRecipe.php プロジェクト: keneanung/gw2spidy
 /**
  * @param	Ingredient $ingredient The ingredient object to add.
  */
 protected function doAddIngredient($ingredient)
 {
     $this->collIngredients[] = $ingredient;
     $ingredient->setRecipe($this);
 }
コード例 #28
0
 /**
  * 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;
 }
コード例 #29
0
ファイル: AddItem.php プロジェクト: rockerest/capstone
	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;
	}
コード例 #30
0
ファイル: Ingredient.php プロジェクト: rockerest/capstone
		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();
			}
		}