1<?php 2 3/** 4 * Observium 5 * 6 * This file is part of Observium. 7 * 8 * @package observium 9 * @subpackage webui 10 * @author Adam Armstrong <adama@observium.org> 11 * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited 12 * 13 */ 14 15$graph_type = "printersupply_usage"; 16 17$supplies = dbFetchRows("SELECT * FROM `printersupplies` WHERE `device_id` = ? ORDER BY `supply_type`", array($device['device_id'])); 18 19if (count($supplies)) 20{ 21 $box_args = array('title' => 'Printer Supplies', 22 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'printing')), 23 'icon' => $config['icon']['printersupply'], 24 ); 25 26 echo generate_box_open($box_args); 27 28 echo('<table class="table table-condensed table-striped">'); 29 30 foreach ($supplies as $supply) 31 { 32 $percent = round($supply['supply_value'], 0); 33 34 if ($supply['supply_colour'] != '') 35 { 36 $background = toner_to_colour($supply['supply_colour'], $percent); 37 } else { 38 $background = toner_to_colour($supply['supply_descr'], $percent); 39 } 40 $background_percent = get_percentage_colours($percent - 100); 41 42 $graph_array = array(); 43 $graph_array['height'] = "100"; 44 $graph_array['width'] = "210"; 45 $graph_array['to'] = $config['time']['now']; 46 $graph_array['id'] = $supply['supply_id']; 47 $graph_array['type'] = $graph_type; 48 $graph_array['from'] = $config['time']['day']; 49 $graph_array['legend'] = "no"; 50 51 $link_array = $graph_array; 52 $link_array['page'] = "graphs"; 53 unset($link_array['height'], $link_array['width'], $link_array['legend']); 54 $link = generate_url($link_array); 55 56 $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $supply['supply_descr']); 57 58 $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; 59 //$graph_array['style'][] = 'margin-top: -6px'; 60 61 $minigraph = generate_graph_tag($graph_array); 62 63 if ($percent < 0) 64 { 65 $percent_text = 'Unknown'; 66 } 67 else if ($percent == 1 && $supply['supply_capacity'] < 0) 68 { 69 $percent_text = 'Some space'; 70 } 71 else if ($percent <= 0 && $supply['supply_capacity'] <= 0) 72 { 73 $percent_text = 'Unknown'; 74 } else { 75 $percent_text = $percent.'%'; 76 } 77 78 echo('<tr class="'.$background_percent['class'].'"> 79 <td class="state-marker"></td> 80 <td class="entity">'.overlib_link($link, $supply['supply_descr'], $overlib_content)."</td> 81 <td style='width: 90px;'>".overlib_link($link, $minigraph, $overlib_content)."</td> 82 <td style='width: 200px;'>".overlib_link($link, print_percentage_bar(400, 20, $percent, $percent_text, 'ffffff', $background['right'], NULL, "ffffff", $background['left']), $overlib_content)."</td> 83 </tr>"); 84 } 85 86 echo("</table>"); 87 echo generate_box_close(); 88} 89 90unset ($supply_rows); 91 92// EOF 93