public function statusItemsJsonAction($status_id)
 {
     $equipment = Equipment_Status::getEquipment($status_id);
     $items = array();
     foreach ($equipment as $item) {
         if ($item->getId() > 0) {
             $item_data = array('id' => $item->getId(), 'asset_id' => $item->getAssetId(), 'category' => $item->getCategory()->getName(), 'status' => $item->getStatus()->getName(), 'published' => $item->isPublished() ? 'Yes' : 'No', 'active' => $item->isActive() ? 'Yes' : 'No');
             $items[] = $item_data;
         }
     }
     echo json_encode($items);
 }
         case 'make_private':
             $sql = 'UPDATE ' . EQUIPMENT_STATUS_TABLE . ' SET ispublic=0 ' . ' WHERE status_id IN (' . implode(',', db_input($_POST['ids'])) . ')';
             if (db_query($sql) && ($num = db_affected_rows())) {
                 if ($num == $count) {
                     $msg = 'Selected status made PRIVATE';
                 } else {
                     $warn = "{$num} of {$count} selected status made PRIVATE";
                 }
             } else {
                 $errors['err'] = 'Unable to disable selected status PRIVATE';
             }
             break;
         case 'delete':
             $i = 0;
             foreach ($_POST['ids'] as $k => $v) {
                 if (($c = Equipment_Status::lookup($v)) && $c->delete()) {
                     $i++;
                 }
             }
             if ($i == $count) {
                 $msg = 'Selected Equipment status deleted successfully';
             } elseif ($i > 0) {
                 $warn = "{$i} of {$count} selected status deleted";
             } elseif (!$errors['err']) {
                 $errors['err'] = 'Unable to delete selected Equipment status';
             }
             break;
         default:
             $errors['err'] = 'Unknown action/command';
     }
 }
 /**
  * This function is overruning its original scope, but it seems logical
  * to put that functionality there.  
  * It finds equipment associated with the supplied ticket id, checks if this
  * ticket is the only one associated with the equipment and will reset
  * equipment status to its baseline.
  * 
  * @param int $ticket_id Ticket id to lookup
  * @param int $eq_id Optional, equipment id to ignore, if this id is 
  * associated with the ticket, it will not be reset.  This is used when
  * a ticket is updated and new status is selected for existing equipment. 
  * @param bool $force Whether to force status reset.  This is used when new
  * equipment is selected during ticket update.  If there is only one ticket
  * associated with this equipment, the equipment status will be reset.
  * @return void
  */
 public static function onCloseTicket($ticket_id, $eq_id = 0, $force = false)
 {
     $eq = self::findByTicket($ticket_id);
     if ($eq) {
         if ($eq->getId() == $eq_id) {
             return;
         }
         $open_tickets = self::getOpenTickets($eq->getId());
         $do_close = count($open_tickets) == 0;
         if (!$do_close) {
             $do_close = $force && count($open_tickets) == 1 && $open_tickets[0] == $ticket_id;
         }
         if ($do_close) {
             $b_status = Equipment_Status::getBaselineStatus();
             if ($b_status) {
                 $eq->setStatus_Id($b_status->getId());
                 $eq->save();
             }
         }
     }
 }
    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';
$category = null;
$eq_status = null;
if ($_REQUEST['cid'] && !($category = Equipment_Category::lookup($_REQUEST['cid']))) {
    $errors['err'] = 'Unknown or invalid equipment category';
}
if ($_REQUEST['status_id'] && !($eq_status = Equipment_Status::lookup($_REQUEST['status_id']))) {
    $errors['err'] = 'Unknown or invalid equipment status';
}
$inc = 'equipment_lists.inc.php';
//Equipment landing page.
if ($category && $_REQUEST['a'] != 'search') {
    $inc = 'equipment_list.inc.php';
} else {
    if ($eq_status) {
        $inc = 'equipment_status_list.inc.php';
    }
}
$nav->setTabActive('equipment');
require_once STAFFINC_DIR . 'header.inc.php';
require_once EQUIPMENT_STAFFINC_DIR . $inc;
require_once STAFFINC_DIR . 'footer.inc.php';