function get_items() { global $smarty, $fpdo; $oItem = new Item($fpdo); $items_results = $oItem->getAll(); $smarty->assign('items', $items_results); $smarty->display('showitems.tpl'); }
function test_deleteAll() { $name = "Gold Liberty Dollar"; $name2 = "Bronze My Little Pony: Applejack"; $test_Item = new Item(null, $name); $test_Item->save(); $test_Item2 = new Item(null, $name2); $test_Item2->save(); Item::deleteAll(); $result = Item::getAll(); $this->assertEquals([], $result); }
static function find($found_id) { $found_item = null; $items = Item::getAll(); foreach ($items as $item) { $id = $item->getId(); if ($id == $found_id) { $found_item = $item; } } return $found_item; }
function test_deleteAll() { //Arrange $name = "Hello Kitty"; $name2 = "Pokemon"; $test_Item = new Item($name); $test_Item->save(); $test_Item2 = new Item($name2); $test_Item2->save(); //Act Item::deleteAll(); $result = Item::getAll(); //Assert $this->assertEquals([], $result); }
function testDeleteAll() { //Arrange $collection_name = "Cool stuff"; $test_collection = new Collection($collection_name); $test_collection->save(); $test_collection_id = $test_collection->getId(); $name = "Hello Kitty"; $name2 = "Pokemon"; $test_item = new Item($name, $test_collection_id); $test_item->save(); $test_item2 = new Item($name2, $test_collection_id); $test_item2->save(); //Act Item::deleteAll(); $result = Item::getAll(); //Assert $this->assertEquals([], $result); }
Debug::enable(); $app = new Silex\Application(); // Set Silex debug mode in $app object $app['debug'] = true; $server = 'mysql:host=localhost;dbname=inventory'; $username = '******'; $password = '******'; $DB = new PDO($server, $username, $password); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get('/', function () use($app) { return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll())); }); $app->post('/collection', function () use($app) { $collection = new Collection($_POST['name']); $collection->save(); return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll())); }); $app->post('/delete_collections', function () use($app) { Collection::deleteAll(); return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll())); }); $app->post('/item', function () use($app) { $item = new Item($_POST['name']); $item->save(); return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll())); }); $app->post('/delete_items', function () use($app) { Item::deleteAll(); return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll())); }); return $app;
if ($storeid) { $store->read($storeid); } include 'inc/widget/error.php'; ?> <form action="" method="post"> <table class="form"> <tr> <td class="label">Nombre:</td> <td> <?php if ($itemid) { echo "<input type='hidden' name='itemid' value='{$itemid}'/><span>{$item->name}, {$item->type}</span>"; } else { $items = Item::getAll("name", ""); echo "<select name='itemid' id='items'>"; echo "<option value=''>-Seleccione-</option>"; foreach ($items as $item) { echo "<option value='{$item->id}'>{$item->name}, {$item->type}</option>"; } echo "</select>"; } ?> </td> </tr> <tr> <td class="label">Cajas:</td> <td><input name="box" type="text" onchange="multiplicar()" id="box" value="" size="20"/> <span class="mandatory">*</span> </td> </tr> <tr>
function testDelete() { //Arrange $description = "Pliny the Elder"; $cost = 5.0; $id = null; $test_item = new Item($description, $cost, $id); $test_item->save(); $description2 = "Lagunitas IPA"; $cost2 = 7.0; $test_item2 = new Item($description2, $cost2, $id); $test_item2->save(); //Act $test_item->delete(); $result = Item::getAll(); //Assert $this->assertEquals($test_item2, $result[0]); }
function testDeleteAssociatedItems() { $collection_name = "Star Wars Cards"; $test_collection = new Collection($collection_name); $test_collection->save(); $collection_id = $test_collection->getId(); $item_name = "Boba Fett"; $test_item = new Item($item_name, $collection_id); $test_item->save(); $item_name2 = "Slave 1"; $test_item2 = new Item($item_name2, $collection_id); $test_item2->save(); // Act $test_collection->deleteAssociatedItems(); // Assert $this->assertEquals([], Item::getAll()); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Item.php"; $app = new Silex\Application(); $server = 'mysql:host=localhost;dbname=inventory'; $username = '******'; $password = '******'; $DB = new PDO($server, $username, $password); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig'); }); $app->post("/delete_items", function () use($app) { Item::deleteAll(); return $app['twig']->render('index.html.twig'); }); $app->post("/inventory", function () use($app) { $item = new Item("id", $_POST['name']); $item->save(); return $app['twig']->render("index.html.twig", array("item" => Item::getAll())); }); return $app;
$page = new Page(0, "OrderUp - Reporting"); $tmpl = new Template(); $userid = $_SESSION['userid']; //set breadcrumb $report_type = isset($_GET['report']) ? $_GET['report'] : null; $bc = new Breadcrumb('report', $report_type); $tmpl->breadcrumb = $bc->path; $tmpl->report_type = $report_type; $page->run(); //get all items $items = array(); $items = Item::getAll(); $tmpl->items = $items; $item_counts = array(); //get all item counts foreach($items as $item) { $item_counts[$item->itemid] = Order_Item::getOrderCount($item->itemid); } $tmpl->item_counts = $item_counts; $order_times = array(); //push active orders
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../vendor/autoload.php"; $app = new Silex\Application(); $server = 'mysql:host=localhost;dbname=market'; $username = '******'; $password = '******'; $DB = new PDO($server, $username, $password); $app->register(new Silex\Prodiver\TwigServerProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('inventory.html.twig', array('items' => Item::getAll())); });