/*********************************************************************
    equipment_item.php
 
    Alex P <*****@*****.**>
    Copyright (c)  2013 XpressTek
    http://www.xpresstek.net

    Released under the GNU General Public License WITHOUT ANY WARRANTY.
    See LICENSE.TXT for details.

    vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require 'staff.inc.php';
require_once EQUIPMENT_INCLUDE_DIR . 'class.equipment.php';
$equipment = $category = null;
if ($_REQUEST['id'] && !($equipment = Equipment::lookup($_REQUEST['id']))) {
    $errors['err'] = 'Unknown or invalid equipment';
}
if ($_REQUEST['cid'] && !$equipment && !($category = Equipment_Category::lookup($_REQUEST['cid']))) {
    $errors['err'] = 'Unknown or invalid equipment category';
}
if ($_POST) {
    $errors = array();
    switch (strtolower($_POST['do'])) {
        case 'create':
        case 'add':
            if ($equipment = Equipment::add($_POST, $errors)) {
                $msg = 'Equipment added successfully';
            } elseif (!$errors['err']) {
                $errors['err'] = 'Unable to add Equipment. Try again!';
            }