$db->query($query); if ($db->next_record()) { alloc_redirect($TPL["url_alloc_item"] . "itemID=" . $db->f("itemID")); } } else { //open the index $index = new Zend_Search_Lucene(ATTACHMENTS_DIR . 'search/item'); $query = Zend_Search_Lucene_Search_QueryParser::parse($needle); $hits = $index->find($needle); $TPL["index_count"] = $index->count(); $TPL["hits_count"] = count($hits); $p =& get_cached_table("person"); foreach ($hits as $hit) { $d = $hit->getDocument(); $item = new item(); $item->set_id($d->getFieldValue('id')); $item->select(); $row = array(); $row["idx"] = $hit->id; $author = $item->get_value("itemAuthor"); $author and $author = " by " . $author; $row["title"] = $item->get_id() . " " . $item->get_link() . $author; $row["score"] = sprintf('%d%%', $hit->score * 100); $row["desc"] = page::htmlentities($d->getFieldValue('desc')); // get availability of loan $db2 = new db_alloc(); $query = prepare("SELECT * FROM loan WHERE itemID = %d AND dateReturned='0000-00-00'", $item->get_id()); $db2->query($query); if ($db2->next_record()) { $loan = new loan(); $loan->read_db_record($db2);
} //so that the user can edit the item later $TPL["personID"] = $current_user->get_id(); // item types $itemType = new meta("itemType"); $TPL["itemTypes"] = page::select_options($itemType->get_assoc_array("itemTypeID", "itemTypeID"), $item->get_value("itemType")); // setup item list (for removals) $item_list = array(); $db = new db_alloc(); $db->query("SELECT * FROM item ORDER BY itemName"); while ($db->next_record()) { $item = new item(); $item->read_db_record($db); $item_list[$item->get_id()] = $item->get_value('itemName'); } $TPL["item_list"] = page::select_options($item_list, ""); if ($_POST["edit_items"]) { $item = new item(); $item->set_id($_POST["itemID"][0]); $item->select(); if (count($_POST["itemID"]) < 1) { alloc_error("You Must Select An Item"); } else { if (count($_POST["itemID"]) > 1) { alloc_error("Can Only Edit 1 Item At A Time"); } $TPL["edit_options"] = "<table><tr>\n" . " <td>Name: </td>\n" . " <td colspan=\"2\"><input size=\"40\" type=\"text\" name=\"update_itemName\" value=\"" . $item->get_value("itemName") . "\"></td>\n" . "</tr><tr>\n" . " <td>Notes: </td>\n" . " <td colspan=\"2\"><input size=\"40\" type=\"text\" name=\"update_itemNotes\" value=\"" . $item->get_value("itemNotes") . "\"></td>\n" . "</tr><tr>\n" . " <td>Type: </td>\n" . " <td><select name=\"update_itemType\" value=\"" . $item->get_value("itemType") . "\">" . page::select_options($itemType->get_assoc_array("itemTypeID", "itemTypeID"), $item->get_value("itemType")) . " </select>" . " <input type=\"hidden\" name=\"update_itemID\" value=\"" . $item->get_id() . "\"></td>" . " <td align=\"right\">" . ' <button type="submit" name="update_item" value="1" class="save_button">Save Changes<i class="icon-ok-sign"></i></button>' . " </td>\n" . "</tr><td colspan=\"3\"><hr></td></tr>\n" . "</tr></table>\n"; } } $TPL["main_alloc_title"] = "Edit Items - " . APPLICATION_NAME; include_template("templates/addItemM.tpl");