}
/* The actual query */
//if ( $sWhere == "" ) $sWhere = " WHERE 1=1 ";
//(purchasedate+warrantymonths*30*24*60*60-$t)/(60*60*24) AS remdays,
$sQuery = "\n\t\t  SELECT \n\t\t  items.id AS itemid,\n\t\t  itemtypes.typedesc as typedesc, \n                  agents.title,\n                  items.model as itemmodel,\n                  dnsname,\n                  items.label as itemlabel,\n                  purchasedate,\n                  users.username,\n                  statustypes.statusdesc,\n                  locations.name as locationname,\n                  locareas.areaname,\n                  coalesce(sn,'') || ' ' || coalesce(sn2,'') || ' ' || coalesce(sn3,'') AS serial,\n\t\t\t\t  '' as remdays, warrantymonths, \n                  coalesce(racks.label,'') || ' ' || coalesce(racks.usize,'') || ' ' || coalesce(racks.model,'') AS rackinfo,\n                  (SELECT group_concat( tags.name ,', ') FROM tags,tag2item WHERE tag2item.itemid=items.id AND tags.id=tag2item.tagid) AS taginfo,\n                  (SELECT group_concat( software.stitle ,',') FROM software,item2soft WHERE item2soft.itemid=items.id and software.id=item2soft.softid) AS softinfo,\n                  purchprice,\n                  macs, ipv4, ipv6, remadmip\n                  FROM\n                  items\n\t\t  JOIN itemtypes ON items.itemtypeid=itemtypes.id \n\t\t  JOIN agents ON items.manufacturerid=agents.id\n\t\t  LEFT OUTER JOIN statustypes ON items.status=statustypes.id\n\t\t  JOIN users ON items.userid=users.id\n\t\t  LEFT OUTER JOIN locations ON items.locationid=locations.id\n\t\t  LEFT OUTER JOIN locareas ON items.locareaid=locareas.id\n\t\t  LEFT OUTER JOIN racks ON items.rackid=racks.id\n\t\t  {$sWhere}\n\t\t  {$sOrder}\n\t\t  {$sLimit}\n\t\t  ";
//file_put_contents("/tmp/itlog.txt",$sQuery."\n\n");
$sth = db_execute($dbh, $sQuery);
/*
 * Output
 */
$output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
while ($aRow = $sth->fetch(PDO::FETCH_ASSOC)) {
    $row = array();
    for ($i = 0; $i < count($aColumns); $i++) {
        if ($aColumns[$i] == "itemid") {
            $statusid = getstatusidofitem($aRow['itemid'], $dbh);
            $x = attrofstatus($statusid, $dbh);
            $attr = $x[0];
            $statustxt = $x[1];
            $r = "<div style='width:60px'><span {$attr}>&nbsp;</span>" . "<span><a class='editid' title='Edit' href='?action=edititem&amp;id=" . $aRow['itemid'] . "'>" . $aRow['itemid'] . "</a></span></div>";
            $row[] = $r;
        } elseif ($aColumns[$i] == "remdays") {
            //$remdays=$aRow['remdays'];
            $remdays_r = calcremdays($aRow['purchasedate'], $aRow['warrantymonths']);
            $rdstr = $remdays_r['string'];
            $rd = $remdays_r['days'];
            $row[] = "<small><div title='{$rd}'>" . $rdstr . "</div></small>";
            // title attribute used for sorting
        } elseif ($aColumns[$i] == "purchasedate") {
            if (strlen($aRow[$aColumns[$i]])) {
                $row[] = "<span title='{$aRow[$aColumns[$i]]}'>" . date($dateparam, (int) $aRow[$aColumns[$i]]) . "</span>";
Esempio n. 2
0
function printitemcell($rr, $depth)
{
    global $rackrow, $items, $scriptname, $_GET;
    global $dbh;
    $dns = $items[$rackrow[$rr][$depth]]['dnsname'];
    $label = $items[$rackrow[$rr][$depth]]['label'];
    $dr = explode(".", $dns);
    if (count($dr)) {
        $dr = $dr[0];
    }
    $itemid = $items[$rackrow[$rr][$depth]]['id'];
    $mixlabel = " ";
    if (strlen($label)) {
        $mixlabel = " {$label} ";
    }
    if (strlen($dr)) {
        $mixlabel .= " [DNS:{$dr}]";
    }
    $sid = getstatusidofitem($itemid, $dbh);
    $x = attrofstatus($sid, $dbh);
    $attr = $x[0];
    $statustxt = $x[1];
    return "<span {$attr}>&nbsp;</span>&nbsp;<a href='{$scriptname}?action=edititem&amp;id={$rackrow[$rr][$depth]}'>" . $items[$rackrow[$rr][$depth]]['agtitle'] . " " . $items[$rackrow[$rr][$depth]]['model'] . " " . " [ID:{$itemid}]" . $mixlabel . "</a>";
}