function printRackThumbImage($rack_id, $scale = 1) { $rackData = spotEntity('rack', $rack_id); amplifyCell($rackData); markupObjectProblems($rackData); global $rtwidth; $offset[0] = 3; $offset[1] = 3 + $rtwidth[0]; $offset[2] = 3 + $rtwidth[0] + $rtwidth[1]; $totalheight = 3 + 3 + $rackData['height'] * 2; $totalwidth = $offset[2] + $rtwidth[2] + 3; $img = @imagecreatetruecolor($totalwidth, $totalheight) or die("Cannot Initialize new GD image stream"); # It was measured, that caching palette in an array is faster, than # calling colorFromHex() multiple times. It matters, when user's # browser is trying to fetch many minirack images in parallel. $color = array('F' => colorFromHex($img, '8fbfbf'), 'A' => colorFromHex($img, 'bfbfbf'), 'U' => colorFromHex($img, 'bf8f8f'), 'T' => colorFromHex($img, '408080'), 'Th' => colorFromHex($img, '80ffff'), 'Tw' => colorFromHex($img, '804040'), 'Thw' => colorFromHex($img, 'ff8080'), 'black' => colorFromHex($img, '000000'), 'gray' => colorFromHex($img, 'c0c0c0')); $border_color = $rackData['has_problems'] == 'yes' ? $color['Thw'] : $color['gray']; imagerectangle($img, 0, 0, $totalwidth - 1, $totalheight - 1, $color['black']); imagerectangle($img, 1, 1, $totalwidth - 2, $totalheight - 2, $border_color); imagerectangle($img, 2, 2, $totalwidth - 3, $totalheight - 3, $color['black']); for ($unit_no = 1; $unit_no <= $rackData['height']; $unit_no++) { for ($locidx = 0; $locidx < 3; $locidx++) { $colorcode = $rackData[$unit_no][$locidx]['state']; if (isset($rackData[$unit_no][$locidx]['hl'])) { $colorcode = $colorcode . $rackData[$unit_no][$locidx]['hl']; } imagerectangle($img, $offset[$locidx], 3 + ($rackData['height'] - $unit_no) * 2, $offset[$locidx] + $rtwidth[$locidx] - 1, 3 + ($rackData['height'] - $unit_no) * 2 + 1, $color[$colorcode]); } } if ($scale > 1) { $resized = imagecreate($totalwidth * $scale, $totalheight * $scale); imagecopyresized($resized, $img, 0, 0, 0, 0, $totalwidth * $scale, $totalheight * $scale, $totalwidth, $totalheight); imagedestroy($img); $img = $resized; } imagepng($img); imagedestroy($img); }
function renderGridForm($rack_id, $filter, $header, $submit, $state1, $state2) { $rackData = spotEntity('rack', $rack_id); amplifyCell($rackData); $filter($rackData); markupObjectProblems($rackData); // Render the result whatever it is. // Main layout. echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; echo "<tr><td colspan=2 align=center><h1>{$rackData['name']}</h1></td></tr>\n"; // Left column with information portlet. echo "<tr><td class=pcleft height='1%' width='50%'>"; renderRackInfoPortlet($rackData); echo "</td>\n"; echo "<td class=pcright>"; // Grid form. startPortlet($header); addJS('js/racktables.js'); echo "<center>\n"; echo "<table class=rack border=0 cellspacing=0 cellpadding=1>\n"; echo "<tr><th width='10%'> </th>"; echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('{$rack_id}', '0', {$rackData['height']})\">Front</a></th>"; echo "<th width='50%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('{$rack_id}', '1', {$rackData['height']})\">Interior</a></th>"; echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('{$rack_id}', '2', {$rackData['height']})\">Back</a></th></tr>\n"; printOpFormIntro('updateRack'); markupAtomGrid($rackData, $state2); renderAtomGrid($rackData); echo "</table></center>\n"; echo "<br><input type=submit name=do_update value='{$submit}'></form><br><br>\n"; finishPortlet(); echo "</td></tr></table>\n"; }
function updateRackProblems() { $rackData = spotEntity('rack', getBypassValue()); amplifyCell($rackData); applyRackProblemMask($rackData); markupObjectProblems($rackData); if (processGridForm($rackData, 'F', 'U')) { showSuccess("Saved successfully"); } else { showNotice("Nothing saved"); } }