<?php namespace tatt; require_once "tatt/webcommon.php"; $item_id = Item::create('book1', 1, 1); $item = new Item($item_id); $item->set_location("Bobs House"); $item->set_last_accounted_for("2011-11-01"); $item->set_photo("EMPTY"); $item->update_last_accounted_for(); $item->set_due_date("2011-11-01"); $item->set_checked_out_by(4); $check_item = new Item($item_id); var_dump($check_item); $page->assign('page_title','test2'); $page->display('test2.tpl'); ?>
$auth->require_login(); if(!isset($_GET['id']) || !is_numeric($_GET['id'])) redirect_to_url('/items/view_items.php'); //Redirect to inventory page. $item_id = (int)$_GET['id']; $item = new Item($item_id); if($item->get_owner_id() != $user_id) redirect_to_url('/items/view_items.php'); //Redirect to inventory page. if(isset($_POST['name'])){ //form was submitted $name = $db->escape_string($_POST['name']); $location = $db->escape_string($_POST['location']); $item->set_name($name); $item->set_location($location); if(isset($_POST['attributes'])){ $attributes = $_POST['attributes']; foreach($attributes as $attribute){ $attribute_id = (int)$attribute['id']; $value = $db->escape_string($attribute['value']); //echo "ID: $attribute_id V: $value"; $new_attribute = new Attribute($item_id, $attribute_id); $new_attribute->set_value($value); } } redirect_to_url("/items/item.php?id=$item_id"); } //TODO Fix bug where all available attributes won't show if only a few were previously set. (Do this by creating attribute objects in Item object when no value set. Just make the value NULL...)