/** * Check if the recipe ingredient qty is available in the * ridge or not. * * @param Ingredient $contestant [description] * @return boolean return TRUE if qty can be met, FALSE if not */ public function isSatisfiedBy($contestant) { $qty_available = 0; if ($this->usable_ingredients->count()) { if ($this->usable_ingredients->get($contestant->getName())) { $qty_available = $this->usable_ingredients->get($contestant->getName())->getQty(); } } if ($contestant->getQty() <= $qty_available) { return TRUE; } $this->addMessage('INGREDIENTS', 'Required amount of ingredients is not available in the fridge.'); return FALSE; }
/** * [getLines description] * @param [type] $buffer [description] * @return [type] [description] */ function getLines($buffer) { $lines = new SplFixedArray($buffer->count()); for ($buffer->rewind(); $buffer->valid(); $buffer->next()) { $lines[$buffer->key()] = getCoords($buffer->current()); } return $lines; }
/** * [renderProduct description] * @param [type] $products [description] * @param [type] $item_number [description] * @return [type] [description] */ function renderProduct($products, $item_number, $parent_class, $chill_class) { $html = ""; $length = $products->count(); $newDays = 86400 * 3; foreach ($products as $key => $item) { if ($key % $item_number == 0) { $html .= '<div class="' . $parent_class . '">'; } $html .= '<div class="no-margin product-item-holder hover ' . $chill_class . '">'; $html .= '<div class="product-item">'; if (time() - strtotime($item->created_at) <= $newDays) { $html .= '<div class="ribbon blue"><span>new!</span></div>'; } if ($item->price_bestsaller != 0) { $html .= '<div class="ribbon green"><span>bestseller</span></div>'; } else { $html .= '<div class="ribbon red"><span>sale</span></div>'; } $html .= '<div class="image">'; $html .= HTML::image("lib/images/blank.gif", null, array('data-echo' => asset($item->image))); $html .= '</div>'; $html .= '<div class="body">'; if ($item->price_bestsaller != 0) { $html .= '<div class="label-discount green">-' . $item->price_bestsaller . '% sale</div>'; } elseif ($item->price_sale != 0) { $html .= '<div class="label-discount green">-' . $item->price_sale . '% sale</div>'; } $html .= '<div class="title">'; $html .= HTML::link('/product/details/' . $item->slug, $item->name, array('alt' => $item->slug)); $html .= '</div>'; // $html .= '<div class="brand">acer</div>'; $html .= '</div>'; $html .= '<div class="prices">'; if ($item->price_bestsaller != 0) { if ($item_number == 3) { $html .= '<div class="price-current text-right">' . adddotstring(round($item->price - $item->price * $item->price_bestsaller / 100)) . '<sup>VND</sup></div>'; $price = round($item->price - $item->price * $item->price_bestsaller / 100); } else { $html .= '<div class="price-prev">' . adddotstring($item->price) . '<sup>VND</sup></div>'; $html .= '<div class="price-current pull-right">' . adddotstring(round($item->price - $item->price * $item->price_bestsaller / 100)) . '<sup>VND</sup></div>'; $price = round($item->price - $item->price * $item->price_bestsaller / 100); } } elseif ($item->price_sale != 0) { $html .= '<div class="price-prev">' . adddotstring($item->price) . '<sup>VND</sup></div>'; $html .= '<div class="price-current pull-right">' . adddotstring(round($item->price - $item->price * $item->price_sale / 100)) . '<sup>VND</sup></div>'; $price = round($item->price - $item->price * $item->price_sale / 100); } else { $html .= '<div class="price-current pull-right">' . adddotstring($item->price) . '<sup>VND</sup></div>'; $price = $item->price; } $html .= '</div>'; $html .= '<div class="hover-area">'; $html .= '<div class="add-cart-button">'; $html .= '<a href="javascript: addtocart( ' . "'" . $item->slug . "'" . ',' . $price . ' )" class="le-button">add to cart</a>'; $html .= '</div>'; $html .= '<div class="wish-compare">'; $html .= '<a class="btn-add-to-wishlist" href="javascript: wishlist()">add to wishlist</a>'; $html .= '<a class="btn-add-to-compare" href="javascript: compare()">compare</a>'; $html .= '</div>'; $html .= '</div>'; $html .= '</div>'; $html .= '</div>'; if ($key % $item_number == $item_number - 1 || $key == $length - 1) { $html .= '</div>'; } } $html .= '<div class="clearfix"></div>'; return $html; }