?> </th><th><?php te("S/N"); ?> </th> </tr> </thead> <tbody> <?php while ($ir = $sth->fetch(PDO::FETCH_ASSOC)) { if ($ir['islinked']) { $cls = "class='bld'"; } else { $cls = ""; } $x = attrofstatus((int) $ir['status'], $dbh); $attr = $x[0]; $statustxt = $x[1]; echo "<tr><td><input name='itlnk[]' value='" . $ir['id'] . "' "; if ($ir['islinked']) { echo " checked "; } echo " type='checkbox'></td>" . "<td nowrap {$cls}><span {$attr}> </span><a title='Edit item {$ir['id']} in a new window' " . "target=_blank href='{$scriptname}?action=edititem&id=" . $ir['id'] . "'><div class='editid'>"; echo $ir['id']; echo "</div></a></td>" . "<td {$cls}>" . $ir['typedesc'] . "</td>" . "<td {$cls}>" . $agents[$ir['manufacturerid']]['title'] . " </td>" . "<td {$cls}>" . $ir['model'] . " </td>" . "<td {$cls}>" . $ir['label'] . " </td>" . "<td {$cls}>" . $ir['dnsname'] . " </td>" . "<td {$cls}>" . $ir['username'] . " </td>" . "<td {$cls}>" . $ir['sn'] . " </td></tr>\n"; } ?> </tbody> </table> </div>
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}> </span> <a href='{$scriptname}?action=edititem&id={$rackrow[$rr][$depth]}'>" . $items[$rackrow[$rr][$depth]]['agtitle'] . " " . $items[$rackrow[$rr][$depth]]['model'] . " " . " [ID:{$itemid}]" . $mixlabel . "</a>"; }
/* 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}> </span>" . "<span><a class='editid' title='Edit' href='?action=edititem&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>"; } else {
te("Description"); ?> </th></tr> <?php $i = 0; while ($r = $sth->fetch(PDO::FETCH_ASSOC)) { $i++; $dbid = $r['id']; if ($dbid > $internaltypes) { //change this to remove X from internal types echo "\n<tr><td title='Delete'><a href='javascript:delconfirm(\"{$itype}\",\"{$scriptname}?action={$action}&deltype={$dbid}\");'>" . "<img src='images/delete.png' border=0></a></td>"; } else { echo "\n\n<tr><td title='internal type ({$dbid}), cannot delete'></td>"; } $x = attrofstatus($dbid, $dbh); $attr = $x[0]; $statustxt = $x[1]; echo "<td nowrap><input type=hidden name='id[]' value='" . $r['id'] . "' readonly size=3>\n"; echo "<span {$attr}> </span><input size=15 maxlen=20 type=text name='statusdesc[]' value=\"" . $r['statusdesc'] . "\"></td>\n"; echo "</tr>\n\n"; } //empty line to add new items at bottom echo "<tr><td><input type=hidden name='id[]' value='new' readonly size=3>New:</td>\n"; echo "<td><input size=15 maxlen=20 type=text name='statusdesc[]' ></td>\n"; ?> <tr><td colspan=2><button type="submit"><img src="images/save.png" alt="Save" > <?php te("Save"); ?> </button></td></tr>